com.amazonaws.services.s3.model.EncryptionMaterialsProvider#com.amazonaws.auth.Signer源码实例Demo

下面列出了com.amazonaws.services.s3.model.EncryptionMaterialsProvider#com.amazonaws.auth.Signer 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 *
 * @param service service that we're connecting to
 * @param signer particular signer implementation
 * @param awsCredentialsProvider source of AWS credentials for signing
 */
public AWSRequestSigningApacheInterceptor(final String service,
                                          final Signer signer,
                                          final AWSCredentialsProvider awsCredentialsProvider)
{
    this.service = service;
    this.signer = signer;
    this.awsCredentialsProvider = awsCredentialsProvider;
}
 
/**
 *
 * @param service service that we're connecting to
 * @param signer particular signer implementation
 * @param awsCredentialsProvider source of AWS credentials for signing
 */
public AWSRequestSigningApacheInterceptor(final String service,
                            final Signer signer,
                            final AWSCredentialsProvider awsCredentialsProvider) {
    this.service = service;
    this.signer = signer;
    this.awsCredentialsProvider = awsCredentialsProvider;
}
 
/**
 *
 * @param service service that we're connecting to
 * @param signer particular signer implementation
 * @param awsCredentialsProvider source of AWS credentials for signing
 */
public AwsRequestSigningApacheInterceptor(final String service,
                                          final Signer signer,
                                          final AWSCredentialsProvider awsCredentialsProvider) {
  this.service = service;
  this.signer = signer;
  this.awsCredentialsProvider = awsCredentialsProvider;
}
 
源代码4 项目: presto   文件: PrestoS3FileSystem.java
private AmazonS3 createAmazonS3Client(Configuration hadoopConfig, ClientConfiguration clientConfig)
{
    Optional<EncryptionMaterialsProvider> encryptionMaterialsProvider = createEncryptionMaterialsProvider(hadoopConfig);
    AmazonS3Builder<? extends AmazonS3Builder<?, ?>, ? extends AmazonS3> clientBuilder;

    String signerType = hadoopConfig.get(S3_SIGNER_TYPE);
    if (signerType != null) {
        clientConfig.withSignerOverride(signerType);
    }

    String signerClass = hadoopConfig.get(S3_SIGNER_CLASS);
    if (signerClass != null) {
        Class<? extends Signer> klass;
        try {
            klass = Class.forName(signerClass).asSubclass(Signer.class);
        }
        catch (ClassNotFoundException e) {
            throw new RuntimeException("Signer class not found: " + signerClass, e);
        }
        SignerFactory.registerSigner(S3_CUSTOM_SIGNER, klass);
        clientConfig.setSignerOverride(S3_CUSTOM_SIGNER);
    }

    if (encryptionMaterialsProvider.isPresent()) {
        clientBuilder = AmazonS3EncryptionClient.encryptionBuilder()
                .withCredentials(credentialsProvider)
                .withEncryptionMaterials(encryptionMaterialsProvider.get())
                .withClientConfiguration(clientConfig)
                .withMetricsCollector(METRIC_COLLECTOR);
    }
    else {
        clientBuilder = AmazonS3Client.builder()
                .withCredentials(credentialsProvider)
                .withClientConfiguration(clientConfig)
                .withMetricsCollector(METRIC_COLLECTOR);
    }

    boolean regionOrEndpointSet = false;

    // use local region when running inside of EC2
    if (pinS3ClientToCurrentRegion) {
        clientBuilder.setRegion(getCurrentRegionFromEC2Metadata().getName());
        regionOrEndpointSet = true;
    }

    String endpoint = hadoopConfig.get(S3_ENDPOINT);
    if (endpoint != null) {
        clientBuilder.setEndpointConfiguration(new EndpointConfiguration(endpoint, null));
        regionOrEndpointSet = true;
    }

    if (isPathStyleAccess) {
        clientBuilder.enablePathStyleAccess();
    }

    if (!regionOrEndpointSet) {
        clientBuilder.withRegion(US_EAST_1);
        clientBuilder.setForceGlobalBucketAccessEnabled(true);
    }

    return clientBuilder.build();
}
 
@Override
public Signer getSignerByURI(URI uri) {
    return this.signer;
}