예제 #1
0
 private void calculateAndReplaceAuthHeader(HttpRequest request, String toSign)
     throws HttpException {
   String signature = signString(toSign);
   if (signatureWire.enabled()) signatureWire.input(Utils.toInputStream(signature));
   request
       .getHeaders()
       .replaceValues(AtmosStorageHeaders.SIGNATURE, Collections.singletonList(signature));
 }
예제 #2
0
 public String createStringToSign(HttpRequest request) {
   utils.logRequest(signatureLog, request, ">>");
   StringBuilder buffer = new StringBuilder();
   // re-sign the request
   appendMethod(request, buffer);
   appendPayloadMetadata(request, buffer);
   appendHttpHeaders(request, buffer);
   appendCanonicalizedResource(request, buffer);
   appendCanonicalizedHeaders(request, buffer);
   if (signatureWire.enabled()) signatureWire.output(buffer.toString());
   return buffer.toString();
 }
  @VisibleForTesting
  HttpRequest calculateAndReplaceAuthorizationHeaders(HttpRequest request, String toSign)
      throws HttpException {
    String signature = sign(toSign);
    if (signatureWire.enabled()) signatureWire.input(Strings2.toInputStream(signature));
    String[] signatureLines =
        Iterables.toArray(Splitter.fixedLength(60).split(signature), String.class);

    Multimap<String, String> headers = ArrayListMultimap.create();
    for (int i = 0; i < signatureLines.length; i++) {
      headers.put("X-Ops-Authorization-" + (i + 1), signatureLines[i]);
    }
    return request.toBuilder().replaceHeaders(headers).build();
  }