Java Code Examples for com.amazonaws.ClientConfiguration#setProxyDomain()

The following examples show how to use com.amazonaws.ClientConfiguration#setProxyDomain() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AWSUtil.java    From datacollector with Apache License 2.0 5 votes vote down vote up
public static ClientConfiguration getClientConfiguration(ProxyConfig config) throws StageException {
  ClientConfiguration clientConfig = new ClientConfiguration();

  clientConfig.setConnectionTimeout(config.connectionTimeout * MILLIS);
  clientConfig.setSocketTimeout(config.socketTimeout * MILLIS);
  clientConfig.withMaxErrorRetry(config.retryCount);

  // 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.get().isEmpty()) {
        clientConfig.setProxyUsername(config.proxyUser.get());
      }

      if (config.proxyPassword != null && !config.proxyPassword.get().isEmpty()) {
        clientConfig.setProxyPassword(config.proxyPassword.get());
      }

      if (config.proxyDomain != null && !config.proxyDomain.isEmpty()) {
        clientConfig.setProxyDomain(config.proxyDomain);
      }

      if (config.proxyWorkstation != null && !config.proxyWorkstation.isEmpty()) {
        clientConfig.setProxyWorkstation(config.proxyWorkstation);
      }
    }
  }
  return clientConfig;
}
 
Example 2
Source File: KinesisAppender.java    From kinesis-log4j-appender with Apache License 2.0 5 votes vote down vote up
/**
 * 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.
 */
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;
}