Example usage for com.amazonaws ClientConfiguration setProxyPort

List of usage examples for com.amazonaws ClientConfiguration setProxyPort

Introduction

In this page you can find the example usage for com.amazonaws ClientConfiguration setProxyPort.

Prototype

public void setProxyPort(int proxyPort) 

Source Link

Document

Sets the optional proxy port the client will connect through.

Usage

From source file:com.liferay.portal.store.s3.S3Store.java

License:Open Source License

protected void configureProxySettings(ClientConfiguration clientConfiguration) {

    String proxyHost = _s3StoreConfiguration.proxyHost();

    if (Validator.isNull(proxyHost)) {
        return;//www .jav  a 2 s .co  m
    }

    clientConfiguration.setProxyHost(proxyHost);
    clientConfiguration.setProxyPort(_s3StoreConfiguration.proxyPort());

    String proxyAuthType = _s3StoreConfiguration.proxyAuthType();

    if (proxyAuthType.equals("ntlm") || proxyAuthType.equals("username-password")) {

        clientConfiguration.setProxyPassword(_s3StoreConfiguration.proxyPassword());
        clientConfiguration.setProxyUsername(_s3StoreConfiguration.proxyUsername());

        if (proxyAuthType.equals("ntlm")) {
            clientConfiguration.setProxyDomain(_s3StoreConfiguration.ntlmProxyDomain());
            clientConfiguration.setProxyWorkstation(_s3StoreConfiguration.ntlmProxyWorkstation());
        }
    }
}

From source file:com.netflix.exhibitor.core.s3.PropertyBasedS3ClientConfig.java

License:Apache License

@Override
public ClientConfiguration getAWSClientConfig() {
    ClientConfiguration awsClientConfig = new ClientConfiguration();
    awsClientConfig.setProxyHost(proxyHost);
    awsClientConfig.setProxyPort(proxyPort);

    if (proxyUsername != null) {
        awsClientConfig.setProxyUsername(proxyUsername);
    }//from  www  . j  av  a 2 s  . com

    if (proxyPassword != null) {
        awsClientConfig.setProxyPassword(proxyPassword);
    }
    return awsClientConfig;
}

From source file:com.netflix.spinnaker.clouddriver.aws.security.AWSProxy.java

License:Apache License

public void apply(ClientConfiguration clientConfiguration) {

    clientConfiguration.setProxyHost(proxyHost);
    clientConfiguration.setProxyPort(Integer.parseInt(proxyPort));
    clientConfiguration.setProxyUsername(proxyUsername);
    clientConfiguration.setProxyPassword(proxyPassword);

    Protocol awsProtocol = Protocol.HTTP;

    if ("HTTPS".equalsIgnoreCase(protocol)) {
        awsProtocol = Protocol.HTTPS;/* w ww  .ja  v  a  2s .  com*/
    }

    clientConfiguration.setProtocol(awsProtocol);

    if (isNTLMProxy()) {
        clientConfiguration.setProxyDomain(proxyDomain);
        clientConfiguration.setProxyWorkstation(proxyWorkstation);
    }
}

From source file:com.pinterest.secor.uploader.S3UploadManager.java

License:Apache License

public S3UploadManager(SecorConfig config) {
    super(config);

    final String accessKey = mConfig.getAwsAccessKey();
    final String secretKey = mConfig.getAwsSecretKey();
    final String endpoint = mConfig.getAwsEndpoint();
    final String region = mConfig.getAwsRegion();
    final String awsRole = mConfig.getAwsRole();

    s3Path = mConfig.getS3Path();

    AmazonS3 client;/* w w  w  .  j  a va  2 s  . c om*/
    AWSCredentialsProvider provider;

    ClientConfiguration clientConfiguration = new ClientConfiguration();
    boolean isHttpProxyEnabled = mConfig.getAwsProxyEnabled();

    //proxy settings
    if (isHttpProxyEnabled) {
        LOG.info("Http Proxy Enabled for S3UploadManager");
        String httpProxyHost = mConfig.getAwsProxyHttpHost();
        int httpProxyPort = mConfig.getAwsProxyHttpPort();
        clientConfiguration.setProxyHost(httpProxyHost);
        clientConfiguration.setProxyPort(httpProxyPort);
    }

    if (accessKey.isEmpty() || secretKey.isEmpty()) {
        provider = new DefaultAWSCredentialsProviderChain();
    } else {
        provider = new AWSCredentialsProvider() {
            public AWSCredentials getCredentials() {
                return new BasicAWSCredentials(accessKey, secretKey);
            }

            public void refresh() {
            }
        };
    }

    if (!awsRole.isEmpty()) {
        provider = new STSAssumeRoleSessionCredentialsProvider(provider, awsRole, "secor");
    }

    client = new AmazonS3Client(provider, clientConfiguration);

    if (!endpoint.isEmpty()) {
        client.setEndpoint(endpoint);
    } else if (!region.isEmpty()) {
        client.setRegion(Region.getRegion(Regions.fromName(region)));
    }

    mManager = new TransferManager(client);
}

