Example usage for com.amazonaws.auth SignerFactory getSignerByTypeAndService

List of usage examples for com.amazonaws.auth SignerFactory getSignerByTypeAndService

Introduction

In this page you can find the example usage for com.amazonaws.auth SignerFactory getSignerByTypeAndService.

Prototype

public static Signer getSignerByTypeAndService(String signerType, final String serviceName) 

Source Link

Document

Returns an instance of the given signer type and configures it with the given service name (if applicable).

Usage

From source file:org.elasticsearch.cloud.aws.AwsSigner.java

License:Apache License

/**
 * Add a AWS API Signer.//from  w  ww .ja va  2s  . c  om
 * @param signer Signer to use
 * @param configuration AWS Client configuration
 * @throws IllegalArgumentException if signer does not exist
 */
public static void configureSigner(String signer, ClientConfiguration configuration)
        throws IllegalArgumentException {

    if (signer == null) {
        throw new IllegalArgumentException("[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 IllegalArgumentException("wrong signer set [" + signer + "]");
    }
}

From source file:org.elasticsearch.discovery.ec2.AwsSigner.java

License:Apache License

protected static void validateSignerType(String signer) throws IllegalArgumentException {
    if (signer == null) {
        throw new IllegalArgumentException("[null] signer set");
    }/* w  w  w.  j av  a2s.com*/

    try {
        // We check this signer actually exists in AWS SDK
        // It throws a IllegalArgumentException if not found
        SignerFactory.getSignerByTypeAndService(signer, null);
    } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException("wrong signer set [" + signer + "]");
    }
}

From source file:org.elasticsearch.repositories.s3.AwsSigner.java

License:Apache License

protected static void validateSignerType(String signer, String endpoint) {
    if (signer == null) {
        throw new IllegalArgumentException("[null] signer set");
    }// ww  w. j a  va 2 s . c om

    // do not block user to any signerType
    switch (signer) {
    case "S3SignerType":
        if (endpoint.equals("s3.cn-north-1.amazonaws.com.cn")
                || endpoint.equals("s3.eu-central-1.amazonaws.com")) {
            throw new IllegalArgumentException(
                    "[S3SignerType] may not be supported in aws Beijing and Frankfurt region");
        }
        break;
    case "AWSS3V4SignerType":
        break;
    default:
        try {
            SignerFactory.getSignerByTypeAndService(signer, null);
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException("[" + signer + "] may not be supported");
        }
    }
}