EMMA Coverage Report (generated Wed Jun 22 19:47:49 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 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
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