From source file:com.smoketurner.pipeline.application.config.AwsConfiguration.java

License:Apache License

@JsonIgnore
public ClientConfiguration getClientConfiguration() {
    final ClientConfiguration clientConfig = new ClientConfiguration();
    if (proxy.isPresent()) {
        clientConfig.setProxyHost(proxy.get().getHostText());
        clientConfig.setProxyPort(proxy.get().getPort());
    }/*from ww w  .java  2  s. c  om*/
    clientConfig.setUseTcpKeepAlive(true);
    // needs to be false to support streaming gunzipping
    clientConfig.setUseGzip(false);
    return clientConfig;
}

From source file:com.streamsets.pipeline.lib.aws.s3.S3Accessor.java

License:Apache License

ClientConfiguration createClientConfiguration() throws StageException {
    ClientConfiguration clientConfig = new ClientConfiguration();

    clientConfig.setConnectionTimeout(connectionConfigs.getConnectionTimeoutMillis());
    clientConfig.setSocketTimeout(connectionConfigs.getSocketTimeoutMillis());
    clientConfig.withMaxErrorRetry(connectionConfigs.getMaxErrorRetry());

    if (connectionConfigs.isProxyEnabled()) {
        clientConfig.setProxyHost(connectionConfigs.getProxyHost());
        clientConfig.setProxyPort(connectionConfigs.getProxyPort());
        if (connectionConfigs.isProxyAuthenticationEnabled()) {
            clientConfig.setProxyUsername(connectionConfigs.getProxyUser().get());
            clientConfig.setProxyPassword(connectionConfigs.getProxyPassword().get());
        }/*w w w.ja  va 2  s.c om*/
    }
    return clientConfig;
}

From source file:com.streamsets.pipeline.stage.lib.aws.AWSUtil.java

License:Apache License

public static ClientConfiguration getClientConfiguration(ProxyConfig config) {
    ClientConfiguration clientConfig = new ClientConfiguration();

    // Optional proxy settings
    if (config.useProxy) {
        if (config.proxyHost != null && !config.proxyHost.isEmpty()) {
            clientConfig.setProxyHost(config.proxyHost);
            clientConfig.setProxyPort(config.proxyPort);

            if (config.proxyUser != null && !config.proxyUser.isEmpty()) {
                clientConfig.setProxyUsername(config.proxyUser);
            }/*from w  w w . j  a va 2 s  . co m*/

            if (config.proxyPassword != null) {
                clientConfig.setProxyPassword(config.proxyPassword);
            }
        }
    }
    return clientConfig;
}

From source file:com.tcl.gateway.firehose.log4j.FirehoseAppender.java

License:Open Source License

/**
 * Set proxy configuration based on system properties. Some of the properties are standard
 * properties documented by Oracle (http.proxyHost, http.proxyPort, http.auth.ntlm.domain),
 * and others are from common convention (http.proxyUser, http.proxyPassword).
 *
 * Finally, for NTLM authentication the workstation name is taken from the environment as
 * COMPUTERNAME. We set this on the client configuration only if the NTLM domain was specified.
 *//*w  w  w .  jav  a 2s .c  om*/
private ClientConfiguration setProxySettingsFromSystemProperties(ClientConfiguration clientConfiguration) {

    final String proxyHost = System.getProperty("http.proxyHost");
    if (proxyHost != null) {
        clientConfiguration.setProxyHost(proxyHost);
    }

    final String proxyPort = System.getProperty("http.proxyPort");
    if (proxyPort != null) {
        clientConfiguration.setProxyPort(Integer.parseInt(proxyPort));
    }

    final String proxyUser = System.getProperty("http.proxyUser");
    if (proxyUser != null) {
        clientConfiguration.setProxyUsername(proxyUser);
    }

    final String proxyPassword = System.getProperty("http.proxyPassword");
    if (proxyPassword != null) {
        clientConfiguration.setProxyPassword(proxyPassword);
    }

    final String proxyDomain = System.getProperty("http.auth.ntlm.domain");
    if (proxyDomain != null) {
        clientConfiguration.setProxyDomain(proxyDomain);
    }

    final String workstation = System.getenv("COMPUTERNAME");
    if (proxyDomain != null && workstation != null) {
        clientConfiguration.setProxyWorkstation(workstation);
    }

    return clientConfiguration;
}

From source file:com.upplication.s3fs.S3FileSystemProvider.java

