JCLOUDS-766: Do not resign already-signed requests

Previously jclouds would add both a V2 and V4 signature to some
requests which Amazon rejects.  Addresses AWSS3BlobSignerLiveTest test
failures with time-limited requests.
This commit is contained in:
Andrew Gaul 2016-03-27 16:19:55 -07:00
parent 6964ef6c8f
commit fdec2fa99f
1 changed files with 5 additions and 1 deletions

View File

@ -17,11 +17,14 @@
package org.jclouds.aws.s3.filters;
import static org.jclouds.http.utils.Queries.queryParser;
import static org.jclouds.aws.s3.blobstore.AWSS3BlobRequestSigner.TEMPORARY_SIGNATURE_PARAM;
import static org.jclouds.s3.filters.AwsSignatureV4Constants.AMZ_SIGNATURE_PARAM;
import javax.inject.Inject;
import javax.inject.Singleton;
import com.google.common.collect.Multimap;
import org.jclouds.http.HttpRequest;
import org.jclouds.s3.filters.Aws4SignerForAuthorizationHeader;
import org.jclouds.s3.filters.Aws4SignerForChunkedUpload;
@ -50,7 +53,8 @@ public class AWSRequestAuthorizeSignatureV4 extends RequestAuthorizeSignatureV4
* with expiration.
*/
if (queryParser().apply(request.getEndpoint().getQuery()).containsKey(AMZ_SIGNATURE_PARAM)) {
Multimap<String, String> queryMap = queryParser().apply(request.getEndpoint().getQuery());
if (queryMap.containsKey(AMZ_SIGNATURE_PARAM) || queryMap.containsKey(TEMPORARY_SIGNATURE_PARAM)) {
return request;
}
return super.signForAuthorizationHeader(request);