Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014-2015 Amazon.com, 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
   *
   *  http://aws.amazon.com/apache2.0
   *
  * or in the "license" file accompanying this file. This file is distributed
  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.auth.internal;
 
 import java.util.Date;
 
Parameters that are used for computing a AWS 4 signature for a request.
 
 public final class AWS4SignerRequestParams {

    
The request for which the signature needs to be computed.
 
     private final SignableRequest<?> request;

    
The datetime in milliseconds for which the signature needs to be computed.
 
     private final long signingDateTimeMilli;

    
The scope of the signature.
 
     private final String scope;

    
The AWS region to be used for computing the signature.
 
     private final String regionName;

    
The name of the AWS service.
 
     private final String serviceName;

    
UTC formatted version of the signing time stamp.
 
     private final String formattedSigningDateTime;

    
UTC Formatted Signing date with time stamp stripped
 
     private final String formattedSigningDate;

    
The signing algorithm to be used for computing the signature.
 
     private final String signingAlgorithm;

    
Generates an instance of AWS4signerRequestParams that holds the parameters used for computing a AWS 4 signature for a request
 
     public AWS4SignerRequestParams(SignableRequest<?> request,
             Date signingDateOverrideString regionNameOverride,
             String serviceNameOverrideString signingAlgorithm) {
         if (request == null) {
             throw new IllegalArgumentException("Request cannot be null");
         }
         if (signingAlgorithm == null) {
             throw new IllegalArgumentException(
                     "Signing Algorithm cannot be null");
         }
         this. = request;
         this. = signingDateOverride != null ? signingDateOverride
                 .getTime() : getSigningDate(request);
         this. = AWS4SignerUtils
                 .formatDateStamp();
         this. = serviceNameOverride != null ? serviceNameOverride
                 : AwsHostNameUtils.parseServiceName(request.getEndpoint());
         this. = regionNameOverride != null ? regionNameOverride
                 : AwsHostNameUtils.parseRegionName(request.getEndpoint()
                         .getHost(), );
         this. = generateScope(request,
                 );
         this. = AWS4SignerUtils
                 .formatTimestamp();
         this. = signingAlgorithm;
     }

    
Returns the signing date from the request.
    private final long getSigningDate(SignableRequest<?> request) {
        return System.currentTimeMillis() - request.getTimeOffset() * 1000;
    }

    
Returns the scope to be used for the signing.
    private String generateScope(SignableRequest<?> requestString dateStamp,
            String serviceNameString regionName) {
        final StringBuilder scopeBuilder = new StringBuilder();
        return scopeBuilder.append(dateStamp).append("/").append(regionName)
                .append("/").append(serviceName).append("/")
                .append(.).toString();
    }

    
Returns the request for which the signing needs to be done.
    public SignableRequest<?> getRequest() {
        return ;
    }

    
Returns the scope of the signing.
    public String getScope() {
        return ;
    }

    
Returns the formatted date and time of the signing date in UTC zone.
        return ;
    }

    
Returns the signing date time in millis for which the signature needs to be computed.
    public long getSigningDateTimeMilli() {
        return ;
    }

    
Returns the AWS region name to be used while computing the signature.
    public String getRegionName() {
        return ;
    }

    
Returns the AWS Service name to be used while computing the signature.
    public String getServiceName() {
        return ;
    }

    
Returns the formatted date in UTC zone of the signing date.
    public String getFormattedSigningDate() {
        return ;
    }

    
Returns the signing algorithm used for computing the signature.
    public String getSigningAlgorithm() {
        return ;
    }
New to GrepCode? Check out our FAQ X