List of usage examples for com.amazonaws.services.s3 Headers DATE
String DATE
To view the source code for com.amazonaws.services.s3 Headers DATE.
Click Source Link
From source file:com.emc.vipr.services.s3.ViPRS3Signer.java
License:Open Source License
@Override public void sign(Request<?> request, AWSCredentials credentials) throws AmazonClientException { if (credentials == null || credentials.getAWSSecretKey() == null) { log.debug("Canonical string will not be signed, as no AWS Secret Key was provided"); return;// w w w. j a v a 2 s .com } AWSCredentials sanitizedCredentials = sanitizeCredentials(credentials); if (sanitizedCredentials instanceof AWSSessionCredentials) { addSessionCredentials(request, (AWSSessionCredentials) sanitizedCredentials); } /* * In s3 sigv2, the way slash characters are encoded should be * consistent in both the request url and the encoded resource path. * Since we have to encode "//" to "/%2F" in the request url to make * httpclient works, we need to do the same encoding here for the * resource path. */ String encodedResourcePath = HttpUtils.appendUri(request.getEndpoint().getPath(), resourcePath, true); Date date = getSignatureDate(request.getTimeOffset()); request.addHeader(Headers.DATE, ServiceUtils.formatRfc822Date(date)); String canonicalString = makeS3CanonicalString(httpVerb, encodedResourcePath, request, null); log.debug("Calculated string to sign:\n\"" + canonicalString + "\""); String signature = super.signAndBase64Encode(canonicalString, sanitizedCredentials.getAWSSecretKey(), SigningAlgorithm.HmacSHA1); request.addHeader("Authorization", "AWS " + sanitizedCredentials.getAWSAccessKeyId() + ":" + signature); }
From source file:org.duracloud.s3storage.S3StorageProvider.java
License:Apache License
@Override protected Map<String, String> removeCalculatedProperties(Map<String, String> contentProperties) { contentProperties = super.removeCalculatedProperties(contentProperties); if (contentProperties != null) { contentProperties.remove(Headers.CONTENT_LENGTH); contentProperties.remove(Headers.CONTENT_TYPE); // Content-Type is set on ObjectMetadata object contentProperties.remove(Headers.LAST_MODIFIED); contentProperties.remove(Headers.DATE); contentProperties.remove(Headers.ETAG); contentProperties.remove(Headers.CONTENT_LENGTH.toLowerCase()); contentProperties.remove(Headers.CONTENT_TYPE.toLowerCase()); contentProperties.remove(Headers.LAST_MODIFIED.toLowerCase()); contentProperties.remove(Headers.DATE.toLowerCase()); contentProperties.remove(Headers.ETAG.toLowerCase()); }/*from w w w .ja v a2 s. co m*/ return contentProperties; }