Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright 2010-2015, Inc. or its affiliates. All Rights Reserved.
  * Licensed under the Apache License, Version 2.0 (the "License").
  * You may not use this file except in compliance with the License.
  * A copy of the License is located at
 * or in the "license" file accompanying this file. This file is distributed
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
public class S3QueryStringSigner extends AbstractAWSSigner {

The HTTP verb (GET, PUT, HEAD, DELETE) the request to sign is using. TODO: We need to know the HTTP verb in order to create the authentication signature, but we don't have easy access to it through the request object. Maybe it'd be better for the S3 signer (or all signers?) to work directly off of the HttpRequest instead of the Request object?
    private final String httpVerb;

The canonical resource path portion of the S3 string to sign. Examples: "/", "/<bucket name>/", or "/<bucket name>/<key>" TODO: We don't want to hold the resource path as member data in the S3 signer, but we need access to it and can't get it through the request yet.
    private final String resourcePath;
    private final Date expiration;
    public S3QueryStringSigner(String httpVerbString resourcePathDate expiration) {
        this. = httpVerb;
        this. = resourcePath;
        this. = expiration;
        if (resourcePath == null)
            throw new IllegalArgumentException("Parameter resourcePath is empty");
    public void sign(SignableRequest<?> requestAWSCredentials credentialsthrows AmazonClientException {
        AWSCredentials sanitizedCredentials = sanitizeCredentials(credentials);
        if ( sanitizedCredentials instanceof AWSSessionCredentials ) {
            addSessionCredentials(request, (AWSSessionCredentialssanitizedCredentials);
        String expirationInSeconds = Long.toString(.getTime() / 1000L);
        String canonicalString = RestUtils.makeS3CanonicalString(
        String signature = super.signAndBase64Encode(canonicalStringsanitizedCredentials.getAWSSecretKey(), .);
    protected void addSessionCredentials(SignableRequest<?> requestAWSSessionCredentials credentials) {
New to GrepCode? Check out our FAQ X