All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.fitko.fitconnect.api.config.http.ProxyConfig Maven / Gradle / Ivy

Go to download

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;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy