EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.azure.storage.util]

COVERAGE SUMMARY FOR SOURCE FILE [AzureStorageUtils.java]

nameclass, %method, %block, %line, %
AzureStorageUtils.java100% (1/1)100% (2/2)65%  (26/40)71%  (5/7)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AzureStorageUtils100% (1/1)100% (2/2)65%  (26/40)71%  (5/7)
parseAzureStorageErrorFromContent (HttpCommand, HttpResponse, InputStream): A... 100% (1/1)62%  (23/37)67%  (4/6)
AzureStorageUtils (): void 100% (1/1)100% (3/3)100% (1/1)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.azure.storage.util;
20 
21import java.io.InputStream;
22 
23import javax.inject.Inject;
24import javax.inject.Provider;
25 
26import org.jclouds.azure.storage.domain.AzureStorageError;
27import org.jclouds.azure.storage.filters.SharedKeyLiteAuthentication;
28import org.jclouds.azure.storage.reference.AzureStorageHeaders;
29import org.jclouds.azure.storage.xml.ErrorHandler;
30import org.jclouds.http.HttpCommand;
31import org.jclouds.http.HttpException;
32import org.jclouds.http.HttpResponse;
33import org.jclouds.http.functions.ParseSax;
34 
35/**
36 * Encryption, Hashing, and IO Utilities needed to sign and verify Azure Storage requests and
37 * responses.
38 * 
39 * @author Adrian Cole
40 */
41public class AzureStorageUtils {
42 
43   @Inject
44   SharedKeyLiteAuthentication signer;
45 
46   @Inject
47   ParseSax.Factory factory;
48 
49   @Inject
50   Provider<ErrorHandler> errorHandlerProvider;
51 
52   public AzureStorageError parseAzureStorageErrorFromContent(HttpCommand command,
53            HttpResponse response, InputStream content) throws HttpException {
54      AzureStorageError error = factory.create(errorHandlerProvider.get()).parse(content);
55      error.setRequestId(response.getFirstHeaderOrNull(AzureStorageHeaders.REQUEST_ID));
56      if ("AuthenticationFailed".equals(error.getCode())) {
57         error.setStringSigned(signer.createStringToSign(command.getCurrentRequest()));
58         error.setSignature(signer.signString(error.getStringSigned()));
59      }
60      return error;
61   }
62 
63}

[all classes][org.jclouds.azure.storage.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov