Example usage for com.amazonaws SignableRequest getHttpMethod

List of usage examples for com.amazonaws SignableRequest getHttpMethod

Introduction

In this page you can find the example usage for com.amazonaws SignableRequest getHttpMethod.

Prototype

HttpMethodName getHttpMethod();

Source Link

Document

Returns the HTTP method (GET, POST, etc) to use when sending this request.

Usage

From source file:com.ibm.og.s3.v2.AWSV2Auth.java

License:Open Source License

@Override
public AuthenticatedRequest authenticate(final Request request) {
    checkNotNull(request);// w  ww.j a va  2 s.  c  o m
    final String accessKeyId = checkNotNull(request.getContext().get(Context.X_OG_USERNAME));
    final String secretAccessKey = checkNotNull(request.getContext().get(Context.X_OG_PASSWORD));
    final AWSCredentials credentials = new BasicAWSCredentials(accessKeyId, secretAccessKey);

    final AuthenticatedHttpRequest authenticatedRequest = new AuthenticatedHttpRequest(request);
    final SignableRequest<Request> signableRequest = new SignableRequestAdapter(authenticatedRequest);

    final S3Signer signer = new S3Signer(signableRequest.getHttpMethod().toString(),
            signableRequest.getResourcePath());

    signer.sign(signableRequest, credentials);

    return authenticatedRequest;
}

From source file:com.ibm.og.s3.v4.AWSS3V4Signer.java

License:Open Source License

/**
 * Determine whether to use aws-chunked for signing
 *//*  w  w w.j  a v a 2 s.  com*/
private boolean useChunkEncoding(final SignableRequest<?> request) {
    // If chunked encoding is explicitly disabled through client options
    // return right here.
    if (isChunkedEncodingDisabled(request)) {
        return false;
    }
    // FIXME this may break with POST or part upload
    return this.chunkedEncoding && request.getHttpMethod() == HttpMethodName.PUT;
}