Esempio n. 1
0
 public String signString(String toSign) {
   String signature;
   try {
     signature =
         CryptoStreams.base64(CryptoStreams.mac(InputSuppliers.of(toSign), crypto.hmacSHA1(key)));
   } catch (Exception e) {
     throw new HttpException("error signing request", e);
   }
   return signature;
 }
Esempio n. 2
0
 @Override
 public Object apply(Exception from) {
   Iterable<HttpResponseException> throwables =
       Iterables.filter(Throwables.getCausalChain(from), HttpResponseException.class);
   HttpResponseException exception = Iterables.getFirst(throwables, null);
   if (exception != null
       && exception.getResponse() != null
       && exception.getResponse().getStatusCode() >= 400
       && exception.getResponse().getStatusCode() < 500) {
     try {
       Error error =
           JAXB.unmarshal(InputSuppliers.of(exception.getContent()).getInput(), Error.class);
       throw new VCloudDirectorException(error);
     } catch (IOException e) {
       Throwables.propagate(e);
     }
   }
   throw Throwables.propagate(from);
 }