Example usage for com.amazonaws ClientConfiguration setProxyHost

List of usage examples for com.amazonaws ClientConfiguration setProxyHost

Introduction

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

Prototype

public void setProxyHost(String proxyHost) 

Source Link

Document

Sets the optional proxy host the client will connect through.

Usage

From source file:org.opendedup.sdfs.filestore.cloud.BatchAwsS3ChunkStore.java

License:Open Source License

@Override
public boolean checkAccess(String username, String password, Properties props) throws Exception {
    BasicAWSCredentials _cred = new BasicAWSCredentials(username, password);
    if (props.containsKey("default-bucket-location")) {
        bucketLocation = RegionUtils.getRegion(props.getProperty("default-bucket-location"));
    }/*  w w  w.j av a  2s. c  om*/

    ClientConfiguration clientConfig = new ClientConfiguration();
    clientConfig.setMaxConnections(Main.dseIOThreads * 2);
    clientConfig.setConnectionTimeout(10000);
    clientConfig.setSocketTimeout(10000);
    String s3Target = null;

    if (props.containsKey("s3-target")) {
        s3Target = props.getProperty("s3-target");
    }
    if (props.containsKey("proxy-host")) {
        clientConfig.setProxyHost(props.getProperty("proxy-host"));
    }
    if (props.containsKey("proxy-domain")) {
        clientConfig.setProxyDomain(props.getProperty("proxy-domain"));
    }
    if (props.containsKey("proxy-password")) {
        clientConfig.setProxyPassword(props.getProperty("proxy-password"));
    }
    if (props.containsKey("proxy-port")) {
        clientConfig.setProxyPort(Integer.parseInt(props.getProperty("proxy-port")));
    }
    if (props.containsKey("proxy-username")) {
        clientConfig.setProxyUsername(props.getProperty("proxy-username"));
    }
    s3Service = new AmazonS3Client(_cred, clientConfig);
    if (s3Target != null) {
        TrustStrategy acceptingTrustStrategy = new TrustStrategy() {
            @Override
            public boolean isTrusted(X509Certificate[] certificate, String authType) {
                return true;
            }
        };
        SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy,
                SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
        clientConfig.getApacheHttpClientConfig().withSslSocketFactory(sf);
        s3Service.setEndpoint(s3Target);
    }
    s3Service.listBuckets();
    return true;
}

From source file:org.openflamingo.fs.s3.S3ObjectProvider.java

License:Apache License

public S3ObjectProvider(org.openflamingo.provider.fs.FileSystemAuditService auditService) {
    this.auditService = auditService;

    String accessKey = FileSystemAuthentication.getAccessKey();
    String secretKey = FileSystemAuthentication.getSecretKey();
    AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);

    if (FileSystemAuthentication.isTestEnvironment()) {
        ClientConfiguration clientConfiguration = new ClientConfiguration();
        clientConfiguration.setProxyHost(FileSystemAuthentication.getProxyAddress());
        clientConfiguration.setProxyPort(Integer.parseInt(FileSystemAuthentication.getProxyPort()));

        this.awsClient = new AmazonS3Client(awsCredentials, clientConfiguration);
    } else {//from  w w w .j av a2s  .c  o  m
        this.awsClient = new AmazonS3Client(awsCredentials);
    }
}

From source file:org.swiftshire.nifi.processors.kinesis.consumer.AbstractKinesisConsumerProcessor.java

License:Apache License

/**
 * Creates and initializes our KCL configuration to use.
 *
 * @param context//from  w w w  .  java  2 s . co  m
 * @return
 */
protected ClientConfiguration createConfiguration(final ProcessContext context) {
    final ClientConfiguration config = new ClientConfiguration();

    config.setMaxConnections(context.getMaxConcurrentTasks());
    config.setMaxErrorRetry(0);
    config.setUserAgent(DEFAULT_USER_AGENT);

    final int timeout = context.getProperty(TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue();
    config.setConnectionTimeout(timeout);
    config.setSocketTimeout(timeout);

    final SSLContextService sslContextService = context.getProperty(SSL_CONTEXT_SERVICE)
            .asControllerService(SSLContextService.class);

    if (sslContextService != null) {
        final SSLContext sslContext = sslContextService.createSSLContext(SSLContextService.ClientAuth.NONE);

        SdkTLSSocketFactory sdkTLSSocketFactory = new SdkTLSSocketFactory(sslContext, null);
        config.getApacheHttpClientConfig().setSslSocketFactory(sdkTLSSocketFactory);
    }

    if (context.getProperty(PROXY_HOST).isSet()) {
        String proxyHost = context.getProperty(PROXY_HOST).getValue();
        config.setProxyHost(proxyHost);

        Integer proxyPort = context.getProperty(PROXY_HOST_PORT).asInteger();
        config.setProxyPort(proxyPort);
    }

    return config;
}

From source file:org.xmlsh.aws.gradle.AwsPluginExtension.java

License:BSD License

public <T extends AmazonWebServiceClient> T createClient(Class<T> serviceClass, String profileName,
        ClientConfiguration config) {
    if (profileName == null) {
        if (this.profileName == null) {
            throw new IllegalStateException("default profileName is null");
        }//from   w ww. ja  va 2  s . c  o m
        profileName = this.profileName;
    }

    AWSCredentialsProvider credentialsProvider = newCredentialsProvider(profileName);
    if (this.proxyHost != null && this.proxyPort > 0) {
        config.setProxyHost(this.proxyHost);
        config.setProxyPort(this.proxyPort);
    }
    return createClient(serviceClass, credentialsProvider, config);
}