com.amazonaws.ClientConfigurationFactory Java Examples

The following examples show how to use com.amazonaws.ClientConfigurationFactory. 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: DynamoDBStreamsProxy.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an AmazonDynamoDBStreamsAdapterClient.
 * Uses it as the internal client interacting with the DynamoDB streams.
 *
 * @param configProps configuration properties
 * @return an AWS DynamoDB streams adapter client
 */
@Override
protected AmazonKinesis createKinesisClient(Properties configProps) {
	ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
	setAwsClientConfigProperties(awsClientConfig, configProps);

	AWSCredentialsProvider credentials = getCredentialsProvider(configProps);
	awsClientConfig.setUserAgentPrefix(
			String.format(
					USER_AGENT_FORMAT,
					EnvironmentInformation.getVersion(),
					EnvironmentInformation.getRevisionInformation().commitId));

	AmazonDynamoDBStreamsAdapterClient adapterClient =
			new AmazonDynamoDBStreamsAdapterClient(credentials, awsClientConfig);

	if (configProps.containsKey(AWS_ENDPOINT)) {
		adapterClient.setEndpoint(configProps.getProperty(AWS_ENDPOINT));
	} else {
		adapterClient.setRegion(Region.getRegion(
				Regions.fromName(configProps.getProperty(AWS_REGION))));
	}

	return adapterClient;
}
 
Example #2
Source File: DynamoDBStreamsProxy.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an AmazonDynamoDBStreamsAdapterClient.
 * Uses it as the internal client interacting with the DynamoDB streams.
 *
 * @param configProps configuration properties
 * @return an AWS DynamoDB streams adapter client
 */
@Override
protected AmazonKinesis createKinesisClient(Properties configProps) {
	ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
	setAwsClientConfigProperties(awsClientConfig, configProps);

	AWSCredentialsProvider credentials = getCredentialsProvider(configProps);
	awsClientConfig.setUserAgentPrefix(
			String.format(
					USER_AGENT_FORMAT,
					EnvironmentInformation.getVersion(),
					EnvironmentInformation.getRevisionInformation().commitId));

	AmazonDynamoDBStreamsAdapterClient adapterClient =
			new AmazonDynamoDBStreamsAdapterClient(credentials, awsClientConfig);

	if (configProps.containsKey(AWS_ENDPOINT)) {
		adapterClient.setEndpoint(configProps.getProperty(AWS_ENDPOINT));
	} else {
		adapterClient.setRegion(Region.getRegion(
				Regions.fromName(configProps.getProperty(AWS_REGION))));
	}

	return adapterClient;
}
 
Example #3
Source File: RegistryAuthSupplierChainTest.java    From docker-registry-artifact-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldSetUsernameAndPasswordByMakingARequestToECRIfTypeIsEcr() {
    GetAuthorizationTokenResult mockAuthorizationTokenResult = mock(GetAuthorizationTokenResult.class);
    AuthorizationData mockAuthorization = mock(AuthorizationData.class);
    List<AuthorizationData> authorizationData = new ArrayList<>();
    authorizationData.add(mockAuthorization);
    final ArtifactStoreConfig artifactStoreConfig = new ArtifactStoreConfig("https://12345.dkr.ecr.region.amazonaws.com", "ecr", "awsAccessKeyId", "awsSecretAccessKey", "awsRegion");

    String usernameAndPassword="AWS:secretAuthorizationToken";
    when(mockAmazonEcrClient.getAuthorizationToken(any(GetAuthorizationTokenRequest.class))).thenReturn(mockAuthorizationTokenResult);
    when(mockAuthorizationTokenResult.getAuthorizationData()).thenReturn(authorizationData);
    when(mockAuthorization.getAuthorizationToken()).thenReturn(Base64.getEncoder().encodeToString(usernameAndPassword.getBytes()));

    final RegistryAuthSupplierChain registryAuthSupplierChain = new RegistryAuthSupplierChain(artifactStoreConfig, new AWSTokenRequestGenerator(new MockAwsECRClientBuilder(new ClientConfigurationFactory())));
    final RegistryAuth registryAuth = registryAuthSupplierChain.authFor("foo");

    assertThat(registryAuth.serverAddress()).isEqualTo(artifactStoreConfig.getRegistryUrl());
    assertThat(registryAuth.username()).isEqualTo("AWS");
    assertThat(registryAuth.password()).isEqualTo("secretAuthorizationToken");
}
 
Example #4
Source File: DynamoDBStreamsProxy.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an AmazonDynamoDBStreamsAdapterClient.
 * Uses it as the internal client interacting with the DynamoDB streams.
 *
 * @param configProps configuration properties
 * @return an AWS DynamoDB streams adapter client
 */
@Override
protected AmazonKinesis createKinesisClient(Properties configProps) {
	ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
	setAwsClientConfigProperties(awsClientConfig, configProps);

	AWSCredentialsProvider credentials = getCredentialsProvider(configProps);
	awsClientConfig.setUserAgentPrefix(
			String.format(
					USER_AGENT_FORMAT,
					EnvironmentInformation.getVersion(),
					EnvironmentInformation.getRevisionInformation().commitId));

	AmazonDynamoDBStreamsAdapterClient adapterClient =
			new AmazonDynamoDBStreamsAdapterClient(credentials, awsClientConfig);

	if (configProps.containsKey(AWS_ENDPOINT)) {
		adapterClient.setEndpoint(configProps.getProperty(AWS_ENDPOINT));
	} else {
		adapterClient.setRegion(Region.getRegion(
				Regions.fromName(configProps.getProperty(AWS_REGION))));
	}

	return adapterClient;
}
 
