Example usage for com.amazonaws AmazonWebServiceRequest getRequestCredentials

List of usage examples for com.amazonaws AmazonWebServiceRequest getRequestCredentials

Introduction

In this page you can find the example usage for com.amazonaws AmazonWebServiceRequest getRequestCredentials.

Prototype

@Deprecated
public AWSCredentials getRequestCredentials() 

Source Link

Document

Returns the optional credentials to use to sign this request, overriding the default credentials set at the client level.

Usage

From source file:com.ivona.services.tts.IvonaSpeechCloudClient.java

License:Open Source License

private <Y> Request<Y> prepareRequest(Request<Y> request, ExecutionContext executionContext,
        boolean signRequest) {
    request.setEndpoint(endpoint);/*from   w  ww.  j av a2  s.c  o  m*/
    request.setTimeOffset(timeOffset);

    AWSCredentials credentials = awsCredentialsProvider.getCredentials();

    AmazonWebServiceRequest originalRequest = request.getOriginalRequest();
    if (originalRequest != null && originalRequest.getRequestCredentials() != null) {
        credentials = originalRequest.getRequestCredentials();
    }
    if (signRequest) {
        // expiration date is not currently supported on service side, but presignRequest method requires
        // this argument so one with default value is provided.
        Date expirationDate = DateTime.now(DateTimeZone.UTC).plusMinutes(DEFAULT_GET_REQUEST_EXPIRATION_MINUTES)
                .toDate();
        signer.presignRequest(request, credentials, expirationDate);
    } else {
        executionContext.setSigner(signer);
        executionContext.setCredentials(credentials);
    }
    return request;
}