Merge pull request #478 from andrewgaul/first-headers-to-sign

Prefer ImmutableCollection over mutable array
This commit is contained in:
Adrian Cole 2012-03-19 19:13:46 -07:00
commit 73749de4e3
2 changed files with 8 additions and 5 deletions

View File

@ -62,6 +62,7 @@ import org.jclouds.s3.Bucket;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.Ordering;
@ -85,9 +86,9 @@ public class RequestAuthorizeSignature implements HttpRequestFilter, RequestSign
}
};
private final String[] firstHeadersToSign = new String[] { HttpHeaders.DATE };
private static final Collection<String> FIRST_HEADERS_TO_SIGN = ImmutableList.of(HttpHeaders.DATE);
public static Set<String> SIGNED_PARAMETERS = ImmutableSet.of("acl", "torrent", "logging", "location", "policy",
private static final Set<String> SIGNED_PARAMETERS = ImmutableSet.of("acl", "torrent", "logging", "location", "policy",
"requestPayment", "versioning", "versions", "versionId", "notification", "uploadId", "uploads",
"partNumber", "website", "response-content-type", "response-content-language", "response-expires",
"response-cache-control", "response-content-disposition", "response-content-encoding");
@ -209,7 +210,7 @@ public class RequestAuthorizeSignature implements HttpRequestFilter, RequestSign
buffer.append(
utils.valueOrEmpty(request.getPayload() == null ? request.getFirstHeaderOrNull(HttpHeaders.CONTENT_TYPE)
: request.getPayload().getContentMetadata().getContentType())).append("\n");
for (String header : firstHeadersToSign)
for (String header : FIRST_HEADERS_TO_SIGN)
buffer.append(valueOrEmpty(request.getHeaders().get(header))).append("\n");
}

View File

@ -20,6 +20,7 @@ package org.jclouds.azure.storage.filters;
import static org.jclouds.util.Patterns.NEWLINE_PATTERN;
import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;
@ -45,6 +46,7 @@ import org.jclouds.logging.Logger;
import org.jclouds.util.Strings2;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Multimaps;
@ -58,7 +60,7 @@ import com.google.common.collect.Multimaps;
*/
@Singleton
public class SharedKeyLiteAuthentication implements HttpRequestFilter {
private final String[] firstHeadersToSign = new String[] { HttpHeaders.DATE };
private static final Collection<String> FIRST_HEADERS_TO_SIGN = ImmutableList.of(HttpHeaders.DATE);
private final SignatureWire signatureWire;
private final String identity;
@ -163,7 +165,7 @@ public class SharedKeyLiteAuthentication implements HttpRequestFilter {
}
private void appendHttpHeaders(HttpRequest request, StringBuilder toSign) {
for (String header : firstHeadersToSign)
for (String header : FIRST_HEADERS_TO_SIGN)
toSign.append(utils.valueOrEmpty(request.getHeaders().get(header))).append("\n");
}