dev.fitko.fitconnect.api.config.http.ProxyConfig Maven / Gradle / Ivy
package dev.fitko.fitconnect.api.config.http;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.net.InetSocketAddress;
import java.net.Proxy;
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProxyConfig {
@Builder.Default
private String host = "";
@Builder.Default
private Integer port = 0;
@Builder.Default
private ProxyAuth basicAuth = new ProxyAuth();
public boolean isProxySet() {
return (port != null && port > 0) && (host != null && !host.isBlank());
}
public boolean hasBasicAuthentication() {
return basicAuth.getUsername() != null && basicAuth.getPassword() != null;
}
public Proxy getHttpProxy() {
return isProxySet() ? new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port)) : Proxy.NO_PROXY;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy