/** * Sets the name of the signature algorithm to use for signing requests made by this client. If * not set or explicitly set to null, the client will choose a signature algorithm to use based * on a configuration file of supported signature algorithms for the service and region. * <p> * Most users do not need to concern themselves with which signature algorithm is being used, as * the defaults will be sufficient. This setting exists only so advanced users can opt in to * newer signature protocols which have not yet been made the default for a particular * service/region. * <p> * Not all services support all signature algorithms, and configuring an unsupported signature * algorithm will lead to authentication failures. Use me at your own risk, and only after * consulting the documentation for the service to ensure it actually does supports your chosen * algorithm. * <p> * If non-null, the name returned from this method is used to look up a {@code Signer} class * implementing the chosen algorithm by the {@code com.amazonaws.auth.SignerFactory} class. * * @param value * The signature algorithm to use for this client, or null to use the default. * @return The updated ClientConfiguration object. */ public ClientConfiguration withSignerOverride(final String value) { setSignerOverride(value); return this; }
private void initializeSignerOverride(final ProcessContext context, final ClientConfiguration config) { String signer = context.getProperty(SIGNER_OVERRIDE).getValue(); if (signer != null && !signer.equals(SIGNER_OVERRIDE.getDefaultValue())) { config.setSignerOverride(signer); } }
/** * Sets the name of the signature algorithm to use for signing requests made by this client. If * not set or explicitly set to null, the client will choose a signature algorithm to use based * on a configuration file of supported signature algorithms for the service and region. * <p> * Most users do not need to concern themselves with which signature algorithm is being used, as * the defaults will be sufficient. This setting exists only so advanced users can opt in to * newer signature protocols which have not yet been made the default for a particular * service/region. * <p> * Not all services support all signature algorithms, and configuring an unsupported signature * algorithm will lead to authentication failures. Use me at your own risk, and only after * consulting the documentation for the service to ensure it actually does supports your chosen * algorithm. * <p> * If non-null, the name returned from this method is used to look up a {@code Signer} class * implementing the chosen algorithm by the {@code com.amazonaws.auth.SignerFactory} class. * * @param value * The signature algorithm to use for this client, or null to use the default. * @return The updated ClientConfiguration object. */ public ClientConfiguration withSignerOverride(final String value) { setSignerOverride(value); return this; }
clientConf.setSignerOverride(conf.get(PropertyKey.UNDERFS_S3A_SIGNER_ALGORITHM));
/** * Sets the name of the signature algorithm to use for signing requests made * by this client. If not set or explicitly set to null, the client will * choose a signature algorithm to use based on a configuration file of * supported signature algorithms for the service and region. * <p> * Most users do not need to concern themselves with which signature * algorithm is being used, as the defaults will be sufficient. This setting * exists only so advanced users can opt in to newer signature protocols * which have not yet been made the default for a particular service/region. * <p> * Not all services support all signature algorithms, and configuring an * unsupported signature algorithm will lead to authentication failures. Use * me at your own risk, and only after consulting the documentation for the * service to ensure it actually does supports your chosen algorithm. * <p> * If non-null, the name returned from this method is used to look up a * {@code Signer} class implementing the chosen algorithm by the * {@code com.amazonaws.auth.SignerFactory} class. * * @param value The signature algorithm to use for this client, or null to * use the default. * @return The updated ClientConfiguration object. */ public ClientConfiguration withSignerOverride(final String value) { setSignerOverride(value); return this; }
public static ClientConfiguration buildClientConfig() { final String userAgent = System.getProperty(PROP_S3_HANDLER_USER_AGENT, null); final String protocol = System.getProperty(PROP_S3_HANDLER_PROTOCOL, "https").toLowerCase(); final String signerOverride = System.getProperty(PROP_S3_HANDLER_SIGNER_OVERRIDE, null); final ClientConfiguration clientConfig = new ClientConfiguration() .withProtocol("https".equals(protocol) ? Protocol.HTTPS : Protocol.HTTP); if (userAgent != null) { clientConfig.setUserAgentPrefix(userAgent); } if (signerOverride != null) { clientConfig.setSignerOverride(signerOverride); } return clientConfig; }
.withSocketTimeout(configuration.getS3ChunkDownloadTimeoutMillis()); if (configuration.isS3UseV2Signing()) { clientConfiguration.setSignerOverride("S3SignerType");
@Test public void testOverrideSigner() { final ClientConfiguration config = new ClientConfiguration(); config.setSignerOverride("QueryStringSignerType"); final AmazonTestClient client = new AmazonTestClient(config); Assert.assertTrue(client.getSigner() instanceof QueryStringSigner); }
configuration.setSignerOverride(clientOptions.getSigner());
/** * Sets the name of the signature algorithm to use for signing requests made by this client. If * not set or explicitly set to null, the client will choose a signature algorithm to use based * on a configuration file of supported signature algorithms for the service and region. * <p> * Most users do not need to concern themselves with which signature algorithm is being used, as * the defaults will be sufficient. This setting exists only so advanced users can opt in to * newer signature protocols which have not yet been made the default for a particular * service/region. * <p> * Not all services support all signature algorithms, and configuring an unsupported signature * algorithm will lead to authentication failures. Use me at your own risk, and only after * consulting the documentation for the service to ensure it actually does supports your chosen * algorithm. * <p> * If non-null, the name returned from this method is used to look up a {@code Signer} class * implementing the chosen algorithm by the {@code com.amazonaws.auth.SignerFactory} class. * * @param value * The signature algorithm to use for this client, or null to use the default. * @return The updated ClientConfiguration object. */ public ClientConfiguration withSignerOverride(final String value) { setSignerOverride(value); return this; }
ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setSignerOverride("S3SignerType");
ClientConfiguration opts = new ClientConfiguration(); opts.setSignerOverride("S3SignerType"); // NOT "AWS3SignerType" AmazonS3Client s3 = new AmazonS3Client(opts);
@Override protected ClientConfiguration getClientConfiguration(PluginTask task) { RiakCsPluginTask t = (RiakCsPluginTask) task; ClientConfiguration config = super.getClientConfiguration(t); config.setSignerOverride("S3SignerType"); return config; } }
private ClientConfiguration buildClientConfig() { final String userAgent = System.getProperty(PROP_S3_HANDLER_USER_AGENT, null); final String protocol = System.getProperty(PROP_S3_HANDLER_PROTOCOL, "https"); final String signerOverride = System.getProperty(PROP_S3_HANDLER_SIGNER_OVERRIDE, null); final ClientConfiguration clientConfig = new ClientConfiguration().withProtocol( "https".equalsIgnoreCase(protocol) ? Protocol.HTTPS : Protocol.HTTP); if (userAgent != null) { clientConfig.setUserAgent(userAgent); } if (signerOverride != null) { clientConfig.setSignerOverride(signerOverride); } return clientConfig; } }
private void initializeSignerOverride(final ProcessContext context, final ClientConfiguration config) { String signer = context.getProperty(SIGNER_OVERRIDE).getValue(); if (signer != null && !signer.equals(SIGNER_OVERRIDE.getDefaultValue())) { config.setSignerOverride(signer); } }
/** * Add a AWS API Signer. * @param signer Signer to use * @param configuration AWS Client configuration * @throws ElasticsearchIllegalArgumentException if signer does not exist */ public static void configureSigner(String signer, ClientConfiguration configuration) throws ElasticsearchIllegalArgumentException { if (signer == null) { throw new ElasticsearchIllegalArgumentException("[null] signer set"); } try { // We check this signer actually exists in AWS SDK // It throws a IllegalArgumentException if not found SignerFactory.getSignerByTypeAndService(signer, null); configuration.setSignerOverride(signer); } catch (IllegalArgumentException e) { throw new ElasticsearchIllegalArgumentException("wrong signer set [" + signer + "]"); } } }
public static ClientConfiguration createClientConfiguration(final String host) { ClientConfiguration config = new ClientConfiguration(); config.setMaxErrorRetry(16); // Default retry limit (3) is low and often // cause problems. Raise it a bit. // See: https://issues.jenkins-ci.org/browse/JENKINS-26800 config.setSignerOverride("AWS4SignerType"); ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy; Proxy proxy = proxyConfig == null ? Proxy.NO_PROXY : proxyConfig.createProxy(host); if (!proxy.equals(Proxy.NO_PROXY) && proxy.address() instanceof InetSocketAddress) { InetSocketAddress address = (InetSocketAddress) proxy.address(); config.setProxyHost(address.getHostName()); config.setProxyPort(address.getPort()); if (null != proxyConfig.getUserName()) { config.setProxyUsername(proxyConfig.getUserName()); config.setProxyPassword(proxyConfig.getPassword()); } } return config; }
/*** * Connect to an EC2 instance. * @return {@link AmazonEC2} client */ public synchronized static AmazonEC2 connect(AWSCredentialsProvider credentialsProvider, URL endpoint) { awsCredentialsProvider = credentialsProvider; ClientConfiguration config = new ClientConfiguration(); config.setMaxErrorRetry(16); // Default retry limit (3) is low and often cause problems. Raise it a bit. // See: https://issues.jenkins-ci.org/browse/JENKINS-26800 config.setSignerOverride("QueryStringSignerType"); ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy; Proxy proxy = proxyConfig == null ? Proxy.NO_PROXY : proxyConfig.createProxy(endpoint.getHost()); if (! proxy.equals(Proxy.NO_PROXY) && proxy.address() instanceof InetSocketAddress) { InetSocketAddress address = (InetSocketAddress) proxy.address(); config.setProxyHost(address.getHostName()); config.setProxyPort(address.getPort()); if(null != proxyConfig.getUserName()) { config.setProxyUsername(proxyConfig.getUserName()); config.setProxyPassword(proxyConfig.getPassword()); } } AmazonEC2 client = new AmazonEC2Client(credentialsProvider, config); client.setEndpoint(endpoint.toString()); return client; }
/** * Initializes all AWS SDK settings related to connection management. * * @param conf Hadoop configuration * @param awsConf AWS SDK configuration */ private static void initConnectionSettings(Configuration conf, ClientConfiguration awsConf) { awsConf.setMaxConnections(intOption(conf, Constants.MAXIMUM_CONNECTIONS, Constants.DEFAULT_MAXIMUM_CONNECTIONS, 1)); boolean secureConnections = conf.getBoolean(Constants.SECURE_CONNECTIONS, Constants.DEFAULT_SECURE_CONNECTIONS); awsConf.setProtocol(secureConnections ? Protocol.HTTPS : Protocol.HTTP); awsConf.setMaxErrorRetry(intOption(conf, Constants.MAX_ERROR_RETRIES, Constants.DEFAULT_MAX_ERROR_RETRIES, 0)); awsConf.setConnectionTimeout(intOption(conf, Constants.ESTABLISH_TIMEOUT, Constants.DEFAULT_ESTABLISH_TIMEOUT, 0)); awsConf.setSocketTimeout(intOption(conf, Constants.SOCKET_TIMEOUT, Constants.DEFAULT_SOCKET_TIMEOUT, 0)); int sockSendBuffer = intOption(conf, S3Constants.SOCKET_SEND_BUFFER, S3Constants.DEFAULT_SOCKET_SEND_BUFFER, 2048); int sockRecvBuffer = intOption(conf, S3Constants.SOCKET_RECV_BUFFER, S3Constants.DEFAULT_SOCKET_RECV_BUFFER, 2048); awsConf.setSocketBufferSizeHints(sockSendBuffer, sockRecvBuffer); String signerOverride = conf.getTrimmed(S3Constants.SIGNING_ALGORITHM, ""); if (!signerOverride.isEmpty()) { logger.debug("Signer override = {}", signerOverride); awsConf.setSignerOverride(signerOverride); } }
c.setSignerOverride("ride"); assertEquals(c.getSignerOverride(), "ride");