License:Open Source License

protected ClientConfiguration createClientConfig(Properties props) {
    ClientConfiguration config = new ClientConfiguration();

    if (props == null)
        return config;

    if (props.containsKey("connection_timeout")) {
        log.trace("AWS client config - connection_timeout: {}", props.getProperty("connection_timeout"));
        config.setConnectionTimeout(Integer.parseInt(props.getProperty("connection_timeout")));
    }/*from   ww  w. j  ava  2 s  .c o  m*/

    if (props.containsKey("max_connections")) {
        log.trace("AWS client config - max_connections: {}", props.getProperty("max_connections"));
        config.setMaxConnections(Integer.parseInt(props.getProperty("max_connections")));
    }

    if (props.containsKey("max_error_retry")) {
        log.trace("AWS client config - max_error_retry: {}", props.getProperty("max_error_retry"));
        config.setMaxErrorRetry(Integer.parseInt(props.getProperty("max_error_retry")));
    }

    if (props.containsKey("protocol")) {
        log.trace("AWS client config - protocol: {}", props.getProperty("protocol"));
        config.setProtocol(Protocol.valueOf(props.getProperty("protocol").toUpperCase()));
    }

    if (props.containsKey("proxy_domain")) {
        log.trace("AWS client config - proxy_domain: {}", props.getProperty("proxy_domain"));
        config.setProxyDomain(props.getProperty("proxy_domain"));
    }

    if (props.containsKey("proxy_host")) {
        log.trace("AWS client config - proxy_host: {}", props.getProperty("proxy_host"));
        config.setProxyHost(props.getProperty("proxy_host"));
    }

    if (props.containsKey("proxy_port")) {
        log.trace("AWS client config - proxy_port: {}", props.getProperty("proxy_port"));
        config.setProxyPort(Integer.parseInt(props.getProperty("proxy_port")));
    }

    if (props.containsKey("proxy_username")) {
        log.trace("AWS client config - proxy_username: {}", props.getProperty("proxy_username"));
        config.setProxyUsername(props.getProperty("proxy_username"));
    }

    if (props.containsKey("proxy_password")) {
        log.trace("AWS client config - proxy_password: {}", props.getProperty("proxy_password"));
        config.setProxyPassword(props.getProperty("proxy_password"));
    }

    if (props.containsKey("proxy_workstation")) {
        log.trace("AWS client config - proxy_workstation: {}", props.getProperty("proxy_workstation"));
        config.setProxyWorkstation(props.getProperty("proxy_workstation"));
    }

    if (props.containsKey("signer_override")) {
        log.debug("AWS client config - signerOverride: {}", props.getProperty("signer_override"));
        config.setSignerOverride(props.getProperty("signer_override"));
    }

    if (props.containsKey("socket_send_buffer_size_hints")
            || props.containsKey("socket_recv_buffer_size_hints")) {
        log.trace("AWS client config - socket_send_buffer_size_hints: {}, socket_recv_buffer_size_hints: {}",
                props.getProperty("socket_send_buffer_size_hints", "0"),
                props.getProperty("socket_recv_buffer_size_hints", "0"));
        int send = Integer.parseInt(props.getProperty("socket_send_buffer_size_hints", "0"));
        int recv = Integer.parseInt(props.getProperty("socket_recv_buffer_size_hints", "0"));
        config.setSocketBufferSizeHints(send, recv);
    }

    if (props.containsKey("socket_timeout")) {
        log.trace("AWS client config - socket_timeout: {}", props.getProperty("socket_timeout"));
        config.setSocketTimeout(Integer.parseInt(props.getProperty("socket_timeout")));
    }

    if (props.containsKey("user_agent")) {
        log.trace("AWS client config - user_agent: {}", props.getProperty("user_agent"));
        config.setUserAgent(props.getProperty("user_agent"));
    }

    return config;
}

From source file:de.taimos.pipeline.aws.ProxyConfiguration.java

License:Apache License

private static void useJenkinsProxy(ClientConfiguration config) {
    if (Jenkins.getInstance() != null) {
        hudson.ProxyConfiguration proxyConfiguration = Jenkins.getInstance().proxy;
        if (proxyConfiguration != null) {
            config.setProxyHost(proxyConfiguration.name);
            config.setProxyPort(proxyConfiguration.port);
            config.setProxyUsername(proxyConfiguration.getUserName());
            config.setProxyPassword(proxyConfiguration.getPassword());

            if (proxyConfiguration.noProxyHost != null) {
                String[] noProxyParts = proxyConfiguration.noProxyHost.split("[ \t\n,|]+");
                config.setNonProxyHosts(Joiner.on('|').join(noProxyParts));
            }//ww w  . j ava  2  s  .c  o m
        }
    }
}