Refine search
public String apply(HttpResponse from) { if (from.getPayload() == null) return null; try { if (from.getStatusCode() >= 200) { InputStream payload = from.getPayload().getInput(); String toReturn = null; try { toReturn = Strings2.toStringAndClose(payload); } catch (IOException e) { throw new HttpException(String.format( "Couldn't receive response %1$s, payload: %2$s ", from, toReturn), e); } return toReturn; } else { throw new HttpException(String.format("Unhandled status code - %1$s", from)); } } finally { releasePayload(from); } }
public URI apply(HttpResponse from) { if (from.getStatusCode() > 206) throw new HttpException(String.format("Unhandled status code - %1$s", from)); if ("text/uri-list".equals(from.getFirstHeaderOrNull(CONTENT_TYPE))) { try { if (from.getPayload().getInput() == null) throw new HttpResponseException("no content", null, from); String toParse = Strings2.toString(from.getPayload()); return URI.create(toParse.trim()); } catch (IOException e) {
public String apply(HttpResponse from) { releasePayload(from); String eTag = from.getFirstHeaderOrNull(ETAG); if (eTag == null) { // TODO: Cloud Files sends incorrectly cased ETag header... Remove this when fixed. eTag = from.getFirstHeaderOrNull("Etag"); } if (eTag != null) { return eTag; } throw new HttpException("did not receive ETag"); }
/** * hmac sha256 * * @param toSign string to sign * @param key hash key */ protected byte[] hmacSHA256(String toSign, byte[] key) { try { return readBytes(toInputStream(toSign), hmacSHA256(crypto, key)); } catch (IOException e) { throw new HttpException("read sign error", e); } catch (InvalidKeyException e) { throw new HttpException("invalid key", e); } }
static byte[] hmacSHA256(String data, byte[] key) { try { String algorithm = "HmacSHA256"; Mac mac = Mac.getInstance(algorithm); mac.init(new SecretKeySpec(key, algorithm)); return mac.doFinal(data.getBytes(UTF_8)); } catch (GeneralSecurityException e) { throw new HttpException(e); } }
public URI apply(HttpResponse from) { if (from.getStatusCode() > 206) throw new HttpException(String.format("Unhandled status code - %1$s", from)); if ("text/uri-list".equals(from.getFirstHeaderOrNull(CONTENT_TYPE))) { try { if (from.getPayload().getInput() == null) throw new HttpResponseException("no content", null, from); String toParse = Strings2.toString(from.getPayload()); return URI.create(toParse.trim()); } catch (IOException e) {
public String apply(HttpResponse from) { releasePayload(from); String eTag = from.getFirstHeaderOrNull(ETAG); if (eTag == null) { // TODO: Cloud Files sends incorrectly cased ETag header... Remove this when fixed. eTag = from.getFirstHeaderOrNull("Etag"); } if (eTag != null) { return eTag; } throw new HttpException("did not receive ETag"); }
/** * hmac sha256 * * @param toSign string to sign * @param key hash key */ protected byte[] hmacSHA256(String toSign, byte[] key) { try { return readBytes(toInputStream(toSign), hmacSHA256(crypto, key)); } catch (IOException e) { throw new HttpException("read sign error", e); } catch (InvalidKeyException e) { throw new HttpException("invalid key", e); } }
static byte[] hmacSHA256(String data, byte[] key) { try { String algorithm = "HmacSHA256"; Mac mac = Mac.getInstance(algorithm); mac.init(new SecretKeySpec(key, algorithm)); return mac.doFinal(data.getBytes(UTF_8)); } catch (GeneralSecurityException e) { throw new HttpException(e); } }
public String apply(HttpResponse from) { if (from.getPayload() == null) return null; try { if (from.getStatusCode() >= 200) { InputStream payload = from.getPayload().getInput(); String toReturn = null; try { toReturn = Strings2.toStringAndClose(payload); } catch (IOException e) { throw new HttpException(String.format( "Couldn't receive response %1$s, payload: %2$s ", from, toReturn), e); } return toReturn; } else { throw new HttpException(String.format("Unhandled status code - %1$s", from)); } } finally { releasePayload(from); } }
public URI apply(HttpResponse from) { if (from.getStatusCode() > 206) throw new HttpException(String.format("Unhandled status code - %1$s", from)); if ("text/uri-list".equals(from.getFirstHeaderOrNull(CONTENT_TYPE))) { try { if (from.getPayload().getInput() == null) throw new HttpResponseException("no content", null, from); String toParse = Strings2.toString(from.getPayload()); return URI.create(toParse.trim()); } catch (IOException e) {
public String apply(HttpResponse from) { releasePayload(from); String eTag = from.getFirstHeaderOrNull(ETAG); if (eTag == null) { // TODO: Cloud Files sends incorrectly cased ETag header... Remove this when fixed. eTag = from.getFirstHeaderOrNull("Etag"); } if (eTag != null) { return eTag; } throw new HttpException("did not receive ETag"); }
/** * hmac sha256 * * @param toSign string to sign * @param key hash key */ protected byte[] hmacSHA256(String toSign, byte[] key) { try { return readBytes(toInputStream(toSign), hmacSHA256(crypto, key)); } catch (IOException e) { throw new HttpException("read sign error", e); } catch (InvalidKeyException e) { throw new HttpException("invalid key", e); } }
static byte[] hmacSHA256(String data, byte[] key) { try { String algorithm = "HmacSHA256"; Mac mac = Mac.getInstance(algorithm); mac.init(new SecretKeySpec(key, algorithm)); return mac.doFinal(data.getBytes(UTF_8)); } catch (GeneralSecurityException e) { throw new HttpException(e); } }
public String apply(HttpResponse from) { if (from.getPayload() == null) return null; try { if (from.getStatusCode() >= 200) { InputStream payload = from.getPayload().getInput(); String toReturn = null; try { toReturn = Strings2.toStringAndClose(payload); } catch (IOException e) { throw new HttpException(String.format( "Couldn't receive response %1$s, payload: %2$s ", from, toReturn), e); } return toReturn; } else { throw new HttpException(String.format("Unhandled status code - %1$s", from)); } } finally { releasePayload(from); } }
public String apply(HttpResponse from) { releasePayload(from); String eTag = from.getFirstHeaderOrNull(ETAG); if (eTag == null) { // TODO: Cloud Files sends incorrectly cased ETag header... Remove this when fixed. eTag = from.getFirstHeaderOrNull("Etag"); } if (eTag != null) { return eTag; } throw new HttpException("did not receive ETag"); }
public String signString(String toSign) { try { ByteProcessor<byte[]> hmacSHA256 = asByteProcessor(crypto.hmacSHA256(base64().decode(creds.get().credential))); return base64().encode(readBytes(toInputStream(toSign), hmacSHA256)); } catch (Exception e) { throw new HttpException("error signing request", e); } }
static byte[] hmacSHA256(String data, byte[] key) { try { String algorithm = "HmacSHA256"; Mac mac = Mac.getInstance(algorithm); mac.init(new SecretKeySpec(key, algorithm)); return mac.doFinal(data.getBytes(UTF_8)); } catch (GeneralSecurityException e) { throw new HttpException(e); } }
public String apply(HttpResponse from) { if (from.getPayload() == null) return null; try { if (from.getStatusCode() >= 200) { InputStream payload = from.getPayload().getInput(); String toReturn = null; try { toReturn = Strings2.toStringAndClose(payload); } catch (IOException e) { throw new HttpException(String.format( "Couldn't receive response %1$s, payload: %2$s ", from, toReturn), e); } return toReturn; } else { throw new HttpException(String.format("Unhandled status code - %1$s", from)); } } finally { releasePayload(from); } }
public String apply(HttpResponse from) { releasePayload(from); String eTag = from.getFirstHeaderOrNull(ETAG); if (eTag == null) { // TODO: Cloud Files sends incorrectly cased ETag header... Remove this when fixed. eTag = from.getFirstHeaderOrNull("Etag"); } if (eTag != null) { return eTag; } throw new HttpException("did not receive ETag"); }