Example #5
Source File: KinesisProxy.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Create the Kinesis client, using the provided configuration properties and default {@link ClientConfiguration}.
 * Derived classes can override this method to customize the client configuration.
 * @param configProps
 * @return
 */
protected AmazonKinesis createKinesisClient(Properties configProps) {

	ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
	AWSUtil.setAwsClientConfigProperties(awsClientConfig, configProps);
	return AWSUtil.createKinesisClient(configProps, awsClientConfig);
}
 
Example #6
Source File: KinesisProxy.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Create the Kinesis client, using the provided configuration properties and default {@link ClientConfiguration}.
 * Derived classes can override this method to customize the client configuration.
 * @param configProps
 * @return
 */
protected AmazonKinesis createKinesisClient(Properties configProps) {

	ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
	AWSUtil.setAwsClientConfigProperties(awsClientConfig, configProps);
	return AWSUtil.createKinesisClient(configProps, awsClientConfig);
}
 
Example #7
Source File: OldS3NotebookRepo.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
/**
 * Create AWS client configuration and return it.
 * @return AWS client configuration
 */
private ClientConfiguration createClientConfiguration() {
  ClientConfigurationFactory configFactory = new ClientConfigurationFactory();
  ClientConfiguration config = configFactory.getConfig();

  String s3SignerOverride = conf.getS3SignerOverride();
  if (StringUtils.isNotBlank(s3SignerOverride)) {
    config.setSignerOverride(s3SignerOverride);
  }

  return config;
}
 
Example #8
Source File: S3NotebookRepo.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
/**
 * Create AWS client configuration and return it.
 * @return AWS client configuration
 */
private ClientConfiguration createClientConfiguration() {
  ClientConfigurationFactory configFactory = new ClientConfigurationFactory();
  ClientConfiguration config = configFactory.getConfig();

  String s3SignerOverride = conf.getS3SignerOverride();
  if (StringUtils.isNotBlank(s3SignerOverride)) {
    config.setSignerOverride(s3SignerOverride);
  }

  return config;
}
 
Example #9
Source File: KinesisProxy.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Create the Kinesis client, using the provided configuration properties and default {@link ClientConfiguration}.
 * Derived classes can override this method to customize the client configuration.
 */
protected AmazonKinesis createKinesisClient(Properties configProps) {

	ClientConfiguration awsClientConfig = new ClientConfigurationFactory().getConfig();
	AWSUtil.setAwsClientConfigProperties(awsClientConfig, configProps);
	return AWSUtil.createKinesisClient(configProps, awsClientConfig);
}
 
Example #10
Source File: Proxy.java    From graylog-plugin-aws with Apache License 2.0 5 votes vote down vote up
public static ClientConfiguration forAWS(@NotNull HttpUrl proxyUrl) {
    return new ClientConfigurationFactory().getConfig()
            .withProxyHost(proxyUrl.host())
            .withProxyPort(proxyUrl.port())
            .withProxyUsername(proxyUrl.username())
            .withProxyPassword(proxyUrl.password());
}
 
Example #11
Source File: AWSAutoConfiguration.java    From genie with Apache License 2.0 5 votes vote down vote up
/**
 * Create a named {@link ClientConfiguration} to be used by the {@link AmazonSNS} client, unless a bean by that
 * name already exists in context.
 *
 * @param retryPolicy The retry policy
 * @return a named {@link ClientConfiguration}
 */
@Bean(name = SNS_CLIENT_CONFIGURATION_BEAN_NAME)
@ConditionalOnMissingBean(name = SNS_CLIENT_CONFIGURATION_BEAN_NAME)
public ClientConfiguration jobNotificationsSNSClientConfiguration(
    @Qualifier(SNS_CLIENT_RETRY_POLICY_BEAN_NAME) final RetryPolicy retryPolicy
) {
    final ClientConfiguration configuration = new ClientConfigurationFactory().getConfig();
    configuration.setRetryPolicy(retryPolicy);
    return configuration;
}
 
Example #12
Source File: RegistryAuthSupplierChainTest.java    From docker-registry-artifact-plugin with Apache License 2.0 4 votes vote down vote up
MockAwsECRClientBuilder(ClientConfigurationFactory clientConfigFactory) {
    super(clientConfigFactory);
}
 
Example #13
Source File: AmazonTestWebserviceClientBuilder.java    From spring-cloud-aws with Apache License 2.0 4 votes vote down vote up
private AmazonTestWebserviceClientBuilder() {
	super(new ClientConfigurationFactory());
}
 
Example #14
Source File: AWSUtil.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an AmazonKinesis client.
 * @param configProps configuration properties containing the access key, secret key, and region
 * @return a new AmazonKinesis client
 */
public static AmazonKinesis createKinesisClient(Properties configProps) {
	return createKinesisClient(configProps, new ClientConfigurationFactory().getConfig());
}
 
Example #15
Source File: AWSUtil.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an AmazonKinesis client.
 * @param configProps configuration properties containing the access key, secret key, and region
 * @return a new AmazonKinesis client
 */
public static AmazonKinesis createKinesisClient(Properties configProps) {
	return createKinesisClient(configProps, new ClientConfigurationFactory().getConfig());
}
 
Example #16
Source File: AWSUtil.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an AmazonKinesis client.
 * @param configProps configuration properties containing the access key, secret key, and region
 * @return a new AmazonKinesis client
 */
public static AmazonKinesis createKinesisClient(Properties configProps) {
	return createKinesisClient(configProps, new ClientConfigurationFactory().getConfig());
}