Search in sources :

Example 1 with ProxyInfoBuilder

use of com.blackducksoftware.integration.hub.proxy.ProxyInfoBuilder in project hub-detect by blackducksoftware.

the class DetectConfiguration method getHubProxyInfo.

public ProxyInfo getHubProxyInfo() throws DetectUserFriendlyException {
    final ProxyInfoBuilder proxyInfoBuilder = new ProxyInfoBuilder();
    proxyInfoBuilder.setHost(hubProxyHost);
    proxyInfoBuilder.setPort(hubProxyPort);
    proxyInfoBuilder.setUsername(hubProxyUsername);
    proxyInfoBuilder.setPassword(hubProxyPassword);
    proxyInfoBuilder.setNtlmDomain(hubProxyNtlmDomain);
    proxyInfoBuilder.setNtlmWorkstation(hubProxyNtlmWorkstation);
    ProxyInfo proxyInfo = ProxyInfo.NO_PROXY_INFO;
    try {
        proxyInfo = proxyInfoBuilder.build();
    } catch (final IllegalStateException e) {
        throw new DetectUserFriendlyException(String.format("Your proxy configuration is not valid: %s", e.getMessage()), e, ExitCodeType.FAILURE_PROXY_CONNECTIVITY);
    }
    return proxyInfo;
}
Also used : ProxyInfo(com.blackducksoftware.integration.hub.proxy.ProxyInfo) DetectUserFriendlyException(com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendlyException) ProxyInfoBuilder(com.blackducksoftware.integration.hub.proxy.ProxyInfoBuilder)

Example 2 with ProxyInfoBuilder

use of com.blackducksoftware.integration.hub.proxy.ProxyInfoBuilder in project hub-fortify-ssc-integration-service by blackducksoftware.

the class RestConnectionHelper method getProxyInfo.

/**
 * Return the proxy info based on the configuration
 *
 * @param serverConfig
 * @return
 * @throws EncryptionException
 * @throws IllegalArgumentException
 */
private static ProxyInfo getProxyInfo(final HubServerConfig serverConfig) throws EncryptionException, IllegalArgumentException {
    if (!StringUtils.isEmpty(serverConfig.getProxyInfo().getHost())) {
        final ProxyInfoBuilder proxyInfoBuilder = new ProxyInfoBuilder();
        proxyInfoBuilder.setHost(serverConfig.getProxyInfo().getHost());
        proxyInfoBuilder.setPort(serverConfig.getProxyInfo().getPort());
        proxyInfoBuilder.setUsername(serverConfig.getProxyInfo().getUsername());
        proxyInfoBuilder.setPassword(serverConfig.getProxyInfo().getDecryptedPassword());
        proxyInfoBuilder.setNtlmDomain(serverConfig.getProxyInfo().getNtlmDomain());
        proxyInfoBuilder.setNtlmWorkstation(serverConfig.getProxyInfo().getNtlmWorkstation());
        proxyInfoBuilder.setIgnoredProxyHosts(serverConfig.getProxyInfo().getIgnoredProxyHosts());
        return proxyInfoBuilder.build();
    } else {
        return new ProxyInfo(null, 0, null, null, null, null);
    }
}
Also used : ProxyInfo(com.blackducksoftware.integration.hub.proxy.ProxyInfo) ProxyInfoBuilder(com.blackducksoftware.integration.hub.proxy.ProxyInfoBuilder)

Aggregations

ProxyInfo (com.blackducksoftware.integration.hub.proxy.ProxyInfo)2 ProxyInfoBuilder (com.blackducksoftware.integration.hub.proxy.ProxyInfoBuilder)2 DetectUserFriendlyException (com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendlyException)1