dev.fitko.fitconnect.api.config.http.ProxyConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of client Show documentation
Show all versions of client Show documentation
Library that provides client access to the FIT-Connect api-endpoints for sending, subscribing and
routing
The newest version!
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;
}
}