public VAppTemplate apply(Exception from) { if (from instanceof AuthorizationException) { return null; } return propagateOrNull(from); } }
/** * Specifies the customizationScript used to run instances with */ public VCloudTemplateOptions customizationScript(String customizationScript) { Utils.checkNotEmpty(customizationScript, "customizationScript must be non-empty"); this.customizationScript = customizationScript; return this; }
@Override public Properties build() { String endpoint = properties.getProperty(PROPERTY_ENDPOINT); String identity = properties.getProperty(PROPERTY_IDENTITY); properties.setProperty(PROPERTY_ENDPOINT, Utils.replaceAll(endpoint, IDENTITY_PATTERN, identity)); return super.build(); }
message = Utils.toStringAndClose(response.getPayload().getInput()); } catch (IOException e1) { message = Utils.toStringAndClose(response.getPayload().getInput()); } catch (IOException e) {
void calculateAndReplaceAuthHeader(HttpRequest request, String toSign) throws HttpException { String signature = sign(toSign); if (signatureWire.enabled()) signatureWire.input(Utils.toInputStream(signature)); request.getHeaders().replaceValues(HttpHeaders.AUTHORIZATION, Collections.singletonList(authTag + " " + accessKey + ":" + signature)); }
/** * This implementation invokes {@link #clearContainer} then {@link S3Client#deleteBucketIfEmpty} * until it is true. */ public void clearAndDeleteContainer(final String container) { try { if (!Utils.eventuallyTrue(new Supplier<Boolean>() { public Boolean get() { clearContainer(container); return sync.deleteBucketIfEmpty(container); } }, 30000)) { throw new IllegalStateException(container + " still exists after deleting!"); } } catch (InterruptedException e) { new IllegalStateException(container + " interrupted during deletion!", e); } }
@Override public SshClient create(IPSocket socket, Credentials credentials) { return isPrivateKeyCredential(credentials) ? create(socket, credentials.identity, credentials.credential.getBytes()) : create(socket, credentials.identity, credentials.credential); } }
message = Utils.toStringAndClose(response.getPayload().getInput()); } catch (IOException e) {
private void calculateAndReplaceAuthHeader(HttpRequest request, String toSign) throws HttpException { String signature = signString(toSign); if (signatureWire.enabled()) signatureWire.input(Utils.toInputStream(signature)); request.getHeaders().replaceValues(HttpHeaders.AUTHORIZATION, Collections.singletonList("SharedKeyLite " + identity + ":" + signature)); }
message = Utils.toStringAndClose(response.getPayload().getInput()); } catch (IOException e) {
public Boolean apply(Exception from) { if (from instanceof AWSResponseException) { AWSResponseException responseException = (AWSResponseException) from; if ("BucketAlreadyOwnedByYou".equals(responseException.getError().getCode())) { return false; } } return Boolean.class.cast(propagateOrNull(from)); } }
/** * Specifies the subnetId used to run instances in */ public EC2TemplateOptions subnetId(String subnetId) { checkNotNull(subnetId, "subnetId cannot be null"); Utils.checkNotEmpty(subnetId, "subnetId must be non-empty"); this.subnetId = subnetId; return this; }
void appendAmzHeaders(HttpRequest request, StringBuilder toSign) { Set<String> headers = new TreeSet<String>(request.getHeaders().keySet()); for (String header : headers) { if (header.startsWith("x-" + headerTag + "-")) { toSign.append(header.toLowerCase()).append(":"); for (String value : request.getHeaders().get(header)) { toSign.append(Utils.replaceAll(value, NEWLINE_PATTERN, "")).append(","); } toSign.deleteCharAt(toSign.lastIndexOf(",")); toSign.append("\n"); } } }
@VisibleForTesting public String sign(String stringToSign) { String signature; try { signature = CryptoStreams.base64(CryptoStreams.mac(InputSuppliers.of(stringToSign), crypto .hmacSHA256(secretKey.getBytes()))); if (signatureWire.enabled()) signatureWire.input(Utils.toInputStream(signature)); } catch (Exception e) { throw new HttpException("error signing request", e); } return signature; }
try { executor.connect(); String outputString = Utils.toStringAndClose(executor.getInputStream()); String errorString = error.toString(); int errorStatus = executor.getExitStatus();
public Boolean apply(Exception from) { if (from instanceof AzureStorageResponseException) { AzureStorageResponseException responseException = (AzureStorageResponseException) from; if ("ContainerAlreadyExists".equals(responseException.getError().getCode())) { return false; } } return Boolean.class.cast(propagateOrNull(from)); }
/** * Specifies the keypair used to run instances with */ public EC2TemplateOptions placementGroup(String placementGroup) { checkNotNull(placementGroup, "use noPlacementGroup option to request boot without a keypair"); checkState(!noPlacementGroup, "you cannot specify both options placementGroup and noPlacementGroup"); Utils.checkNotEmpty(placementGroup, "placementGroup must be non-empty"); this.placementGroup = placementGroup; return this; }
private void appendCanonicalizedHeaders(HttpRequest request, StringBuilder toSign) { Set<String> headers = new TreeSet<String>(request.getHeaders().keySet()); for (String header : headers) { if (header.startsWith("x-ms-")) { toSign.append(header.toLowerCase()).append(":"); for (String value : request.getHeaders().get(header)) { toSign.append(Utils.replaceAll(value, NEWLINE_PATTERN, "")).append(","); } toSign.deleteCharAt(toSign.lastIndexOf(",")); toSign.append("\n"); } } }
public Void apply(Exception from) { if (from instanceof AWSResponseException) { AWSResponseException e = (AWSResponseException) from; if (e.getError().getCode().equals("IncorrectState") && e.getError().getCode().contains("available")) return null; } return Void.class.cast(propagateOrNull(from)); }
/** * Specifies the keypair used to run instances with */ public EC2TemplateOptions keyPair(String keyPair) { checkNotNull(keyPair, "use noKeyPair option to request boot without a keypair"); checkState(!noKeyPair, "you cannot specify both options keyPair and noKeyPair"); Utils.checkNotEmpty(keyPair, "keypair must be non-empty"); this.keyPair = keyPair; return this; }