From f93aa75f70946645187e7e06cf1edf3d948c91cb Mon Sep 17 00:00:00 2001 From: Pooneh Date: Tue, 7 Jun 2016 09:56:51 -0700 Subject: [PATCH 01/56] Key Vault generated code and POM files --- azure-keyvault/pom.xml | 121 + .../keyvault/implementation/api/Action.java | 41 + .../api/AdministratorDetails.java | 118 + .../implementation/api/Attributes.java | 122 + .../api/BackupKeyResultInner.java | 30 + .../api/CertificateAttributesInner.java | 14 + .../api/CertificateBundleInner.java | 191 + .../api/CertificateCreateParameters.java | 93 + .../api/CertificateImportParameters.java | 147 + .../api/CertificateIssuerItemInner.java | 64 + .../api/CertificateItemInner.java | 117 + .../api/CertificateMergeParameters.java | 94 + .../api/CertificateOperationInner.java | 235 + .../api/CertificatePolicyInner.java | 187 + .../api/CertificateUpdateParameters.java | 67 + .../keyvault/implementation/api/Contact.java | 91 + .../implementation/api/ContactsInner.java | 57 + .../implementation/api/IssuerAttributes.java | 70 + .../implementation/api/IssuerBundleInner.java | 131 + .../implementation/api/IssuerCredentials.java | 67 + .../implementation/api/IssuerReference.java | 39 + .../implementation/api/JsonWebKeyInner.java | 343 + .../api/KeyAttributesInner.java | 14 + .../implementation/api/KeyBundleInner.java | 90 + .../api/KeyCreateParameters.java | 146 + .../api/KeyImportParameters.java | 119 + .../implementation/api/KeyItemInner.java | 90 + .../api/KeyOperationResultInner.java | 45 + .../api/KeyOperationsParameters.java | 67 + .../implementation/api/KeyProperties.java | 117 + .../api/KeyRestoreParameters.java | 41 + .../api/KeyUpdateParameters.java | 95 + .../api/KeyVaultClientImpl.java | 5906 +++++++++++++++++ .../implementation/api/KeyVaultError.java | 60 + .../api/KeyVaultErrorException.java | 85 + .../api/KeyVerifyParameters.java | 94 + .../api/KeyVerifyResultInner.java | 30 + .../implementation/api/LifetimeAction.java | 64 + .../api/OrganizationDetails.java | 218 + .../keyvault/implementation/api/PageImpl.java | 73 + ...endingCertificateSigningRequestResult.java | 30 + .../api/SecretAttributesInner.java | 14 + .../implementation/api/SecretBundleInner.java | 140 + .../implementation/api/SecretItemInner.java | 115 + .../implementation/api/SecretProperties.java | 41 + .../api/SecretSetParameters.java | 118 + .../api/SecretUpdateParameters.java | 92 + .../api/SubjectAlternativeNames.java | 92 + .../keyvault/implementation/api/Trigger.java | 41 + .../api/X509CertificateProperties.java | 144 + .../implementation/api/package-info.java | 9 + .../keyvault/implementation/package-info.java | 9 + .../azure/keyvault/package-info.java | 9 + 53 files changed, 10647 insertions(+) create mode 100644 azure-keyvault/pom.xml create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Action.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/AdministratorDetails.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Attributes.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/BackupKeyResultInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateAttributesInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateBundleInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateCreateParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateImportParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateIssuerItemInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateItemInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateMergeParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateOperationInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificatePolicyInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateUpdateParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Contact.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/ContactsInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerAttributes.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerBundleInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerCredentials.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerReference.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/JsonWebKeyInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyAttributesInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyBundleInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyCreateParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyImportParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyItemInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationResultInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationsParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyProperties.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyRestoreParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyUpdateParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultClientImpl.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultError.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultErrorException.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyResultInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/LifetimeAction.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/OrganizationDetails.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PageImpl.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PendingCertificateSigningRequestResult.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretAttributesInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretBundleInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretItemInner.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretProperties.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretSetParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretUpdateParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SubjectAlternativeNames.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Trigger.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/X509CertificateProperties.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/package-info.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml new file mode 100644 index 0000000000000..4c717b7a4f703 --- /dev/null +++ b/azure-keyvault/pom.xml @@ -0,0 +1,121 @@ + + + 4.0.0 + + com.microsoft.azure + azure-parent + 1.0.0-SNAPSHOT + ../pom.xml + + + azure-keyvault + jar + + Microsoft Azure SDK for Key Vault + This package contains Microsoft Azure Key Vault SDK. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + UTF-8 + + + + + + microsoft + Microsoft + + + + + + com.microsoft.azure + azure-client-runtime + 1.0.0-SNAPSHOT + + + org.apache.httpcomponents + httpclient + 4.5.2 + + + junit + junit + test + + + com.microsoft.azure + azure-client-authentication + 1.0.0-beta1 + test + + + com.microsoft.azure + azure-core + 0.9.3 + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.storage + /** +
* Copyright (c) Microsoft Corporation. All rights reserved. +
* Licensed under the MIT License. See License.txt in the project root for +
* license information. +
*/]]>
+
+
+ +
+
+
diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Action.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Action.java new file mode 100644 index 0000000000000..16f3929d57286 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Action.java @@ -0,0 +1,41 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The Action model. + */ +public class Action { + /** + * The type of the action. + */ + @JsonProperty(value = "action_type") + private String actionType; + + /** + * Get the actionType value. + * + * @return the actionType value + */ + public String actionType() { + return this.actionType; + } + + /** + * Set the actionType value. + * + * @param actionType the actionType value to set + * @return the Action object itself. + */ + public Action setActionType(String actionType) { + this.actionType = actionType; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/AdministratorDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/AdministratorDetails.java new file mode 100644 index 0000000000000..3fac9e65f5bfd --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/AdministratorDetails.java @@ -0,0 +1,118 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The AdministratorDetails model. + */ +public class AdministratorDetails { + /** + * First name. + */ + @JsonProperty(value = "first_name") + private String firstName; + + /** + * Last name. + */ + @JsonProperty(value = "last_name") + private String lastName; + + /** + * Email addresss. + */ + @JsonProperty(value = "email") + private String emailAddress; + + /** + * Phone number. + */ + private String phone; + + /** + * Get the firstName value. + * + * @return the firstName value + */ + public String firstName() { + return this.firstName; + } + + /** + * Set the firstName value. + * + * @param firstName the firstName value to set + * @return the AdministratorDetails object itself. + */ + public AdministratorDetails setFirstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get the lastName value. + * + * @return the lastName value + */ + public String lastName() { + return this.lastName; + } + + /** + * Set the lastName value. + * + * @param lastName the lastName value to set + * @return the AdministratorDetails object itself. + */ + public AdministratorDetails setLastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get the emailAddress value. + * + * @return the emailAddress value + */ + public String emailAddress() { + return this.emailAddress; + } + + /** + * Set the emailAddress value. + * + * @param emailAddress the emailAddress value to set + * @return the AdministratorDetails object itself. + */ + public AdministratorDetails setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + return this; + } + + /** + * Get the phone value. + * + * @return the phone value + */ + public String phone() { + return this.phone; + } + + /** + * Set the phone value. + * + * @param phone the phone value to set + * @return the AdministratorDetails object itself. + */ + public AdministratorDetails setPhone(String phone) { + this.phone = phone; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Attributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Attributes.java new file mode 100644 index 0000000000000..5e47048138282 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Attributes.java @@ -0,0 +1,122 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The Attributes model. + */ +public class Attributes { + /** + * Determines whether the object is enabled. + */ + private Boolean enabled; + + /** + * Not before date in UTC. + */ + @JsonProperty(value = "nbf") + private Long notBefore; + + /** + * Expiry date in UTC. + */ + @JsonProperty(value = "exp") + private Long expires; + + /** + * Creation time in UTC. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private Long created; + + /** + * Last updated time in UTC. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private Long updated; + + /** + * Get the enabled value. + * + * @return the enabled value + */ + public Boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled value. + * + * @param enabled the enabled value to set + * @return the Attributes object itself. + */ + public Attributes setEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the notBefore value. + * + * @return the notBefore value + */ + public Long notBefore() { + return this.notBefore; + } + + /** + * Set the notBefore value. + * + * @param notBefore the notBefore value to set + * @return the Attributes object itself. + */ + public Attributes setNotBefore(Long notBefore) { + this.notBefore = notBefore; + return this; + } + + /** + * Get the expires value. + * + * @return the expires value + */ + public Long expires() { + return this.expires; + } + + /** + * Set the expires value. + * + * @param expires the expires value to set + * @return the Attributes object itself. + */ + public Attributes setExpires(Long expires) { + this.expires = expires; + return this; + } + + /** + * Get the created value. + * + * @return the created value + */ + public Long created() { + return this.created; + } + + /** + * Get the updated value. + * + * @return the updated value + */ + public Long updated() { + return this.updated; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/BackupKeyResultInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/BackupKeyResultInner.java new file mode 100644 index 0000000000000..afa1c41361b9e --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/BackupKeyResultInner.java @@ -0,0 +1,30 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The BackupKeyResultInner model. + */ +public class BackupKeyResultInner { + /** + * The backup blob containing the backed up key. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String value; + + /** + * Get the value value. + * + * @return the value value + */ + public String value() { + return this.value; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateAttributesInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateAttributesInner.java new file mode 100644 index 0000000000000..0950c26cb7842 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateAttributesInner.java @@ -0,0 +1,14 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + + +/** + * The CertificateAttributesInner model. + */ +public class CertificateAttributesInner extends Attributes { +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateBundleInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateBundleInner.java new file mode 100644 index 0000000000000..b17eb35923a9e --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateBundleInner.java @@ -0,0 +1,191 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The CertificateBundleInner model. + */ +public class CertificateBundleInner { + /** + * The certificate id. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * The key id. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String kid; + + /** + * The secret id. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String sid; + + /** + * Thumbprint of the certificate. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String x5t; + + /** + * The management policy. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private CertificatePolicyInner policy; + + /** + * CER contents of x509 certificate. + */ + private String cer; + + /** + * The content type of the secret. + */ + private String contentType; + + /** + * The certificate attributes. + */ + private CertificateAttributesInner attributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get the kid value. + * + * @return the kid value + */ + public String kid() { + return this.kid; + } + + /** + * Get the sid value. + * + * @return the sid value + */ + public String sid() { + return this.sid; + } + + /** + * Get the x5t value. + * + * @return the x5t value + */ + public String x5t() { + return this.x5t; + } + + /** + * Get the policy value. + * + * @return the policy value + */ + public CertificatePolicyInner policy() { + return this.policy; + } + + /** + * Get the cer value. + * + * @return the cer value + */ + public String cer() { + return this.cer; + } + + /** + * Set the cer value. + * + * @param cer the cer value to set + * @return the CertificateBundleInner object itself. + */ + public CertificateBundleInner setCer(String cer) { + this.cer = cer; + return this; + } + + /** + * Get the contentType value. + * + * @return the contentType value + */ + public String contentType() { + return this.contentType; + } + + /** + * Set the contentType value. + * + * @param contentType the contentType value to set + * @return the CertificateBundleInner object itself. + */ + public CertificateBundleInner setContentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public CertificateAttributesInner attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the CertificateBundleInner object itself. + */ + public CertificateBundleInner setAttributes(CertificateAttributesInner attributes) { + this.attributes = attributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the CertificateBundleInner object itself. + */ + public CertificateBundleInner setTags(Map tags) { + this.tags = tags; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateCreateParameters.java new file mode 100644 index 0000000000000..47b6ceee2dea0 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateCreateParameters.java @@ -0,0 +1,93 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The CertificateCreateParameters model. + */ +public class CertificateCreateParameters { + /** + * The management policy for the certificate. + */ + @JsonProperty(value = "policy", required = true) + private CertificatePolicyInner certificatePolicy; + + /** + * The attributes of the certificate (optional). + */ + @JsonProperty(value = "attributes") + private CertificateAttributesInner certificateAttributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the certificatePolicy value. + * + * @return the certificatePolicy value + */ + public CertificatePolicyInner certificatePolicy() { + return this.certificatePolicy; + } + + /** + * Set the certificatePolicy value. + * + * @param certificatePolicy the certificatePolicy value to set + * @return the CertificateCreateParameters object itself. + */ + public CertificateCreateParameters setCertificatePolicy(CertificatePolicyInner certificatePolicy) { + this.certificatePolicy = certificatePolicy; + return this; + } + + /** + * Get the certificateAttributes value. + * + * @return the certificateAttributes value + */ + public CertificateAttributesInner certificateAttributes() { + return this.certificateAttributes; + } + + /** + * Set the certificateAttributes value. + * + * @param certificateAttributes the certificateAttributes value to set + * @return the CertificateCreateParameters object itself. + */ + public CertificateCreateParameters setCertificateAttributes(CertificateAttributesInner certificateAttributes) { + this.certificateAttributes = certificateAttributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the CertificateCreateParameters object itself. + */ + public CertificateCreateParameters setTags(Map tags) { + this.tags = tags; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateImportParameters.java new file mode 100644 index 0000000000000..5ac03538516ac --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateImportParameters.java @@ -0,0 +1,147 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The CertificateImportParameters model. + */ +public class CertificateImportParameters { + /** + * Base64 encoded representaion of the certificate object to import. This + * certificate needs to contain the private key. + */ + @JsonProperty(value = "value", required = true) + private String base64EncodedCertificate; + + /** + * If the private key in base64EncodedCertificate is encrypted, the + * password used for encryption. + */ + @JsonProperty(value = "pwd", required = true) + private String password; + + /** + * The management policy for the certificate. + */ + @JsonProperty(value = "policy", required = true) + private CertificatePolicyInner certificatePolicy; + + /** + * The attributes of the certificate (optional). + */ + @JsonProperty(value = "attributes") + private CertificateAttributesInner certificateAttributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the base64EncodedCertificate value. + * + * @return the base64EncodedCertificate value + */ + public String base64EncodedCertificate() { + return this.base64EncodedCertificate; + } + + /** + * Set the base64EncodedCertificate value. + * + * @param base64EncodedCertificate the base64EncodedCertificate value to set + * @return the CertificateImportParameters object itself. + */ + public CertificateImportParameters setBase64EncodedCertificate(String base64EncodedCertificate) { + this.base64EncodedCertificate = base64EncodedCertificate; + return this; + } + + /** + * Get the password value. + * + * @return the password value + */ + public String password() { + return this.password; + } + + /** + * Set the password value. + * + * @param password the password value to set + * @return the CertificateImportParameters object itself. + */ + public CertificateImportParameters setPassword(String password) { + this.password = password; + return this; + } + + /** + * Get the certificatePolicy value. + * + * @return the certificatePolicy value + */ + public CertificatePolicyInner certificatePolicy() { + return this.certificatePolicy; + } + + /** + * Set the certificatePolicy value. + * + * @param certificatePolicy the certificatePolicy value to set + * @return the CertificateImportParameters object itself. + */ + public CertificateImportParameters setCertificatePolicy(CertificatePolicyInner certificatePolicy) { + this.certificatePolicy = certificatePolicy; + return this; + } + + /** + * Get the certificateAttributes value. + * + * @return the certificateAttributes value + */ + public CertificateAttributesInner certificateAttributes() { + return this.certificateAttributes; + } + + /** + * Set the certificateAttributes value. + * + * @param certificateAttributes the certificateAttributes value to set + * @return the CertificateImportParameters object itself. + */ + public CertificateImportParameters setCertificateAttributes(CertificateAttributesInner certificateAttributes) { + this.certificateAttributes = certificateAttributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the CertificateImportParameters object itself. + */ + public CertificateImportParameters setTags(Map tags) { + this.tags = tags; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateIssuerItemInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateIssuerItemInner.java new file mode 100644 index 0000000000000..ae9dc7c45938f --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateIssuerItemInner.java @@ -0,0 +1,64 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + + +/** + * The CertificateIssuerItemInner model. + */ +public class CertificateIssuerItemInner { + /** + * Certificate Identifier. + */ + private String id; + + /** + * The name of the issuer. + */ + private String provider; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the CertificateIssuerItemInner object itself. + */ + public CertificateIssuerItemInner setId(String id) { + this.id = id; + return this; + } + + /** + * Get the provider value. + * + * @return the provider value + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider value. + * + * @param provider the provider value to set + * @return the CertificateIssuerItemInner object itself. + */ + public CertificateIssuerItemInner setProvider(String provider) { + this.provider = provider; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateItemInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateItemInner.java new file mode 100644 index 0000000000000..779b0e8dd2c65 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateItemInner.java @@ -0,0 +1,117 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The CertificateItemInner model. + */ +public class CertificateItemInner { + /** + * Certificate Identifier. + */ + private String id; + + /** + * The certificate management attributes. + */ + private CertificateAttributesInner attributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Thumbprint of the certificate. + */ + @JsonProperty(value = "x5t") + private String x5T; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the CertificateItemInner object itself. + */ + public CertificateItemInner setId(String id) { + this.id = id; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public CertificateAttributesInner attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the CertificateItemInner object itself. + */ + public CertificateItemInner setAttributes(CertificateAttributesInner attributes) { + this.attributes = attributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the CertificateItemInner object itself. + */ + public CertificateItemInner setTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the x5T value. + * + * @return the x5T value + */ + public String x5T() { + return this.x5T; + } + + /** + * Set the x5T value. + * + * @param x5T the x5T value to set + * @return the CertificateItemInner object itself. + */ + public CertificateItemInner setX5T(String x5T) { + this.x5T = x5T; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateMergeParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateMergeParameters.java new file mode 100644 index 0000000000000..c793a83daa0f1 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateMergeParameters.java @@ -0,0 +1,94 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The CertificateMergeParameters model. + */ +public class CertificateMergeParameters { + /** + * The certificate or the certificte chain to merge. + */ + @JsonProperty(value = "x5c", required = true) + private List x509Certificates; + + /** + * The attributes of the certificate (optional). + */ + @JsonProperty(value = "attributes") + private CertificateAttributesInner certificateAttributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the x509Certificates value. + * + * @return the x509Certificates value + */ + public List x509Certificates() { + return this.x509Certificates; + } + + /** + * Set the x509Certificates value. + * + * @param x509Certificates the x509Certificates value to set + * @return the CertificateMergeParameters object itself. + */ + public CertificateMergeParameters setX509Certificates(List x509Certificates) { + this.x509Certificates = x509Certificates; + return this; + } + + /** + * Get the certificateAttributes value. + * + * @return the certificateAttributes value + */ + public CertificateAttributesInner certificateAttributes() { + return this.certificateAttributes; + } + + /** + * Set the certificateAttributes value. + * + * @param certificateAttributes the certificateAttributes value to set + * @return the CertificateMergeParameters object itself. + */ + public CertificateMergeParameters setCertificateAttributes(CertificateAttributesInner certificateAttributes) { + this.certificateAttributes = certificateAttributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the CertificateMergeParameters object itself. + */ + public CertificateMergeParameters setTags(Map tags) { + this.tags = tags; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateOperationInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateOperationInner.java new file mode 100644 index 0000000000000..33bbddf237e91 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateOperationInner.java @@ -0,0 +1,235 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The CertificateOperationInner model. + */ +public class CertificateOperationInner { + /** + * The certificate id. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * Reference to the issuer of the X509 component of a certificate. + */ + @JsonProperty(value = "issuer") + private IssuerReference issuerReference; + + /** + * The Certificate Signing Request (CSR) that is being used in the + * certificate operation. + */ + private String csr; + + /** + * Indicates if cancellation was requested on the certificate operation. + */ + @JsonProperty(value = "cancellation_requested") + private Boolean cancellationRequested; + + /** + * Status of the certificate operation. + */ + private String status; + + /** + * The status details of the certificate operation. + */ + @JsonProperty(value = "status_details") + private String statusDetails; + + /** + * Error encountered, if any, during the certificate operation. + */ + private KeyVaultError error; + + /** + * Location which contains the result of the certificate operation. + */ + private String target; + + /** + * Identifier for the certificate operation. + */ + @JsonProperty(value = "request_id") + private String requestId; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get the issuerReference value. + * + * @return the issuerReference value + */ + public IssuerReference issuerReference() { + return this.issuerReference; + } + + /** + * Set the issuerReference value. + * + * @param issuerReference the issuerReference value to set + * @return the CertificateOperationInner object itself. + */ + public CertificateOperationInner setIssuerReference(IssuerReference issuerReference) { + this.issuerReference = issuerReference; + return this; + } + + /** + * Get the csr value. + * + * @return the csr value + */ + public String csr() { + return this.csr; + } + + /** + * Set the csr value. + * + * @param csr the csr value to set + * @return the CertificateOperationInner object itself. + */ + public CertificateOperationInner setCsr(String csr) { + this.csr = csr; + return this; + } + + /** + * Get the cancellationRequested value. + * + * @return the cancellationRequested value + */ + public Boolean cancellationRequested() { + return this.cancellationRequested; + } + + /** + * Set the cancellationRequested value. + * + * @param cancellationRequested the cancellationRequested value to set + * @return the CertificateOperationInner object itself. + */ + public CertificateOperationInner setCancellationRequested(Boolean cancellationRequested) { + this.cancellationRequested = cancellationRequested; + return this; + } + + /** + * Get the status value. + * + * @return the status value + */ + public String status() { + return this.status; + } + + /** + * Set the status value. + * + * @param status the status value to set + * @return the CertificateOperationInner object itself. + */ + public CertificateOperationInner setStatus(String status) { + this.status = status; + return this; + } + + /** + * Get the statusDetails value. + * + * @return the statusDetails value + */ + public String statusDetails() { + return this.statusDetails; + } + + /** + * Set the statusDetails value. + * + * @param statusDetails the statusDetails value to set + * @return the CertificateOperationInner object itself. + */ + public CertificateOperationInner setStatusDetails(String statusDetails) { + this.statusDetails = statusDetails; + return this; + } + + /** + * Get the error value. + * + * @return the error value + */ + public KeyVaultError error() { + return this.error; + } + + /** + * Set the error value. + * + * @param error the error value to set + * @return the CertificateOperationInner object itself. + */ + public CertificateOperationInner setError(KeyVaultError error) { + this.error = error; + return this; + } + + /** + * Get the target value. + * + * @return the target value + */ + public String target() { + return this.target; + } + + /** + * Set the target value. + * + * @param target the target value to set + * @return the CertificateOperationInner object itself. + */ + public CertificateOperationInner setTarget(String target) { + this.target = target; + return this; + } + + /** + * Get the requestId value. + * + * @return the requestId value + */ + public String requestId() { + return this.requestId; + } + + /** + * Set the requestId value. + * + * @param requestId the requestId value to set + * @return the CertificateOperationInner object itself. + */ + public CertificateOperationInner setRequestId(String requestId) { + this.requestId = requestId; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificatePolicyInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificatePolicyInner.java new file mode 100644 index 0000000000000..d902c912330d5 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificatePolicyInner.java @@ -0,0 +1,187 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The CertificatePolicyInner model. + */ +public class CertificatePolicyInner { + /** + * The certificate id. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * Properties of the key backing a certificate. + */ + @JsonProperty(value = "key_props") + private KeyProperties keyProperties; + + /** + * Properties of the secret backing a certificate. + */ + @JsonProperty(value = "secret_props") + private SecretProperties secretProperties; + + /** + * Properties of the X509 component of a certificate. + */ + @JsonProperty(value = "x509_props") + private X509CertificateProperties x509CertificateProperties; + + /** + * Actions that will be performed by Key Vault over the lifetime of a + * certificate. + */ + @JsonProperty(value = "lifetime_actions") + private List lifetimeActions; + + /** + * Reference to the issuer of the X509 component of a certificate. + */ + @JsonProperty(value = "issuer") + private IssuerReference issuerReference; + + /** + * The certificate attributes. + */ + private CertificateAttributesInner attributes; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get the keyProperties value. + * + * @return the keyProperties value + */ + public KeyProperties keyProperties() { + return this.keyProperties; + } + + /** + * Set the keyProperties value. + * + * @param keyProperties the keyProperties value to set + * @return the CertificatePolicyInner object itself. + */ + public CertificatePolicyInner setKeyProperties(KeyProperties keyProperties) { + this.keyProperties = keyProperties; + return this; + } + + /** + * Get the secretProperties value. + * + * @return the secretProperties value + */ + public SecretProperties secretProperties() { + return this.secretProperties; + } + + /** + * Set the secretProperties value. + * + * @param secretProperties the secretProperties value to set + * @return the CertificatePolicyInner object itself. + */ + public CertificatePolicyInner setSecretProperties(SecretProperties secretProperties) { + this.secretProperties = secretProperties; + return this; + } + + /** + * Get the x509CertificateProperties value. + * + * @return the x509CertificateProperties value + */ + public X509CertificateProperties x509CertificateProperties() { + return this.x509CertificateProperties; + } + + /** + * Set the x509CertificateProperties value. + * + * @param x509CertificateProperties the x509CertificateProperties value to set + * @return the CertificatePolicyInner object itself. + */ + public CertificatePolicyInner setX509CertificateProperties(X509CertificateProperties x509CertificateProperties) { + this.x509CertificateProperties = x509CertificateProperties; + return this; + } + + /** + * Get the lifetimeActions value. + * + * @return the lifetimeActions value + */ + public List lifetimeActions() { + return this.lifetimeActions; + } + + /** + * Set the lifetimeActions value. + * + * @param lifetimeActions the lifetimeActions value to set + * @return the CertificatePolicyInner object itself. + */ + public CertificatePolicyInner setLifetimeActions(List lifetimeActions) { + this.lifetimeActions = lifetimeActions; + return this; + } + + /** + * Get the issuerReference value. + * + * @return the issuerReference value + */ + public IssuerReference issuerReference() { + return this.issuerReference; + } + + /** + * Set the issuerReference value. + * + * @param issuerReference the issuerReference value to set + * @return the CertificatePolicyInner object itself. + */ + public CertificatePolicyInner setIssuerReference(IssuerReference issuerReference) { + this.issuerReference = issuerReference; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public CertificateAttributesInner attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the CertificatePolicyInner object itself. + */ + public CertificatePolicyInner setAttributes(CertificateAttributesInner attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateUpdateParameters.java new file mode 100644 index 0000000000000..7033fb481350d --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateUpdateParameters.java @@ -0,0 +1,67 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The CertificateUpdateParameters model. + */ +public class CertificateUpdateParameters { + /** + * The attributes of the certificate (optional). + */ + @JsonProperty(value = "attributes") + private CertificateAttributesInner certificateAttributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the certificateAttributes value. + * + * @return the certificateAttributes value + */ + public CertificateAttributesInner certificateAttributes() { + return this.certificateAttributes; + } + + /** + * Set the certificateAttributes value. + * + * @param certificateAttributes the certificateAttributes value to set + * @return the CertificateUpdateParameters object itself. + */ + public CertificateUpdateParameters setCertificateAttributes(CertificateAttributesInner certificateAttributes) { + this.certificateAttributes = certificateAttributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the CertificateUpdateParameters object itself. + */ + public CertificateUpdateParameters setTags(Map tags) { + this.tags = tags; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Contact.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Contact.java new file mode 100644 index 0000000000000..5b3ef8276d400 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Contact.java @@ -0,0 +1,91 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The Contact model. + */ +public class Contact { + /** + * Email addresss. + */ + @JsonProperty(value = "email") + private String emailAddress; + + /** + * Name. + */ + private String name; + + /** + * Phone number. + */ + private String phone; + + /** + * Get the emailAddress value. + * + * @return the emailAddress value + */ + public String emailAddress() { + return this.emailAddress; + } + + /** + * Set the emailAddress value. + * + * @param emailAddress the emailAddress value to set + * @return the Contact object itself. + */ + public Contact setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the Contact object itself. + */ + public Contact setName(String name) { + this.name = name; + return this; + } + + /** + * Get the phone value. + * + * @return the phone value + */ + public String phone() { + return this.phone; + } + + /** + * Set the phone value. + * + * @param phone the phone value to set + * @return the Contact object itself. + */ + public Contact setPhone(String phone) { + this.phone = phone; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/ContactsInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/ContactsInner.java new file mode 100644 index 0000000000000..2d329cc4c249a --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/ContactsInner.java @@ -0,0 +1,57 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The ContactsInner model. + */ +public class ContactsInner { + /** + * Identifier for the contacts collection. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * Contacts. + */ + @JsonProperty(value = "contacts") + private List contactList; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get the contactList value. + * + * @return the contactList value + */ + public List contactList() { + return this.contactList; + } + + /** + * Set the contactList value. + * + * @param contactList the contactList value to set + * @return the ContactsInner object itself. + */ + public ContactsInner setContactList(List contactList) { + this.contactList = contactList; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerAttributes.java new file mode 100644 index 0000000000000..7c45207e64ff3 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerAttributes.java @@ -0,0 +1,70 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The IssuerAttributes model. + */ +public class IssuerAttributes { + /** + * Determines whether the issuer is enabled. + */ + private Boolean enabled; + + /** + * Creation time in UTC. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private Long created; + + /** + * Last updated time in UTC. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private Long updated; + + /** + * Get the enabled value. + * + * @return the enabled value + */ + public Boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled value. + * + * @param enabled the enabled value to set + * @return the IssuerAttributes object itself. + */ + public IssuerAttributes setEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the created value. + * + * @return the created value + */ + public Long created() { + return this.created; + } + + /** + * Get the updated value. + * + * @return the updated value + */ + public Long updated() { + return this.updated; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerBundleInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerBundleInner.java new file mode 100644 index 0000000000000..3ecc36659a564 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerBundleInner.java @@ -0,0 +1,131 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The IssuerBundleInner model. + */ +public class IssuerBundleInner { + /** + * Identifier for the issuer object. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * The name of the issuer. + */ + private String provider; + + /** + * The credentials to be used for the issuer. + */ + private IssuerCredentials credentials; + + /** + * Details of the organization as provided to the issuer. + */ + @JsonProperty(value = "org_details") + private OrganizationDetails organizationDetails; + + /** + * Attributes of the issuer object. + */ + private IssuerAttributes attributes; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Get the provider value. + * + * @return the provider value + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider value. + * + * @param provider the provider value to set + * @return the IssuerBundleInner object itself. + */ + public IssuerBundleInner setProvider(String provider) { + this.provider = provider; + return this; + } + + /** + * Get the credentials value. + * + * @return the credentials value + */ + public IssuerCredentials credentials() { + return this.credentials; + } + + /** + * Set the credentials value. + * + * @param credentials the credentials value to set + * @return the IssuerBundleInner object itself. + */ + public IssuerBundleInner setCredentials(IssuerCredentials credentials) { + this.credentials = credentials; + return this; + } + + /** + * Get the organizationDetails value. + * + * @return the organizationDetails value + */ + public OrganizationDetails organizationDetails() { + return this.organizationDetails; + } + + /** + * Set the organizationDetails value. + * + * @param organizationDetails the organizationDetails value to set + * @return the IssuerBundleInner object itself. + */ + public IssuerBundleInner setOrganizationDetails(OrganizationDetails organizationDetails) { + this.organizationDetails = organizationDetails; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public IssuerAttributes attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the IssuerBundleInner object itself. + */ + public IssuerBundleInner setAttributes(IssuerAttributes attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerCredentials.java new file mode 100644 index 0000000000000..8215222ddcd6c --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerCredentials.java @@ -0,0 +1,67 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The IssuerCredentials model. + */ +public class IssuerCredentials { + /** + * The user name/account name/account id. + */ + @JsonProperty(value = "account_id") + private String accountId; + + /** + * The password/secret/account key. + */ + @JsonProperty(value = "pwd") + private String password; + + /** + * Get the accountId value. + * + * @return the accountId value + */ + public String accountId() { + return this.accountId; + } + + /** + * Set the accountId value. + * + * @param accountId the accountId value to set + * @return the IssuerCredentials object itself. + */ + public IssuerCredentials setAccountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Get the password value. + * + * @return the password value + */ + public String password() { + return this.password; + } + + /** + * Set the password value. + * + * @param password the password value to set + * @return the IssuerCredentials object itself. + */ + public IssuerCredentials setPassword(String password) { + this.password = password; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerReference.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerReference.java new file mode 100644 index 0000000000000..6731f92c97a3b --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerReference.java @@ -0,0 +1,39 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + + +/** + * The IssuerReference model. + */ +public class IssuerReference { + /** + * Name of the referenced issuer object. + */ + private String name; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the IssuerReference object itself. + */ + public IssuerReference setName(String name) { + this.name = name; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/JsonWebKeyInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/JsonWebKeyInner.java new file mode 100644 index 0000000000000..bae3e57a8feda --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/JsonWebKeyInner.java @@ -0,0 +1,343 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The JsonWebKeyInner model. + */ +public class JsonWebKeyInner { + /** + * Key Identifier. + */ + private String kid; + + /** + * Key type, usually RSA. + */ + private String kty; + + /** + * The keyOps property. + */ + @JsonProperty(value = "key_ops") + private List keyOps; + + /** + * RSA modulus. + */ + private String n; + + /** + * RSA public exponent. + */ + private String e; + + /** + * RSA private exponent. + */ + private String d; + + /** + */ + private String dp; + + /** + * The dq property. + */ + private String dq; + + /** + * The qi property. + */ + private String qi; + + /** + * The p property. + */ + private String p; + + /** + * The q property. + */ + private String q; + + /** + * Symmetric key. + */ + @JsonProperty(value = "K") + private String k; + + /** + * HSM Token, used with Bring Your Own Key. + */ + @JsonProperty(value = "key_hsm") + private String t; + + /** + * Get the kid value. + * + * @return the kid value + */ + public String kid() { + return this.kid; + } + + /** + * Set the kid value. + * + * @param kid the kid value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setKid(String kid) { + this.kid = kid; + return this; + } + + /** + * Get the kty value. + * + * @return the kty value + */ + public String kty() { + return this.kty; + } + + /** + * Set the kty value. + * + * @param kty the kty value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setKty(String kty) { + this.kty = kty; + return this; + } + + /** + * Get the keyOps value. + * + * @return the keyOps value + */ + public List keyOps() { + return this.keyOps; + } + + /** + * Set the keyOps value. + * + * @param keyOps the keyOps value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setKeyOps(List keyOps) { + this.keyOps = keyOps; + return this; + } + + /** + * Get the n value. + * + * @return the n value + */ + public String n() { + return this.n; + } + + /** + * Set the n value. + * + * @param n the n value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setN(String n) { + this.n = n; + return this; + } + + /** + * Get the e value. + * + * @return the e value + */ + public String e() { + return this.e; + } + + /** + * Set the e value. + * + * @param e the e value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setE(String e) { + this.e = e; + return this; + } + + /** + * Get the d value. + * + * @return the d value + */ + public String d() { + return this.d; + } + + /** + * Set the d value. + * + * @param d the d value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setD(String d) { + this.d = d; + return this; + } + + /** + * Get the dp value. + * + * @return the dp value + */ + public String dp() { + return this.dp; + } + + /** + * Set the dp value. + * + * @param dp the dp value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setDp(String dp) { + this.dp = dp; + return this; + } + + /** + * Get the dq value. + * + * @return the dq value + */ + public String dq() { + return this.dq; + } + + /** + * Set the dq value. + * + * @param dq the dq value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setDq(String dq) { + this.dq = dq; + return this; + } + + /** + * Get the qi value. + * + * @return the qi value + */ + public String qi() { + return this.qi; + } + + /** + * Set the qi value. + * + * @param qi the qi value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setQi(String qi) { + this.qi = qi; + return this; + } + + /** + * Get the p value. + * + * @return the p value + */ + public String p() { + return this.p; + } + + /** + * Set the p value. + * + * @param p the p value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setP(String p) { + this.p = p; + return this; + } + + /** + * Get the q value. + * + * @return the q value + */ + public String q() { + return this.q; + } + + /** + * Set the q value. + * + * @param q the q value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setQ(String q) { + this.q = q; + return this; + } + + /** + * Get the k value. + * + * @return the k value + */ + public String k() { + return this.k; + } + + /** + * Set the k value. + * + * @param k the k value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setK(String k) { + this.k = k; + return this; + } + + /** + * Get the t value. + * + * @return the t value + */ + public String t() { + return this.t; + } + + /** + * Set the t value. + * + * @param t the t value to set + * @return the JsonWebKeyInner object itself. + */ + public JsonWebKeyInner setT(String t) { + this.t = t; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyAttributesInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyAttributesInner.java new file mode 100644 index 0000000000000..d1aa5c986b1ad --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyAttributesInner.java @@ -0,0 +1,14 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + + +/** + * The KeyAttributesInner model. + */ +public class KeyAttributesInner extends Attributes { +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyBundleInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyBundleInner.java new file mode 100644 index 0000000000000..ec29f7dad6d04 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyBundleInner.java @@ -0,0 +1,90 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.Map; + +/** + * The KeyBundleInner model. + */ +public class KeyBundleInner { + /** + * The Json web key. + */ + private JsonWebKeyInner key; + + /** + * The key management attributes. + */ + private KeyAttributesInner attributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the key value. + * + * @return the key value + */ + public JsonWebKeyInner key() { + return this.key; + } + + /** + * Set the key value. + * + * @param key the key value to set + * @return the KeyBundleInner object itself. + */ + public KeyBundleInner setKey(JsonWebKeyInner key) { + this.key = key; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public KeyAttributesInner attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the KeyBundleInner object itself. + */ + public KeyBundleInner setAttributes(KeyAttributesInner attributes) { + this.attributes = attributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the KeyBundleInner object itself. + */ + public KeyBundleInner setTags(Map tags) { + this.tags = tags; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyCreateParameters.java new file mode 100644 index 0000000000000..a454d9848720b --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyCreateParameters.java @@ -0,0 +1,146 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The KeyCreateParameters model. + */ +public class KeyCreateParameters { + /** + * The type of key to create. For valid key types, see WebKeyTypes. + */ + @JsonProperty(required = true) + private String kty; + + /** + * Size of the key. + */ + @JsonProperty(value = "key_size") + private Integer keySize; + + /** + * The keyOps property. + */ + @JsonProperty(value = "key_ops") + private List keyOps; + + /** + * The keyAttributes property. + */ + @JsonProperty(value = "attributes") + private KeyAttributesInner keyAttributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the kty value. + * + * @return the kty value + */ + public String kty() { + return this.kty; + } + + /** + * Set the kty value. + * + * @param kty the kty value to set + * @return the KeyCreateParameters object itself. + */ + public KeyCreateParameters setKty(String kty) { + this.kty = kty; + return this; + } + + /** + * Get the keySize value. + * + * @return the keySize value + */ + public Integer keySize() { + return this.keySize; + } + + /** + * Set the keySize value. + * + * @param keySize the keySize value to set + * @return the KeyCreateParameters object itself. + */ + public KeyCreateParameters setKeySize(Integer keySize) { + this.keySize = keySize; + return this; + } + + /** + * Get the keyOps value. + * + * @return the keyOps value + */ + public List keyOps() { + return this.keyOps; + } + + /** + * Set the keyOps value. + * + * @param keyOps the keyOps value to set + * @return the KeyCreateParameters object itself. + */ + public KeyCreateParameters setKeyOps(List keyOps) { + this.keyOps = keyOps; + return this; + } + + /** + * Get the keyAttributes value. + * + * @return the keyAttributes value + */ + public KeyAttributesInner keyAttributes() { + return this.keyAttributes; + } + + /** + * Set the keyAttributes value. + * + * @param keyAttributes the keyAttributes value to set + * @return the KeyCreateParameters object itself. + */ + public KeyCreateParameters setKeyAttributes(KeyAttributesInner keyAttributes) { + this.keyAttributes = keyAttributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the KeyCreateParameters object itself. + */ + public KeyCreateParameters setTags(Map tags) { + this.tags = tags; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyImportParameters.java new file mode 100644 index 0000000000000..3c30878317d07 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyImportParameters.java @@ -0,0 +1,119 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The KeyImportParameters model. + */ +public class KeyImportParameters { + /** + * Whether to import as a hardware key (HSM) or software key. + */ + @JsonProperty(value = "Hsm") + private Boolean hsm; + + /** + * The Json web key. + */ + @JsonProperty(required = true) + private JsonWebKeyInner key; + + /** + * The key management attributes. + */ + @JsonProperty(value = "attributes") + private KeyAttributesInner keyAttributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the hsm value. + * + * @return the hsm value + */ + public Boolean hsm() { + return this.hsm; + } + + /** + * Set the hsm value. + * + * @param hsm the hsm value to set + * @return the KeyImportParameters object itself. + */ + public KeyImportParameters setHsm(Boolean hsm) { + this.hsm = hsm; + return this; + } + + /** + * Get the key value. + * + * @return the key value + */ + public JsonWebKeyInner key() { + return this.key; + } + + /** + * Set the key value. + * + * @param key the key value to set + * @return the KeyImportParameters object itself. + */ + public KeyImportParameters setKey(JsonWebKeyInner key) { + this.key = key; + return this; + } + + /** + * Get the keyAttributes value. + * + * @return the keyAttributes value + */ + public KeyAttributesInner keyAttributes() { + return this.keyAttributes; + } + + /** + * Set the keyAttributes value. + * + * @param keyAttributes the keyAttributes value to set + * @return the KeyImportParameters object itself. + */ + public KeyImportParameters setKeyAttributes(KeyAttributesInner keyAttributes) { + this.keyAttributes = keyAttributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the KeyImportParameters object itself. + */ + public KeyImportParameters setTags(Map tags) { + this.tags = tags; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyItemInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyItemInner.java new file mode 100644 index 0000000000000..9ebf7c6ab2e5b --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyItemInner.java @@ -0,0 +1,90 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.Map; + +/** + * The KeyItemInner model. + */ +public class KeyItemInner { + /** + * Key Identifier. + */ + private String kid; + + /** + * The key management attributes. + */ + private KeyAttributesInner attributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the kid value. + * + * @return the kid value + */ + public String kid() { + return this.kid; + } + + /** + * Set the kid value. + * + * @param kid the kid value to set + * @return the KeyItemInner object itself. + */ + public KeyItemInner setKid(String kid) { + this.kid = kid; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public KeyAttributesInner attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the KeyItemInner object itself. + */ + public KeyItemInner setAttributes(KeyAttributesInner attributes) { + this.attributes = attributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the KeyItemInner object itself. + */ + public KeyItemInner setTags(Map tags) { + this.tags = tags; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationResultInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationResultInner.java new file mode 100644 index 0000000000000..980e0b2123bac --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationResultInner.java @@ -0,0 +1,45 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The KeyOperationResultInner model. + */ +public class KeyOperationResultInner { + /** + * Key identifier. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String kid; + + /** + * The result property. + */ + @JsonProperty(value = "value", access = JsonProperty.Access.WRITE_ONLY) + private String result; + + /** + * Get the kid value. + * + * @return the kid value + */ + public String kid() { + return this.kid; + } + + /** + * Get the result value. + * + * @return the result value + */ + public String result() { + return this.result; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationsParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationsParameters.java new file mode 100644 index 0000000000000..38f218a0844c8 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationsParameters.java @@ -0,0 +1,67 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The KeyOperationsParameters model. + */ +public class KeyOperationsParameters { + /** + * algorithm identifier. + */ + @JsonProperty(value = "alg", required = true) + private String algorithm; + + /** + * The value property. + */ + @JsonProperty(required = true) + private String value; + + /** + * Get the algorithm value. + * + * @return the algorithm value + */ + public String algorithm() { + return this.algorithm; + } + + /** + * Set the algorithm value. + * + * @param algorithm the algorithm value to set + * @return the KeyOperationsParameters object itself. + */ + public KeyOperationsParameters setAlgorithm(String algorithm) { + this.algorithm = algorithm; + return this; + } + + /** + * Get the value value. + * + * @return the value value + */ + public String value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the KeyOperationsParameters object itself. + */ + public KeyOperationsParameters setValue(String value) { + this.value = value; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyProperties.java new file mode 100644 index 0000000000000..6534c1c89462e --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyProperties.java @@ -0,0 +1,117 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The KeyProperties model. + */ +public class KeyProperties { + /** + * Indicates if the private key can be exported. + */ + private Boolean exportable; + + /** + * The key type. + */ + private String kty; + + /** + * The key size. + */ + @JsonProperty(value = "key_size") + private Integer keySize; + + /** + * Indicates if the same key pair will be used on certificate renewal. + */ + @JsonProperty(value = "reuse_key") + private Boolean reuseKey; + + /** + * Get the exportable value. + * + * @return the exportable value + */ + public Boolean exportable() { + return this.exportable; + } + + /** + * Set the exportable value. + * + * @param exportable the exportable value to set + * @return the KeyProperties object itself. + */ + public KeyProperties setExportable(Boolean exportable) { + this.exportable = exportable; + return this; + } + + /** + * Get the kty value. + * + * @return the kty value + */ + public String kty() { + return this.kty; + } + + /** + * Set the kty value. + * + * @param kty the kty value to set + * @return the KeyProperties object itself. + */ + public KeyProperties setKty(String kty) { + this.kty = kty; + return this; + } + + /** + * Get the keySize value. + * + * @return the keySize value + */ + public Integer keySize() { + return this.keySize; + } + + /** + * Set the keySize value. + * + * @param keySize the keySize value to set + * @return the KeyProperties object itself. + */ + public KeyProperties setKeySize(Integer keySize) { + this.keySize = keySize; + return this; + } + + /** + * Get the reuseKey value. + * + * @return the reuseKey value + */ + public Boolean reuseKey() { + return this.reuseKey; + } + + /** + * Set the reuseKey value. + * + * @param reuseKey the reuseKey value to set + * @return the KeyProperties object itself. + */ + public KeyProperties setReuseKey(Boolean reuseKey) { + this.reuseKey = reuseKey; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyRestoreParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyRestoreParameters.java new file mode 100644 index 0000000000000..0baf0b3eac1a8 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyRestoreParameters.java @@ -0,0 +1,41 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The KeyRestoreParameters model. + */ +public class KeyRestoreParameters { + /** + * the backup blob associated with a key bundle. + */ + @JsonProperty(value = "value", required = true) + private String keyBundleBackup; + + /** + * Get the keyBundleBackup value. + * + * @return the keyBundleBackup value + */ + public String keyBundleBackup() { + return this.keyBundleBackup; + } + + /** + * Set the keyBundleBackup value. + * + * @param keyBundleBackup the keyBundleBackup value to set + * @return the KeyRestoreParameters object itself. + */ + public KeyRestoreParameters setKeyBundleBackup(String keyBundleBackup) { + this.keyBundleBackup = keyBundleBackup; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyUpdateParameters.java new file mode 100644 index 0000000000000..152e463fc8a0d --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyUpdateParameters.java @@ -0,0 +1,95 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The KeyUpdateParameters model. + */ +public class KeyUpdateParameters { + /** + * Json web key operations. For more information on possible key + * operations, see JsonWebKeyOperation. + */ + @JsonProperty(value = "key_ops") + private List keyOps; + + /** + * The keyAttributes property. + */ + @JsonProperty(value = "attributes") + private KeyAttributesInner keyAttributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the keyOps value. + * + * @return the keyOps value + */ + public List keyOps() { + return this.keyOps; + } + + /** + * Set the keyOps value. + * + * @param keyOps the keyOps value to set + * @return the KeyUpdateParameters object itself. + */ + public KeyUpdateParameters setKeyOps(List keyOps) { + this.keyOps = keyOps; + return this; + } + + /** + * Get the keyAttributes value. + * + * @return the keyAttributes value + */ + public KeyAttributesInner keyAttributes() { + return this.keyAttributes; + } + + /** + * Set the keyAttributes value. + * + * @param keyAttributes the keyAttributes value to set + * @return the KeyUpdateParameters object itself. + */ + public KeyUpdateParameters setKeyAttributes(KeyAttributesInner keyAttributes) { + this.keyAttributes = keyAttributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the KeyUpdateParameters object itself. + */ + public KeyUpdateParameters setTags(Map tags) { + this.tags = tags; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultClientImpl.java new file mode 100644 index 0000000000000..dd34a9af8d16e --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultClientImpl.java @@ -0,0 +1,5906 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.azure.AzureServiceResponseBuilder; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestClient; +import com.microsoft.rest.serializer.CollectionFormat; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseCallback; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import okhttp3.ResponseBody; +import retrofit2.Call; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.http.Url; +import retrofit2.Response; + +/** + * Initializes a new instance of the KeyVaultClientImpl class. + */ +public final class KeyVaultClientImpl extends AzureServiceClient { + /** The Retrofit service to perform REST calls. */ + private KeyVaultClientService service; + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** Client Api Version. */ + private String apiVersion; + + /** + * Gets Client Api Version. + * + * @return the apiVersion value. + */ + public String apiVersion() { + return this.apiVersion; + } + + /** Gets or sets the preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + */ + public void setAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + } + + /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + */ + public void setLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + } + + /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + */ + public void setGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + } + + /** + * Initializes an instance of KeyVaultClient client. + * + * @param credentials the management credentials for Azure + */ + public KeyVaultClientImpl(ServiceClientCredentials credentials) { + this("{vaultBaseUrl}", credentials); + } + + /** + * Initializes an instance of KeyVaultClient client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + private KeyVaultClientImpl(String baseUrl, ServiceClientCredentials credentials) { + this(new RestClient.Builder(baseUrl) + .withMapperAdapter(new AzureJacksonMapperAdapter()) + .withCredentials(credentials) + .build()); + } + + /** + * Initializes an instance of KeyVaultClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public KeyVaultClientImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.apiVersion = "2015-06-01-preview2"; + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.azureClient = new AzureClient(this); + initializeService(); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("Azure-SDK-For-Java/%s (%s)", + getClass().getPackage().getImplementationVersion(), + "KeyVaultClient, 2015-06-01-preview2"); + } + + private void initializeService() { + service = restClient().retrofit().create(KeyVaultClientService.class); + } + + /** + * The interface defining all the services for KeyVaultClient to be + * used by Retrofit to perform actually REST calls. + */ + interface KeyVaultClientService { + @Headers("Content-Type: application/json; charset=utf-8") + @POST("keys/{key-name}/create") + Call createKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCreateParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("keys/{key-name}") + Call importKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyImportParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "keys/{key-name}", method = "DELETE", hasBody = true) + Call deleteKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PATCH("keys/{key-name}/{key-version}") + Call updateKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyUpdateParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("keys/{key-name}/{key-version}") + Call getKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("keys/{key-name}/versions") + Call getKeyVersions(@Path("key-name") String keyName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("keys") + Call getKeys(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("keys/{key-name}/backup") + Call backupKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("keys/restore") + Call restoreKey(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyRestoreParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("keys/{key-name}/{key-version}/encrypt") + Call encrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("keys/{key-name}/{key-version}/decrypt") + Call decrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("keys/{key-name}/{key-version}/sign") + Call sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("keys/{key-name}/{key-version}/verify") + Call verify(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyVerifyParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("keys/{key-name}/{key-version}/wrapkey") + Call wrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("keys/{key-name}/{key-version}/unwrapkey") + Call unwrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("secrets/{secret-name}") + Call setSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretSetParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "secrets/{secret-name}", method = "DELETE", hasBody = true) + Call deleteSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PATCH("secrets/{secret-name}/{secret-version}") + Call updateSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretUpdateParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("secrets/{secret-name}/{secret-version}") + Call getSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("secrets") + Call getSecrets(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("secrets/{secret-name}/versions") + Call getSecretVersions(@Path("secret-name") String secretName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("certificates") + Call getCertificates(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "certificates/{certificate-name}", method = "DELETE", hasBody = true) + Call deleteCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("certificates/contacts") + Call setCertificateContacts(@Body ContactsInner contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("certificates/contacts") + Call getCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "certificates/contacts", method = "DELETE", hasBody = true) + Call deleteCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("certificates/issuers") + Call getCertificateIssuers(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("certificates/issuers/{issuer-name}") + Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundleInner issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PATCH("certificates/issuers/{issuer-name}") + Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundleInner issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("certificates/issuers/{issuer-name}") + Call getCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "certificates/issuers/{issuer-name}", method = "DELETE", hasBody = true) + Call deleteCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("certificates/{certificate-name}/create") + Call createCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateCreateParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("certificates/{certificate-name}/import") + Call importCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateImportParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("certificates/{certificate-name}/versions") + Call getCertificateVersions(@Path("certificate-name") String certificateName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("certificates/{certificate-name}/policy") + Call getCertificatePolicy(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PATCH("certificates/{certificate-name}/policy") + Call updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicyInner certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PATCH("certificates/{certificate-name}/{certificate-version}") + Call updateCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateUpdateParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("certificates/{certificate-name}/{certificate-version}") + Call getCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PATCH("certificates/{certificate-name}/pending") + Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Body CertificateOperationInner certificateOperation, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("certificates/{certificate-name}/pending") + Call getCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "certificates/{certificate-name}/pending", method = "DELETE", hasBody = true) + Call deleteCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @POST("certificates/{certificate-name}/pending/merge") + Call mergeCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateMergeParameters parameters, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET + Call getKeyVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET + Call getKeysNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET + Call getSecretsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET + Call getSecretVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET + Call getCertificatesNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET + Call getCertificateIssuersNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET + Call getCertificateVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. For valid key types, see WebKeyTypes. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (kty == null) { + throw new IllegalArgumentException("Parameter kty is required and cannot be null."); + } + final Integer keySize = null; + final String keyOpsConverted = null; + final KeyAttributesInner keyAttributes = null; + final Map tags = null; + KeyCreateParameters parameters = new KeyCreateParameters(); + parameters.setKty(kty); + parameters.setKeySize(null); + parameters.setKeyOps(null); + parameters.setKeyAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return createKeyDelegate(call.execute()); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. For valid key types, see WebKeyTypes. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (kty == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter kty is required and cannot be null.")); + return null; + } + final Integer keySize = null; + final String keyOpsConverted = null; + final KeyAttributesInner keyAttributes = null; + final Map tags = null; + KeyCreateParameters parameters = new KeyCreateParameters(); + parameters.setKty(kty); + parameters.setKeySize(null); + parameters.setKeyOps(null); + parameters.setKeyAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(createKeyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. For valid key types, see WebKeyTypes. + * @param keySize Size of the key + * @param keyOps the List<String> value + * @param keyAttributes the KeyAttributesInner value + * @param tags Application-specific metadata in the form of key-value pairs + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributesInner keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (kty == null) { + throw new IllegalArgumentException("Parameter kty is required and cannot be null."); + } + Validator.validate(keyOps); + Validator.validate(keyAttributes); + Validator.validate(tags); + KeyCreateParameters parameters = new KeyCreateParameters(); + parameters.setKty(kty); + parameters.setKeySize(keySize); + parameters.setKeyOps(keyOps); + parameters.setKeyAttributes(keyAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return createKeyDelegate(call.execute()); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. For valid key types, see WebKeyTypes. + * @param keySize Size of the key + * @param keyOps the List<String> value + * @param keyAttributes the KeyAttributesInner value + * @param tags Application-specific metadata in the form of key-value pairs + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributesInner keyAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (kty == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter kty is required and cannot be null.")); + return null; + } + Validator.validate(keyOps, serviceCallback); + Validator.validate(keyAttributes, serviceCallback); + Validator.validate(tags, serviceCallback); + KeyCreateParameters parameters = new KeyCreateParameters(); + parameters.setKty(kty); + parameters.setKeySize(keySize); + parameters.setKeyOps(keyOps); + parameters.setKeyAttributes(keyAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(createKeyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse createKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKeyInner key) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (key == null) { + throw new IllegalArgumentException("Parameter key is required and cannot be null."); + } + Validator.validate(key); + final Boolean hsm = null; + final KeyAttributesInner keyAttributes = null; + final Map tags = null; + KeyImportParameters parameters = new KeyImportParameters(); + parameters.setHsm(null); + parameters.setKey(key); + parameters.setKeyAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return importKeyDelegate(call.execute()); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyInner key, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (key == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter key is required and cannot be null.")); + return null; + } + Validator.validate(key, serviceCallback); + final Boolean hsm = null; + final KeyAttributesInner keyAttributes = null; + final Map tags = null; + KeyImportParameters parameters = new KeyImportParameters(); + parameters.setHsm(null); + parameters.setKey(key); + parameters.setKeyAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(importKeyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @param hsm Whether to import as a hardware key (HSM) or software key + * @param keyAttributes The key management attributes + * @param tags Application-specific metadata in the form of key-value pairs + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKeyInner key, Boolean hsm, KeyAttributesInner keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (key == null) { + throw new IllegalArgumentException("Parameter key is required and cannot be null."); + } + Validator.validate(key); + Validator.validate(keyAttributes); + Validator.validate(tags); + KeyImportParameters parameters = new KeyImportParameters(); + parameters.setHsm(hsm); + parameters.setKey(key); + parameters.setKeyAttributes(keyAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return importKeyDelegate(call.execute()); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @param hsm Whether to import as a hardware key (HSM) or software key + * @param keyAttributes The key management attributes + * @param tags Application-specific metadata in the form of key-value pairs + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyInner key, Boolean hsm, KeyAttributesInner keyAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (key == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter key is required and cannot be null.")); + return null; + } + Validator.validate(key, serviceCallback); + Validator.validate(keyAttributes, serviceCallback); + Validator.validate(tags, serviceCallback); + KeyImportParameters parameters = new KeyImportParameters(); + parameters.setHsm(hsm); + parameters.setKey(key); + parameters.setKeyAttributes(keyAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(importKeyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse importKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Deletes the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return deleteKeyDelegate(call.execute()); + } + + /** + * Deletes the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(deleteKeyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse deleteKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final String keyOpsConverted = null; + final KeyAttributesInner keyAttributes = null; + final Map tags = null; + KeyUpdateParameters parameters = new KeyUpdateParameters(); + parameters.setKeyOps(null); + parameters.setKeyAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return updateKeyDelegate(call.execute()); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (keyVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + final String keyOpsConverted = null; + final KeyAttributesInner keyAttributes = null; + final Map tags = null; + KeyUpdateParameters parameters = new KeyUpdateParameters(); + parameters.setKeyOps(null); + parameters.setKeyAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updateKeyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. + * @param keyAttributes the KeyAttributesInner value + * @param tags Application-specific metadata in the form of key-value pairs + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributesInner keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(keyOps); + Validator.validate(keyAttributes); + Validator.validate(tags); + KeyUpdateParameters parameters = new KeyUpdateParameters(); + parameters.setKeyOps(keyOps); + parameters.setKeyAttributes(keyAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return updateKeyDelegate(call.execute()); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. + * @param keyAttributes the KeyAttributesInner value + * @param tags Application-specific metadata in the form of key-value pairs + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributesInner keyAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (keyVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + Validator.validate(keyOps, serviceCallback); + Validator.validate(keyAttributes, serviceCallback); + Validator.validate(tags, serviceCallback); + KeyUpdateParameters parameters = new KeyUpdateParameters(); + parameters.setKeyOps(keyOps); + parameters.setKeyAttributes(keyAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updateKeyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse updateKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return getKeyDelegate(call.execute()); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (keyVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getKeyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<KeyItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getKeyVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getKeyVersionsNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getKeyVersionsDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param maxresults Maximum number of results to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<KeyItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getKeyVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getKeyVersionsNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getKeyVersionsDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getKeyVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<KeyItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getKeysDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getKeysNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getKeysDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<KeyItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getKeysDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getKeysNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getKeysDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getKeysDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Requests that a backup of the specified key be downloaded to the client. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the BackupKeyResultInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return backupKeyDelegate(call.execute()); + } + + /** + * Requests that a backup of the specified key be downloaded to the client. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(backupKeyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse backupKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Restores the backup key in to a vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyBundleBackup the backup blob associated with a key bundle + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse restoreKey(String vaultBaseUrl, String keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (keyBundleBackup == null) { + throw new IllegalArgumentException("Parameter keyBundleBackup is required and cannot be null."); + } + KeyRestoreParameters parameters = new KeyRestoreParameters(); + parameters.setKeyBundleBackup(keyBundleBackup); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return restoreKeyDelegate(call.execute()); + } + + /** + * Restores the backup key in to a vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyBundleBackup the backup blob associated with a key bundle + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall restoreKeyAsync(String vaultBaseUrl, String keyBundleBackup, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (keyBundleBackup == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyBundleBackup is required and cannot be null.")); + return null; + } + KeyRestoreParameters parameters = new KeyRestoreParameters(); + parameters.setKeyBundleBackup(keyBundleBackup); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(restoreKeyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse restoreKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Encrypts a single block of data. The amount of data that may be encrypted is determined. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier + * @param value the String value + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyOperationResultInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse encrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (algorithm == null) { + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.setAlgorithm(algorithm); + parameters.setValue(value); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return encryptDelegate(call.execute()); + } + + /** + * Encrypts a single block of data. The amount of data that may be encrypted is determined. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier + * @param value the String value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (keyVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (algorithm == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter algorithm is required and cannot be null.")); + return null; + } + if (value == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); + return null; + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.setAlgorithm(algorithm); + parameters.setValue(value); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(encryptDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse encryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Decrypts a single block of encrypted data. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier + * @param value the String value + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyOperationResultInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse decrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (algorithm == null) { + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.setAlgorithm(algorithm); + parameters.setValue(value); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return decryptDelegate(call.execute()); + } + + /** + * Decrypts a single block of encrypted data. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier + * @param value the String value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (keyVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (algorithm == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter algorithm is required and cannot be null.")); + return null; + } + if (value == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); + return null; + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.setAlgorithm(algorithm); + parameters.setValue(value); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(decryptDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse decryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Creates a signature from a digest using the specified key in the vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier + * @param value the String value + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyOperationResultInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse sign(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (algorithm == null) { + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.setAlgorithm(algorithm); + parameters.setValue(value); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return signDelegate(call.execute()); + } + + /** + * Creates a signature from a digest using the specified key in the vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier + * @param value the String value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (keyVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (algorithm == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter algorithm is required and cannot be null.")); + return null; + } + if (value == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); + return null; + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.setAlgorithm(algorithm); + parameters.setValue(value); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(signDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse signDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Verifies a signature using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param digest The digest used for signing + * @param signature The signature to be verified + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyVerifyResultInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse verify(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String digest, String signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (algorithm == null) { + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); + } + if (digest == null) { + throw new IllegalArgumentException("Parameter digest is required and cannot be null."); + } + if (signature == null) { + throw new IllegalArgumentException("Parameter signature is required and cannot be null."); + } + KeyVerifyParameters parameters = new KeyVerifyParameters(); + parameters.setAlgorithm(algorithm); + parameters.setDigest(digest); + parameters.setSignature(signature); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return verifyDelegate(call.execute()); + } + + /** + * Verifies a signature using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param digest The digest used for signing + * @param signature The signature to be verified + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String digest, String signature, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (keyVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (algorithm == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter algorithm is required and cannot be null.")); + return null; + } + if (digest == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter digest is required and cannot be null.")); + return null; + } + if (signature == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter signature is required and cannot be null.")); + return null; + } + KeyVerifyParameters parameters = new KeyVerifyParameters(); + parameters.setAlgorithm(algorithm); + parameters.setDigest(digest); + parameters.setSignature(signature); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(verifyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse verifyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Wraps a symmetric key using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier + * @param value the String value + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyOperationResultInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse wrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (algorithm == null) { + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.setAlgorithm(algorithm); + parameters.setValue(value); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return wrapKeyDelegate(call.execute()); + } + + /** + * Wraps a symmetric key using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier + * @param value the String value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (keyVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (algorithm == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter algorithm is required and cannot be null.")); + return null; + } + if (value == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); + return null; + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.setAlgorithm(algorithm); + parameters.setValue(value); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(wrapKeyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse wrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier + * @param value the String value + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyOperationResultInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (algorithm == null) { + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.setAlgorithm(algorithm); + parameters.setValue(value); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return unwrapKeyDelegate(call.execute()); + } + + /** + * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier + * @param value the String value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (keyName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); + return null; + } + if (keyVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (algorithm == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter algorithm is required and cannot be null.")); + return null; + } + if (value == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); + return null; + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.setAlgorithm(algorithm); + parameters.setValue(value); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(unwrapKeyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse unwrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse setSecret(String vaultBaseUrl, String secretName, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + final Map tags = null; + final String contentType = null; + final SecretAttributesInner secretAttributes = null; + SecretSetParameters parameters = new SecretSetParameters(); + parameters.setValue(value); + parameters.setTags(null); + parameters.setContentType(null); + parameters.setSecretAttributes(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return setSecretDelegate(call.execute()); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (secretName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (value == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); + return null; + } + final Map tags = null; + final String contentType = null; + final SecretAttributesInner secretAttributes = null; + SecretSetParameters parameters = new SecretSetParameters(); + parameters.setValue(value); + parameters.setTags(null); + parameters.setContentType(null); + parameters.setSecretAttributes(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(setSecretDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @param tags Application-specific metadata in the form of key-value pairs + * @param contentType Type of the secret value such as a password + * @param secretAttributes the SecretAttributesInner value + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributesInner secretAttributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + Validator.validate(tags); + Validator.validate(secretAttributes); + SecretSetParameters parameters = new SecretSetParameters(); + parameters.setValue(value); + parameters.setTags(tags); + parameters.setContentType(contentType); + parameters.setSecretAttributes(secretAttributes); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return setSecretDelegate(call.execute()); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @param tags Application-specific metadata in the form of key-value pairs + * @param contentType Type of the secret value such as a password + * @param secretAttributes the SecretAttributesInner value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributesInner secretAttributes, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (secretName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (value == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); + return null; + } + Validator.validate(tags, serviceCallback); + Validator.validate(secretAttributes, serviceCallback); + SecretSetParameters parameters = new SecretSetParameters(); + parameters.setValue(value); + parameters.setTags(tags); + parameters.setContentType(contentType); + parameters.setSecretAttributes(secretAttributes); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(setSecretDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse setSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Deletes a secret from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return deleteSecretDelegate(call.execute()); + } + + /** + * Deletes a secret from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (secretName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(deleteSecretDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse deleteSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (secretVersion == null) { + throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final String contentType = null; + final SecretAttributesInner secretAttributes = null; + final Map tags = null; + SecretUpdateParameters parameters = new SecretUpdateParameters(); + parameters.setContentType(null); + parameters.setSecretAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return updateSecretDelegate(call.execute()); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (secretName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); + return null; + } + if (secretVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secretVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + final String contentType = null; + final SecretAttributesInner secretAttributes = null; + final Map tags = null; + SecretUpdateParameters parameters = new SecretUpdateParameters(); + parameters.setContentType(null); + parameters.setSecretAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updateSecretDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @param contentType Type of the secret value such as a password + * @param secretAttributes the SecretAttributesInner value + * @param tags Application-specific metadata in the form of key-value pairs + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributesInner secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (secretVersion == null) { + throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(secretAttributes); + Validator.validate(tags); + SecretUpdateParameters parameters = new SecretUpdateParameters(); + parameters.setContentType(contentType); + parameters.setSecretAttributes(secretAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return updateSecretDelegate(call.execute()); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @param contentType Type of the secret value such as a password + * @param secretAttributes the SecretAttributesInner value + * @param tags Application-specific metadata in the form of key-value pairs + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributesInner secretAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (secretName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); + return null; + } + if (secretVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secretVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + Validator.validate(secretAttributes, serviceCallback); + Validator.validate(tags, serviceCallback); + SecretUpdateParameters parameters = new SecretUpdateParameters(); + parameters.setContentType(contentType); + parameters.setSecretAttributes(secretAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updateSecretDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse updateSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Gets a secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (secretVersion == null) { + throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return getSecretDelegate(call.execute()); + } + + /** + * Gets a secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (secretName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); + return null; + } + if (secretVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secretVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getSecretDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<SecretItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getSecretsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getSecretsNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getSecretsDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of secrets to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<SecretItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getSecretsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getSecretsNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of secrets to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getSecretsDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getSecretsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<SecretItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getSecretVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getSecretVersionsNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (secretName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getSecretVersionsDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param maxresults Maximum number of results to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<SecretItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getSecretVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getSecretVersionsNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (secretName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getSecretVersionsDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getSecretVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getCertificatesDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getCertificatesNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificatesDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getCertificatesDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getCertificatesNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificatesDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getCertificatesDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Deletes a certificate from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return deleteCertificateDelegate(call.execute()); + } + + /** + * Deletes a certificate from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(deleteCertificateDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse deleteCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param contacts Contacts. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the ContactsInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse setCertificateContacts(String vaultBaseUrl, ContactsInner contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (contacts == null) { + throw new IllegalArgumentException("Parameter contacts is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(contacts); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return setCertificateContactsDelegate(call.execute()); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param contacts Contacts. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, ContactsInner contacts, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (contacts == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter contacts is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + Validator.validate(contacts, serviceCallback); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(setCertificateContactsDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse setCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Gets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the ContactsInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return getCertificateContactsDelegate(call.execute()); + } + + /** + * Gets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getCertificateContactsDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Deletes the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the ContactsInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return deleteCertificateContactsDelegate(call.execute()); + } + + /** + * Deletes the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(deleteCertificateContactsDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse deleteCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateIssuerItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getCertificateIssuersNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificateIssuersDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateIssuerItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getCertificateIssuersNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificateIssuersDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getCertificateIssuersDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param issuer The issuer bundle. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the IssuerBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundleInner issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); + } + if (issuer == null) { + throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(issuer); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return setCertificateIssuerDelegate(call.execute()); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param issuer The issuer bundle. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundleInner issuer, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (issuerName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter issuerName is required and cannot be null.")); + return null; + } + if (issuer == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter issuer is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + Validator.validate(issuer, serviceCallback); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(setCertificateIssuerDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse setCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param issuer The issuer bundle. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the IssuerBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundleInner issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); + } + if (issuer == null) { + throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(issuer); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return updateCertificateIssuerDelegate(call.execute()); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param issuer The issuer bundle. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundleInner issuer, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (issuerName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter issuerName is required and cannot be null.")); + return null; + } + if (issuer == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter issuer is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + Validator.validate(issuer, serviceCallback); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updateCertificateIssuerDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse updateCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Gets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the IssuerBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return getCertificateIssuerDelegate(call.execute()); + } + + /** + * Gets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (issuerName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter issuerName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getCertificateIssuerDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Deletes the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the IssuerBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return deleteCertificateIssuerDelegate(call.execute()); + } + + /** + * Deletes the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (issuerName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter issuerName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(deleteCertificateIssuerDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse deleteCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param certificatePolicy The management policy for the certificate + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateOperationInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicyInner certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (certificatePolicy == null) { + throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); + } + Validator.validate(certificatePolicy); + final CertificateAttributesInner certificateAttributes = null; + final Map tags = null; + CertificateCreateParameters parameters = new CertificateCreateParameters(); + parameters.setCertificatePolicy(certificatePolicy); + parameters.setCertificateAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return createCertificateDelegate(call.execute()); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param certificatePolicy The management policy for the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicyInner certificatePolicy, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (certificatePolicy == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null.")); + return null; + } + Validator.validate(certificatePolicy, serviceCallback); + final CertificateAttributesInner certificateAttributes = null; + final Map tags = null; + CertificateCreateParameters parameters = new CertificateCreateParameters(); + parameters.setCertificatePolicy(certificatePolicy); + parameters.setCertificateAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(createCertificateDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateOperationInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicyInner certificatePolicy, CertificateAttributesInner certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (certificatePolicy == null) { + throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); + } + Validator.validate(certificatePolicy); + Validator.validate(certificateAttributes); + Validator.validate(tags); + CertificateCreateParameters parameters = new CertificateCreateParameters(); + parameters.setCertificatePolicy(certificatePolicy); + parameters.setCertificateAttributes(certificateAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return createCertificateDelegate(call.execute()); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicyInner certificatePolicy, CertificateAttributesInner certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (certificatePolicy == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null.")); + return null; + } + Validator.validate(certificatePolicy, serviceCallback); + Validator.validate(certificateAttributes, serviceCallback); + Validator.validate(tags, serviceCallback); + CertificateCreateParameters parameters = new CertificateCreateParameters(); + parameters.setCertificatePolicy(certificatePolicy); + parameters.setCertificateAttributes(certificateAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(createCertificateDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse createCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(202, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representaion of the certificate object to import. This certificate needs to contain the private key. + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param certificatePolicy The management policy for the certificate + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicyInner certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (base64EncodedCertificate == null) { + throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); + } + if (password == null) { + throw new IllegalArgumentException("Parameter password is required and cannot be null."); + } + if (certificatePolicy == null) { + throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); + } + Validator.validate(certificatePolicy); + final CertificateAttributesInner certificateAttributes = null; + final Map tags = null; + CertificateImportParameters parameters = new CertificateImportParameters(); + parameters.setBase64EncodedCertificate(base64EncodedCertificate); + parameters.setPassword(password); + parameters.setCertificatePolicy(certificatePolicy); + parameters.setCertificateAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return importCertificateDelegate(call.execute()); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representaion of the certificate object to import. This certificate needs to contain the private key. + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param certificatePolicy The management policy for the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicyInner certificatePolicy, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (base64EncodedCertificate == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null.")); + return null; + } + if (password == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter password is required and cannot be null.")); + return null; + } + if (certificatePolicy == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null.")); + return null; + } + Validator.validate(certificatePolicy, serviceCallback); + final CertificateAttributesInner certificateAttributes = null; + final Map tags = null; + CertificateImportParameters parameters = new CertificateImportParameters(); + parameters.setBase64EncodedCertificate(base64EncodedCertificate); + parameters.setPassword(password); + parameters.setCertificatePolicy(certificatePolicy); + parameters.setCertificateAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(importCertificateDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representaion of the certificate object to import. This certificate needs to contain the private key. + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicyInner certificatePolicy, CertificateAttributesInner certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (base64EncodedCertificate == null) { + throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); + } + if (password == null) { + throw new IllegalArgumentException("Parameter password is required and cannot be null."); + } + if (certificatePolicy == null) { + throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); + } + Validator.validate(certificatePolicy); + Validator.validate(certificateAttributes); + Validator.validate(tags); + CertificateImportParameters parameters = new CertificateImportParameters(); + parameters.setBase64EncodedCertificate(base64EncodedCertificate); + parameters.setPassword(password); + parameters.setCertificatePolicy(certificatePolicy); + parameters.setCertificateAttributes(certificateAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return importCertificateDelegate(call.execute()); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representaion of the certificate object to import. This certificate needs to contain the private key. + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicyInner certificatePolicy, CertificateAttributesInner certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (base64EncodedCertificate == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null.")); + return null; + } + if (password == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter password is required and cannot be null.")); + return null; + } + if (certificatePolicy == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null.")); + return null; + } + Validator.validate(certificatePolicy, serviceCallback); + Validator.validate(certificateAttributes, serviceCallback); + Validator.validate(tags, serviceCallback); + CertificateImportParameters parameters = new CertificateImportParameters(); + parameters.setBase64EncodedCertificate(base64EncodedCertificate); + parameters.setPassword(password); + parameters.setCertificatePolicy(certificatePolicy); + parameters.setCertificateAttributes(certificateAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(importCertificateDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse importCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getCertificateVersionsNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + final Integer maxresults = null; + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificateVersionsDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param maxresults Maximum number of results to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getCertificateVersionsNext(nextPageLink).getBody(); + } + }; + return new ServiceResponse<>(result, response.getResponse()); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificateVersionsDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getCertificateVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Gets the policy for a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificatePolicyInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return getCertificatePolicyDelegate(call.execute()); + } + + /** + * Gets the policy for a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getCertificatePolicyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @param certificatePolicy The policy for the certificate. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificatePolicyInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicyInner certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (certificatePolicy == null) { + throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(certificatePolicy); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return updateCertificatePolicyDelegate(call.execute()); + } + + /** + * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @param certificatePolicy The policy for the certificate. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicyInner certificatePolicy, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (certificatePolicy == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + Validator.validate(certificatePolicy, serviceCallback); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updateCertificatePolicyDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse updateCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (certificateVersion == null) { + throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final CertificateAttributesInner certificateAttributes = null; + final Map tags = null; + CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.setCertificateAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return updateCertificateDelegate(call.execute()); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (certificateVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + final CertificateAttributesInner certificateAttributes = null; + final Map tags = null; + CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.setCertificateAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updateCertificateDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributesInner certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (certificateVersion == null) { + throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(certificateAttributes); + Validator.validate(tags); + CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.setCertificateAttributes(certificateAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return updateCertificateDelegate(call.execute()); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributesInner certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (certificateVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + Validator.validate(certificateAttributes, serviceCallback); + Validator.validate(tags, serviceCallback); + CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.setCertificateAttributes(certificateAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updateCertificateDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse updateCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Gets a Certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (certificateVersion == null) { + throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return getCertificateDelegate(call.execute()); + } + + /** + * Gets a Certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (certificateVersion == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateVersion is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getCertificateDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Updates a certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param certificateOperation The certificate operation response. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateOperationInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateCertificateOperation(String vaultBaseUrl, String certificateName, CertificateOperationInner certificateOperation) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (certificateOperation == null) { + throw new IllegalArgumentException("Parameter certificateOperation is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(certificateOperation); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return updateCertificateOperationDelegate(call.execute()); + } + + /** + * Updates a certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param certificateOperation The certificate operation response. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, CertificateOperationInner certificateOperation, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (certificateOperation == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateOperation is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + Validator.validate(certificateOperation, serviceCallback); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(updateCertificateOperationDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse updateCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Gets the certificate operation response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateOperationInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return getCertificateOperationDelegate(call.execute()); + } + + /** + * Gets the certificate operation response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getCertificateOperationDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Deletes the certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateOperationInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + return deleteCertificateOperationDelegate(call.execute()); + } + + /** + * Deletes the certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(deleteCertificateOperationDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse deleteCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificte chain to merge + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (x509Certificates == null) { + throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); + } + Validator.validate(x509Certificates); + final CertificateAttributesInner certificateAttributes = null; + final Map tags = null; + CertificateMergeParameters parameters = new CertificateMergeParameters(); + parameters.setX509Certificates(x509Certificates); + parameters.setCertificateAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return mergeCertificateDelegate(call.execute()); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificte chain to merge + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (x509Certificates == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter x509Certificates is required and cannot be null.")); + return null; + } + Validator.validate(x509Certificates, serviceCallback); + final CertificateAttributesInner certificateAttributes = null; + final Map tags = null; + CertificateMergeParameters parameters = new CertificateMergeParameters(); + parameters.setX509Certificates(x509Certificates); + parameters.setCertificateAttributes(null); + parameters.setTags(null); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(mergeCertificateDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificte chain to merge + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributesInner certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (x509Certificates == null) { + throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); + } + Validator.validate(x509Certificates); + Validator.validate(certificateAttributes); + Validator.validate(tags); + CertificateMergeParameters parameters = new CertificateMergeParameters(); + parameters.setX509Certificates(x509Certificates); + parameters.setCertificateAttributes(certificateAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + return mergeCertificateDelegate(call.execute()); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificte chain to merge + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributesInner certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + if (x509Certificates == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter x509Certificates is required and cannot be null.")); + return null; + } + Validator.validate(x509Certificates, serviceCallback); + Validator.validate(certificateAttributes, serviceCallback); + Validator.validate(tags, serviceCallback); + CertificateMergeParameters parameters = new CertificateMergeParameters(); + parameters.setX509Certificates(x509Certificates); + parameters.setCertificateAttributes(certificateAttributes); + parameters.setTags(tags); + this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(mergeCertificateDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse mergeCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) + .register(201, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List the versions of the specified key. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<KeyItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + this.restClient().setBaseUrl(); + Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getKeyVersionsNextDelegate(call.execute()); + } + + /** + * List the versions of the specified key. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (nextPageLink == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl(); + Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getKeyVersionsNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getKeyVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List keys in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<KeyItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + this.restClient().setBaseUrl(); + Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getKeysNextDelegate(call.execute()); + } + + /** + * List keys in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getKeysNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (nextPageLink == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl(); + Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getKeysNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getKeysNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List secrets in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<SecretItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + this.restClient().setBaseUrl(); + Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getSecretsNextDelegate(call.execute()); + } + + /** + * List secrets in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getSecretsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (nextPageLink == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl(); + Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getSecretsNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getSecretsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List the versions of the specified secret. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<SecretItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + this.restClient().setBaseUrl(); + Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getSecretVersionsNextDelegate(call.execute()); + } + + /** + * List the versions of the specified secret. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (nextPageLink == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl(); + Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getSecretVersionsNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getSecretVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List certificates in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + this.restClient().setBaseUrl(); + Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getCertificatesNextDelegate(call.execute()); + } + + /** + * List certificates in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificatesNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (nextPageLink == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl(); + Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificatesNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getCertificatesNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List certificate issuers for the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateIssuerItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + this.restClient().setBaseUrl(); + Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getCertificateIssuersNextDelegate(call.execute()); + } + + /** + * List certificate issuers for the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (nextPageLink == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl(); + Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificateIssuersNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getCertificateIssuersNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List the versions of a certificate. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItemInner> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + this.restClient().setBaseUrl(); + Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getCertificateVersionsNextDelegate(call.execute()); + } + + /** + * List the versions of a certificate. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (nextPageLink == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); + return null; + } + this.restClient().setBaseUrl(); + Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificateVersionsNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse> getCertificateVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultError.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultError.java new file mode 100644 index 0000000000000..c504f03637deb --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultError.java @@ -0,0 +1,60 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The KeyVaultError model. + */ +public class KeyVaultError { + /** + * The code property. + */ + @JsonProperty(value = "error.code", access = JsonProperty.Access.WRITE_ONLY) + private String code; + + /** + * The message property. + */ + @JsonProperty(value = "error.message", access = JsonProperty.Access.WRITE_ONLY) + private String message; + + /** + * The additionalInfo property. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private Object additionalInfo; + + /** + * Get the code value. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Get the additionalInfo value. + * + * @return the additionalInfo value + */ + public Object additionalInfo() { + return this.additionalInfo; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultErrorException.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultErrorException.java new file mode 100644 index 0000000000000..71fbfd04d67de --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultErrorException.java @@ -0,0 +1,85 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.microsoft.rest.RestException; +import retrofit2.Response; + +/** + * Exception thrown for an invalid response with KeyVaultError information. + */ +public class KeyVaultErrorException extends RestException { + /** + * Information about the associated HTTP response. + */ + private Response response; + /** + * The actual response body. + */ + private KeyVaultError body; + /** + * Initializes a new instance of the KeyVaultErrorException class. + */ + public KeyVaultErrorException() { } + /** + * Initializes a new instance of the KeyVaultErrorException class. + * + * @param message The exception message. + */ + public KeyVaultErrorException(final String message) { + super(message); + } + /** + * Initializes a new instance of the KeyVaultErrorException class. + * + * @param message the exception message + * @param cause exception that caused this exception to occur + */ + public KeyVaultErrorException(final String message, final Throwable cause) { + super(message, cause); + } + /** + * Initializes a new instance of the KeyVaultErrorException class. + * + * @param cause exception that caused this exception to occur + */ + public KeyVaultErrorException(final Throwable cause) { + super(cause); + } + /** + * Gets information about the associated HTTP response. + * + * @return the HTTP response + */ + public Response getResponse() { + return response; + } + /** + * Gets the HTTP response body. + * + * @return the response body + */ + public KeyVaultError getBody() { + return body; + } + /** + * Sets the HTTP response. + * + * @param response the HTTP response + */ + public void setResponse(Response response) { + this.response = response; + } + /** + * Sets the HTTP response body. + * + * @param body the response body + */ + public void setBody(KeyVaultError body) { + this.body = body; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyParameters.java new file mode 100644 index 0000000000000..8bd81f43c138f --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyParameters.java @@ -0,0 +1,94 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The KeyVerifyParameters model. + */ +public class KeyVerifyParameters { + /** + * The signing/verification algorithm. For more information on possible + * algorithm types, see JsonWebKeySignatureAlgorithm. + */ + @JsonProperty(value = "alg", required = true) + private String algorithm; + + /** + * The digest used for signing. + */ + @JsonProperty(required = true) + private String digest; + + /** + * The signature to be verified. + */ + @JsonProperty(value = "value", required = true) + private String signature; + + /** + * Get the algorithm value. + * + * @return the algorithm value + */ + public String algorithm() { + return this.algorithm; + } + + /** + * Set the algorithm value. + * + * @param algorithm the algorithm value to set + * @return the KeyVerifyParameters object itself. + */ + public KeyVerifyParameters setAlgorithm(String algorithm) { + this.algorithm = algorithm; + return this; + } + + /** + * Get the digest value. + * + * @return the digest value + */ + public String digest() { + return this.digest; + } + + /** + * Set the digest value. + * + * @param digest the digest value to set + * @return the KeyVerifyParameters object itself. + */ + public KeyVerifyParameters setDigest(String digest) { + this.digest = digest; + return this; + } + + /** + * Get the signature value. + * + * @return the signature value + */ + public String signature() { + return this.signature; + } + + /** + * Set the signature value. + * + * @param signature the signature value to set + * @return the KeyVerifyParameters object itself. + */ + public KeyVerifyParameters setSignature(String signature) { + this.signature = signature; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyResultInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyResultInner.java new file mode 100644 index 0000000000000..498c3377c2060 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyResultInner.java @@ -0,0 +1,30 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The KeyVerifyResultInner model. + */ +public class KeyVerifyResultInner { + /** + * true if the signature is verified, false otherwise. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private Boolean value; + + /** + * Get the value value. + * + * @return the value value + */ + public Boolean value() { + return this.value; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/LifetimeAction.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/LifetimeAction.java new file mode 100644 index 0000000000000..7d7b058d7a532 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/LifetimeAction.java @@ -0,0 +1,64 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + + +/** + * The LifetimeAction model. + */ +public class LifetimeAction { + /** + * The condition that will execute the action. + */ + private Trigger trigger; + + /** + * The action that will be executed. + */ + private Action action; + + /** + * Get the trigger value. + * + * @return the trigger value + */ + public Trigger trigger() { + return this.trigger; + } + + /** + * Set the trigger value. + * + * @param trigger the trigger value to set + * @return the LifetimeAction object itself. + */ + public LifetimeAction setTrigger(Trigger trigger) { + this.trigger = trigger; + return this; + } + + /** + * Get the action value. + * + * @return the action value + */ + public Action action() { + return this.action; + } + + /** + * Set the action value. + * + * @param action the action value to set + * @return the LifetimeAction object itself. + */ + public LifetimeAction setAction(Action action) { + this.action = action; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/OrganizationDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/OrganizationDetails.java new file mode 100644 index 0000000000000..966176854fb57 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/OrganizationDetails.java @@ -0,0 +1,218 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The OrganizationDetails model. + */ +public class OrganizationDetails { + /** + * Name of the organization. + */ + private String name; + + /** + * Address line 1. + */ + private String address1; + + /** + * Address line 2. + */ + private String address2; + + /** + * City. + */ + private String city; + + /** + * Zipcode. + */ + @JsonProperty(value = "zip") + private String zipcode; + + /** + * State. + */ + private String state; + + /** + * Country. + */ + private String country; + + /** + * Details of the organization administrator. + */ + @JsonProperty(value = "AdministratorDetails") + private List administratorDetails; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the OrganizationDetails object itself. + */ + public OrganizationDetails setName(String name) { + this.name = name; + return this; + } + + /** + * Get the address1 value. + * + * @return the address1 value + */ + public String address1() { + return this.address1; + } + + /** + * Set the address1 value. + * + * @param address1 the address1 value to set + * @return the OrganizationDetails object itself. + */ + public OrganizationDetails setAddress1(String address1) { + this.address1 = address1; + return this; + } + + /** + * Get the address2 value. + * + * @return the address2 value + */ + public String address2() { + return this.address2; + } + + /** + * Set the address2 value. + * + * @param address2 the address2 value to set + * @return the OrganizationDetails object itself. + */ + public OrganizationDetails setAddress2(String address2) { + this.address2 = address2; + return this; + } + + /** + * Get the city value. + * + * @return the city value + */ + public String city() { + return this.city; + } + + /** + * Set the city value. + * + * @param city the city value to set + * @return the OrganizationDetails object itself. + */ + public OrganizationDetails setCity(String city) { + this.city = city; + return this; + } + + /** + * Get the zipcode value. + * + * @return the zipcode value + */ + public String zipcode() { + return this.zipcode; + } + + /** + * Set the zipcode value. + * + * @param zipcode the zipcode value to set + * @return the OrganizationDetails object itself. + */ + public OrganizationDetails setZipcode(String zipcode) { + this.zipcode = zipcode; + return this; + } + + /** + * Get the state value. + * + * @return the state value + */ + public String state() { + return this.state; + } + + /** + * Set the state value. + * + * @param state the state value to set + * @return the OrganizationDetails object itself. + */ + public OrganizationDetails setState(String state) { + this.state = state; + return this; + } + + /** + * Get the country value. + * + * @return the country value + */ + public String country() { + return this.country; + } + + /** + * Set the country value. + * + * @param country the country value to set + * @return the OrganizationDetails object itself. + */ + public OrganizationDetails setCountry(String country) { + this.country = country; + return this; + } + + /** + * Get the administratorDetails value. + * + * @return the administratorDetails value + */ + public List administratorDetails() { + return this.administratorDetails; + } + + /** + * Set the administratorDetails value. + * + * @param administratorDetails the administratorDetails value to set + * @return the OrganizationDetails object itself. + */ + public OrganizationDetails setAdministratorDetails(List administratorDetails) { + this.administratorDetails = administratorDetails; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PageImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PageImpl.java new file mode 100644 index 0000000000000..315104b999a07 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PageImpl.java @@ -0,0 +1,73 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.Page; +import java.util.List; + +/** + * An instance of this class defines a page of Azure resources and a link to + * get the next page of resources, if any. + * + * @param type of Azure resource + */ +public class PageImpl implements Page { + /** + * The link to the next page. + */ + @JsonProperty("nextLink") + private String nextPageLink; + + /** + * The list of items. + */ + @JsonProperty("value") + private List items; + + /** + * Gets the link to the next page. + * + * @return the link to the next page. + */ + @Override + public String getNextPageLink() { + return this.nextPageLink; + } + + /** + * Gets the list of items. + * + * @return the list of items in {@link List}. + */ + @Override + public List getItems() { + return items; + } + + /** + * Sets the link to the next page. + * + * @param nextPageLink the link to the next page. + * @return this Page object itself. + */ + public PageImpl setNextPageLink(String nextPageLink) { + this.nextPageLink = nextPageLink; + return this; + } + + /** + * Sets the list of items. + * + * @param items the list of items in {@link List}. + * @return this Page object itself. + */ + public PageImpl setItems(List items) { + this.items = items; + return this; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PendingCertificateSigningRequestResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PendingCertificateSigningRequestResult.java new file mode 100644 index 0000000000000..eccaac27e5af8 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PendingCertificateSigningRequestResult.java @@ -0,0 +1,30 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The PendingCertificateSigningRequestResult model. + */ +public class PendingCertificateSigningRequestResult { + /** + * The pending certificate signing request as Base64 encoded string. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String value; + + /** + * Get the value value. + * + * @return the value value + */ + public String value() { + return this.value; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretAttributesInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretAttributesInner.java new file mode 100644 index 0000000000000..d7ab4522fdbe4 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretAttributesInner.java @@ -0,0 +1,14 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + + +/** + * The SecretAttributesInner model. + */ +public class SecretAttributesInner extends Attributes { +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretBundleInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretBundleInner.java new file mode 100644 index 0000000000000..850d7b026667a --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretBundleInner.java @@ -0,0 +1,140 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.Map; + +/** + * The SecretBundleInner model. + */ +public class SecretBundleInner { + /** + * The secret value. + */ + private String value; + + /** + * The secret id. + */ + private String id; + + /** + * The content type of the secret. + */ + private String contentType; + + /** + * The secret management attributes. + */ + private SecretAttributesInner attributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the value value. + * + * @return the value value + */ + public String value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the SecretBundleInner object itself. + */ + public SecretBundleInner setValue(String value) { + this.value = value; + return this; + } + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the SecretBundleInner object itself. + */ + public SecretBundleInner setId(String id) { + this.id = id; + return this; + } + + /** + * Get the contentType value. + * + * @return the contentType value + */ + public String contentType() { + return this.contentType; + } + + /** + * Set the contentType value. + * + * @param contentType the contentType value to set + * @return the SecretBundleInner object itself. + */ + public SecretBundleInner setContentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public SecretAttributesInner attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the SecretBundleInner object itself. + */ + public SecretBundleInner setAttributes(SecretAttributesInner attributes) { + this.attributes = attributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the SecretBundleInner object itself. + */ + public SecretBundleInner setTags(Map tags) { + this.tags = tags; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretItemInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretItemInner.java new file mode 100644 index 0000000000000..af5245e6f1a34 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretItemInner.java @@ -0,0 +1,115 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.Map; + +/** + * The SecretItemInner model. + */ +public class SecretItemInner { + /** + * Secret Identifier. + */ + private String id; + + /** + * The secret management attributes. + */ + private SecretAttributesInner attributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Type of the secret value such as a password. + */ + private String contentType; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the SecretItemInner object itself. + */ + public SecretItemInner setId(String id) { + this.id = id; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public SecretAttributesInner attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the SecretItemInner object itself. + */ + public SecretItemInner setAttributes(SecretAttributesInner attributes) { + this.attributes = attributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the SecretItemInner object itself. + */ + public SecretItemInner setTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the contentType value. + * + * @return the contentType value + */ + public String contentType() { + return this.contentType; + } + + /** + * Set the contentType value. + * + * @param contentType the contentType value to set + * @return the SecretItemInner object itself. + */ + public SecretItemInner setContentType(String contentType) { + this.contentType = contentType; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretProperties.java new file mode 100644 index 0000000000000..466d90d0343a7 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretProperties.java @@ -0,0 +1,41 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The SecretProperties model. + */ +public class SecretProperties { + /** + * The media type (MIME type). + */ + @JsonProperty(value = "ContentType") + private String contentType; + + /** + * Get the contentType value. + * + * @return the contentType value + */ + public String contentType() { + return this.contentType; + } + + /** + * Set the contentType value. + * + * @param contentType the contentType value to set + * @return the SecretProperties object itself. + */ + public SecretProperties setContentType(String contentType) { + this.contentType = contentType; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretSetParameters.java new file mode 100644 index 0000000000000..3cb2510508571 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretSetParameters.java @@ -0,0 +1,118 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The SecretSetParameters model. + */ +public class SecretSetParameters { + /** + * The value of the secret. + */ + @JsonProperty(required = true) + private String value; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Type of the secret value such as a password. + */ + private String contentType; + + /** + * The secretAttributes property. + */ + @JsonProperty(value = "attributes") + private SecretAttributesInner secretAttributes; + + /** + * Get the value value. + * + * @return the value value + */ + public String value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the SecretSetParameters object itself. + */ + public SecretSetParameters setValue(String value) { + this.value = value; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the SecretSetParameters object itself. + */ + public SecretSetParameters setTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the contentType value. + * + * @return the contentType value + */ + public String contentType() { + return this.contentType; + } + + /** + * Set the contentType value. + * + * @param contentType the contentType value to set + * @return the SecretSetParameters object itself. + */ + public SecretSetParameters setContentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Get the secretAttributes value. + * + * @return the secretAttributes value + */ + public SecretAttributesInner secretAttributes() { + return this.secretAttributes; + } + + /** + * Set the secretAttributes value. + * + * @param secretAttributes the secretAttributes value to set + * @return the SecretSetParameters object itself. + */ + public SecretSetParameters setSecretAttributes(SecretAttributesInner secretAttributes) { + this.secretAttributes = secretAttributes; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretUpdateParameters.java new file mode 100644 index 0000000000000..f9ee68f2a6c0b --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretUpdateParameters.java @@ -0,0 +1,92 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The SecretUpdateParameters model. + */ +public class SecretUpdateParameters { + /** + * Type of the secret value such as a password. + */ + private String contentType; + + /** + * The secretAttributes property. + */ + @JsonProperty(value = "attributes") + private SecretAttributesInner secretAttributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the contentType value. + * + * @return the contentType value + */ + public String contentType() { + return this.contentType; + } + + /** + * Set the contentType value. + * + * @param contentType the contentType value to set + * @return the SecretUpdateParameters object itself. + */ + public SecretUpdateParameters setContentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Get the secretAttributes value. + * + * @return the secretAttributes value + */ + public SecretAttributesInner secretAttributes() { + return this.secretAttributes; + } + + /** + * Set the secretAttributes value. + * + * @param secretAttributes the secretAttributes value to set + * @return the SecretUpdateParameters object itself. + */ + public SecretUpdateParameters setSecretAttributes(SecretAttributesInner secretAttributes) { + this.secretAttributes = secretAttributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the SecretUpdateParameters object itself. + */ + public SecretUpdateParameters setTags(Map tags) { + this.tags = tags; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SubjectAlternativeNames.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SubjectAlternativeNames.java new file mode 100644 index 0000000000000..049064abfca9a --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SubjectAlternativeNames.java @@ -0,0 +1,92 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The SubjectAlternativeNames model. + */ +public class SubjectAlternativeNames { + /** + * Email addresses. + */ + private List emails; + + /** + * Domain names. + */ + @JsonProperty(value = "dns_names") + private List dnsNames; + + /** + * User principal names. + */ + private List upns; + + /** + * Get the emails value. + * + * @return the emails value + */ + public List emails() { + return this.emails; + } + + /** + * Set the emails value. + * + * @param emails the emails value to set + * @return the SubjectAlternativeNames object itself. + */ + public SubjectAlternativeNames setEmails(List emails) { + this.emails = emails; + return this; + } + + /** + * Get the dnsNames value. + * + * @return the dnsNames value + */ + public List dnsNames() { + return this.dnsNames; + } + + /** + * Set the dnsNames value. + * + * @param dnsNames the dnsNames value to set + * @return the SubjectAlternativeNames object itself. + */ + public SubjectAlternativeNames setDnsNames(List dnsNames) { + this.dnsNames = dnsNames; + return this; + } + + /** + * Get the upns value. + * + * @return the upns value + */ + public List upns() { + return this.upns; + } + + /** + * Set the upns value. + * + * @param upns the upns value to set + * @return the SubjectAlternativeNames object itself. + */ + public SubjectAlternativeNames setUpns(List upns) { + this.upns = upns; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Trigger.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Trigger.java new file mode 100644 index 0000000000000..395a1fe79b303 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Trigger.java @@ -0,0 +1,41 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The Trigger model. + */ +public class Trigger { + /** + * The type of the action. + */ + @JsonProperty(value = "lifetime_percentage") + private Integer lifetimePercentage; + + /** + * Get the lifetimePercentage value. + * + * @return the lifetimePercentage value + */ + public Integer lifetimePercentage() { + return this.lifetimePercentage; + } + + /** + * Set the lifetimePercentage value. + * + * @param lifetimePercentage the lifetimePercentage value to set + * @return the Trigger object itself. + */ + public Trigger setLifetimePercentage(Integer lifetimePercentage) { + this.lifetimePercentage = lifetimePercentage; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/X509CertificateProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/X509CertificateProperties.java new file mode 100644 index 0000000000000..a575de944736c --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/X509CertificateProperties.java @@ -0,0 +1,144 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The X509CertificateProperties model. + */ +public class X509CertificateProperties { + /** + * The subject name. Should be a valid X500 Distinguished Name. + */ + private String subject; + + /** + * The subject alternate names. + */ + private List ekus; + + /** + * The subject alternative names. + */ + @JsonProperty(value = "sans") + private SubjectAlternativeNames subjectAlternativeNames; + + /** + * The subject alternate names. + */ + @JsonProperty(value = "key_usage") + private List keyUsage; + + /** + * The subject alternate names. + */ + @JsonProperty(value = "validity_months") + private Integer validityInMonths; + + /** + * Get the subject value. + * + * @return the subject value + */ + public String subject() { + return this.subject; + } + + /** + * Set the subject value. + * + * @param subject the subject value to set + * @return the X509CertificateProperties object itself. + */ + public X509CertificateProperties setSubject(String subject) { + this.subject = subject; + return this; + } + + /** + * Get the ekus value. + * + * @return the ekus value + */ + public List ekus() { + return this.ekus; + } + + /** + * Set the ekus value. + * + * @param ekus the ekus value to set + * @return the X509CertificateProperties object itself. + */ + public X509CertificateProperties setEkus(List ekus) { + this.ekus = ekus; + return this; + } + + /** + * Get the subjectAlternativeNames value. + * + * @return the subjectAlternativeNames value + */ + public SubjectAlternativeNames subjectAlternativeNames() { + return this.subjectAlternativeNames; + } + + /** + * Set the subjectAlternativeNames value. + * + * @param subjectAlternativeNames the subjectAlternativeNames value to set + * @return the X509CertificateProperties object itself. + */ + public X509CertificateProperties setSubjectAlternativeNames(SubjectAlternativeNames subjectAlternativeNames) { + this.subjectAlternativeNames = subjectAlternativeNames; + return this; + } + + /** + * Get the keyUsage value. + * + * @return the keyUsage value + */ + public List keyUsage() { + return this.keyUsage; + } + + /** + * Set the keyUsage value. + * + * @param keyUsage the keyUsage value to set + * @return the X509CertificateProperties object itself. + */ + public X509CertificateProperties setKeyUsage(List keyUsage) { + this.keyUsage = keyUsage; + return this; + } + + /** + * Get the validityInMonths value. + * + * @return the validityInMonths value + */ + public Integer validityInMonths() { + return this.validityInMonths; + } + + /** + * Set the validityInMonths value. + * + * @param validityInMonths the validityInMonths value to set + * @return the X509CertificateProperties object itself. + */ + public X509CertificateProperties setValidityInMonths(Integer validityInMonths) { + this.validityInMonths = validityInMonths; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/package-info.java new file mode 100644 index 0000000000000..4b09867281625 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/package-info.java @@ -0,0 +1,9 @@ +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +/** + * This package contains the implementation.api classes for KeyVaultClient. + * Client class to perform cryptographic key operations and vault operations against the Key Vault service. + */ +package com.microsoft.azure.keyvault.implementation.api; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java new file mode 100644 index 0000000000000..71b13c1e3ea8a --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java @@ -0,0 +1,9 @@ +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +/** + * This package contains the implementation classes for KeyVaultClient. + * Client class to perform cryptographic key operations and vault operations against the Key Vault service. + */ +package com.microsoft.azure.keyvault.implementation; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java new file mode 100644 index 0000000000000..1160e5ba8eb04 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java @@ -0,0 +1,9 @@ +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +/** + * This package contains the classes for KeyVaultClient. + * Client class to perform cryptographic key operations and vault operations against the Key Vault service. + */ +package com.microsoft.azure.keyvault; From 2c4080ba42a7a9d919b8e1744599956ae6b685a8 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Wed, 15 Jun 2016 16:13:04 -0700 Subject: [PATCH 02/56] Updated the Key Vault client generated code --- .../keyvault/implementation/api/Action.java | 2 +- .../api/AdministratorDetails.java | 8 +- .../implementation/api/Attributes.java | 6 +- .../api/CertificateBundleInner.java | 8 +- .../api/CertificateCreateParameters.java | 6 +- .../api/CertificateImportParameters.java | 10 +- .../api/CertificateIssuerItemInner.java | 4 +- .../api/CertificateItemInner.java | 8 +- .../api/CertificateMergeParameters.java | 6 +- .../api/CertificateOperationInner.java | 20 +- .../api/CertificatePolicyInner.java | 12 +- .../api/CertificateUpdateParameters.java | 4 +- .../keyvault/implementation/api/Contact.java | 6 +- .../implementation/api/ContactsInner.java | 2 +- .../keyvault/implementation/api/Error.java | 45 + .../implementation/api/IssuerAttributes.java | 2 +- .../implementation/api/IssuerBundleInner.java | 8 +- .../implementation/api/IssuerCredentials.java | 4 +- .../implementation/api/IssuerReference.java | 2 +- .../implementation/api/JsonWebKeyInner.java | 26 +- .../implementation/api/KeyBundleInner.java | 6 +- .../api/KeyCreateParameters.java | 10 +- .../api/KeyImportParameters.java | 8 +- .../implementation/api/KeyItemInner.java | 6 +- .../api/KeyOperationsParameters.java | 4 +- .../implementation/api/KeyProperties.java | 8 +- .../api/KeyRestoreParameters.java | 2 +- .../api/KeyUpdateParameters.java | 6 +- .../api/KeyVaultClientImpl.java | 896 +++++++++--------- .../implementation/api/KeyVaultError.java | 42 +- .../api/KeyVerifyParameters.java | 6 +- .../implementation/api/LifetimeAction.java | 4 +- .../api/OrganizationDetails.java | 16 +- .../implementation/api/SecretBundleInner.java | 10 +- .../implementation/api/SecretItemInner.java | 8 +- .../implementation/api/SecretProperties.java | 2 +- .../api/SecretSetParameters.java | 8 +- .../api/SecretUpdateParameters.java | 6 +- .../api/SubjectAlternativeNames.java | 6 +- .../keyvault/implementation/api/Trigger.java | 2 +- .../api/X509CertificateProperties.java | 10 +- 41 files changed, 631 insertions(+), 624 deletions(-) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Error.java diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Action.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Action.java index 16f3929d57286..ac83df8194215 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Action.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Action.java @@ -33,7 +33,7 @@ public String actionType() { * @param actionType the actionType value to set * @return the Action object itself. */ - public Action setActionType(String actionType) { + public Action withActionType(String actionType) { this.actionType = actionType; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/AdministratorDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/AdministratorDetails.java index 3fac9e65f5bfd..0e5717b3385ce 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/AdministratorDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/AdministratorDetails.java @@ -50,7 +50,7 @@ public String firstName() { * @param firstName the firstName value to set * @return the AdministratorDetails object itself. */ - public AdministratorDetails setFirstName(String firstName) { + public AdministratorDetails withFirstName(String firstName) { this.firstName = firstName; return this; } @@ -70,7 +70,7 @@ public String lastName() { * @param lastName the lastName value to set * @return the AdministratorDetails object itself. */ - public AdministratorDetails setLastName(String lastName) { + public AdministratorDetails withLastName(String lastName) { this.lastName = lastName; return this; } @@ -90,7 +90,7 @@ public String emailAddress() { * @param emailAddress the emailAddress value to set * @return the AdministratorDetails object itself. */ - public AdministratorDetails setEmailAddress(String emailAddress) { + public AdministratorDetails withEmailAddress(String emailAddress) { this.emailAddress = emailAddress; return this; } @@ -110,7 +110,7 @@ public String phone() { * @param phone the phone value to set * @return the AdministratorDetails object itself. */ - public AdministratorDetails setPhone(String phone) { + public AdministratorDetails withPhone(String phone) { this.phone = phone; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Attributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Attributes.java index 5e47048138282..a7f84612cbef0 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Attributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Attributes.java @@ -56,7 +56,7 @@ public Boolean enabled() { * @param enabled the enabled value to set * @return the Attributes object itself. */ - public Attributes setEnabled(Boolean enabled) { + public Attributes withEnabled(Boolean enabled) { this.enabled = enabled; return this; } @@ -76,7 +76,7 @@ public Long notBefore() { * @param notBefore the notBefore value to set * @return the Attributes object itself. */ - public Attributes setNotBefore(Long notBefore) { + public Attributes withNotBefore(Long notBefore) { this.notBefore = notBefore; return this; } @@ -96,7 +96,7 @@ public Long expires() { * @param expires the expires value to set * @return the Attributes object itself. */ - public Attributes setExpires(Long expires) { + public Attributes withExpires(Long expires) { this.expires = expires; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateBundleInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateBundleInner.java index b17eb35923a9e..764173f4bdbd2 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateBundleInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateBundleInner.java @@ -123,7 +123,7 @@ public String cer() { * @param cer the cer value to set * @return the CertificateBundleInner object itself. */ - public CertificateBundleInner setCer(String cer) { + public CertificateBundleInner withCer(String cer) { this.cer = cer; return this; } @@ -143,7 +143,7 @@ public String contentType() { * @param contentType the contentType value to set * @return the CertificateBundleInner object itself. */ - public CertificateBundleInner setContentType(String contentType) { + public CertificateBundleInner withContentType(String contentType) { this.contentType = contentType; return this; } @@ -163,7 +163,7 @@ public CertificateAttributesInner attributes() { * @param attributes the attributes value to set * @return the CertificateBundleInner object itself. */ - public CertificateBundleInner setAttributes(CertificateAttributesInner attributes) { + public CertificateBundleInner withAttributes(CertificateAttributesInner attributes) { this.attributes = attributes; return this; } @@ -183,7 +183,7 @@ public Map tags() { * @param tags the tags value to set * @return the CertificateBundleInner object itself. */ - public CertificateBundleInner setTags(Map tags) { + public CertificateBundleInner withTags(Map tags) { this.tags = tags; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateCreateParameters.java index 47b6ceee2dea0..548ab8b64a492 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateCreateParameters.java @@ -45,7 +45,7 @@ public CertificatePolicyInner certificatePolicy() { * @param certificatePolicy the certificatePolicy value to set * @return the CertificateCreateParameters object itself. */ - public CertificateCreateParameters setCertificatePolicy(CertificatePolicyInner certificatePolicy) { + public CertificateCreateParameters withCertificatePolicy(CertificatePolicyInner certificatePolicy) { this.certificatePolicy = certificatePolicy; return this; } @@ -65,7 +65,7 @@ public CertificateAttributesInner certificateAttributes() { * @param certificateAttributes the certificateAttributes value to set * @return the CertificateCreateParameters object itself. */ - public CertificateCreateParameters setCertificateAttributes(CertificateAttributesInner certificateAttributes) { + public CertificateCreateParameters withCertificateAttributes(CertificateAttributesInner certificateAttributes) { this.certificateAttributes = certificateAttributes; return this; } @@ -85,7 +85,7 @@ public Map tags() { * @param tags the tags value to set * @return the CertificateCreateParameters object itself. */ - public CertificateCreateParameters setTags(Map tags) { + public CertificateCreateParameters withTags(Map tags) { this.tags = tags; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateImportParameters.java index 5ac03538516ac..1c4c87173a3db 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateImportParameters.java @@ -59,7 +59,7 @@ public String base64EncodedCertificate() { * @param base64EncodedCertificate the base64EncodedCertificate value to set * @return the CertificateImportParameters object itself. */ - public CertificateImportParameters setBase64EncodedCertificate(String base64EncodedCertificate) { + public CertificateImportParameters withBase64EncodedCertificate(String base64EncodedCertificate) { this.base64EncodedCertificate = base64EncodedCertificate; return this; } @@ -79,7 +79,7 @@ public String password() { * @param password the password value to set * @return the CertificateImportParameters object itself. */ - public CertificateImportParameters setPassword(String password) { + public CertificateImportParameters withPassword(String password) { this.password = password; return this; } @@ -99,7 +99,7 @@ public CertificatePolicyInner certificatePolicy() { * @param certificatePolicy the certificatePolicy value to set * @return the CertificateImportParameters object itself. */ - public CertificateImportParameters setCertificatePolicy(CertificatePolicyInner certificatePolicy) { + public CertificateImportParameters withCertificatePolicy(CertificatePolicyInner certificatePolicy) { this.certificatePolicy = certificatePolicy; return this; } @@ -119,7 +119,7 @@ public CertificateAttributesInner certificateAttributes() { * @param certificateAttributes the certificateAttributes value to set * @return the CertificateImportParameters object itself. */ - public CertificateImportParameters setCertificateAttributes(CertificateAttributesInner certificateAttributes) { + public CertificateImportParameters withCertificateAttributes(CertificateAttributesInner certificateAttributes) { this.certificateAttributes = certificateAttributes; return this; } @@ -139,7 +139,7 @@ public Map tags() { * @param tags the tags value to set * @return the CertificateImportParameters object itself. */ - public CertificateImportParameters setTags(Map tags) { + public CertificateImportParameters withTags(Map tags) { this.tags = tags; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateIssuerItemInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateIssuerItemInner.java index ae9dc7c45938f..e9945a9ec0400 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateIssuerItemInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateIssuerItemInner.java @@ -36,7 +36,7 @@ public String id() { * @param id the id value to set * @return the CertificateIssuerItemInner object itself. */ - public CertificateIssuerItemInner setId(String id) { + public CertificateIssuerItemInner withId(String id) { this.id = id; return this; } @@ -56,7 +56,7 @@ public String provider() { * @param provider the provider value to set * @return the CertificateIssuerItemInner object itself. */ - public CertificateIssuerItemInner setProvider(String provider) { + public CertificateIssuerItemInner withProvider(String provider) { this.provider = provider; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateItemInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateItemInner.java index 779b0e8dd2c65..44773df601a6f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateItemInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateItemInner.java @@ -49,7 +49,7 @@ public String id() { * @param id the id value to set * @return the CertificateItemInner object itself. */ - public CertificateItemInner setId(String id) { + public CertificateItemInner withId(String id) { this.id = id; return this; } @@ -69,7 +69,7 @@ public CertificateAttributesInner attributes() { * @param attributes the attributes value to set * @return the CertificateItemInner object itself. */ - public CertificateItemInner setAttributes(CertificateAttributesInner attributes) { + public CertificateItemInner withAttributes(CertificateAttributesInner attributes) { this.attributes = attributes; return this; } @@ -89,7 +89,7 @@ public Map tags() { * @param tags the tags value to set * @return the CertificateItemInner object itself. */ - public CertificateItemInner setTags(Map tags) { + public CertificateItemInner withTags(Map tags) { this.tags = tags; return this; } @@ -109,7 +109,7 @@ public String x5T() { * @param x5T the x5T value to set * @return the CertificateItemInner object itself. */ - public CertificateItemInner setX5T(String x5T) { + public CertificateItemInner withX5T(String x5T) { this.x5T = x5T; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateMergeParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateMergeParameters.java index c793a83daa0f1..c108a8ef1f008 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateMergeParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateMergeParameters.java @@ -46,7 +46,7 @@ public List x509Certificates() { * @param x509Certificates the x509Certificates value to set * @return the CertificateMergeParameters object itself. */ - public CertificateMergeParameters setX509Certificates(List x509Certificates) { + public CertificateMergeParameters withX509Certificates(List x509Certificates) { this.x509Certificates = x509Certificates; return this; } @@ -66,7 +66,7 @@ public CertificateAttributesInner certificateAttributes() { * @param certificateAttributes the certificateAttributes value to set * @return the CertificateMergeParameters object itself. */ - public CertificateMergeParameters setCertificateAttributes(CertificateAttributesInner certificateAttributes) { + public CertificateMergeParameters withCertificateAttributes(CertificateAttributesInner certificateAttributes) { this.certificateAttributes = certificateAttributes; return this; } @@ -86,7 +86,7 @@ public Map tags() { * @param tags the tags value to set * @return the CertificateMergeParameters object itself. */ - public CertificateMergeParameters setTags(Map tags) { + public CertificateMergeParameters withTags(Map tags) { this.tags = tags; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateOperationInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateOperationInner.java index 33bbddf237e91..b5ee3da1a1068 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateOperationInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateOperationInner.java @@ -50,7 +50,7 @@ public class CertificateOperationInner { /** * Error encountered, if any, during the certificate operation. */ - private KeyVaultError error; + private Error error; /** * Location which contains the result of the certificate operation. @@ -87,7 +87,7 @@ public IssuerReference issuerReference() { * @param issuerReference the issuerReference value to set * @return the CertificateOperationInner object itself. */ - public CertificateOperationInner setIssuerReference(IssuerReference issuerReference) { + public CertificateOperationInner withIssuerReference(IssuerReference issuerReference) { this.issuerReference = issuerReference; return this; } @@ -107,7 +107,7 @@ public String csr() { * @param csr the csr value to set * @return the CertificateOperationInner object itself. */ - public CertificateOperationInner setCsr(String csr) { + public CertificateOperationInner withCsr(String csr) { this.csr = csr; return this; } @@ -127,7 +127,7 @@ public Boolean cancellationRequested() { * @param cancellationRequested the cancellationRequested value to set * @return the CertificateOperationInner object itself. */ - public CertificateOperationInner setCancellationRequested(Boolean cancellationRequested) { + public CertificateOperationInner withCancellationRequested(Boolean cancellationRequested) { this.cancellationRequested = cancellationRequested; return this; } @@ -147,7 +147,7 @@ public String status() { * @param status the status value to set * @return the CertificateOperationInner object itself. */ - public CertificateOperationInner setStatus(String status) { + public CertificateOperationInner withStatus(String status) { this.status = status; return this; } @@ -167,7 +167,7 @@ public String statusDetails() { * @param statusDetails the statusDetails value to set * @return the CertificateOperationInner object itself. */ - public CertificateOperationInner setStatusDetails(String statusDetails) { + public CertificateOperationInner withStatusDetails(String statusDetails) { this.statusDetails = statusDetails; return this; } @@ -177,7 +177,7 @@ public CertificateOperationInner setStatusDetails(String statusDetails) { * * @return the error value */ - public KeyVaultError error() { + public Error error() { return this.error; } @@ -187,7 +187,7 @@ public KeyVaultError error() { * @param error the error value to set * @return the CertificateOperationInner object itself. */ - public CertificateOperationInner setError(KeyVaultError error) { + public CertificateOperationInner withError(Error error) { this.error = error; return this; } @@ -207,7 +207,7 @@ public String target() { * @param target the target value to set * @return the CertificateOperationInner object itself. */ - public CertificateOperationInner setTarget(String target) { + public CertificateOperationInner withTarget(String target) { this.target = target; return this; } @@ -227,7 +227,7 @@ public String requestId() { * @param requestId the requestId value to set * @return the CertificateOperationInner object itself. */ - public CertificateOperationInner setRequestId(String requestId) { + public CertificateOperationInner withRequestId(String requestId) { this.requestId = requestId; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificatePolicyInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificatePolicyInner.java index d902c912330d5..91742463041db 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificatePolicyInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificatePolicyInner.java @@ -79,7 +79,7 @@ public KeyProperties keyProperties() { * @param keyProperties the keyProperties value to set * @return the CertificatePolicyInner object itself. */ - public CertificatePolicyInner setKeyProperties(KeyProperties keyProperties) { + public CertificatePolicyInner withKeyProperties(KeyProperties keyProperties) { this.keyProperties = keyProperties; return this; } @@ -99,7 +99,7 @@ public SecretProperties secretProperties() { * @param secretProperties the secretProperties value to set * @return the CertificatePolicyInner object itself. */ - public CertificatePolicyInner setSecretProperties(SecretProperties secretProperties) { + public CertificatePolicyInner withSecretProperties(SecretProperties secretProperties) { this.secretProperties = secretProperties; return this; } @@ -119,7 +119,7 @@ public X509CertificateProperties x509CertificateProperties() { * @param x509CertificateProperties the x509CertificateProperties value to set * @return the CertificatePolicyInner object itself. */ - public CertificatePolicyInner setX509CertificateProperties(X509CertificateProperties x509CertificateProperties) { + public CertificatePolicyInner withX509CertificateProperties(X509CertificateProperties x509CertificateProperties) { this.x509CertificateProperties = x509CertificateProperties; return this; } @@ -139,7 +139,7 @@ public List lifetimeActions() { * @param lifetimeActions the lifetimeActions value to set * @return the CertificatePolicyInner object itself. */ - public CertificatePolicyInner setLifetimeActions(List lifetimeActions) { + public CertificatePolicyInner withLifetimeActions(List lifetimeActions) { this.lifetimeActions = lifetimeActions; return this; } @@ -159,7 +159,7 @@ public IssuerReference issuerReference() { * @param issuerReference the issuerReference value to set * @return the CertificatePolicyInner object itself. */ - public CertificatePolicyInner setIssuerReference(IssuerReference issuerReference) { + public CertificatePolicyInner withIssuerReference(IssuerReference issuerReference) { this.issuerReference = issuerReference; return this; } @@ -179,7 +179,7 @@ public CertificateAttributesInner attributes() { * @param attributes the attributes value to set * @return the CertificatePolicyInner object itself. */ - public CertificatePolicyInner setAttributes(CertificateAttributesInner attributes) { + public CertificatePolicyInner withAttributes(CertificateAttributesInner attributes) { this.attributes = attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateUpdateParameters.java index 7033fb481350d..eb0510a6a7edf 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateUpdateParameters.java @@ -39,7 +39,7 @@ public CertificateAttributesInner certificateAttributes() { * @param certificateAttributes the certificateAttributes value to set * @return the CertificateUpdateParameters object itself. */ - public CertificateUpdateParameters setCertificateAttributes(CertificateAttributesInner certificateAttributes) { + public CertificateUpdateParameters withCertificateAttributes(CertificateAttributesInner certificateAttributes) { this.certificateAttributes = certificateAttributes; return this; } @@ -59,7 +59,7 @@ public Map tags() { * @param tags the tags value to set * @return the CertificateUpdateParameters object itself. */ - public CertificateUpdateParameters setTags(Map tags) { + public CertificateUpdateParameters withTags(Map tags) { this.tags = tags; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Contact.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Contact.java index 5b3ef8276d400..ea02c39ea4c66 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Contact.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Contact.java @@ -43,7 +43,7 @@ public String emailAddress() { * @param emailAddress the emailAddress value to set * @return the Contact object itself. */ - public Contact setEmailAddress(String emailAddress) { + public Contact withEmailAddress(String emailAddress) { this.emailAddress = emailAddress; return this; } @@ -63,7 +63,7 @@ public String name() { * @param name the name value to set * @return the Contact object itself. */ - public Contact setName(String name) { + public Contact withName(String name) { this.name = name; return this; } @@ -83,7 +83,7 @@ public String phone() { * @param phone the phone value to set * @return the Contact object itself. */ - public Contact setPhone(String phone) { + public Contact withPhone(String phone) { this.phone = phone; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/ContactsInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/ContactsInner.java index 2d329cc4c249a..ec8e80710ab0d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/ContactsInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/ContactsInner.java @@ -49,7 +49,7 @@ public List contactList() { * @param contactList the contactList value to set * @return the ContactsInner object itself. */ - public ContactsInner setContactList(List contactList) { + public ContactsInner withContactList(List contactList) { this.contactList = contactList; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Error.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Error.java new file mode 100644 index 0000000000000..63c6990b2b734 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Error.java @@ -0,0 +1,45 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation.api; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The Error model. + */ +public class Error { + /** + * The code property. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String code; + + /** + * The message property. + */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private String message; + + /** + * Get the code value. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerAttributes.java index 7c45207e64ff3..3b8ad409a218c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerAttributes.java @@ -44,7 +44,7 @@ public Boolean enabled() { * @param enabled the enabled value to set * @return the IssuerAttributes object itself. */ - public IssuerAttributes setEnabled(Boolean enabled) { + public IssuerAttributes withEnabled(Boolean enabled) { this.enabled = enabled; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerBundleInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerBundleInner.java index 3ecc36659a564..965eecb4a74fa 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerBundleInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerBundleInner.java @@ -63,7 +63,7 @@ public String provider() { * @param provider the provider value to set * @return the IssuerBundleInner object itself. */ - public IssuerBundleInner setProvider(String provider) { + public IssuerBundleInner withProvider(String provider) { this.provider = provider; return this; } @@ -83,7 +83,7 @@ public IssuerCredentials credentials() { * @param credentials the credentials value to set * @return the IssuerBundleInner object itself. */ - public IssuerBundleInner setCredentials(IssuerCredentials credentials) { + public IssuerBundleInner withCredentials(IssuerCredentials credentials) { this.credentials = credentials; return this; } @@ -103,7 +103,7 @@ public OrganizationDetails organizationDetails() { * @param organizationDetails the organizationDetails value to set * @return the IssuerBundleInner object itself. */ - public IssuerBundleInner setOrganizationDetails(OrganizationDetails organizationDetails) { + public IssuerBundleInner withOrganizationDetails(OrganizationDetails organizationDetails) { this.organizationDetails = organizationDetails; return this; } @@ -123,7 +123,7 @@ public IssuerAttributes attributes() { * @param attributes the attributes value to set * @return the IssuerBundleInner object itself. */ - public IssuerBundleInner setAttributes(IssuerAttributes attributes) { + public IssuerBundleInner withAttributes(IssuerAttributes attributes) { this.attributes = attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerCredentials.java index 8215222ddcd6c..63fa5e8a56104 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerCredentials.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerCredentials.java @@ -39,7 +39,7 @@ public String accountId() { * @param accountId the accountId value to set * @return the IssuerCredentials object itself. */ - public IssuerCredentials setAccountId(String accountId) { + public IssuerCredentials withAccountId(String accountId) { this.accountId = accountId; return this; } @@ -59,7 +59,7 @@ public String password() { * @param password the password value to set * @return the IssuerCredentials object itself. */ - public IssuerCredentials setPassword(String password) { + public IssuerCredentials withPassword(String password) { this.password = password; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerReference.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerReference.java index 6731f92c97a3b..ffe58ead3d1fd 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerReference.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerReference.java @@ -31,7 +31,7 @@ public String name() { * @param name the name value to set * @return the IssuerReference object itself. */ - public IssuerReference setName(String name) { + public IssuerReference withName(String name) { this.name = name; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/JsonWebKeyInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/JsonWebKeyInner.java index bae3e57a8feda..9e7d28f008142 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/JsonWebKeyInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/JsonWebKeyInner.java @@ -95,7 +95,7 @@ public String kid() { * @param kid the kid value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setKid(String kid) { + public JsonWebKeyInner withKid(String kid) { this.kid = kid; return this; } @@ -115,7 +115,7 @@ public String kty() { * @param kty the kty value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setKty(String kty) { + public JsonWebKeyInner withKty(String kty) { this.kty = kty; return this; } @@ -135,7 +135,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setKeyOps(List keyOps) { + public JsonWebKeyInner withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } @@ -155,7 +155,7 @@ public String n() { * @param n the n value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setN(String n) { + public JsonWebKeyInner withN(String n) { this.n = n; return this; } @@ -175,7 +175,7 @@ public String e() { * @param e the e value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setE(String e) { + public JsonWebKeyInner withE(String e) { this.e = e; return this; } @@ -195,7 +195,7 @@ public String d() { * @param d the d value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setD(String d) { + public JsonWebKeyInner withD(String d) { this.d = d; return this; } @@ -215,7 +215,7 @@ public String dp() { * @param dp the dp value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setDp(String dp) { + public JsonWebKeyInner withDp(String dp) { this.dp = dp; return this; } @@ -235,7 +235,7 @@ public String dq() { * @param dq the dq value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setDq(String dq) { + public JsonWebKeyInner withDq(String dq) { this.dq = dq; return this; } @@ -255,7 +255,7 @@ public String qi() { * @param qi the qi value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setQi(String qi) { + public JsonWebKeyInner withQi(String qi) { this.qi = qi; return this; } @@ -275,7 +275,7 @@ public String p() { * @param p the p value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setP(String p) { + public JsonWebKeyInner withP(String p) { this.p = p; return this; } @@ -295,7 +295,7 @@ public String q() { * @param q the q value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setQ(String q) { + public JsonWebKeyInner withQ(String q) { this.q = q; return this; } @@ -315,7 +315,7 @@ public String k() { * @param k the k value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setK(String k) { + public JsonWebKeyInner withK(String k) { this.k = k; return this; } @@ -335,7 +335,7 @@ public String t() { * @param t the t value to set * @return the JsonWebKeyInner object itself. */ - public JsonWebKeyInner setT(String t) { + public JsonWebKeyInner withT(String t) { this.t = t; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyBundleInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyBundleInner.java index ec29f7dad6d04..766e84baf74ba 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyBundleInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyBundleInner.java @@ -42,7 +42,7 @@ public JsonWebKeyInner key() { * @param key the key value to set * @return the KeyBundleInner object itself. */ - public KeyBundleInner setKey(JsonWebKeyInner key) { + public KeyBundleInner withKey(JsonWebKeyInner key) { this.key = key; return this; } @@ -62,7 +62,7 @@ public KeyAttributesInner attributes() { * @param attributes the attributes value to set * @return the KeyBundleInner object itself. */ - public KeyBundleInner setAttributes(KeyAttributesInner attributes) { + public KeyBundleInner withAttributes(KeyAttributesInner attributes) { this.attributes = attributes; return this; } @@ -82,7 +82,7 @@ public Map tags() { * @param tags the tags value to set * @return the KeyBundleInner object itself. */ - public KeyBundleInner setTags(Map tags) { + public KeyBundleInner withTags(Map tags) { this.tags = tags; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyCreateParameters.java index a454d9848720b..1920720f3fc82 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyCreateParameters.java @@ -58,7 +58,7 @@ public String kty() { * @param kty the kty value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters setKty(String kty) { + public KeyCreateParameters withKty(String kty) { this.kty = kty; return this; } @@ -78,7 +78,7 @@ public Integer keySize() { * @param keySize the keySize value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters setKeySize(Integer keySize) { + public KeyCreateParameters withKeySize(Integer keySize) { this.keySize = keySize; return this; } @@ -98,7 +98,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters setKeyOps(List keyOps) { + public KeyCreateParameters withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } @@ -118,7 +118,7 @@ public KeyAttributesInner keyAttributes() { * @param keyAttributes the keyAttributes value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters setKeyAttributes(KeyAttributesInner keyAttributes) { + public KeyCreateParameters withKeyAttributes(KeyAttributesInner keyAttributes) { this.keyAttributes = keyAttributes; return this; } @@ -138,7 +138,7 @@ public Map tags() { * @param tags the tags value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters setTags(Map tags) { + public KeyCreateParameters withTags(Map tags) { this.tags = tags; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyImportParameters.java index 3c30878317d07..cfa7bcf1b718b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyImportParameters.java @@ -51,7 +51,7 @@ public Boolean hsm() { * @param hsm the hsm value to set * @return the KeyImportParameters object itself. */ - public KeyImportParameters setHsm(Boolean hsm) { + public KeyImportParameters withHsm(Boolean hsm) { this.hsm = hsm; return this; } @@ -71,7 +71,7 @@ public JsonWebKeyInner key() { * @param key the key value to set * @return the KeyImportParameters object itself. */ - public KeyImportParameters setKey(JsonWebKeyInner key) { + public KeyImportParameters withKey(JsonWebKeyInner key) { this.key = key; return this; } @@ -91,7 +91,7 @@ public KeyAttributesInner keyAttributes() { * @param keyAttributes the keyAttributes value to set * @return the KeyImportParameters object itself. */ - public KeyImportParameters setKeyAttributes(KeyAttributesInner keyAttributes) { + public KeyImportParameters withKeyAttributes(KeyAttributesInner keyAttributes) { this.keyAttributes = keyAttributes; return this; } @@ -111,7 +111,7 @@ public Map tags() { * @param tags the tags value to set * @return the KeyImportParameters object itself. */ - public KeyImportParameters setTags(Map tags) { + public KeyImportParameters withTags(Map tags) { this.tags = tags; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyItemInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyItemInner.java index 9ebf7c6ab2e5b..29c682ec434d6 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyItemInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyItemInner.java @@ -42,7 +42,7 @@ public String kid() { * @param kid the kid value to set * @return the KeyItemInner object itself. */ - public KeyItemInner setKid(String kid) { + public KeyItemInner withKid(String kid) { this.kid = kid; return this; } @@ -62,7 +62,7 @@ public KeyAttributesInner attributes() { * @param attributes the attributes value to set * @return the KeyItemInner object itself. */ - public KeyItemInner setAttributes(KeyAttributesInner attributes) { + public KeyItemInner withAttributes(KeyAttributesInner attributes) { this.attributes = attributes; return this; } @@ -82,7 +82,7 @@ public Map tags() { * @param tags the tags value to set * @return the KeyItemInner object itself. */ - public KeyItemInner setTags(Map tags) { + public KeyItemInner withTags(Map tags) { this.tags = tags; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationsParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationsParameters.java index 38f218a0844c8..4904582f1f333 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationsParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationsParameters.java @@ -39,7 +39,7 @@ public String algorithm() { * @param algorithm the algorithm value to set * @return the KeyOperationsParameters object itself. */ - public KeyOperationsParameters setAlgorithm(String algorithm) { + public KeyOperationsParameters withAlgorithm(String algorithm) { this.algorithm = algorithm; return this; } @@ -59,7 +59,7 @@ public String value() { * @param value the value value to set * @return the KeyOperationsParameters object itself. */ - public KeyOperationsParameters setValue(String value) { + public KeyOperationsParameters withValue(String value) { this.value = value; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyProperties.java index 6534c1c89462e..c10ecb32bcf27 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyProperties.java @@ -49,7 +49,7 @@ public Boolean exportable() { * @param exportable the exportable value to set * @return the KeyProperties object itself. */ - public KeyProperties setExportable(Boolean exportable) { + public KeyProperties withExportable(Boolean exportable) { this.exportable = exportable; return this; } @@ -69,7 +69,7 @@ public String kty() { * @param kty the kty value to set * @return the KeyProperties object itself. */ - public KeyProperties setKty(String kty) { + public KeyProperties withKty(String kty) { this.kty = kty; return this; } @@ -89,7 +89,7 @@ public Integer keySize() { * @param keySize the keySize value to set * @return the KeyProperties object itself. */ - public KeyProperties setKeySize(Integer keySize) { + public KeyProperties withKeySize(Integer keySize) { this.keySize = keySize; return this; } @@ -109,7 +109,7 @@ public Boolean reuseKey() { * @param reuseKey the reuseKey value to set * @return the KeyProperties object itself. */ - public KeyProperties setReuseKey(Boolean reuseKey) { + public KeyProperties withReuseKey(Boolean reuseKey) { this.reuseKey = reuseKey; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyRestoreParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyRestoreParameters.java index 0baf0b3eac1a8..921b368c43f84 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyRestoreParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyRestoreParameters.java @@ -33,7 +33,7 @@ public String keyBundleBackup() { * @param keyBundleBackup the keyBundleBackup value to set * @return the KeyRestoreParameters object itself. */ - public KeyRestoreParameters setKeyBundleBackup(String keyBundleBackup) { + public KeyRestoreParameters withKeyBundleBackup(String keyBundleBackup) { this.keyBundleBackup = keyBundleBackup; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyUpdateParameters.java index 152e463fc8a0d..9466ee100573d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyUpdateParameters.java @@ -47,7 +47,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the KeyUpdateParameters object itself. */ - public KeyUpdateParameters setKeyOps(List keyOps) { + public KeyUpdateParameters withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } @@ -67,7 +67,7 @@ public KeyAttributesInner keyAttributes() { * @param keyAttributes the keyAttributes value to set * @return the KeyUpdateParameters object itself. */ - public KeyUpdateParameters setKeyAttributes(KeyAttributesInner keyAttributes) { + public KeyUpdateParameters withKeyAttributes(KeyAttributesInner keyAttributes) { this.keyAttributes = keyAttributes; return this; } @@ -87,7 +87,7 @@ public Map tags() { * @param tags the tags value to set * @return the KeyUpdateParameters object itself. */ - public KeyUpdateParameters setTags(Map tags) { + public KeyUpdateParameters withTags(Map tags) { this.tags = tags; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultClientImpl.java index dd34a9af8d16e..8e41001831050 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultClientImpl.java @@ -6,6 +6,7 @@ package com.microsoft.azure.keyvault.implementation.api; +import com.google.common.base.Joiner; import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceClient; @@ -16,7 +17,6 @@ import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.RestClient; -import com.microsoft.rest.serializer.CollectionFormat; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -85,9 +85,11 @@ public String acceptLanguage() { * Sets Gets or sets the preferred language for the response. * * @param acceptLanguage the acceptLanguage value. + * @return the service client itself */ - public void setAcceptLanguage(String acceptLanguage) { + public KeyVaultClientImpl withAcceptLanguage(String acceptLanguage) { this.acceptLanguage = acceptLanguage; + return this; } /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ @@ -106,9 +108,11 @@ public int longRunningOperationRetryTimeout() { * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. * * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself */ - public void setLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + public KeyVaultClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; } /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ @@ -127,9 +131,11 @@ public boolean generateClientRequestId() { * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. * * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself */ - public void setGenerateClientRequestId(boolean generateClientRequestId) { + public KeyVaultClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { this.generateClientRequestId = generateClientRequestId; + return this; } /** @@ -196,171 +202,171 @@ private void initializeService() { interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/create") - Call createKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCreateParameters parameters, @Header("User-Agent") String userAgent); + Call createKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("keys/{key-name}") - Call importKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyImportParameters parameters, @Header("User-Agent") String userAgent); + Call importKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "keys/{key-name}", method = "DELETE", hasBody = true) - Call deleteKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call deleteKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("keys/{key-name}/{key-version}") - Call updateKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyUpdateParameters parameters, @Header("User-Agent") String userAgent); + Call updateKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys/{key-name}/{key-version}") - Call getKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys/{key-name}/versions") - Call getKeyVersions(@Path("key-name") String keyName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getKeyVersions(@Path("key-name") String keyName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys") - Call getKeys(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getKeys(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/backup") - Call backupKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call backupKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/restore") - Call restoreKey(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyRestoreParameters parameters, @Header("User-Agent") String userAgent); + Call restoreKey(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyRestoreParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/encrypt") - Call encrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("User-Agent") String userAgent); + Call encrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/decrypt") - Call decrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("User-Agent") String userAgent); + Call decrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/sign") - Call sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("User-Agent") String userAgent); + Call sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/verify") - Call verify(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyVerifyParameters parameters, @Header("User-Agent") String userAgent); + Call verify(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyVerifyParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/wrapkey") - Call wrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("User-Agent") String userAgent); + Call wrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/unwrapkey") - Call unwrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("User-Agent") String userAgent); + Call unwrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("secrets/{secret-name}") - Call setSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretSetParameters parameters, @Header("User-Agent") String userAgent); + Call setSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretSetParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "secrets/{secret-name}", method = "DELETE", hasBody = true) - Call deleteSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call deleteSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("secrets/{secret-name}/{secret-version}") - Call updateSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretUpdateParameters parameters, @Header("User-Agent") String userAgent); + Call updateSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets/{secret-name}/{secret-version}") - Call getSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets") - Call getSecrets(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getSecrets(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets/{secret-name}/versions") - Call getSecretVersions(@Path("secret-name") String secretName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getSecretVersions(@Path("secret-name") String secretName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates") - Call getCertificates(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getCertificates(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/{certificate-name}", method = "DELETE", hasBody = true) - Call deleteCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call deleteCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/contacts") - Call setCertificateContacts(@Body ContactsInner contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call setCertificateContacts(@Body ContactsInner contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/contacts") - Call getCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/contacts", method = "DELETE", hasBody = true) - Call deleteCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call deleteCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers") - Call getCertificateIssuers(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getCertificateIssuers(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/issuers/{issuer-name}") - Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundleInner issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundleInner issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/issuers/{issuer-name}") - Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundleInner issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundleInner issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers/{issuer-name}") - Call getCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/issuers/{issuer-name}", method = "DELETE", hasBody = true) - Call deleteCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call deleteCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/create") - Call createCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateCreateParameters parameters, @Header("User-Agent") String userAgent); + Call createCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/import") - Call importCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateImportParameters parameters, @Header("User-Agent") String userAgent); + Call importCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/versions") - Call getCertificateVersions(@Path("certificate-name") String certificateName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getCertificateVersions(@Path("certificate-name") String certificateName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/policy") - Call getCertificatePolicy(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getCertificatePolicy(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/policy") - Call updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicyInner certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicyInner certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/{certificate-version}") - Call updateCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateUpdateParameters parameters, @Header("User-Agent") String userAgent); + Call updateCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/{certificate-version}") - Call getCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/pending") - Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Body CertificateOperationInner certificateOperation, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Body CertificateOperationInner certificateOperation, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/pending") - Call getCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call getCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/{certificate-name}/pending", method = "DELETE", hasBody = true) - Call deleteCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Call deleteCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/pending/merge") - Call mergeCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateMergeParameters parameters, @Header("User-Agent") String userAgent); + Call mergeCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateMergeParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET @@ -417,17 +423,17 @@ public ServiceResponse createKey(String vaultBaseUrl, String key throw new IllegalArgumentException("Parameter kty is required and cannot be null."); } final Integer keySize = null; - final String keyOpsConverted = null; + final List keyOps = null; final KeyAttributesInner keyAttributes = null; final Map tags = null; KeyCreateParameters parameters = new KeyCreateParameters(); - parameters.setKty(kty); - parameters.setKeySize(null); - parameters.setKeyOps(null); - parameters.setKeyAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withKty(kty); + parameters.withKeySize(null); + parameters.withKeyOps(null); + parameters.withKeyAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return createKeyDelegate(call.execute()); } @@ -462,17 +468,17 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kt return null; } final Integer keySize = null; - final String keyOpsConverted = null; + final List keyOps = null; final KeyAttributesInner keyAttributes = null; final Map tags = null; KeyCreateParameters parameters = new KeyCreateParameters(); - parameters.setKty(kty); - parameters.setKeySize(null); - parameters.setKeyOps(null); - parameters.setKeyAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withKty(kty); + parameters.withKeySize(null); + parameters.withKeyOps(null); + parameters.withKeyAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -519,13 +525,13 @@ public ServiceResponse createKey(String vaultBaseUrl, String key Validator.validate(keyAttributes); Validator.validate(tags); KeyCreateParameters parameters = new KeyCreateParameters(); - parameters.setKty(kty); - parameters.setKeySize(keySize); - parameters.setKeyOps(keyOps); - parameters.setKeyAttributes(keyAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withKty(kty); + parameters.withKeySize(keySize); + parameters.withKeyOps(keyOps); + parameters.withKeyAttributes(keyAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return createKeyDelegate(call.execute()); } @@ -567,13 +573,13 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kt Validator.validate(keyAttributes, serviceCallback); Validator.validate(tags, serviceCallback); KeyCreateParameters parameters = new KeyCreateParameters(); - parameters.setKty(kty); - parameters.setKeySize(keySize); - parameters.setKeyOps(keyOps); - parameters.setKeyAttributes(keyAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withKty(kty); + parameters.withKeySize(keySize); + parameters.withKeyOps(keyOps); + parameters.withKeyAttributes(keyAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -624,12 +630,12 @@ public ServiceResponse importKey(String vaultBaseUrl, String key final KeyAttributesInner keyAttributes = null; final Map tags = null; KeyImportParameters parameters = new KeyImportParameters(); - parameters.setHsm(null); - parameters.setKey(key); - parameters.setKeyAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withHsm(null); + parameters.withKey(key); + parameters.withKeyAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return importKeyDelegate(call.execute()); } @@ -668,12 +674,12 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKe final KeyAttributesInner keyAttributes = null; final Map tags = null; KeyImportParameters parameters = new KeyImportParameters(); - parameters.setHsm(null); - parameters.setKey(key); - parameters.setKeyAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withHsm(null); + parameters.withKey(key); + parameters.withKeyAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -719,12 +725,12 @@ public ServiceResponse importKey(String vaultBaseUrl, String key Validator.validate(keyAttributes); Validator.validate(tags); KeyImportParameters parameters = new KeyImportParameters(); - parameters.setHsm(hsm); - parameters.setKey(key); - parameters.setKeyAttributes(keyAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withHsm(hsm); + parameters.withKey(key); + parameters.withKeyAttributes(keyAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return importKeyDelegate(call.execute()); } @@ -765,12 +771,12 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKe Validator.validate(keyAttributes, serviceCallback); Validator.validate(tags, serviceCallback); KeyImportParameters parameters = new KeyImportParameters(); - parameters.setHsm(hsm); - parameters.setKey(key); - parameters.setKeyAttributes(keyAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withHsm(hsm); + parameters.withKey(key); + parameters.withKeyAttributes(keyAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -812,8 +818,8 @@ public ServiceResponse deleteKey(String vaultBaseUrl, String key if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return deleteKeyDelegate(call.execute()); } @@ -842,8 +848,8 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final Ser serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -889,15 +895,15 @@ public ServiceResponse updateKey(String vaultBaseUrl, String key if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - final String keyOpsConverted = null; + final List keyOps = null; final KeyAttributesInner keyAttributes = null; final Map tags = null; KeyUpdateParameters parameters = new KeyUpdateParameters(); - parameters.setKeyOps(null); - parameters.setKeyAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withKeyOps(null); + parameters.withKeyAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return updateKeyDelegate(call.execute()); } @@ -931,15 +937,15 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String ke serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - final String keyOpsConverted = null; + final List keyOps = null; final KeyAttributesInner keyAttributes = null; final Map tags = null; KeyUpdateParameters parameters = new KeyUpdateParameters(); - parameters.setKeyOps(null); - parameters.setKeyAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withKeyOps(null); + parameters.withKeyAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -985,11 +991,11 @@ public ServiceResponse updateKey(String vaultBaseUrl, String key Validator.validate(keyAttributes); Validator.validate(tags); KeyUpdateParameters parameters = new KeyUpdateParameters(); - parameters.setKeyOps(keyOps); - parameters.setKeyAttributes(keyAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withKeyOps(keyOps); + parameters.withKeyAttributes(keyAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return updateKeyDelegate(call.execute()); } @@ -1030,11 +1036,11 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String ke Validator.validate(keyAttributes, serviceCallback); Validator.validate(tags, serviceCallback); KeyUpdateParameters parameters = new KeyUpdateParameters(); - parameters.setKeyOps(keyOps); - parameters.setKeyAttributes(keyAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withKeyOps(keyOps); + parameters.withKeyAttributes(keyAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -1080,8 +1086,8 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyNam if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return getKeyDelegate(call.execute()); } @@ -1115,8 +1121,8 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVe serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -1159,8 +1165,8 @@ public ServiceResponse> getKeyVersions(final String vaul throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getKeyVersionsDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -1197,8 +1203,8 @@ public ServiceCall getKeyVersionsAsync(final String vaultBaseUrl, final String k return null; } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -1241,8 +1247,8 @@ public ServiceResponse> getKeyVersions(final String vaul if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getKeyVersionsDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -1279,8 +1285,8 @@ public ServiceCall getKeyVersionsAsync(final String vaultBaseUrl, final String k serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -1326,8 +1332,8 @@ public ServiceResponse> getKeys(final String vaultBaseUr throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getKeysDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -1359,8 +1365,8 @@ public ServiceCall getKeysAsync(final String vaultBaseUrl, final ListOperationCa return null; } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -1399,8 +1405,8 @@ public ServiceResponse> getKeys(final String vaultBaseUr if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getKeysDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -1432,8 +1438,8 @@ public ServiceCall getKeysAsync(final String vaultBaseUrl, final Integer maxresu serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -1482,8 +1488,8 @@ public ServiceResponse backupKey(String vaultBaseUrl, Stri if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return backupKeyDelegate(call.execute()); } @@ -1512,8 +1518,8 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final Ser serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -1556,9 +1562,9 @@ public ServiceResponse restoreKey(String vaultBaseUrl, String ke throw new IllegalArgumentException("Parameter keyBundleBackup is required and cannot be null."); } KeyRestoreParameters parameters = new KeyRestoreParameters(); - parameters.setKeyBundleBackup(keyBundleBackup); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withKeyBundleBackup(keyBundleBackup); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return restoreKeyDelegate(call.execute()); } @@ -1588,9 +1594,9 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, String keyBundleBackup, return null; } KeyRestoreParameters parameters = new KeyRestoreParameters(); - parameters.setKeyBundleBackup(keyBundleBackup); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withKeyBundleBackup(keyBundleBackup); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -1645,10 +1651,10 @@ public ServiceResponse encrypt(String vaultBaseUrl, Str throw new IllegalArgumentException("Parameter value is required and cannot be null."); } KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return encryptDelegate(call.execute()); } @@ -1693,10 +1699,10 @@ public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyV return null; } KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -1751,10 +1757,10 @@ public ServiceResponse decrypt(String vaultBaseUrl, Str throw new IllegalArgumentException("Parameter value is required and cannot be null."); } KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return decryptDelegate(call.execute()); } @@ -1799,10 +1805,10 @@ public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyV return null; } KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -1857,10 +1863,10 @@ public ServiceResponse sign(String vaultBaseUrl, String throw new IllegalArgumentException("Parameter value is required and cannot be null."); } KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return signDelegate(call.execute()); } @@ -1905,10 +1911,10 @@ public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVers return null; } KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -1967,11 +1973,11 @@ public ServiceResponse verify(String vaultBaseUrl, String throw new IllegalArgumentException("Parameter signature is required and cannot be null."); } KeyVerifyParameters parameters = new KeyVerifyParameters(); - parameters.setAlgorithm(algorithm); - parameters.setDigest(digest); - parameters.setSignature(signature); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withAlgorithm(algorithm); + parameters.withDigest(digest); + parameters.withSignature(signature); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return verifyDelegate(call.execute()); } @@ -2021,11 +2027,11 @@ public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVe return null; } KeyVerifyParameters parameters = new KeyVerifyParameters(); - parameters.setAlgorithm(algorithm); - parameters.setDigest(digest); - parameters.setSignature(signature); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withAlgorithm(algorithm); + parameters.withDigest(digest); + parameters.withSignature(signature); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -2080,10 +2086,10 @@ public ServiceResponse wrapKey(String vaultBaseUrl, Str throw new IllegalArgumentException("Parameter value is required and cannot be null."); } KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return wrapKeyDelegate(call.execute()); } @@ -2128,10 +2134,10 @@ public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyV return null; } KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -2186,10 +2192,10 @@ public ServiceResponse unwrapKey(String vaultBaseUrl, S throw new IllegalArgumentException("Parameter value is required and cannot be null."); } KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return unwrapKeyDelegate(call.execute()); } @@ -2234,10 +2240,10 @@ public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String ke return null; } KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.setAlgorithm(algorithm); - parameters.setValue(value); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -2287,12 +2293,12 @@ public ServiceResponse setSecret(String vaultBaseUrl, String final String contentType = null; final SecretAttributesInner secretAttributes = null; SecretSetParameters parameters = new SecretSetParameters(); - parameters.setValue(value); - parameters.setTags(null); - parameters.setContentType(null); - parameters.setSecretAttributes(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withValue(value); + parameters.withTags(null); + parameters.withContentType(null); + parameters.withSecretAttributes(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return setSecretDelegate(call.execute()); } @@ -2330,12 +2336,12 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String final String contentType = null; final SecretAttributesInner secretAttributes = null; SecretSetParameters parameters = new SecretSetParameters(); - parameters.setValue(value); - parameters.setTags(null); - parameters.setContentType(null); - parameters.setSecretAttributes(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withValue(value); + parameters.withTags(null); + parameters.withContentType(null); + parameters.withSecretAttributes(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -2380,12 +2386,12 @@ public ServiceResponse setSecret(String vaultBaseUrl, String Validator.validate(tags); Validator.validate(secretAttributes); SecretSetParameters parameters = new SecretSetParameters(); - parameters.setValue(value); - parameters.setTags(tags); - parameters.setContentType(contentType); - parameters.setSecretAttributes(secretAttributes); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withValue(value); + parameters.withTags(tags); + parameters.withContentType(contentType); + parameters.withSecretAttributes(secretAttributes); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return setSecretDelegate(call.execute()); } @@ -2425,12 +2431,12 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String Validator.validate(tags, serviceCallback); Validator.validate(secretAttributes, serviceCallback); SecretSetParameters parameters = new SecretSetParameters(); - parameters.setValue(value); - parameters.setTags(tags); - parameters.setContentType(contentType); - parameters.setSecretAttributes(secretAttributes); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withValue(value); + parameters.withTags(tags); + parameters.withContentType(contentType); + parameters.withSecretAttributes(secretAttributes); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -2472,8 +2478,8 @@ public ServiceResponse deleteSecret(String vaultBaseUrl, Stri if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return deleteSecretDelegate(call.execute()); } @@ -2502,8 +2508,8 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, fin serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -2553,11 +2559,11 @@ public ServiceResponse updateSecret(String vaultBaseUrl, Stri final SecretAttributesInner secretAttributes = null; final Map tags = null; SecretUpdateParameters parameters = new SecretUpdateParameters(); - parameters.setContentType(null); - parameters.setSecretAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withContentType(null); + parameters.withSecretAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return updateSecretDelegate(call.execute()); } @@ -2595,11 +2601,11 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, Str final SecretAttributesInner secretAttributes = null; final Map tags = null; SecretUpdateParameters parameters = new SecretUpdateParameters(); - parameters.setContentType(null); - parameters.setSecretAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withContentType(null); + parameters.withSecretAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -2644,11 +2650,11 @@ public ServiceResponse updateSecret(String vaultBaseUrl, Stri Validator.validate(secretAttributes); Validator.validate(tags); SecretUpdateParameters parameters = new SecretUpdateParameters(); - parameters.setContentType(contentType); - parameters.setSecretAttributes(secretAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withContentType(contentType); + parameters.withSecretAttributes(secretAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return updateSecretDelegate(call.execute()); } @@ -2688,11 +2694,11 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, Str Validator.validate(secretAttributes, serviceCallback); Validator.validate(tags, serviceCallback); SecretUpdateParameters parameters = new SecretUpdateParameters(); - parameters.setContentType(contentType); - parameters.setSecretAttributes(secretAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withContentType(contentType); + parameters.withSecretAttributes(secretAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -2738,8 +2744,8 @@ public ServiceResponse getSecret(String vaultBaseUrl, String if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return getSecretDelegate(call.execute()); } @@ -2773,8 +2779,8 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -2813,8 +2819,8 @@ public ServiceResponse> getSecrets(final String vault throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getSecretsDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -2846,8 +2852,8 @@ public ServiceCall getSecretsAsync(final String vaultBaseUrl, final ListOperatio return null; } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -2886,8 +2892,8 @@ public ServiceResponse> getSecrets(final String vault if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getSecretsDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -2919,8 +2925,8 @@ public ServiceCall getSecretsAsync(final String vaultBaseUrl, final Integer maxr serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -2970,8 +2976,8 @@ public ServiceResponse> getSecretVersions(final Strin throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getSecretVersionsDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -3008,8 +3014,8 @@ public ServiceCall getSecretVersionsAsync(final String vaultBaseUrl, final Strin return null; } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -3052,8 +3058,8 @@ public ServiceResponse> getSecretVersions(final Strin if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getSecretVersionsDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -3090,8 +3096,8 @@ public ServiceCall getSecretVersionsAsync(final String vaultBaseUrl, final Strin serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -3137,8 +3143,8 @@ public ServiceResponse> getCertificates(final St throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getCertificatesDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -3170,8 +3176,8 @@ public ServiceCall getCertificatesAsync(final String vaultBaseUrl, final ListOpe return null; } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -3210,8 +3216,8 @@ public ServiceResponse> getCertificates(final St if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getCertificatesDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -3243,8 +3249,8 @@ public ServiceCall getCertificatesAsync(final String vaultBaseUrl, final Integer serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -3293,8 +3299,8 @@ public ServiceResponse deleteCertificate(String vaultBas if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return deleteCertificateDelegate(call.execute()); } @@ -3323,8 +3329,8 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificat serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -3367,8 +3373,8 @@ public ServiceResponse setCertificateContacts(String vaultBaseUrl throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } Validator.validate(contacts); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return setCertificateContactsDelegate(call.execute()); } @@ -3398,8 +3404,8 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, ContactsInne return null; } Validator.validate(contacts, serviceCallback); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -3437,8 +3443,8 @@ public ServiceResponse getCertificateContacts(String vaultBaseUrl if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return getCertificateContactsDelegate(call.execute()); } @@ -3462,8 +3468,8 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final Servic serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -3501,8 +3507,8 @@ public ServiceResponse deleteCertificateContacts(String vaultBase if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return deleteCertificateContactsDelegate(call.execute()); } @@ -3526,8 +3532,8 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final Ser serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -3566,8 +3572,8 @@ public ServiceResponse> getCertificateIssu throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -3599,8 +3605,8 @@ public ServiceCall getCertificateIssuersAsync(final String vaultBaseUrl, final L return null; } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -3639,8 +3645,8 @@ public ServiceResponse> getCertificateIssu if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -3672,8 +3678,8 @@ public ServiceCall getCertificateIssuersAsync(final String vaultBaseUrl, final I serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -3727,8 +3733,8 @@ public ServiceResponse setCertificateIssuer(String vaultBaseU throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } Validator.validate(issuer); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return setCertificateIssuerDelegate(call.execute()); } @@ -3763,8 +3769,8 @@ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerN return null; } Validator.validate(issuer, serviceCallback); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -3811,8 +3817,8 @@ public ServiceResponse updateCertificateIssuer(String vaultBa throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } Validator.validate(issuer); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return updateCertificateIssuerDelegate(call.execute()); } @@ -3847,8 +3853,8 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issu return null; } Validator.validate(issuer, serviceCallback); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -3890,8 +3896,8 @@ public ServiceResponse getCertificateIssuer(String vaultBaseU if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return getCertificateIssuerDelegate(call.execute()); } @@ -3920,8 +3926,8 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerN serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -3963,8 +3969,8 @@ public ServiceResponse deleteCertificateIssuer(String vaultBa if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return deleteCertificateIssuerDelegate(call.execute()); } @@ -3993,8 +3999,8 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issu serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -4044,11 +4050,11 @@ public ServiceResponse createCertificate(String vault final CertificateAttributesInner certificateAttributes = null; final Map tags = null; CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificateAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return createCertificateDelegate(call.execute()); } @@ -4086,11 +4092,11 @@ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificat final CertificateAttributesInner certificateAttributes = null; final Map tags = null; CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificateAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -4135,11 +4141,11 @@ public ServiceResponse createCertificate(String vault Validator.validate(certificateAttributes); Validator.validate(tags); CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificateAttributes(certificateAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return createCertificateDelegate(call.execute()); } @@ -4179,11 +4185,11 @@ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificat Validator.validate(certificateAttributes, serviceCallback); Validator.validate(tags, serviceCallback); CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificateAttributes(certificateAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -4241,13 +4247,13 @@ public ServiceResponse importCertificate(String vaultBas final CertificateAttributesInner certificateAttributes = null; final Map tags = null; CertificateImportParameters parameters = new CertificateImportParameters(); - parameters.setBase64EncodedCertificate(base64EncodedCertificate); - parameters.setPassword(password); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withBase64EncodedCertificate(base64EncodedCertificate); + parameters.withPassword(password); + parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificateAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return importCertificateDelegate(call.execute()); } @@ -4295,13 +4301,13 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificat final CertificateAttributesInner certificateAttributes = null; final Map tags = null; CertificateImportParameters parameters = new CertificateImportParameters(); - parameters.setBase64EncodedCertificate(base64EncodedCertificate); - parameters.setPassword(password); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withBase64EncodedCertificate(base64EncodedCertificate); + parameters.withPassword(password); + parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificateAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -4354,13 +4360,13 @@ public ServiceResponse importCertificate(String vaultBas Validator.validate(certificateAttributes); Validator.validate(tags); CertificateImportParameters parameters = new CertificateImportParameters(); - parameters.setBase64EncodedCertificate(base64EncodedCertificate); - parameters.setPassword(password); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withBase64EncodedCertificate(base64EncodedCertificate); + parameters.withPassword(password); + parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificateAttributes(certificateAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return importCertificateDelegate(call.execute()); } @@ -4410,13 +4416,13 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificat Validator.validate(certificateAttributes, serviceCallback); Validator.validate(tags, serviceCallback); CertificateImportParameters parameters = new CertificateImportParameters(); - parameters.setBase64EncodedCertificate(base64EncodedCertificate); - parameters.setPassword(password); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withBase64EncodedCertificate(base64EncodedCertificate); + parameters.withPassword(password); + parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificateAttributes(certificateAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -4459,8 +4465,8 @@ public ServiceResponse> getCertificateVersions(f throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -4497,8 +4503,8 @@ public ServiceCall getCertificateVersionsAsync(final String vaultBaseUrl, final return null; } final Integer maxresults = null; - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -4541,8 +4547,8 @@ public ServiceResponse> getCertificateVersions(f if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); PagedList result = new PagedList(response.getBody()) { @Override @@ -4579,8 +4585,8 @@ public ServiceCall getCertificateVersionsAsync(final String vaultBaseUrl, final serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override @@ -4629,8 +4635,8 @@ public ServiceResponse getCertificatePolicy(String vault if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return getCertificatePolicyDelegate(call.execute()); } @@ -4659,8 +4665,8 @@ public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certifi serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -4707,8 +4713,8 @@ public ServiceResponse updateCertificatePolicy(String va throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } Validator.validate(certificatePolicy); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return updateCertificatePolicyDelegate(call.execute()); } @@ -4743,8 +4749,8 @@ public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String cert return null; } Validator.validate(certificatePolicy, serviceCallback); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -4793,10 +4799,10 @@ public ServiceResponse updateCertificate(String vaultBas final CertificateAttributesInner certificateAttributes = null; final Map tags = null; CertificateUpdateParameters parameters = new CertificateUpdateParameters(); - parameters.setCertificateAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withCertificateAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return updateCertificateDelegate(call.execute()); } @@ -4833,10 +4839,10 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificat final CertificateAttributesInner certificateAttributes = null; final Map tags = null; CertificateUpdateParameters parameters = new CertificateUpdateParameters(); - parameters.setCertificateAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withCertificateAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -4880,10 +4886,10 @@ public ServiceResponse updateCertificate(String vaultBas Validator.validate(certificateAttributes); Validator.validate(tags); CertificateUpdateParameters parameters = new CertificateUpdateParameters(); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withCertificateAttributes(certificateAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return updateCertificateDelegate(call.execute()); } @@ -4922,10 +4928,10 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificat Validator.validate(certificateAttributes, serviceCallback); Validator.validate(tags, serviceCallback); CertificateUpdateParameters parameters = new CertificateUpdateParameters(); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withCertificateAttributes(certificateAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -4971,8 +4977,8 @@ public ServiceResponse getCertificate(String vaultBaseUr if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return getCertificateDelegate(call.execute()); } @@ -5006,8 +5012,8 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateNa serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -5054,8 +5060,8 @@ public ServiceResponse updateCertificateOperation(Str throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } Validator.validate(certificateOperation); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return updateCertificateOperationDelegate(call.execute()); } @@ -5090,8 +5096,8 @@ public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String c return null; } Validator.validate(certificateOperation, serviceCallback); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -5133,8 +5139,8 @@ public ServiceResponse getCertificateOperation(String if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return getCertificateOperationDelegate(call.execute()); } @@ -5163,8 +5169,8 @@ public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String cert serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -5206,8 +5212,8 @@ public ServiceResponse deleteCertificateOperation(Str if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); return deleteCertificateOperationDelegate(call.execute()); } @@ -5236,8 +5242,8 @@ public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String c serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), this.userAgent()); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -5287,11 +5293,11 @@ public ServiceResponse mergeCertificate(String vaultBase final CertificateAttributesInner certificateAttributes = null; final Map tags = null; CertificateMergeParameters parameters = new CertificateMergeParameters(); - parameters.setX509Certificates(x509Certificates); - parameters.setCertificateAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withX509Certificates(x509Certificates); + parameters.withCertificateAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return mergeCertificateDelegate(call.execute()); } @@ -5329,11 +5335,11 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificate final CertificateAttributesInner certificateAttributes = null; final Map tags = null; CertificateMergeParameters parameters = new CertificateMergeParameters(); - parameters.setX509Certificates(x509Certificates); - parameters.setCertificateAttributes(null); - parameters.setTags(null); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withX509Certificates(x509Certificates); + parameters.withCertificateAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -5378,11 +5384,11 @@ public ServiceResponse mergeCertificate(String vaultBase Validator.validate(certificateAttributes); Validator.validate(tags); CertificateMergeParameters parameters = new CertificateMergeParameters(); - parameters.setX509Certificates(x509Certificates); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withX509Certificates(x509Certificates); + parameters.withCertificateAttributes(certificateAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); return mergeCertificateDelegate(call.execute()); } @@ -5422,11 +5428,11 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificate Validator.validate(certificateAttributes, serviceCallback); Validator.validate(tags, serviceCallback); CertificateMergeParameters parameters = new CertificateMergeParameters(); - parameters.setX509Certificates(x509Certificates); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - this.restClient().setBaseUrl("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, this.userAgent()); + parameters.withX509Certificates(x509Certificates); + parameters.withCertificateAttributes(certificateAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override @@ -5461,7 +5467,6 @@ public ServiceResponse> getKeyVersionsNext(final String n if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - this.restClient().setBaseUrl(); Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); return getKeyVersionsNextDelegate(call.execute()); } @@ -5483,7 +5488,6 @@ public ServiceCall getKeyVersionsNextAsync(final String nextPageLink, final Serv serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); return null; } - this.restClient().setBaseUrl(); Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @@ -5526,7 +5530,6 @@ public ServiceResponse> getKeysNext(final String nextPage if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - this.restClient().setBaseUrl(); Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); return getKeysNextDelegate(call.execute()); } @@ -5548,7 +5551,6 @@ public ServiceCall getKeysNextAsync(final String nextPageLink, final ServiceCall serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); return null; } - this.restClient().setBaseUrl(); Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @@ -5591,7 +5593,6 @@ public ServiceResponse> getSecretsNext(final String ne if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - this.restClient().setBaseUrl(); Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); return getSecretsNextDelegate(call.execute()); } @@ -5613,7 +5614,6 @@ public ServiceCall getSecretsNextAsync(final String nextPageLink, final ServiceC serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); return null; } - this.restClient().setBaseUrl(); Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @@ -5656,7 +5656,6 @@ public ServiceResponse> getSecretVersionsNext(final St if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - this.restClient().setBaseUrl(); Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); return getSecretVersionsNextDelegate(call.execute()); } @@ -5678,7 +5677,6 @@ public ServiceCall getSecretVersionsNextAsync(final String nextPageLink, final S serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); return null; } - this.restClient().setBaseUrl(); Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @@ -5721,7 +5719,6 @@ public ServiceResponse> getCertificatesNext(final if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - this.restClient().setBaseUrl(); Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); return getCertificatesNextDelegate(call.execute()); } @@ -5743,7 +5740,6 @@ public ServiceCall getCertificatesNextAsync(final String nextPageLink, final Ser serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); return null; } - this.restClient().setBaseUrl(); Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @@ -5786,7 +5782,6 @@ public ServiceResponse> getCertificateIssue if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - this.restClient().setBaseUrl(); Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); return getCertificateIssuersNextDelegate(call.execute()); } @@ -5808,7 +5803,6 @@ public ServiceCall getCertificateIssuersNextAsync(final String nextPageLink, fin serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); return null; } - this.restClient().setBaseUrl(); Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { @@ -5851,7 +5845,6 @@ public ServiceResponse> getCertificateVersionsNex if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - this.restClient().setBaseUrl(); Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); return getCertificateVersionsNextDelegate(call.execute()); } @@ -5873,7 +5866,6 @@ public ServiceCall getCertificateVersionsNextAsync(final String nextPageLink, fi serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); return null; } - this.restClient().setBaseUrl(); Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); call.enqueue(new ServiceResponseCallback>(serviceCallback) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultError.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultError.java index c504f03637deb..76f5f95f69a7c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultError.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultError.java @@ -13,48 +13,18 @@ */ public class KeyVaultError { /** - * The code property. - */ - @JsonProperty(value = "error.code", access = JsonProperty.Access.WRITE_ONLY) - private String code; - - /** - * The message property. - */ - @JsonProperty(value = "error.message", access = JsonProperty.Access.WRITE_ONLY) - private String message; - - /** - * The additionalInfo property. + * The error property. */ @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private Object additionalInfo; - - /** - * Get the code value. - * - * @return the code value - */ - public String code() { - return this.code; - } - - /** - * Get the message value. - * - * @return the message value - */ - public String message() { - return this.message; - } + private Error error; /** - * Get the additionalInfo value. + * Get the error value. * - * @return the additionalInfo value + * @return the error value */ - public Object additionalInfo() { - return this.additionalInfo; + public Error error() { + return this.error; } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyParameters.java index 8bd81f43c138f..efeaf0e3e1672 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyParameters.java @@ -46,7 +46,7 @@ public String algorithm() { * @param algorithm the algorithm value to set * @return the KeyVerifyParameters object itself. */ - public KeyVerifyParameters setAlgorithm(String algorithm) { + public KeyVerifyParameters withAlgorithm(String algorithm) { this.algorithm = algorithm; return this; } @@ -66,7 +66,7 @@ public String digest() { * @param digest the digest value to set * @return the KeyVerifyParameters object itself. */ - public KeyVerifyParameters setDigest(String digest) { + public KeyVerifyParameters withDigest(String digest) { this.digest = digest; return this; } @@ -86,7 +86,7 @@ public String signature() { * @param signature the signature value to set * @return the KeyVerifyParameters object itself. */ - public KeyVerifyParameters setSignature(String signature) { + public KeyVerifyParameters withSignature(String signature) { this.signature = signature; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/LifetimeAction.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/LifetimeAction.java index 7d7b058d7a532..21f9d6790b667 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/LifetimeAction.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/LifetimeAction.java @@ -36,7 +36,7 @@ public Trigger trigger() { * @param trigger the trigger value to set * @return the LifetimeAction object itself. */ - public LifetimeAction setTrigger(Trigger trigger) { + public LifetimeAction withTrigger(Trigger trigger) { this.trigger = trigger; return this; } @@ -56,7 +56,7 @@ public Action action() { * @param action the action value to set * @return the LifetimeAction object itself. */ - public LifetimeAction setAction(Action action) { + public LifetimeAction withAction(Action action) { this.action = action; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/OrganizationDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/OrganizationDetails.java index 966176854fb57..cda130a7302e7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/OrganizationDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/OrganizationDetails.java @@ -70,7 +70,7 @@ public String name() { * @param name the name value to set * @return the OrganizationDetails object itself. */ - public OrganizationDetails setName(String name) { + public OrganizationDetails withName(String name) { this.name = name; return this; } @@ -90,7 +90,7 @@ public String address1() { * @param address1 the address1 value to set * @return the OrganizationDetails object itself. */ - public OrganizationDetails setAddress1(String address1) { + public OrganizationDetails withAddress1(String address1) { this.address1 = address1; return this; } @@ -110,7 +110,7 @@ public String address2() { * @param address2 the address2 value to set * @return the OrganizationDetails object itself. */ - public OrganizationDetails setAddress2(String address2) { + public OrganizationDetails withAddress2(String address2) { this.address2 = address2; return this; } @@ -130,7 +130,7 @@ public String city() { * @param city the city value to set * @return the OrganizationDetails object itself. */ - public OrganizationDetails setCity(String city) { + public OrganizationDetails withCity(String city) { this.city = city; return this; } @@ -150,7 +150,7 @@ public String zipcode() { * @param zipcode the zipcode value to set * @return the OrganizationDetails object itself. */ - public OrganizationDetails setZipcode(String zipcode) { + public OrganizationDetails withZipcode(String zipcode) { this.zipcode = zipcode; return this; } @@ -170,7 +170,7 @@ public String state() { * @param state the state value to set * @return the OrganizationDetails object itself. */ - public OrganizationDetails setState(String state) { + public OrganizationDetails withState(String state) { this.state = state; return this; } @@ -190,7 +190,7 @@ public String country() { * @param country the country value to set * @return the OrganizationDetails object itself. */ - public OrganizationDetails setCountry(String country) { + public OrganizationDetails withCountry(String country) { this.country = country; return this; } @@ -210,7 +210,7 @@ public List administratorDetails() { * @param administratorDetails the administratorDetails value to set * @return the OrganizationDetails object itself. */ - public OrganizationDetails setAdministratorDetails(List administratorDetails) { + public OrganizationDetails withAdministratorDetails(List administratorDetails) { this.administratorDetails = administratorDetails; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretBundleInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretBundleInner.java index 850d7b026667a..fa342a844c7cf 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretBundleInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretBundleInner.java @@ -52,7 +52,7 @@ public String value() { * @param value the value value to set * @return the SecretBundleInner object itself. */ - public SecretBundleInner setValue(String value) { + public SecretBundleInner withValue(String value) { this.value = value; return this; } @@ -72,7 +72,7 @@ public String id() { * @param id the id value to set * @return the SecretBundleInner object itself. */ - public SecretBundleInner setId(String id) { + public SecretBundleInner withId(String id) { this.id = id; return this; } @@ -92,7 +92,7 @@ public String contentType() { * @param contentType the contentType value to set * @return the SecretBundleInner object itself. */ - public SecretBundleInner setContentType(String contentType) { + public SecretBundleInner withContentType(String contentType) { this.contentType = contentType; return this; } @@ -112,7 +112,7 @@ public SecretAttributesInner attributes() { * @param attributes the attributes value to set * @return the SecretBundleInner object itself. */ - public SecretBundleInner setAttributes(SecretAttributesInner attributes) { + public SecretBundleInner withAttributes(SecretAttributesInner attributes) { this.attributes = attributes; return this; } @@ -132,7 +132,7 @@ public Map tags() { * @param tags the tags value to set * @return the SecretBundleInner object itself. */ - public SecretBundleInner setTags(Map tags) { + public SecretBundleInner withTags(Map tags) { this.tags = tags; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretItemInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretItemInner.java index af5245e6f1a34..a73028014a936 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretItemInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretItemInner.java @@ -47,7 +47,7 @@ public String id() { * @param id the id value to set * @return the SecretItemInner object itself. */ - public SecretItemInner setId(String id) { + public SecretItemInner withId(String id) { this.id = id; return this; } @@ -67,7 +67,7 @@ public SecretAttributesInner attributes() { * @param attributes the attributes value to set * @return the SecretItemInner object itself. */ - public SecretItemInner setAttributes(SecretAttributesInner attributes) { + public SecretItemInner withAttributes(SecretAttributesInner attributes) { this.attributes = attributes; return this; } @@ -87,7 +87,7 @@ public Map tags() { * @param tags the tags value to set * @return the SecretItemInner object itself. */ - public SecretItemInner setTags(Map tags) { + public SecretItemInner withTags(Map tags) { this.tags = tags; return this; } @@ -107,7 +107,7 @@ public String contentType() { * @param contentType the contentType value to set * @return the SecretItemInner object itself. */ - public SecretItemInner setContentType(String contentType) { + public SecretItemInner withContentType(String contentType) { this.contentType = contentType; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretProperties.java index 466d90d0343a7..8004af2957c05 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretProperties.java @@ -33,7 +33,7 @@ public String contentType() { * @param contentType the contentType value to set * @return the SecretProperties object itself. */ - public SecretProperties setContentType(String contentType) { + public SecretProperties withContentType(String contentType) { this.contentType = contentType; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretSetParameters.java index 3cb2510508571..b964181c1e2bf 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretSetParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretSetParameters.java @@ -50,7 +50,7 @@ public String value() { * @param value the value value to set * @return the SecretSetParameters object itself. */ - public SecretSetParameters setValue(String value) { + public SecretSetParameters withValue(String value) { this.value = value; return this; } @@ -70,7 +70,7 @@ public Map tags() { * @param tags the tags value to set * @return the SecretSetParameters object itself. */ - public SecretSetParameters setTags(Map tags) { + public SecretSetParameters withTags(Map tags) { this.tags = tags; return this; } @@ -90,7 +90,7 @@ public String contentType() { * @param contentType the contentType value to set * @return the SecretSetParameters object itself. */ - public SecretSetParameters setContentType(String contentType) { + public SecretSetParameters withContentType(String contentType) { this.contentType = contentType; return this; } @@ -110,7 +110,7 @@ public SecretAttributesInner secretAttributes() { * @param secretAttributes the secretAttributes value to set * @return the SecretSetParameters object itself. */ - public SecretSetParameters setSecretAttributes(SecretAttributesInner secretAttributes) { + public SecretSetParameters withSecretAttributes(SecretAttributesInner secretAttributes) { this.secretAttributes = secretAttributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretUpdateParameters.java index f9ee68f2a6c0b..4e682f6baa37f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretUpdateParameters.java @@ -44,7 +44,7 @@ public String contentType() { * @param contentType the contentType value to set * @return the SecretUpdateParameters object itself. */ - public SecretUpdateParameters setContentType(String contentType) { + public SecretUpdateParameters withContentType(String contentType) { this.contentType = contentType; return this; } @@ -64,7 +64,7 @@ public SecretAttributesInner secretAttributes() { * @param secretAttributes the secretAttributes value to set * @return the SecretUpdateParameters object itself. */ - public SecretUpdateParameters setSecretAttributes(SecretAttributesInner secretAttributes) { + public SecretUpdateParameters withSecretAttributes(SecretAttributesInner secretAttributes) { this.secretAttributes = secretAttributes; return this; } @@ -84,7 +84,7 @@ public Map tags() { * @param tags the tags value to set * @return the SecretUpdateParameters object itself. */ - public SecretUpdateParameters setTags(Map tags) { + public SecretUpdateParameters withTags(Map tags) { this.tags = tags; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SubjectAlternativeNames.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SubjectAlternativeNames.java index 049064abfca9a..06cd128d1b833 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SubjectAlternativeNames.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SubjectAlternativeNames.java @@ -44,7 +44,7 @@ public List emails() { * @param emails the emails value to set * @return the SubjectAlternativeNames object itself. */ - public SubjectAlternativeNames setEmails(List emails) { + public SubjectAlternativeNames withEmails(List emails) { this.emails = emails; return this; } @@ -64,7 +64,7 @@ public List dnsNames() { * @param dnsNames the dnsNames value to set * @return the SubjectAlternativeNames object itself. */ - public SubjectAlternativeNames setDnsNames(List dnsNames) { + public SubjectAlternativeNames withDnsNames(List dnsNames) { this.dnsNames = dnsNames; return this; } @@ -84,7 +84,7 @@ public List upns() { * @param upns the upns value to set * @return the SubjectAlternativeNames object itself. */ - public SubjectAlternativeNames setUpns(List upns) { + public SubjectAlternativeNames withUpns(List upns) { this.upns = upns; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Trigger.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Trigger.java index 395a1fe79b303..df3b61f908745 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Trigger.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Trigger.java @@ -33,7 +33,7 @@ public Integer lifetimePercentage() { * @param lifetimePercentage the lifetimePercentage value to set * @return the Trigger object itself. */ - public Trigger setLifetimePercentage(Integer lifetimePercentage) { + public Trigger withLifetimePercentage(Integer lifetimePercentage) { this.lifetimePercentage = lifetimePercentage; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/X509CertificateProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/X509CertificateProperties.java index a575de944736c..2aeae068b0fb9 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/X509CertificateProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/X509CertificateProperties.java @@ -56,7 +56,7 @@ public String subject() { * @param subject the subject value to set * @return the X509CertificateProperties object itself. */ - public X509CertificateProperties setSubject(String subject) { + public X509CertificateProperties withSubject(String subject) { this.subject = subject; return this; } @@ -76,7 +76,7 @@ public List ekus() { * @param ekus the ekus value to set * @return the X509CertificateProperties object itself. */ - public X509CertificateProperties setEkus(List ekus) { + public X509CertificateProperties withEkus(List ekus) { this.ekus = ekus; return this; } @@ -96,7 +96,7 @@ public SubjectAlternativeNames subjectAlternativeNames() { * @param subjectAlternativeNames the subjectAlternativeNames value to set * @return the X509CertificateProperties object itself. */ - public X509CertificateProperties setSubjectAlternativeNames(SubjectAlternativeNames subjectAlternativeNames) { + public X509CertificateProperties withSubjectAlternativeNames(SubjectAlternativeNames subjectAlternativeNames) { this.subjectAlternativeNames = subjectAlternativeNames; return this; } @@ -116,7 +116,7 @@ public List keyUsage() { * @param keyUsage the keyUsage value to set * @return the X509CertificateProperties object itself. */ - public X509CertificateProperties setKeyUsage(List keyUsage) { + public X509CertificateProperties withKeyUsage(List keyUsage) { this.keyUsage = keyUsage; return this; } @@ -136,7 +136,7 @@ public Integer validityInMonths() { * @param validityInMonths the validityInMonths value to set * @return the X509CertificateProperties object itself. */ - public X509CertificateProperties setValidityInMonths(Integer validityInMonths) { + public X509CertificateProperties withValidityInMonths(Integer validityInMonths) { this.validityInMonths = validityInMonths; return this; } From afe97339fb88849ad1cfad8c932cccd68c308981 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Wed, 20 Jul 2016 14:06:50 -0700 Subject: [PATCH 03/56] Updated Key Vault SDK based on none fluent AutoRest and costumized code for method calls with long list of optional properties --- azure-keyvault/pom.xml | 24 +- .../authentication/ChallengeCache.java | 81 + .../authentication/KeyVaultCredentials.java | 206 ++ .../implementation/CertificateIdentifier.java | 38 + .../CertificateOperationIdentifier.java | 64 + .../implementation/IssuerIdentifier.java | 97 + .../implementation/KeyIdentifier.java | 37 + .../implementation/KeyVaultClient.java | 2215 +++++++++++++++++ .../{api => }/KeyVaultClientImpl.java | 1114 +++++---- .../implementation/ObjectIdentifier.java | 185 ++ .../implementation/SecretIdentifier.java | 37 + .../implementation/api/JsonWebKeyInner.java | 343 --- .../implementation/api/KeyBundleInner.java | 90 - .../api/OrganizationDetails.java | 218 -- .../requests/CreateCertificateRequest.java | 182 ++ .../requests/CreateKeyRequest.java | 182 ++ .../requests/ImportCertificateRequest.java | 217 ++ .../requests/ImportKeyRequest.java | 175 ++ .../requests/MergeCertificateRequest.java | 130 + .../requests/SetCertificateIssuerRequest.java | 92 + .../requests/SetSecretRequest.java | 152 ++ .../UpdateCertificateIssuerRequest.java | 92 + .../UpdateCertificateOperationRequest.java | 83 + .../UpdateCertificatePolicyRequest.java | 123 + .../requests/UpdateCertificateRequest.java | 137 + .../requests/UpdateKeyRequest.java | 182 ++ .../requests/UpdateSecretRequest.java | 167 ++ .../api => models}/Action.java | 11 +- .../azure/keyvault/models/ActionType.java | 51 + .../api => models}/AdministratorDetails.java | 2 +- .../api => models}/Attributes.java | 44 +- .../BackupKeyResult.java} | 16 +- .../CertificateAttributes.java} | 6 +- .../CertificateBundle.java} | 86 +- .../CertificateCreateParameters.java | 14 +- .../CertificateImportParameters.java | 18 +- .../CertificateIssuerItem.java} | 14 +- .../CertificateItem.java} | 51 +- .../CertificateMergeParameters.java | 10 +- .../CertificateOperation.java} | 70 +- .../CertificatePolicy.java} | 34 +- .../CertificateUpdateParameters.java | 8 +- .../api => models}/Contact.java | 2 +- .../Contacts.java} | 10 +- .../{implementation/api => models}/Error.java | 6 +- .../api => models}/IssuerAttributes.java | 18 +- .../IssuerBundle.java} | 48 +- .../api => models}/IssuerCredentials.java | 2 +- .../api => models}/IssuerReference.java | 2 +- .../azure/keyvault/models/JsonWebKey.java | 529 ++++ .../KeyAttributes.java} | 6 +- .../azure/keyvault/models/KeyBundle.java | 116 + .../api => models}/KeyCreateParameters.java | 8 +- .../api => models}/KeyImportParameters.java | 14 +- .../KeyItemInner.java => models/KeyItem.java} | 36 +- .../KeyOperationResult.java} | 16 +- .../KeyOperationsParameters.java | 16 +- .../api => models}/KeyProperties.java | 21 +- .../api => models}/KeyRestoreParameters.java | 16 +- .../api => models}/KeyUpdateParameters.java | 8 +- .../azure/keyvault/models/KeyUsageType.java | 42 + .../api => models}/KeyVaultError.java | 2 +- .../KeyVaultErrorException.java | 2 +- .../api => models}/KeyVerifyParameters.java | 29 +- .../KeyVerifyResult.java} | 6 +- .../api => models}/LifetimeAction.java | 2 +- .../keyvault/models/OrganizationDetails.java | 67 + .../api => models}/PageImpl.java | 2 +- ...endingCertificateSigningRequestResult.java | 2 +- .../SecretAttributes.java} | 6 +- .../SecretBundle.java} | 58 +- .../SecretItem.java} | 40 +- .../api => models}/SecretProperties.java | 2 +- .../api => models}/SecretSetParameters.java | 10 +- .../SecretUpdateParameters.java | 10 +- .../SubjectAlternativeNames.java | 2 +- .../api => models}/Trigger.java | 31 +- .../X509CertificateProperties.java | 6 +- .../api => models}/package-info.java | 4 +- .../webkey/JsonWebKeyEncryptionAlgorithm.java | 39 + .../keyvault/webkey/JsonWebKeyOperation.java | 43 + .../webkey/JsonWebKeySignatureAlgorithm.java | 40 + .../azure/keyvault/webkey/JsonWebKeyType.java | 40 + .../test/CertificateOperationsTest.java | 1276 ++++++++++ .../keyvault/test/KeyOperationsTest.java | 570 +++++ .../KeyVaultClientIntegrationTestBase.java | 164 ++ .../keyvault/test/SecretOperationsTest.java | 301 +++ 87 files changed, 9265 insertions(+), 1503 deletions(-) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateIdentifier.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateOperationIdentifier.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/IssuerIdentifier.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyIdentifier.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClient.java rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/{api => }/KeyVaultClientImpl.java (84%) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/ObjectIdentifier.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/SecretIdentifier.java delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/JsonWebKeyInner.java delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyBundleInner.java delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/OrganizationDetails.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateCertificateRequest.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateKeyRequest.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportCertificateRequest.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportKeyRequest.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/MergeCertificateRequest.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetCertificateIssuerRequest.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetSecretRequest.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateIssuerRequest.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateOperationRequest.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificatePolicyRequest.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateRequest.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateKeyRequest.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateSecretRequest.java rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/Action.java (71%) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/AdministratorDetails.java (97%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/Attributes.java (62%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/BackupKeyResultInner.java => models/BackupKeyResult.java} (58%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/KeyAttributesInner.java => models/CertificateAttributes.java} (55%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/CertificateBundleInner.java => models/CertificateBundle.java} (55%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/CertificateCreateParameters.java (84%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/CertificateImportParameters.java (87%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/CertificateIssuerItemInner.java => models/CertificateIssuerItem.java} (70%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/CertificateItemInner.java => models/CertificateItem.java} (57%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/CertificateMergeParameters.java (88%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/CertificateOperationInner.java => models/CertificateOperation.java} (66%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/CertificatePolicyInner.java => models/CertificatePolicy.java} (76%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/CertificateUpdateParameters.java (86%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/Contact.java (96%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/ContactsInner.java => models/Contacts.java} (81%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/Error.java (87%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/IssuerAttributes.java (73%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/IssuerBundleInner.java => models/IssuerBundle.java} (62%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/IssuerCredentials.java (96%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/IssuerReference.java (92%) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/SecretAttributesInner.java => models/KeyAttributes.java} (54%) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/KeyCreateParameters.java (92%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/KeyImportParameters.java (86%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/KeyItemInner.java => models/KeyItem.java} (62%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/KeyOperationResultInner.java => models/KeyOperationResult.java} (68%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/KeyOperationsParameters.java (77%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/KeyProperties.java (84%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/KeyRestoreParameters.java (64%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/KeyUpdateParameters.java (89%) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/KeyVaultError.java (90%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/KeyVaultErrorException.java (97%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/KeyVerifyParameters.java (72%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/KeyVerifyResultInner.java => models/KeyVerifyResult.java} (80%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/LifetimeAction.java (95%) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/PageImpl.java (96%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/PendingCertificateSigningRequestResult.java (92%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/CertificateAttributesInner.java => models/SecretAttributes.java} (52%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/SecretBundleInner.java => models/SecretBundle.java} (56%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api/SecretItemInner.java => models/SecretItem.java} (65%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/SecretProperties.java (93%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/SecretSetParameters.java (91%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/SecretUpdateParameters.java (89%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/SubjectAlternativeNames.java (97%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/Trigger.java (54%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/X509CertificateProperties.java (96%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation/api => models}/package-info.java (67%) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java create mode 100644 azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java create mode 100644 azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java create mode 100644 azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java create mode 100644 azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index 4c717b7a4f703..1adbfe52e1f61 100644 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -45,32 +45,24 @@ + - com.microsoft.azure - azure-client-runtime - 1.0.0-SNAPSHOT - - - org.apache.httpcomponents - httpclient - 4.5.2 + com.microsoft.azure + azure-client-runtime + 1.0.0-SNAPSHOT + + junit junit test - - com.microsoft.azure - azure-client-authentication - 1.0.0-beta1 - test - com.microsoft.azure - azure-core - 0.9.3 + azure-client-authentication + 1.0.0-SNAPSHOT diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java new file mode 100644 index 0000000000000..3b25b0737de36 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java @@ -0,0 +1,81 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.authentication; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +import com.microsoft.rest.credentials.ServiceClientCredentials; + +import okhttp3.HttpUrl; + +/** + * An implementation of {@link ServiceClientCredentials} that supports automatic bearer + * token refresh. + * + */ +class ChallengeCache { + + private final HashMap> cachedChallenges = new HashMap>(); + + /** + * Uses authority to retrieve the cached values + * @param url the url that is used as a cache key + * @return cached value or null if value is not available + */ + public Map getCachedChallenge(HttpUrl url) { + if(url == null) return null; + String authority = getAuthority(url); + authority = authority.toLowerCase(Locale.ENGLISH); + return cachedChallenges.get(authority); + } + + /** + * Uses authority to cache challenge + * @param url the url that is used as a cache key + * @param challenge the challenge to cache + */ + public void addCachedChallenge(HttpUrl url, Map challenge) { + if(url == null || challenge == null) return; + String authority = getAuthority(url); + authority = authority.toLowerCase(Locale.ENGLISH); + cachedChallenges.put(authority, challenge); + } + + /** + * Gets authority of a url + * @param url the url to get the authority for + * @return the authority + */ + public String getAuthority(HttpUrl url) { + String scheme = url.scheme(); + String host = url.host(); + int port = url.port(); + StringBuilder builder = new StringBuilder(); + if (scheme != null) { + builder.append(scheme).append("://"); + } + builder.append(host); + if (port >= 0) { + builder.append(':').append(port); + } + return builder.toString(); + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java new file mode 100644 index 0000000000000..f3f4e48edb419 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java @@ -0,0 +1,206 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.authentication; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import com.microsoft.rest.credentials.ServiceClientCredentials; + +import okhttp3.Authenticator; +import okhttp3.HttpUrl; +import okhttp3.Interceptor; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.Route; + +/** + * An implementation of {@link ServiceClientCredentials} that supports automatic bearer + * token refresh. + * + */ +public abstract class KeyVaultCredentials implements ServiceClientCredentials { + + private static final String wwwAuthenticate = "WWW-Authenticate"; + private static final String authorization = "Authorization"; + private static final String bearerTokenPrefix = "Bearer "; + + private final ChallengeCache cache = new ChallengeCache(); + + @Override + public void applyCredentialsFilter(OkHttpClient.Builder clientBuilder) { + + clientBuilder.addInterceptor(new Interceptor() { + + @Override + public Response intercept(Chain chain) throws IOException { + + HttpUrl url = chain.request().url(); + + Map challengeMap = cache.getCachedChallenge(url); + + if(challengeMap != null) { + // Get the bearer token + String credential = getAuthenticationCredentials(challengeMap); + + Request newRequest = chain.request().newBuilder() + .header(authorization, bearerTokenPrefix + credential) + .build(); + + return chain.proceed(newRequest); + } + else { + // challenge is new for the URL and is not cached, + // so the request is sent out to get the challenges in response + return chain.proceed(chain.request()); + } + } + }); + + // Caches the challenge for failed request and re-send the request with access token + clientBuilder.authenticator(new Authenticator() { + + @Override + public Request authenticate(Route route, Response response) throws IOException { + + //if challenge is not cached then extract and cache it + String authenticateHeader = response.header(wwwAuthenticate); + + Map challengeMap = extractChallenge(authenticateHeader, bearerTokenPrefix); + + //Cache the challenge + cache.addCachedChallenge(response.request().url(), challengeMap); + + // Get the bearer token from the callback by providing the challenges + String credential = getAuthenticationCredentials(challengeMap); + + if (credential == null) return null; + + // Add the token header and resume the call. + // The token should live for duration of this request and never + // be cached anywhere in our code. + return response.request().newBuilder() + .header(authorization, bearerTokenPrefix + credential) + .build(); + } + }); + } + + /** + * Extracts the authentication challenges from the challenge map and + * calls the authentication callback to get the bearer token and return it + * @param challengeMap the challenge map + * @return the bearer token + */ + private String getAuthenticationCredentials(Map challengeMap) { + + String authorization = challengeMap.get("authorization"); + if(authorization == null) authorization = challengeMap.get("authorization_uri"); + + String resource = challengeMap.get("resource"); + String scope = challengeMap.get("scope"); + + return doAuthenticate(authorization, resource, scope); + } + + /** + * Extracts the challenge off the authentication header + * @param authenticateHeader the authentication header containing all the challenges + * @param authChallengePrefix the authentication challenge name + * @return a challenge map + */ + private Map extractChallenge(String authenticateHeader, String authChallengePrefix) { + if (!isValidChallenge(authenticateHeader, authChallengePrefix)) return null; + + authenticateHeader = authenticateHeader.toLowerCase() + .replace(authChallengePrefix.toLowerCase(), ""); + + String [] challenges = authenticateHeader.split(", "); + Map challengeMap = new HashMap(); + for(String pair : challenges) { + String [] keyValue = pair.split("="); + challengeMap.put(keyValue[0].replaceAll("\"", ""), keyValue[1].replaceAll("\"", "")); + } + return challengeMap; + } + + /** + * Verifies whether a challenge is bearer or not + * @param authenticateHeader the authentication header containing all the challenges + * @param authChallengePrefix the authentication challenge name + * @return + */ + private boolean isValidChallenge(String authenticateHeader, String authChallengePrefix) { + if(authenticateHeader!= null && !authenticateHeader.isEmpty() + && authenticateHeader.toLowerCase().startsWith(authChallengePrefix.toLowerCase())) + return true; + return false; + } + + /** + * Answers a server challenge with a token header. + *

+ * Implementations typically use ADAL to get a token, as performed in the + * sample below: + *

+ * + *
+     * @Override
+     * public String doAuthenticate(String authorization, String resource, String scope) {
+     *     String clientId = ...; // client GUID as shown in Azure portal.
+     *     String clientKey = ...; // client key as provided by Azure portal.
+     *     AuthenticationResult token = getAccessTokenFromClientCredentials(authorization, resource, clientId, clientKey);
+     *     return token.getAccessToken();;
+     * }
+     *
+     * private static AuthenticationResult getAccessTokenFromClientCredentials(String authorization, String resource, String clientId, String clientKey) {
+     *     AuthenticationContext context = null;
+     *     AuthenticationResult result = null;
+     *     ExecutorService service = null;
+     *     try {
+     *         service = Executors.newFixedThreadPool(1);
+     *         context = new AuthenticationContext(authorization, false, service);
+     *         ClientCredential credentials = new ClientCredential(clientId, clientKey);
+     *         Future<AuthenticationResult> future = context.acquireToken(resource, credentials, null);
+     *         result = future.get();
+     *     } catch (Exception e) {
+     *         throw new RuntimeException(e);
+     *     } finally {
+     *         service.shutdown();
+     *     }
+     *
+     *     if (result == null) {
+     *         throw new RuntimeException("authentication result was null");
+     *     }
+     *     return result;
+     * }
+     * 
+ * + *

+ * Note: The client key must be securely stored. It's advised to use two + * client applications - one for development and other for production - + * managed by separate parties. + *

+ * + */ + public abstract String doAuthenticate(String authorization, String resource, String scope); + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateIdentifier.java new file mode 100644 index 0000000000000..3212b73970f92 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateIdentifier.java @@ -0,0 +1,38 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.implementation; + +public final class CertificateIdentifier extends ObjectIdentifier { + + public static boolean isCertificateIdentifier(String identifier) { + return ObjectIdentifier.isObjectIdentifier("certificates", identifier); + } + + public CertificateIdentifier(String vault, String name) { + this(vault, name, ""); + } + + public CertificateIdentifier(String vault, String name, String version) { + super(vault, "certificates", name, version); + } + + public CertificateIdentifier(String identifier) { + super("certificates", identifier); + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateOperationIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateOperationIdentifier.java new file mode 100644 index 0000000000000..95819298f24a6 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateOperationIdentifier.java @@ -0,0 +1,64 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.implementation; + +import java.net.URI; +import java.net.URISyntaxException; + +public final class CertificateOperationIdentifier extends ObjectIdentifier { + + public static boolean isCertificateOperationIdentifier(String identifier) { + identifier = verifyNonEmpty(identifier, "identifier"); + + URI baseUri; + try { + baseUri = new URI(identifier); + } catch (URISyntaxException e) { + return false; + } + + // Path is of the form "/certificates/[name]/pending" + String[] segments = baseUri.getPath().split("/"); + if (segments.length != 4) { + return false; + } + + if (!(segments[1]).equals("certificates")) { + return false; + } + + if (!(segments[3]).equals("pending")) { + return false; + } + + return true; + } + + public CertificateOperationIdentifier(String vault, String name, String version) { + super(vault, "certificates", name, "pending"); + } + + public CertificateOperationIdentifier(String identifier) { + super("certificates", identifier); + if (!version().equals("pending")) { + throw new IllegalArgumentException( + String.format("Invalid CertificateOperationIdentifier: {0}", identifier)); + } + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/IssuerIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/IssuerIdentifier.java new file mode 100644 index 0000000000000..ef0b4c6334844 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/IssuerIdentifier.java @@ -0,0 +1,97 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.implementation; + +import java.net.URI; +import java.net.URISyntaxException; +import java.security.InvalidParameterException; + +public final class IssuerIdentifier extends ObjectIdentifier { + + public static boolean isIssuerIdentifier(String identifier) { + identifier = verifyNonEmpty(identifier, "identifier"); + + URI baseUri; + try { + baseUri = new URI(identifier); + } catch (URISyntaxException e) { + return false; + } + + String[] segments = baseUri.getPath().split("/"); + if (segments.length != 4 || segments[1] != "certificates" || segments[2] != "issuers") { + return false; + } + + return true; + } + + public IssuerIdentifier(String vault, String name) { + vault = verifyNonEmpty(vault, "vault"); + + name = verifyNonEmpty(name, "name"); + + URI baseUri; + try { + baseUri = new URI(vault); + } catch (URISyntaxException e) { + throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. Not a valid URI", vault)); + } + + this.name = name; + this.version = null; + this.vault = String.format("%s://%s", baseUri.getScheme(), getFullAuthority(baseUri)); + + baseIdentifier = String.format("%s/%s/%s", this.vault, "certificates/issuers", this.name); + identifier = baseIdentifier; + } + + public IssuerIdentifier(String identifier) { + + identifier = verifyNonEmpty(identifier, "identifier"); + + URI baseUri; + try { + baseUri = new URI(identifier); + } catch (URISyntaxException e) { + throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. Not a valid URI", identifier)); + } + + // Path is of the form "/collection/name[/version]" + String[] segments = baseUri.getPath().split("/"); + if (segments.length != 4) { + throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. Bad number of segments: %d", identifier, segments.length)); + } + + if (!segments[1].equals("certificates")) { + throw new InvalidParameterException( + String.format("Invalid ObjectIdentifier: %s. Segment [1] should be '%s', found '%s'", identifier, "certificates", segments[1])); + } + if (!segments[2].equals("issuers")) { + throw new InvalidParameterException( + String.format("Invalid ObjectIdentifier: %s. Segment [2] should be '%s', found '%s'", identifier, "issuers", segments[2])); + } + + name = segments[3]; + version = ""; + vault = String.format("%s://%s", baseUri.getScheme(), getFullAuthority(baseUri)); + baseIdentifier = String.format("%s/%s/%s", vault, "certificates/issuers", name); + this.identifier = baseIdentifier; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyIdentifier.java new file mode 100644 index 0000000000000..bf67ff2164183 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyIdentifier.java @@ -0,0 +1,37 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.implementation; + +public final class KeyIdentifier extends ObjectIdentifier { + public static boolean isKeyIdentifier(String identifier) { + return ObjectIdentifier.isObjectIdentifier("keys", identifier); + } + + public KeyIdentifier(String vault, String name) { + this(vault, name, ""); + } + + public KeyIdentifier(String vault, String name, String version) { + super(vault, "keys", name, version); + } + + public KeyIdentifier(String identifier) { + super("keys", identifier); + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClient.java new file mode 100644 index 0000000000000..6190d84a84dd8 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClient.java @@ -0,0 +1,2215 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.implementation; + +import java.io.IOException; + +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceResponseBuilder; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.keyvault.implementation.requests.CreateCertificateRequest; +import com.microsoft.azure.keyvault.implementation.requests.CreateKeyRequest; +import com.microsoft.azure.keyvault.implementation.requests.ImportCertificateRequest; +import com.microsoft.azure.keyvault.implementation.requests.ImportKeyRequest; +import com.microsoft.azure.keyvault.implementation.requests.MergeCertificateRequest; +import com.microsoft.azure.keyvault.implementation.requests.SetCertificateIssuerRequest; +import com.microsoft.azure.keyvault.implementation.requests.SetSecretRequest; +import com.microsoft.azure.keyvault.implementation.requests.UpdateCertificateIssuerRequest; +import com.microsoft.azure.keyvault.implementation.requests.UpdateCertificateOperationRequest; +import com.microsoft.azure.keyvault.implementation.requests.UpdateCertificatePolicyRequest; +import com.microsoft.azure.keyvault.implementation.requests.UpdateCertificateRequest; +import com.microsoft.azure.keyvault.implementation.requests.UpdateKeyRequest; +import com.microsoft.azure.keyvault.implementation.requests.UpdateSecretRequest; +import com.microsoft.azure.keyvault.models.BackupKeyResult; +import com.microsoft.azure.keyvault.models.CertificateBundle; +import com.microsoft.azure.keyvault.models.CertificateIssuerItem; +import com.microsoft.azure.keyvault.models.CertificateItem; +import com.microsoft.azure.keyvault.models.CertificateOperation; +import com.microsoft.azure.keyvault.models.CertificatePolicy; +import com.microsoft.azure.keyvault.models.Contacts; +import com.microsoft.azure.keyvault.models.IssuerBundle; +import com.microsoft.azure.keyvault.models.KeyBundle; +import com.microsoft.azure.keyvault.models.KeyItem; +import com.microsoft.azure.keyvault.models.KeyOperationResult; +import com.microsoft.azure.keyvault.models.KeyVaultErrorException; +import com.microsoft.azure.keyvault.models.KeyVerifyResult; +import com.microsoft.azure.keyvault.models.PageImpl; +import com.microsoft.azure.keyvault.models.SecretBundle; +import com.microsoft.azure.keyvault.models.SecretItem; +import com.microsoft.azure.RestClient; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseCallback; +import com.microsoft.rest.credentials.ServiceClientCredentials; + +import okhttp3.ResponseBody; +import retrofit2.Call; +import retrofit2.Response; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; + +/** + * Initializes a new instance of the KeyVaultClient class. + */ +public final class KeyVaultClient { + + private KeyVaultClientImpl innerKeyVaultClient; + + /** The Retrofit service to perform REST calls. */ + private KeyVaultClientService service; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return innerKeyVaultClient.getAzureClient(); + } + + /** + * Gets Client Api Version. + * + * @return the apiVersion value. + */ + public String apiVersion() { + return innerKeyVaultClient.apiVersion(); + } + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return innerKeyVaultClient.acceptLanguage(); + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + */ + public void withAcceptLanguage(String acceptLanguage) { + innerKeyVaultClient.withAcceptLanguage(acceptLanguage); + } + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return innerKeyVaultClient.longRunningOperationRetryTimeout(); + } + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + */ + public void withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + innerKeyVaultClient.withLongRunningOperationRetryTimeout(longRunningOperationRetryTimeout); + } + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean getGenerateClientRequestId() { + return innerKeyVaultClient.generateClientRequestId(); + } + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + */ + public void withGenerateClientRequestId(boolean generateClientRequestId) { + innerKeyVaultClient.withGenerateClientRequestId(generateClientRequestId); + } + + /** + * Initializes an instance of KeyVaultClient client. + * + * @param credentials the management credentials for Azure + */ + public KeyVaultClient(ServiceClientCredentials credentials) { + innerKeyVaultClient = new KeyVaultClientImpl(credentials); + initializeService(); + } + + /** + * Initializes an instance of KeyVaultClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public KeyVaultClient(RestClient restClient) { + innerKeyVaultClient = new KeyVaultClientImpl(restClient); + initializeService(); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + public String userAgent() { + return innerKeyVaultClient.userAgent(); + } + + private void initializeService() { + service = innerKeyVaultClient.restClient().retrofit().create(KeyVaultClientService.class); + } + + /** + * The interface defining all the services for KeyVaultClient to be + * used by Retrofit to perform actually REST calls. + */ + interface KeyVaultClientService { + @Headers({"Content-Type: application/json; charset=utf-8", "Accept: application/pkcs10"}) + @GET("certificates/{certificate-name}/pending") + Call getPendingCertificateSigningRequest(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param createKeyRequest the grouped properties for creating a key request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse createKey(CreateKeyRequest createKeyRequest) + throws KeyVaultErrorException, IllegalArgumentException, IOException { + return innerKeyVaultClient.createKey( + createKeyRequest.vaultBaseUrl(), + createKeyRequest.keyName(), + createKeyRequest.keyType(), + createKeyRequest.keySize(), + createKeyRequest.keyOperations(), + createKeyRequest.keyAttributes(), + createKeyRequest.tags()); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param createKeyRequest the grouped properties for creating a key request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link Call} object + */ + public ServiceCall createKey(CreateKeyRequest createKeyRequest, ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.createKeyAsync( + createKeyRequest.vaultBaseUrl(), + createKeyRequest.keyName(), + createKeyRequest.keyType(), + createKeyRequest.keySize(), + createKeyRequest.keyOperations(), + createKeyRequest.keyAttributes(), + createKeyRequest.tags(), + serviceCallback); + } + + /** + * Imports a key into the specified vault. + * + * @param importKeyRequest the grouped properties for importing a key request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse importKey(ImportKeyRequest importKeyRequest) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.importKey( + importKeyRequest.vaultBaseUrl(), + importKeyRequest.keyName(), + importKeyRequest.key(), + importKeyRequest.isHsm(), + importKeyRequest.keyAttributes(), + importKeyRequest.tags()); + } + + /** + * Imports a key into the specified vault. + * + * @param importKeyRequest the grouped properties for importing a key request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall importKey(ImportKeyRequest importKeyRequest, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.importKeyAsync( + importKeyRequest.vaultBaseUrl(), + importKeyRequest.keyName(), + importKeyRequest.key(), + importKeyRequest.isHsm(), + importKeyRequest.keyAttributes(), + importKeyRequest.tags(), + serviceCallback); + } + + /** + * Deletes the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.deleteKey(vaultBaseUrl, keyName); + } + + /** + * Deletes the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall deleteKey(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.deleteKeyAsync(vaultBaseUrl, keyName, serviceCallback); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param updateKeyRequest the grouped properties for updating a key request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateKey(UpdateKeyRequest updateKeyRequest) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.updateKey( + updateKeyRequest.vaultBaseUrl(), + updateKeyRequest.keyName(), + updateKeyRequest.keyVersion(), + updateKeyRequest.keyOperations(), + updateKeyRequest.keyAttributes(), + updateKeyRequest.tags()); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param updateKeyRequest the grouped properties for updating a key request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall updateKey(UpdateKeyRequest updateKeyRequest, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.updateKeyAsync( + updateKeyRequest.vaultBaseUrl(), + updateKeyRequest.keyName(), + updateKeyRequest.keyVersion(), + updateKeyRequest.keyOperations(), + updateKeyRequest.keyAttributes(), + updateKeyRequest.tags(), + serviceCallback); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param keyIdentifier The full key identifier + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getKey(String keyIdentifier) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.getKey(id.vault, id.name, id.version == null? "" : id.version); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param keyIdentifier The full key identifier + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getKey(String keyIdentifier, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.getKeyAsync(id.vault, id.name, id.version == null? "" : id.version, serviceCallback); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getKey(String vaultBaseUrl, String keyName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, ""); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getKey(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getKeyAsync(vaultBaseUrl, keyName, "", serviceCallback); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, keyVersion); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getKey(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getKeyAsync(vaultBaseUrl, keyName, keyVersion, serviceCallback); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getKeyVersions(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, serviceCallback); + } + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param maxresults Maximum number of results to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName, maxresults); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, maxresults, serviceCallback); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getKeys(final String vaultBaseUrl) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKeys(vaultBaseUrl); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getKeys(final String vaultBaseUrl, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, serviceCallback); + } + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKeys(vaultBaseUrl, maxresults); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getKeys(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, maxresults, serviceCallback); + } + + /** + * Requests that a backup of the specified key be downloaded to the client. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the BackupKeyResult object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse backupKey(String vaultBaseUrl, String keyName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.backupKey(vaultBaseUrl, keyName); + } + + /** + * Requests that a backup of the specified key be downloaded to the client. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall backupKey(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.backupKeyAsync(vaultBaseUrl, keyName, serviceCallback); + } + + /** + * Restores the backup key in to a vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyBundleBackup the backup blob associated with a key bundle + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.restoreKey(vaultBaseUrl, keyBundleBackup); + } + + /** + * Restores the backup key in to a vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyBundleBackup the backup blob associated with a key bundle + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall restoreKey(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.restoreKeyAsync(vaultBaseUrl, keyBundleBackup, serviceCallback); + } + + /** + * Encrypts a single block of data. The amount of data that may be encrypted is determined. + * + * @param keyIdentifier The full key identifier + * @param algorithm algorithm identifier + * @param value + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse encrypt(String keyIdentifier, String algorithm, byte[] value) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.encrypt(id.vault, id.name, id.version == null? "" : id.version, algorithm, value); + } + + /** + * Encrypts a single block of data. The amount of data that may be encrypted is determined. + * + * @param keyIdentifier The full key identifier + * @param algorithm algorithm identifier + * @param value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall encrypt(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.encryptAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); + } + + /** + * Decrypts a single block of encrypted data. + * + * @param keyIdentifier The full key identifier + * @param algorithm algorithm identifier + * @param value + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse decrypt(String keyIdentifier, String algorithm, byte[] value) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.decrypt(id.vault, id.name, id.version == null? "" : id.version, algorithm, value); + } + + /** + * Decrypts a single block of encrypted data. + * + * @param keyIdentifier The full key identifier + * @param algorithm algorithm identifier + * @param value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall decrypt(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.decryptAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); + } + + /** + * Creates a signature from a digest using the specified key in the vault. + * + * @param keyIdentifier The full key identifier + * @param algorithm algorithm identifier + * @param value + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse sign(String keyIdentifier, String algorithm, byte[] value) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.sign(id.vault, id.name, id.version == null? "" : id.version, algorithm, value); + } + + /** + * Creates a signature from a digest using the specified key in the vault. + * + * @param keyIdentifier The full key identifier + * @param algorithm algorithm identifier + * @param value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall sign(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.signAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); + } + + /** + * Verifies a signature using the specified key. + * + * @param keyIdentifier The full key identifier + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param digest The digest used for signing + * @param signature The signature to be verified + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse verify(String keyIdentifier, String algorithm, byte[] digest, byte[] signature) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.verify(id.vault, id.name, id.version == null? "" : id.version, algorithm, digest, signature); + } + + /** + * Verifies a signature using the specified key. + * + * @param keyIdentifier The full key identifier + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param digest The digest used for signing + * @param signature The signature to be verified + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall verify(String keyIdentifier, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.verifyAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, digest, signature, serviceCallback); + } + + /** + * Wraps a symmetric key using the specified key. + * + * @param keyIdentifier The full key identifier + * @param algorithm algorithm identifier + * @param value + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse wrapKey(String keyIdentifier, String algorithm, byte[] value) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.wrapKey(id.vault, id.name, id.version == null? "" : id.version, algorithm, value); + } + + /** + * Wraps a symmetric key using the specified key. + * + * @param keyIdentifier The full key identifier + * @param algorithm algorithm identifier + * @param value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall wrapKey(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.wrapKeyAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); + } + + /** + * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * + * @param keyIdentifier The full key identifier + * @param algorithm algorithm identifier + * @param value + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse unwrapKey(String keyIdentifier, String algorithm, byte[] value) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.unwrapKey(id.vault, id.name, id.version == null? "" : id.version, algorithm, value); + } + + /** + * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * + * @param keyIdentifier The full key identifier + * @param algorithm algorithm identifier + * @param value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall unwrapKey(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.unwrapKeyAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); + } + + /** + * Sets a secret in the specified vault. + * + * @param setSecretRequest the grouped properties for setting a secret request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse setSecret(SetSecretRequest setSecretRequest) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.setSecret( + setSecretRequest.vaultBaseUrl(), + setSecretRequest.secretName(), + setSecretRequest.value(), + setSecretRequest.tags(), + setSecretRequest.contentType(), + setSecretRequest.secretAttributes()); + } + + /** + * Sets a secret in the specified vault. + * + * @param setSecretRequest the grouped properties for setting a secret request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall setSecret(SetSecretRequest setSecretRequest, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.setSecretAsync( + setSecretRequest.vaultBaseUrl(), + setSecretRequest.secretName(), + setSecretRequest.value(), + setSecretRequest.tags(), + setSecretRequest.contentType(), + setSecretRequest.secretAttributes(), + serviceCallback); + } + + /** + * Deletes a secret from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.deleteSecret(vaultBaseUrl, secretName); + } + + /** + * Deletes a secret from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall deleteSecret(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.deleteSecretAsync(vaultBaseUrl, secretName, serviceCallback); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param updateSecretRequest the grouped properties for updating a secret request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateSecret(UpdateSecretRequest updateSecretRequest) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.updateSecret( + updateSecretRequest.vaultBaseUrl(), + updateSecretRequest.secretName(), + updateSecretRequest.secretVersion(), + updateSecretRequest.contentType(), + updateSecretRequest.secretAttributes(), + updateSecretRequest.tags()); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param updateSecretRequest the grouped properties for updating a secret request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall updateSecret(UpdateSecretRequest updateSecretRequest, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.updateSecretAsync( + updateSecretRequest.vaultBaseUrl(), + updateSecretRequest.secretName(), + updateSecretRequest.secretVersion(), + updateSecretRequest.contentType(), + updateSecretRequest.secretAttributes(), + updateSecretRequest.tags(), + serviceCallback); + } + + /** + * Gets a secret. + * + * @param secretIdentifier The URL for the secret. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getSecret(String secretIdentifier) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + SecretIdentifier id = new SecretIdentifier(secretIdentifier); + return innerKeyVaultClient.getSecret(id.vault, id.name, id.version == null? "" : id.version); + } + + /** + * Gets a secret. + * + * @param secretIdentifier The URL for the secret. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getSecret(String secretIdentifier, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + SecretIdentifier id = new SecretIdentifier(secretIdentifier); + return innerKeyVaultClient.getSecretAsync(id.vault, id.name, id.version == null? "" : id.version, serviceCallback); + } + + /** + * Gets a secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getSecret(String vaultBaseUrl, String secretName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, ""); + } + + /** + * Gets a secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getSecret(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getSecretAsync(vaultBaseUrl, secretName, "", serviceCallback); + } + + /** + * Gets a secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getSecret(String vaultBaseUrl, String secretName, String secretVersion) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, secretVersion == null? "" : secretVersion); + } + + /** + * Gets a secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getSecret(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getSecretAsync(vaultBaseUrl, secretName, secretVersion == null? "" : secretVersion, serviceCallback); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getSecrets(final String vaultBaseUrl) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecrets(vaultBaseUrl); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getSecrets(final String vaultBaseUrl, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, serviceCallback); + } + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of secrets to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecrets(vaultBaseUrl, maxresults); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of secrets to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getSecrets(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, maxresults, serviceCallback); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getSecretVersions(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, serviceCallback); + } + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param maxresults Maximum number of results to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName, maxresults); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, maxresults, serviceCallback); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificates(final String vaultBaseUrl) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificates(vaultBaseUrl); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificates(final String vaultBaseUrl, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, serviceCallback); + } + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificates(final String vaultBaseUrl, final Integer maxresults) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificates(vaultBaseUrl, maxresults); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificates(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, maxresults, serviceCallback); + } + + /** + * Deletes a certificate from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.deleteCertificate(vaultBaseUrl, certificateName); + } + + /** + * Deletes a certificate from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall deleteCertificate(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.deleteCertificateAsync(vaultBaseUrl, certificateName, serviceCallback); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param contacts Contacts. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the Contacts object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse setCertificateContacts(String vaultBaseUrl, Contacts contacts) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.setCertificateContacts(vaultBaseUrl, contacts); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param contacts Contacts. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall setCertificateContacts(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.setCertificateContactsAsync(vaultBaseUrl, contacts, serviceCallback); + } + + /** + * Gets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the Contacts object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getCertificateContacts(String vaultBaseUrl) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateContacts(vaultBaseUrl); + } + + /** + * Gets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificateContacts(String vaultBaseUrl, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificateContactsAsync(vaultBaseUrl, serviceCallback); + } + + /** + * Deletes the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the Contacts object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.deleteCertificateContacts(vaultBaseUrl); + } + + /** + * Deletes the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall deleteCertificateContacts(String vaultBaseUrl, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.deleteCertificateContactsAsync(vaultBaseUrl, serviceCallback); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificateIssuers(final String vaultBaseUrl, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, serviceCallback); + } + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl, maxresults); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, maxresults, serviceCallback); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param setCertificateIssuerRequest the grouped properties for setting a certificate issuer request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.setCertificateIssuer( + setCertificateIssuerRequest.vaultBaseUrl(), + setCertificateIssuerRequest.issuerName(), + setCertificateIssuerRequest.issuer()); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param setCertificateIssuerRequest the grouped properties for setting a certificate issuer request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.setCertificateIssuerAsync( + setCertificateIssuerRequest.vaultBaseUrl(), + setCertificateIssuerRequest.issuerName(), + setCertificateIssuerRequest.issuer(), + serviceCallback); + } + + /** + * Updates the specified certificate issuer. + * + * @param updateCertificateIssuerRequest the grouped properties for updating a certificate issuer request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateCertificateIssuer(UpdateCertificateIssuerRequest updateCertificateIssuerRequest) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.updateCertificateIssuer( + updateCertificateIssuerRequest.vaultBaseUrl(), + updateCertificateIssuerRequest.issuerName(), + updateCertificateIssuerRequest.issuer()); + } + + /** + * Updates the specified certificate issuer. + * + * @param updateCertificateIssuerRequest the grouped properties for updating a certificate issuer request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall updateCertificateIssuer(UpdateCertificateIssuerRequest updateCertificateIssuerRequest, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.updateCertificateIssuerAsync( + updateCertificateIssuerRequest.vaultBaseUrl(), + updateCertificateIssuerRequest.issuerName(), + updateCertificateIssuerRequest.issuer(), + serviceCallback); + } + + /** + * Gets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getCertificateIssuer(String vaultBaseUrl, String issuerName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateIssuer(vaultBaseUrl, issuerName); + } + + /** + * Gets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificateIssuer(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); + } + + /** + * Deletes the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl, String issuerName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.deleteCertificateIssuer(vaultBaseUrl, issuerName); + } + + /** + * Deletes the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall deleteCertificateIssuer(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.deleteCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param createCertificateRequest the grouped properties for creating a certificate request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse createCertificate(CreateCertificateRequest createCertificateRequest) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.createCertificate( + createCertificateRequest.vaultBaseUrl(), + createCertificateRequest.certificateName(), + createCertificateRequest.certificatePolicy(), + createCertificateRequest.certificateAttributes(), + createCertificateRequest.tags()); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param createCertificateRequest the grouped properties for creating a certificate request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall createCertificate(CreateCertificateRequest createCertificateRequest, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.createCertificateAsync( + createCertificateRequest.vaultBaseUrl(), + createCertificateRequest.certificateName(), + createCertificateRequest.certificatePolicy(), + createCertificateRequest.certificateAttributes(), + createCertificateRequest.tags(), + serviceCallback); + } + + /** + * Imports a certificate into the specified vault. + * + * @param importCertificateRequest the grouped properties for importing a certificate request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse importCertificate(ImportCertificateRequest importCertificateRequest) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.importCertificate( + importCertificateRequest.vaultBaseUrl(), + importCertificateRequest.certificateName(), + importCertificateRequest.base64EncodedCertificate(), + importCertificateRequest.certificatePolicy(), + importCertificateRequest.password(), + importCertificateRequest.certificateAttributes(), + importCertificateRequest.tags()); + } + + /** + * Imports a certificate into the specified vault. + * + * @param importCertificateRequest the grouped properties for importing a certificate request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall importCertificate(ImportCertificateRequest importCertificateRequest, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.importCertificateAsync( + importCertificateRequest.vaultBaseUrl(), + importCertificateRequest.certificateName(), + importCertificateRequest.base64EncodedCertificate(), + importCertificateRequest.certificatePolicy(), + importCertificateRequest.password(), + importCertificateRequest.certificateAttributes(), + importCertificateRequest.tags(), + serviceCallback); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificateVersions(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback); + } + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param maxresults Maximum number of results to return. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName, maxresults); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, maxresults, serviceCallback); + } + + /** + * Gets the policy for a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificatePolicy(vaultBaseUrl, certificateName); + } + + /** + * Gets the policy for a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificatePolicy(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificatePolicyAsync(vaultBaseUrl, certificateName, serviceCallback); + } + + /** + * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * + * @param updateCertificatePolicyRequest the grouped properties for updating a certificate policy request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.updateCertificatePolicy( + updateCertificatePolicyRequest.vaultBaseUrl(), + updateCertificatePolicyRequest.certificateName(), + updateCertificatePolicyRequest.certificatePolicy()); + } + + /** + * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * + * @param updateCertificatePolicyRequest the grouped properties for updating a certificate policy request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.updateCertificatePolicyAsync( + updateCertificatePolicyRequest.vaultBaseUrl(), + updateCertificatePolicyRequest.certificateName(), + updateCertificatePolicyRequest.certificatePolicy(), + serviceCallback); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param updateCertificateRequest the grouped properties for updating a certificate request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateCertificate(UpdateCertificateRequest updateCertificateRequest) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.updateCertificate( + updateCertificateRequest.vaultBaseUrl(), + updateCertificateRequest.certificateName(), + updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificateAttributes(), + updateCertificateRequest.tags()); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param updateCertificateRequest the grouped properties for updating a certificate request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall updateCertificate(UpdateCertificateRequest updateCertificateRequest, final ServiceCallback serviceCallback) + throws IllegalArgumentException{ + return innerKeyVaultClient.updateCertificateAsync( + updateCertificateRequest.vaultBaseUrl(), + updateCertificateRequest.certificateName(), + updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificateAttributes(), + updateCertificateRequest.tags(), + serviceCallback); + } + + /** + * Gets a Certificate. + * + * @param certificateIdentifier The certificate identifier + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getCertificate(String certificateIdentifier) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); + return innerKeyVaultClient.getCertificate(id.vault, id.name, id.version == null ? "" : id.version); + } + + /** + * Gets a Certificate. + * + * @param certificateIdentifier The certificate identifier + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificate(String certificateIdentifier, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); + return innerKeyVaultClient.getCertificateAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); + } + + /** + * Gets a Certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, ""); + } + + /** + * Gets a Certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificate(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificateAsync(vaultBaseUrl, certificateName, "", serviceCallback); + } + + /** + * Gets a Certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, certificateVersion); + } + + /** + * Gets a Certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, serviceCallback); + } + + /** + * Updates a certificate operation. + * + * @param updateCertificateOperationRequest the grouped properties for updating a certificate operation request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.updateCertificateOperation( + updateCertificateOperationRequest.vaultBaseUrl(), + updateCertificateOperationRequest.certificateName(), + updateCertificateOperationRequest.certificateOperation()); + } + + /** + * Updates a certificate operation. + * + * @param updateCertificateOperationRequest the grouped properties for updating a certificate operation request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.updateCertificateOperationAsync( + updateCertificateOperationRequest.vaultBaseUrl(), + updateCertificateOperationRequest.certificateName(), + updateCertificateOperationRequest.certificateOperation(), + serviceCallback); + } + + /** + * Gets the certificate operation response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateOperation(vaultBaseUrl, certificateName); + } + + /** + * Gets the certificate operation response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificateOperation(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificateOperationAsync(vaultBaseUrl, certificateName, serviceCallback); + } + + /** + * Deletes the certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.deleteCertificateOperation(vaultBaseUrl, certificateName); + } + + /** + * Deletes the certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + ServiceCall deleteCertificateOperation(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.deleteCertificateOperationAsync(vaultBaseUrl, certificateName, serviceCallback); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param mergeCertificateRequest the grouped properties for merging a certificate request + * + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse mergeCertificate(MergeCertificateRequest mergeCertificateRequest) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.mergeCertificate( + mergeCertificateRequest.vaultBaseUrl(), + mergeCertificateRequest.certificateName(), + mergeCertificateRequest.x509Certificates(), + mergeCertificateRequest.certificateAttributes(), + mergeCertificateRequest.tags()); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param mergeCertificateRequest the grouped properties for merging a certificate request + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall mergeCertificate(MergeCertificateRequest mergeCertificateRequest, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.mergeCertificateAsync( + mergeCertificateRequest.vaultBaseUrl(), + mergeCertificateRequest.certificateName(), + mergeCertificateRequest.x509Certificates(), + mergeCertificateRequest.certificateAttributes(), + mergeCertificateRequest.tags(), + serviceCallback); + } + + + /** + * Gets the pending certificate signing request response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the String object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return getPendingCertificateSigningRequestDelegate(call.execute()); + } + + /** + * Gets the pending certificate signing request response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) + throws IllegalArgumentException { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } + if (vaultBaseUrl == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); + return null; + } + if (certificateName == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); + return null; + } + if (this.apiVersion() == null) { + serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); + return null; + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + serviceCallback.success(getPendingCertificateSigningRequestDelegate(response)); + } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.failure(exception); + } + } + }); + return serviceCall; + } + + private ServiceResponse getPendingCertificateSigningRequestDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(innerKeyVaultClient.restClient().mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(KeyVaultErrorException.class) + .build(response); + } + + /** + * List the versions of the specified key. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getKeyVersionsNext(final String nextPageLink) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKeyVersionsNext(nextPageLink); + } + + /** + * List the versions of the specified key. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getKeyVersionsNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getKeyVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); + } + + /** + * List keys in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getKeysNext(final String nextPageLink) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKeysNext(nextPageLink); + } + + /** + * List keys in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getKeysNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getKeysNextAsync(nextPageLink, serviceCall, serviceCallback); + } + + /** + * List secrets in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getSecretsNext(final String nextPageLink) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecretsNext(nextPageLink); + } + + /** + * List secrets in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getSecretsNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getSecretsNextAsync(nextPageLink, serviceCall, serviceCallback); + } + + /** + * List the versions of the specified secret. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getSecretVersionsNext(final String nextPageLink) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecretVersionsNext(nextPageLink); + } + + /** + * List the versions of the specified secret. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getSecretVersionsNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getSecretVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); + } + + /** + * List certificates in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificatesNext(final String nextPageLink) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificatesNext(nextPageLink); + } + + /** + * List certificates in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificatesNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificatesNextAsync(nextPageLink, serviceCall, serviceCallback); + } + + /** + * List certificate issuers for the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateIssuersNext(nextPageLink); + } + + /** + * List certificate issuers for the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificateIssuersNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificateIssuersNextAsync(nextPageLink, serviceCall, serviceCallback); + } + + /** + * List the versions of a certificate. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateVersionsNext(nextPageLink); + } + + /** + * List the versions of a certificate. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if callback is null + * @return the {@link ServiceCall} object + */ + public ServiceCall getCertificateVersionsNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) + throws IllegalArgumentException { + return innerKeyVaultClient.getCertificateVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java similarity index 84% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultClientImpl.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java index 8e41001831050..aace9f252cda7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java @@ -4,19 +4,50 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.implementation; import com.google.common.base.Joiner; import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.AzureServiceResponseBuilder; +import com.microsoft.azure.keyvault.models.BackupKeyResult; +import com.microsoft.azure.keyvault.models.CertificateAttributes; +import com.microsoft.azure.keyvault.models.CertificateBundle; +import com.microsoft.azure.keyvault.models.CertificateCreateParameters; +import com.microsoft.azure.keyvault.models.CertificateImportParameters; +import com.microsoft.azure.keyvault.models.CertificateIssuerItem; +import com.microsoft.azure.keyvault.models.CertificateItem; +import com.microsoft.azure.keyvault.models.CertificateMergeParameters; +import com.microsoft.azure.keyvault.models.CertificateOperation; +import com.microsoft.azure.keyvault.models.CertificatePolicy; +import com.microsoft.azure.keyvault.models.CertificateUpdateParameters; +import com.microsoft.azure.keyvault.models.Contacts; +import com.microsoft.azure.keyvault.models.IssuerBundle; +import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.models.KeyAttributes; +import com.microsoft.azure.keyvault.models.KeyBundle; +import com.microsoft.azure.keyvault.models.KeyCreateParameters; +import com.microsoft.azure.keyvault.models.KeyImportParameters; +import com.microsoft.azure.keyvault.models.KeyItem; +import com.microsoft.azure.keyvault.models.KeyOperationResult; +import com.microsoft.azure.keyvault.models.KeyOperationsParameters; +import com.microsoft.azure.keyvault.models.KeyRestoreParameters; +import com.microsoft.azure.keyvault.models.KeyUpdateParameters; +import com.microsoft.azure.keyvault.models.KeyVaultErrorException; +import com.microsoft.azure.keyvault.models.KeyVerifyParameters; +import com.microsoft.azure.keyvault.models.KeyVerifyResult; +import com.microsoft.azure.keyvault.models.PageImpl; +import com.microsoft.azure.keyvault.models.SecretAttributes; +import com.microsoft.azure.keyvault.models.SecretBundle; +import com.microsoft.azure.keyvault.models.SecretItem; +import com.microsoft.azure.keyvault.models.SecretSetParameters; +import com.microsoft.azure.keyvault.models.SecretUpdateParameters; import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; +import com.microsoft.azure.RestClient; import com.microsoft.rest.credentials.ServiceClientCredentials; -import com.microsoft.rest.RestClient; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -25,6 +56,7 @@ import java.io.IOException; import java.util.List; import java.util.Map; + import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.Body; @@ -43,7 +75,7 @@ /** * Initializes a new instance of the KeyVaultClientImpl class. */ -public final class KeyVaultClientImpl extends AzureServiceClient { +final class KeyVaultClientImpl extends AzureServiceClient { /** The Retrofit service to perform REST calls. */ private KeyVaultClientService service; /** the {@link AzureClient} used for long running operations. */ @@ -144,7 +176,7 @@ public KeyVaultClientImpl withGenerateClientRequestId(boolean generateClientRequ * @param credentials the management credentials for Azure */ public KeyVaultClientImpl(ServiceClientCredentials credentials) { - this("{vaultBaseUrl}", credentials); + this("https://{vaultBaseUrl}", credentials); } /** @@ -154,8 +186,8 @@ public KeyVaultClientImpl(ServiceClientCredentials credentials) { * @param credentials the management credentials for Azure */ private KeyVaultClientImpl(String baseUrl, ServiceClientCredentials credentials) { - this(new RestClient.Builder(baseUrl) - .withMapperAdapter(new AzureJacksonMapperAdapter()) + this(new RestClient.Builder() + .withBaseUrl(baseUrl) .withCredentials(credentials) .build()); } @@ -294,7 +326,7 @@ interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/contacts") - Call setCertificateContacts(@Body ContactsInner contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call setCertificateContacts(@Body Contacts contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/contacts") @@ -310,11 +342,11 @@ interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/issuers/{issuer-name}") - Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundleInner issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/issuers/{issuer-name}") - Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundleInner issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers/{issuer-name}") @@ -342,7 +374,7 @@ interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/policy") - Call updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicyInner certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicy certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/{certificate-version}") @@ -354,7 +386,7 @@ interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/pending") - Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Body CertificateOperationInner certificateOperation, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Body CertificateOperation certificateOperation, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/pending") @@ -407,9 +439,9 @@ interface KeyVaultClientService { * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -424,7 +456,7 @@ public ServiceResponse createKey(String vaultBaseUrl, String key } final Integer keySize = null; final List keyOps = null; - final KeyAttributesInner keyAttributes = null; + final KeyAttributes keyAttributes = null; final Map tags = null; KeyCreateParameters parameters = new KeyCreateParameters(); parameters.withKty(kty); @@ -447,7 +479,7 @@ public ServiceResponse createKey(String vaultBaseUrl, String key * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -469,7 +501,7 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kt } final Integer keySize = null; final List keyOps = null; - final KeyAttributesInner keyAttributes = null; + final KeyAttributes keyAttributes = null; final Map tags = null; KeyCreateParameters parameters = new KeyCreateParameters(); parameters.withKty(kty); @@ -480,7 +512,7 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kt String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -500,15 +532,15 @@ public void onResponse(Call call, Response response) * @param keyName The name of the key * @param kty The type of key to create. For valid key types, see WebKeyTypes. * @param keySize Size of the key - * @param keyOps the List<String> value - * @param keyAttributes the KeyAttributesInner value + * @param keyOps + * @param keyAttributes * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributesInner keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -542,14 +574,14 @@ public ServiceResponse createKey(String vaultBaseUrl, String key * @param keyName The name of the key * @param kty The type of key to create. For valid key types, see WebKeyTypes. * @param keySize Size of the key - * @param keyOps the List<String> value - * @param keyAttributes the KeyAttributesInner value + * @param keyOps + * @param keyAttributes * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributesInner keyAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -581,7 +613,7 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kt String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -594,9 +626,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse createKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse createKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -610,9 +642,9 @@ private ServiceResponse createKeyDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKeyInner key) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -627,7 +659,7 @@ public ServiceResponse importKey(String vaultBaseUrl, String key } Validator.validate(key); final Boolean hsm = null; - final KeyAttributesInner keyAttributes = null; + final KeyAttributes keyAttributes = null; final Map tags = null; KeyImportParameters parameters = new KeyImportParameters(); parameters.withHsm(null); @@ -649,7 +681,7 @@ public ServiceResponse importKey(String vaultBaseUrl, String key * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyInner key, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -671,7 +703,7 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKe } Validator.validate(key, serviceCallback); final Boolean hsm = null; - final KeyAttributesInner keyAttributes = null; + final KeyAttributes keyAttributes = null; final Map tags = null; KeyImportParameters parameters = new KeyImportParameters(); parameters.withHsm(null); @@ -681,7 +713,7 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKe String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -706,9 +738,9 @@ public void onResponse(Call call, Response response) * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKeyInner key, Boolean hsm, KeyAttributesInner keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -747,7 +779,7 @@ public ServiceResponse importKey(String vaultBaseUrl, String key * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyInner key, Boolean hsm, KeyAttributesInner keyAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -778,7 +810,7 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKe String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -791,9 +823,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse importKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse importKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -806,9 +838,9 @@ private ServiceResponse importKeyDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -832,7 +864,7 @@ public ServiceResponse deleteKey(String vaultBaseUrl, String key * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -851,7 +883,7 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final Ser String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -864,9 +896,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse deleteKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse deleteKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -880,9 +912,9 @@ private ServiceResponse deleteKeyDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -896,7 +928,7 @@ public ServiceResponse updateKey(String vaultBaseUrl, String key throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final List keyOps = null; - final KeyAttributesInner keyAttributes = null; + final KeyAttributes keyAttributes = null; final Map tags = null; KeyUpdateParameters parameters = new KeyUpdateParameters(); parameters.withKeyOps(null); @@ -917,7 +949,7 @@ public ServiceResponse updateKey(String vaultBaseUrl, String key * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -938,7 +970,7 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String ke return null; } final List keyOps = null; - final KeyAttributesInner keyAttributes = null; + final KeyAttributes keyAttributes = null; final Map tags = null; KeyUpdateParameters parameters = new KeyUpdateParameters(); parameters.withKeyOps(null); @@ -947,7 +979,7 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String ke String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -967,14 +999,14 @@ public void onResponse(Call call, Response response) * @param keyName The name of the key * @param keyVersion The version of the key * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. - * @param keyAttributes the KeyAttributesInner value + * @param keyAttributes * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributesInner keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1006,13 +1038,13 @@ public ServiceResponse updateKey(String vaultBaseUrl, String key * @param keyName The name of the key * @param keyVersion The version of the key * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. - * @param keyAttributes the KeyAttributesInner value + * @param keyAttributes * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributesInner keyAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -1042,7 +1074,7 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String ke String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -1055,9 +1087,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse updateKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse updateKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -1071,9 +1103,9 @@ private ServiceResponse updateKeyDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1101,7 +1133,7 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyNam * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -1124,7 +1156,7 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVe String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -1137,9 +1169,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse getKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse getKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -1152,9 +1184,9 @@ private ServiceResponse getKeyDelegate(Response re * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1167,10 +1199,10 @@ public ServiceResponse> getKeyVersions(final String vaul final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeyVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeyVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getKeyVersionsNext(nextPageLink).getBody(); } }; @@ -1186,7 +1218,7 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExce * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -1206,11 +1238,11 @@ public ServiceCall getKeyVersionsAsync(final String vaultBaseUrl, final String k String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getKeyVersionsDelegate(response); + ServiceResponse> result = getKeyVersionsDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -1235,9 +1267,9 @@ public void onResponse(Call call, Response response) * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1249,10 +1281,10 @@ public ServiceResponse> getKeyVersions(final String vaul } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeyVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeyVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getKeyVersionsNext(nextPageLink).getBody(); } }; @@ -1269,7 +1301,7 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExce * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -1288,11 +1320,11 @@ public ServiceCall getKeyVersionsAsync(final String vaultBaseUrl, final String k String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getKeyVersionsDelegate(response); + ServiceResponse> result = getKeyVersionsDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -1308,9 +1340,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getKeyVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getKeyVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -1322,9 +1354,9 @@ private ServiceResponse> getKeyVersionsDelegate(Response< * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1334,10 +1366,10 @@ public ServiceResponse> getKeys(final String vaultBaseUr final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeysDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeysDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getKeysNext(nextPageLink).getBody(); } }; @@ -1352,7 +1384,7 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExce * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -1368,11 +1400,11 @@ public ServiceCall getKeysAsync(final String vaultBaseUrl, final ListOperationCa String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getKeysDelegate(response); + ServiceResponse> result = getKeysDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -1396,9 +1428,9 @@ public void onResponse(Call call, Response response) * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1407,10 +1439,10 @@ public ServiceResponse> getKeys(final String vaultBaseUr } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeysDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeysDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getKeysNext(nextPageLink).getBody(); } }; @@ -1426,7 +1458,7 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExce * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -1441,11 +1473,11 @@ public ServiceCall getKeysAsync(final String vaultBaseUrl, final Integer maxresu String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getKeysDelegate(response); + ServiceResponse> result = getKeysDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -1461,9 +1493,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getKeysDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getKeysDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -1476,9 +1508,9 @@ private ServiceResponse> getKeysDelegate(Response backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1502,7 +1534,7 @@ public ServiceResponse backupKey(String vaultBaseUrl, Stri * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -1521,7 +1553,7 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final Ser String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -1534,9 +1566,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse backupKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse backupKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -1549,9 +1581,9 @@ private ServiceResponse backupKeyDelegate(Response restoreKey(String vaultBaseUrl, String keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1577,7 +1609,7 @@ public ServiceResponse restoreKey(String vaultBaseUrl, String ke * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall restoreKeyAsync(String vaultBaseUrl, String keyBundleBackup, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -1598,7 +1630,7 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, String keyBundleBackup, String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -1611,9 +1643,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse restoreKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse restoreKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -1625,13 +1657,13 @@ private ServiceResponse restoreKeyDelegate(Response encrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse encrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1665,12 +1697,12 @@ public ServiceResponse encrypt(String vaultBaseUrl, Str * @param keyName The name of the key * @param keyVersion The version of the key * @param algorithm algorithm identifier - * @param value the String value + * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -1704,7 +1736,7 @@ public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyV String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -1717,9 +1749,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse encryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse encryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -1731,13 +1763,13 @@ private ServiceResponse encryptDelegate(Response decrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse decrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1771,12 +1803,12 @@ public ServiceResponse decrypt(String vaultBaseUrl, Str * @param keyName The name of the key * @param keyVersion The version of the key * @param algorithm algorithm identifier - * @param value the String value + * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -1810,7 +1842,7 @@ public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyV String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -1823,9 +1855,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse decryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse decryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -1837,13 +1869,13 @@ private ServiceResponse decryptDelegate(Response sign(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse sign(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1877,12 +1909,12 @@ public ServiceResponse sign(String vaultBaseUrl, String * @param keyName The name of the key * @param keyVersion The version of the key * @param algorithm algorithm identifier - * @param value the String value + * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -1916,7 +1948,7 @@ public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVers String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -1929,9 +1961,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse signDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse signDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -1948,9 +1980,9 @@ private ServiceResponse signDelegate(Response verify(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String digest, String signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse verify(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1994,7 +2026,7 @@ public ServiceResponse verify(String vaultBaseUrl, String * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String digest, String signature, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -2033,7 +2065,7 @@ public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVe String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -2046,9 +2078,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse verifyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse verifyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -2060,13 +2092,13 @@ private ServiceResponse verifyDelegate(Response wrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse wrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2100,12 +2132,12 @@ public ServiceResponse wrapKey(String vaultBaseUrl, Str * @param keyName The name of the key * @param keyVersion The version of the key * @param algorithm algorithm identifier - * @param value the String value + * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -2139,7 +2171,7 @@ public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyV String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -2152,9 +2184,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse wrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse wrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -2166,13 +2198,13 @@ private ServiceResponse wrapKeyDelegate(Response unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2206,12 +2238,12 @@ public ServiceResponse unwrapKey(String vaultBaseUrl, S * @param keyName The name of the key * @param keyVersion The version of the key * @param algorithm algorithm identifier - * @param value the String value + * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -2245,7 +2277,7 @@ public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String ke String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -2258,9 +2290,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse unwrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse unwrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -2274,9 +2306,9 @@ private ServiceResponse unwrapKeyDelegate(Response setSecret(String vaultBaseUrl, String secretName, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse setSecret(String vaultBaseUrl, String secretName, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2291,7 +2323,7 @@ public ServiceResponse setSecret(String vaultBaseUrl, String } final Map tags = null; final String contentType = null; - final SecretAttributesInner secretAttributes = null; + final SecretAttributes secretAttributes = null; SecretSetParameters parameters = new SecretSetParameters(); parameters.withValue(value); parameters.withTags(null); @@ -2312,7 +2344,7 @@ public ServiceResponse setSecret(String vaultBaseUrl, String * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -2334,7 +2366,7 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String } final Map tags = null; final String contentType = null; - final SecretAttributesInner secretAttributes = null; + final SecretAttributes secretAttributes = null; SecretSetParameters parameters = new SecretSetParameters(); parameters.withValue(value); parameters.withTags(null); @@ -2343,7 +2375,7 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -2364,13 +2396,13 @@ public void onResponse(Call call, Response response) * @param value The value of the secret * @param tags Application-specific metadata in the form of key-value pairs * @param contentType Type of the secret value such as a password - * @param secretAttributes the SecretAttributesInner value + * @param secretAttributes The secret management attributes * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributesInner secretAttributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2403,12 +2435,12 @@ public ServiceResponse setSecret(String vaultBaseUrl, String * @param value The value of the secret * @param tags Application-specific metadata in the form of key-value pairs * @param contentType Type of the secret value such as a password - * @param secretAttributes the SecretAttributesInner value + * @param secretAttributes The secret management attributes * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributesInner secretAttributes, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -2438,7 +2470,7 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -2451,9 +2483,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse setSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse setSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -2466,9 +2498,9 @@ private ServiceResponse setSecretDelegate(Response deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2492,7 +2524,7 @@ public ServiceResponse deleteSecret(String vaultBaseUrl, Stri * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -2511,7 +2543,7 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, fin String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -2524,9 +2556,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse deleteSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse deleteSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -2540,9 +2572,9 @@ private ServiceResponse deleteSecretDelegate(Response updateSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2556,7 +2588,7 @@ public ServiceResponse updateSecret(String vaultBaseUrl, Stri throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final String contentType = null; - final SecretAttributesInner secretAttributes = null; + final SecretAttributes secretAttributes = null; final Map tags = null; SecretUpdateParameters parameters = new SecretUpdateParameters(); parameters.withContentType(null); @@ -2577,7 +2609,7 @@ public ServiceResponse updateSecret(String vaultBaseUrl, Stri * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -2598,7 +2630,7 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, Str return null; } final String contentType = null; - final SecretAttributesInner secretAttributes = null; + final SecretAttributes secretAttributes = null; final Map tags = null; SecretUpdateParameters parameters = new SecretUpdateParameters(); parameters.withContentType(null); @@ -2607,7 +2639,7 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, Str String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -2627,14 +2659,14 @@ public void onResponse(Call call, Response response) * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret * @param contentType Type of the secret value such as a password - * @param secretAttributes the SecretAttributesInner value + * @param secretAttributes The secret management attributes * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributesInner secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2665,13 +2697,13 @@ public ServiceResponse updateSecret(String vaultBaseUrl, Stri * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret * @param contentType Type of the secret value such as a password - * @param secretAttributes the SecretAttributesInner value + * @param secretAttributes The secret management attributes * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributesInner secretAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -2700,7 +2732,7 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, Str String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -2713,9 +2745,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse updateSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse updateSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -2729,9 +2761,9 @@ private ServiceResponse updateSecretDelegate(Response getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2759,7 +2791,7 @@ public ServiceResponse getSecret(String vaultBaseUrl, String * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -2782,7 +2814,7 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -2795,9 +2827,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse getSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse getSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -2809,9 +2841,9 @@ private ServiceResponse getSecretDelegate(Response> getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2821,10 +2853,10 @@ public ServiceResponse> getSecrets(final String vault final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getSecretsNext(nextPageLink).getBody(); } }; @@ -2839,7 +2871,7 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -2855,11 +2887,11 @@ public ServiceCall getSecretsAsync(final String vaultBaseUrl, final ListOperatio String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getSecretsDelegate(response); + ServiceResponse> result = getSecretsDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -2883,9 +2915,9 @@ public void onResponse(Call call, Response response) * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2894,10 +2926,10 @@ public ServiceResponse> getSecrets(final String vault } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getSecretsNext(nextPageLink).getBody(); } }; @@ -2913,7 +2945,7 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -2928,11 +2960,11 @@ public ServiceCall getSecretsAsync(final String vaultBaseUrl, final Integer maxr String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getSecretsDelegate(response); + ServiceResponse> result = getSecretsDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -2948,9 +2980,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getSecretsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getSecretsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -2963,9 +2995,9 @@ private ServiceResponse> getSecretsDelegate(Response> getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2978,10 +3010,10 @@ public ServiceResponse> getSecretVersions(final Strin final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getSecretVersionsNext(nextPageLink).getBody(); } }; @@ -2997,7 +3029,7 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3017,11 +3049,11 @@ public ServiceCall getSecretVersionsAsync(final String vaultBaseUrl, final Strin String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getSecretVersionsDelegate(response); + ServiceResponse> result = getSecretVersionsDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -3046,9 +3078,9 @@ public void onResponse(Call call, Response response) * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3060,10 +3092,10 @@ public ServiceResponse> getSecretVersions(final Strin } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getSecretVersionsNext(nextPageLink).getBody(); } }; @@ -3080,7 +3112,7 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3099,11 +3131,11 @@ public ServiceCall getSecretVersionsAsync(final String vaultBaseUrl, final Strin String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getSecretVersionsDelegate(response); + ServiceResponse> result = getSecretVersionsDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -3119,9 +3151,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getSecretVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getSecretVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -3133,9 +3165,9 @@ private ServiceResponse> getSecretVersionsDelegate(Res * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3145,10 +3177,10 @@ public ServiceResponse> getCertificates(final St final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificatesDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificatesDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getCertificatesNext(nextPageLink).getBody(); } }; @@ -3163,7 +3195,7 @@ public Page nextPage(String nextPageLink) throws KeyVaultE * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3179,11 +3211,11 @@ public ServiceCall getCertificatesAsync(final String vaultBaseUrl, final ListOpe String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getCertificatesDelegate(response); + ServiceResponse> result = getCertificatesDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -3207,9 +3239,9 @@ public void onResponse(Call call, Response response) * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3218,10 +3250,10 @@ public ServiceResponse> getCertificates(final St } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificatesDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificatesDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getCertificatesNext(nextPageLink).getBody(); } }; @@ -3237,7 +3269,7 @@ public Page nextPage(String nextPageLink) throws KeyVaultE * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3252,11 +3284,11 @@ public ServiceCall getCertificatesAsync(final String vaultBaseUrl, final Integer String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getCertificatesDelegate(response); + ServiceResponse> result = getCertificatesDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -3272,9 +3304,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getCertificatesDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getCertificatesDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -3287,9 +3319,9 @@ private ServiceResponse> getCertificatesDelegate( * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3313,7 +3345,7 @@ public ServiceResponse deleteCertificate(String vaultBas * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3332,7 +3364,7 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificat String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -3345,9 +3377,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse deleteCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse deleteCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -3360,9 +3392,9 @@ private ServiceResponse deleteCertificateDelegate(Respon * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the ContactsInner object wrapped in {@link ServiceResponse} if successful. + * @return the Contacts object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setCertificateContacts(String vaultBaseUrl, ContactsInner contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3387,7 +3419,7 @@ public ServiceResponse setCertificateContacts(String vaultBaseUrl * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, ContactsInner contacts, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3407,7 +3439,7 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, ContactsInne String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -3420,9 +3452,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse setCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse setCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -3434,9 +3466,9 @@ private ServiceResponse setCertificateContactsDelegate(Response getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3456,7 +3488,7 @@ public ServiceResponse getCertificateContacts(String vaultBaseUrl * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3471,7 +3503,7 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final Servic String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -3484,9 +3516,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse getCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse getCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -3498,9 +3530,9 @@ private ServiceResponse getCertificateContactsDelegate(Response deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3520,7 +3552,7 @@ public ServiceResponse deleteCertificateContacts(String vaultBase * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3535,7 +3567,7 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final Ser String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -3548,9 +3580,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse deleteCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse deleteCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -3562,9 +3594,9 @@ private ServiceResponse deleteCertificateContactsDelegate(Respons * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateIssuerItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3574,10 +3606,10 @@ public ServiceResponse> getCertificateIssu final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getCertificateIssuersNext(nextPageLink).getBody(); } }; @@ -3592,7 +3624,7 @@ public Page nextPage(String nextPageLink) throws Key * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3608,11 +3640,11 @@ public ServiceCall getCertificateIssuersAsync(final String vaultBaseUrl, final L String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getCertificateIssuersDelegate(response); + ServiceResponse> result = getCertificateIssuersDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -3636,9 +3668,9 @@ public void onResponse(Call call, Response response) * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateIssuerItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3647,10 +3679,10 @@ public ServiceResponse> getCertificateIssu } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getCertificateIssuersNext(nextPageLink).getBody(); } }; @@ -3666,7 +3698,7 @@ public Page nextPage(String nextPageLink) throws Key * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3681,11 +3713,11 @@ public ServiceCall getCertificateIssuersAsync(final String vaultBaseUrl, final I String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getCertificateIssuersDelegate(response); + ServiceResponse> result = getCertificateIssuersDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -3701,9 +3733,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getCertificateIssuersDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getCertificateIssuersDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -3717,9 +3749,9 @@ private ServiceResponse> getCertificateIssu * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundleInner issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundle issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3748,7 +3780,7 @@ public ServiceResponse setCertificateIssuer(String vaultBaseU * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundleInner issuer, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3772,7 +3804,7 @@ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerN String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -3785,9 +3817,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse setCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse setCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -3801,9 +3833,9 @@ private ServiceResponse setCertificateIssuerDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundleInner issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundle issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3832,7 +3864,7 @@ public ServiceResponse updateCertificateIssuer(String vaultBa * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundleInner issuer, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3856,7 +3888,7 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issu String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -3869,9 +3901,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse updateCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse updateCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -3884,9 +3916,9 @@ private ServiceResponse updateCertificateIssuerDelegate(Respo * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3910,7 +3942,7 @@ public ServiceResponse getCertificateIssuer(String vaultBaseU * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -3929,7 +3961,7 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerN String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -3942,9 +3974,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse getCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse getCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -3957,9 +3989,9 @@ private ServiceResponse getCertificateIssuerDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3983,7 +4015,7 @@ public ServiceResponse deleteCertificateIssuer(String vaultBa * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4002,7 +4034,7 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issu String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -4015,9 +4047,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse deleteCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse deleteCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -4031,9 +4063,9 @@ private ServiceResponse deleteCertificateIssuerDelegate(Respo * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperationInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicyInner certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4047,7 +4079,7 @@ public ServiceResponse createCertificate(String vault throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); } Validator.validate(certificatePolicy); - final CertificateAttributesInner certificateAttributes = null; + final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateCreateParameters parameters = new CertificateCreateParameters(); parameters.withCertificatePolicy(certificatePolicy); @@ -4068,7 +4100,7 @@ public ServiceResponse createCertificate(String vault * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicyInner certificatePolicy, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4089,7 +4121,7 @@ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificat return null; } Validator.validate(certificatePolicy, serviceCallback); - final CertificateAttributesInner certificateAttributes = null; + final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateCreateParameters parameters = new CertificateCreateParameters(); parameters.withCertificatePolicy(certificatePolicy); @@ -4098,7 +4130,7 @@ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificat String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -4122,9 +4154,9 @@ public void onResponse(Call call, Response response) * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperationInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicyInner certificatePolicy, CertificateAttributesInner certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4161,7 +4193,7 @@ public ServiceResponse createCertificate(String vault * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicyInner certificatePolicy, CertificateAttributesInner certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4191,7 +4223,7 @@ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificat String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -4204,9 +4236,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse createCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(202, new TypeToken() { }.getType()) + private ServiceResponse createCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(202, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -4216,15 +4248,14 @@ private ServiceResponse createCertificateDelegate(Res * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param base64EncodedCertificate Base64 encoded representaion of the certificate object to import. This certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @param certificatePolicy The management policy for the certificate * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicyInner certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4237,18 +4268,16 @@ public ServiceResponse importCertificate(String vaultBas if (base64EncodedCertificate == null) { throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); } - if (password == null) { - throw new IllegalArgumentException("Parameter password is required and cannot be null."); - } if (certificatePolicy == null) { throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); } Validator.validate(certificatePolicy); - final CertificateAttributesInner certificateAttributes = null; + final String password = null; + final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateImportParameters parameters = new CertificateImportParameters(); parameters.withBase64EncodedCertificate(base64EncodedCertificate); - parameters.withPassword(password); + parameters.withPassword(null); parameters.withCertificatePolicy(certificatePolicy); parameters.withCertificateAttributes(null); parameters.withTags(null); @@ -4262,14 +4291,13 @@ public ServiceResponse importCertificate(String vaultBas * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param base64EncodedCertificate Base64 encoded representaion of the certificate object to import. This certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @param certificatePolicy The management policy for the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicyInner certificatePolicy, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4289,27 +4317,24 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificat serviceCallback.failure(new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null.")); return null; } - if (password == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter password is required and cannot be null.")); - return null; - } if (certificatePolicy == null) { serviceCallback.failure(new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null.")); return null; } Validator.validate(certificatePolicy, serviceCallback); - final CertificateAttributesInner certificateAttributes = null; + final String password = null; + final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateImportParameters parameters = new CertificateImportParameters(); parameters.withBase64EncodedCertificate(base64EncodedCertificate); - parameters.withPassword(password); + parameters.withPassword(null); parameters.withCertificatePolicy(certificatePolicy); parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -4327,17 +4352,17 @@ public void onResponse(Call call, Response response) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param base64EncodedCertificate Base64 encoded representaion of the certificate object to import. This certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @param certificatePolicy The management policy for the certificate + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicyInner certificatePolicy, CertificateAttributesInner certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, CertificatePolicy certificatePolicy, String password, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4350,9 +4375,6 @@ public ServiceResponse importCertificate(String vaultBas if (base64EncodedCertificate == null) { throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); } - if (password == null) { - throw new IllegalArgumentException("Parameter password is required and cannot be null."); - } if (certificatePolicy == null) { throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); } @@ -4375,16 +4397,16 @@ public ServiceResponse importCertificate(String vaultBas * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param base64EncodedCertificate Base64 encoded representaion of the certificate object to import. This certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @param certificatePolicy The management policy for the certificate + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicyInner certificatePolicy, CertificateAttributesInner certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, CertificatePolicy certificatePolicy, String password, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4404,10 +4426,6 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificat serviceCallback.failure(new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null.")); return null; } - if (password == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter password is required and cannot be null.")); - return null; - } if (certificatePolicy == null) { serviceCallback.failure(new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null.")); return null; @@ -4424,7 +4442,7 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificat String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -4437,9 +4455,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse importCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse importCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -4452,9 +4470,9 @@ private ServiceResponse importCertificateDelegate(Respon * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4467,10 +4485,10 @@ public ServiceResponse> getCertificateVersions(f final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getCertificateVersionsNext(nextPageLink).getBody(); } }; @@ -4486,7 +4504,7 @@ public Page nextPage(String nextPageLink) throws KeyVaultE * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4506,11 +4524,11 @@ public ServiceCall getCertificateVersionsAsync(final String vaultBaseUrl, final String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getCertificateVersionsDelegate(response); + ServiceResponse> result = getCertificateVersionsDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -4535,9 +4553,9 @@ public void onResponse(Call call, Response response) * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4549,10 +4567,10 @@ public ServiceResponse> getCertificateVersions(f } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { return getCertificateVersionsNext(nextPageLink).getBody(); } }; @@ -4569,7 +4587,7 @@ public Page nextPage(String nextPageLink) throws KeyVaultE * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4588,11 +4606,11 @@ public ServiceCall getCertificateVersionsAsync(final String vaultBaseUrl, final String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getCertificateVersionsDelegate(response); + ServiceResponse> result = getCertificateVersionsDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -4608,9 +4626,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getCertificateVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getCertificateVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -4623,9 +4641,9 @@ private ServiceResponse> getCertificateVersionsDe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificatePolicyInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4649,7 +4667,7 @@ public ServiceResponse getCertificatePolicy(String vault * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4668,7 +4686,7 @@ public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certifi String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -4681,9 +4699,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse getCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse getCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -4697,9 +4715,9 @@ private ServiceResponse getCertificatePolicyDelegate(Res * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificatePolicyInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicyInner certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4728,7 +4746,7 @@ public ServiceResponse updateCertificatePolicy(String va * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicyInner certificatePolicy, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4752,7 +4770,7 @@ public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String cert String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -4765,9 +4783,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse updateCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse updateCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -4781,9 +4799,9 @@ private ServiceResponse updateCertificatePolicyDelegate( * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4796,7 +4814,7 @@ public ServiceResponse updateCertificate(String vaultBas if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - final CertificateAttributesInner certificateAttributes = null; + final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateUpdateParameters parameters = new CertificateUpdateParameters(); parameters.withCertificateAttributes(null); @@ -4816,7 +4834,7 @@ public ServiceResponse updateCertificate(String vaultBas * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4836,7 +4854,7 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificat serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - final CertificateAttributesInner certificateAttributes = null; + final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateUpdateParameters parameters = new CertificateUpdateParameters(); parameters.withCertificateAttributes(null); @@ -4844,7 +4862,7 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificat String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -4868,9 +4886,9 @@ public void onResponse(Call call, Response response) * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributesInner certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4905,7 +4923,7 @@ public ServiceResponse updateCertificate(String vaultBas * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributesInner certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4933,7 +4951,7 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificat String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -4946,9 +4964,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse updateCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse updateCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -4962,9 +4980,9 @@ private ServiceResponse updateCertificateDelegate(Respon * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4992,7 +5010,7 @@ public ServiceResponse getCertificate(String vaultBaseUr * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5015,7 +5033,7 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateNa String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5028,9 +5046,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse getCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse getCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -5044,9 +5062,9 @@ private ServiceResponse getCertificateDelegate(Response< * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperationInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificateOperation(String vaultBaseUrl, String certificateName, CertificateOperationInner certificateOperation) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateCertificateOperation(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5075,7 +5093,7 @@ public ServiceResponse updateCertificateOperation(Str * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, CertificateOperationInner certificateOperation, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5099,7 +5117,7 @@ public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String c String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5112,9 +5130,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse updateCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse updateCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -5127,9 +5145,9 @@ private ServiceResponse updateCertificateOperationDel * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperationInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5153,7 +5171,7 @@ public ServiceResponse getCertificateOperation(String * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5172,7 +5190,7 @@ public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String cert String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5185,9 +5203,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse getCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse getCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -5200,9 +5218,9 @@ private ServiceResponse getCertificateOperationDelega * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperationInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5226,7 +5244,7 @@ public ServiceResponse deleteCertificateOperation(Str * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5245,7 +5263,7 @@ public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String c String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5258,9 +5276,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse deleteCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) + private ServiceResponse deleteCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -5270,13 +5288,13 @@ private ServiceResponse deleteCertificateOperationDel * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificte chain to merge + * @param x509Certificates The certificate or the certificate chain to merge * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5290,7 +5308,7 @@ public ServiceResponse mergeCertificate(String vaultBase throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); } Validator.validate(x509Certificates); - final CertificateAttributesInner certificateAttributes = null; + final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateMergeParameters parameters = new CertificateMergeParameters(); parameters.withX509Certificates(x509Certificates); @@ -5306,12 +5324,12 @@ public ServiceResponse mergeCertificate(String vaultBase * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificte chain to merge + * @param x509Certificates The certificate or the certificate chain to merge * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5332,7 +5350,7 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificate return null; } Validator.validate(x509Certificates, serviceCallback); - final CertificateAttributesInner certificateAttributes = null; + final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateMergeParameters parameters = new CertificateMergeParameters(); parameters.withX509Certificates(x509Certificates); @@ -5341,7 +5359,7 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificate String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5359,15 +5377,15 @@ public void onResponse(Call call, Response response) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificte chain to merge + * @param x509Certificates The certificate or the certificate chain to merge * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundleInner object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributesInner certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5397,14 +5415,14 @@ public ServiceResponse mergeCertificate(String vaultBase * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificte chain to merge + * @param x509Certificates The certificate or the certificate chain to merge * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributesInner certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5434,7 +5452,7 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificate String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5447,9 +5465,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse mergeCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.restClient().mapperAdapter()) - .register(201, new TypeToken() { }.getType()) + private ServiceResponse mergeCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.mapperAdapter()) + .register(201, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -5461,9 +5479,9 @@ private ServiceResponse mergeCertificateDelegate(Respons * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } @@ -5480,7 +5498,7 @@ public ServiceResponse> getKeyVersionsNext(final String n * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5490,11 +5508,11 @@ public ServiceCall getKeyVersionsNextAsync(final String nextPageLink, final Serv } Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getKeyVersionsNextDelegate(response); + ServiceResponse> result = getKeyVersionsNextDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -5510,9 +5528,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getKeyVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getKeyVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -5524,9 +5542,9 @@ private ServiceResponse> getKeyVersionsNextDelegate(Respo * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } @@ -5543,7 +5561,7 @@ public ServiceResponse> getKeysNext(final String nextPage * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeysNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getKeysNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5553,11 +5571,11 @@ public ServiceCall getKeysNextAsync(final String nextPageLink, final ServiceCall } Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getKeysNextDelegate(response); + ServiceResponse> result = getKeysNextDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -5573,9 +5591,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getKeysNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getKeysNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -5587,9 +5605,9 @@ private ServiceResponse> getKeysNextDelegate(Response> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } @@ -5606,7 +5624,7 @@ public ServiceResponse> getSecretsNext(final String ne * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getSecretsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5616,11 +5634,11 @@ public ServiceCall getSecretsNextAsync(final String nextPageLink, final ServiceC } Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getSecretsNextDelegate(response); + ServiceResponse> result = getSecretsNextDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -5636,9 +5654,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getSecretsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getSecretsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -5650,9 +5668,9 @@ private ServiceResponse> getSecretsNextDelegate(Respon * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } @@ -5669,7 +5687,7 @@ public ServiceResponse> getSecretVersionsNext(final St * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5679,11 +5697,11 @@ public ServiceCall getSecretVersionsNextAsync(final String nextPageLink, final S } Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getSecretVersionsNextDelegate(response); + ServiceResponse> result = getSecretVersionsNextDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -5699,9 +5717,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getSecretVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getSecretVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -5713,9 +5731,9 @@ private ServiceResponse> getSecretVersionsNextDelegate * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } @@ -5732,7 +5750,7 @@ public ServiceResponse> getCertificatesNext(final * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificatesNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificatesNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5742,11 +5760,11 @@ public ServiceCall getCertificatesNextAsync(final String nextPageLink, final Ser } Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getCertificatesNextDelegate(response); + ServiceResponse> result = getCertificatesNextDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -5762,9 +5780,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getCertificatesNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getCertificatesNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -5776,9 +5794,9 @@ private ServiceResponse> getCertificatesNextDeleg * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateIssuerItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } @@ -5795,7 +5813,7 @@ public ServiceResponse> getCertificateIssue * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5805,11 +5823,11 @@ public ServiceCall getCertificateIssuersNextAsync(final String nextPageLink, fin } Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getCertificateIssuersNextDelegate(response); + ServiceResponse> result = getCertificateIssuersNextDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -5825,9 +5843,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getCertificateIssuersNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getCertificateIssuersNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } @@ -5839,9 +5857,9 @@ private ServiceResponse> getCertificateIssu * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItemInner> object wrapped in {@link ServiceResponse} if successful. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } @@ -5858,7 +5876,7 @@ public ServiceResponse> getCertificateVersionsNex * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -5868,11 +5886,11 @@ public ServiceCall getCertificateVersionsNextAsync(final String nextPageLink, fi } Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - ServiceResponse> result = getCertificateVersionsNextDelegate(response); + ServiceResponse> result = getCertificateVersionsNextDelegate(response); serviceCallback.load(result.getBody().getItems()); if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { @@ -5888,9 +5906,9 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse> getCertificateVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.restClient().mapperAdapter()) - .register(200, new TypeToken>() { }.getType()) + private ServiceResponse> getCertificateVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/ObjectIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/ObjectIdentifier.java new file mode 100644 index 0000000000000..c564a8db45dd4 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/ObjectIdentifier.java @@ -0,0 +1,185 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.implementation; + +import java.net.URI; +import java.net.URISyntaxException; +import java.security.InvalidParameterException; + +public class ObjectIdentifier { + + protected static boolean isObjectIdentifier(String collection, String identifier) { + + collection = verifyNonEmpty(collection, "collection"); + identifier = verifyNonEmpty(identifier, "identifier"); + + URI baseUri; + try { + baseUri = new URI(identifier); + } catch (URISyntaxException e) { + return false; + } + + // Path is of the form "/collection/name[/version]" + String[] segments = baseUri.getPath().split("/"); + if (segments.length != 3 && segments.length != 4) { + return false; + } + + if (!collection.equals(segments[1])) { + return false; + } + + return true; + } + + protected static String verifyNonEmpty(String value, String argName) { + if (value != null) { + value = value.trim(); + if (value.isEmpty()) { + value = null; + } + } + if (value == null) { + throw new IllegalArgumentException(argName); + } + return value; + } + + protected String vault; + protected String name; + protected String version; + protected String baseIdentifier; + protected String identifier; + + protected ObjectIdentifier() { + } + + protected ObjectIdentifier(String vault, String collection, String name) { + this(vault, collection, name, null); + } + + protected ObjectIdentifier(String vault, String collection, String name, String version) { + + vault = verifyNonEmpty(vault, "vault"); + collection = verifyNonEmpty(collection, "collection"); + name = verifyNonEmpty(name, "name"); + + if (version != null) { + version = version.trim(); + } + else version = ""; + + URI baseUri; + try { + baseUri = new URI(vault); + } catch (URISyntaxException e) { + throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. Not a valid URI", vault)); + } + + this.name = name; + this.version = version; + this.vault = String.format("%s://%s", baseUri.getScheme(), getFullAuthority(baseUri)); + baseIdentifier = String.format("%s/%s/%s", this.vault, collection, this.name); + identifier = (version == null || version.isEmpty()) ? baseIdentifier : String.format("%s/%s", baseIdentifier, version); + } + + protected ObjectIdentifier(String collection, String identifier) { + + if (collection == null || collection.length() == 0) { + throw new IllegalArgumentException("collection"); + } + + if (identifier == null || identifier.length() == 0) { + throw new IllegalArgumentException("identifier"); + } + + URI baseUri; + try { + baseUri = new URI(identifier); + } catch (URISyntaxException e) { + throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. Not a valid URI", identifier)); + } + + // Path is of the form "/collection/name[/version]" + String[] segments = baseUri.getPath().split("/"); + if (segments.length != 3 && segments.length != 4) { + throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. Bad number of segments: %d", identifier, segments.length)); + } + + if (!collection.equals(segments[1])) { + throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. segment [1] should be '%s', found '%s'", identifier, collection, segments[1])); + } + + name = segments[2]; + version = segments.length == 4 ? segments[3] : null; + vault = String.format("%s://%s", baseUri.getScheme(), getFullAuthority(baseUri)); + baseIdentifier = String.format("%s/%s/%s", vault, collection, name); + this.identifier = (version == null || version.equals("")) ? baseIdentifier : String.format("%s/%s", baseIdentifier, version); + } + + protected String getFullAuthority(URI uri) { + String authority = uri.getAuthority(); + if (!authority.contains(":") && uri.getPort() > 0) { + // Append port for complete authority + authority = String.format("%s:%d", uri.getAuthority(), uri.getPort()); + } + return authority; + } + + /** + * The base identifier for an object, does not include the object version. + */ + public String baseIdentifier() { + return baseIdentifier; + } + + /** + * The identifier for an object, includes the objects version. + */ + public String identifier() { + return identifier; + } + + /** + * The name of the object. + */ + public String name() { + return name; + } + + /** + * The vault containing the object + */ + public String vault() { + return vault; + } + + /** + * The version of the object. + */ + public String version() { + return version; + } + + @Override + public String toString() { + return identifier; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/SecretIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/SecretIdentifier.java new file mode 100644 index 0000000000000..477304b1024d8 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/SecretIdentifier.java @@ -0,0 +1,37 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.implementation; + +public final class SecretIdentifier extends ObjectIdentifier { + public static boolean isSecretIdentifier(String identifier) { + return ObjectIdentifier.isObjectIdentifier("secrets", identifier); + } + + public SecretIdentifier(String vault, String name) { + this(vault, name, ""); + } + + public SecretIdentifier(String vault, String name, String version) { + super(vault, "secrets", name, version); + } + + public SecretIdentifier(String identifier) { + super("secrets", identifier); + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/JsonWebKeyInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/JsonWebKeyInner.java deleted file mode 100644 index 9e7d28f008142..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/JsonWebKeyInner.java +++ /dev/null @@ -1,343 +0,0 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.azure.keyvault.implementation.api; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The JsonWebKeyInner model. - */ -public class JsonWebKeyInner { - /** - * Key Identifier. - */ - private String kid; - - /** - * Key type, usually RSA. - */ - private String kty; - - /** - * The keyOps property. - */ - @JsonProperty(value = "key_ops") - private List keyOps; - - /** - * RSA modulus. - */ - private String n; - - /** - * RSA public exponent. - */ - private String e; - - /** - * RSA private exponent. - */ - private String d; - - /** - */ - private String dp; - - /** - * The dq property. - */ - private String dq; - - /** - * The qi property. - */ - private String qi; - - /** - * The p property. - */ - private String p; - - /** - * The q property. - */ - private String q; - - /** - * Symmetric key. - */ - @JsonProperty(value = "K") - private String k; - - /** - * HSM Token, used with Bring Your Own Key. - */ - @JsonProperty(value = "key_hsm") - private String t; - - /** - * Get the kid value. - * - * @return the kid value - */ - public String kid() { - return this.kid; - } - - /** - * Set the kid value. - * - * @param kid the kid value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withKid(String kid) { - this.kid = kid; - return this; - } - - /** - * Get the kty value. - * - * @return the kty value - */ - public String kty() { - return this.kty; - } - - /** - * Set the kty value. - * - * @param kty the kty value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withKty(String kty) { - this.kty = kty; - return this; - } - - /** - * Get the keyOps value. - * - * @return the keyOps value - */ - public List keyOps() { - return this.keyOps; - } - - /** - * Set the keyOps value. - * - * @param keyOps the keyOps value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withKeyOps(List keyOps) { - this.keyOps = keyOps; - return this; - } - - /** - * Get the n value. - * - * @return the n value - */ - public String n() { - return this.n; - } - - /** - * Set the n value. - * - * @param n the n value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withN(String n) { - this.n = n; - return this; - } - - /** - * Get the e value. - * - * @return the e value - */ - public String e() { - return this.e; - } - - /** - * Set the e value. - * - * @param e the e value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withE(String e) { - this.e = e; - return this; - } - - /** - * Get the d value. - * - * @return the d value - */ - public String d() { - return this.d; - } - - /** - * Set the d value. - * - * @param d the d value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withD(String d) { - this.d = d; - return this; - } - - /** - * Get the dp value. - * - * @return the dp value - */ - public String dp() { - return this.dp; - } - - /** - * Set the dp value. - * - * @param dp the dp value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withDp(String dp) { - this.dp = dp; - return this; - } - - /** - * Get the dq value. - * - * @return the dq value - */ - public String dq() { - return this.dq; - } - - /** - * Set the dq value. - * - * @param dq the dq value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withDq(String dq) { - this.dq = dq; - return this; - } - - /** - * Get the qi value. - * - * @return the qi value - */ - public String qi() { - return this.qi; - } - - /** - * Set the qi value. - * - * @param qi the qi value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withQi(String qi) { - this.qi = qi; - return this; - } - - /** - * Get the p value. - * - * @return the p value - */ - public String p() { - return this.p; - } - - /** - * Set the p value. - * - * @param p the p value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withP(String p) { - this.p = p; - return this; - } - - /** - * Get the q value. - * - * @return the q value - */ - public String q() { - return this.q; - } - - /** - * Set the q value. - * - * @param q the q value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withQ(String q) { - this.q = q; - return this; - } - - /** - * Get the k value. - * - * @return the k value - */ - public String k() { - return this.k; - } - - /** - * Set the k value. - * - * @param k the k value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withK(String k) { - this.k = k; - return this; - } - - /** - * Get the t value. - * - * @return the t value - */ - public String t() { - return this.t; - } - - /** - * Set the t value. - * - * @param t the t value to set - * @return the JsonWebKeyInner object itself. - */ - public JsonWebKeyInner withT(String t) { - this.t = t; - return this; - } - -} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyBundleInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyBundleInner.java deleted file mode 100644 index 766e84baf74ba..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyBundleInner.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.azure.keyvault.implementation.api; - -import java.util.Map; - -/** - * The KeyBundleInner model. - */ -public class KeyBundleInner { - /** - * The Json web key. - */ - private JsonWebKeyInner key; - - /** - * The key management attributes. - */ - private KeyAttributesInner attributes; - - /** - * Application-specific metadata in the form of key-value pairs. - */ - private Map tags; - - /** - * Get the key value. - * - * @return the key value - */ - public JsonWebKeyInner key() { - return this.key; - } - - /** - * Set the key value. - * - * @param key the key value to set - * @return the KeyBundleInner object itself. - */ - public KeyBundleInner withKey(JsonWebKeyInner key) { - this.key = key; - return this; - } - - /** - * Get the attributes value. - * - * @return the attributes value - */ - public KeyAttributesInner attributes() { - return this.attributes; - } - - /** - * Set the attributes value. - * - * @param attributes the attributes value to set - * @return the KeyBundleInner object itself. - */ - public KeyBundleInner withAttributes(KeyAttributesInner attributes) { - this.attributes = attributes; - return this; - } - - /** - * Get the tags value. - * - * @return the tags value - */ - public Map tags() { - return this.tags; - } - - /** - * Set the tags value. - * - * @param tags the tags value to set - * @return the KeyBundleInner object itself. - */ - public KeyBundleInner withTags(Map tags) { - this.tags = tags; - return this; - } - -} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/OrganizationDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/OrganizationDetails.java deleted file mode 100644 index cda130a7302e7..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/OrganizationDetails.java +++ /dev/null @@ -1,218 +0,0 @@ -/** - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.azure.keyvault.implementation.api; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The OrganizationDetails model. - */ -public class OrganizationDetails { - /** - * Name of the organization. - */ - private String name; - - /** - * Address line 1. - */ - private String address1; - - /** - * Address line 2. - */ - private String address2; - - /** - * City. - */ - private String city; - - /** - * Zipcode. - */ - @JsonProperty(value = "zip") - private String zipcode; - - /** - * State. - */ - private String state; - - /** - * Country. - */ - private String country; - - /** - * Details of the organization administrator. - */ - @JsonProperty(value = "AdministratorDetails") - private List administratorDetails; - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the OrganizationDetails object itself. - */ - public OrganizationDetails withName(String name) { - this.name = name; - return this; - } - - /** - * Get the address1 value. - * - * @return the address1 value - */ - public String address1() { - return this.address1; - } - - /** - * Set the address1 value. - * - * @param address1 the address1 value to set - * @return the OrganizationDetails object itself. - */ - public OrganizationDetails withAddress1(String address1) { - this.address1 = address1; - return this; - } - - /** - * Get the address2 value. - * - * @return the address2 value - */ - public String address2() { - return this.address2; - } - - /** - * Set the address2 value. - * - * @param address2 the address2 value to set - * @return the OrganizationDetails object itself. - */ - public OrganizationDetails withAddress2(String address2) { - this.address2 = address2; - return this; - } - - /** - * Get the city value. - * - * @return the city value - */ - public String city() { - return this.city; - } - - /** - * Set the city value. - * - * @param city the city value to set - * @return the OrganizationDetails object itself. - */ - public OrganizationDetails withCity(String city) { - this.city = city; - return this; - } - - /** - * Get the zipcode value. - * - * @return the zipcode value - */ - public String zipcode() { - return this.zipcode; - } - - /** - * Set the zipcode value. - * - * @param zipcode the zipcode value to set - * @return the OrganizationDetails object itself. - */ - public OrganizationDetails withZipcode(String zipcode) { - this.zipcode = zipcode; - return this; - } - - /** - * Get the state value. - * - * @return the state value - */ - public String state() { - return this.state; - } - - /** - * Set the state value. - * - * @param state the state value to set - * @return the OrganizationDetails object itself. - */ - public OrganizationDetails withState(String state) { - this.state = state; - return this; - } - - /** - * Get the country value. - * - * @return the country value - */ - public String country() { - return this.country; - } - - /** - * Set the country value. - * - * @param country the country value to set - * @return the OrganizationDetails object itself. - */ - public OrganizationDetails withCountry(String country) { - this.country = country; - return this; - } - - /** - * Get the administratorDetails value. - * - * @return the administratorDetails value - */ - public List administratorDetails() { - return this.administratorDetails; - } - - /** - * Set the administratorDetails value. - * - * @param administratorDetails the administratorDetails value to set - * @return the OrganizationDetails object itself. - */ - public OrganizationDetails withAdministratorDetails(List administratorDetails) { - this.administratorDetails = administratorDetails; - return this; - } - -} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateCertificateRequest.java new file mode 100644 index 0000000000000..555902980c169 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateCertificateRequest.java @@ -0,0 +1,182 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Map; + +import com.microsoft.azure.keyvault.models.CertificateAttributes; +import com.microsoft.azure.keyvault.models.CertificatePolicy; +import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.KeyProperties; +import com.microsoft.azure.keyvault.models.LifetimeAction; +import com.microsoft.azure.keyvault.models.SecretProperties; +import com.microsoft.azure.keyvault.models.X509CertificateProperties; + +public class CreateCertificateRequest { + private final String vaultBaseUrl; + private final String certificateName; + private final CertificatePolicy certificatePolicy; + private final CertificateAttributes certificateAttributes; + private final Map tags; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String certificateName; + + // Optional parameters + private CertificatePolicy policy; + private CertificateAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link CreateCertificateRequest} object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName + * The name of the certificate in the given vault + */ + public Builder(String vaultBaseUrl, String certificateName) { + this.vaultBaseUrl = vaultBaseUrl; + this.certificateName = certificateName; + } + + /** + * Set the certificatePolicy value. Mandatory if sending the create request + * for the first time + * + * @param certificatePolicy + * The management policy for the certificate. + * @return the Builder object itself. + */ + public Builder withCertificatePolicy(CertificatePolicy certificatePolicy) { + this.policy = certificatePolicy; + return this; + } + + /** + * Set the attributes value. + * + * @param attributes + * The attributes of the certificate. + * @return the Builder object itself. + */ + public Builder withAttributes(CertificateAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link CreateCertificateRequest} object + */ + public CreateCertificateRequest build() { + return new CreateCertificateRequest(this); + } + } + + private CreateCertificateRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + certificateName = builder.certificateName; + + if (builder.attributes != null) { + certificateAttributes = (CertificateAttributes) new CertificateAttributes() + .withNotBefore(builder.attributes.notBefore()) + .withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()); + } else { + certificateAttributes = null; + } + + if (builder.policy != null) { + certificatePolicy = new CertificatePolicy(); + if (builder.policy.attributes() != null) { + certificatePolicy.withAttributes((CertificateAttributes) new CertificateAttributes() + .withEnabled(builder.policy.attributes().enabled()) + .withExpires(builder.policy.attributes().expires()) + .withNotBefore(builder.policy.attributes().notBefore())); + } + if (builder.policy.issuerReference() != null) { + certificatePolicy.withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); + } + if (builder.policy.x509CertificateProperties() != null) { + certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() + .withValidityInMonths(builder.policy.x509CertificateProperties().validityInMonths()) + .withSubjectAlternativeNames(builder.policy.x509CertificateProperties().subjectAlternativeNames()) + .withSubject(builder.policy.x509CertificateProperties().subject()) + .withEkus(builder.policy.x509CertificateProperties().ekus()) + .withKeyUsage(builder.policy.x509CertificateProperties().keyUsage())); + } + if (builder.policy.lifetimeActions() != null) { + certificatePolicy.withLifetimeActions(new ArrayList(builder.policy.lifetimeActions())); + } + if (builder.policy.keyProperties() != null) { + certificatePolicy.withKeyProperties(new KeyProperties() + .withExportable(builder.policy.keyProperties().exportable()) + .withKeySize(builder.policy.keyProperties().keySize()) + .withKeyType(builder.policy.keyProperties().keyType()) + .withReuseKey(builder.policy.keyProperties().reuseKey())); + } + if (builder.policy.secretProperties() != null) { + certificatePolicy.withSecretProperties( + new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); + } + } else { + certificatePolicy = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } + } + + /** + * @return the vault base url + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the certificate name + */ + public String certificateName() { + return certificateName; + } + + /** + * @return the certificate policy + */ + public CertificatePolicy certificatePolicy() { + return certificatePolicy; + } + + /** + * @return the certificate attributes + */ + public CertificateAttributes certificateAttributes() { + return certificateAttributes; + } + + /** + * @return the tags + */ + public Map tags() { + return tags; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateKeyRequest.java new file mode 100644 index 0000000000000..23a2c464056c9 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateKeyRequest.java @@ -0,0 +1,182 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import com.microsoft.azure.keyvault.models.KeyAttributes; + +public class CreateKeyRequest { + + private final String vaultBaseUrl; + private final String keyName; + private final String keyType; + private final Integer keySize; + private final List keyOperations; + private final KeyAttributes keyAttributes; + private final Map tags; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String keyName; + private final String keyType; + + // Optional parameters + private Integer keySize; + private List keyOperations; + private KeyAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link CreateKeyRequest} object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param keyName + * The name of the key in the given vault + * @param keyType + * The type of key to create. For valid key types, see + * {@link WebKeyTypes}. + */ + public Builder(String vaultBaseUrl, String keyName, String keyType) { + this.vaultBaseUrl = vaultBaseUrl; + this.keyName = keyName; + this.keyType = keyType; + } + + /** + * Set the key size value. + * + * @param size + * the size of the key + * @return the Builder object itself. + */ + public Builder withKeySize(Integer size) { + this.keySize = size; + return this; + } + + /** + * Set the key operations value. + * + * @param size + * the size of the key + * @return the Builder object itself. + */ + public Builder withKeyOperations(List keyOps) { + this.keyOperations = keyOps; + return this; + } + + /** + * Set the key attributes value. + * + * @param attributes + * the key management attributes value to set + * @return the Builder object itself. + */ + public Builder withAttributes(KeyAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link CreateKeyRequest} object + */ + public CreateKeyRequest build() { + return new CreateKeyRequest(this); + } + } + + private CreateKeyRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + keyName = builder.keyName; + keyType = builder.keyType; + keySize = builder.keySize; + + if (builder.keyOperations != null) { + keyOperations = new ArrayList(builder.keyOperations); + } else { + keyOperations = null; + } + + if (builder.attributes != null) { + keyAttributes = (KeyAttributes) new KeyAttributes() + .withNotBefore(builder.attributes.notBefore()) + .withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()); + } else { + keyAttributes = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } + } + + /** + * @return the vault base url + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the key name + */ + public String keyName() { + return keyName; + } + + /** + * @return the key type + */ + public String keyType() { + return keyType; + } + + /** + * @return the key size + */ + public Integer keySize() { + return keySize; + } + + /** + * @return the key operations + */ + public List keyOperations() { + return keyOperations; + } + + /** + * @return the key attributes + */ + public KeyAttributes keyAttributes() { + return keyAttributes; + } + + /** + * @return the tags + */ + public Map tags() { + return tags; + } +} \ No newline at end of file diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportCertificateRequest.java new file mode 100644 index 0000000000000..3b3ac0b615dec --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportCertificateRequest.java @@ -0,0 +1,217 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Map; + +import com.microsoft.azure.keyvault.models.CertificateAttributes; +import com.microsoft.azure.keyvault.models.CertificatePolicy; +import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.KeyProperties; +import com.microsoft.azure.keyvault.models.LifetimeAction; +import com.microsoft.azure.keyvault.models.SecretProperties; +import com.microsoft.azure.keyvault.models.X509CertificateProperties; + +public class ImportCertificateRequest { + private final String vaultBaseUrl; + private final String certificateName; + private final String base64EncodedCertificate; + private final String password; + private final CertificatePolicy certificatePolicy; + private final CertificateAttributes certificateAttributes; + private final Map tags; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String certificateName; + private final String base64EncodedCertificate; + + // Optional parameters + private String password; + private CertificatePolicy policy; + private CertificateAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link ImportCertificateRequest} object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName + * The name of the certificate in the given vault + * @param base64EncodedCertificate + * Base64 encoded representation of the certificate object to + * import. This certificate needs to contain the private key. + */ + public Builder(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { + this.vaultBaseUrl = vaultBaseUrl; + this.certificateName = certificateName; + this.base64EncodedCertificate = base64EncodedCertificate; + } + + /** + * Set the password + * + * @param password + * If the private key in base64EncodedCertificate is encrypted, the + * password used for encryption + * @return the Builder object itself. + */ + public Builder withPassword(String password) { + this.password = password; + return this; + } + + /** + * Set the certificate policy + * + * @param policy + * The management policy for the certificate + * @return the Builder object itself. + */ + public Builder withPolicy(CertificatePolicy policy) { + this.policy = policy; + return this; + } + + /** + * Set the certificate attributes + * + * @param attributes + * The attributes of the certificate + * @return the Builder object itself. + */ + public Builder withAttributes(CertificateAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link ImportCertificateRequest} object + */ + public ImportCertificateRequest build() { + return new ImportCertificateRequest(this); + } + } + + private ImportCertificateRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + certificateName = builder.certificateName; + base64EncodedCertificate = builder.base64EncodedCertificate; + password = builder.password; + + if (builder.attributes != null) + certificateAttributes = (CertificateAttributes) new CertificateAttributes() + .withNotBefore(builder.attributes.notBefore()) + .withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()); + else + certificateAttributes = null; + + if (builder.policy != null) { + certificatePolicy = new CertificatePolicy(); + if (builder.policy.attributes() != null) { + certificatePolicy.withAttributes((CertificateAttributes) new CertificateAttributes() + .withEnabled(builder.policy.attributes().enabled()) + .withExpires(builder.policy.attributes().expires()) + .withNotBefore(builder.policy.attributes().notBefore())); + } + if (builder.policy.issuerReference() != null) { + certificatePolicy.withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); + } + if (builder.policy.x509CertificateProperties() != null) { + certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() + .withValidityInMonths(builder.policy.x509CertificateProperties().validityInMonths()) + .withSubjectAlternativeNames(builder.policy.x509CertificateProperties().subjectAlternativeNames()) + .withSubject(builder.policy.x509CertificateProperties().subject()) + .withEkus(builder.policy.x509CertificateProperties().ekus()) + .withKeyUsage(builder.policy.x509CertificateProperties().keyUsage())); + } + if (builder.policy.lifetimeActions() != null) { + certificatePolicy.withLifetimeActions(new ArrayList(builder.policy.lifetimeActions())); + } + if (builder.policy.keyProperties() != null) { + certificatePolicy.withKeyProperties(new KeyProperties() + .withExportable(builder.policy.keyProperties().exportable()) + .withKeySize(builder.policy.keyProperties().keySize()) + .withKeyType(builder.policy.keyProperties().keyType()) + .withReuseKey(builder.policy.keyProperties().reuseKey())); + } + if (builder.policy.secretProperties() != null) { + certificatePolicy.withSecretProperties( + new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); + } + } else { + certificatePolicy = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } + } + + /** + * @return the vault base url + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the certificate name + */ + public String certificateName() { + return certificateName; + } + + /** + * @return the base64 encoded certificate + */ + public String base64EncodedCertificate() { + return base64EncodedCertificate; + } + + /** + * @return the password + */ + public String password() { + return password; + } + + /** + * @return the certificatePolicy + */ + public CertificatePolicy certificatePolicy() { + return certificatePolicy; + } + + /** + * @return the certificateAttributes + */ + public CertificateAttributes certificateAttributes() { + return certificateAttributes; + } + + /** + * @return the tags + */ + public Map tags() { + return tags; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportKeyRequest.java new file mode 100644 index 0000000000000..7862870103949 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportKeyRequest.java @@ -0,0 +1,175 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Map; + +import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.models.KeyAttributes; + +public class ImportKeyRequest { + + private final String vaultBaseUrl; + private final String keyName; + private final JsonWebKey key; + private final boolean isHsm; + private final KeyAttributes keyAttributes; + private final Map tags; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String keyName; + private final JsonWebKey key; + + // Optional parameters + private boolean isHsm; + private KeyAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link ImportKeyRequest} object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param keyName + * The name of the key in the given vault + * @param key + * The Json web key. + */ + public Builder(String vaultBaseUrl, String keyName, JsonWebKey key) { + this.vaultBaseUrl = vaultBaseUrl; + this.keyName = keyName; + this.key = key; + } + + /** + * Set the isHsm to true if the key is imported as a hardware key to HSM, + * false otherwise. + * + * @param size + * the size of the key + * @return the Builder object itself. + */ + public Builder withHsm(boolean isHsm) { + this.isHsm = isHsm; + return this; + } + + /** + * Set the key attributes value. + * + * @param attributes + * the key management attributes value to set + * @return the Builder object itself. + */ + public Builder withAttributes(KeyAttributes value) { + this.attributes = value; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link ImportKeyRequest} object + */ + public ImportKeyRequest build() { + return new ImportKeyRequest(this); + } + } + + private ImportKeyRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + keyName = builder.keyName; + isHsm = builder.isHsm; + + if (builder.key != null) { + key = new JsonWebKey() + .withKty(builder.key.kty()) + .withN(builder.key.n()) + .withE(builder.key.e()) + .withD(builder.key.d()) + .withP(builder.key.p()) + .withQ(builder.key.q()) + .withDp(builder.key.dp()) + .withDq(builder.key.dq()) + .withQi(builder.key.qi()) + .withK(builder.key.k()) + .withT(builder.key.t()); + if (builder.key.keyOps() != null) { + key.withKeyOps(new ArrayList(builder.key.keyOps())); + } + } else { + key = null; + } + + if (builder.attributes != null) { + keyAttributes = (KeyAttributes) new KeyAttributes() + .withNotBefore(builder.attributes.notBefore()) + .withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()); + } else { + keyAttributes = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } + } + + /** + * @return the vault base url + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the key name + */ + public String keyName() { + return keyName; + } + + /** + * @return the key + */ + public JsonWebKey key() { + return key; + } + + /** + * @return the isHsm + */ + public boolean isHsm() { + return isHsm; + } + + /** + * @return the key attribute + */ + public KeyAttributes keyAttributes() { + return keyAttributes; + } + + /** + * @return the tags + */ + public Map tags() { + return tags; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/MergeCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/MergeCertificateRequest.java new file mode 100644 index 0000000000000..708dc6ee19236 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/MergeCertificateRequest.java @@ -0,0 +1,130 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import com.microsoft.azure.keyvault.models.CertificateAttributes; + +public class MergeCertificateRequest { + private final String vaultBaseUrl; + private final String certificateName; + private final List x509Certificates; + private final CertificateAttributes certificateAttributes; + private final Map tags; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String certificateName; + private final List x509Certificates; + + // Optional parameters + private CertificateAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link MergeCertificateRequest} object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName + * The name of the certificate in the given vault + * @param x509Certificates + * The certificate or the certificate chain to merge + */ + public Builder(String vaultBaseUrl, String certificateName, List x509Certificates) { + this.vaultBaseUrl = vaultBaseUrl; + this.certificateName = certificateName; + this.x509Certificates = x509Certificates; + } + + /** + * Set the attributes value. + * + * @param attributes + * The attributes of the certificate. + * @return the Builder object itself. + */ + public Builder withAttributes(CertificateAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link MergeCertificateRequest} object + */ + public MergeCertificateRequest build() { + return new MergeCertificateRequest(this); + } + } + + private MergeCertificateRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + certificateName = builder.certificateName; + x509Certificates = new ArrayList(builder.x509Certificates); + + if (builder.attributes != null) { + certificateAttributes = (CertificateAttributes) new CertificateAttributes() + .withNotBefore(builder.attributes.notBefore()) + .withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()); + } else { + certificateAttributes = null; + } + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } + } + + /** + * @return the vault base url + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the certificate name + */ + public String certificateName() { + return certificateName; + } + + /** + * @return the x509 certificates + */ + public List x509Certificates() { + return x509Certificates; + } + + /** + * @return the certificate attributes + */ + public CertificateAttributes certificateAttributes() { + return certificateAttributes; + } + + /** + * @return the tags + */ + public Map tags() { + return tags; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetCertificateIssuerRequest.java new file mode 100644 index 0000000000000..9a45b5233c24b --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetCertificateIssuerRequest.java @@ -0,0 +1,92 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import com.microsoft.azure.keyvault.models.IssuerAttributes; +import com.microsoft.azure.keyvault.models.IssuerBundle; + +public class SetCertificateIssuerRequest { + + private final String vaultBaseUrl; + private final String issuerName; + private final IssuerBundle issuer; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String issuerName; + + // Optional parameters + private IssuerBundle issuer; + + /** + * The builder for constructing {@link SetCertificateIssuerRequest} object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName + * The name of the issuer. + */ + public Builder(String vaultBaseUrl, String issuerName) { + this.vaultBaseUrl = vaultBaseUrl; + this.issuerName = issuerName; + } + + /** + * Set the issuer value. + * + * @param issuer + * The issuer bundle. + * @return the Builder object itself. + */ + public Builder withIssuer(IssuerBundle issuer) { + this.issuer = issuer; + return this; + } + + /** + * builds the {@link SetCertificateIssuerRequest} object + */ + public SetCertificateIssuerRequest build() { + return new SetCertificateIssuerRequest(this); + } + } + + private SetCertificateIssuerRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + issuerName = builder.issuerName; + if (builder.issuer != null) { + issuer = new IssuerBundle() + .withProvider(builder.issuer.provider()) + .withOrganizationDetails(builder.issuer.organizationDetails()) + .withCredentials(builder.issuer.credentials()); + if (builder.issuer.attributes() != null) { + issuer.withAttributes(new IssuerAttributes() + .withEnabled(builder.issuer.attributes().enabled())); + } + } else { + issuer = null; + } + } + + /** + * @return the vault base url + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the issuer name + */ + public String issuerName() { + return issuerName; + } + + /** + * @return the issuer + */ + public IssuerBundle issuer() { + return issuer; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetSecretRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetSecretRequest.java new file mode 100644 index 0000000000000..f6bebdb17199e --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetSecretRequest.java @@ -0,0 +1,152 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import java.util.Collections; +import java.util.Map; + +import com.microsoft.azure.keyvault.models.SecretAttributes; + +public class SetSecretRequest { + private final String vaultBaseUrl; + private final String secretName; + private final String value; + private final String contentType; + private final SecretAttributes secretAttributes; + private final Map tags; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String secretName; + private final String value; + + // Optional parameters + private String contentType; + private SecretAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link SetSecretRequest} object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param secretName + * The name of the secret in the given vault + * @param value + * The value of the secret + */ + public Builder(String vaultBaseUrl, String secretName, String value) { + this.vaultBaseUrl = vaultBaseUrl; + this.secretName = secretName; + this.value = value; + } + + /** + * Set the content type value. + * + * @param contentType + * Type of the secret value such as a password + * @return the Builder object itself. + */ + public Builder withContentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the attributes value. + * + * @param attributes + * The secret management attributes. + * @return the Builder object itself. + */ + public Builder withAttributes(SecretAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link SetSecretRequest} object + */ + public SetSecretRequest build() { + return new SetSecretRequest(this); + } + } + + private SetSecretRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + secretName = builder.secretName; + value = builder.value; + contentType = builder.contentType; + + if (builder.attributes != null) { + secretAttributes = (SecretAttributes) new SecretAttributes() + .withNotBefore(builder.attributes.notBefore()) + .withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()); + } else { + secretAttributes = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } + } + + /** + * @return the vaultBaseUrl + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the secretName + */ + public String secretName() { + return secretName; + } + + /** + * @return the value + */ + public String value() { + return value; + } + + /** + * @return the contentType + */ + public String contentType() { + return contentType; + } + + /** + * @return the secretAttributes + */ + public SecretAttributes secretAttributes() { + return secretAttributes; + } + + /** + * @return the tags + */ + public Map tags() { + return tags; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateIssuerRequest.java new file mode 100644 index 0000000000000..c1a9f151e16c9 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateIssuerRequest.java @@ -0,0 +1,92 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import com.microsoft.azure.keyvault.models.IssuerAttributes; +import com.microsoft.azure.keyvault.models.IssuerBundle; + +public class UpdateCertificateIssuerRequest { + private final String vaultBaseUrl; + private final String issuerName; + private final IssuerBundle issuer; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String issuerName; + + // Optional parameters + private IssuerBundle issuer; + + /** + * The builder for constructing {@link UpdateCertificateIssuerRequest} + * object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName + * The name of the issuer in the given vault + */ + public Builder(String vaultBaseUrl, String issuerName) { + this.vaultBaseUrl = vaultBaseUrl; + this.issuerName = issuerName; + } + + /** + * Set the issuer value. + * + * @param issuer + * The issuer bundle. + * @return the Builder object itself. + */ + public Builder withIssuer(IssuerBundle issuer) { + this.issuer = issuer; + return this; + } + + /** + * builds the {@link UpdateCertificateIssuerRequest} object + */ + public UpdateCertificateIssuerRequest build() { + return new UpdateCertificateIssuerRequest(this); + } + } + + private UpdateCertificateIssuerRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + issuerName = builder.issuerName; + + if (builder.issuer != null) { + issuer = new IssuerBundle() + .withProvider(builder.issuer.provider()) + .withOrganizationDetails(builder.issuer.organizationDetails()) + .withCredentials(builder.issuer.credentials()); + if (builder.issuer.attributes() != null) { + issuer.withAttributes(new IssuerAttributes() + .withEnabled(builder.issuer.attributes().enabled())); + } + } else { + issuer = null; + } + } + + /** + * @return the vault base url + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the issuer name + */ + public String issuerName() { + return issuerName; + } + + /** + * @return the issuer + */ + public IssuerBundle issuer() { + return issuer; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateOperationRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateOperationRequest.java new file mode 100644 index 0000000000000..406e619809471 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateOperationRequest.java @@ -0,0 +1,83 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import com.microsoft.azure.keyvault.models.CertificateOperation; + +public class UpdateCertificateOperationRequest { + private final String vaultBaseUrl; + private final String certificateName; + private final CertificateOperation certificateOperation; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String certificateName; + + // Optional parameters + private Boolean cancellationRequested; + + /** + * The builder for constructing {@link CreateCertificateRequest} object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName + * The name of the certificate in the given vault + */ + public Builder(String vaultBaseUrl, String certificateName) { + this.vaultBaseUrl = vaultBaseUrl; + this.certificateName = certificateName; + } + + /** + * Set the cancellationRequested value. + * + * @param cancellationRequested + * Indicates if cancellation was requested on the certificate + * operation. + * @return the Builder object itself. + */ + public Builder withCancellationRequested(Boolean cancellationRequested) { + this.cancellationRequested = cancellationRequested; + return this; + } + + /** + * builds the {@link UpdateCertificateOperationRequest} object + */ + public UpdateCertificateOperationRequest build() { + return new UpdateCertificateOperationRequest(this); + } + } + + private UpdateCertificateOperationRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + certificateName = builder.certificateName; + if (builder.cancellationRequested != null) { + certificateOperation = new CertificateOperation().withCancellationRequested(builder.cancellationRequested); + } else { + certificateOperation = null; + } + } + + /** + * @return the vault base url + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the certificate name + */ + public String certificateName() { + return certificateName; + } + + /** + * @return the certificate policy + */ + public CertificateOperation certificateOperation() { + return certificateOperation; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificatePolicyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificatePolicyRequest.java new file mode 100644 index 0000000000000..934946eadc4ed --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificatePolicyRequest.java @@ -0,0 +1,123 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import java.util.ArrayList; + +import com.microsoft.azure.keyvault.models.CertificateAttributes; +import com.microsoft.azure.keyvault.models.CertificatePolicy; +import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.KeyProperties; +import com.microsoft.azure.keyvault.models.LifetimeAction; +import com.microsoft.azure.keyvault.models.SecretProperties; +import com.microsoft.azure.keyvault.models.X509CertificateProperties; + +public class UpdateCertificatePolicyRequest { + private final String vaultBaseUrl; + private final String certificateName; + private final CertificatePolicy certificatePolicy; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String certificateName; + + // Optional parameters + private CertificatePolicy policy; + + /** + * The builder for constructing {@link UpdateCertificatePolicyRequest} + * object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName + * The name of the certificate in the given vault + */ + public Builder(String vaultBaseUrl, String certificateName) { + this.vaultBaseUrl = vaultBaseUrl; + this.certificateName = certificateName; + } + + /** + * Set the certificatePolicy value. + * + * @param certificatePolicy + * The management policy for the certificate. + * @return the Builder object itself. + */ + public Builder withCertificatePolicy(CertificatePolicy certificatePolicy) { + this.policy = certificatePolicy; + return this; + } + + /** + * builds the {@link UpdateCertificatePolicyRequest} object + */ + public UpdateCertificatePolicyRequest build() { + return new UpdateCertificatePolicyRequest(this); + } + } + + private UpdateCertificatePolicyRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + certificateName = builder.certificateName; + + if (builder.policy != null) { + certificatePolicy = new CertificatePolicy(); + if (builder.policy.attributes() != null) { + certificatePolicy.withAttributes((CertificateAttributes) new CertificateAttributes() + .withEnabled(builder.policy.attributes().enabled()) + .withExpires(builder.policy.attributes().expires()) + .withNotBefore(builder.policy.attributes().notBefore())); + } + if (builder.policy.issuerReference() != null) { + certificatePolicy.withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); + } + if (builder.policy.x509CertificateProperties() != null) { + certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() + .withValidityInMonths(builder.policy.x509CertificateProperties().validityInMonths()) + .withSubjectAlternativeNames(builder.policy.x509CertificateProperties().subjectAlternativeNames()) + .withSubject(builder.policy.x509CertificateProperties().subject()) + .withEkus(builder.policy.x509CertificateProperties().ekus()) + .withKeyUsage(builder.policy.x509CertificateProperties().keyUsage())); + } + if (builder.policy.lifetimeActions() != null) { + certificatePolicy.withLifetimeActions(new ArrayList(builder.policy.lifetimeActions())); + } + if (builder.policy.keyProperties() != null) { + certificatePolicy.withKeyProperties(new KeyProperties() + .withExportable(builder.policy.keyProperties().exportable()) + .withKeySize(builder.policy.keyProperties().keySize()) + .withKeyType(builder.policy.keyProperties().keyType()) + .withReuseKey(builder.policy.keyProperties().reuseKey())); + } + if (builder.policy.secretProperties() != null) { + certificatePolicy.withSecretProperties( + new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); + } + } else { + certificatePolicy = null; + } + } + + /** + * @return the vault base url + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the certificate name + */ + public String certificateName() { + return certificateName; + } + + /** + * @return the certificate policy + */ + public CertificatePolicy certificatePolicy() { + return certificatePolicy; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateRequest.java new file mode 100644 index 0000000000000..e80d84acbe77b --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateRequest.java @@ -0,0 +1,137 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import java.util.Collections; +import java.util.Map; + +import com.microsoft.azure.keyvault.models.CertificateAttributes; + +public class UpdateCertificateRequest { + private final String vaultBaseUrl; + private final String certificateName; + private final String certificateVersion; + private final CertificateAttributes certificateAttributes; + private final Map tags; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String certificateName; + + // Optional parameters + private String certificateVersion; + private CertificateAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link UpdateCertificateRequest} object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName + * The name of the certificate in the given vault + */ + public Builder(String vaultBaseUrl, String certificateName) { + this.vaultBaseUrl = vaultBaseUrl; + this.certificateName = certificateName; + } + + /** + * Set the certificate version value. + * + * @param version + * The version of the certificate + * @return the Builder object itself. + */ + public Builder withCertificateVersion(String version) { + this.certificateVersion = version; + return this; + } + + /** + * Set the attributes value. + * + * @param attributes + * The attributes of the certificate. + * @return the Builder object itself. + */ + public Builder withAttributes(CertificateAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link UpdateCertificateRequest} object + */ + public UpdateCertificateRequest build() { + return new UpdateCertificateRequest(this); + } + } + + private UpdateCertificateRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + certificateName = builder.certificateName; + certificateVersion = builder.certificateVersion == null ? "" : builder.certificateVersion; + + if (builder.attributes != null) { + certificateAttributes = (CertificateAttributes) new CertificateAttributes() + .withNotBefore(builder.attributes.notBefore()).withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()); + } else { + certificateAttributes = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } + } + + /** + * @return the vault base url + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the certificate name + */ + public String certificateName() { + return certificateName; + } + + /** + * @return the certificate version + */ + public String certificateVersion() { + return certificateVersion; + } + + /** + * @return the certificate attributes + */ + public CertificateAttributes certificateAttributes() { + return certificateAttributes; + } + + /** + * @return the tags + */ + public Map tags() { + return tags; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateKeyRequest.java new file mode 100644 index 0000000000000..7e0f7fa2f23f6 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateKeyRequest.java @@ -0,0 +1,182 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import com.microsoft.azure.keyvault.implementation.KeyIdentifier; +import com.microsoft.azure.keyvault.models.KeyAttributes; + +public class UpdateKeyRequest { + + private final String vaultBaseUrl; + private final String keyName; + private final String keyVersion; + private final List keyOperations; + private final KeyAttributes keyAttributes; + private final Map tags; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String keyName; + + // Optional parameters + private String keyVersion; + private List keyOperations; + private KeyAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link UpdateKeyRequest} object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param keyName + * The name of the key in the given vault + */ + public Builder(String vaultBaseUrl, String keyName) { + this.vaultBaseUrl = vaultBaseUrl; + this.keyName = keyName; + } + + /** + * The builder for constructing {@link UpdateKeyRequest} object + * + * @param keyIdentifier + * The key identifier, e.g. + * https://{vault-name}.vault.azure.net/keys/{key-name}/{key- + * version} + */ + public Builder(String keyIdentifier) { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + this.vaultBaseUrl = id.vault(); + this.keyName = id.name(); + this.keyVersion = id.version(); + } + + /** + * Set the key version value. + * + * @param keyVersion + * the key version + * @return the Builder object itself. + */ + public Builder withVersion(String keyVersion) { + this.keyVersion = keyVersion; + return this; + } + + /** + * Set the key operations value. + * + * @param size + * the size of the key + * @return the Builder object itself. + */ + public Builder withKeyOperations(List keyOperations) { + this.keyOperations = keyOperations; + return this; + } + + /** + * Set the key attributes value. + * + * @param attributes + * the key management attributes value to set + * @return the Builder object itself. + */ + public Builder withAttributes(KeyAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link UpdateKeyRequest} object + */ + public UpdateKeyRequest build() { + return new UpdateKeyRequest(this); + } + } + + private UpdateKeyRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + keyName = builder.keyName; + keyVersion = builder.keyVersion == null ? "" : builder.keyVersion; + + if (builder.keyOperations != null) { + keyOperations = new ArrayList(builder.keyOperations); + } else { + keyOperations = null; + } + + if (builder.attributes != null) { + keyAttributes = (KeyAttributes) new KeyAttributes().withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()).withNotBefore(builder.attributes.notBefore()); + } else { + keyAttributes = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } + } + + /** + * @return the vault base url + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the key name + */ + public String keyName() { + return keyName; + } + + /** + * @return the key version + */ + public String keyVersion() { + return keyVersion; + } + + /** + * @return the key operations + */ + public List keyOperations() { + return keyOperations; + } + + /** + * @return the key attributes + */ + public KeyAttributes keyAttributes() { + return keyAttributes; + } + + /** + * @return the tags + */ + public Map tags() { + return tags; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateSecretRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateSecretRequest.java new file mode 100644 index 0000000000000..33df1aa2a48da --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateSecretRequest.java @@ -0,0 +1,167 @@ +package com.microsoft.azure.keyvault.implementation.requests; + +import java.util.Collections; +import java.util.Map; + +import com.microsoft.azure.keyvault.implementation.SecretIdentifier; +import com.microsoft.azure.keyvault.models.SecretAttributes; + +public class UpdateSecretRequest { + private final String vaultBaseUrl; + private final String secretName; + private final String secretVersion; + private final String contentType; + private final SecretAttributes secretAttributes; + private final Map tags; + + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String secretName; + + // Optional parameters + private String secretVersion; + private String contentType; + private SecretAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link UpdateSecretRequest} object + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param secretName + * The name of the secret in the given vault + */ + public Builder(String vaultBaseUrl, String secretName) { + this.vaultBaseUrl = vaultBaseUrl; + this.secretName = secretName; + } + + /** + * The builder for constructing {@link UpdateSecretRequest} object + * + * @param secretId + * The secret identifier, e.g. + * https://{vault-name}.vault.azure.net/secrets/{secret-name}/{ + * secret-version} + */ + public Builder(String secretId) { + SecretIdentifier id = new SecretIdentifier(secretId); + this.vaultBaseUrl = id.vault(); + this.secretName = id.name(); + this.secretVersion = id.version(); + } + + public Builder withVersion(String version) { + this.secretVersion = version; + return this; + } + + /** + * Set the content type value. + * + * @param contentType + * Type of the secret value such as a password + * @return the Builder object itself. + */ + public Builder withContentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the attributes value. + * + * @param attributes + * The secret management attributes. + * @return the Builder object itself. + */ + public Builder withAttributes(SecretAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link UpdateSecretRequest} object + */ + public UpdateSecretRequest build() { + return new UpdateSecretRequest(this); + } + } + + private UpdateSecretRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + secretName = builder.secretName; + secretVersion = builder.secretVersion == null ? "" : builder.secretVersion; + contentType = builder.contentType; + + if (builder.attributes != null) { + secretAttributes = (SecretAttributes) new SecretAttributes().withNotBefore(builder.attributes.notBefore()) + .withEnabled(builder.attributes.enabled()).withExpires(builder.attributes.expires()); + } else { + secretAttributes = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } + } + + /** + * @return the vaultBaseUrl + */ + public String vaultBaseUrl() { + return vaultBaseUrl; + } + + /** + * @return the secretName + */ + public String secretName() { + return secretName; + } + + /** + * @return the secretVersion + */ + public String secretVersion() { + return secretVersion; + } + + /** + * @return the contentType + */ + public String contentType() { + return contentType; + } + + /** + * @return the secretAttributes + */ + public SecretAttributes secretAttributes() { + return secretAttributes; + } + + /** + * @return the tags + */ + public Map tags() { + return tags; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Action.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java similarity index 71% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Action.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java index ac83df8194215..6b8870b2a9d64 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Action.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; @@ -13,17 +13,18 @@ */ public class Action { /** - * The type of the action. + * The type of the action. Possible values include: 'EmailContacts', + * 'AutoRenew'. */ @JsonProperty(value = "action_type") - private String actionType; + private ActionType actionType; /** * Get the actionType value. * * @return the actionType value */ - public String actionType() { + public ActionType actionType() { return this.actionType; } @@ -33,7 +34,7 @@ public String actionType() { * @param actionType the actionType value to set * @return the Action object itself. */ - public Action withActionType(String actionType) { + public Action withActionType(ActionType actionType) { this.actionType = actionType; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java new file mode 100644 index 0000000000000..fa8aca689e543 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java @@ -0,0 +1,51 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for ActionType. + */ +public enum ActionType { + /** Enum value EmailContacts. */ + EMAIL_CONTACTS("EmailContacts"), + + /** Enum value AutoRenew. */ + AUTO_RENEW("AutoRenew"); + + /** The actual serialized value for a ActionType instance. */ + private String value; + + ActionType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ActionType instance. + * + * @param value the serialized value to parse. + * @return the parsed ActionType object, or null if unable to parse. + */ + @JsonCreator + public static ActionType fromString(String value) { + ActionType[] items = ActionType.values(); + for (ActionType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/AdministratorDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java similarity index 97% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/AdministratorDetails.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java index 0e5717b3385ce..3900cb4883035 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/AdministratorDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Attributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java similarity index 62% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Attributes.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java index a7f84612cbef0..25bcd55f762c7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Attributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java @@ -4,8 +4,10 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; import com.fasterxml.jackson.annotation.JsonProperty; /** @@ -66,8 +68,11 @@ public Attributes withEnabled(Boolean enabled) { * * @return the notBefore value */ - public Long notBefore() { - return this.notBefore; + public DateTime notBefore() { + if (this.notBefore == null) { + return null; + } + return new DateTime(this.notBefore * 1000L, DateTimeZone.UTC); } /** @@ -76,8 +81,10 @@ public Long notBefore() { * @param notBefore the notBefore value to set * @return the Attributes object itself. */ - public Attributes withNotBefore(Long notBefore) { - this.notBefore = notBefore; + public Attributes withNotBefore(DateTime notBefore) { + if (notBefore != null) + this.notBefore = notBefore.toDateTime(DateTimeZone.UTC).getMillis() / 1000; + else this.notBefore = null; return this; } @@ -86,8 +93,11 @@ public Attributes withNotBefore(Long notBefore) { * * @return the expires value */ - public Long expires() { - return this.expires; + public DateTime expires() { + if (this.expires == null) { + return null; + } + return new DateTime(this.expires * 1000L, DateTimeZone.UTC); } /** @@ -96,8 +106,10 @@ public Long expires() { * @param expires the expires value to set * @return the Attributes object itself. */ - public Attributes withExpires(Long expires) { - this.expires = expires; + public Attributes withExpires(DateTime expires) { + if (expires != null) + this.expires = expires.toDateTime(DateTimeZone.UTC).getMillis() / 1000; + else this.expires = null; return this; } @@ -106,8 +118,11 @@ public Attributes withExpires(Long expires) { * * @return the created value */ - public Long created() { - return this.created; + public DateTime created() { + if (this.created == null) { + return null; + } + return new DateTime(this.created * 1000L, DateTimeZone.UTC); } /** @@ -115,8 +130,11 @@ public Long created() { * * @return the updated value */ - public Long updated() { - return this.updated; + public DateTime updated() { + if (this.updated == null) { + return null; + } + return new DateTime(this.updated * 1000L, DateTimeZone.UTC); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/BackupKeyResultInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java similarity index 58% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/BackupKeyResultInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java index afa1c41361b9e..0003fc9c8f4ff 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/BackupKeyResultInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java @@ -4,27 +4,31 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; +import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; /** - * The BackupKeyResultInner model. + * The BackupKeyResult model. */ -public class BackupKeyResultInner { +public class BackupKeyResult { /** * The backup blob containing the backed up key. */ @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private String value; + private Base64Url value; /** * Get the value value. * * @return the value value */ - public String value() { - return this.value; + public byte[] value() { + if (this.value == null) { + return null; + } + return this.value.getDecodedBytes(); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyAttributesInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java similarity index 55% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyAttributesInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java index d1aa5c986b1ad..a42aec24d1c36 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyAttributesInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java @@ -4,11 +4,11 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; /** - * The KeyAttributesInner model. + * The certificate management attributes. */ -public class KeyAttributesInner extends Attributes { +public class CertificateAttributes extends Attributes { } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateBundleInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java similarity index 55% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateBundleInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java index 764173f4bdbd2..32865f854c88f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateBundleInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java @@ -4,15 +4,24 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; +import com.microsoft.azure.keyvault.implementation.CertificateIdentifier; +import com.microsoft.azure.keyvault.implementation.KeyIdentifier; +import com.microsoft.azure.keyvault.implementation.SecretIdentifier; +import com.microsoft.rest.Base64Url; + +import java.io.IOException; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; /** - * The CertificateBundleInner model. + * The CertificateBundle model. */ -public class CertificateBundleInner { +public class CertificateBundle { /** * The certificate id. */ @@ -35,18 +44,18 @@ public class CertificateBundleInner { * Thumbprint of the certificate. */ @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private String x5t; + private Base64Url x5t; /** * The management policy. */ @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private CertificatePolicyInner policy; + private CertificatePolicy policy; /** * CER contents of x509 certificate. */ - private String cer; + private byte[] cer; /** * The content type of the secret. @@ -56,7 +65,7 @@ public class CertificateBundleInner { /** * The certificate attributes. */ - private CertificateAttributesInner attributes; + private CertificateAttributes attributes; /** * Application-specific metadata in the form of key-value pairs. @@ -95,8 +104,11 @@ public String sid() { * * @return the x5t value */ - public String x5t() { - return this.x5t; + public byte[] x5t() { + if (this.x5t == null) { + return null; + } + return this.x5t.getDecodedBytes(); } /** @@ -104,7 +116,7 @@ public String x5t() { * * @return the policy value */ - public CertificatePolicyInner policy() { + public CertificatePolicy policy() { return this.policy; } @@ -113,7 +125,7 @@ public CertificatePolicyInner policy() { * * @return the cer value */ - public String cer() { + public byte[] cer() { return this.cer; } @@ -121,9 +133,9 @@ public String cer() { * Set the cer value. * * @param cer the cer value to set - * @return the CertificateBundleInner object itself. + * @return the CertificateBundle object itself. */ - public CertificateBundleInner withCer(String cer) { + public CertificateBundle withCer(byte[] cer) { this.cer = cer; return this; } @@ -141,9 +153,9 @@ public String contentType() { * Set the contentType value. * * @param contentType the contentType value to set - * @return the CertificateBundleInner object itself. + * @return the CertificateBundle object itself. */ - public CertificateBundleInner withContentType(String contentType) { + public CertificateBundle withContentType(String contentType) { this.contentType = contentType; return this; } @@ -153,7 +165,7 @@ public CertificateBundleInner withContentType(String contentType) { * * @return the attributes value */ - public CertificateAttributesInner attributes() { + public CertificateAttributes attributes() { return this.attributes; } @@ -161,9 +173,9 @@ public CertificateAttributesInner attributes() { * Set the attributes value. * * @param attributes the attributes value to set - * @return the CertificateBundleInner object itself. + * @return the CertificateBundle object itself. */ - public CertificateBundleInner withAttributes(CertificateAttributesInner attributes) { + public CertificateBundle withAttributes(CertificateAttributes attributes) { this.attributes = attributes; return this; } @@ -181,11 +193,45 @@ public Map tags() { * Set the tags value. * * @param tags the tags value to set - * @return the CertificateBundleInner object itself. + * @return the CertificateBundle object itself. */ - public CertificateBundleInner withTags(Map tags) { + public CertificateBundle withTags(Map tags) { this.tags = tags; return this; } + + public CertificateIdentifier certificateIdentifier() { + if (id() == null || id().isEmpty()) { + return null; + } + return new CertificateIdentifier(id()); + } + + public SecretIdentifier secretIdentifier() { + if (sid() == null || sid().isEmpty()) { + return null; + } + return new SecretIdentifier(sid()); + } + + public KeyIdentifier keyIdentifier() { + if (kid() == null || kid().isEmpty()) { + return null; + } + return new KeyIdentifier(kid()); + } + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java similarity index 84% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateCreateParameters.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java index 548ab8b64a492..2d6f5686ac0b1 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; @@ -17,13 +17,13 @@ public class CertificateCreateParameters { * The management policy for the certificate. */ @JsonProperty(value = "policy", required = true) - private CertificatePolicyInner certificatePolicy; + private CertificatePolicy certificatePolicy; /** * The attributes of the certificate (optional). */ @JsonProperty(value = "attributes") - private CertificateAttributesInner certificateAttributes; + private CertificateAttributes certificateAttributes; /** * Application-specific metadata in the form of key-value pairs. @@ -35,7 +35,7 @@ public class CertificateCreateParameters { * * @return the certificatePolicy value */ - public CertificatePolicyInner certificatePolicy() { + public CertificatePolicy certificatePolicy() { return this.certificatePolicy; } @@ -45,7 +45,7 @@ public CertificatePolicyInner certificatePolicy() { * @param certificatePolicy the certificatePolicy value to set * @return the CertificateCreateParameters object itself. */ - public CertificateCreateParameters withCertificatePolicy(CertificatePolicyInner certificatePolicy) { + public CertificateCreateParameters withCertificatePolicy(CertificatePolicy certificatePolicy) { this.certificatePolicy = certificatePolicy; return this; } @@ -55,7 +55,7 @@ public CertificateCreateParameters withCertificatePolicy(CertificatePolicyInner * * @return the certificateAttributes value */ - public CertificateAttributesInner certificateAttributes() { + public CertificateAttributes certificateAttributes() { return this.certificateAttributes; } @@ -65,7 +65,7 @@ public CertificateAttributesInner certificateAttributes() { * @param certificateAttributes the certificateAttributes value to set * @return the CertificateCreateParameters object itself. */ - public CertificateCreateParameters withCertificateAttributes(CertificateAttributesInner certificateAttributes) { + public CertificateCreateParameters withCertificateAttributes(CertificateAttributes certificateAttributes) { this.certificateAttributes = certificateAttributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java similarity index 87% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateImportParameters.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java index 1c4c87173a3db..fb787afd76537 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; @@ -14,7 +14,7 @@ */ public class CertificateImportParameters { /** - * Base64 encoded representaion of the certificate object to import. This + * Base64 encoded representation of the certificate object to import. This * certificate needs to contain the private key. */ @JsonProperty(value = "value", required = true) @@ -24,20 +24,20 @@ public class CertificateImportParameters { * If the private key in base64EncodedCertificate is encrypted, the * password used for encryption. */ - @JsonProperty(value = "pwd", required = true) + @JsonProperty(value = "pwd") private String password; /** * The management policy for the certificate. */ @JsonProperty(value = "policy", required = true) - private CertificatePolicyInner certificatePolicy; + private CertificatePolicy certificatePolicy; /** * The attributes of the certificate (optional). */ @JsonProperty(value = "attributes") - private CertificateAttributesInner certificateAttributes; + private CertificateAttributes certificateAttributes; /** * Application-specific metadata in the form of key-value pairs. @@ -89,7 +89,7 @@ public CertificateImportParameters withPassword(String password) { * * @return the certificatePolicy value */ - public CertificatePolicyInner certificatePolicy() { + public CertificatePolicy certificatePolicy() { return this.certificatePolicy; } @@ -99,7 +99,7 @@ public CertificatePolicyInner certificatePolicy() { * @param certificatePolicy the certificatePolicy value to set * @return the CertificateImportParameters object itself. */ - public CertificateImportParameters withCertificatePolicy(CertificatePolicyInner certificatePolicy) { + public CertificateImportParameters withCertificatePolicy(CertificatePolicy certificatePolicy) { this.certificatePolicy = certificatePolicy; return this; } @@ -109,7 +109,7 @@ public CertificateImportParameters withCertificatePolicy(CertificatePolicyInner * * @return the certificateAttributes value */ - public CertificateAttributesInner certificateAttributes() { + public CertificateAttributes certificateAttributes() { return this.certificateAttributes; } @@ -119,7 +119,7 @@ public CertificateAttributesInner certificateAttributes() { * @param certificateAttributes the certificateAttributes value to set * @return the CertificateImportParameters object itself. */ - public CertificateImportParameters withCertificateAttributes(CertificateAttributesInner certificateAttributes) { + public CertificateImportParameters withCertificateAttributes(CertificateAttributes certificateAttributes) { this.certificateAttributes = certificateAttributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateIssuerItemInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java similarity index 70% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateIssuerItemInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java index e9945a9ec0400..126c91f8cec93 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateIssuerItemInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java @@ -4,13 +4,13 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; /** - * The CertificateIssuerItemInner model. + * The CertificateIssuerItem model. */ -public class CertificateIssuerItemInner { +public class CertificateIssuerItem { /** * Certificate Identifier. */ @@ -34,9 +34,9 @@ public String id() { * Set the id value. * * @param id the id value to set - * @return the CertificateIssuerItemInner object itself. + * @return the CertificateIssuerItem object itself. */ - public CertificateIssuerItemInner withId(String id) { + public CertificateIssuerItem withId(String id) { this.id = id; return this; } @@ -54,9 +54,9 @@ public String provider() { * Set the provider value. * * @param provider the provider value to set - * @return the CertificateIssuerItemInner object itself. + * @return the CertificateIssuerItem object itself. */ - public CertificateIssuerItemInner withProvider(String provider) { + public CertificateIssuerItem withProvider(String provider) { this.provider = provider; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateItemInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java similarity index 57% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateItemInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java index 44773df601a6f..6c0c99bc69ce3 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateItemInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java @@ -4,15 +4,17 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.Map; +import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.keyvault.implementation.CertificateIdentifier; /** - * The CertificateItemInner model. + * The CertificateItem model. */ -public class CertificateItemInner { +public class CertificateItem { /** * Certificate Identifier. */ @@ -21,7 +23,7 @@ public class CertificateItemInner { /** * The certificate management attributes. */ - private CertificateAttributesInner attributes; + private CertificateAttributes attributes; /** * Application-specific metadata in the form of key-value pairs. @@ -32,7 +34,7 @@ public class CertificateItemInner { * Thumbprint of the certificate. */ @JsonProperty(value = "x5t") - private String x5T; + private Base64Url x5T; /** * Get the id value. @@ -47,9 +49,9 @@ public String id() { * Set the id value. * * @param id the id value to set - * @return the CertificateItemInner object itself. + * @return the CertificateItem object itself. */ - public CertificateItemInner withId(String id) { + public CertificateItem withId(String id) { this.id = id; return this; } @@ -59,7 +61,7 @@ public CertificateItemInner withId(String id) { * * @return the attributes value */ - public CertificateAttributesInner attributes() { + public CertificateAttributes attributes() { return this.attributes; } @@ -67,9 +69,9 @@ public CertificateAttributesInner attributes() { * Set the attributes value. * * @param attributes the attributes value to set - * @return the CertificateItemInner object itself. + * @return the CertificateItem object itself. */ - public CertificateItemInner withAttributes(CertificateAttributesInner attributes) { + public CertificateItem withAttributes(CertificateAttributes attributes) { this.attributes = attributes; return this; } @@ -87,9 +89,9 @@ public Map tags() { * Set the tags value. * * @param tags the tags value to set - * @return the CertificateItemInner object itself. + * @return the CertificateItem object itself. */ - public CertificateItemInner withTags(Map tags) { + public CertificateItem withTags(Map tags) { this.tags = tags; return this; } @@ -99,19 +101,34 @@ public CertificateItemInner withTags(Map tags) { * * @return the x5T value */ - public String x5T() { - return this.x5T; + public byte[] x5T() { + if (this.x5T == null) { + return null; + } + return this.x5T.getDecodedBytes(); } /** * Set the x5T value. * * @param x5T the x5T value to set - * @return the CertificateItemInner object itself. + * @return the CertificateItem object itself. */ - public CertificateItemInner withX5T(String x5T) { - this.x5T = x5T; + public CertificateItem withX5T(byte[] x5T) { + this.x5T = Base64Url.encode(x5T); return this; } + + /** + * @return The Identifier value + */ + public CertificateIdentifier identifier() { + CertificateIdentifier identifier = null; + + if (id() != null && !id().isEmpty()) { + identifier = new CertificateIdentifier(id()); + } + return identifier; + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateMergeParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java similarity index 88% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateMergeParameters.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java index c108a8ef1f008..bfbbdedf6668e 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateMergeParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.List; import java.util.Map; @@ -15,7 +15,7 @@ */ public class CertificateMergeParameters { /** - * The certificate or the certificte chain to merge. + * The certificate or the certificate chain to merge. */ @JsonProperty(value = "x5c", required = true) private List x509Certificates; @@ -24,7 +24,7 @@ public class CertificateMergeParameters { * The attributes of the certificate (optional). */ @JsonProperty(value = "attributes") - private CertificateAttributesInner certificateAttributes; + private CertificateAttributes certificateAttributes; /** * Application-specific metadata in the form of key-value pairs. @@ -56,7 +56,7 @@ public CertificateMergeParameters withX509Certificates(List x509Certific * * @return the certificateAttributes value */ - public CertificateAttributesInner certificateAttributes() { + public CertificateAttributes certificateAttributes() { return this.certificateAttributes; } @@ -66,7 +66,7 @@ public CertificateAttributesInner certificateAttributes() { * @param certificateAttributes the certificateAttributes value to set * @return the CertificateMergeParameters object itself. */ - public CertificateMergeParameters withCertificateAttributes(CertificateAttributesInner certificateAttributes) { + public CertificateMergeParameters withCertificateAttributes(CertificateAttributes certificateAttributes) { this.certificateAttributes = certificateAttributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateOperationInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java similarity index 66% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateOperationInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java index b5ee3da1a1068..5f2a473eefe38 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateOperationInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java @@ -4,14 +4,22 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; + +import com.microsoft.rest.Base64Url; + +import java.io.IOException; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.implementation.CertificateOperationIdentifier; /** - * The CertificateOperationInner model. + * The CertificateOperation model. */ -public class CertificateOperationInner { +public class CertificateOperation { /** * The certificate id. */ @@ -28,7 +36,7 @@ public class CertificateOperationInner { * The Certificate Signing Request (CSR) that is being used in the * certificate operation. */ - private String csr; + private byte[] csr; /** * Indicates if cancellation was requested on the certificate operation. @@ -85,9 +93,9 @@ public IssuerReference issuerReference() { * Set the issuerReference value. * * @param issuerReference the issuerReference value to set - * @return the CertificateOperationInner object itself. + * @return the CertificateOperation object itself. */ - public CertificateOperationInner withIssuerReference(IssuerReference issuerReference) { + public CertificateOperation withIssuerReference(IssuerReference issuerReference) { this.issuerReference = issuerReference; return this; } @@ -97,7 +105,7 @@ public CertificateOperationInner withIssuerReference(IssuerReference issuerRefer * * @return the csr value */ - public String csr() { + public byte[] csr() { return this.csr; } @@ -105,9 +113,9 @@ public String csr() { * Set the csr value. * * @param csr the csr value to set - * @return the CertificateOperationInner object itself. + * @return the CertificateOperation object itself. */ - public CertificateOperationInner withCsr(String csr) { + public CertificateOperation withCsr(byte[] csr) { this.csr = csr; return this; } @@ -125,9 +133,9 @@ public Boolean cancellationRequested() { * Set the cancellationRequested value. * * @param cancellationRequested the cancellationRequested value to set - * @return the CertificateOperationInner object itself. + * @return the CertificateOperation object itself. */ - public CertificateOperationInner withCancellationRequested(Boolean cancellationRequested) { + public CertificateOperation withCancellationRequested(Boolean cancellationRequested) { this.cancellationRequested = cancellationRequested; return this; } @@ -145,9 +153,9 @@ public String status() { * Set the status value. * * @param status the status value to set - * @return the CertificateOperationInner object itself. + * @return the CertificateOperation object itself. */ - public CertificateOperationInner withStatus(String status) { + public CertificateOperation withStatus(String status) { this.status = status; return this; } @@ -165,9 +173,9 @@ public String statusDetails() { * Set the statusDetails value. * * @param statusDetails the statusDetails value to set - * @return the CertificateOperationInner object itself. + * @return the CertificateOperation object itself. */ - public CertificateOperationInner withStatusDetails(String statusDetails) { + public CertificateOperation withStatusDetails(String statusDetails) { this.statusDetails = statusDetails; return this; } @@ -185,9 +193,9 @@ public Error error() { * Set the error value. * * @param error the error value to set - * @return the CertificateOperationInner object itself. + * @return the CertificateOperation object itself. */ - public CertificateOperationInner withError(Error error) { + public CertificateOperation withError(Error error) { this.error = error; return this; } @@ -205,9 +213,9 @@ public String target() { * Set the target value. * * @param target the target value to set - * @return the CertificateOperationInner object itself. + * @return the CertificateOperation object itself. */ - public CertificateOperationInner withTarget(String target) { + public CertificateOperation withTarget(String target) { this.target = target; return this; } @@ -225,11 +233,31 @@ public String requestId() { * Set the requestId value. * * @param requestId the requestId value to set - * @return the CertificateOperationInner object itself. + * @return the CertificateOperation object itself. */ - public CertificateOperationInner withRequestId(String requestId) { + public CertificateOperation withRequestId(String requestId) { this.requestId = requestId; return this; } + + public CertificateOperationIdentifier certificateOperationIdentifier() { + if (id() == null || id().isEmpty()) { + return null; + } + return new CertificateOperationIdentifier(id()); + } + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificatePolicyInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java similarity index 76% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificatePolicyInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java index 91742463041db..234480213a8b4 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificatePolicyInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java @@ -4,15 +4,15 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; /** - * The CertificatePolicyInner model. + * The CertificatePolicy model. */ -public class CertificatePolicyInner { +public class CertificatePolicy { /** * The certificate id. */ @@ -53,7 +53,7 @@ public class CertificatePolicyInner { /** * The certificate attributes. */ - private CertificateAttributesInner attributes; + private CertificateAttributes attributes; /** * Get the id value. @@ -77,9 +77,9 @@ public KeyProperties keyProperties() { * Set the keyProperties value. * * @param keyProperties the keyProperties value to set - * @return the CertificatePolicyInner object itself. + * @return the CertificatePolicy object itself. */ - public CertificatePolicyInner withKeyProperties(KeyProperties keyProperties) { + public CertificatePolicy withKeyProperties(KeyProperties keyProperties) { this.keyProperties = keyProperties; return this; } @@ -97,9 +97,9 @@ public SecretProperties secretProperties() { * Set the secretProperties value. * * @param secretProperties the secretProperties value to set - * @return the CertificatePolicyInner object itself. + * @return the CertificatePolicy object itself. */ - public CertificatePolicyInner withSecretProperties(SecretProperties secretProperties) { + public CertificatePolicy withSecretProperties(SecretProperties secretProperties) { this.secretProperties = secretProperties; return this; } @@ -117,9 +117,9 @@ public X509CertificateProperties x509CertificateProperties() { * Set the x509CertificateProperties value. * * @param x509CertificateProperties the x509CertificateProperties value to set - * @return the CertificatePolicyInner object itself. + * @return the CertificatePolicy object itself. */ - public CertificatePolicyInner withX509CertificateProperties(X509CertificateProperties x509CertificateProperties) { + public CertificatePolicy withX509CertificateProperties(X509CertificateProperties x509CertificateProperties) { this.x509CertificateProperties = x509CertificateProperties; return this; } @@ -137,9 +137,9 @@ public List lifetimeActions() { * Set the lifetimeActions value. * * @param lifetimeActions the lifetimeActions value to set - * @return the CertificatePolicyInner object itself. + * @return the CertificatePolicy object itself. */ - public CertificatePolicyInner withLifetimeActions(List lifetimeActions) { + public CertificatePolicy withLifetimeActions(List lifetimeActions) { this.lifetimeActions = lifetimeActions; return this; } @@ -157,9 +157,9 @@ public IssuerReference issuerReference() { * Set the issuerReference value. * * @param issuerReference the issuerReference value to set - * @return the CertificatePolicyInner object itself. + * @return the CertificatePolicy object itself. */ - public CertificatePolicyInner withIssuerReference(IssuerReference issuerReference) { + public CertificatePolicy withIssuerReference(IssuerReference issuerReference) { this.issuerReference = issuerReference; return this; } @@ -169,7 +169,7 @@ public CertificatePolicyInner withIssuerReference(IssuerReference issuerReferenc * * @return the attributes value */ - public CertificateAttributesInner attributes() { + public CertificateAttributes attributes() { return this.attributes; } @@ -177,9 +177,9 @@ public CertificateAttributesInner attributes() { * Set the attributes value. * * @param attributes the attributes value to set - * @return the CertificatePolicyInner object itself. + * @return the CertificatePolicy object itself. */ - public CertificatePolicyInner withAttributes(CertificateAttributesInner attributes) { + public CertificatePolicy withAttributes(CertificateAttributes attributes) { this.attributes = attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java similarity index 86% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateUpdateParameters.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java index eb0510a6a7edf..b015da3314875 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; @@ -17,7 +17,7 @@ public class CertificateUpdateParameters { * The attributes of the certificate (optional). */ @JsonProperty(value = "attributes") - private CertificateAttributesInner certificateAttributes; + private CertificateAttributes certificateAttributes; /** * Application-specific metadata in the form of key-value pairs. @@ -29,7 +29,7 @@ public class CertificateUpdateParameters { * * @return the certificateAttributes value */ - public CertificateAttributesInner certificateAttributes() { + public CertificateAttributes certificateAttributes() { return this.certificateAttributes; } @@ -39,7 +39,7 @@ public CertificateAttributesInner certificateAttributes() { * @param certificateAttributes the certificateAttributes value to set * @return the CertificateUpdateParameters object itself. */ - public CertificateUpdateParameters withCertificateAttributes(CertificateAttributesInner certificateAttributes) { + public CertificateUpdateParameters withCertificateAttributes(CertificateAttributes certificateAttributes) { this.certificateAttributes = certificateAttributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Contact.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java similarity index 96% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Contact.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java index ea02c39ea4c66..18a6694a21afb 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Contact.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/ContactsInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java similarity index 81% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/ContactsInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java index ec8e80710ab0d..3be777fbfccd7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/ContactsInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java @@ -4,15 +4,15 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; /** - * The ContactsInner model. + * The Contacts model. */ -public class ContactsInner { +public class Contacts { /** * Identifier for the contacts collection. */ @@ -47,9 +47,9 @@ public List contactList() { * Set the contactList value. * * @param contactList the contactList value to set - * @return the ContactsInner object itself. + * @return the Contacts object itself. */ - public ContactsInner withContactList(List contactList) { + public Contacts withContactList(List contactList) { this.contactList = contactList; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Error.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java similarity index 87% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Error.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java index 63c6990b2b734..2046221183fe2 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Error.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; @@ -13,13 +13,13 @@ */ public class Error { /** - * The code property. + * The error code. */ @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String code; /** - * The message property. + * The error message. */ @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String message; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java similarity index 73% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerAttributes.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java index 3b8ad409a218c..d07df06a92a71 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java @@ -4,8 +4,10 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; import com.fasterxml.jackson.annotation.JsonProperty; /** @@ -54,8 +56,11 @@ public IssuerAttributes withEnabled(Boolean enabled) { * * @return the created value */ - public Long created() { - return this.created; + public DateTime created() { + if (this.created == null) { + return null; + } + return new DateTime(this.created * 1000L, DateTimeZone.UTC); } /** @@ -63,8 +68,11 @@ public Long created() { * * @return the updated value */ - public Long updated() { - return this.updated; + public DateTime updated() { + if (this.updated == null) { + return null; + } + return new DateTime(this.updated * 1000L, DateTimeZone.UTC); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerBundleInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java similarity index 62% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerBundleInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java index 965eecb4a74fa..6c28a862a28a3 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerBundleInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -4,14 +4,20 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; + +import java.io.IOException; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.implementation.IssuerIdentifier; /** - * The IssuerBundleInner model. + * The IssuerBundle model. */ -public class IssuerBundleInner { +public class IssuerBundle { /** * Identifier for the issuer object. */ @@ -61,9 +67,9 @@ public String provider() { * Set the provider value. * * @param provider the provider value to set - * @return the IssuerBundleInner object itself. + * @return the IssuerBundle object itself. */ - public IssuerBundleInner withProvider(String provider) { + public IssuerBundle withProvider(String provider) { this.provider = provider; return this; } @@ -81,9 +87,9 @@ public IssuerCredentials credentials() { * Set the credentials value. * * @param credentials the credentials value to set - * @return the IssuerBundleInner object itself. + * @return the IssuerBundle object itself. */ - public IssuerBundleInner withCredentials(IssuerCredentials credentials) { + public IssuerBundle withCredentials(IssuerCredentials credentials) { this.credentials = credentials; return this; } @@ -101,9 +107,9 @@ public OrganizationDetails organizationDetails() { * Set the organizationDetails value. * * @param organizationDetails the organizationDetails value to set - * @return the IssuerBundleInner object itself. + * @return the IssuerBundle object itself. */ - public IssuerBundleInner withOrganizationDetails(OrganizationDetails organizationDetails) { + public IssuerBundle withOrganizationDetails(OrganizationDetails organizationDetails) { this.organizationDetails = organizationDetails; return this; } @@ -121,11 +127,31 @@ public IssuerAttributes attributes() { * Set the attributes value. * * @param attributes the attributes value to set - * @return the IssuerBundleInner object itself. + * @return the IssuerBundle object itself. */ - public IssuerBundleInner withAttributes(IssuerAttributes attributes) { + public IssuerBundle withAttributes(IssuerAttributes attributes) { this.attributes = attributes; return this; } + + public IssuerIdentifier issuerIdentifier() { + if (id() == null || id().isEmpty()) { + return null; + } + return new IssuerIdentifier(id()); + } + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java similarity index 96% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerCredentials.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java index 63fa5e8a56104..674f8822d10f9 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerCredentials.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerReference.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java similarity index 92% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerReference.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java index ffe58ead3d1fd..d6e7985b81156 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/IssuerReference.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java new file mode 100644 index 0000000000000..0db281ea99185 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java @@ -0,0 +1,529 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +import java.io.IOException; +import java.math.BigInteger; +import java.security.GeneralSecurityException; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.interfaces.RSAPrivateCrtKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.RSAPrivateCrtKeySpec; +import java.security.spec.RSAPrivateKeySpec; +import java.security.spec.RSAPublicKeySpec; +import java.util.Arrays; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; +import com.microsoft.rest.Base64Url; + +/** + * The JsonWebKey model. + */ +public class JsonWebKey { + /** + * Key Identifier. + */ + private String kid; + + /** + * Key type, usually RSA. + */ + private String kty; + + /** + * The keyOps property. + */ + @JsonProperty(value = "key_ops") + private List keyOps; + + /** + * RSA modulus. + */ + private Base64Url n; + + /** + * RSA public exponent. + */ + private Base64Url e; + + /** + * RSA private exponent. + */ + private Base64Url d; + + /** + * The dp property. + */ + private Base64Url dp; + + /** + * The dq property. + */ + private Base64Url dq; + + /** + * The qi property. + */ + private Base64Url qi; + + /** + * The p property. + */ + private Base64Url p; + + /** + * The q property. + */ + private Base64Url q; + + /** + * Symmetric key. + */ + @JsonProperty(value = "K") + private Base64Url k; + + /** + * HSM Token, used with Bring Your Own Key. + */ + @JsonProperty(value = "key_hsm") + private Base64Url t; + + /** + * Get the kid value. + * + * @return the kid value + */ + public String kid() { + return this.kid; + } + + /** + * Set the kid value. + * + * @param kid the kid value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withKid(String kid) { + this.kid = kid; + return this; + } + + /** + * Get the kty value. + * + * @return the kty value + */ + public String kty() { + return this.kty; + } + + /** + * Set the kty value. + * + * @param kty the kty value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withKty(String kty) { + this.kty = kty; + return this; + } + + /** + * Get the keyOps value. + * + * @return the keyOps value + */ + public List keyOps() { + return this.keyOps; + } + + /** + * Set the keyOps value. + * + * @param keyOps the keyOps value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withKeyOps(List keyOps) { + this.keyOps = keyOps; + return this; + } + + /** + * Get the n value. + * + * @return the n value + */ + public byte[] n() { + if (this.n == null) { + return null; + } + return this.n.getDecodedBytes(); + } + + /** + * Set the n value. + * + * @param n the n value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withN(byte[] n) { + if (n != null) + this.n = Base64Url.encode(n); + return this; + } + + /** + * Get the e value. + * + * @return the e value + */ + public byte[] e() { + if (this.e == null) { + return null; + } + return this.e.getDecodedBytes(); + } + + /** + * Set the e value. + * + * @param e the e value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withE(byte[] e) { + if (e != null) + this.e = Base64Url.encode(e); + return this; + } + + /** + * Get the d value. + * + * @return the d value + */ + public byte[] d() { + if (this.d == null) { + return null; + } + return this.d.getDecodedBytes(); + } + + /** + * Set the d value. + * + * @param d the d value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withD(byte[] d) { + if (d != null) + this.d = Base64Url.encode(d); + return this; + } + + /** + * Get the dp value. + * + * @return the dp value + */ + public byte[] dp() { + if (this.dp == null) { + return null; + } + return this.dp.getDecodedBytes(); + } + + /** + * Set the dp value. + * + * @param dp the dp value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withDp(byte[] dp) { + if (dp != null) + this.dp = Base64Url.encode(dp); + return this; + } + + /** + * Get the dq value. + * + * @return the dq value + */ + public byte[] dq() { + if (this.dq == null) { + return null; + } + return this.dq.getDecodedBytes(); + } + + /** + * Set the dq value. + * + * @param dq the dq value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withDq(byte[] dq) { + if (dq != null) + this.dq = Base64Url.encode(dq); + return this; + } + + /** + * Get the qi value. + * + * @return the qi value + */ + public byte[] qi() { + if (this.qi == null) { + return null; + } + return this.qi.getDecodedBytes(); + } + + /** + * Set the qi value. + * + * @param qi the qi value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withQi(byte[] qi) { + if (qi != null) + this.qi = Base64Url.encode(qi); + return this; + } + + /** + * Get the p value. + * + * @return the p value + */ + public byte[] p() { + if (this.p == null) { + return null; + } + return this.p.getDecodedBytes(); + } + + /** + * Set the p value. + * + * @param p the p value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withP(byte[] p) { + if (p != null) + this.p = Base64Url.encode(p); + return this; + } + + /** + * Get the q value. + * + * @return the q value + */ + public byte[] q() { + if (this.q == null) { + return null; + } + return this.q.getDecodedBytes(); + } + + /** + * Set the q value. + * + * @param q the q value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withQ(byte[] q) { + if (q != null) + this.q = Base64Url.encode(q); + return this; + } + + /** + * Get the k value. + * + * @return the k value + */ + public byte[] k() { + if (this.k == null) { + return null; + } + return this.k.getDecodedBytes(); + } + + /** + * Set the k value. + * + * @param k the k value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withK(byte[] k) { + if (k != null) + this.k = Base64Url.encode(k); + return this; + } + + /** + * Get the t value. + * + * @return the t value + */ + public byte[] t() { + if (this.t == null) { + return null; + } + return this.t.getDecodedBytes(); + } + + /** + * Set the t value. + * + * @param t the t value to set + * @return the JsonWebKey object itself. + */ + public JsonWebKey withT(byte[] t) { + if (t != null) + this.t = Base64Url.encode(t); + return this; + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + private RSAPublicKeySpec getRSAPublicKeySpec() { + + return new RSAPublicKeySpec(toBigInteger(n()), toBigInteger(e())); + } + + private RSAPrivateKeySpec getRSAPrivateKeySpec() { + + return new RSAPrivateCrtKeySpec(toBigInteger(n()), toBigInteger(e()), toBigInteger(d()), toBigInteger(p()), toBigInteger(q()), toBigInteger(dp()), toBigInteger(dq()), toBigInteger(qi())); + } + + private PublicKey getRSAPublicKey() { + + try { + RSAPublicKeySpec publicKeySpec = getRSAPublicKeySpec(); + KeyFactory factory = KeyFactory.getInstance("RSA"); + + return factory.generatePublic(publicKeySpec); + } catch (GeneralSecurityException e) { + throw new IllegalStateException(e); + } + } + + private PrivateKey RSAPrivateKey() { + + try { + RSAPrivateKeySpec privateKeySpec = getRSAPrivateKeySpec(); + KeyFactory factory = KeyFactory.getInstance("RSA"); + + return factory.generatePrivate(privateKeySpec); + } catch (GeneralSecurityException e) { + throw new IllegalStateException(e); + } + } + + private void checkRSACompatible() { + if (!JsonWebKeyType.RSA.equals(kty()) && !JsonWebKeyType.RSAHSM.equals(kty())) { + throw new UnsupportedOperationException("Not an RSA key"); + } + } + + private static byte[] toByteArray(BigInteger n) { + byte[] result = n.toByteArray(); + if (result[0] == 0) { + // The leading zero is used to let the number positive. Since RSA + // parameters are always positive, we remove it. + return Arrays.copyOfRange(result, 1, result.length); + } + return result; + } + + private static BigInteger toBigInteger(byte[] b) { + if (b[0] < 0) { + // RSA parameters are always positive numbers, so if the first byte + // is negative, we need to add a leading zero + // to make the entire BigInteger positive. + byte[] temp = new byte[1 + b.length]; + System.arraycopy(b, 0, temp, 1, b.length); + b = temp; + } + return new BigInteger(b); + } + + public static JsonWebKey fromRSA(KeyPair keyPair) { + + RSAPrivateCrtKey privateKey = (RSAPrivateCrtKey) keyPair.getPrivate(); + JsonWebKey key = null; + + if (privateKey != null) { + + key = new JsonWebKey() + .withKty(JsonWebKeyType.RSA) + .withN(toByteArray(privateKey.getModulus())) + .withE(toByteArray(privateKey.getPublicExponent())) + .withD(toByteArray(privateKey.getPrivateExponent())) + .withP(toByteArray(privateKey.getPrimeP())) + .withQ(toByteArray(privateKey.getPrimeQ())) + .withDp(toByteArray(privateKey.getPrimeExponentP())) + .withDq(toByteArray(privateKey.getPrimeExponentQ())) + .withQi(toByteArray(privateKey.getCrtCoefficient())); + } else { + + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + + key = new JsonWebKey() + .withKty(JsonWebKeyType.RSA) + .withN(toByteArray(publicKey.getModulus())) + .withE(toByteArray(publicKey.getPublicExponent())) + .withD(null) + .withP(null) + .withQ(null) + .withDp(null) + .withDq(null) + .withQi(null); + } + + return key; + } + + public KeyPair toRSA() { + return this.toRSA(false); + } + + public KeyPair toRSA(boolean includePrivateParameters) { + + // Must be RSA + checkRSACompatible(); + + if (includePrivateParameters) { + return new KeyPair(getRSAPublicKey(), RSAPrivateKey()); + } else { + return new KeyPair(getRSAPublicKey(), null); + } + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretAttributesInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java similarity index 54% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretAttributesInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java index d7ab4522fdbe4..6a4983eeaa85f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretAttributesInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java @@ -4,11 +4,11 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; /** - * The SecretAttributesInner model. + * The key management attributes. */ -public class SecretAttributesInner extends Attributes { +public class KeyAttributes extends Attributes { } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java new file mode 100644 index 0000000000000..8f5d1ca1cf7a6 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -0,0 +1,116 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +import java.io.IOException; +import java.util.Map; + +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.implementation.KeyIdentifier; + +/** + * The KeyBundle model. + */ +public class KeyBundle { + /** + * The Json web key. + */ + private JsonWebKey key; + + /** + * The key management attributes. + */ + private KeyAttributes attributes; + + /** + * Application-specific metadata in the form of key-value pairs. + */ + private Map tags; + + /** + * Get the key value. + * + * @return the key value + */ + public JsonWebKey key() { + return this.key; + } + + /** + * Set the key value. + * + * @param key the key value to set + * @return the KeyBundle object itself. + */ + public KeyBundle withKey(JsonWebKey key) { + this.key = key; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public KeyAttributes attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the KeyBundle object itself. + */ + public KeyBundle withAttributes(KeyAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the KeyBundle object itself. + */ + public KeyBundle withTags(Map tags) { + this.tags = tags; + return this; + } + + public KeyIdentifier keyIdentifier() { + if (key() == null || key().kid() == null || key().kid().length() == 0) { + return null; + } + return new KeyIdentifier(key().kid()); + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java similarity index 92% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyCreateParameters.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java index 1920720f3fc82..304abe65e1eef 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.List; import java.util.Map; @@ -36,7 +36,7 @@ public class KeyCreateParameters { * The keyAttributes property. */ @JsonProperty(value = "attributes") - private KeyAttributesInner keyAttributes; + private KeyAttributes keyAttributes; /** * Application-specific metadata in the form of key-value pairs. @@ -108,7 +108,7 @@ public KeyCreateParameters withKeyOps(List keyOps) { * * @return the keyAttributes value */ - public KeyAttributesInner keyAttributes() { + public KeyAttributes keyAttributes() { return this.keyAttributes; } @@ -118,7 +118,7 @@ public KeyAttributesInner keyAttributes() { * @param keyAttributes the keyAttributes value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters withKeyAttributes(KeyAttributesInner keyAttributes) { + public KeyCreateParameters withKeyAttributes(KeyAttributes keyAttributes) { this.keyAttributes = keyAttributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java similarity index 86% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyImportParameters.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java index cfa7bcf1b718b..23ef7ecdea255 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; @@ -23,13 +23,13 @@ public class KeyImportParameters { * The Json web key. */ @JsonProperty(required = true) - private JsonWebKeyInner key; + private JsonWebKey key; /** * The key management attributes. */ @JsonProperty(value = "attributes") - private KeyAttributesInner keyAttributes; + private KeyAttributes keyAttributes; /** * Application-specific metadata in the form of key-value pairs. @@ -61,7 +61,7 @@ public KeyImportParameters withHsm(Boolean hsm) { * * @return the key value */ - public JsonWebKeyInner key() { + public JsonWebKey key() { return this.key; } @@ -71,7 +71,7 @@ public JsonWebKeyInner key() { * @param key the key value to set * @return the KeyImportParameters object itself. */ - public KeyImportParameters withKey(JsonWebKeyInner key) { + public KeyImportParameters withKey(JsonWebKey key) { this.key = key; return this; } @@ -81,7 +81,7 @@ public KeyImportParameters withKey(JsonWebKeyInner key) { * * @return the keyAttributes value */ - public KeyAttributesInner keyAttributes() { + public KeyAttributes keyAttributes() { return this.keyAttributes; } @@ -91,7 +91,7 @@ public KeyAttributesInner keyAttributes() { * @param keyAttributes the keyAttributes value to set * @return the KeyImportParameters object itself. */ - public KeyImportParameters withKeyAttributes(KeyAttributesInner keyAttributes) { + public KeyImportParameters withKeyAttributes(KeyAttributes keyAttributes) { this.keyAttributes = keyAttributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyItemInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java similarity index 62% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyItemInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index 29c682ec434d6..dbeb9a1516bbb 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyItemInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -4,14 +4,16 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.Map; +import com.microsoft.azure.keyvault.implementation.KeyIdentifier; + /** - * The KeyItemInner model. + * The KeyItem model. */ -public class KeyItemInner { +public class KeyItem { /** * Key Identifier. */ @@ -20,7 +22,7 @@ public class KeyItemInner { /** * The key management attributes. */ - private KeyAttributesInner attributes; + private KeyAttributes attributes; /** * Application-specific metadata in the form of key-value pairs. @@ -40,9 +42,9 @@ public String kid() { * Set the kid value. * * @param kid the kid value to set - * @return the KeyItemInner object itself. + * @return the KeyItem object itself. */ - public KeyItemInner withKid(String kid) { + public KeyItem withKid(String kid) { this.kid = kid; return this; } @@ -52,7 +54,7 @@ public KeyItemInner withKid(String kid) { * * @return the attributes value */ - public KeyAttributesInner attributes() { + public KeyAttributes attributes() { return this.attributes; } @@ -60,9 +62,9 @@ public KeyAttributesInner attributes() { * Set the attributes value. * * @param attributes the attributes value to set - * @return the KeyItemInner object itself. + * @return the KeyItem object itself. */ - public KeyItemInner withAttributes(KeyAttributesInner attributes) { + public KeyItem withAttributes(KeyAttributes attributes) { this.attributes = attributes; return this; } @@ -80,11 +82,23 @@ public Map tags() { * Set the tags value. * * @param tags the tags value to set - * @return the KeyItemInner object itself. + * @return the KeyItem object itself. */ - public KeyItemInner withTags(Map tags) { + public KeyItem withTags(Map tags) { this.tags = tags; return this; } + + /** + * @return The Identifier value + */ + public KeyIdentifier identifier() { + KeyIdentifier identifier = null; + + if (kid() != null && !kid().isEmpty()) { + identifier = new KeyIdentifier(kid()); + } + return identifier; + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationResultInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java similarity index 68% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationResultInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java index 980e0b2123bac..46057b6f20742 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationResultInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java @@ -4,14 +4,15 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; +import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; /** - * The KeyOperationResultInner model. + * The KeyOperationResult model. */ -public class KeyOperationResultInner { +public class KeyOperationResult { /** * Key identifier. */ @@ -22,7 +23,7 @@ public class KeyOperationResultInner { * The result property. */ @JsonProperty(value = "value", access = JsonProperty.Access.WRITE_ONLY) - private String result; + private Base64Url result; /** * Get the kid value. @@ -38,8 +39,11 @@ public String kid() { * * @return the result value */ - public String result() { - return this.result; + public byte[] result() { + if (this.result == null) { + return null; + } + return this.result.getDecodedBytes(); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationsParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java similarity index 77% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationsParameters.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java index 4904582f1f333..84381a63f3528 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyOperationsParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java @@ -4,8 +4,9 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; +import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; /** @@ -22,7 +23,7 @@ public class KeyOperationsParameters { * The value property. */ @JsonProperty(required = true) - private String value; + private Base64Url value; /** * Get the algorithm value. @@ -49,8 +50,11 @@ public KeyOperationsParameters withAlgorithm(String algorithm) { * * @return the value value */ - public String value() { - return this.value; + public byte[] value() { + if (this.value == null) { + return null; + } + return this.value.getDecodedBytes(); } /** @@ -59,8 +63,8 @@ public String value() { * @param value the value value to set * @return the KeyOperationsParameters object itself. */ - public KeyOperationsParameters withValue(String value) { - this.value = value; + public KeyOperationsParameters withValue(byte[] value) { + this.value = Base64Url.encode(value); return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java similarity index 84% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyProperties.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java index c10ecb32bcf27..6452c1ddca7d1 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; @@ -20,7 +20,8 @@ public class KeyProperties { /** * The key type. */ - private String kty; + @JsonProperty(value = "kty") + private String keyType; /** * The key size. @@ -55,22 +56,22 @@ public KeyProperties withExportable(Boolean exportable) { } /** - * Get the kty value. + * Get the keyType value. * - * @return the kty value + * @return the keyType value */ - public String kty() { - return this.kty; + public String keyType() { + return this.keyType; } /** - * Set the kty value. + * Set the keyType value. * - * @param kty the kty value to set + * @param keyType the keyType value to set * @return the KeyProperties object itself. */ - public KeyProperties withKty(String kty) { - this.kty = kty; + public KeyProperties withKeyType(String keyType) { + this.keyType = keyType; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyRestoreParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java similarity index 64% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyRestoreParameters.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java index 921b368c43f84..c35ae6b9ca12c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyRestoreParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java @@ -4,8 +4,9 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; +import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; /** @@ -16,15 +17,18 @@ public class KeyRestoreParameters { * the backup blob associated with a key bundle. */ @JsonProperty(value = "value", required = true) - private String keyBundleBackup; + private Base64Url keyBundleBackup; /** * Get the keyBundleBackup value. * * @return the keyBundleBackup value */ - public String keyBundleBackup() { - return this.keyBundleBackup; + public byte[] keyBundleBackup() { + if (this.keyBundleBackup == null) { + return null; + } + return this.keyBundleBackup.getDecodedBytes(); } /** @@ -33,8 +37,8 @@ public String keyBundleBackup() { * @param keyBundleBackup the keyBundleBackup value to set * @return the KeyRestoreParameters object itself. */ - public KeyRestoreParameters withKeyBundleBackup(String keyBundleBackup) { - this.keyBundleBackup = keyBundleBackup; + public KeyRestoreParameters withKeyBundleBackup(byte[] keyBundleBackup) { + this.keyBundleBackup = Base64Url.encode(keyBundleBackup); return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java similarity index 89% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyUpdateParameters.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java index 9466ee100573d..8b5a4d6e75c7e 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.List; import java.util.Map; @@ -25,7 +25,7 @@ public class KeyUpdateParameters { * The keyAttributes property. */ @JsonProperty(value = "attributes") - private KeyAttributesInner keyAttributes; + private KeyAttributes keyAttributes; /** * Application-specific metadata in the form of key-value pairs. @@ -57,7 +57,7 @@ public KeyUpdateParameters withKeyOps(List keyOps) { * * @return the keyAttributes value */ - public KeyAttributesInner keyAttributes() { + public KeyAttributes keyAttributes() { return this.keyAttributes; } @@ -67,7 +67,7 @@ public KeyAttributesInner keyAttributes() { * @param keyAttributes the keyAttributes value to set * @return the KeyUpdateParameters object itself. */ - public KeyUpdateParameters withKeyAttributes(KeyAttributesInner keyAttributes) { + public KeyUpdateParameters withKeyAttributes(KeyAttributes keyAttributes) { this.keyAttributes = keyAttributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java new file mode 100644 index 0000000000000..020a9073e1b50 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java @@ -0,0 +1,42 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +/** + * Defines values for KeyUsageType. + */ +public final class KeyUsageType { + /** Static value digitalSignature for KeyUsageType. */ + public static final String DIGITAL_SIGNATURE = "digitalSignature"; + + /** Static value nonRepudiation for KeyUsageType. */ + public static final String NON_REPUDIATION = "nonRepudiation"; + + /** Static value keyEncipherment for KeyUsageType. */ + public static final String KEY_ENCIPHERMENT = "keyEncipherment"; + + /** Static value dataEncipherment for KeyUsageType. */ + public static final String DATA_ENCIPHERMENT = "dataEncipherment"; + + /** Static value keyAgreement for KeyUsageType. */ + public static final String KEY_AGREEMENT = "keyAgreement"; + + /** Static value keyCertSign for KeyUsageType. */ + public static final String KEY_CERT_SIGN = "keyCertSign"; + + /** Static value cRLSign for KeyUsageType. */ + public static final String C_RLSIGN = "cRLSign"; + + /** Static value encipherOnly for KeyUsageType. */ + public static final String ENCIPHER_ONLY = "encipherOnly"; + + /** Static value decipherOnly for KeyUsageType. */ + public static final String DECIPHER_ONLY = "decipherOnly"; + + private KeyUsageType() { + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultError.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java similarity index 90% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultError.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java index 76f5f95f69a7c..4666ffa6c2f6a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultError.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultErrorException.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java similarity index 97% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultErrorException.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java index 71fbfd04d67de..1501eb1adc162 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVaultErrorException.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.microsoft.rest.RestException; import retrofit2.Response; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java similarity index 72% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyParameters.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java index efeaf0e3e1672..e393a8a8f0ff9 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java @@ -4,8 +4,9 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; +import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; /** @@ -23,13 +24,13 @@ public class KeyVerifyParameters { * The digest used for signing. */ @JsonProperty(required = true) - private String digest; + private Base64Url digest; /** * The signature to be verified. */ @JsonProperty(value = "value", required = true) - private String signature; + private Base64Url signature; /** * Get the algorithm value. @@ -56,8 +57,11 @@ public KeyVerifyParameters withAlgorithm(String algorithm) { * * @return the digest value */ - public String digest() { - return this.digest; + public byte[] digest() { + if (this.digest == null) { + return null; + } + return this.digest.getDecodedBytes(); } /** @@ -66,8 +70,8 @@ public String digest() { * @param digest the digest value to set * @return the KeyVerifyParameters object itself. */ - public KeyVerifyParameters withDigest(String digest) { - this.digest = digest; + public KeyVerifyParameters withDigest(byte[] digest) { + this.digest = Base64Url.encode(digest); return this; } @@ -76,8 +80,11 @@ public KeyVerifyParameters withDigest(String digest) { * * @return the signature value */ - public String signature() { - return this.signature; + public byte[] signature() { + if (this.signature == null) { + return null; + } + return this.signature.getDecodedBytes(); } /** @@ -86,8 +93,8 @@ public String signature() { * @param signature the signature value to set * @return the KeyVerifyParameters object itself. */ - public KeyVerifyParameters withSignature(String signature) { - this.signature = signature; + public KeyVerifyParameters withSignature(byte[] signature) { + this.signature = Base64Url.encode(signature); return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyResultInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java similarity index 80% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyResultInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java index 498c3377c2060..d69200854435f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/KeyVerifyResultInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java @@ -4,14 +4,14 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; /** - * The KeyVerifyResultInner model. + * The KeyVerifyResult model. */ -public class KeyVerifyResultInner { +public class KeyVerifyResult { /** * true if the signature is verified, false otherwise. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/LifetimeAction.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java similarity index 95% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/LifetimeAction.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java index 21f9d6790b667..f381b9b90c05b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/LifetimeAction.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java new file mode 100644 index 0000000000000..4968fde2996ad --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java @@ -0,0 +1,67 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The OrganizationDetails model. + */ +public class OrganizationDetails { + /** + * Id of the organization. + */ + private String id; + + /** + * Details of the organization administrator. + */ + @JsonProperty(value = "AdministratorDetails") + private List administratorDetails; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the OrganizationDetails object itself. + */ + public OrganizationDetails withId(String id) { + this.id = id; + return this; + } + + /** + * Get the administratorDetails value. + * + * @return the administratorDetails value + */ + public List administratorDetails() { + return this.administratorDetails; + } + + /** + * Set the administratorDetails value. + * + * @param administratorDetails the administratorDetails value to set + * @return the OrganizationDetails object itself. + */ + public OrganizationDetails withAdministratorDetails(List administratorDetails) { + this.administratorDetails = administratorDetails; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PageImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java similarity index 96% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PageImpl.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java index 315104b999a07..9d209d1c4472e 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PageImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; import com.microsoft.azure.Page; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PendingCertificateSigningRequestResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java similarity index 92% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PendingCertificateSigningRequestResult.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java index eccaac27e5af8..4be0e50df8043 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/PendingCertificateSigningRequestResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateAttributesInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java similarity index 52% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateAttributesInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java index 0950c26cb7842..4edba47d30062 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/CertificateAttributesInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java @@ -4,11 +4,11 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; /** - * The CertificateAttributesInner model. + * The secret management attributes. */ -public class CertificateAttributesInner extends Attributes { +public class SecretAttributes extends Attributes { } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretBundleInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java similarity index 56% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretBundleInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index fa342a844c7cf..83b615cb90d1d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretBundleInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -4,14 +4,20 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; +import java.io.IOException; import java.util.Map; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.implementation.SecretIdentifier; + /** - * The SecretBundleInner model. + * The SecretBundle model. */ -public class SecretBundleInner { +public class SecretBundle { /** * The secret value. */ @@ -30,7 +36,7 @@ public class SecretBundleInner { /** * The secret management attributes. */ - private SecretAttributesInner attributes; + private SecretAttributes attributes; /** * Application-specific metadata in the form of key-value pairs. @@ -50,9 +56,9 @@ public String value() { * Set the value value. * * @param value the value value to set - * @return the SecretBundleInner object itself. + * @return the SecretBundle object itself. */ - public SecretBundleInner withValue(String value) { + public SecretBundle withValue(String value) { this.value = value; return this; } @@ -70,9 +76,9 @@ public String id() { * Set the id value. * * @param id the id value to set - * @return the SecretBundleInner object itself. + * @return the SecretBundle object itself. */ - public SecretBundleInner withId(String id) { + public SecretBundle withId(String id) { this.id = id; return this; } @@ -90,9 +96,9 @@ public String contentType() { * Set the contentType value. * * @param contentType the contentType value to set - * @return the SecretBundleInner object itself. + * @return the SecretBundle object itself. */ - public SecretBundleInner withContentType(String contentType) { + public SecretBundle withContentType(String contentType) { this.contentType = contentType; return this; } @@ -102,7 +108,7 @@ public SecretBundleInner withContentType(String contentType) { * * @return the attributes value */ - public SecretAttributesInner attributes() { + public SecretAttributes attributes() { return this.attributes; } @@ -110,9 +116,9 @@ public SecretAttributesInner attributes() { * Set the attributes value. * * @param attributes the attributes value to set - * @return the SecretBundleInner object itself. + * @return the SecretBundle object itself. */ - public SecretBundleInner withAttributes(SecretAttributesInner attributes) { + public SecretBundle withAttributes(SecretAttributes attributes) { this.attributes = attributes; return this; } @@ -130,11 +136,33 @@ public Map tags() { * Set the tags value. * * @param tags the tags value to set - * @return the SecretBundleInner object itself. + * @return the SecretBundle object itself. */ - public SecretBundleInner withTags(Map tags) { + public SecretBundle withTags(Map tags) { this.tags = tags; return this; } + + + public SecretIdentifier secretIdentifier() { + if (id() == null || id().length() == 0) { + return null; + } + return new SecretIdentifier(id()); + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretItemInner.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java similarity index 65% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretItemInner.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index a73028014a936..d68f4494dcd06 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretItemInner.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -4,14 +4,16 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.Map; +import com.microsoft.azure.keyvault.implementation.SecretIdentifier; + /** - * The SecretItemInner model. + * The SecretItem model. */ -public class SecretItemInner { +public class SecretItem { /** * Secret Identifier. */ @@ -20,7 +22,7 @@ public class SecretItemInner { /** * The secret management attributes. */ - private SecretAttributesInner attributes; + private SecretAttributes attributes; /** * Application-specific metadata in the form of key-value pairs. @@ -45,9 +47,9 @@ public String id() { * Set the id value. * * @param id the id value to set - * @return the SecretItemInner object itself. + * @return the SecretItem object itself. */ - public SecretItemInner withId(String id) { + public SecretItem withId(String id) { this.id = id; return this; } @@ -57,7 +59,7 @@ public SecretItemInner withId(String id) { * * @return the attributes value */ - public SecretAttributesInner attributes() { + public SecretAttributes attributes() { return this.attributes; } @@ -65,9 +67,9 @@ public SecretAttributesInner attributes() { * Set the attributes value. * * @param attributes the attributes value to set - * @return the SecretItemInner object itself. + * @return the SecretItem object itself. */ - public SecretItemInner withAttributes(SecretAttributesInner attributes) { + public SecretItem withAttributes(SecretAttributes attributes) { this.attributes = attributes; return this; } @@ -85,9 +87,9 @@ public Map tags() { * Set the tags value. * * @param tags the tags value to set - * @return the SecretItemInner object itself. + * @return the SecretItem object itself. */ - public SecretItemInner withTags(Map tags) { + public SecretItem withTags(Map tags) { this.tags = tags; return this; } @@ -105,11 +107,23 @@ public String contentType() { * Set the contentType value. * * @param contentType the contentType value to set - * @return the SecretItemInner object itself. + * @return the SecretItem object itself. */ - public SecretItemInner withContentType(String contentType) { + public SecretItem withContentType(String contentType) { this.contentType = contentType; return this; } + /** + * @return The Identifier value + */ + public SecretIdentifier identifier() { + SecretIdentifier identifier = null; + + if (id() != null && !id().isEmpty()) { + identifier = new SecretIdentifier(id()); + } + + return identifier; + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java similarity index 93% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretProperties.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java index 8004af2957c05..8c588dc20194a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java similarity index 91% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretSetParameters.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java index b964181c1e2bf..77a95e23b8de4 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretSetParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; @@ -30,10 +30,10 @@ public class SecretSetParameters { private String contentType; /** - * The secretAttributes property. + * The secret management attributes. */ @JsonProperty(value = "attributes") - private SecretAttributesInner secretAttributes; + private SecretAttributes secretAttributes; /** * Get the value value. @@ -100,7 +100,7 @@ public SecretSetParameters withContentType(String contentType) { * * @return the secretAttributes value */ - public SecretAttributesInner secretAttributes() { + public SecretAttributes secretAttributes() { return this.secretAttributes; } @@ -110,7 +110,7 @@ public SecretAttributesInner secretAttributes() { * @param secretAttributes the secretAttributes value to set * @return the SecretSetParameters object itself. */ - public SecretSetParameters withSecretAttributes(SecretAttributesInner secretAttributes) { + public SecretSetParameters withSecretAttributes(SecretAttributes secretAttributes) { this.secretAttributes = secretAttributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java similarity index 89% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretUpdateParameters.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java index 4e682f6baa37f..71f75ba128cdd 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SecretUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; @@ -19,10 +19,10 @@ public class SecretUpdateParameters { private String contentType; /** - * The secretAttributes property. + * The secret management attributes. */ @JsonProperty(value = "attributes") - private SecretAttributesInner secretAttributes; + private SecretAttributes secretAttributes; /** * Application-specific metadata in the form of key-value pairs. @@ -54,7 +54,7 @@ public SecretUpdateParameters withContentType(String contentType) { * * @return the secretAttributes value */ - public SecretAttributesInner secretAttributes() { + public SecretAttributes secretAttributes() { return this.secretAttributes; } @@ -64,7 +64,7 @@ public SecretAttributesInner secretAttributes() { * @param secretAttributes the secretAttributes value to set * @return the SecretUpdateParameters object itself. */ - public SecretUpdateParameters withSecretAttributes(SecretAttributesInner secretAttributes) { + public SecretUpdateParameters withSecretAttributes(SecretAttributes secretAttributes) { this.secretAttributes = secretAttributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SubjectAlternativeNames.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java similarity index 97% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SubjectAlternativeNames.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java index 06cd128d1b833..0add3eae269df 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/SubjectAlternativeNames.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Trigger.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java similarity index 54% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Trigger.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java index df3b61f908745..900129b0a5da0 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/Trigger.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; @@ -13,11 +13,18 @@ */ public class Trigger { /** - * The type of the action. + * Percentage of lifetime as which to trigger. Value should be between 1 + * and 99. */ @JsonProperty(value = "lifetime_percentage") private Integer lifetimePercentage; + /** + * Days before expiry. + */ + @JsonProperty(value = "days_before_expiry") + private Integer daysBeforeExpiry; + /** * Get the lifetimePercentage value. * @@ -38,4 +45,24 @@ public Trigger withLifetimePercentage(Integer lifetimePercentage) { return this; } + /** + * Get the daysBeforeExpiry value. + * + * @return the daysBeforeExpiry value + */ + public Integer daysBeforeExpiry() { + return this.daysBeforeExpiry; + } + + /** + * Set the daysBeforeExpiry value. + * + * @param daysBeforeExpiry the daysBeforeExpiry value to set + * @return the Trigger object itself. + */ + public Trigger withDaysBeforeExpiry(Integer daysBeforeExpiry) { + this.daysBeforeExpiry = daysBeforeExpiry; + return this; + } + } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/X509CertificateProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java similarity index 96% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/X509CertificateProperties.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java index 2aeae068b0fb9..e66ee40ec72f3 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/X509CertificateProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; @@ -19,7 +19,7 @@ public class X509CertificateProperties { private String subject; /** - * The subject alternate names. + * The enhaunced key usage. */ private List ekus; @@ -30,7 +30,7 @@ public class X509CertificateProperties { private SubjectAlternativeNames subjectAlternativeNames; /** - * The subject alternate names. + * List of key usages. */ @JsonProperty(value = "key_usage") private List keyUsage; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java similarity index 67% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/package-info.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java index 4b09867281625..241355f8ecd6f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/api/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java @@ -3,7 +3,7 @@ // regenerated. /** - * This package contains the implementation.api classes for KeyVaultClient. + * This package contains the models classes for KeyVaultClient. * Client class to perform cryptographic key operations and vault operations against the Key Vault service. */ -package com.microsoft.azure.keyvault.implementation.api; +package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java new file mode 100644 index 0000000000000..6a39ee15891d0 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java @@ -0,0 +1,39 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.webkey; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Supported JsonWebKey Algorithms + */ +public final class JsonWebKeyEncryptionAlgorithm { + + public static final String RSAOAEP = "RSA-OAEP"; + public static final String RSA15 = "RSA1_5"; + + public static final List ALL_ALGORITHMS = Collections.unmodifiableList(Arrays.asList(new String[] { RSA15, RSAOAEP })); + + private JsonWebKeyEncryptionAlgorithm() { + // not instantiable + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java new file mode 100644 index 0000000000000..cceb635f4a88a --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java @@ -0,0 +1,43 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.webkey; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Supported JsonWebKey operations + */ +public final class JsonWebKeyOperation { + + public static final String ENCRYPT = "encrypt"; + public static final String DECRYPT = "decrypt"; + public static final String SIGN = "sign"; + public static final String VERIFY = "verify"; + public static final String WRAP = "wrapKey"; + public static final String UNWRAP = "unwrapKey"; + + public static final List ALL_OPERATIONS = Collections.unmodifiableList(Arrays.asList(new String[] { ENCRYPT, DECRYPT, SIGN, VERIFY, WRAP, UNWRAP })); + + private JsonWebKeyOperation() { + // not instantiable + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java new file mode 100644 index 0000000000000..0c2d856aec0c0 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.webkey; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Supported JsonWebKey Algorithms + */ +public final class JsonWebKeySignatureAlgorithm { + + public static final String RS256 = "RS256"; + public static final String RS384 = "RS384"; + public static final String RS512 = "RS512"; + public static final String RSNULL = "RSNULL"; + + public static final List ALL_ALGORITHMS = Collections.unmodifiableList(Arrays.asList(new String[] { RS256, RS384, RS512, RSNULL })); + + private JsonWebKeySignatureAlgorithm() { + // not instantiable + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java new file mode 100644 index 0000000000000..af2dbf6b9351a --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.webkey; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Supported JsonWebKey key types (kty) + */ +public final class JsonWebKeyType { + + public static final String EC = "EC"; + public static final String RSA = "RSA"; + public static final String RSAHSM = "RSA-HSM"; + public static final String OCT = "oct"; + + public static final List ALL_TYPES = Collections.unmodifiableList(Arrays.asList(new String[] { EC, RSA, RSAHSM, OCT })); + + private JsonWebKeyType() { + // not instantiable + } +} diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java new file mode 100644 index 0000000000000..e82143de89ff5 --- /dev/null +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -0,0 +1,1276 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyStore; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.PKCS8EncodedKeySpec; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.concurrent.ExecutionException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; + +import org.apache.commons.codec.binary.Base64; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.keyvault.implementation.CertificateIdentifier; +import com.microsoft.azure.keyvault.implementation.SecretIdentifier; +import com.microsoft.azure.keyvault.implementation.requests.CreateCertificateRequest; +import com.microsoft.azure.keyvault.implementation.requests.ImportCertificateRequest; +import com.microsoft.azure.keyvault.implementation.requests.SetCertificateIssuerRequest; +import com.microsoft.azure.keyvault.implementation.requests.UpdateCertificateIssuerRequest; +import com.microsoft.azure.keyvault.models.AdministratorDetails; +import com.microsoft.azure.keyvault.models.CertificateBundle; +import com.microsoft.azure.keyvault.models.Contact; +import com.microsoft.azure.keyvault.models.Contacts; +import com.microsoft.azure.keyvault.models.IssuerBundle; +import com.microsoft.azure.keyvault.models.IssuerCredentials; +import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.KeyVaultErrorException; +import com.microsoft.azure.keyvault.models.OrganizationDetails; +import com.microsoft.azure.keyvault.models.CertificateItem; +import com.microsoft.azure.keyvault.models.CertificateOperation; +import com.microsoft.azure.keyvault.models.CertificatePolicy; +import com.microsoft.azure.keyvault.models.SecretBundle; +import com.microsoft.azure.keyvault.models.SecretProperties; +import com.microsoft.azure.keyvault.models.X509CertificateProperties; + +public class CertificateOperationsTest extends KeyVaultClientIntegrationTestBase { + + static final String ALGO_RSA = "RSA"; + + static final String X509 = "X.509"; + + static final String PKCS12 = "PKCS12"; + + static final String MIME_PKCS12 = "application/x-pkcs12"; + + static final String MIME_PEM = "application/x-pem-file"; + + static final String ISSUER_SELF = "Self"; + + static final String ISSUER_TEST = "Test"; + + static final String ISSUER_UNKNOWN = "Unknown"; + + static final String STATUS_IN_PROGRESS = "inProgress"; + + static final String STATUS_COMPLETED = "Completed"; + + static final Base64 _base64 = new Base64(-1, null, true); + + static final Pattern _privateKey = Pattern.compile("-{5}BEGIN PRIVATE KEY-{5}(?:\\s|\\r|\\n)+" + + "([a-zA-Z0-9+/=\r\n]+)" + "-{5}END PRIVATE KEY-{5}(?:\\s|\\r|\\n)+"); + + static final Pattern _certificate = Pattern.compile("-{5}BEGIN CERTIFICATE-{5}(?:\\s|\\r|\\n)+" + + "([a-zA-Z0-9+/=\r\n]+)" + "-{5}END CERTIFICATE-{5}(?:\\s|\\r|\\n)+"); + + private static final int MAX_CERTS = 4; + private static final int PAGELIST_MAX_CERTS = 3; + + /** + * Create a self-signed certificate in PKCS12 format (which includes the + * private key) certificate. + * + * @throws Exception + */ + @Test + public void createSelfSignedCertificatePkcs12() throws Exception { + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PKCS12); + + X509CertificateProperties x509Properties = new X509CertificateProperties(); + String subjectName = "CN=SelfSignedJavaPkcs12"; + x509Properties.withSubject(subjectName); + x509Properties.withValidityInMonths(12); + + // Set issuer to "Self" + IssuerReference issuerReference = new IssuerReference(); + issuerReference.withName(ISSUER_SELF); + + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + certificatePolicy.withIssuerReference(issuerReference); + certificatePolicy.withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "createSelfSignedJavaPkcs12"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withCertificatePolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + + CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); + Assert.assertNotNull(certificateBundle); + Assert.assertNotNull(certificateBundle.id()); + Assert.assertNotNull(certificateBundle.keyIdentifier()); + Assert.assertNotNull(certificateBundle.secretIdentifier()); + Assert.assertNotNull(certificateBundle.x5t()); + + // Load the CER part into X509Certificate object + Assert.assertNotNull(certificateBundle.cer()); + ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); + cerStream.close(); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + + // Load the secret into a KeyStore + ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); + String secretPassword = ""; + KeyStore keyStore = KeyStore.getInstance(PKCS12); + keyStore.load(secretStream, secretPassword.toCharArray()); + secretStream.close(); + + // Validate the certificate in the KeyStore + String defaultAlias = Collections.list(keyStore.aliases()).get(0); + X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); + Assert.assertNotNull(secretCertificate); + Assert.assertTrue(secretCertificate.getPublicKey().equals(x509Certificate.getPublicKey())); + Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() + .equals(x509Certificate.getSubjectX500Principal().getName())); + Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() + .equals(x509Certificate.getIssuerX500Principal().getName())); + Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); + + // Validate the key in the KeyStore + Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); + Assert.assertNotNull(secretKey); + Assert.assertTrue(secretKey instanceof PrivateKey); + PrivateKey secretPrivateKey = (PrivateKey) secretKey; + + // Create a KeyPair with the private key from the KeyStore and public + // key from the certificate to verify they match + KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); + Assert.assertNotNull(keyPair); + verifyRSAKeyPair(keyPair); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Create a self-signed certificate in PEM format (which includes the + * private key) certificate. + * + * @throws Exception + */ + @Test + public void createSelfSignedCertificatePem() throws Exception { + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PEM); + + X509CertificateProperties x509Properties = new X509CertificateProperties(); + String subjectName = "CN=SelfSignedJavaPem"; + x509Properties.withSubject(subjectName); + x509Properties.withValidityInMonths(12); + + // Set issuer to "Self" + IssuerReference issuerReference = new IssuerReference(); + issuerReference.withName(ISSUER_SELF); + + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + certificatePolicy.withIssuerReference(issuerReference); + certificatePolicy.withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "SelfSignedJavaPem"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withCertificatePolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + + CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); + Assert.assertNotNull(certificateBundle); + Assert.assertNotNull(certificateBundle.id()); + Assert.assertNotNull(certificateBundle.kid()); + Assert.assertNotNull(certificateBundle.sid()); + Assert.assertNotNull(certificateBundle.x5t()); + + // Load the CER part into X509Certificate object + Assert.assertNotNull(certificateBundle.cer()); + ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); + cerStream.close(); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + String secretValue = secret.value(); + + // Extract private key from PEM + PrivateKey secretPrivateKey = extractPrivateKeyFromPemContents(secretValue); + Assert.assertNotNull(secretPrivateKey); + + // Extract certificates from PEM + List certificates = extractCertificatesFromPemContents(secretValue); + Assert.assertNotNull(certificates); + Assert.assertTrue(certificates.size() == 1); + + // TODO: Iterate over certificates collection to find which certificate + // has the public key corresponding to the private key. + X509Certificate secretCertificate = certificates.get(0); + Assert.assertNotNull(secretCertificate); + Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() + .equals(x509Certificate.getSubjectX500Principal().getName())); + Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() + .equals(x509Certificate.getIssuerX500Principal().getName())); + Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); + + // Create a KeyPair with the private key from the KeyStore and public + // key from the certificate to verify they match + KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); + Assert.assertNotNull(keyPair); + verifyRSAKeyPair(keyPair); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Create a test-issuer issued certificate in PKCS12 format (which includes + * the private key) certificate. + * + * @throws Exception + */ + @Test + public void createCertificatePkcs12() throws Exception { + // Construct organization administrator details + AdministratorDetails administratorDetails = new AdministratorDetails(); + administratorDetails.withFirstName("John"); + administratorDetails.withLastName("Doe"); + administratorDetails.withEmailAddress("john.doe@contoso.com"); + administratorDetails.withPhone("1234567890"); + + // Construct organization details + OrganizationDetails organizationDetails = new OrganizationDetails(); + List administratorsDetails = new ArrayList(); + administratorsDetails.add(administratorDetails); + organizationDetails.withAdministratorDetails(administratorsDetails); + + // Construct certificate issuer credentials + IssuerCredentials credentials = new IssuerCredentials(); + credentials.withAccountId("account1"); + credentials.withPassword("Pa$$w0rd"); + + IssuerBundle certificateIssuer = new IssuerBundle(); + certificateIssuer.withProvider(ISSUER_TEST); + certificateIssuer.withCredentials(credentials); + certificateIssuer.withOrganizationDetails(organizationDetails); + + String certificateIssuerName = "createCertificateJavaPkcs12Issuer01"; + IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( + new SetCertificateIssuerRequest + .Builder(getVaultUri(),certificateIssuerName) + .withIssuer(certificateIssuer) + .build()).getBody(); + + Assert.assertNotNull(createdCertificateIssuer); + Assert.assertNotNull(createdCertificateIssuer.issuerIdentifier()); + Assert.assertNotNull(createdCertificateIssuer.issuerIdentifier().name()); + Assert.assertTrue(createdCertificateIssuer.issuerIdentifier().name().equalsIgnoreCase(certificateIssuerName)); + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PKCS12); + + X509CertificateProperties x509Properties = new X509CertificateProperties(); + String subjectName = "CN=TestJavaPkcs12"; + x509Properties.withSubject(subjectName); + x509Properties.withValidityInMonths(12); + + // Set issuer reference to the created issuer + IssuerReference issuerReference = new IssuerReference(); + issuerReference.withName(createdCertificateIssuer.issuerIdentifier().name()); + + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + certificatePolicy.withIssuerReference(issuerReference); + certificatePolicy.withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "createTestJavaPkcs12"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withCertificatePolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + + CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); + Assert.assertNotNull(certificateBundle); + Assert.assertNotNull(certificateBundle.id()); + Assert.assertNotNull(certificateBundle.keyIdentifier()); + Assert.assertNotNull(certificateBundle.secretIdentifier()); + Assert.assertNotNull(certificateBundle.x5t()); + Assert.assertNotNull(certificateBundle.policy()); + Assert.assertNotNull(certificateBundle.policy().issuerReference()); + Assert.assertNotNull(certificateBundle.policy().issuerReference().name()); + Assert.assertTrue( + certificateBundle.policy().issuerReference().name().equalsIgnoreCase(certificateIssuerName)); + + // Load the CER part into X509Certificate object + Assert.assertNotNull(certificateBundle.cer()); + ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); + cerStream.close(); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + + // Load the secret into a KeyStore + ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); + String secretPassword = ""; + KeyStore keyStore = KeyStore.getInstance(PKCS12); + keyStore.load(secretStream, secretPassword.toCharArray()); + secretStream.close(); + + // Validate the certificate in the KeyStore + String defaultAlias = Collections.list(keyStore.aliases()).get(0); + X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); + Assert.assertNotNull(secretCertificate); + Assert.assertTrue(secretCertificate.getPublicKey().equals(x509Certificate.getPublicKey())); + Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() + .equals(x509Certificate.getSubjectX500Principal().getName())); + Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() + .equals(x509Certificate.getIssuerX500Principal().getName())); + Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); + + // Validate the key in the KeyStore + Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); + Assert.assertNotNull(secretKey); + Assert.assertTrue(secretKey instanceof PrivateKey); + PrivateKey secretPrivateKey = (PrivateKey) secretKey; + + // Create a KeyPair with the private key from the KeyStore and public + // key from the certificate to verify they match + KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); + Assert.assertNotNull(keyPair); + verifyRSAKeyPair(keyPair); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Create a test-issuer certificate in PEM format (which includes the + * private key) certificate. + * + * @throws Exception + */ + @Test + public void createCertificatePem() throws Exception { + // Construct organization administrator details + AdministratorDetails administratorDetails = new AdministratorDetails(); + administratorDetails.withFirstName("John"); + administratorDetails.withLastName("Doe"); + administratorDetails.withEmailAddress("john.doe@contoso.com"); + administratorDetails.withPhone("1234567890"); + + // Construct organization details + OrganizationDetails organizationDetails = new OrganizationDetails(); + List administratorsDetails = new ArrayList(); + administratorsDetails.add(administratorDetails); + organizationDetails.withAdministratorDetails(administratorsDetails); + + // Construct certificate issuer credentials + IssuerCredentials credentials = new IssuerCredentials(); + credentials.withAccountId("account1"); + credentials.withPassword("Pa$$w0rd"); + + IssuerBundle certificateIssuer = new IssuerBundle(); + certificateIssuer.withProvider(ISSUER_TEST); + certificateIssuer.withCredentials(credentials); + certificateIssuer.withOrganizationDetails(organizationDetails); + + String certificateIssuerName = "createCertificateJavaPemIssuer01"; + IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( + new SetCertificateIssuerRequest + .Builder(getVaultUri(), certificateIssuerName) + .withIssuer(certificateIssuer) + .build()).getBody(); + Assert.assertNotNull(createdCertificateIssuer); + Assert.assertNotNull(createdCertificateIssuer.issuerIdentifier()); + Assert.assertNotNull(createdCertificateIssuer.issuerIdentifier().name()); + Assert.assertTrue(createdCertificateIssuer.issuerIdentifier().name().equalsIgnoreCase(certificateIssuerName)); + + // Set content type to indicate the certificate is PEM format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PEM); + + X509CertificateProperties x509Properties = new X509CertificateProperties(); + String subjectName = "CN=TestJavaPem"; + x509Properties.withSubject(subjectName); + x509Properties.withValidityInMonths(12); + + // Set issuer reference to the created issuer + IssuerReference issuerReference = new IssuerReference(); + issuerReference.withName(createdCertificateIssuer.issuerIdentifier().name()); + + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + certificatePolicy.withIssuerReference(issuerReference); + certificatePolicy.withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "createTestJavaPem"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withCertificatePolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + + CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); + Assert.assertNotNull(certificateBundle); + Assert.assertNotNull(certificateBundle.id()); + Assert.assertNotNull(certificateBundle.kid()); + Assert.assertNotNull(certificateBundle.sid()); + Assert.assertNotNull(certificateBundle.x5t()); + Assert.assertNotNull(certificateBundle.policy()); + Assert.assertNotNull(certificateBundle.policy().issuerReference()); + Assert.assertNotNull(certificateBundle.policy().issuerReference().name()); + Assert.assertTrue( + certificateBundle.policy().issuerReference().name().equalsIgnoreCase(certificateIssuerName)); + + // Load the CER part into X509Certificate object + Assert.assertNotNull(certificateBundle.cer()); + ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); + cerStream.close(); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + String secretValue = secret.value(); + + // Extract private key from PEM + PrivateKey secretPrivateKey = extractPrivateKeyFromPemContents(secretValue); + Assert.assertNotNull(secretPrivateKey); + + // Extract certificates from PEM + List certificates = extractCertificatesFromPemContents(secretValue); + Assert.assertNotNull(certificates); + Assert.assertTrue(certificates.size() == 1); + + // TODO: Iterate over certificates collection to find which certificate + // has the public key corresponding to the private key. + X509Certificate secretCertificate = certificates.get(0); + Assert.assertNotNull(secretCertificate); + Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() + .equals(x509Certificate.getSubjectX500Principal().getName())); + Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() + .equals(x509Certificate.getIssuerX500Principal().getName())); + Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); + + // Create a KeyPair with the private key from the KeyStore and public + // key from the certificate to verify they match + KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); + Assert.assertNotNull(keyPair); + verifyRSAKeyPair(keyPair); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } + catch(KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Create a certificate signing request with key in Key Vault. + * @throws ExecutionException + * @throws InterruptedException + * @throws IOException + * @throws IllegalArgumentException + * @throws KeyVaultErrorException + * + * @throws Exception + */ + @Test + public void createCsr() throws InterruptedException, ExecutionException, KeyVaultErrorException, IllegalArgumentException, IOException { + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PKCS12); + + X509CertificateProperties x509Properties = new X509CertificateProperties(); + String subjectName = "CN=ManualEnrollmentJava"; + x509Properties.withSubject(subjectName); + x509Properties.withValidityInMonths(12); + + // Set issuer to "Unknown" + IssuerReference issuerReference = new IssuerReference(); + issuerReference.withName(ISSUER_UNKNOWN); + + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + certificatePolicy.withIssuerReference(issuerReference); + certificatePolicy.withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "createManualEnrollmentJava4"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withCertificatePolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + Assert.assertNotNull(certificateOperation.csr()); + + String csr = keyVaultClient.getPendingCertificateSigningRequest(vaultUri, certificateName).getBody(); + Assert.assertNotNull(csr); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + /** + * Import a PKCS12 format (which includes the private key) certificate. + */ + @Test + public void importCertificatePkcs12() throws Exception { + String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; + String certificatePassword = "123"; + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PKCS12); + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + + String vaultUri = getVaultUri(); + String certificateName = "importCertPkcs"; + CertificateBundle certificateBundle = keyVaultClient.importCertificate( + new ImportCertificateRequest + .Builder(vaultUri, certificateName, certificateContent) + .withPassword(certificatePassword) + .withPolicy(certificatePolicy) + .build()).getBody(); + + // Validate the certificate bundle created + Assert.assertNotNull(certificateBundle); + Assert.assertNotNull(certificateBundle.id()); + Assert.assertNotNull(certificateBundle.kid()); + Assert.assertNotNull(certificateBundle.sid()); + Assert.assertNotNull(certificateBundle.x5t()); + + //TODO the x5t is different - fix it + //Assert.assertTrue(toHexString(certificateBundle.x5t()).equalsIgnoreCase("7cb8b7539d87ba7215357b9b9049dff2d3fa59ba")); + + // Load the CER part into X509Certificate object + Assert.assertNotNull(certificateBundle.cer()); + ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); + cerStream.close(); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals("CN=KeyVaultTest")); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals("CN=Root Agency")); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + + // Load the secret into a KeyStore + ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); + String secretPassword = ""; + KeyStore keyStore = KeyStore.getInstance(PKCS12); + keyStore.load(secretStream, secretPassword.toCharArray()); + secretStream.close(); + + // Validate the certificate in the KeyStore + String defaultAlias = Collections.list(keyStore.aliases()).get(0); + X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); + Assert.assertNotNull(secretCertificate); + Assert.assertTrue(secretCertificate.getPublicKey().equals(x509Certificate.getPublicKey())); + Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() + .equals(x509Certificate.getSubjectX500Principal().getName())); + Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() + .equals(x509Certificate.getIssuerX500Principal().getName())); + Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); + + // Validate the key in the KeyStore + Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); + Assert.assertNotNull(secretKey); + Assert.assertTrue(secretKey instanceof PrivateKey); + PrivateKey secretPrivateKey = (PrivateKey) secretKey; + + // Create a KeyPair with the private key from the KeyStore and public + // key from the certificate to verify they match + KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); + Assert.assertNotNull(keyPair); + verifyRSAKeyPair(keyPair); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Import a PEM format (which includes a encrypted private key) certificate. + * TODO: Server can't handle this yet. + */ + // @Test + public void importCertificatePem() throws Exception { + String certificateContent = "-----BEGIN ENCRYPTED PRIVATE KEY-----\n" + + "MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQI+mprWsX8IMICAggA\n" + + "MBQGCCqGSIb3DQMHBAgu4FUBoWBbGgSCBMhjsFyDgeqAVrMRXKaGpdstAHttWxGw\n" + + "JfkthRr8eULwldl2sYZdxwZaHOWjhhwp3LHZ7M5+6augyo1WxIJ456hPlZQ0nlXO\n" + + "y9pFBXEFSIeemd7JdVPjZ3HWVrkXapcKh12hqhzskdXlBermc5uS5NScOFJhnGFT\n" + + "68Va9KHglOmX2T0fUIagWnxQuP2gu3w3PIbbMt8tB0fN5H2xfd6xjKiTlb+3jHP2\n" + + "kZzAcPCzqgNlCK09fOqD9x+fFO2Zn6SqzPt66E8IMZ/7s41mF5IU8H0rIkA9vOZM\n" + + "oM41r0S+N1nhn1MV52aHcqQETV/odKq968dnLRiSIRLfSI9HQWubXu3jWeDHh3GC\n" + + "gaJbafDZWYjN42xIamm5xv3JEycED3Cqk4ibSJgw72uEIGZmhxzo8cXCelOezCBT\n" + + "aj3IkLfUej9p9UhIZJ6DX3kWFh7Ab5T4c23ZzV1WeDtLSANqh1FHFnWMxAcTOgY0\n" + + "0uPGKW03uz3RQdypI8GbrYlT0QiLAaCT6dijFyGNk8W1eAcFJQS4Vtp7PBG+o1qn\n" + + "+xdXVEiQxpZbiFeSMaydfxWAbin4gr98I55gf2VXq9VOFsRY2LxeNzmmEVt1HjuJ\n" + + "rCl4KB/d7VrB+Ev/zjUHDtD22f/Gca7VRET7FaG9Mdj4trtngKFc3B82Q98a3F2w\n" + + "l7ppYQMwdOFUrDRCCDdmatVJwtg/MAXxaIxwGAow+po0dQx2xyqz/8aIPoSg604d\n" + + "+Z5AEmpyLC7369+OZUtJfQ5bCmFbBLne9YvoDAKXuJ07fx+Sq7Hzrbb3uPQo6vgi\n" + + "QrLJhY8KgCFMMWzsfiVPOIGkWIR2KRiyX2HMbsYGRdhRsGl4xco8mmCv4C9WjR9A\n" + + "AT5mVi6U9/zMG1wJMrnVoPQ1E+pi+nuviWZWKZ8uqYOAOEwewHpuTrdmgPe1yoJ/\n" + + "beIYzTOEt9BemnuQge9/zdhH3U5667xWb08hV5dv1Z9ubLKbZx3Yea/J+EbfNW3B\n" + + "OxuacDsaMSSj1wiKKgeSkusrAikCvlsCJumTRAbu/uR6HgmqIlBpB3JTJHoCx90F\n" + + "BsIcwf73aFs/rQQJ6aZRi/fFgHpxWgtEQ9aTKXmhgbfTjjHYGYGkHvDNdzKaXu46\n" + + "6WliF9G0WAeotaGrRESvqVDswaM0F27KjtSdcmtdUQOtbtVVd84VClZqhbyd6tFh\n" + + "lqFsHO9oN+mQQJNhemqiL/Tdo+BQwGxeWjlstd7HlwUsc1sp0OLA8h8QlteBAnNb\n" + + "KpOQYblZbCZX4uZR5KJYDeCuDmWp/Qg7gcKyRLC9I+PrzYockl375RuK60Lws8B+\n" + + "kW49wYHzJFf7DOwuV/2TwkOwP0jcr9nWkjS1uwryuYbp9zPuqddHWggt2rDIlBIG\n" + + "aCU46hS1cGJmzLcIF8TAg8hPQgSikr1AIseyDnWK96OnrTRVK8TbVWOHwvJWr92g\n" + + "ZLwgAve79qgG4LPCOF1HZSeU9sq81FbzPz+BGdVLn5xkoZ1gyjclR78W6jeeTGH3\n" + + "efiw9atBkAiUKaODMXbtHm93JcSQ5sK0r66J7uAQVjLIMu757V0paJNjfF5WoisC\n" + + "3nwuSbg71YHNgvlx/OYWRBRreT/zDgApvnrYqUsUPSQaybMc/9Pbjj76T4AWmjVa\n" + + "JHA=\n" + + "-----END ENCRYPTED PRIVATE KEY-----\n" + + "-----BEGIN CERTIFICATE-----\n" + + "MIIDozCCAougAwIBAgIJAIvNGnmenqgjMA0GCSqGSIb3DQEBCwUAMGgxCzAJBgNV\n" + + "BAYTAlVTMQswCQYDVQQIDAJXQTEQMA4GA1UEBwwHUmVkbW9uZDEXMBUGA1UECgwO\n" + + "TWljcm9zb2Z0IENvcnAxDjAMBgNVBAsMBUF6dXJlMREwDwYDVQQDDAhLZXlWYXVs\n" + + "dDAeFw0xNjA0MDEyMzAwMjlaFw0xNjA1MzEyMzAwMjlaMGgxCzAJBgNVBAYTAlVT\n" + + "MQswCQYDVQQIDAJXQTEQMA4GA1UEBwwHUmVkbW9uZDEXMBUGA1UECgwOTWljcm9z\n" + + "b2Z0IENvcnAxDjAMBgNVBAsMBUF6dXJlMREwDwYDVQQDDAhLZXlWYXVsdDCCASIw\n" + + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN1udkhsWIwmua3SFJWxS9AJoKK5\n" + + "o7RAHwsQUWWNkSsPiWrzDYXarfUEs1HBEsAjOJDabK1L0ahw4Manx0NXDOmw8kuD\n" + + "lNMs4yTZNxvECvKpq37Z6Q3D9ts4sVSeFbXtOYr81P+8DOOH3Ibk3sldoJBMXJ5h\n" + + "pw4R72988m9CZ9KjcdaKFk3L1baCehpwkJLZD2XD7MzV9YBKNnd15DPCkVZHul1t\n" + + "bW0E7kf7vUOPIfRuNZeN6QvqsKTA+RoGh3CVu9QV+XG/AsHDoHUwGUlJPvOCm3U5\n" + + "tDrrbXAP+Wa/kE/fGAJkZQLPcbappUI4Swtt9u7+CpyQ96H7BY1yHvmBzBUCAwEA\n" + + "AaNQME4wHQYDVR0OBBYEFJ9DSIY/4ODmWY7oIQkGDD7KlQnAMB8GA1UdIwQYMBaA\n" + + "FJ9DSIY/4ODmWY7oIQkGDD7KlQnAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEL\n" + + "BQADggEBAGV3fTAVWd1tdgcaogBirn1LF8d3H45bdDtjD98933dsOCYlXHKNdB62\n" + + "6Qwg6XF9a+p1vuHI1I8MKBu//q+pLJce+bi2jmge64zlz/iO3sLSOFo/q1EWzhal\n" + + "TRglNkvqWr7OvJXdUznQI3AzjB8tbFB2YerSbmD6FxAAihEq8ZoJ1BsMq5vknpPB\n" + + "iETENaNSjdgPEsiapYNALgY4AVxtSS5GJDZ9zpc5Q6HCPmUozLbQheNZf3+D75cy\n" + + "gB2odtfwhKCuIfuMan51UqjupK0JVJuNV4MXRXH0mFPEBxI4pYolFuV8960jGXqE\n" + + "m/26LtCJLW5QaedtCCKpn9fat5VHgso=\n" + + "-----END CERTIFICATE-----\n"; + + String certificatePassword = "1234"; + + // Set content type to indicate the certificate is PEM format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PEM); + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + + String vaultUri = getVaultUri(); + String certificateName = "importCertPem"; + CertificateBundle certificateBundle = keyVaultClient.importCertificate( + new ImportCertificateRequest + .Builder(vaultUri, certificateName, certificateContent) + .withPassword(certificatePassword) + .withPolicy(certificatePolicy) + .build()).getBody(); + + // Validate the certificate bundle created + Assert.assertNotNull(certificateBundle); + Assert.assertNotNull(certificateBundle.id()); + Assert.assertNotNull(certificateBundle.kid()); + Assert.assertNotNull(certificateBundle.sid()); + Assert.assertNotNull(certificateBundle.x5t()); + Assert.assertTrue(toHexString(certificateBundle.x5t()).equalsIgnoreCase("d86db6736c335f08ef39aa27ef83836e8eba95b9")); + + // Load the CER part into X509Certificate object + Assert.assertNotNull(certificateBundle.cer()); + ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); + cerStream.close(); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName() + .equals("CN=KeyVault,OU=Azure,O=Microsoft Corp,L=Redmond,ST=WA,C=US")); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName() + .equals("CN=KeyVault,OU=Azure,O=Microsoft Corp,L=Redmond,ST=WA,C=US")); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + + // Load the secret into a KeyStore + ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); + String secretPassword = ""; + KeyStore keyStore = KeyStore.getInstance(PKCS12); + keyStore.load(secretStream, secretPassword.toCharArray()); + secretStream.close(); + + // Validate the certificate in the KeyStore + String defaultAlias = Collections.list(keyStore.aliases()).get(0); + X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); + Assert.assertNotNull(secretCertificate); + Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() + .equals(x509Certificate.getSubjectX500Principal().getName())); + Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() + .equals(x509Certificate.getIssuerX500Principal().getName())); + Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); + + // Validate the key in the KeyStore + Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); + Assert.assertNotNull(secretKey); + Assert.assertTrue(secretKey instanceof PrivateKey); + PrivateKey secretPrivateKey = (PrivateKey) secretKey; + + // Create a KeyPair with the private key from the KeyStore and public + // key from the certificate to verify they match + KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); + Assert.assertNotNull(keyPair); + verifyRSAKeyPair(keyPair); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * List certificates in a vault. + */ + @Test + public void listCertificates() throws Exception { + String certificateName = "listCertificate"; + String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; + String certificatePassword = "123"; + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PKCS12); + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + + HashSet certificates = new HashSet(); + for (int i = 0; i < MAX_CERTS; ++i) { + int failureCount = 0; + for (;;) { + try { + CertificateBundle certificateBundle = keyVaultClient.importCertificate( + new ImportCertificateRequest + .Builder(getVaultUri(), certificateName + i, certificateContent) + .withPassword(certificatePassword) + .withPolicy(certificatePolicy) + .build()).getBody(); + CertificateIdentifier id = certificateBundle.certificateIdentifier(); + certificates.add(id.baseIdentifier()); + break; + } catch (KeyVaultErrorException e) { + ++failureCount; + if (e.getBody().error().code().equals("Throttled")) { + System.out.println("Waiting to avoid throttling"); + Thread.sleep(failureCount * 1500); + continue; + } + throw e; + } + } + } + + PagedList listResult = keyVaultClient.getCertificates(getVaultUri(), PAGELIST_MAX_CERTS).getBody(); + Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); + + HashSet toDelete = new HashSet(); + + listResult.forEach((item) -> { + CertificateIdentifier id = new CertificateIdentifier(item.id()); + toDelete.add(id.name()); + certificates.remove(item.id()); + }); + + String nextLink = listResult.nextPageLink(); + + while (nextLink != null) { + Page nextSecrets = listResult.nextPage(nextLink); + nextLink = nextSecrets.getNextPageLink(); + for (CertificateItem item : nextSecrets.getItems()) { + CertificateIdentifier id = new CertificateIdentifier(item.id()); + toDelete.add(id.name()); + certificates.remove(item.id()); + } + } + + Assert.assertEquals(0, certificates.size()); + + for (String toDeleteCertificateName : toDelete) { + keyVaultClient.deleteCertificate(getVaultUri(), toDeleteCertificateName); + } + } + + /** + * List versions of a certificate in a vault. + */ + @Test + public void listCertificateVersions() throws Exception { + String certificateName = "listCertificateVersions"; + String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; + String certificatePassword = "123"; + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PKCS12); + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + + HashSet certificates = new HashSet(); + for (int i = 0; i < MAX_CERTS; ++i) { + int failureCount = 0; + for (;;) { + try { + CertificateBundle certificateBundle = keyVaultClient.importCertificate( + new ImportCertificateRequest + .Builder(getVaultUri(), certificateName, certificateContent) + .withPassword(certificatePassword) + .withPolicy(certificatePolicy) + .build()).getBody(); + CertificateIdentifier id = certificateBundle.certificateIdentifier(); + certificates.add(id.identifier()); + break; + } catch (KeyVaultErrorException e) { + ++failureCount; + if (e.getBody().error().code().equals("Throttled")) { + System.out.println("Waiting to avoid throttling"); + Thread.sleep(failureCount * 1500); + continue; + } + throw e; + } + } + } + + PagedList listResult = keyVaultClient.getCertificateVersions(getVaultUri(), certificateName, PAGELIST_MAX_CERTS).getBody(); + Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); + + listResult = keyVaultClient.getCertificateVersions(getVaultUri(), certificateName).getBody(); + for (;;) { + listResult.forEach((item) -> { + certificates.remove(item.id()); + }); + String nextLink = listResult.nextPageLink(); + if (nextLink == null) { + break; + } + //TODO test after list bug is resolved + keyVaultClient.getCertificateVersionsNext(nextLink).getBody(); + } + + Assert.assertEquals(0, certificates.size()); + + keyVaultClient.deleteCertificate(getVaultUri(), certificateName); + } + + /** + * CRUD for Certificate issuers + */ + @Test + public void issuerCrudOperations() throws Exception { + // Construct organization administrator details + AdministratorDetails administratorDetails = new AdministratorDetails(); + administratorDetails.withFirstName("John"); + administratorDetails.withLastName("Doe"); + administratorDetails.withEmailAddress("john.doe@contoso.com"); + administratorDetails.withPhone("1234567890"); + + // Construct organization details + OrganizationDetails organizationDetails = new OrganizationDetails(); + List administratorsDetails = new ArrayList(); + administratorsDetails.add(administratorDetails); + organizationDetails.withAdministratorDetails(administratorsDetails); + + // Construct certificate issuer credentials + IssuerCredentials credentials = new IssuerCredentials(); + credentials.withAccountId("account1"); + credentials.withPassword("Pa$$w0rd"); + + IssuerBundle certificateIssuer = new IssuerBundle(); + certificateIssuer.withProvider(ISSUER_TEST); + certificateIssuer.withCredentials(credentials); + certificateIssuer.withOrganizationDetails(organizationDetails); + + IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( + new SetCertificateIssuerRequest + .Builder(getVaultUri(), "issuer1") + .withIssuer(certificateIssuer) + .build()).getBody(); + + Assert.assertNotNull(createdCertificateIssuer); + Assert.assertNotNull(createdCertificateIssuer.provider()); + Assert.assertTrue(createdCertificateIssuer.provider().equals("Test")); + + Assert.assertNotNull(createdCertificateIssuer.credentials()); + Assert.assertNotNull(createdCertificateIssuer.credentials().accountId()); + Assert.assertTrue(createdCertificateIssuer.credentials().accountId().equals("account1")); + Assert.assertNull(createdCertificateIssuer.credentials().password()); + + Assert.assertNotNull(createdCertificateIssuer.organizationDetails()); + + String certificateIssuerName = createdCertificateIssuer.issuerIdentifier().name(); + IssuerBundle retrievedCertificateIssuer = keyVaultClient.getCertificateIssuer(getVaultUri(), + certificateIssuerName).getBody(); + + Assert.assertNotNull(retrievedCertificateIssuer); + Assert.assertNotNull(retrievedCertificateIssuer.provider()); + Assert.assertTrue(retrievedCertificateIssuer.provider().equals(ISSUER_TEST)); + + Assert.assertNotNull(retrievedCertificateIssuer.credentials()); + Assert.assertNotNull(retrievedCertificateIssuer.credentials().accountId()); + Assert.assertTrue(retrievedCertificateIssuer.credentials().accountId().equals("account1")); + Assert.assertNull(retrievedCertificateIssuer.credentials().password()); + + Assert.assertNotNull(retrievedCertificateIssuer.organizationDetails()); + + IssuerCredentials updatedCredentials = new IssuerCredentials(); + updatedCredentials.withAccountId("account2"); + updatedCredentials.withPassword("Secur!Ty"); + retrievedCertificateIssuer.withCredentials(updatedCredentials); + IssuerBundle updatedCertificateIssuer = keyVaultClient.updateCertificateIssuer( + new UpdateCertificateIssuerRequest + .Builder(getVaultUri(), certificateIssuerName) + .withIssuer(retrievedCertificateIssuer) + .build()).getBody(); + + Assert.assertNotNull(updatedCertificateIssuer); + Assert.assertNotNull(updatedCertificateIssuer.provider()); + Assert.assertTrue(updatedCertificateIssuer.provider().equals(ISSUER_TEST)); + + Assert.assertNotNull(updatedCertificateIssuer.credentials()); + Assert.assertNotNull(updatedCertificateIssuer.credentials().accountId()); + Assert.assertTrue(updatedCertificateIssuer.credentials().accountId().equals("account2")); + Assert.assertNull(updatedCertificateIssuer.credentials().password()); + + Assert.assertNotNull(updatedCertificateIssuer.organizationDetails()); + + IssuerBundle deletedCertificateIssuer = keyVaultClient.deleteCertificateIssuer(getVaultUri(), certificateIssuerName).getBody(); + + Assert.assertNotNull(deletedCertificateIssuer); + Assert.assertNotNull(deletedCertificateIssuer.provider()); + Assert.assertTrue(deletedCertificateIssuer.provider().equals(ISSUER_TEST)); + + Assert.assertNotNull(deletedCertificateIssuer.credentials()); + Assert.assertNotNull(deletedCertificateIssuer.credentials().accountId()); + Assert.assertTrue(deletedCertificateIssuer.credentials().accountId().equals("account2")); + Assert.assertNull(deletedCertificateIssuer.credentials().password()); + + Assert.assertNotNull(deletedCertificateIssuer.organizationDetails()); + + try { + keyVaultClient.getCertificateIssuer(getVaultUri(), certificateIssuerName); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateIssuerNotFound", e.getBody().error().code()); + } + } + + /** + * CRUD for Certificate contacts + * @throws Exception + */ + @Test + public void contactsCrudOperations() throws Exception { + // Create + Contact contact1 = new Contact(); + contact1.withName("James"); + contact1.withEmailAddress("james@contoso.com"); + contact1.withPhone("7777777777"); + + Contact contact2 = new Contact(); + contact2.withName("Ethan"); + contact2.withEmailAddress("ethan@contoso.com"); + contact2.withPhone("8888888888"); + + List contacts = new ArrayList(); + contacts.add(contact1); + contacts.add(contact2); + + Contacts certificateContacts = new Contacts(); + certificateContacts.withContactList(contacts); + Contacts createdCertificateContacts = keyVaultClient.setCertificateContacts(getVaultUri(), certificateContacts).getBody(); + Assert.assertNotNull(createdCertificateContacts); + Assert.assertNotNull(createdCertificateContacts.contactList()); + Assert.assertTrue(createdCertificateContacts.contactList().size() == 2); + Contact[] createContacts = createdCertificateContacts.contactList().toArray(new Contact[createdCertificateContacts.contactList().size()]); + Assert.assertTrue(createContacts[0].name().equalsIgnoreCase("James")); + Assert.assertTrue(createContacts[0].emailAddress().equalsIgnoreCase("james@contoso.com")); + Assert.assertTrue(createContacts[0].phone().equalsIgnoreCase("7777777777")); + Assert.assertTrue(createContacts[1].name().equalsIgnoreCase("Ethan")); + Assert.assertTrue(createContacts[1].emailAddress().equalsIgnoreCase("ethan@contoso.com")); + Assert.assertTrue(createContacts[1].phone().equalsIgnoreCase("8888888888")); + + // Get + Contacts retrievedCertificateContacts = keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); + Assert.assertNotNull(retrievedCertificateContacts); + Assert.assertNotNull(retrievedCertificateContacts.contactList()); + Assert.assertTrue(retrievedCertificateContacts.contactList().size() == 2); + + // Delete + Contacts deletedCertificateContacts = keyVaultClient.deleteCertificateContacts(getVaultUri()).getBody(); + Assert.assertNotNull(deletedCertificateContacts); + Assert.assertNotNull(deletedCertificateContacts.contactList()); + Assert.assertTrue(deletedCertificateContacts.contactList().size() == 2); + + // Get after delete + try { + keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("ContactsNotFound", e.getBody().error().code()); + } + } + + /** + * Polls on a certificate operation for completion. + * + * @throws Exception + */ + private static CertificateBundle pollOnCertificateOperation(CertificateOperation certificateOperation) + throws Exception { + + // Wait for enrollment to complete. We will wait for 200 seconds + int pendingPollCount = 0; + while (pendingPollCount < 21) { + String certificateName = certificateOperation.certificateOperationIdentifier().name(); + CertificateOperation pendingCertificateOperation = keyVaultClient + .getCertificateOperation(getVaultUri(), certificateName).getBody(); + if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)) { + Thread.sleep(10000); + pendingPollCount += 1; + continue; + } + + if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_COMPLETED)) { + return keyVaultClient.getCertificate(pendingCertificateOperation.target()).getBody(); + } + + throw new Exception(String.format( + "Polling on pending certificate returned an unexpected result. Error code = {1}, Error message = {2}", + pendingCertificateOperation.error().code(), + pendingCertificateOperation.error().message())); + } + + throw new Exception("Pending certificate processing delayed"); + } + + /** + * Extracts private key from PEM contents + * + * @throws InvalidKeySpecException + * @throws NoSuchAlgorithmException + */ + private static PrivateKey extractPrivateKeyFromPemContents(String pemContents) + throws InvalidKeySpecException, NoSuchAlgorithmException { + Matcher matcher = _privateKey.matcher(pemContents); + if (!matcher.find()) { + throw new IllegalArgumentException("No private key found in PEM contents."); + } + + byte[] privateKeyBytes = _base64.decode(matcher.group(1)); + PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes); + KeyFactory keyFactory = KeyFactory.getInstance(ALGO_RSA); + PrivateKey privateKey = keyFactory.generatePrivate(keySpec); + return privateKey; + } + + /** + * Extracts certificates from PEM contents + * + * @throws CertificateException + * @throws IOException + */ + private static List extractCertificatesFromPemContents(String pemContents) + throws CertificateException, IOException { + Matcher matcher = _certificate.matcher(pemContents); + if (!matcher.find()) { + throw new IllegalArgumentException("No certificate found in PEM contents."); + } + + List result = new ArrayList(); + int offset = 0; + while (true) { + if (!matcher.find(offset)) { + break; + } + byte[] certBytes = _base64.decode(matcher.group(1)); + ByteArrayInputStream certStream = new ByteArrayInputStream(certBytes); + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(certStream); + certStream.close(); + + result.add(x509Certificate); + offset = matcher.end(); + } + + return result; + } + + /** + * Verify a RSA key pair with a simple encrypt/decrypt test. + * + * @throws NoSuchPaddingException + * @throws NoSuchAlgorithmException + * @throws InvalidKeyException + * @throws BadPaddingException + * @throws IllegalBlockSizeException + */ + private static void verifyRSAKeyPair(KeyPair keyPair) throws NoSuchAlgorithmException, NoSuchPaddingException, + InvalidKeyException, IllegalBlockSizeException, BadPaddingException { + // Validate algorithm is RSA + Assert.assertTrue(keyPair.getPublic().getAlgorithm().equals(ALGO_RSA)); + Assert.assertTrue(keyPair.getPrivate().getAlgorithm().equals(ALGO_RSA)); + + // Generate an array of 10 random bytes + byte[] plainData = new byte[10]; + Random random = new Random(); + random.nextBytes(plainData); + + // Encrypt using the public key + Cipher encryptCipher = Cipher.getInstance(ALGO_RSA); + encryptCipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic()); + byte[] encryptedData = encryptCipher.doFinal(plainData); + + // Decrypt using the private key + Cipher decryptCipher = Cipher.getInstance(ALGO_RSA); + decryptCipher.init(Cipher.DECRYPT_MODE, keyPair.getPrivate()); + byte[] decryptedData = decryptCipher.doFinal(encryptedData); + + // Validate plainData is equal to decryptedData + Assert.assertArrayEquals(plainData, decryptedData); + } + + private String toHexString(byte[] x5t) { + if(x5t == null) + return ""; + + return new String(x5t, StandardCharsets.UTF_8).replace("-", ""); + } +} diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java new file mode 100644 index 0000000000000..dc892eddf5720 --- /dev/null +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -0,0 +1,570 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.test; + +import java.math.BigInteger; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.MessageDigest; +import java.security.spec.KeySpec; +import java.security.spec.RSAPrivateCrtKeySpec; +import java.security.spec.RSAPublicKeySpec; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Random; +import javax.crypto.Cipher; + +import org.joda.time.DateTime; +import org.junit.Assert; +import org.junit.Test; + +import com.microsoft.azure.keyvault.models.KeyBundle; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.keyvault.implementation.KeyIdentifier; +import com.microsoft.azure.keyvault.implementation.SecretIdentifier; +import com.microsoft.azure.keyvault.implementation.requests.CreateKeyRequest; +import com.microsoft.azure.keyvault.implementation.requests.ImportKeyRequest; +import com.microsoft.azure.keyvault.implementation.requests.UpdateKeyRequest; +import com.microsoft.azure.keyvault.models.KeyItem; +import com.microsoft.azure.keyvault.models.KeyOperationResult; +import com.microsoft.azure.keyvault.models.KeyVaultErrorException; +import com.microsoft.azure.keyvault.models.KeyVerifyResult; +import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; + +public class KeyOperationsTest extends KeyVaultClientIntegrationTestBase { + + private static final String KEY_NAME = "javaKey"; + private static final int MAX_KEYS = 4; + private static final int PAGELIST_MAX_KEYS = 3; + + @Test + public void transparentAuthentication() throws Exception { + + // Create a key on a vault. + { + KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); + validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, "RSA", null); + } + + // Create a key on a different vault. Key Vault Data Plane returns 401, + // which must be transparently handled by KeyVaultCredentials. + { + KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, "RSA").build()).getBody(); + validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, "RSA", null); + } + + } + + @Test + public void importKeyOperation() throws Exception { + + KeyBundle keyBundle = new KeyBundle(); + JsonWebKey key = JsonWebKey.fromRSA(getTestKeyMaterial()); + + key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT)); + + keyBundle.withKey(key); + + checkImportOperation(keyBundle, false); + checkImportOperation(keyBundle, true); + } + + private void checkImportOperation(KeyBundle keyBundle, boolean importToHardware) throws Exception { + JsonWebKey importedJwk = keyBundle.key(); + KeyBundle importResultBundle = keyVaultClient.importKey( + new ImportKeyRequest + .Builder(getVaultUri(), KEY_NAME, keyBundle.key()) + .withHsm(importToHardware) + .build()).getBody(); + validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? "RSA-HSM" : "RSA", importedJwk.keyOps()); + checkEncryptDecryptSequence(importedJwk, importResultBundle); + } + + private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle importedKeyBundle) throws Exception { + + // Test variables + byte[] plainText = new byte[100]; + new Random(0x1234567L).nextBytes(plainText); + byte[] cipherText; + + // Encrypt in the service. + { + KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + cipherText = result.result(); + } + + // Decrypt in the client, notice OAEP algorithm instance to use. + { + Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA1AndMGF1Padding"); + cipher.init(Cipher.DECRYPT_MODE, importedKey.toRSA(true).getPrivate()); + + byte[] beforeEncrypt = plainText; + byte[] afterDecrypt = cipher.doFinal(cipherText); + Assert.assertArrayEquals(beforeEncrypt, afterDecrypt); + } + + // Encrypt in the client, using the service provided material. Also use + // standard padding. + { + Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); + cipher.init(Cipher.ENCRYPT_MODE, importedKeyBundle.key().toRSA().getPublic()); + + cipherText = cipher.doFinal(plainText); + } + + // Decrypt in the service. + { + KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA15, cipherText).getBody(); + + byte[] beforeEncrypt = plainText; + byte[] afterDecrypt = result.result(); + Assert.assertArrayEquals(beforeEncrypt, afterDecrypt); + } + } + + @Test + public void crudOperations() throws Exception { + + KeyBundle createdBundle; + { + // Create key + createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null); + } + + // Key identifier. + KeyIdentifier keyId = new KeyIdentifier(createdBundle.key().kid()); + + { + // Get key using kid WO version + KeyBundle readBundle = keyVaultClient.getKey(keyId.baseIdentifier()).getBody(); + compareKeyBundles(createdBundle, readBundle); + } + + { + // Get key using full kid as defined in the bundle + KeyBundle readBundle = keyVaultClient.getKey(createdBundle.key().kid()).getBody(); + compareKeyBundles(createdBundle, readBundle); + } + + { + // Get key using vault and key name. + KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME).getBody(); + compareKeyBundles(createdBundle, readBundle); + } + + { + // Get key using vault, key name and version. + KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME, keyId.version()).getBody(); + compareKeyBundles(createdBundle, readBundle); + } + + { + // Get key using vault, key name and a null version. + KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME).getBody(); + compareKeyBundles(createdBundle, readBundle); + } + + { + // Update key using the kid as defined in the bundle + + // First we create a bundle with the modified attributes. + createdBundle.attributes().withExpires(new DateTime() + .withMonthOfYear(2) + .withDayOfMonth(1) + .withYear(2050)); + List key_ops = Arrays.asList("encrypt", "decrypt"); + Map tags = new HashMap(); + tags.put("foo", "baz"); + createdBundle.key().withKeyOps(key_ops); + createdBundle.withTags(tags); + + // Perform the operation. + KeyBundle updatedBundle = keyVaultClient.updateKey( + new UpdateKeyRequest + .Builder(createdBundle.key().kid()) + .withKeyOperations(key_ops) + .withAttributes(createdBundle.attributes()) + .withTags(createdBundle.tags()) + .build()).getBody(); + + compareKeyBundles(createdBundle, updatedBundle); + + // Subsequent operations must use the updated bundle for comparison. + createdBundle = updatedBundle; + } + + { + // Update key using vault and key name. + + // First we create a bundle with the modified attributes. + createdBundle.attributes().withNotBefore(new DateTime() + .withMonthOfYear(2) + .withDayOfMonth(1) + .withYear(2000)); + List key_ops = Arrays.asList("sign", "verify"); + createdBundle.key().withKeyOps(key_ops); + Map tags = new HashMap(); + tags.put("foo", "baz"); + createdBundle.withTags(tags); + + // Perform the operation. + KeyBundle updatedBundle = keyVaultClient.updateKey( + new UpdateKeyRequest + .Builder(getVaultUri(), KEY_NAME) + .withKeyOperations(key_ops) + .withAttributes(createdBundle.attributes()) + .withTags(createdBundle.tags()) + .build()).getBody(); + + compareKeyBundles(createdBundle, updatedBundle); + } + + { + // Delete key + KeyBundle deleteBundle = keyVaultClient.deleteKey(getVaultUri(), KEY_NAME).getBody(); + compareKeyBundles(createdBundle, deleteBundle); + } + + { + // Expects a key not found + try { + keyVaultClient.getKey(keyId.baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("KeyNotFound", e.getBody().error().code()); + } + } + + } + + @Test + public void backupRestore() throws Exception { + + KeyBundle createdBundle; + + // Creates a key + { + createdBundle = keyVaultClient.createKey( + new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA") + .build()).getBody(); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null); + } + + // Creates a backup of key. + byte[] keyBackup; + { + keyBackup = keyVaultClient.backupKey(getVaultUri(), KEY_NAME).getBody().value(); + } + + // Deletes the key. + { + keyVaultClient.deleteKey(getVaultUri(), KEY_NAME); + } + + // Restores the key. + { + KeyBundle restoredBundle = keyVaultClient.restoreKey(getVaultUri(), keyBackup).getBody(); + compareKeyBundles(createdBundle, restoredBundle); + } + + } + + @Test + public void listKeys() throws Exception { + + HashSet keys = new HashSet(); + for (int i = 0; i < MAX_KEYS; ++i) { + int failureCount = 0; + for (;;) { + try { + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, "RSA").build()).getBody(); + KeyIdentifier kid = new KeyIdentifier(createdBundle.key().kid()); + keys.add(kid.baseIdentifier()); + break; + } catch (KeyVaultErrorException e) { + ++failureCount; + if (e.getBody().error().code().equals("Throttled")) { + System.out.println("Waiting to avoid throttling"); + Thread.sleep(failureCount * 1500); + continue; + } + throw e; + } + } + } + + PagedList listResult = keyVaultClient.getKeys(getVaultUri(), PAGELIST_MAX_KEYS).getBody(); + Assert.assertTrue(PAGELIST_MAX_KEYS >= listResult.currentPage().getItems().size()); + + HashSet toDelete = new HashSet(); + + listResult.forEach((item) -> { + KeyIdentifier id = new KeyIdentifier(item.kid()); + toDelete.add(id.name()); + keys.remove(item.kid()); + }); + + String nextLink = listResult.nextPageLink(); + + while (nextLink != null) { + Page nextKeys = listResult.nextPage(nextLink); + nextLink = nextKeys.getNextPageLink(); + for (KeyItem item : nextKeys.getItems()) { + SecretIdentifier id = new SecretIdentifier(item.kid()); + toDelete.add(id.name()); + keys.remove(item.kid()); + } + } + + Assert.assertEquals(0, keys.size()); + + for (String name : toDelete) { + try{ + keyVaultClient.deleteKey(getVaultUri(), name); + } + catch(KeyVaultErrorException e){ + // Ignore forbidden exception for certificate keys that cannot be deleted + if(!e.getBody().error().code().equals("Forbidden")) + throw e; + } + } + } + + @Test + public void listKeyVersions() throws Exception { + + HashSet keys = new HashSet(); + for (int i = 0; i < MAX_KEYS; ++i) { + int failureCount = 0; + for (;;) { + try { + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); + keys.add(createdBundle.key().kid()); + break; + } catch (KeyVaultErrorException e) { + ++failureCount; + if (e.getBody().error().code().equals("Throttled")) { + System.out.println("Waiting to avoid throttling"); + Thread.sleep(failureCount * 1500); + continue; + } + throw e; + } + } + } + + PagedList listResult = keyVaultClient.getKeyVersions(getVaultUri(), KEY_NAME, MAX_KEYS).getBody(); + //TODO bug: Assert.assertTrue(PAGELIST_MAX_KEYS >= listResult.currentPage().getItems().size()); + + listResult = keyVaultClient.getKeyVersions(getVaultUri(), KEY_NAME).getBody(); + + for (;;) { + listResult.forEach((item) -> { + keys.remove(item.kid()); + }); + String nextLink = listResult.nextPageLink(); + if (nextLink == null) { + break; + } + //TODO test after list bug is resolved + keyVaultClient.getKeyVersionsNext(nextLink).getBody(); + } + + Assert.assertEquals(0, keys.size()); + + keyVaultClient.deleteKey(getVaultUri(), KEY_NAME); + } + + @Test + public void encryptDecryptOperations() throws Exception { + + JsonWebKey testKey = importTestKey(); + KeyIdentifier keyId = new KeyIdentifier(testKey.kid()); + + // Test variables + byte[] plainText = new byte[100]; + new Random(0x1234567L).nextBytes(plainText); + byte[] cipherText; + + KeyOperationResult result; + + // encrypt and decrypt using kid WO version + { + result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + cipherText = result.result(); + + result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + Assert.assertArrayEquals(plainText, result.result()); + } + + // encrypt and decrypt using full kid + { + result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + cipherText = result.result(); + + result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + Assert.assertArrayEquals(plainText, result.result()); + } + } + + @Test + public void wrapUnwrapOperations() throws Exception { + + JsonWebKey testKey = importTestKey(); + KeyIdentifier keyId = new KeyIdentifier(testKey.kid()); + + // Test variables + byte[] plainText = new byte[100]; + new Random(0x1234567L).nextBytes(plainText); + byte[] cipherText; + + KeyOperationResult result; + + // wrap and unwrap using kid WO version + { + result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + cipherText = result.result(); + + result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + Assert.assertArrayEquals(plainText, result.result()); + } + + // wrap and unwrap using full kid + { + result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + cipherText = result.result(); + + result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + Assert.assertArrayEquals(plainText, result.result()); + } + } + + @Test + public void signVerifyOperations() throws Exception { + + JsonWebKey testKey = importTestKey(); + KeyIdentifier keyId = new KeyIdentifier(testKey.kid()); + + // Test variables + byte[] plainText = new byte[100]; + new Random(0x1234567L).nextBytes(plainText); + MessageDigest md = MessageDigest.getInstance("SHA-256"); + md.update(plainText); + byte[] digest = md.digest(); + byte[] signature; + + KeyOperationResult result; + KeyVerifyResult verifyResult; + + // Using kid WO version + { + result = keyVaultClient.sign(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest).getBody(); + signature = result.result(); + + verifyResult = keyVaultClient.verify(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest, signature).getBody(); + Assert.assertEquals(new Boolean(true), verifyResult.value()); + } + + // Using full kid + { + result = keyVaultClient.sign(testKey.kid(), JsonWebKeySignatureAlgorithm.RS256, digest).getBody(); + signature = result.result(); + + verifyResult = keyVaultClient.verify(testKey.kid(), JsonWebKeySignatureAlgorithm.RS256, digest, signature).getBody(); + Assert.assertEquals(new Boolean(true), verifyResult.value()); + + } + } + + private static JsonWebKey importTestKey() throws Exception { + + KeyBundle keyBundle = new KeyBundle(); + JsonWebKey key = JsonWebKey.fromRSA(getTestKeyMaterial()); + + key.withKty(JsonWebKeyType.RSA); + key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT, JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY, JsonWebKeyOperation.WRAP, JsonWebKeyOperation.UNWRAP)); + + keyBundle = keyVaultClient.importKey( + new ImportKeyRequest + .Builder(getVaultUri(), KEY_NAME, key) + .withHsm(false) + .build()).getBody(); + + validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, "RSA", null); + + return keyBundle.key(); + } + + private static KeyPair getTestKeyMaterial() throws Exception { + return getWellKnownKey(); + } + + private static KeyPair getWellKnownKey() throws Exception { + BigInteger modulus = new BigInteger("27266783713040163753473734334021230592631652450892850648620119914958066181400432364213298181846462385257448168605902438305568194683691563208578540343969522651422088760509452879461613852042845039552547834002168737350264189810815735922734447830725099163869215360401162450008673869707774119785881115044406101346450911054819448375712432746968301739007624952483347278954755460152795801894283389540036131881712321193750961817346255102052653789197325341350920441746054233522546543768770643593655942246891652634114922277138937273034902434321431672058220631825053788262810480543541597284376261438324665363067125951152574540779"); + BigInteger publicExponent = new BigInteger("65537"); + BigInteger privateExponent = new BigInteger("10466613941269075477152428927796086150095892102279802916937552172064636326433780566497000814207416485739683286961848843255766652023400959086290344987308562817062506476465756840999981989957456897020361717197805192876094362315496459535960304928171129585813477132331538577519084006595335055487028872410579127692209642938724850603554885478763205394868103298473476811627231543504190652483290944218004086457805431824328448422034887148115990501701345535825110962804471270499590234116100216841170344686381902328362376624405803648588830575558058257742073963036264273582756620469659464278207233345784355220317478103481872995809"); + BigInteger primeP = new BigInteger("175002941104568842715096339107566771592009112128184231961529953978142750732317724951747797764638217287618769007295505214923187971350518217670604044004381362495186864051394404165602744235299100790551775147322153206730562450301874236875459336154569893255570576967036237661594595803204808064127845257496057219227"); + BigInteger primeQ = new BigInteger("155807574095269324897144428622185380283967159190626345335083690114147315509962698765044950001909553861571493035240542031420213144237033208612132704562174772894369053916729901982420535940939821673277140180113593951522522222348910536202664252481405241042414183668723338300649954708432681241621374644926879028977"); + BigInteger primeExponentP = new BigInteger("79745606804504995938838168837578376593737280079895233277372027184693457251170125851946171360348440134236338520742068873132216695552312068793428432338173016914968041076503997528137698610601222912385953171485249299873377130717231063522112968474603281996190849604705284061306758152904594168593526874435238915345"); + BigInteger primeExponentQ = new BigInteger("80619964983821018303966686284189517841976445905569830731617605558094658227540855971763115484608005874540349730961777634427740786642996065386667564038755340092176159839025706183161615488856833433976243963682074011475658804676349317075370362785860401437192843468423594688700132964854367053490737073471709030801"); + BigInteger crtCoefficient = new BigInteger("2157818511040667226980891229484210846757728661751992467240662009652654684725325675037512595031058612950802328971801913498711880111052682274056041470625863586779333188842602381844572406517251106159327934511268610438516820278066686225397795046020275055545005189953702783748235257613991379770525910232674719428"); + + KeySpec publicKeySpec = new RSAPublicKeySpec(modulus, publicExponent); + KeySpec privateKeySpec = new RSAPrivateCrtKeySpec(modulus, publicExponent, privateExponent, primeP, primeQ, primeExponentP, primeExponentQ, crtCoefficient); + KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + + return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); + } + + private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops) throws Exception { + String prefix = vault + "/keys/" + keyName + "/"; + String kid = bundle.key().kid(); + Assert.assertTrue( + String.format("\"kid\" should start with \"%s\", but instead the value is \"%s\".", prefix, kid), + kid.startsWith(prefix)); + Assert.assertEquals(kty, bundle.key().kty()); + Assert.assertNotNull("\"n\" should not be null.", bundle.key().n()); + Assert.assertNotNull("\"e\" should not be null.", bundle.key().e()); + if (key_ops != null) { + Assert.assertTrue(key_ops.equals(bundle.key().keyOps())); + } + Assert.assertNotNull("\"created\" should not be null.", bundle.attributes().created()); + Assert.assertNotNull("\"updated\" should not be null.", bundle.attributes().updated()); + } + + + + private void compareKeyBundles(KeyBundle expected, KeyBundle actual) { + Assert.assertTrue(expected.key().toString().equals(actual.key().toString())); + Assert.assertEquals(expected.attributes().enabled(), actual.attributes().enabled()); + Assert.assertEquals(expected.attributes().expires(), actual.attributes().expires()); + Assert.assertEquals(expected.attributes().notBefore(), actual.attributes().notBefore()); + if(expected.tags() != null || actual.tags() != null) + Assert.assertTrue(expected.tags().equals(actual.tags())); + } +} diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java new file mode 100644 index 0000000000000..412e9591fbd8f --- /dev/null +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java @@ -0,0 +1,164 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.test; + + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; + + +import com.microsoft.azure.keyvault.implementation.KeyVaultClient; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.ObjectWriter; +import com.microsoft.aad.adal4j.AuthenticationContext; +import com.microsoft.aad.adal4j.AuthenticationResult; +import com.microsoft.aad.adal4j.ClientCredential; +import com.microsoft.azure.keyvault.authentication.KeyVaultCredentials; + +public class KeyVaultClientIntegrationTestBase { + + /** + * The client instance that should be used on tests. + */ + protected static KeyVaultClient keyVaultClient; + + /** + * Primary vault URI, used for keys and secrets tests. + */ + public static String getVaultUri() { + return getLiveVaultUri1(); + } + + /** + * Secondary vault URI, used to verify ability to transparently authenticate + * against a different resource. + */ + public static String getSecondaryVaultUri() { + return getLiveVaultUri2(); + } + + private static String getLiveVaultUri1() { + return getenvOrDefault("keyvault.vaulturi", "https://javasdktestvault.vault.azure.net"); + } + + private static String getLiveVaultUri2() { + return getenvOrDefault("keyvault.vaulturi.alt", "https://javasdktestvault2.vault.azure.net"); + } + + private static String getenvOrDefault(String varName, String defValue) { + String value = System.getenv(varName); + return value != null ? value : defValue; + } + + protected static void createKeyVaultClient() throws Exception { + keyVaultClient = new KeyVaultClient(createTestCredentials()); + } + + private static ServiceClientCredentials createTestCredentials() throws Exception { + return new KeyVaultCredentials() { + + @Override + public String doAuthenticate(String authorization, String resource, String scope) { + try { + AuthenticationResult authResult = getAccessToken(authorization, resource); + return authResult.getAccessToken(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + }; + } + + private static AuthenticationResult getAccessToken(String authorization, String resource) throws Exception { + + String clientId = System.getenv("arm.clientid"); + + if (clientId == null) { + throw new Exception("Please inform arm.clientid in the environment settings."); + } + + String clientKey = System.getenv("arm.clientkey"); + String username = System.getenv("arm.username"); + String password = System.getenv("arm.password"); + + AuthenticationResult result = null; + ExecutorService service = null; + try { + service = Executors.newFixedThreadPool(1); + AuthenticationContext context = new AuthenticationContext(authorization, false, service); + + Future future = null; + + if (clientKey != null && password == null) { + ClientCredential credentials = new ClientCredential(clientId, clientKey); + future = context.acquireToken(resource, credentials, null); + } + + if (password != null && clientKey == null) { + future = context.acquireToken(resource, clientId, username, password, null); + } + + if (future == null) { + throw new Exception("Missing or ambiguous credentials - please inform exactly one of arm.clientkey or arm.password in the environment settings."); + } + + result = future.get(); + } finally { + service.shutdown(); + } + + if (result == null) { + throw new RuntimeException("authentication result was null"); + } + return result; + } + + protected static ObjectWriter jsonWriter; + protected static ObjectReader jsonReader; + + @BeforeClass + public static void setup() throws Exception { + createKeyVaultClient(); + jsonWriter = new ObjectMapper().writer().withDefaultPrettyPrinter(); + jsonReader = new ObjectMapper().reader(); + } + + @AfterClass + public static void cleanup() throws Exception { + } + + @Before + public void beforeTest() throws Exception { + //setupTest(getClass().getSimpleName() + "-" + "??"); + } + + @After + public void afterTest() throws Exception { + //resetTest(getClass().getSimpleName() + "-" + "??"); + } + +} \ No newline at end of file diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java new file mode 100644 index 0000000000000..022c5e1eda80a --- /dev/null +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -0,0 +1,301 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.test; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import org.joda.time.DateTime; +import org.junit.Assert; +import org.junit.Test; + +import com.microsoft.azure.keyvault.models.KeyVaultErrorException; +import com.microsoft.azure.keyvault.models.SecretBundle; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.keyvault.implementation.SecretIdentifier; +import com.microsoft.azure.keyvault.implementation.requests.SetSecretRequest; +import com.microsoft.azure.keyvault.implementation.requests.UpdateSecretRequest; +import com.microsoft.azure.keyvault.models.SecretItem; + +public class SecretOperationsTest extends KeyVaultClientIntegrationTestBase { + + private static final String SECRET_NAME = "javaSecret"; + private static final String SECRET_VALUE = "Chocolate is hidden in the toothpaste cabinet"; + private static final int MAX_SECRETS = 4; + private static final int PAGELIST_MAX_SECRETS = 3; + + @Test + public void transparentAuthentication() throws Exception { + + // Create a secret on a vault. + { + SecretBundle secret = keyVaultClient.setSecret( + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, null); + } + + // Create a secret on a different vault. Secret Vault Data Plane returns + // 401, which must be transparently handled by KeyVaultCredentials. + { + SecretBundle secret = keyVaultClient.setSecret( + new SetSecretRequest.Builder(getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + validateSecret(secret, getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE, null); + } + + } + + @Test + public void crudOperations() throws Exception { + + SecretBundle secret; + { + // Create secret + secret = keyVaultClient.setSecret( + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, null); + } + + // Secret identifier. + SecretIdentifier secretId = new SecretIdentifier(secret.id()); + + { + // Get secret using kid WO version + SecretBundle readBundle = keyVaultClient.getSecret(secretId.baseIdentifier()).getBody(); + compareSecrets(secret, readBundle); + } + + { + // Get secret using full kid as defined in the bundle + SecretBundle readBundle = keyVaultClient.getSecret(secret.id()).getBody(); + compareSecrets(secret, readBundle); + } + + { + // Get secret using vault and secret name. + SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME).getBody(); + compareSecrets(secret, readBundle); + } + + { + // Get secret using vault, secret name and version. + SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME, secretId.version()).getBody(); + compareSecrets(secret, readBundle); + } + + { + secret.attributes().withExpires(new DateTime() + .withMonthOfYear(2) + .withDayOfMonth(1) + .withYear(2050)); + Map tags = new HashMap(); + tags.put("foo", "baz"); + secret.withTags(tags) + .withContentType("application/html") + .withValue(null); // The value doesn't get updated + + // Update secret using the kid as defined in the bundle + SecretBundle updatedSecret = keyVaultClient.updateSecret( + new UpdateSecretRequest + .Builder(secret.id()) + .withContentType(secret.contentType()) + .withAttributes(secret.attributes()) + .withTags(secret.tags()) + .build()).getBody(); + compareSecrets(secret, updatedSecret); + + // Subsequent operations must use the updated bundle for comparison. + secret = updatedSecret; + } + + { + // Update secret using vault and secret name. + + secret.attributes().withNotBefore(new DateTime() + .withMonthOfYear(2) + .withDayOfMonth(1) + .withYear(2000)); + Map tags = new HashMap(); + tags.put("rex", "woof"); + secret.withTags(tags) + .withContentType("application/html"); + + // Perform the operation. + SecretBundle updatedSecret = keyVaultClient.updateSecret( + new UpdateSecretRequest + .Builder(getVaultUri(), SECRET_NAME) + .withContentType(secret.contentType()) + .withAttributes(secret.attributes()) + .withTags(secret.tags()) + .build()).getBody(); + + compareSecrets(secret, updatedSecret); + } + + { + // Delete secret + SecretBundle deleteBundle = keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME).getBody(); + compareSecrets(secret, deleteBundle); + } + + { + // Expects a secret not found + try { + keyVaultClient.getSecret(secretId.baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error().code()); + Assert.assertEquals("SecretNotFound", e.getBody().error().code()); + } + } + + } + + @Test + public void listSecrets() throws Exception { + + HashSet secrets = new HashSet(); + for (int i = 0; i < MAX_SECRETS; ++i) { + int failureCount = 0; + for (;;) { + try { + SecretBundle secret = keyVaultClient.setSecret( + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME + i, SECRET_VALUE).build()).getBody(); + SecretIdentifier id = new SecretIdentifier(secret.id()); + secrets.add(id.baseIdentifier()); + break; + } catch (KeyVaultErrorException e) { + ++failureCount; + if (e.getBody().error().code().equals("Throttled")) { + System.out.println("Waiting to avoid throttling"); + Thread.sleep(failureCount * 1500); + continue; + } + throw e; + } + } + } + + PagedList listResult = keyVaultClient.getSecrets(getVaultUri(), PAGELIST_MAX_SECRETS).getBody(); + Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().getItems().size()); + + HashSet toDelete = new HashSet(); + + listResult.forEach((item) -> { + SecretIdentifier id = new SecretIdentifier(item.id()); + toDelete.add(id.name()); + secrets.remove(item.id()); + }); + + String nextLink = listResult.nextPageLink(); + + while (nextLink != null) { + Page nextSecrets = listResult.nextPage(nextLink); + nextLink = nextSecrets.getNextPageLink(); + for (SecretItem item : nextSecrets.getItems()) { + SecretIdentifier id = new SecretIdentifier(item.id()); + toDelete.add(id.name()); + secrets.remove(item.id()); + } + } + + Assert.assertEquals(0, secrets.size()); + + for (String secretName : toDelete) { + try{ + keyVaultClient.deleteSecret(getVaultUri(), secretName); + } + catch(KeyVaultErrorException e){ + // Ignore forbidden exception for certificate secrets that cannot be deleted + if(!e.getBody().error().code().equals("Forbidden")) + throw e; + } + } + } + + @Test + public void listSecretVersions() throws Exception { + + HashSet secrets = new HashSet(); + for (int i = 0; i < MAX_SECRETS; ++i) { + int failureCount = 0; + for (;;) { + try { + SecretBundle secret = keyVaultClient.setSecret( + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + secrets.add(secret.id()); + break; + } catch (KeyVaultErrorException e) { + ++failureCount; + if (e.getBody().error().code().equals("Throttled")) { + System.out.println("Throttled!"); + Thread.sleep(failureCount * 1500); + continue; + } + throw e; + } + } + } + + PagedList listResult = keyVaultClient.getSecretVersions(getVaultUri(), SECRET_NAME, PAGELIST_MAX_SECRETS).getBody(); + Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().getItems().size()); + + listResult = keyVaultClient.getSecretVersions(getVaultUri(), SECRET_NAME).getBody(); + for (;;) { + listResult.forEach((item) -> { + secrets.remove(item.id()); + }); + String nextLink = listResult.nextPageLink(); + if (nextLink == null) { + break; + } + //TODO test after list bug is resolved + keyVaultClient.getSecretVersionsNext(nextLink).getBody(); + } + + Assert.assertEquals(0, secrets.size()); + + keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME); + } + + private static void validateSecret(SecretBundle secret, String vault, String name, String value, String contentType) throws Exception { + String prefix = vault + "/secrets/" + name + "/"; + String id = secret.id(); + Assert.assertTrue( // + String.format("\"id\" should start with \"%s\", but instead the value is \"%s\".", prefix, id), // + id.startsWith(prefix)); + Assert.assertEquals(value, secret.value()); + if (contentType != null) { + Assert.assertEquals(contentType, secret.contentType()); + } + Assert.assertNotNull("\"created\" should not be null.", secret.attributes().created()); + Assert.assertNotNull("\"updated\" should not be null.", secret.attributes().updated()); + } + + private void compareSecrets(SecretBundle expected, SecretBundle actual) { + Assert.assertEquals(expected.contentType(), actual.contentType()); + Assert.assertEquals(expected.id(), actual.id()); + Assert.assertEquals(expected.value(), actual.value()); + Assert.assertEquals(expected.attributes().enabled(), actual.attributes().enabled()); + Assert.assertEquals(expected.attributes().expires(), actual.attributes().expires()); + Assert.assertEquals(expected.attributes().notBefore(), actual.attributes().notBefore()); + if(expected.tags() != null || actual.tags() != null) + Assert.assertTrue(expected.tags().equals(actual.tags())); + } + +} From b1290c2a4c34d394fae7d65e31b54056037a26fa Mon Sep 17 00:00:00 2001 From: Pooneh Date: Tue, 26 Jul 2016 11:48:22 -0700 Subject: [PATCH 04/56] Removing lambda expression and listing by nextLink. The nextLink listing operation is handled implicitly by Azure core --- .../test/CertificateOperationsTest.java | 20 +++---------------- .../keyvault/test/KeyOperationsTest.java | 20 ++++--------------- .../keyvault/test/SecretOperationsTest.java | 20 ++++--------------- 3 files changed, 11 insertions(+), 49 deletions(-) diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index e82143de89ff5..6e4a9006900b0 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -49,7 +49,6 @@ import org.apache.commons.codec.binary.Base64; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import com.microsoft.azure.Page; @@ -903,22 +902,10 @@ public void listCertificates() throws Exception { HashSet toDelete = new HashSet(); - listResult.forEach((item) -> { + for (CertificateItem item : listResult) { CertificateIdentifier id = new CertificateIdentifier(item.id()); toDelete.add(id.name()); certificates.remove(item.id()); - }); - - String nextLink = listResult.nextPageLink(); - - while (nextLink != null) { - Page nextSecrets = listResult.nextPage(nextLink); - nextLink = nextSecrets.getNextPageLink(); - for (CertificateItem item : nextSecrets.getItems()) { - CertificateIdentifier id = new CertificateIdentifier(item.id()); - toDelete.add(id.name()); - certificates.remove(item.id()); - } } Assert.assertEquals(0, certificates.size()); @@ -974,14 +961,13 @@ public void listCertificateVersions() throws Exception { listResult = keyVaultClient.getCertificateVersions(getVaultUri(), certificateName).getBody(); for (;;) { - listResult.forEach((item) -> { + for (CertificateItem item : listResult) { certificates.remove(item.id()); - }); + } String nextLink = listResult.nextPageLink(); if (nextLink == null) { break; } - //TODO test after list bug is resolved keyVaultClient.getCertificateVersionsNext(nextLink).getBody(); } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index dc892eddf5720..86dc22f1c824c 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -49,6 +49,7 @@ import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyResult; +import com.microsoft.azure.keyvault.models.CertificateItem; import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; @@ -323,22 +324,10 @@ public void listKeys() throws Exception { HashSet toDelete = new HashSet(); - listResult.forEach((item) -> { + for (KeyItem item : listResult) { KeyIdentifier id = new KeyIdentifier(item.kid()); toDelete.add(id.name()); keys.remove(item.kid()); - }); - - String nextLink = listResult.nextPageLink(); - - while (nextLink != null) { - Page nextKeys = listResult.nextPage(nextLink); - nextLink = nextKeys.getNextPageLink(); - for (KeyItem item : nextKeys.getItems()) { - SecretIdentifier id = new SecretIdentifier(item.kid()); - toDelete.add(id.name()); - keys.remove(item.kid()); - } } Assert.assertEquals(0, keys.size()); @@ -384,14 +373,13 @@ public void listKeyVersions() throws Exception { listResult = keyVaultClient.getKeyVersions(getVaultUri(), KEY_NAME).getBody(); for (;;) { - listResult.forEach((item) -> { + for (KeyItem item : listResult) { keys.remove(item.kid()); - }); + } String nextLink = listResult.nextPageLink(); if (nextLink == null) { break; } - //TODO test after list bug is resolved keyVaultClient.getKeyVersionsNext(nextLink).getBody(); } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index 022c5e1eda80a..ff5b2f960acb2 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -25,6 +25,7 @@ import org.junit.Assert; import org.junit.Test; +import com.microsoft.azure.keyvault.models.CertificateItem; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.Page; @@ -196,22 +197,10 @@ public void listSecrets() throws Exception { HashSet toDelete = new HashSet(); - listResult.forEach((item) -> { + for (SecretItem item : listResult) { SecretIdentifier id = new SecretIdentifier(item.id()); toDelete.add(id.name()); secrets.remove(item.id()); - }); - - String nextLink = listResult.nextPageLink(); - - while (nextLink != null) { - Page nextSecrets = listResult.nextPage(nextLink); - nextLink = nextSecrets.getNextPageLink(); - for (SecretItem item : nextSecrets.getItems()) { - SecretIdentifier id = new SecretIdentifier(item.id()); - toDelete.add(id.name()); - secrets.remove(item.id()); - } } Assert.assertEquals(0, secrets.size()); @@ -257,14 +246,13 @@ public void listSecretVersions() throws Exception { listResult = keyVaultClient.getSecretVersions(getVaultUri(), SECRET_NAME).getBody(); for (;;) { - listResult.forEach((item) -> { + for (SecretItem item : listResult) { secrets.remove(item.id()); - }); + } String nextLink = listResult.nextPageLink(); if (nextLink == null) { break; } - //TODO test after list bug is resolved keyVaultClient.getSecretVersionsNext(nextLink).getBody(); } From ce28f8c6b94a6b16019f5939242f2a1f4bf347b9 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Wed, 27 Jul 2016 15:32:59 -0700 Subject: [PATCH 05/56] Updating the API version, documentation, remove policy as mandatory parameter, fix AdminDetails tag --- .../implementation/KeyVaultClient.java | 26 ++---- .../implementation/KeyVaultClientImpl.java | 73 +++++------------ .../keyvault/implementation/package-info.java | 2 +- .../requests/CreateCertificateRequest.java | 2 +- .../UpdateCertificatePolicyRequest.java | 2 +- .../azure/keyvault/models/Action.java | 2 +- .../keyvault/models/AdministratorDetails.java | 2 +- .../azure/keyvault/models/Attributes.java | 18 ++-- .../keyvault/models/BackupKeyResult.java | 2 +- .../keyvault/models/CertificateBundle.java | 2 +- .../models/CertificateCreateParameters.java | 4 +- .../models/CertificateImportParameters.java | 4 +- .../models/CertificateIssuerItem.java | 2 +- .../keyvault/models/CertificateItem.java | 8 +- .../models/CertificateMergeParameters.java | 2 +- .../keyvault/models/CertificateOperation.java | 4 +- .../keyvault/models/CertificatePolicy.java | 2 +- .../models/CertificateUpdateParameters.java | 2 +- .../azure/keyvault/models/Contact.java | 2 +- .../azure/keyvault/models/Contacts.java | 4 +- .../azure/keyvault/models/Error.java | 2 +- .../keyvault/models/IssuerAttributes.java | 2 +- .../azure/keyvault/models/IssuerBundle.java | 2 +- .../keyvault/models/IssuerCredentials.java | 2 +- .../keyvault/models/IssuerReference.java | 2 +- .../azure/keyvault/models/JsonWebKey.java | 82 +++++++++++++------ .../azure/keyvault/models/KeyAttributes.java | 2 +- .../azure/keyvault/models/KeyBundle.java | 2 +- .../keyvault/models/KeyCreateParameters.java | 2 +- .../keyvault/models/KeyImportParameters.java | 2 +- .../azure/keyvault/models/KeyItem.java | 2 +- .../keyvault/models/KeyOperationResult.java | 2 +- .../models/KeyOperationsParameters.java | 8 +- .../azure/keyvault/models/KeyProperties.java | 2 +- .../keyvault/models/KeyRestoreParameters.java | 8 +- .../keyvault/models/KeyUpdateParameters.java | 2 +- .../azure/keyvault/models/KeyVaultError.java | 2 +- .../keyvault/models/KeyVerifyParameters.java | 14 +++- .../keyvault/models/KeyVerifyResult.java | 2 +- .../azure/keyvault/models/LifetimeAction.java | 3 +- .../keyvault/models/OrganizationDetails.java | 22 ++--- ...endingCertificateSigningRequestResult.java | 2 +- .../azure/keyvault/models/SecretBundle.java | 2 +- .../azure/keyvault/models/SecretItem.java | 2 +- .../keyvault/models/SecretProperties.java | 4 +- .../keyvault/models/SecretSetParameters.java | 2 +- .../models/SecretUpdateParameters.java | 2 +- .../models/SubjectAlternativeNames.java | 2 +- .../azure/keyvault/models/Trigger.java | 2 +- .../models/X509CertificateProperties.java | 4 +- .../azure/keyvault/models/package-info.java | 2 +- .../azure/keyvault/package-info.java | 2 +- .../test/CertificateOperationsTest.java | 21 ++--- .../keyvault/test/KeyOperationsTest.java | 3 - .../keyvault/test/SecretOperationsTest.java | 2 - 55 files changed, 193 insertions(+), 191 deletions(-) diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClient.java index 6190d84a84dd8..878d6d5393db7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClient.java @@ -9,9 +9,7 @@ import java.io.IOException; import com.google.common.base.Joiner; -import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureClient; -import com.microsoft.azure.AzureServiceResponseBuilder; import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.PagedList; import com.microsoft.azure.keyvault.implementation.requests.CreateCertificateRequest; @@ -1205,7 +1203,7 @@ public ServiceCall deleteCertificate(String vaultBaseUrl, String certificateName * Sets the certificate contacts for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param contacts Contacts. + * @param contacts The contacts for the vault certificates. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -1220,7 +1218,7 @@ public ServiceResponse setCertificateContacts(String vaultBaseUrl, Con * Sets the certificate contacts for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param contacts Contacts. + * @param contacts The contacts for the vault certificates. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object @@ -1524,9 +1522,9 @@ public ServiceResponse importCertificate(ImportCertificateReq return innerKeyVaultClient.importCertificate( importCertificateRequest.vaultBaseUrl(), importCertificateRequest.certificateName(), - importCertificateRequest.base64EncodedCertificate(), + importCertificateRequest.base64EncodedCertificate(), + importCertificateRequest.password(), importCertificateRequest.certificatePolicy(), - importCertificateRequest.password(), importCertificateRequest.certificateAttributes(), importCertificateRequest.tags()); } @@ -1546,8 +1544,8 @@ public ServiceCall importCertificate(ImportCertificateRequest importCertificateR importCertificateRequest.vaultBaseUrl(), importCertificateRequest.certificateName(), importCertificateRequest.base64EncodedCertificate(), - importCertificateRequest.certificatePolicy(), importCertificateRequest.password(), + importCertificateRequest.certificatePolicy(), importCertificateRequest.certificateAttributes(), importCertificateRequest.tags(), serviceCallback); @@ -1964,7 +1962,8 @@ public ServiceResponse getPendingCertificateSigningRequest(String vaultB } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getPendingCertificateSigningRequestDelegate(call.execute()); + Response response = call.execute(); + return new ServiceResponse(response.body().string(), response); } /** @@ -2000,8 +1999,8 @@ public ServiceCall getPendingCertificateSigningRequest(String vaultBaseUrl, Stri @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(getPendingCertificateSigningRequestDelegate(response)); - } catch (KeyVaultErrorException | IOException exception) { + serviceCallback.success(new ServiceResponse(response.body().string(), response)); + } catch (IOException exception) { serviceCallback.failure(exception); } } @@ -2009,13 +2008,6 @@ public void onResponse(Call call, Response response) return serviceCall; } - private ServiceResponse getPendingCertificateSigningRequestDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(innerKeyVaultClient.restClient().mapperAdapter()) - .register(200, new TypeToken() { }.getType()) - .registerError(KeyVaultErrorException.class) - .build(response); - } - /** * List the versions of the specified key. * diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java index aace9f252cda7..058578a8e63a7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java @@ -56,7 +56,6 @@ import java.io.IOException; import java.util.List; import java.util.Map; - import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.Body; @@ -203,7 +202,7 @@ public KeyVaultClientImpl(RestClient restClient) { } protected void initialize() { - this.apiVersion = "2015-06-01-preview2"; + this.apiVersion = "2015-06-01"; this.acceptLanguage = "en-US"; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; @@ -220,7 +219,7 @@ protected void initialize() { public String userAgent() { return String.format("Azure-SDK-For-Java/%s (%s)", getClass().getPackage().getImplementationVersion(), - "KeyVaultClient, 2015-06-01-preview2"); + "KeyVaultClient, 2015-06-01"); } private void initializeService() { @@ -3388,7 +3387,7 @@ private ServiceResponse deleteCertificateDelegate(Response setCertificateContacts(String vaultBaseUrl, Con * Sets the certificate contacts for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param contacts Contacts. + * @param contacts The contacts for the vault certificates. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object @@ -4059,13 +4058,12 @@ private ServiceResponse deleteCertificateIssuerDelegate(Response createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse createCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4075,14 +4073,11 @@ public ServiceResponse createCertificate(String vaultBaseU if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - if (certificatePolicy == null) { - throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); - } - Validator.validate(certificatePolicy); + final CertificatePolicy certificatePolicy = null; final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificatePolicy(null); parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -4095,12 +4090,11 @@ public ServiceResponse createCertificate(String vaultBaseU * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param certificatePolicy The management policy for the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4116,15 +4110,11 @@ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificat serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - if (certificatePolicy == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null.")); - return null; - } - Validator.validate(certificatePolicy, serviceCallback); + final CertificatePolicy certificatePolicy = null; final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificatePolicy(null); parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -4166,9 +4156,6 @@ public ServiceResponse createCertificate(String vaultBaseU if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - if (certificatePolicy == null) { - throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); - } Validator.validate(certificatePolicy); Validator.validate(certificateAttributes); Validator.validate(tags); @@ -4209,10 +4196,6 @@ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificat serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); return null; } - if (certificatePolicy == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null.")); - return null; - } Validator.validate(certificatePolicy, serviceCallback); Validator.validate(certificateAttributes, serviceCallback); Validator.validate(tags, serviceCallback); @@ -4249,13 +4232,12 @@ private ServiceResponse createCertificateDelegate(Response * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. - * @param certificatePolicy The management policy for the certificate * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4268,17 +4250,14 @@ public ServiceResponse importCertificate(String vaultBaseUrl, if (base64EncodedCertificate == null) { throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); } - if (certificatePolicy == null) { - throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); - } - Validator.validate(certificatePolicy); final String password = null; + final CertificatePolicy certificatePolicy = null; final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateImportParameters parameters = new CertificateImportParameters(); parameters.withBase64EncodedCertificate(base64EncodedCertificate); parameters.withPassword(null); - parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificatePolicy(null); parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -4292,12 +4271,11 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. - * @param certificatePolicy The management policy for the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4317,18 +4295,14 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificat serviceCallback.failure(new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null.")); return null; } - if (certificatePolicy == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null.")); - return null; - } - Validator.validate(certificatePolicy, serviceCallback); final String password = null; + final CertificatePolicy certificatePolicy = null; final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateImportParameters parameters = new CertificateImportParameters(); parameters.withBase64EncodedCertificate(base64EncodedCertificate); parameters.withPassword(null); - parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificatePolicy(null); parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -4353,8 +4327,8 @@ public void onResponse(Call call, Response response) * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. - * @param certificatePolicy The management policy for the certificate * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param certificatePolicy The management policy for the certificate * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call @@ -4362,7 +4336,7 @@ public void onResponse(Call call, Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, CertificatePolicy certificatePolicy, String password, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4375,9 +4349,6 @@ public ServiceResponse importCertificate(String vaultBaseUrl, if (base64EncodedCertificate == null) { throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); } - if (certificatePolicy == null) { - throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); - } Validator.validate(certificatePolicy); Validator.validate(certificateAttributes); Validator.validate(tags); @@ -4398,15 +4369,15 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. - * @param certificatePolicy The management policy for the certificate * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param certificatePolicy The management policy for the certificate * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, CertificatePolicy certificatePolicy, String password, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } @@ -4426,10 +4397,6 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificat serviceCallback.failure(new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null.")); return null; } - if (certificatePolicy == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null.")); - return null; - } Validator.validate(certificatePolicy, serviceCallback); Validator.validate(certificateAttributes, serviceCallback); Validator.validate(tags, serviceCallback); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java index 71b13c1e3ea8a..1251b3303e03b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java @@ -4,6 +4,6 @@ /** * This package contains the implementation classes for KeyVaultClient. - * Client class to perform cryptographic key operations and vault operations against the Key Vault service. + * Perform cryptographic key operations and vault operations against the Key Vault service. */ package com.microsoft.azure.keyvault.implementation; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateCertificateRequest.java index 555902980c169..08825d02bcbff 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateCertificateRequest.java @@ -51,7 +51,7 @@ public Builder(String vaultBaseUrl, String certificateName) { * The management policy for the certificate. * @return the Builder object itself. */ - public Builder withCertificatePolicy(CertificatePolicy certificatePolicy) { + public Builder withPolicy(CertificatePolicy certificatePolicy) { this.policy = certificatePolicy; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificatePolicyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificatePolicyRequest.java index 934946eadc4ed..ab32687a7559d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificatePolicyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificatePolicyRequest.java @@ -45,7 +45,7 @@ public Builder(String vaultBaseUrl, String certificateName) { * The management policy for the certificate. * @return the Builder object itself. */ - public Builder withCertificatePolicy(CertificatePolicy certificatePolicy) { + public Builder withPolicy(CertificatePolicy certificatePolicy) { this.policy = certificatePolicy; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java index 6b8870b2a9d64..d95af8df0185b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The Action model. + * The action that will be executed. */ public class Action { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java index 3900cb4883035..790aef8054b95 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The AdministratorDetails model. + * Details of the organization administrator of the certificate issuer. */ public class AdministratorDetails { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java index 25bcd55f762c7..f4b4da10feb09 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The Attributes model. + * The object attributes managed by the KeyVault service. */ public class Attributes { /** @@ -82,9 +82,11 @@ public DateTime notBefore() { * @return the Attributes object itself. */ public Attributes withNotBefore(DateTime notBefore) { - if (notBefore != null) - this.notBefore = notBefore.toDateTime(DateTimeZone.UTC).getMillis() / 1000; - else this.notBefore = null; + if (notBefore == null) { + this.notBefore = null; + } else { + this.notBefore = notBefore.toDateTime(DateTimeZone.UTC).getMillis() / 1000; + } return this; } @@ -107,9 +109,11 @@ public DateTime expires() { * @return the Attributes object itself. */ public Attributes withExpires(DateTime expires) { - if (expires != null) - this.expires = expires.toDateTime(DateTimeZone.UTC).getMillis() / 1000; - else this.expires = null; + if (expires == null) { + this.expires = null; + } else { + this.expires = expires.toDateTime(DateTimeZone.UTC).getMillis() / 1000; + } return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java index 0003fc9c8f4ff..6d8a48e0187e1 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The BackupKeyResult model. + * The backup key result, containing the backup blob. */ public class BackupKeyResult { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java index 32865f854c88f..a67937cc1d0d9 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; /** - * The CertificateBundle model. + * A certificate bundle consists of a certificate (X509) plus its attributes. */ public class CertificateBundle { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java index 2d6f5686ac0b1..61727eacb5f76 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java @@ -10,13 +10,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The CertificateCreateParameters model. + * The certificate create parameters. */ public class CertificateCreateParameters { /** * The management policy for the certificate. */ - @JsonProperty(value = "policy", required = true) + @JsonProperty(value = "policy") private CertificatePolicy certificatePolicy; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java index fb787afd76537..f0c1a3e80049c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The CertificateImportParameters model. + * The certificate import parameters. */ public class CertificateImportParameters { /** @@ -30,7 +30,7 @@ public class CertificateImportParameters { /** * The management policy for the certificate. */ - @JsonProperty(value = "policy", required = true) + @JsonProperty(value = "policy") private CertificatePolicy certificatePolicy; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java index 126c91f8cec93..97c7e6231ba76 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java @@ -8,7 +8,7 @@ /** - * The CertificateIssuerItem model. + * The certificate issuer item containing certificate issuer metadata. */ public class CertificateIssuerItem { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java index 6c0c99bc69ce3..4cf89baf08bf2 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java @@ -12,7 +12,7 @@ import com.microsoft.azure.keyvault.implementation.CertificateIdentifier; /** - * The CertificateItem model. + * The certificate item containing certificate metadata. */ public class CertificateItem { /** @@ -115,7 +115,11 @@ public byte[] x5T() { * @return the CertificateItem object itself. */ public CertificateItem withX5T(byte[] x5T) { - this.x5T = Base64Url.encode(x5T); + if (x5T == null) { + this.x5T = null; + } else { + this.x5T = Base64Url.encode(x5T); + } return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java index bfbbdedf6668e..6c24fe1e941c5 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The CertificateMergeParameters model. + * The certificate merge parameters. */ public class CertificateMergeParameters { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java index 5f2a473eefe38..d455ed507da3f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java @@ -6,8 +6,6 @@ package com.microsoft.azure.keyvault.models; -import com.microsoft.rest.Base64Url; - import java.io.IOException; import com.fasterxml.jackson.annotation.JsonProperty; @@ -17,7 +15,7 @@ import com.microsoft.azure.keyvault.implementation.CertificateOperationIdentifier; /** - * The CertificateOperation model. + * A certificate operation is returned in case of async requests. */ public class CertificateOperation { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java index 234480213a8b4..6eed27f2610fa 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The CertificatePolicy model. + * Management policy for a certificate. */ public class CertificatePolicy { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java index b015da3314875..68dca444f6e2e 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The CertificateUpdateParameters model. + * The certificate update parameters. */ public class CertificateUpdateParameters { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java index 18a6694a21afb..e92efcb58400c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The Contact model. + * The contact information for the vault certificates. */ public class Contact { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java index 3be777fbfccd7..1cbd4321f1785 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The Contacts model. + * The contacts for the vault certificates. */ public class Contacts { /** @@ -20,7 +20,7 @@ public class Contacts { private String id; /** - * Contacts. + * The contact list for the vault certificates. */ @JsonProperty(value = "contacts") private List contactList; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java index 2046221183fe2..fcbfce15499c2 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The Error model. + * The key vault server error. */ public class Error { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java index d07df06a92a71..475da1d65800f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The IssuerAttributes model. + * The attributes of an issuer managed by the KeyVault service. */ public class IssuerAttributes { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java index 6c28a862a28a3..9ebcdc6161c6e 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -15,7 +15,7 @@ import com.microsoft.azure.keyvault.implementation.IssuerIdentifier; /** - * The IssuerBundle model. + * The issuer for Key Vault certificate. */ public class IssuerBundle { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java index 674f8822d10f9..17de164137dd0 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The IssuerCredentials model. + * The credentials to be used for the certificate issuer. */ public class IssuerCredentials { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java index d6e7985b81156..2a3d0f7dd05bd 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java @@ -8,7 +8,7 @@ /** - * The IssuerReference model. + * Reference to the issuer of the X509 component of a certificate. */ public class IssuerReference { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java index 0db281ea99185..15df227b48437 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java @@ -28,7 +28,7 @@ import com.microsoft.rest.Base64Url; /** - * The JsonWebKey model. + * As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18. */ public class JsonWebKey { /** @@ -63,27 +63,27 @@ public class JsonWebKey { private Base64Url d; /** - * The dp property. + * RSA Private Key Parameter. */ private Base64Url dp; /** - * The dq property. + * RSA Private Key Parameter. */ private Base64Url dq; /** - * The qi property. + * RSA Private Key Parameter. */ private Base64Url qi; /** - * The p property. + * RSA secret prime. */ private Base64Url p; /** - * The q property. + * RSA secret prime, with p < q. */ private Base64Url q; @@ -178,8 +178,11 @@ public byte[] n() { * @return the JsonWebKey object itself. */ public JsonWebKey withN(byte[] n) { - if (n != null) - this.n = Base64Url.encode(n); + if (n == null) { + this.n = null; + } else { + this.n = Base64Url.encode(n); + } return this; } @@ -202,8 +205,11 @@ public byte[] e() { * @return the JsonWebKey object itself. */ public JsonWebKey withE(byte[] e) { - if (e != null) - this.e = Base64Url.encode(e); + if (e == null) { + this.e = null; + } else { + this.e = Base64Url.encode(e); + } return this; } @@ -226,8 +232,11 @@ public byte[] d() { * @return the JsonWebKey object itself. */ public JsonWebKey withD(byte[] d) { - if (d != null) - this.d = Base64Url.encode(d); + if (d == null) { + this.d = null; + } else { + this.d = Base64Url.encode(d); + } return this; } @@ -250,8 +259,11 @@ public byte[] dp() { * @return the JsonWebKey object itself. */ public JsonWebKey withDp(byte[] dp) { - if (dp != null) - this.dp = Base64Url.encode(dp); + if (dp == null) { + this.dp = null; + } else { + this.dp = Base64Url.encode(dp); + } return this; } @@ -274,8 +286,11 @@ public byte[] dq() { * @return the JsonWebKey object itself. */ public JsonWebKey withDq(byte[] dq) { - if (dq != null) - this.dq = Base64Url.encode(dq); + if (dq == null) { + this.dq = null; + } else { + this.dq = Base64Url.encode(dq); + } return this; } @@ -298,8 +313,11 @@ public byte[] qi() { * @return the JsonWebKey object itself. */ public JsonWebKey withQi(byte[] qi) { - if (qi != null) - this.qi = Base64Url.encode(qi); + if (qi == null) { + this.qi = null; + } else { + this.qi = Base64Url.encode(qi); + } return this; } @@ -322,8 +340,11 @@ public byte[] p() { * @return the JsonWebKey object itself. */ public JsonWebKey withP(byte[] p) { - if (p != null) - this.p = Base64Url.encode(p); + if (p == null) { + this.p = null; + } else { + this.p = Base64Url.encode(p); + } return this; } @@ -346,8 +367,11 @@ public byte[] q() { * @return the JsonWebKey object itself. */ public JsonWebKey withQ(byte[] q) { - if (q != null) - this.q = Base64Url.encode(q); + if (q == null) { + this.q = null; + } else { + this.q = Base64Url.encode(q); + } return this; } @@ -370,8 +394,11 @@ public byte[] k() { * @return the JsonWebKey object itself. */ public JsonWebKey withK(byte[] k) { - if (k != null) - this.k = Base64Url.encode(k); + if (k == null) { + this.k = null; + } else { + this.k = Base64Url.encode(k); + } return this; } @@ -394,8 +421,11 @@ public byte[] t() { * @return the JsonWebKey object itself. */ public JsonWebKey withT(byte[] t) { - if (t != null) - this.t = Base64Url.encode(t); + if (t == null) { + this.t = null; + } else { + this.t = Base64Url.encode(t); + } return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java index 6a4983eeaa85f..7ce170c5baa24 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java @@ -8,7 +8,7 @@ /** - * The key management attributes. + * The attributes of a key managed by the KeyVault service. */ public class KeyAttributes extends Attributes { } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index 8f5d1ca1cf7a6..744bc82515910 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -15,7 +15,7 @@ import com.microsoft.azure.keyvault.implementation.KeyIdentifier; /** - * The KeyBundle model. + * A KeyBundle consisting of a WebKey plus its Attributes. */ public class KeyBundle { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java index 304abe65e1eef..4c384abeac0d7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The KeyCreateParameters model. + * The key create parameters. */ public class KeyCreateParameters { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java index 23ef7ecdea255..57d738de2eace 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The KeyImportParameters model. + * The key import parameters. */ public class KeyImportParameters { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index dbeb9a1516bbb..4b7ed86c6f657 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -11,7 +11,7 @@ import com.microsoft.azure.keyvault.implementation.KeyIdentifier; /** - * The KeyItem model. + * The key item containing key metadata. */ public class KeyItem { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java index 46057b6f20742..738ffda32dfa0 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The KeyOperationResult model. + * The key operation result. */ public class KeyOperationResult { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java index 84381a63f3528..0115785ea2798 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The KeyOperationsParameters model. + * The key operations parameters. */ public class KeyOperationsParameters { /** @@ -64,7 +64,11 @@ public byte[] value() { * @return the KeyOperationsParameters object itself. */ public KeyOperationsParameters withValue(byte[] value) { - this.value = Base64Url.encode(value); + if (value == null) { + this.value = null; + } else { + this.value = Base64Url.encode(value); + } return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java index 6452c1ddca7d1..c88ff228583e6 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The KeyProperties model. + * Properties of the key pair backing a certificate. */ public class KeyProperties { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java index c35ae6b9ca12c..97adc31e5034b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The KeyRestoreParameters model. + * The key restore parameters. */ public class KeyRestoreParameters { /** @@ -38,7 +38,11 @@ public byte[] keyBundleBackup() { * @return the KeyRestoreParameters object itself. */ public KeyRestoreParameters withKeyBundleBackup(byte[] keyBundleBackup) { - this.keyBundleBackup = Base64Url.encode(keyBundleBackup); + if (keyBundleBackup == null) { + this.keyBundleBackup = null; + } else { + this.keyBundleBackup = Base64Url.encode(keyBundleBackup); + } return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java index 8b5a4d6e75c7e..e10e3aa0335dc 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The KeyUpdateParameters model. + * The key update parameters. */ public class KeyUpdateParameters { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java index 4666ffa6c2f6a..81c51587804cc 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The KeyVaultError model. + * the key vault error exception. */ public class KeyVaultError { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java index e393a8a8f0ff9..6c2d0d6a56494 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The KeyVerifyParameters model. + * The key verify parameters. */ public class KeyVerifyParameters { /** @@ -71,7 +71,11 @@ public byte[] digest() { * @return the KeyVerifyParameters object itself. */ public KeyVerifyParameters withDigest(byte[] digest) { - this.digest = Base64Url.encode(digest); + if (digest == null) { + this.digest = null; + } else { + this.digest = Base64Url.encode(digest); + } return this; } @@ -94,7 +98,11 @@ public byte[] signature() { * @return the KeyVerifyParameters object itself. */ public KeyVerifyParameters withSignature(byte[] signature) { - this.signature = Base64Url.encode(signature); + if (signature == null) { + this.signature = null; + } else { + this.signature = Base64Url.encode(signature); + } return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java index d69200854435f..317c6ef3a7aab 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The KeyVerifyResult model. + * The key verify result. */ public class KeyVerifyResult { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java index f381b9b90c05b..27d6d074e7da5 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java @@ -8,7 +8,8 @@ /** - * The LifetimeAction model. + * Action and its trigger that will be performed by Key Vault over the + * lifetime of a certificate. */ public class LifetimeAction { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java index 4968fde2996ad..531f1171db4da 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The OrganizationDetails model. + * Details of the organization of the certificate issuer. */ public class OrganizationDetails { /** @@ -21,8 +21,8 @@ public class OrganizationDetails { /** * Details of the organization administrator. */ - @JsonProperty(value = "AdministratorDetails") - private List administratorDetails; + @JsonProperty(value = "admin_details") + private List adminDetails; /** * Get the id value. @@ -45,22 +45,22 @@ public OrganizationDetails withId(String id) { } /** - * Get the administratorDetails value. + * Get the adminDetails value. * - * @return the administratorDetails value + * @return the adminDetails value */ - public List administratorDetails() { - return this.administratorDetails; + public List adminDetails() { + return this.adminDetails; } /** - * Set the administratorDetails value. + * Set the adminDetails value. * - * @param administratorDetails the administratorDetails value to set + * @param adminDetails the adminDetails value to set * @return the OrganizationDetails object itself. */ - public OrganizationDetails withAdministratorDetails(List administratorDetails) { - this.administratorDetails = administratorDetails; + public OrganizationDetails withAdminDetails(List adminDetails) { + this.adminDetails = adminDetails; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java index 4be0e50df8043..dbb7d57926145 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The PendingCertificateSigningRequestResult model. + * The pending certificate signing request result. */ public class PendingCertificateSigningRequestResult { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index 83b615cb90d1d..f4dea9b870674 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -15,7 +15,7 @@ import com.microsoft.azure.keyvault.implementation.SecretIdentifier; /** - * The SecretBundle model. + * A Secret consisting of a value, id and its attributes. */ public class SecretBundle { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index d68f4494dcd06..1eab37d1fe431 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -11,7 +11,7 @@ import com.microsoft.azure.keyvault.implementation.SecretIdentifier; /** - * The SecretItem model. + * The secret item containing secret metadata. */ public class SecretItem { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java index 8c588dc20194a..4ba5abada96a7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java @@ -6,16 +6,14 @@ package com.microsoft.azure.keyvault.models; -import com.fasterxml.jackson.annotation.JsonProperty; /** - * The SecretProperties model. + * Properties of the key backing a certificate. */ public class SecretProperties { /** * The media type (MIME type). */ - @JsonProperty(value = "ContentType") private String contentType; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java index 77a95e23b8de4..810e96bece7ef 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The SecretSetParameters model. + * The secret set parameters. */ public class SecretSetParameters { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java index 71f75ba128cdd..06174214cc161 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The SecretUpdateParameters model. + * The secret update parameters. */ public class SecretUpdateParameters { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java index 0add3eae269df..4b09ad331a801 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The SubjectAlternativeNames model. + * The subject alternate names of a X509 object. */ public class SubjectAlternativeNames { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java index 900129b0a5da0..6f780dea882c7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The Trigger model. + * A condition to be satisfied for an action to be executed. */ public class Trigger { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java index e66ee40ec72f3..c291be20c8123 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java @@ -10,11 +10,11 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The X509CertificateProperties model. + * Properties of the X509 component of a certificate. */ public class X509CertificateProperties { /** - * The subject name. Should be a valid X500 Distinguished Name. + * The subject name. Should be a valid X509 Distinguished Name. */ private String subject; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java index 241355f8ecd6f..91ac9f584403a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java @@ -4,6 +4,6 @@ /** * This package contains the models classes for KeyVaultClient. - * Client class to perform cryptographic key operations and vault operations against the Key Vault service. + * Perform cryptographic key operations and vault operations against the Key Vault service. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java index 1160e5ba8eb04..140c3c675f762 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java @@ -4,6 +4,6 @@ /** * This package contains the classes for KeyVaultClient. - * Client class to perform cryptographic key operations and vault operations against the Key Vault service. + * Perform cryptographic key operations and vault operations against the Key Vault service. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index 6e4a9006900b0..12c1922493e48 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -51,7 +51,6 @@ import org.junit.Assert; import org.junit.Test; -import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.azure.keyvault.implementation.CertificateIdentifier; import com.microsoft.azure.keyvault.implementation.SecretIdentifier; @@ -139,7 +138,7 @@ public void createSelfSignedCertificatePkcs12() throws Exception { CertificateOperation certificateOperation = keyVaultClient.createCertificate( new CreateCertificateRequest .Builder(vaultUri, certificateName) - .withCertificatePolicy(certificatePolicy) + .withPolicy(certificatePolicy) .build()).getBody(); Assert.assertNotNull(certificateOperation); @@ -237,7 +236,7 @@ public void createSelfSignedCertificatePem() throws Exception { CertificateOperation certificateOperation = keyVaultClient.createCertificate( new CreateCertificateRequest .Builder(vaultUri, certificateName) - .withCertificatePolicy(certificatePolicy) + .withPolicy(certificatePolicy) .build()).getBody(); Assert.assertNotNull(certificateOperation); @@ -274,7 +273,6 @@ public void createSelfSignedCertificatePem() throws Exception { Assert.assertNotNull(certificates); Assert.assertTrue(certificates.size() == 1); - // TODO: Iterate over certificates collection to find which certificate // has the public key corresponding to the private key. X509Certificate secretCertificate = certificates.get(0); Assert.assertNotNull(secretCertificate); @@ -320,7 +318,7 @@ public void createCertificatePkcs12() throws Exception { OrganizationDetails organizationDetails = new OrganizationDetails(); List administratorsDetails = new ArrayList(); administratorsDetails.add(administratorDetails); - organizationDetails.withAdministratorDetails(administratorsDetails); + organizationDetails.withAdminDetails(administratorsDetails); // Construct certificate issuer credentials IssuerCredentials credentials = new IssuerCredentials(); @@ -367,7 +365,7 @@ public void createCertificatePkcs12() throws Exception { CertificateOperation certificateOperation = keyVaultClient.createCertificate( new CreateCertificateRequest .Builder(vaultUri, certificateName) - .withCertificatePolicy(certificatePolicy) + .withPolicy(certificatePolicy) .build()).getBody(); Assert.assertNotNull(certificateOperation); @@ -459,7 +457,7 @@ public void createCertificatePem() throws Exception { OrganizationDetails organizationDetails = new OrganizationDetails(); List administratorsDetails = new ArrayList(); administratorsDetails.add(administratorDetails); - organizationDetails.withAdministratorDetails(administratorsDetails); + organizationDetails.withAdminDetails(administratorsDetails); // Construct certificate issuer credentials IssuerCredentials credentials = new IssuerCredentials(); @@ -505,7 +503,7 @@ public void createCertificatePem() throws Exception { CertificateOperation certificateOperation = keyVaultClient.createCertificate( new CreateCertificateRequest .Builder(vaultUri, certificateName) - .withCertificatePolicy(certificatePolicy) + .withPolicy(certificatePolicy) .build()).getBody(); Assert.assertNotNull(certificateOperation); @@ -547,7 +545,6 @@ public void createCertificatePem() throws Exception { Assert.assertNotNull(certificates); Assert.assertTrue(certificates.size() == 1); - // TODO: Iterate over certificates collection to find which certificate // has the public key corresponding to the private key. X509Certificate secretCertificate = certificates.get(0); Assert.assertNotNull(secretCertificate); @@ -605,11 +602,11 @@ public void createCsr() throws InterruptedException, ExecutionException, KeyVaul certificatePolicy.withX509CertificateProperties(x509Properties); String vaultUri = getVaultUri(); - String certificateName = "createManualEnrollmentJava4"; + String certificateName = "createManualEnrollmentJava"; CertificateOperation certificateOperation = keyVaultClient.createCertificate( new CreateCertificateRequest .Builder(vaultUri, certificateName) - .withCertificatePolicy(certificatePolicy) + .withPolicy(certificatePolicy) .build()).getBody(); Assert.assertNotNull(certificateOperation); @@ -992,7 +989,7 @@ public void issuerCrudOperations() throws Exception { OrganizationDetails organizationDetails = new OrganizationDetails(); List administratorsDetails = new ArrayList(); administratorsDetails.add(administratorDetails); - organizationDetails.withAdministratorDetails(administratorsDetails); + organizationDetails.withAdminDetails(administratorsDetails); // Construct certificate issuer credentials IssuerCredentials credentials = new IssuerCredentials(); diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 86dc22f1c824c..963985e7b6994 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -38,10 +38,8 @@ import org.junit.Test; import com.microsoft.azure.keyvault.models.KeyBundle; -import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.azure.keyvault.implementation.KeyIdentifier; -import com.microsoft.azure.keyvault.implementation.SecretIdentifier; import com.microsoft.azure.keyvault.implementation.requests.CreateKeyRequest; import com.microsoft.azure.keyvault.implementation.requests.ImportKeyRequest; import com.microsoft.azure.keyvault.implementation.requests.UpdateKeyRequest; @@ -49,7 +47,6 @@ import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyResult; -import com.microsoft.azure.keyvault.models.CertificateItem; import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index ff5b2f960acb2..9ca02891c2b50 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -25,10 +25,8 @@ import org.junit.Assert; import org.junit.Test; -import com.microsoft.azure.keyvault.models.CertificateItem; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.SecretBundle; -import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.azure.keyvault.implementation.SecretIdentifier; import com.microsoft.azure.keyvault.implementation.requests.SetSecretRequest; From 8ea2abf23f4f5e421e104ef96b449887002a44de Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Fri, 22 Jul 2016 10:48:45 -0700 Subject: [PATCH 06/56] Working core, cryptography and extensions using a FutureAdapter. --- azure-keyvault-core/pom.xml | 130 ++++++ .../microsoft/azure/keyvault/core/IKey.java | 156 +++++++ .../azure/keyvault/core/IKeyResolver.java | 39 ++ azure-keyvault-cryptography/pom.xml | 68 +++ .../keyvault/cryptography/Algorithm.java | 36 ++ .../cryptography/AlgorithmResolver.java | 83 ++++ .../AsymmetricEncryptionAlgorithm.java | 42 ++ .../AsymmetricSignatureAlgorithm.java | 27 ++ .../cryptography/EncryptionAlgorithm.java | 27 ++ .../keyvault/cryptography/FutureBase.java | 71 +++ .../FutureExecutionException.java | 45 ++ .../cryptography/FutureImmediate.java | 56 +++ .../IAuthenticatedCryptoTransform.java | 24 + .../cryptography/ICryptoTransform.java | 30 ++ .../cryptography/KeyWrapAlgorithm.java | 49 ++ .../azure/keyvault/cryptography/RsaKey.java | 342 ++++++++++++++ .../cryptography/SignatureAlgorithm.java | 27 ++ .../azure/keyvault/cryptography/Strings.java | 42 ++ .../SymmetricEncryptionAlgorithm.java | 42 ++ .../keyvault/cryptography/SymmetricKey.java | 349 ++++++++++++++ .../cryptography/algorithms/Aes128Cbc.java | 29 ++ .../algorithms/Aes128CbcHmacSha256.java | 28 ++ .../cryptography/algorithms/Aes192Cbc.java | 29 ++ .../algorithms/Aes192CbcHmacSha384.java | 28 ++ .../cryptography/algorithms/Aes256Cbc.java | 29 ++ .../algorithms/Aes256CbcHmacSha512.java | 28 ++ .../cryptography/algorithms/AesCbc.java | 109 +++++ .../algorithms/AesCbcHmacSha2.java | 289 ++++++++++++ .../cryptography/algorithms/AesKw.java | 192 ++++++++ .../cryptography/algorithms/AesKw128.java | 65 +++ .../cryptography/algorithms/AesKw192.java | 65 +++ .../cryptography/algorithms/AesKw256.java | 65 +++ .../cryptography/algorithms/Rsa15.java | 113 +++++ .../algorithms/RsaEncryption.java | 29 ++ .../cryptography/algorithms/RsaOaep.java | 115 +++++ .../cryptography/algorithms/package.html | 5 + .../azure/keyvault/cryptography/package.html | 5 + .../test/AesCbcBCProviderTest.java | 132 ++++++ .../test/AesCbcDefaultProviderTest.java | 120 +++++ .../cryptography/test/AesCbcHmacShaTest.java | 121 +++++ .../test/AesKwBCProviderTest.java | 289 ++++++++++++ .../test/AesKwDefaultProviderTest.java | 316 +++++++++++++ .../cryptography/test/RsaKeyTest.java | 204 +++++++++ .../test/SymmetricKeyBCProviderTest.java | 354 +++++++++++++++ .../test/SymmetricKeyDefaultProviderTest.java | 424 ++++++++++++++++++ azure-keyvault-extensions/pom.xml | 143 ++++++ .../extensions/AggregateKeyResolver.java | 139 ++++++ .../extensions/CachingKeyResolver.java | 50 +++ .../keyvault/extensions/FutureAdapter.java | 138 ++++++ .../azure/keyvault/extensions/FutureBase.java | 61 +++ .../extensions/FutureExecutionException.java | 45 ++ .../keyvault/extensions/FutureImmediate.java | 56 +++ .../keyvault/extensions/KeyVaultKey.java | 247 ++++++++++ .../extensions/KeyVaultKeyResolver.java | 125 ++++++ .../azure/keyvault/extensions/Strings.java | 41 ++ .../azure/keyvault/extensions/package.html | 5 + .../test/CachingKeyResolverTest.java | 98 ++++ .../KeyVaultClientIntegrationTestBase.java | 164 +++++++ .../KeyVaultKeyResolverBCProviderTest.java | 294 ++++++++++++ ...eyVaultKeyResolverDefaultProviderTest.java | 316 +++++++++++++ azure-keyvault/pom.xml | 1 + 61 files changed, 6791 insertions(+) create mode 100644 azure-keyvault-core/pom.xml create mode 100644 azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java create mode 100644 azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java create mode 100644 azure-keyvault-cryptography/pom.xml create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureBase.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureExecutionException.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureImmediate.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java create mode 100644 azure-keyvault-extensions/pom.xml create mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java create mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java create mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureAdapter.java create mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureBase.java create mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureExecutionException.java create mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureImmediate.java create mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java create mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java create mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java create mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/package.html create mode 100644 azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java create mode 100644 azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java create mode 100644 azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java create mode 100644 azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml new file mode 100644 index 0000000000000..86897281875d3 --- /dev/null +++ b/azure-keyvault-core/pom.xml @@ -0,0 +1,130 @@ + + + 4.0.0 + + com.microsoft.azure + azure-parent + 1.0.0-SNAPSHOT + ../pom.xml + + + azure-keyvault-core + jar + + Microsoft Azure SDK for Key Vault + This package contains Microsoft Azure Key Vault SDK. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + UTF-8 + + + + + + microsoft + Microsoft + + + + + + com.microsoft.azure + azure-client-runtime + 1.0.0-SNAPSHOT + + + org.apache.httpcomponents + httpclient + 4.5.2 + + + junit + junit + test + + + com.microsoft.azure + azure-client-authentication + 1.0.0-beta1 + test + + + com.microsoft.azure + azure-core + 0.9.3 + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.storage + /** +
* Copyright (c) Microsoft Corporation. All rights reserved. +
* Licensed under the MIT License. See License.txt in the project root for +
* license information. +
*/]]>
+
+
+ +
+
+
diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java new file mode 100644 index 0000000000000..c604c4b5c3052 --- /dev/null +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java @@ -0,0 +1,156 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.core; + +import java.io.Closeable; +import java.security.NoSuchAlgorithmException; +import java.util.concurrent.Future; + +import org.apache.commons.lang3.tuple.Pair; +import org.apache.commons.lang3.tuple.Triple; + +/** + * Interface for representing cryptographic keys with the Microsoft Azure Key + * Vault libraries. + */ +public interface IKey extends Closeable { + + /** + * The default encryption algorithm for this key, using the representations + * from Json Web Key Algorithms, RFC7513 + * + * @return The default encryption algorithm for this key. + */ + String getDefaultEncryptionAlgorithm(); + + /** + * The default key wrap algorithm for this key, using the representations + * from Json Web Key Algorithms, RFC7513 + * + * @return The default key wrap algorithm for this key. + */ + String getDefaultKeyWrapAlgorithm(); + + /** + * The default signature algorithm for this key, using the representations + * from Json Web Key Algorithms, RFC7513 + * + * @return The default signature algorithm for this key. + */ + String getDefaultSignatureAlgorithm(); + + /** + * The unique key identifier for this key. + * + * @return The key identifier + */ + String getKid(); + + /** + * Decrypts the specified cipher text. Note that not all algorithms require, + * or support, all parameters. + * + * @param ciphertext + * The cipher text to decrypt + * @param iv + * The initialization vector (optional with some algorithms) + * @param authenticationData + * Additional authentication data (optional with some algorithms) + * @param authenticationTag + * The authentication tag from the encrypt operation (optional + * with some algorithms) + * @param algorithm + * The encryption algorithm to use, must be supplied + * @return A {@link:Future} containing the plain text + * @throws NoSuchAlgorithmException + */ + Future decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm) throws NoSuchAlgorithmException; + + /** + * Encrypts the specified plain text. Note that not all algorithms require, + * or support, all parameters. + * + * @param plaintext + * The plain text to encrypt + * @param iv + * The initialization vector (optional with some algorithms) + * @param authenticationData + * Additional authentication data (optional with some algorithms) + * @param algorithm + * The encryption algorithm to use, defaults to the keys + * DefaultEncryptionAlgorithm + * @return A {@link:Future} containing the cipher text, the authentication + * tag and the algorithm that was used + * @throws NoSuchAlgorithmException + */ + Future> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm) throws NoSuchAlgorithmException; + + /** + * Wraps (encrypts) the specified symmetric key material using the specified + * algorithm, or the keys DefaultKeyWrapAlgorithm if none is specified. + * + * @param key + * The symmetric key to wrap + * @param algorithm + * The wrapping algorithm to use, defaults to the keys + * DefaultKeyWrapAlgorithm + * @return A {@link:Future} containing the encrypted key and the algorithm + * that was used + * @throws NoSuchAlgorithmException + */ + Future> wrapKeyAsync(final byte[] key, final String algorithm) throws NoSuchAlgorithmException; + + /** + * Unwraps (decrypts) the specified encryped key material. + * + * @param encryptedKey + * The encrypted key to decrypt + * @param algorithm + * The algorithm to use, must be supplied + * @return A {@link:Future} containing the unwrapped key + * @throws NoSuchAlgorithmException + */ + Future unwrapKeyAsync(final byte[] encryptedKey, final String algorithm) throws NoSuchAlgorithmException; + + /** + * Signs the specified digest using the specified algorithm, or the keys + * DefaultSignatureAlgorithm if no algorithm is specified. + * + * @param digest + * The digest to sign + * @param algorithm + * The signature algorithm to use + * @return A {@link:Future} containing the signature and the algorithm used. + */ + Future> signAsync(final byte[] digest, final String algorithm); + + /** + * Verifies the supplied signature value using the supplied digest and + * algorithm. + * + * @param digest + * The digest input + * @param signature + * The signature to verify + * @param algorithm + * The algorithm to use, must be provided + * @return A {@link:Future} containing a boolean result + */ + Future verifyAsync(final byte[] digest, final byte[] signature, final String algorithm); +} diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java new file mode 100644 index 0000000000000..2a3238e5716d9 --- /dev/null +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java @@ -0,0 +1,39 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.core; + +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +public interface IKeyResolver { + + /** + * Retrieves an IKey implementation for the specified key identifier. + * Implementations should check the format of the kid to ensure that it is + * recognized. Null, rather than an exception, should be returned for + * unrecognized key identifiers to enable chaining of key resolvers. + * + * @param kid + * The key identifier to resolve. + * @return A {@link:Future} containing the resolved IKey + * @throws InterruptedException + * @throws ExecutionException + */ + Future resolveKeyAsync(String kid); +} diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml new file mode 100644 index 0000000000000..a8991d80d2da3 --- /dev/null +++ b/azure-keyvault-cryptography/pom.xml @@ -0,0 +1,68 @@ + + + 4.0.0 + + + com.microsoft.azure + azure-parent + 1.0.0-SNAPSHOT + ../pom.xml + + + azure-keyvault-cryptography + jar + + Microsoft Azure SDK for Key Vault + This package contains Microsoft Azure SDK for Key Vault. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + UTF-8 + + + true + + + + + + org.apache.commons + commons-lang3 + 3.4 + + + junit + junit + test + + + org.bouncycastle + bcprov-jdk15on + test + 1.54 + + + ${project.groupId} + azure-keyvault-core + ${project.version} + + + diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java new file mode 100644 index 0000000000000..810a6dfa4fb51 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java @@ -0,0 +1,36 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +public abstract class Algorithm { + + private final String _name; + + protected Algorithm(String name) { + if (Strings.isNullOrEmpty(name)) { + throw new IllegalArgumentException("name"); + } + + _name = name; + } + + public String getName() { + return _name; + } +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java new file mode 100644 index 0000000000000..1eacaad75e0c3 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java @@ -0,0 +1,83 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128CbcHmacSha256; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes192Cbc; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes192CbcHmacSha384; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes256Cbc; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes256CbcHmacSha512; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw128; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw192; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256; +import com.microsoft.azure.keyvault.cryptography.algorithms.Rsa15; +import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; + +public class AlgorithmResolver { + + public static final AlgorithmResolver Default = new AlgorithmResolver(); + + static { + Default.put(Aes128CbcHmacSha256.AlgorithmName, new Aes128CbcHmacSha256()); + Default.put(Aes192CbcHmacSha384.AlgorithmName, new Aes192CbcHmacSha384()); + Default.put(Aes256CbcHmacSha512.AlgorithmName, new Aes256CbcHmacSha512()); + + Default.put(Aes128Cbc.AlgorithmName, new Aes128Cbc()); + Default.put(Aes192Cbc.AlgorithmName, new Aes192Cbc()); + Default.put(Aes256Cbc.AlgorithmName, new Aes256Cbc()); + + Default.put(AesKw128.AlgorithmName, new AesKw128()); + Default.put(AesKw192.AlgorithmName, new AesKw192()); + Default.put(AesKw256.AlgorithmName, new AesKw256()); + + Default.put(Rsa15.AlgorithmName, new Rsa15()); + Default.put(RsaOaep.AlgorithmName, new RsaOaep()); + + // Default.put( Rs256.AlgorithmName, new Rs256() ); + // Default.put( RsNull.AlgorithmName, new RsNull() ); + } + + private final ConcurrentMap _algorithms = new ConcurrentHashMap(); + + /// + /// Returns the implementation for an algorithm name + /// + /// The algorithm name + /// + public Algorithm get(String algorithmName) { + return _algorithms.get(algorithmName); + } + + public void put(String algorithmName, Algorithm provider) { + _algorithms.put(algorithmName, provider); + } + + /// + /// Removes an algorithm from the resolver + /// + /// The algorithm name + public void remove(String algorithmName) { + _algorithms.remove(algorithmName); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java new file mode 100644 index 0000000000000..6a01e0333b0f2 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java @@ -0,0 +1,42 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +import java.security.InvalidKeyException; +import java.security.KeyPair; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.NoSuchPaddingException; + +public abstract class AsymmetricEncryptionAlgorithm extends EncryptionAlgorithm { + + protected AsymmetricEncryptionAlgorithm(String name) { + super(name); + } + + public abstract ICryptoTransform CreateEncryptor(KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException; + + public abstract ICryptoTransform CreateEncryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException; + + public abstract ICryptoTransform CreateDecryptor(KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException; + + public abstract ICryptoTransform CreateDecryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException; + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java new file mode 100644 index 0000000000000..5232ab646ff4c --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java @@ -0,0 +1,27 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +public abstract class AsymmetricSignatureAlgorithm extends SignatureAlgorithm { + + protected AsymmetricSignatureAlgorithm(String name) { + super(name); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java new file mode 100644 index 0000000000000..527b704d6db20 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java @@ -0,0 +1,27 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +public abstract class EncryptionAlgorithm extends Algorithm { + + protected EncryptionAlgorithm(String name) { + super(name); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureBase.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureBase.java new file mode 100644 index 0000000000000..3f2a53ebd57b2 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureBase.java @@ -0,0 +1,71 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +import java.util.concurrent.Future; + +abstract class FutureBase implements Future { + + private boolean _cancelled = false; + private boolean _done = false; + + protected FutureBase() { + this(false, false); + } + + protected FutureBase(boolean done) { + this(done, false); + } + + protected FutureBase(boolean done, boolean cancelled) { + _done = done; + _cancelled = cancelled; + } + + protected void setDone() { + _cancelled = false; + _done = true; + } + + protected void setCancelled() { + _cancelled = true; + _done = true; + } + + @Override + public boolean cancel(boolean mayInterruptIfRunning) { + + // mark cancelled + _cancelled = true; + + return _cancelled; + } + + @Override + public boolean isCancelled() { + + return _cancelled; + } + + @Override + public boolean isDone() { + + return _done; + } +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureExecutionException.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureExecutionException.java new file mode 100644 index 0000000000000..f070e7149eebb --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureExecutionException.java @@ -0,0 +1,45 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +class FutureExecutionException extends FutureBase { + + private final ExecutionException _e; + + FutureExecutionException(Throwable t) { + super(true,false); + + _e = new ExecutionException(t); + } + + @Override + public T get() throws InterruptedException, ExecutionException { + throw _e; + } + + @Override + public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + throw _e; + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureImmediate.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureImmediate.java new file mode 100644 index 0000000000000..35b6e2ecd9344 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureImmediate.java @@ -0,0 +1,56 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +class FutureImmediate extends FutureBase { + + private final T _result; + + FutureImmediate(T result) { + super(true); + + _result = result; + } + + @Override + public T get() throws InterruptedException, ExecutionException { + + // throw if cancelled + if (isCancelled()) { + throw new InterruptedException(); + } + + return _result; + } + + @Override + public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + + // throw if cancelled + if (isCancelled()) { + throw new InterruptedException(); + } + + return _result; + } +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java new file mode 100644 index 0000000000000..8145964666abf --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java @@ -0,0 +1,24 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +public interface IAuthenticatedCryptoTransform extends ICryptoTransform { + + public byte[] getTag(); +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java new file mode 100644 index 0000000000000..3e1c725b3f8b0 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java @@ -0,0 +1,30 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; + +public interface ICryptoTransform { + + public byte[] doFinal(byte[] input) throws IllegalBlockSizeException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException; +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java new file mode 100644 index 0000000000000..fdc15bc1dad94 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java @@ -0,0 +1,49 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.NoSuchPaddingException; + +public abstract class KeyWrapAlgorithm extends Algorithm { + + protected KeyWrapAlgorithm(String name) { + super(name); + } + + public abstract ICryptoTransform CreateEncryptor(byte[] key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + + public abstract ICryptoTransform CreateEncryptor(byte[] key, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + + public abstract ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + + public abstract ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + + public abstract ICryptoTransform CreateDecryptor(byte[] key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + + public abstract ICryptoTransform CreateDecryptor(byte[] key, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + + public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + + public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java new file mode 100644 index 0000000000000..e34910c847a9a --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java @@ -0,0 +1,342 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +import java.io.IOException; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.interfaces.RSAPublicKey; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.apache.commons.lang3.tuple.Pair; +import org.apache.commons.lang3.tuple.Triple; + +import com.microsoft.azure.keyvault.core.IKey; +import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; +import com.microsoft.azure.keyvault.cryptography.FutureBase; +import com.microsoft.azure.keyvault.cryptography.FutureExecutionException; +import com.microsoft.azure.keyvault.cryptography.Strings; + +public class RsaKey implements IKey { + + class FutureDecrypt extends FutureBase { + + private final byte[] _data; + private final ICryptoTransform _transform; + + FutureDecrypt(ICryptoTransform transform, byte[] data) { + _data = data; + _transform = transform; + } + + @Override + public byte[] get() throws InterruptedException, ExecutionException { + try { + return _transform.doFinal(_data); + } catch (Exception e) { + throw new ExecutionException(e); + } + } + + @Override + public byte[] get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + try { + return _transform.doFinal(_data); + } catch (Exception e) { + throw new ExecutionException(e); + } + } + } + + class FutureEncrypt extends FutureBase> { + + private final String _algorithm; + private final byte[] _data; + private final ICryptoTransform _transform; + + FutureEncrypt(String algorithm, byte[] data, ICryptoTransform transform) { + _algorithm = algorithm; + _data = data; + _transform = transform; + } + + @Override + public Triple get() throws InterruptedException, ExecutionException { + try { + return Triple.of(_transform.doFinal(_data), (byte[]) null, _algorithm); + } catch (Exception e) { + throw new ExecutionException(e); + } + } + + @Override + public Triple get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + try { + return Triple.of(_transform.doFinal(_data), (byte[]) null, _algorithm); + } catch (Exception e) { + throw new ExecutionException(e); + } + } + } + + class FutureWrap extends FutureBase> { + + private final String _algorithm; + private final byte[] _data; + private final ICryptoTransform _transform; + + FutureWrap(String algorithm, byte[] data, ICryptoTransform transform) { + _algorithm = algorithm; + _data = data; + _transform = transform; + } + + @Override + public Pair get() throws InterruptedException, ExecutionException { + try { + return Pair.of(_transform.doFinal(_data), _algorithm); + } catch (Exception e) { + throw new ExecutionException(e); + } + } + + @Override + public Pair get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + try { + return Pair.of(_transform.doFinal(_data), _algorithm); + } catch (Exception e) { + throw new ExecutionException(e); + } + } + } + + public static int KeySize1024 = 1024; + public static int KeySize2048 = 2048; + + public static int getDefaultKeySize() { + return RsaKey.KeySize2048; + } + + private final String _kid; + private final KeyPair _keyPair; + + public RsaKey(String kid) throws NoSuchAlgorithmException { + this(kid, getDefaultKeySize()); + } + + public RsaKey(String kid, int keySize) throws NoSuchAlgorithmException { + + if (Strings.isNullOrWhiteSpace(kid)) { + throw new IllegalArgumentException("kid"); + } + + final KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); + + generator.initialize(keySize); + + _keyPair = generator.generateKeyPair(); + _kid = kid; + } + + public RsaKey(String kid, KeyPair keyPair) { + + if (Strings.isNullOrWhiteSpace(kid)) { + throw new IllegalArgumentException("kid"); + } + + if (keyPair == null) { + throw new IllegalArgumentException("kid"); + } + + if (keyPair.getPublic() == null || !(keyPair.getPublic() instanceof RSAPublicKey)) { + throw new IllegalArgumentException("keyPair"); + } + + _keyPair = keyPair; + _kid = kid; + } + + @Override + public String getDefaultEncryptionAlgorithm() { + return RsaOaep.AlgorithmName; + } + + @Override + public String getDefaultKeyWrapAlgorithm() { + return RsaOaep.AlgorithmName; + } + + @Override + public String getDefaultSignatureAlgorithm() { + // TODO: Signature Processing + return null; + } + + @Override + public String getKid() { + return _kid; + } + + @Override + public Future decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm) throws NoSuchAlgorithmException { + + if (ciphertext == null) { + throw new IllegalArgumentException("ciphertext"); + } + + // Interpret the requested algorithm + if (Strings.isNullOrWhiteSpace(algorithm)) { + throw new IllegalArgumentException("algorithm"); + } + + Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithm); + + if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricEncryptionAlgorithm)) { + throw new NoSuchAlgorithmException(algorithm); + } + + AsymmetricEncryptionAlgorithm algo = (AsymmetricEncryptionAlgorithm)baseAlgorithm; + + ICryptoTransform transform; + Future result; + + try { + transform = algo.CreateDecryptor(_keyPair); + result = new FutureDecrypt(transform, ciphertext); + } catch (Exception e) { + result = new FutureExecutionException(e); + } + + return result; + } + + @Override + public Future> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm) throws NoSuchAlgorithmException { + + if (plaintext == null) { + throw new IllegalArgumentException("plaintext"); + } + + // Interpret the requested algorithm + String algorithmName = (Strings.isNullOrWhiteSpace(algorithm) ? getDefaultEncryptionAlgorithm() : algorithm); + Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithmName); + + if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricEncryptionAlgorithm)) { + throw new NoSuchAlgorithmException(algorithmName); + } + + AsymmetricEncryptionAlgorithm algo = (AsymmetricEncryptionAlgorithm)baseAlgorithm; + + ICryptoTransform transform; + Future> result; + + try { + transform = algo.CreateEncryptor(_keyPair); + result = new FutureEncrypt(algorithmName, plaintext, transform); + } catch (Exception e) { + result = new FutureExecutionException>(e); + } + + return result; + } + + @Override + public Future> wrapKeyAsync(final byte[] key, final String algorithm) throws NoSuchAlgorithmException { + + if (key == null) { + throw new IllegalArgumentException("key"); + } + + // Interpret the requested algorithm + String algorithmName = (Strings.isNullOrWhiteSpace(algorithm) ? getDefaultKeyWrapAlgorithm() : algorithm); + Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithmName); + + if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricEncryptionAlgorithm)) { + throw new NoSuchAlgorithmException(algorithmName); + } + + AsymmetricEncryptionAlgorithm algo = (AsymmetricEncryptionAlgorithm)baseAlgorithm; + + ICryptoTransform transform; + Future> result; + + try { + transform = algo.CreateEncryptor(_keyPair); + result = new FutureWrap(algorithmName, key, transform); + } catch (Exception e) { + result = new FutureExecutionException>(e); + } + + return result; + } + + @Override + public Future unwrapKeyAsync(final byte[] encryptedKey, final String algorithm) throws NoSuchAlgorithmException { + + if (encryptedKey == null) { + throw new IllegalArgumentException("encryptedKey "); + } + + // Interpret the requested algorithm + if (Strings.isNullOrWhiteSpace(algorithm)) { + throw new IllegalArgumentException("algorithm"); + } + + // Interpret the requested algorithm + Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithm); + + if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricEncryptionAlgorithm)) { + throw new NoSuchAlgorithmException(algorithm); + } + + AsymmetricEncryptionAlgorithm algo = (AsymmetricEncryptionAlgorithm)baseAlgorithm; + + ICryptoTransform transform; + Future result; + + try { + transform = algo.CreateDecryptor(_keyPair); + result = new FutureDecrypt(transform, encryptedKey); + } catch (Exception e) { + result = new FutureExecutionException(e); + } + + return result; + } + + @Override + public Future> signAsync(final byte[] digest, final String algorithm) { + return null; + } + + @Override + public Future verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) { + return null; + } + + @Override + public void close() throws IOException { + // Intentionally empty + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java new file mode 100644 index 0000000000000..f0d8f2b953f88 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java @@ -0,0 +1,27 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +public abstract class SignatureAlgorithm extends Algorithm { + + protected SignatureAlgorithm(String name) { + super(name); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java new file mode 100644 index 0000000000000..c948e8e3453ab --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java @@ -0,0 +1,42 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +import com.microsoft.azure.keyvault.cryptography.Strings; + +public class Strings { + + public static boolean isNullOrEmpty(String arg) { + + if (arg == null || arg.isEmpty()) { + return true; + } + + return false; + } + + public static boolean isNullOrWhiteSpace(String arg) { + + if (Strings.isNullOrEmpty(arg) || arg.trim().isEmpty()) { + return true; + } + + return false; + } +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java new file mode 100644 index 0000000000000..4834485c31957 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java @@ -0,0 +1,42 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.NoSuchPaddingException; + +public abstract class SymmetricEncryptionAlgorithm extends EncryptionAlgorithm { + + protected SymmetricEncryptionAlgorithm(String name) { + super(name); + } + + public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + + public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + + public abstract ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + + public abstract ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java new file mode 100644 index 0000000000000..f8614de47de94 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java @@ -0,0 +1,349 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography; + +import java.io.IOException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; +import java.util.concurrent.Future; + +import org.apache.commons.lang3.tuple.Pair; +import org.apache.commons.lang3.tuple.Triple; + +import com.microsoft.azure.keyvault.core.IKey; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128CbcHmacSha256; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes192Cbc; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes192CbcHmacSha384; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes256CbcHmacSha512; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw128; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw192; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256; +import com.microsoft.azure.keyvault.cryptography.FutureExecutionException; +import com.microsoft.azure.keyvault.cryptography.FutureImmediate; +import com.microsoft.azure.keyvault.cryptography.Strings; + +public class SymmetricKey implements IKey { + + public static final int KeySize128 = 128 >> 3; + public static final int KeySize192 = 192 >> 3; + public static final int KeySize256 = 256 >> 3; + public static final int KeySize384 = 384 >> 3; + public static final int KeySize512 = 512 >> 3; + + private final String _kid; + private final byte[] _key; + private final Provider _provider; + + public SymmetricKey(String kid, byte[] keyBytes) { + this(kid, keyBytes, null); + } + + public SymmetricKey(String kid, byte[] keyBytes, Provider provider) { + + if (Strings.isNullOrWhiteSpace(kid)) { + throw new IllegalArgumentException("kid"); + } + + if (keyBytes == null) { + throw new IllegalArgumentException("keyBytes"); + } + + if (keyBytes.length != KeySize128 && keyBytes.length != KeySize192 && keyBytes.length != KeySize256 && keyBytes.length != KeySize384 && keyBytes.length != KeySize512) { + throw new IllegalArgumentException("The key material must be 128, 192, 256, 384 or 512 bits of data"); + } + + _kid = kid; + _key = keyBytes; + _provider = provider; + } + + @Override + public String getDefaultEncryptionAlgorithm() { + + switch (_key.length) { + case KeySize128: + return Aes128Cbc.AlgorithmName; + + case KeySize192: + return Aes192Cbc.AlgorithmName; + + case KeySize256: + return Aes128CbcHmacSha256.AlgorithmName; + + case KeySize384: + return Aes192CbcHmacSha384.AlgorithmName; + + case KeySize512: + return Aes256CbcHmacSha512.AlgorithmName; + } + + return null; + } + + @Override + public String getDefaultKeyWrapAlgorithm() { + + switch (_key.length) { + case KeySize128: + return AesKw128.AlgorithmName; + + case KeySize192: + return AesKw192.AlgorithmName; + + case KeySize256: + return AesKw256.AlgorithmName; + + case KeySize384: + // Default to longest allowed key length for wrap + return AesKw256.AlgorithmName; + + case KeySize512: + // Default to longest allowed key length for wrap + return AesKw256.AlgorithmName; + } + + return null; + } + + @Override + public String getDefaultSignatureAlgorithm() { + + return null; + } + + @Override + public String getKid() { + + return _kid; + } + + @Override + public Future decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm) throws NoSuchAlgorithmException { + + if (Strings.isNullOrWhiteSpace(algorithm)) { + throw new IllegalArgumentException("algorithm"); + } + + if (ciphertext == null) { + throw new IllegalArgumentException("ciphertext"); + } + + if (iv == null) { + throw new IllegalArgumentException("iv"); + } + + // Interpret the algorithm + Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithm); + + if (baseAlgorithm == null || !(baseAlgorithm instanceof SymmetricEncryptionAlgorithm)) { + throw new NoSuchAlgorithmException(algorithm); + } + + SymmetricEncryptionAlgorithm algo = (SymmetricEncryptionAlgorithm)baseAlgorithm; + + ICryptoTransform transform = null; + + try { + transform = algo.CreateDecryptor(_key, iv, authenticationData, _provider ); + } catch (Exception e) { + return new FutureExecutionException(e); + } + + byte[] result = null; + + try { + result = transform.doFinal(ciphertext); + } catch (Exception e) { + return new FutureExecutionException(e); + } + + if (transform instanceof IAuthenticatedCryptoTransform) { + + IAuthenticatedCryptoTransform authenticatedTransform = (IAuthenticatedCryptoTransform) transform; + + if (authenticationData == null || authenticationTag == null) { + throw new IllegalArgumentException("AuthenticatingCryptoTransform requires authenticationData and authenticationTag"); + } + + if (!sequenceEqualConstantTime(authenticationTag, authenticatedTransform.getTag())) { + throw new IllegalArgumentException("Data is not authentic"); + } + } + + return new FutureImmediate(result); + } + + @Override + public Future> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm) throws NoSuchAlgorithmException { + + if (plaintext == null) { + throw new IllegalArgumentException("plaintext"); + } + + if (iv == null) { + throw new IllegalArgumentException("iv"); + } + + // Interpret the algorithm + String algorithmName = (Strings.isNullOrWhiteSpace(algorithm)) ? getDefaultEncryptionAlgorithm() : algorithm; + Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithmName); + + if (baseAlgorithm == null || !(baseAlgorithm instanceof SymmetricEncryptionAlgorithm)) { + throw new NoSuchAlgorithmException(algorithm); + } + + SymmetricEncryptionAlgorithm algo = (SymmetricEncryptionAlgorithm)baseAlgorithm; + + ICryptoTransform transform = null; + + try { + transform = algo.CreateEncryptor(_key, iv, authenticationData, _provider); + } catch (Exception e) { + return new FutureExecutionException>(e); + } + + byte[] cipherText = null; + + try { + cipherText = transform.doFinal(plaintext); + } catch (Exception e) { + return new FutureExecutionException>(e); + } + + byte[] authenticationTag = null; + + if (transform instanceof IAuthenticatedCryptoTransform) { + + IAuthenticatedCryptoTransform authenticatedTransform = (IAuthenticatedCryptoTransform) transform; + + authenticationTag = authenticatedTransform.getTag().clone(); + } + + return new FutureImmediate>(Triple.of(cipherText, authenticationTag, algorithm)); + } + + @Override + public Future> wrapKeyAsync(final byte[] key, final String algorithm) throws NoSuchAlgorithmException { + + if (key == null || key.length == 0) { + throw new IllegalArgumentException("key"); + } + + // Interpret the algorithm + String algorithmName = (Strings.isNullOrWhiteSpace(algorithm)) ? getDefaultKeyWrapAlgorithm() : algorithm; + Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithmName); + + if (baseAlgorithm == null || !(baseAlgorithm instanceof KeyWrapAlgorithm)) { + throw new NoSuchAlgorithmException(algorithmName); + } + + KeyWrapAlgorithm algo = (KeyWrapAlgorithm)baseAlgorithm; + + ICryptoTransform transform = null; + + try { + transform = algo.CreateEncryptor(_key, null, _provider); + } catch (Exception e) { + return new FutureExecutionException>(e); + } + + byte[] encrypted = null; + + try { + encrypted = transform.doFinal(key); + } catch (Exception e) { + return new FutureExecutionException>(e); + } + + return new FutureImmediate>(Pair.of(encrypted, algorithmName)); + } + + @Override + public Future unwrapKeyAsync(final byte[] encryptedKey, final String algorithm) throws NoSuchAlgorithmException { + + if (Strings.isNullOrWhiteSpace(algorithm)) { + throw new IllegalArgumentException("algorithm"); + } + + if (encryptedKey == null || encryptedKey.length == 0) { + throw new IllegalArgumentException("wrappedKey"); + } + + Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithm); + + if (baseAlgorithm == null || !(baseAlgorithm instanceof KeyWrapAlgorithm)) { + throw new NoSuchAlgorithmException(algorithm); + } + + KeyWrapAlgorithm algo = (KeyWrapAlgorithm)baseAlgorithm; + + ICryptoTransform transform = null; + + try { + transform = algo.CreateDecryptor(_key, null, _provider); + } catch (Exception e) { + return new FutureExecutionException(e); + } + + byte[] decrypted = null; + + try { + decrypted = transform.doFinal(encryptedKey); + } catch (Exception e) { + return new FutureExecutionException(e); + } + + return new FutureImmediate(decrypted); + } + + @Override + public Future> signAsync(final byte[] digest, final String algorithm) { + return null; + } + + @Override + public Future verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) { + return null; + } + + @Override + public void close() throws IOException { + } + + public static boolean sequenceEqualConstantTime(byte[] self, byte[] other) { + if (self == null) { + throw new IllegalArgumentException("self"); + } + + if (other == null) { + throw new IllegalArgumentException("other"); + } + + // Constant time comparison of two byte arrays + long difference = (self.length & 0xffffffffl) ^ (other.length & 0xffffffffl); + + for (int i = 0; i < self.length && i < other.length; i++) { + difference |= (self[i] & 0xffffffffl) ^ (other[i] & 0xffffffffl); + } + + return difference == 0; + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java new file mode 100644 index 0000000000000..206a463d5b7ef --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java @@ -0,0 +1,29 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +public class Aes128Cbc extends AesCbc { + + public static final String AlgorithmName = "A128CBC"; + + public Aes128Cbc() { + super(AlgorithmName); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java new file mode 100644 index 0000000000000..eeb40fa3808b4 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java @@ -0,0 +1,28 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +public class Aes128CbcHmacSha256 extends AesCbcHmacSha2 { + + public static final String AlgorithmName = "A128CBC-HS256"; + + public Aes128CbcHmacSha256() { + super(AlgorithmName); + } +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java new file mode 100644 index 0000000000000..2cb0fc22b4d96 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java @@ -0,0 +1,29 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +public class Aes192Cbc extends AesCbc { + + public static final String AlgorithmName = "A192CBC"; + + public Aes192Cbc() { + super(AlgorithmName); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java new file mode 100644 index 0000000000000..0e0e6758558a8 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java @@ -0,0 +1,28 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +public class Aes192CbcHmacSha384 extends AesCbcHmacSha2 { + + public static final String AlgorithmName = "A192CBC-HS384"; + + public Aes192CbcHmacSha384() { + super(AlgorithmName); + } +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java new file mode 100644 index 0000000000000..91fb58e09c932 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java @@ -0,0 +1,29 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +public class Aes256Cbc extends AesCbc { + + public static final String AlgorithmName = "A256CBC"; + + public Aes256Cbc() { + super(AlgorithmName); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java new file mode 100644 index 0000000000000..495bc7bd69468 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java @@ -0,0 +1,28 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +public class Aes256CbcHmacSha512 extends AesCbcHmacSha2 { + + public static final String AlgorithmName = "A256CBC-HS512"; + + public Aes256CbcHmacSha512() { + super(AlgorithmName); + } +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java new file mode 100644 index 0000000000000..7c49fba06c6b2 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java @@ -0,0 +1,109 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; +import com.microsoft.azure.keyvault.cryptography.SymmetricEncryptionAlgorithm; + +public abstract class AesCbc extends SymmetricEncryptionAlgorithm { + + static class AesCbcDecryptor implements ICryptoTransform { + + private final Cipher _cipher; + + AesCbcDecryptor(byte[] key, byte[] iv, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { + + // Create the cipher using the Provider if specified + if (provider == null) { + _cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + } else { + _cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", provider); + } + + _cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key, "AES"), new IvParameterSpec(iv)); + } + + @Override + public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPaddingException { + return _cipher.doFinal(plaintext); + } + } + + static class AesCbcEncryptor implements ICryptoTransform { + + private final Cipher _cipher; + + AesCbcEncryptor(byte[] key, byte[] iv, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { + + // Create the cipher using the Provider if specified + if (provider == null) { + _cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); + } else { + _cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", provider); + } + + _cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"), new IvParameterSpec(iv)); + } + + @Override + public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPaddingException { + return _cipher.doFinal(plaintext); + } + } + + protected AesCbc(String name) { + super(name); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + return new AesCbcEncryptor(key, iv, null); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + return new AesCbcEncryptor(key, iv, provider); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + return new AesCbcDecryptor(key, iv, null); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + return new AesCbcDecryptor(key, iv, provider); + } +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java new file mode 100644 index 0000000000000..882a21284d616 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java @@ -0,0 +1,289 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import java.math.BigInteger; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.Mac; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.spec.SecretKeySpec; + +import org.apache.commons.lang3.tuple.Triple; + +import com.microsoft.azure.keyvault.cryptography.IAuthenticatedCryptoTransform; +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; +import com.microsoft.azure.keyvault.cryptography.SymmetricEncryptionAlgorithm; + +public abstract class AesCbcHmacSha2 extends SymmetricEncryptionAlgorithm { + + static class AesCbcHmacSha2Decryptor implements IAuthenticatedCryptoTransform { + + final byte[] _aad_length; + final Mac _hmac; + final byte[] _hmac_key; + final ICryptoTransform _inner; + + byte[] _tag; + + AesCbcHmacSha2Decryptor(String name, byte[] key, byte[] iv, byte[] associatedData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + // Split the key to get the AES key, the HMAC key and the HMAC + // object + Triple parameters = GetAlgorithmParameters(name, key); + + // Save the MAC provider and key + _hmac = parameters.getRight(); + _hmac_key = parameters.getMiddle(); + + // Create the AES provider + _inner = new AesCbc.AesCbcDecryptor(parameters.getLeft(), iv, provider); + + _aad_length = toBigEndian(associatedData.length * 8); + + // Prime the hash. + _hmac.update(associatedData); + _hmac.update(iv); + } + + @Override + public byte[] getTag() { + return _tag; + } + + // public int TransformBlock( byte[] inputBuffer, int inputOffset, int + // inputCount, byte[] outputBuffer, int outputOffset ) + // { + // // Add the cipher text to the running hash + // _hmac.TransformBlock( inputBuffer, inputOffset, inputCount, + // inputBuffer, inputOffset ); + // + // // Decrypt the cipher text + // return _inner.TransformBlock( inputBuffer, inputOffset, inputCount, + // outputBuffer, outputOffset ); + // } + + @Override + public byte[] doFinal(byte[] input) throws IllegalBlockSizeException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException { + + // Add the cipher text to the running hash + _hmac.update(input); + + // Add the associated_data_length bytes to the hash + byte[] hash = _hmac.doFinal(_aad_length); + + // Compute the tag + _tag = new byte[_hmac_key.length]; + System.arraycopy(hash, 0, _tag, 0, _hmac_key.length); + + return _inner.doFinal(input); + } + } + + static class AesCbcHmacSha2Encryptor implements IAuthenticatedCryptoTransform { + + final byte[] _aad_length; + final Mac _hmac; + final byte[] _hmac_key; + final ICryptoTransform _inner; + + byte[] _tag; + + AesCbcHmacSha2Encryptor(String name, byte[] key, byte[] iv, byte[] associatedData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + // Split the key to get the AES key, the HMAC key and the HMAC + // object + Triple parameters = GetAlgorithmParameters(name, key); + + // Save the MAC provider and key + _hmac = parameters.getRight(); + _hmac_key = parameters.getMiddle(); + + // Create the AES encryptor + _inner = new AesCbc.AesCbcEncryptor(parameters.getLeft(), iv, provider); + + _aad_length = toBigEndian(associatedData.length * 8); + + // Prime the hash. + _hmac.update(associatedData); + _hmac.update(iv); + } + + @Override + public byte[] getTag() { + return _tag; + } + + // public int TransformBlock( byte[] inputBuffer, int inputOffset, int + // inputCount, byte[] outputBuffer, int outputOffset ) + // { + // // Encrypt the block + // var result = _inner.TransformBlock( inputBuffer, inputOffset, + // inputCount, outputBuffer, outputOffset ); + // + // // Add it to the running hash + // _hmac.TransformBlock( outputBuffer, outputOffset, result, + // outputBuffer, outputOffset ); + // + // return result; + // } + + @Override + public byte[] doFinal(byte[] input) throws IllegalBlockSizeException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException { + + // Encrypt the block + byte[] output = _inner.doFinal(input); + + // Add the cipher text to the running hash + _hmac.update(output); + + // Add the associated_data_length bytes to the hash + byte[] hash = _hmac.doFinal(_aad_length); + + // Compute the tag + _tag = new byte[_hmac_key.length]; + System.arraycopy(hash, 0, _tag, 0, _tag.length); + + return output; + } + } + + protected AesCbcHmacSha2(String name) { + super(name); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + return CreateDecryptor(key, iv, authenticationData, null); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + if (key == null) { + throw new IllegalArgumentException("No key material"); + } + + if (iv == null) { + throw new IllegalArgumentException("No initialization vector"); + } + + if (authenticationData == null) { + throw new IllegalArgumentException("No associated data"); + } + + // Create the Decryptor + return new AesCbcHmacSha2Decryptor(getName(), key, iv, authenticationData, provider); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + return CreateEncryptor(key, iv, authenticationData, null); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null) { + throw new IllegalArgumentException("No key material"); + } + + if (iv == null) { + throw new IllegalArgumentException("No initialization vector"); + } + + if (authenticationData == null) { + throw new IllegalArgumentException("No associated data"); + } + + // Create the Encryptor + return new AesCbcHmacSha2Encryptor(getName(), key, iv, authenticationData, provider); + } + + private static Triple GetAlgorithmParameters(String algorithm, byte[] key) throws InvalidKeyException, NoSuchAlgorithmException { + + byte[] aes_key; + byte[] hmac_key; + Mac hmac; + + if (algorithm.equalsIgnoreCase(Aes128CbcHmacSha256.AlgorithmName)) { + if ((key.length << 3) < 256) { + throw new IllegalArgumentException(String.format("%s key length in bits %d < 256", algorithm, key.length << 3)); + } + + hmac_key = new byte[128 >> 3]; + aes_key = new byte[128 >> 3]; + + // The HMAC key precedes the AES key + System.arraycopy(key, 0, hmac_key, 0, 128 >> 3); + System.arraycopy(key, 128 >> 3, aes_key, 0, 128 >> 3); + + hmac = Mac.getInstance("HmacSHA256"); + hmac.init(new SecretKeySpec(hmac_key, "HmacSHA256")); + + } else if (algorithm.equalsIgnoreCase(Aes192CbcHmacSha384.AlgorithmName)) { + + if ((key.length << 3) < 384) { + throw new IllegalArgumentException(String.format("%s key length in bits %d < 384", algorithm, key.length << 3)); + } + + hmac_key = new byte[192 >> 3]; + aes_key = new byte[192 >> 3]; + + // The HMAC key precedes the AES key + System.arraycopy(key, 0, hmac_key, 0, 192 >> 3); + System.arraycopy(key, 192 >> 3, aes_key, 0, 192 >> 3); + + hmac = Mac.getInstance("HmacSHA384"); + hmac.init(new SecretKeySpec(hmac_key, "HmacSHA384")); + } else if (algorithm.equalsIgnoreCase(Aes256CbcHmacSha512.AlgorithmName)) { + + if ((key.length << 3) < 512) { + throw new IllegalArgumentException(String.format("%s key length in bits %d < 512", algorithm, key.length << 3)); + } + + hmac_key = new byte[256 >> 3]; + aes_key = new byte[256 >> 3]; + + // The HMAC key precedes the AES key + System.arraycopy(key, 0, hmac_key, 0, 256 >> 3); + System.arraycopy(key, 256 >> 3, aes_key, 0, 256 >> 3); + + hmac = Mac.getInstance("HmacSHA512"); + hmac.init(new SecretKeySpec(hmac_key, "HmacSHA512")); + } else { + throw new IllegalArgumentException(String.format("Unsupported algorithm: %s", algorithm)); + } + + return Triple.of(aes_key, hmac_key, hmac); + } + + static byte[] toBigEndian(long i) { + + byte[] shortRepresentation = BigInteger.valueOf(i).toByteArray(); + byte[] longRepresentation = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }; + + System.arraycopy(shortRepresentation, 0, longRepresentation, longRepresentation.length - shortRepresentation.length, shortRepresentation.length); + + return longRepresentation; + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java new file mode 100644 index 0000000000000..8f7fa07ae6f12 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java @@ -0,0 +1,192 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; +import com.microsoft.azure.keyvault.cryptography.KeyWrapAlgorithm; + +public abstract class AesKw extends KeyWrapAlgorithm { + + static final byte[] _defaultIv = new byte[] { (byte) 0xA6, (byte) 0xA6, (byte) 0xA6, (byte) 0xA6, (byte) 0xA6, (byte) 0xA6, (byte) 0xA6, (byte) 0xA6 }; + static final String _cipherName = "AESWrap"; + + class AesKwDecryptor implements ICryptoTransform { + + final Cipher _cipher; + + AesKwDecryptor(byte[] key, byte[] iv, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { + + if (provider == null) { + _cipher = Cipher.getInstance(_cipherName); + } else { + _cipher = Cipher.getInstance(_cipherName, provider); + } + + // The default provider does not support the specification of IV. This + // is guarded by the CreateEncrypter wrapper method and the iv parameter + // can be ignored when using the default provider + if (provider == null ) { + _cipher.init(Cipher.UNWRAP_MODE, new SecretKeySpec(key, "AES")); + } else { + _cipher.init(Cipher.UNWRAP_MODE, new SecretKeySpec(key, "AES"), new IvParameterSpec(iv)); + } + } + + @Override + public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException { + + return _cipher.unwrap(plaintext, "AESWrap", Cipher.SECRET_KEY).getEncoded(); + } + + } + + class AesKwEncryptor implements ICryptoTransform { + + final Cipher _cipher; + + AesKwEncryptor(byte[] key, byte[] iv, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { + + if (provider == null) { + _cipher = Cipher.getInstance(_cipherName); + } else { + _cipher = Cipher.getInstance(_cipherName, provider); + } + + // The default provider does not support the specification of IV. This + // is guarded by the CreateEncrypter wrapper method and the iv parameter + // can be ignored when using the default provider + if (provider == null ) { + _cipher.init(Cipher.WRAP_MODE, new SecretKeySpec(key, "AES")); + } else { + _cipher.init(Cipher.WRAP_MODE, new SecretKeySpec(key, "AES"), new IvParameterSpec(iv)); + } + } + + @Override + public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPaddingException, InvalidKeyException { + + return _cipher.wrap(new SecretKeySpec(plaintext, "AES")); + } + + } + + protected AesKw(String name) { + super(name); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { + + return CreateEncryptor(key, null, null); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { + + return CreateEncryptor(key, null, provider); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { + + return CreateEncryptor(key, iv, null); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { + + if (key == null) { + throw new IllegalArgumentException("key"); + } + + if (key.length != 128 >> 3 && key.length != 192 >> 3 && key.length != 256 >> 3) { + throw new IllegalArgumentException("key length must be 128, 192 or 256 bits"); + } + + if (iv != null ) { + // iv length must be 64 bits + if ( iv.length != 8) { + throw new IllegalArgumentException("iv length must be 64 bits"); + } + // iv cannot be specified with the default provider + if (provider == null) { + throw new IllegalArgumentException("user specified iv is not supported with the default provider"); + } + } + + return new AesKwEncryptor(key, iv == null ? _defaultIv : iv, provider); + + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { + + return CreateDecryptor(key, null, null); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { + + return CreateDecryptor(key, null, provider); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { + return CreateDecryptor(key, iv, null); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { + + if (key == null) { + throw new IllegalArgumentException("key"); + } + + if (key.length != 128 >> 3 && key.length != 192 >> 3 && key.length != 256 >> 3) { + throw new IllegalArgumentException("key length must be 128, 192 or 256 bits"); + } + + + if (iv != null ) { + // iv length must be 64 bits + if ( iv.length != 8) { + throw new IllegalArgumentException("iv length must be 64 bits"); + } + // iv cannot be specified with the default provider + if (provider == null) { + throw new IllegalArgumentException("user specified iv is not supported with the default provider"); + } + } + + return new AesKwDecryptor(key, iv == null ? _defaultIv : iv, provider); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java new file mode 100644 index 0000000000000..5d7a15605aea6 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java @@ -0,0 +1,65 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; + +public final class AesKw128 extends AesKw { + + public static final String AlgorithmName = "A128KW"; + + public AesKw128() { + super(AlgorithmName); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null) { + throw new IllegalArgumentException("key must not be null"); + } + + if (key.length << 3 != 128) { + throw new IllegalArgumentException("key must be 128 bits long"); + } + + return super.CreateEncryptor(key, iv); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null) { + throw new IllegalArgumentException("key must not be null"); + } + + if (key.length << 3 != 128) { + throw new IllegalArgumentException("key must be 128 bits long"); + } + + return super.CreateDecryptor(key, iv); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java new file mode 100644 index 0000000000000..f20f5ec7ee22c --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java @@ -0,0 +1,65 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; + +public final class AesKw192 extends AesKw { + + public static final String AlgorithmName = "A192KW"; + + public AesKw192() { + super(AlgorithmName); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null) { + throw new IllegalArgumentException("key must not be null"); + } + + if (key.length << 3 != 192) { + throw new IllegalArgumentException("key must be 192 bits long"); + } + + return super.CreateEncryptor(key, iv); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null) { + throw new IllegalArgumentException("key must not be null"); + } + + if (key.length << 3 != 192) { + throw new IllegalArgumentException("key must be 192 bits long"); + } + + return super.CreateDecryptor(key, iv); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java new file mode 100644 index 0000000000000..c4b23a572c222 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java @@ -0,0 +1,65 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; + +public final class AesKw256 extends AesKw { + + public static final String AlgorithmName = "A256KW"; + + public AesKw256() { + super(AlgorithmName); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null) { + throw new IllegalArgumentException("key must not be null"); + } + + if (key.length << 3 != 256) { + throw new IllegalArgumentException("key must be 256 bits long"); + } + + return super.CreateEncryptor(key, iv); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null) { + throw new IllegalArgumentException("key must not be null"); + } + + if (key.length << 3 != 256) { + throw new IllegalArgumentException("key must be 256 bits long"); + } + + return super.CreateDecryptor(key, iv); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java new file mode 100644 index 0000000000000..8161095756f88 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java @@ -0,0 +1,113 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import java.security.InvalidKeyException; +import java.security.KeyPair; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; + +public final class Rsa15 extends RsaEncryption { + + class Rsa15Decryptor implements ICryptoTransform { + + private final Cipher _cipher; + + Rsa15Decryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + + // Create a cipher object using the provider, if specified + if (provider == null) { + _cipher = Cipher.getInstance(RSA15); + } else { + _cipher = Cipher.getInstance(RSA15, provider); + } + + // encrypt the plain text using the public key + _cipher.init(Cipher.DECRYPT_MODE, keyPair.getPrivate()); + } + + @Override + public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPaddingException { + + return _cipher.doFinal(plaintext); + } + + } + + class Rsa15Encryptor implements ICryptoTransform { + + private final Cipher _cipher; + + Rsa15Encryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + + // Create a cipher object using the provider, if specified + if (provider == null) { + _cipher = Cipher.getInstance(RSA15); + } else { + _cipher = Cipher.getInstance(RSA15, provider); + } + + // encrypt the plain text using the public key + _cipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic()); + } + + @Override + public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPaddingException { + + return _cipher.doFinal(plaintext); + } + + } + + final static String RSA15 = "RSA/ECB/PKCS1Padding"; + + public final static String AlgorithmName = "RSA1_5"; + + public Rsa15() { + super(AlgorithmName); + } + + @Override + public ICryptoTransform CreateEncryptor(KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + return CreateEncryptor(keyPair, null); + } + + @Override + public ICryptoTransform CreateEncryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + return new Rsa15Encryptor(keyPair, provider); + } + + @Override + public ICryptoTransform CreateDecryptor(KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + return CreateDecryptor(keyPair, null); + } + + @Override + public ICryptoTransform CreateDecryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + return new Rsa15Decryptor(keyPair, provider); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java new file mode 100644 index 0000000000000..dd673f61ab416 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java @@ -0,0 +1,29 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import com.microsoft.azure.keyvault.cryptography.AsymmetricEncryptionAlgorithm; + +public abstract class RsaEncryption extends AsymmetricEncryptionAlgorithm { + + protected RsaEncryption(String name) { + super(name); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java new file mode 100644 index 0000000000000..424778e85f261 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java @@ -0,0 +1,115 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import java.security.InvalidKeyException; +import java.security.KeyPair; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; + +public final class RsaOaep extends RsaEncryption { + + class RsaOaepDecryptor implements ICryptoTransform { + + private final Cipher _cipher; + + RsaOaepDecryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + + // Create a cipher object using the provider, if specified + if (provider == null) { + _cipher = Cipher.getInstance(RSAOAEP); + } else { + _cipher = Cipher.getInstance(RSAOAEP, provider); + } + + // encrypt the plain text using the public key + _cipher.init(Cipher.DECRYPT_MODE, keyPair.getPrivate()); + } + + @Override + public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPaddingException { + + return _cipher.doFinal(plaintext); + } + + } + + class RsaOaepEncryptor implements ICryptoTransform { + + private final Cipher _cipher; + + RsaOaepEncryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + + // Create a cipher object using the provider, if specified + if (provider == null) { + _cipher = Cipher.getInstance(RSAOAEP); + } else { + _cipher = Cipher.getInstance(RSAOAEP, provider); + } + + // encrypt the plain text using the public key + _cipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic()); + } + + @Override + public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPaddingException { + + return _cipher.doFinal(plaintext); + } + + } + + final static String RSAOAEP = "RSA/ECB/OAEPWithSHA1AndMGF1Padding"; + + public final static String AlgorithmName = "RSA-OAEP"; + + public RsaOaep() { + super(AlgorithmName); + } + + @Override + public ICryptoTransform CreateEncryptor(KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + return CreateEncryptor(keyPair, null); + } + + @Override + public ICryptoTransform CreateEncryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + + return new RsaOaepEncryptor(keyPair, provider); + } + + @Override + public ICryptoTransform CreateDecryptor(KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + return CreateDecryptor(keyPair, null); + } + + @Override + public ICryptoTransform CreateDecryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { + + return new RsaOaepDecryptor(keyPair, provider); + } + +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html new file mode 100644 index 0000000000000..102a782ab4a86 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html @@ -0,0 +1,5 @@ + + +This package contains the Azure Key Vault Extension Cryptographic algorithm classes. + + diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html new file mode 100644 index 0000000000000..12edd05fd0bac --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html @@ -0,0 +1,5 @@ + + +This package contains the Azure Key Vault Extension classes. + + diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java new file mode 100644 index 0000000000000..c7d9c96b36702 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java @@ -0,0 +1,132 @@ +package com.microsoft.azure.keyvault.cryptography.test; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.fail; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; + +public class AesCbcBCProviderTest { + + private Provider _provider = null; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + try { + _provider = (Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance(); + } catch (ClassNotFoundException ex) { + throw new RuntimeException(ex.getMessage()); + } catch (IllegalAccessException ex) { + throw new RuntimeException(ex.getMessage()); + } catch (InstantiationException ex) { + throw new RuntimeException(ex.getMessage()); + } + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testAes128Cbc() { + // Arrange: These values are taken from Appendix B of the JWE + // specification at + // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B + // Since the values were intended for use with AES128-CBC-HMAC-SHA2 we + // actually take the realCEK from the second half of the CEK data below + // in order + // that the encrypted result will match the ED value from the example. + byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; + byte[] PLAIN = { 76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, 112, 114, 111, 115, 112, 101, 114, 46 }; + byte[] IV = { 3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101 }; + //byte[] AUTH = { 101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52, 83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66, 77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73, 110, 48 }; + byte[] ED = { 40, 57, 83, (byte) 181, 119, 33, (byte) 133, (byte) 148, (byte) 198, (byte) 185, (byte) 243, 24, (byte) 152, (byte) 230, 6, 75, (byte) 129, (byte) 223, 127, 19, (byte) 210, 82, (byte) 183, (byte) 230, (byte) 168, 33, (byte) 215, 104, (byte) 143, 112, 56, 102 }; + //byte[] TAG = { 83, 73, (byte) 191, 98, 104, (byte) 205, (byte) 211, (byte) 128, (byte) 201, (byte) 189, (byte) 199, (byte) 133, 32, 38, (byte) 194, 85 }; + + Aes128Cbc algo = new Aes128Cbc(); + byte[] realCEK = new byte[128 >> 3]; + byte[] encrypted = null; + + // Take the second half of CEK as the AES key + System.arraycopy(CEK, 128 >> 3, realCEK, 0, 128 >> 3); + + ICryptoTransform encryptor = null; + try { + encryptor = algo.CreateEncryptor(realCEK, IV, null, _provider); + } catch (InvalidKeyException e1) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e1) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e1) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e1) { + fail("InvalidAlgorithmParameterException"); + } + + try { + encrypted = encryptor.doFinal(PLAIN); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + ICryptoTransform decryptor = null; + try { + decryptor = algo.CreateDecryptor(realCEK, IV, null, _provider); + } catch (InvalidKeyException e1) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e1) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e1) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e1) { + fail("InvalidAlgorithmParameterException"); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(encrypted); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(PLAIN, decrypted); + assertArrayEquals(ED, encrypted); + } +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java new file mode 100644 index 0000000000000..947ef7cddfc74 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java @@ -0,0 +1,120 @@ +package com.microsoft.azure.keyvault.cryptography.test; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.fail; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; + +public class AesCbcDefaultProviderTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testAes128Cbc() { + // Arrange: These values are taken from Appendix B of the JWE + // specification at + // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B + // Since the values were intended for use with AES128-CBC-HMAC-SHA2 we + // actually take the realCEK from the second half of the CEK data below + // in order + // that the encrypted result will match the ED value from the example. + byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; + byte[] PLAIN = { 76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, 112, 114, 111, 115, 112, 101, 114, 46 }; + byte[] IV = { 3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101 }; + //byte[] AUTH = { 101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52, 83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66, 77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73, 110, 48 }; + byte[] ED = { 40, 57, 83, (byte) 181, 119, 33, (byte) 133, (byte) 148, (byte) 198, (byte) 185, (byte) 243, 24, (byte) 152, (byte) 230, 6, 75, (byte) 129, (byte) 223, 127, 19, (byte) 210, 82, (byte) 183, (byte) 230, (byte) 168, 33, (byte) 215, 104, (byte) 143, 112, 56, 102 }; + //byte[] TAG = { 83, 73, (byte) 191, 98, 104, (byte) 205, (byte) 211, (byte) 128, (byte) 201, (byte) 189, (byte) 199, (byte) 133, 32, 38, (byte) 194, 85 }; + + Aes128Cbc algo = new Aes128Cbc(); + byte[] realCEK = new byte[128 >> 3]; + byte[] encrypted = null; + + // Take the second half of CEK as the AES key + System.arraycopy(CEK, 128 >> 3, realCEK, 0, 128 >> 3); + + ICryptoTransform encryptor = null; + try { + encryptor = algo.CreateEncryptor(realCEK, IV, null); + } catch (InvalidKeyException e1) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e1) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e1) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e1) { + fail("InvalidAlgorithmParameterException"); + } + + try { + encrypted = encryptor.doFinal(PLAIN); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + ICryptoTransform decryptor = null; + try { + decryptor = algo.CreateDecryptor(realCEK, IV, null); + } catch (InvalidKeyException e1) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e1) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e1) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e1) { + fail("InvalidAlgorithmParameterException"); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(encrypted); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(PLAIN, decrypted); + assertArrayEquals(ED, encrypted); + } +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java new file mode 100644 index 0000000000000..211f3116bd0bc --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java @@ -0,0 +1,121 @@ +package com.microsoft.azure.keyvault.cryptography.test; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.fail; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; + +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.azure.keyvault.cryptography.IAuthenticatedCryptoTransform; +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128CbcHmacSha256; + +public class AesCbcHmacShaTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testAes128CbcHmacSha256() { + // Arrange: These values are taken from Appendix B of the JWE + // specification at + // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B + byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; + byte[] PLAIN = { 76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, 112, 114, 111, 115, 112, 101, 114, 46 }; + byte[] IV = { 3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101 }; + byte[] AUTH = { 101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52, 83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66, 77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73, 110, 48 }; + byte[] ED = { 40, 57, 83, (byte) 181, 119, 33, (byte) 133, (byte) 148, (byte) 198, (byte) 185, (byte) 243, 24, (byte) 152, (byte) 230, 6, 75, (byte) 129, (byte) 223, 127, 19, (byte) 210, 82, (byte) 183, (byte) 230, (byte) 168, 33, (byte) 215, 104, (byte) 143, 112, 56, 102 }; + byte[] TAG = { 83, 73, (byte) 191, 98, 104, (byte) 205, (byte) 211, (byte) 128, (byte) 201, (byte) 189, (byte) 199, (byte) 133, 32, 38, (byte) 194, 85 }; + + Aes128CbcHmacSha256 algo = new Aes128CbcHmacSha256(); + + IAuthenticatedCryptoTransform transform = null; + + byte[] encrypted = null; + byte[] tag = null; + + try { + transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(CEK, IV, AUTH); + } catch (InvalidKeyException e1) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e1) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e1) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e1) { + fail("InvalidAlgorithmParameterException"); + } + + try { + encrypted = transform.doFinal(PLAIN); + tag = transform.getTag(); + + assertArrayEquals(ED, encrypted); + assertArrayEquals(TAG, tag); + + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + ICryptoTransform decryptor = null; + try { + decryptor = algo.CreateDecryptor(CEK, IV, AUTH); + } catch (InvalidKeyException e1) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e1) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e1) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e1) { + fail("InvalidAlgorithmParameterException"); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(encrypted); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(PLAIN, decrypted); + } + +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java new file mode 100644 index 0000000000000..e1e7ce50c53f7 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java @@ -0,0 +1,289 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.fail; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw128; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw192; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256; + +public class AesKwBCProviderTest { + + private Provider _provider = null; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + try { + _provider = (Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance(); + } catch (ClassNotFoundException ex) { + throw new RuntimeException(ex.getMessage()); + } catch (IllegalAccessException ex) { + throw new RuntimeException(ex.getMessage()); + } catch (InstantiationException ex) { + throw new RuntimeException(ex.getMessage()); + } + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void KeyVault_AesKw128() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; + + AesKw kw = new AesKw128(); + + ICryptoTransform encryptor = null; + + try { + encryptor = kw.CreateEncryptor(KEK, _provider); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e) { + fail("InvalidAlgorithmParameterException"); + } + + byte[] encrypted = null; + + try { + encrypted = encryptor.doFinal(CEK); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + + ICryptoTransform decryptor = null; + + try { + decryptor = kw.CreateDecryptor(KEK, _provider); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e) { + fail("InvalidAlgorithmParameterException"); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(EK); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + @Test + public void KeyVault_AesKw192() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + AesKw kw = new AesKw192(); + + ICryptoTransform encryptor = null; + + try { + encryptor = kw.CreateEncryptor(KEK, _provider); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e) { + fail("InvalidAlgorithmParameterException"); + } + + byte[] encrypted = null; + + try { + encrypted = encryptor.doFinal(CEK); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + + ICryptoTransform decryptor = null; + + try { + decryptor = kw.CreateDecryptor(KEK, _provider); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e) { + fail("InvalidAlgorithmParameterException"); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(EK); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + @Test + public void KeyVault_AesKw256() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + + AesKw kw = new AesKw256(); + + ICryptoTransform encryptor = null; + + try { + encryptor = kw.CreateEncryptor(KEK, _provider); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e) { + fail("InvalidAlgorithmParameterException"); + } + + byte[] encrypted = null; + + try { + encrypted = encryptor.doFinal(CEK); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + + ICryptoTransform decryptor = null; + + try { + decryptor = kw.CreateDecryptor(KEK, _provider); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e) { + fail("InvalidAlgorithmParameterException"); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(EK); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java new file mode 100644 index 0000000000000..a9b4495e9313a --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java @@ -0,0 +1,316 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.fail; + +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw128; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw192; +import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256; + +public class AesKwDefaultProviderTest { + + private static boolean hasUnlimitedCrypto() { + try { + return Cipher.getMaxAllowedKeyLength("RC5") >= 256; + } catch (NoSuchAlgorithmException e) { + return false; + } + } + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + // Always null for the default provider + private Provider _provider = null; + + @Test + public void KeyVault_AesKw128() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; + + AesKw kw = new AesKw128(); + + ICryptoTransform encryptor = null; + + try { + encryptor = kw.CreateEncryptor(KEK, _provider); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e) { + fail("InvalidAlgorithmParameterException"); + } + + byte[] encrypted = null; + + try { + encrypted = encryptor.doFinal(CEK); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + + ICryptoTransform decryptor = null; + + try { + decryptor = kw.CreateDecryptor(KEK, _provider); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e) { + fail("InvalidAlgorithmParameterException"); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(EK); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + @Test + public void KeyVault_AesKw192() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + AesKw kw = new AesKw192(); + + ICryptoTransform encryptor = null; + + try { + encryptor = kw.CreateEncryptor(KEK); + + if (!unlimited) fail("Expected InvalidKeyException"); + } catch (InvalidKeyException e) { + if (unlimited) fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e) { + fail("InvalidAlgorithmParameterException"); + } + + if (unlimited) { + byte[] encrypted = null; + + try { + encrypted = encryptor.doFinal(CEK); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + + ICryptoTransform decryptor = null; + + try { + decryptor = kw.CreateDecryptor(KEK); + if (!unlimited) fail("Expected InvalidKeyException"); + } catch (InvalidKeyException e) { + if (unlimited) fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e) { + fail("InvalidAlgorithmParameterException"); + } + + if (unlimited) { + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(EK); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + } + + @Test + public void KeyVault_AesKw256() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + AesKw kw = new AesKw256(); + + ICryptoTransform encryptor = null; + + try { + encryptor = kw.CreateEncryptor(KEK); + if (!unlimited) fail("Expected InvalidKeyException"); + } catch (InvalidKeyException e) { + if (unlimited) fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e) { + fail("InvalidAlgorithmParameterException"); + } + + if (unlimited) { + byte[] encrypted = null; + + try { + encrypted = encryptor.doFinal(CEK); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + + ICryptoTransform decryptor = null; + + try { + decryptor = kw.CreateDecryptor(KEK); + + if (!unlimited) fail("Expected InvalidKeyException"); + } catch (InvalidKeyException e) { + if (unlimited) fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } catch (NoSuchPaddingException e) { + fail("NoSuchPaddingException"); + } catch (InvalidAlgorithmParameterException e) { + fail("InvalidAlgorithmParameterException"); + } + + if (unlimited) { + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(EK); + } catch (IllegalBlockSizeException e) { + fail("IllegalBlockSizeException"); + } catch (BadPaddingException e) { + fail("BadPaddingException"); + } catch (InvalidKeyException e) { + fail("InvalidKeyException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + } + +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java new file mode 100644 index 0000000000000..e41ceaa460ab6 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -0,0 +1,204 @@ +package com.microsoft.azure.keyvault.cryptography.test; + +import static org.junit.Assert.*; + +import java.math.BigInteger; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.spec.KeySpec; +import java.security.spec.RSAPrivateCrtKeySpec; +import java.security.spec.RSAPublicKeySpec; +import java.util.concurrent.Future; + +import org.apache.commons.lang3.tuple.Pair; +import org.apache.commons.lang3.tuple.Triple; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.azure.keyvault.cryptography.RsaKey; +import com.microsoft.azure.keyvault.cryptography.algorithms.Rsa15; +import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; + +public class RsaKeyTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEncryptDecryptRsa15() throws Exception { + + KeyPair keyPair = getTestKeyMaterial(); + RsaKey key = new RsaKey("foo", keyPair); + byte[] plaintext = "plaintext".getBytes(); + + // Encrypt the plaintext + Triple result = key.encryptAsync(plaintext, null, null, Rsa15.AlgorithmName).get(); + + byte[] ciphertext = result.getLeft(); + + assertEquals(Rsa15.AlgorithmName, result.getRight()); + + // Decrypt the ciphertext + Future decryptResult = key.decryptAsync(ciphertext, null, null, null, result.getRight()); + byte[] decrypted = decryptResult.get(); + + key.close(); + + assertArrayEquals(plaintext, decrypted); + } + + @Test + public void testEncryptDecryptRsaOaep() throws Exception { + + KeyPair keyPair = getTestKeyMaterial(); + RsaKey key = new RsaKey("foo", keyPair); + byte[] plaintext = "plaintext".getBytes(); + + // Encrypt the plaintext + Triple result = key.encryptAsync(plaintext, null, null, RsaOaep.AlgorithmName).get(); + + byte[] ciphertext = result.getLeft(); + + assertEquals(RsaOaep.AlgorithmName, result.getRight()); + + // Decrypt the ciphertext + Future decryptResult = key.decryptAsync(ciphertext, null, null, null, result.getRight()); + byte[] decrypted = decryptResult.get(); + + key.close(); + + assertArrayEquals(plaintext, decrypted); + } + + @Test + public void testWrapUnwrapRsa15() throws Exception { + + KeyPair keyPair = getTestKeyMaterial(); + RsaKey key = new RsaKey("foo", keyPair); + byte[] plaintext = "plaintext".getBytes(); + + // Encrypt the plaintext + Pair result = key.wrapKeyAsync(plaintext, Rsa15.AlgorithmName).get(); + + byte[] ciphertext = result.getLeft(); + + assertEquals(Rsa15.AlgorithmName, result.getRight()); + + // Decrypt the ciphertext + Future decryptResult = key.unwrapKeyAsync(ciphertext, result.getRight()); + byte[] decrypted = decryptResult.get(); + + key.close(); + + assertArrayEquals(plaintext, decrypted); + } + + @Test + public void testWrapUnwrapRsaOaep() throws Exception { + + KeyPair keyPair = getTestKeyMaterial(); + RsaKey key = new RsaKey("foo", keyPair); + byte[] plaintext = "plaintext".getBytes(); + + // Encrypt the plaintext + Pair result = key.wrapKeyAsync(plaintext, RsaOaep.AlgorithmName).get(); + + byte[] ciphertext = result.getLeft(); + + assertEquals(RsaOaep.AlgorithmName, result.getRight()); + + // Decrypt the ciphertext + Future decryptResult = key.unwrapKeyAsync(ciphertext, result.getRight()); + byte[] decrypted = decryptResult.get(); + + key.close(); + + assertArrayEquals(plaintext, decrypted); + } + + @Test + public void testEncryptDecryptDefaultAlgorithm() throws Exception { + + KeyPair keyPair = getTestKeyMaterial(); + RsaKey key = new RsaKey("foo", keyPair); + byte[] plaintext = "plaintext".getBytes(); + + // Encrypt the plaintext + Triple result = key.encryptAsync(plaintext, null, null, null).get(); + + byte[] ciphertext = result.getLeft(); + + assertEquals(RsaOaep.AlgorithmName, result.getRight()); + + // Decrypt the ciphertext + Future decryptResult = key.decryptAsync(ciphertext, null, null, null, result.getRight()); + byte[] decrypted = decryptResult.get(); + + key.close(); + + assertArrayEquals(plaintext, decrypted); + } + + @Test + public void testWrapUnwrapDefaultAlgorithm() throws Exception { + + KeyPair keyPair = getTestKeyMaterial(); + RsaKey key = new RsaKey("foo", keyPair); + byte[] plaintext = "plaintext".getBytes(); + + // Encrypt the plaintext + Pair result = key.wrapKeyAsync(plaintext, null).get(); + + byte[] ciphertext = result.getLeft(); + + assertEquals(RsaOaep.AlgorithmName, result.getRight()); + + // Decrypt the ciphertext + Future decryptResult = key.unwrapKeyAsync(ciphertext, result.getRight()); + byte[] decrypted = decryptResult.get(); + + key.close(); + + assertArrayEquals(plaintext, decrypted); + } + + private static KeyPair getTestKeyMaterial() throws Exception { + + return getWellKnownKey(); + } + + private static KeyPair getWellKnownKey() throws Exception { + BigInteger modulus = new BigInteger("27266783713040163753473734334021230592631652450892850648620119914958066181400432364213298181846462385257448168605902438305568194683691563208578540343969522651422088760509452879461613852042845039552547834002168737350264189810815735922734447830725099163869215360401162450008673869707774119785881115044406101346450911054819448375712432746968301739007624952483347278954755460152795801894283389540036131881712321193750961817346255102052653789197325341350920441746054233522546543768770643593655942246891652634114922277138937273034902434321431672058220631825053788262810480543541597284376261438324665363067125951152574540779"); + BigInteger publicExponent = new BigInteger("65537"); + BigInteger privateExponent = new BigInteger("10466613941269075477152428927796086150095892102279802916937552172064636326433780566497000814207416485739683286961848843255766652023400959086290344987308562817062506476465756840999981989957456897020361717197805192876094362315496459535960304928171129585813477132331538577519084006595335055487028872410579127692209642938724850603554885478763205394868103298473476811627231543504190652483290944218004086457805431824328448422034887148115990501701345535825110962804471270499590234116100216841170344686381902328362376624405803648588830575558058257742073963036264273582756620469659464278207233345784355220317478103481872995809"); + BigInteger primeP = new BigInteger("175002941104568842715096339107566771592009112128184231961529953978142750732317724951747797764638217287618769007295505214923187971350518217670604044004381362495186864051394404165602744235299100790551775147322153206730562450301874236875459336154569893255570576967036237661594595803204808064127845257496057219227"); + BigInteger primeQ = new BigInteger("155807574095269324897144428622185380283967159190626345335083690114147315509962698765044950001909553861571493035240542031420213144237033208612132704562174772894369053916729901982420535940939821673277140180113593951522522222348910536202664252481405241042414183668723338300649954708432681241621374644926879028977"); + BigInteger primeExponentP = new BigInteger("79745606804504995938838168837578376593737280079895233277372027184693457251170125851946171360348440134236338520742068873132216695552312068793428432338173016914968041076503997528137698610601222912385953171485249299873377130717231063522112968474603281996190849604705284061306758152904594168593526874435238915345"); + BigInteger primeExponentQ = new BigInteger("80619964983821018303966686284189517841976445905569830731617605558094658227540855971763115484608005874540349730961777634427740786642996065386667564038755340092176159839025706183161615488856833433976243963682074011475658804676349317075370362785860401437192843468423594688700132964854367053490737073471709030801"); + BigInteger crtCoefficient = new BigInteger("2157818511040667226980891229484210846757728661751992467240662009652654684725325675037512595031058612950802328971801913498711880111052682274056041470625863586779333188842602381844572406517251106159327934511268610438516820278066686225397795046020275055545005189953702783748235257613991379770525910232674719428"); + + KeySpec publicKeySpec = new RSAPublicKeySpec(modulus, publicExponent); + KeySpec privateKeySpec = new RSAPrivateCrtKeySpec(modulus, publicExponent, privateExponent, primeP, primeQ, primeExponentP, primeExponentQ, crtCoefficient); + KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + + return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); + } + +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java new file mode 100644 index 0000000000000..ba86f68eeff90 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java @@ -0,0 +1,354 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; +import java.util.concurrent.ExecutionException; + +import org.apache.commons.lang3.tuple.Pair; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.azure.keyvault.cryptography.SymmetricKey; + +public class SymmetricKeyBCProviderTest { + + private Provider _provider = null; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + try { + _provider = (Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance(); + } catch (ClassNotFoundException ex) { + throw new RuntimeException(ex.getMessage()); + } catch (IllegalAccessException ex) { + throw new RuntimeException(ex.getMessage()); + } catch (InstantiationException ex) { + throw new RuntimeException(ex.getMessage()); + } + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSymmetricKeyAesKw128() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; + + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A128KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyAesKw192() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A192KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyAesKw256() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A256KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyDefaultAlgorithmAesKw128() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; + + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + String algorithm = null; + + try { + Pair result = key.wrapKeyAsync(CEK, null).get(); + encrypted = result.getLeft(); + algorithm = result.getRight(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertEquals("A128KW", algorithm); + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, algorithm).get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyDefaultAlgorithmAesKw192() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + String algorithm = null; + + try { + Pair result = key.wrapKeyAsync(CEK, null).get(); + encrypted = result.getLeft(); + algorithm = result.getRight(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertEquals( "A192KW", algorithm); + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, algorithm).get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyDefaultAlgorithmAesKw256() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + String algorithm = null; + + try { + Pair result = key.wrapKeyAsync(CEK, null).get(); + encrypted = result.getLeft(); + algorithm = result.getRight(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertEquals("A256KW", algorithm); + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, algorithm).get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java new file mode 100644 index 0000000000000..9365b416988e3 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java @@ -0,0 +1,424 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.concurrent.ExecutionException; + +import javax.crypto.Cipher; + +import org.apache.commons.lang3.tuple.Pair; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.azure.keyvault.cryptography.SymmetricKey; + +public class SymmetricKeyDefaultProviderTest { + + private static boolean hasUnlimitedCrypto() { + try { + return Cipher.getMaxAllowedKeyLength("RC5") >= 256; + } catch (NoSuchAlgorithmException e) { + return false; + } + } + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testSymmetricKeyAesKw128() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; + + SymmetricKey key = new SymmetricKey("KEK", KEK); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A128KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyAesKw192() { + + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A192KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyAesKw256() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A256KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyDefaultAlgorithmAesKw128() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; + + SymmetricKey key = new SymmetricKey("KEK", KEK); + + byte[] encrypted = null; + String algorithm = null; + + try { + Pair result = key.wrapKeyAsync(CEK, null).get(); + encrypted = result.getLeft(); + algorithm = result.getRight(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertEquals("A128KW", algorithm); + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, algorithm).get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyDefaultAlgorithmAesKw192() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK); + + byte[] encrypted = null; + String algorithm = null; + + try { + Pair result = key.wrapKeyAsync(CEK, null).get(); + + encrypted = result.getLeft(); + algorithm = result.getRight(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertEquals( "A192KW", algorithm); + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, algorithm).get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyDefaultAlgorithmAesKw256() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK); + + byte[] encrypted = null; + String algorithm = null; + + try { + Pair result = key.wrapKeyAsync(CEK, null).get(); + encrypted = result.getLeft(); + algorithm = result.getRight(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertEquals("A256KW", algorithm); + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, algorithm).get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + +} diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml new file mode 100644 index 0000000000000..8568ec6facddf --- /dev/null +++ b/azure-keyvault-extensions/pom.xml @@ -0,0 +1,143 @@ + + + 4.0.0 + + com.microsoft.azure + azure-parent + 1.0.0-SNAPSHOT + ../pom.xml + + + azure-keyvault-extensions + jar + + Microsoft Azure SDK for Key Vault + This package contains Microsoft Azure Key Vault SDK. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + UTF-8 + + + + + + microsoft + Microsoft + + + + + + com.microsoft.azure + azure-client-runtime + 1.0.0-SNAPSHOT + + + org.apache.httpcomponents + httpclient + 4.5.2 + + + com.microsoft.azure + azure-client-authentication + 1.0.0-beta1 + test + + + junit + junit + test + + + org.bouncycastle + bcprov-jdk15on + test + 1.54 + + + ${project.groupId} + azure-keyvault + ${project.version} + + + ${project.groupId} + azure-keyvault-cryptography + ${project.version} + + + com.microsoft.azure + azure-keyvault-core + 1.0.0-SNAPSHOT + + + org.mockito + mockito-core + 1.10.19 + test + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.storage + /** +
* Copyright (c) Microsoft Corporation. All rights reserved. +
* Licensed under the MIT License. See License.txt in the project root for +
* license information. +
*/]]>
+
+
+ +
+
+
diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java new file mode 100644 index 0000000000000..bd55a075bdb18 --- /dev/null +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java @@ -0,0 +1,139 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.extensions; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import com.microsoft.azure.keyvault.core.IKey; +import com.microsoft.azure.keyvault.core.IKeyResolver; + +public class AggregateKeyResolver implements IKeyResolver { + + class FutureKey implements Future { + + private final String _kid; + + private boolean _cancelled = false; + private boolean _done = false; + private IKey _result = null; + + FutureKey(String kid) { + _kid = kid; + } + + @Override + public boolean cancel(boolean mayInterruptIfRunning) { + + // mark cancelled + _cancelled = true; + + return _cancelled; + } + + @Override + public boolean isCancelled() { + return _cancelled; + } + + @Override + public boolean isDone() { + + // always true + return _done; + } + + @Override + public IKey get() throws InterruptedException, ExecutionException { + + // throw if cancelled + if (_cancelled) { + throw new InterruptedException(); + } + + synchronized( _resolvers ) { + for (IKeyResolver resolver : _resolvers) { + Future futureKey = resolver.resolveKeyAsync(_kid); + + _result = futureKey.get(); + + if (_result != null) { + break; + } + } + } + + // Mark done + _done = true; + + return _result; + } + + @Override + public IKey get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + + // throw if cancelled + if (_cancelled) { + throw new InterruptedException(); + } + + synchronized( _resolvers ) { + for (IKeyResolver resolver : _resolvers) { + Future futureKey = resolver.resolveKeyAsync(_kid); + + _result = futureKey.get(timeout, unit); + + if (_result != null) { + break; + } + } + } + + // Mark done + _done = true; + + return _result; + } + } + + private final List _resolvers; + + public AggregateKeyResolver() { + + _resolvers = Collections.synchronizedList(new ArrayList()); + } + + public void Add(IKeyResolver resolver) { + + synchronized( _resolvers ) { + _resolvers.add(resolver); + } + } + + @Override + public Future resolveKeyAsync(String kid) { + return new FutureKey(kid); + } + +} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java new file mode 100644 index 0000000000000..cd93c8fdaf913 --- /dev/null +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java @@ -0,0 +1,50 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.extensions; + +import java.util.concurrent.Future; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.microsoft.azure.keyvault.core.IKey; +import com.microsoft.azure.keyvault.core.IKeyResolver; + +public class CachingKeyResolver implements IKeyResolver { + + private final LoadingCache> _cache; + private final IKeyResolver _inner; + + public CachingKeyResolver(int capacity, IKeyResolver inner) { + _cache = CacheBuilder.newBuilder().maximumSize(capacity) + .build( new CacheLoader>(){ + + @Override + public Future load(String kid) { + return _inner.resolveKeyAsync(kid); + }}); + + _inner = inner; + } + + @Override + public Future resolveKeyAsync(String kid) { + return _cache.getUnchecked(kid); + } +} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureAdapter.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureAdapter.java new file mode 100644 index 0000000000000..25723415db3d3 --- /dev/null +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureAdapter.java @@ -0,0 +1,138 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.extensions; + +import java.io.IOException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; + +abstract class FutureAdapter extends ServiceCallback implements Future { + + private final Object _lock = new Object(); + + private ServiceCall _call; + + private S _source; + private Throwable _throwable; + + protected FutureAdapter() { + _call = null; + _source = null; + _throwable = null; + } + + public void setServiceCall(ServiceCall call) { + _call = call; + } + + // ServiceCallback overrides + + @Override + public void failure(Throwable t) { + synchronized( _lock ) { + _throwable = t; + + _lock.notifyAll(); + } + } + + + @Override + public void success(ServiceResponse result) { + synchronized( _lock ) { + _source = result.getBody(); + + _lock.notifyAll(); + } + } + + @Override + public boolean cancel(boolean mayInterruptIfRunning) { + + if ( !isCancelled()) { + // TODO: Call.cancel has no return value and does not support mayInterruptIfRunning + _call.getCall().cancel(); + } + + return true; + } + + // Future implementation + + @Override + public boolean isCancelled() { + return _call.getCall().isCanceled(); + } + + @Override + public boolean isDone() { + // _call.getCall().isExecuted() is not the same as done as it will be true when the request is enqueued but not actually + // completed. So we check our results to determine whether we are actually done. + synchronized(_lock) { + return ( _source != null || _throwable != null ); + } + } + + @Override + public T get() throws InterruptedException, ExecutionException { + try { + synchronized( _lock ) { + if ( _source == null && _throwable == null ) { + _lock.wait(); + } + } + + if ( _source != null ) { + return translate(_source); + } else { + throw _throwable; + } + } catch (Throwable e) { + throw new ExecutionException(e); + } + } + + @Override + public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + try { + synchronized( _lock ) { + if ( _source == null && _throwable == null ) { + _lock.wait(); + } + } + + if ( _source != null ) { + return translate(_source); + } else { + throw _throwable; + } + } catch (Throwable e) { + throw new ExecutionException(e); + } + } + + protected abstract T translate(S result) throws IOException; + +} \ No newline at end of file diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureBase.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureBase.java new file mode 100644 index 0000000000000..b25bcde3203d0 --- /dev/null +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureBase.java @@ -0,0 +1,61 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.extensions; + +import java.util.concurrent.Future; + +abstract class FutureBase implements Future { + + private boolean _cancelled = false; + private boolean _done = false; + + protected FutureBase() { + this(false, false); + } + + protected FutureBase(boolean done) { + this(done, false); + } + + protected FutureBase(boolean done, boolean cancelled) { + _done = done; + _cancelled = cancelled; + } + + @Override + public boolean cancel(boolean mayInterruptIfRunning) { + + // mark cancelled + _cancelled = true; + + return _cancelled; + } + + @Override + public boolean isCancelled() { + + return _cancelled; + } + + @Override + public boolean isDone() { + + return _done; + } +} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureExecutionException.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureExecutionException.java new file mode 100644 index 0000000000000..a3744fb037efb --- /dev/null +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureExecutionException.java @@ -0,0 +1,45 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.extensions; + +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +class FutureExecutionException extends FutureBase { + + private final ExecutionException _e; + + FutureExecutionException(Throwable t) { + super(true); + + _e = new ExecutionException(t); + } + + @Override + public T get() throws InterruptedException, ExecutionException { + throw _e; + } + + @Override + public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + throw _e; + } + +} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureImmediate.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureImmediate.java new file mode 100644 index 0000000000000..0e086cec82698 --- /dev/null +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureImmediate.java @@ -0,0 +1,56 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.extensions; + +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +class FutureImmediate extends FutureBase { + + private final T _result; + + FutureImmediate(T result) { + super(true); + + _result = result; + } + + @Override + public T get() throws InterruptedException, ExecutionException { + + // throw if cancelled + if (isCancelled()) { + throw new InterruptedException(); + } + + return _result; + } + + @Override + public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + + // throw if cancelled + if (isCancelled()) { + throw new InterruptedException(); + } + + return _result; + } +} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java new file mode 100644 index 0000000000000..c9b1c0a2876a4 --- /dev/null +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -0,0 +1,247 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.extensions; + +import java.io.IOException; +import java.security.NoSuchAlgorithmException; +import java.util.concurrent.Future; + +import org.apache.commons.lang3.tuple.Pair; +import org.apache.commons.lang3.tuple.Triple; + +import com.microsoft.azure.keyvault.implementation.KeyVaultClient; +import com.microsoft.azure.keyvault.core.IKey; +import com.microsoft.azure.keyvault.cryptography.RsaKey; +import com.microsoft.azure.keyvault.cryptography.Strings; +import com.microsoft.azure.keyvault.models.KeyBundle; +import com.microsoft.azure.keyvault.models.KeyOperationResult; +import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; + +public class KeyVaultKey implements IKey { + + class FutureDecryptResult extends FutureAdapter { + + FutureDecryptResult() { + super(); + } + + @Override + protected byte[] translate(KeyOperationResult result) throws IOException { + return result.result(); + } + } + + class FutureSignResult extends FutureAdapter> { + + private final String _algorithm; + + FutureSignResult(String algorithm) { + super(); + _algorithm = algorithm; + } + + @Override + protected Pair translate(KeyOperationResult result) throws IOException { + return Pair.of(result.result(), _algorithm); + } + } + + private final KeyVaultClient _client; + private IKey _implementation; + + protected KeyVaultKey(KeyVaultClient client, KeyBundle keyBundle) { + + if (client == null) { + throw new IllegalArgumentException("client"); + } + + if (keyBundle == null) { + throw new IllegalArgumentException("keyBundle"); + } + + JsonWebKey key = keyBundle.key(); + + if (key == null) { + throw new IllegalArgumentException("keyBundle must contain a key"); + } + + if (key.kty().equals(JsonWebKeyType.RSA)) { + // The private key is not available for KeyVault keys + _implementation = new RsaKey(key.kid(), key.toRSA(false)); + } else if (key.kty().equals(JsonWebKeyType.RSAHSM)) { + // The private key is not available for KeyVault keys + _implementation = new RsaKey(key.kid(), key.toRSA(false)); + } + + if (_implementation == null) { + throw new IllegalArgumentException(String.format("The key type %s is not supported", key.kty())); + } + + _client = client; + } + + @Override + public void close() throws IOException { + if (_implementation != null) { + _implementation.close(); + } + } + + @Override + public String getDefaultEncryptionAlgorithm() { + if (_implementation == null) { + return null; + } + + return _implementation.getDefaultEncryptionAlgorithm(); + } + + @Override + public String getDefaultKeyWrapAlgorithm() { + + if (_implementation == null) { + return null; + } + + return _implementation.getDefaultKeyWrapAlgorithm(); + } + + @Override + public String getDefaultSignatureAlgorithm() { + + if (_implementation == null) { + return null; + } + + return _implementation.getDefaultSignatureAlgorithm(); + } + + @Override + public String getKid() { + + if (_implementation == null) { + return null; + } + + return _implementation.getKid(); + } + + @Override + public Future decryptAsync(byte[] ciphertext, byte[] iv, byte[] authenticationData, byte[] authenticationTag, String algorithm) { + + if (_implementation == null) { + return null; + } + + if (Strings.isNullOrWhiteSpace(algorithm)) { + algorithm = getDefaultEncryptionAlgorithm(); + } + + // Never local + FutureDecryptResult result = new FutureDecryptResult(); + + result.setServiceCall( + _client.decrypt( + _implementation.getKid(), + algorithm, + ciphertext, + result ) ); + + return result; + } + + @Override + public Future> encryptAsync(byte[] plaintext, byte[] iv, byte[] authenticationData, String algorithm) throws NoSuchAlgorithmException { + if (_implementation == null) { + return null; + } + + return _implementation.encryptAsync(plaintext, iv, authenticationData, algorithm); + } + + @Override + public Future> wrapKeyAsync(byte[] plaintext, String algorithm) throws NoSuchAlgorithmException { + if (_implementation == null) { + return null; + } + + return _implementation.wrapKeyAsync(plaintext, algorithm); + } + + @Override + public Future unwrapKeyAsync(byte[] ciphertext, String algorithm) { + if (_implementation == null) { + return null; + } + + if (Strings.isNullOrWhiteSpace(algorithm)) { + algorithm = getDefaultKeyWrapAlgorithm(); + } + + // Never local + FutureDecryptResult result = new FutureDecryptResult(); + + result.setServiceCall( + _client.unwrapKey( + _implementation.getKid(), + algorithm, + ciphertext, + result ) ); + + return result; + + } + + @Override + public Future> signAsync(byte[] digest, String algorithm) { + if (_implementation == null) { + return null; + } + + if (Strings.isNullOrWhiteSpace(algorithm)) { + algorithm = getDefaultSignatureAlgorithm(); + } + + // Never local + FutureSignResult result = new FutureSignResult(algorithm); + + result.setServiceCall( + _client.sign( + _implementation.getKid(), + algorithm, + digest, + result ) ); + + return result; + + } + + @Override + public Future verifyAsync(byte[] digest, byte[] signature, String algorithm) { + if (_implementation == null) { + return null; + } + + return _implementation.verifyAsync(digest, signature, algorithm); + } +} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java new file mode 100644 index 0000000000000..ac6bbf7560904 --- /dev/null +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java @@ -0,0 +1,125 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.extensions; + +import java.security.Provider; +import java.util.concurrent.Future; + +import org.apache.commons.codec.binary.Base64; + +import com.microsoft.azure.keyvault.implementation.KeyVaultClient; +import com.microsoft.azure.keyvault.core.IKey; +import com.microsoft.azure.keyvault.core.IKeyResolver; +import com.microsoft.azure.keyvault.cryptography.SymmetricKey; +import com.microsoft.azure.keyvault.models.KeyBundle; +import com.microsoft.azure.keyvault.implementation.KeyIdentifier; +import com.microsoft.azure.keyvault.models.SecretBundle; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.azure.keyvault.implementation.SecretIdentifier; + +public class KeyVaultKeyResolver implements IKeyResolver { + + static final Base64 _base64 = new Base64(-1, null, true); + + class FutureKeyFromKey extends FutureAdapter { + + protected FutureKeyFromKey() { + super(); + } + + @Override + protected IKey translate(KeyBundle keyBundle) { + + if (keyBundle != null) { + return new KeyVaultKey(_client, keyBundle); + } + + return null; + } + } + + class FutureKeyFromSecret extends FutureAdapter { + + + protected FutureKeyFromSecret() { + super(); + } + + @Override + protected IKey translate(SecretBundle secretBundle) { + + if (secretBundle != null && secretBundle.contentType().equalsIgnoreCase("application/octet-stream")) { + byte[] keyBytes = _base64.decode(secretBundle.value()); + + if (keyBytes != null) { + return new SymmetricKey(secretBundle.id(), keyBytes, _provider ); + } + } + + return null; + } + } + + private final KeyVaultClient _client; + private final Provider _provider; + + public KeyVaultKeyResolver(KeyVaultClient client) { + _client = client; + _provider = null; + } + + public KeyVaultKeyResolver(KeyVaultClient client, Provider provider) { + _client = client; + _provider = provider; + } + + private Future resolveKeyFromSecretAsync(String kid) { + + FutureKeyFromSecret result = new FutureKeyFromSecret(); + + result.setServiceCall( _client.getSecret(kid, result) ); + + return result; + } + + private Future resolveKeyFromKeyAsync(String kid) { + + FutureKeyFromKey result = new FutureKeyFromKey(); + + + result.setServiceCall( _client.getKey(kid, result ) ); + + return result; + } + + @Override + public Future resolveKeyAsync(String kid) { + + if (KeyIdentifier.isKeyIdentifier(kid)) { + return resolveKeyFromKeyAsync(kid); + } else if (SecretIdentifier.isSecretIdentifier(kid)) { + return resolveKeyFromSecretAsync(kid); + } + + return new FutureImmediate(null); + } + +} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java new file mode 100644 index 0000000000000..495e17811a1f5 --- /dev/null +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java @@ -0,0 +1,41 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.extensions; + + +public class Strings { + + public static boolean isNullOrEmpty(String arg) { + + if (arg == null || arg.isEmpty()) { + return true; + } + + return false; + } + + public static boolean isNullOrWhiteSpace(String arg) { + + if (Strings.isNullOrEmpty(arg) || arg.trim().isEmpty()) { + return true; + } + + return false; + } +} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/package.html b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/package.html new file mode 100644 index 0000000000000..12edd05fd0bac --- /dev/null +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/package.html @@ -0,0 +1,5 @@ + + +This package contains the Azure Key Vault Extension classes. + + diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java new file mode 100644 index 0000000000000..44c64e6a863ce --- /dev/null +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java @@ -0,0 +1,98 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.extensions.test; + +import static org.junit.Assert.*; + +import java.util.concurrent.Future; + +import org.junit.Test; + +import com.google.common.util.concurrent.UncheckedExecutionException; +import com.microsoft.azure.keyvault.core.IKey; +import com.microsoft.azure.keyvault.core.IKeyResolver; +import com.microsoft.azure.keyvault.extensions.CachingKeyResolver; +import static org.mockito.Mockito.*; + +public class CachingKeyResolverTest { + + @SuppressWarnings("unchecked") + final Future ikeyAsync = mock(Future.class); + final static String keyId = "keyID"; + final static String keyId2 = "keyID2"; + final static String keyId3 = "keyID3"; + + + /* + * Tests the capacity limit of CachingKeyResolver by adding more keys + * than the cache limit and verifying that least recently used entity is evicted. + */ + @Test + public void KeyVault_CapacityLimitOfCachingKeyResolver() + { + IKeyResolver mockedKeyResolver = mock(IKeyResolver.class); + CachingKeyResolver resolver = new CachingKeyResolver(2, mockedKeyResolver); + + when(mockedKeyResolver.resolveKeyAsync(keyId)).thenReturn(ikeyAsync); + when(mockedKeyResolver.resolveKeyAsync(keyId2)).thenReturn(ikeyAsync); + when(mockedKeyResolver.resolveKeyAsync(keyId3)).thenReturn(ikeyAsync); + + resolver.resolveKeyAsync(keyId); + resolver.resolveKeyAsync(keyId2); + resolver.resolveKeyAsync(keyId3); + + resolver.resolveKeyAsync(keyId2); + resolver.resolveKeyAsync(keyId3); + resolver.resolveKeyAsync(keyId); + resolver.resolveKeyAsync(keyId3); + + verify(mockedKeyResolver, times(1)).resolveKeyAsync(keyId2); + verify(mockedKeyResolver, times(1)).resolveKeyAsync(keyId3); + verify(mockedKeyResolver, times(2)).resolveKeyAsync(keyId); + } + + /* + * Tests the behavior of CachingKeyResolver when resolving key throws + * and validate that the failed entity is not added to the cache. + */ + @Test + public void KeyVault_CachingKeyResolverThrows() + { + IKeyResolver mockedKeyResolver = mock(IKeyResolver.class); + CachingKeyResolver resolver = new CachingKeyResolver(10, mockedKeyResolver); + + // First throw exception and for the second call return a value + when(mockedKeyResolver.resolveKeyAsync(keyId)) + .thenThrow(new RuntimeException("test")) + .thenReturn(ikeyAsync); + + try { + resolver.resolveKeyAsync(keyId); + assertFalse("Should have thrown an exception.", true); + } + catch (UncheckedExecutionException e) { + assertTrue("RuntimeException is expected.", e.getCause() instanceof RuntimeException); + } + + resolver.resolveKeyAsync(keyId); + resolver.resolveKeyAsync(keyId); + + verify(mockedKeyResolver, times(2)).resolveKeyAsync(keyId); + } +} diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java new file mode 100644 index 0000000000000..f764ece79d26b --- /dev/null +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java @@ -0,0 +1,164 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.extensions.test; + + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; + + +import com.microsoft.azure.keyvault.implementation.KeyVaultClient; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.ObjectWriter; +import com.microsoft.aad.adal4j.AuthenticationContext; +import com.microsoft.aad.adal4j.AuthenticationResult; +import com.microsoft.aad.adal4j.ClientCredential; +import com.microsoft.azure.keyvault.authentication.KeyVaultCredentials; + +public class KeyVaultClientIntegrationTestBase { + + /** + * The client instance that should be used on tests. + */ + protected static KeyVaultClient keyVaultClient; + + /** + * Primary vault URI, used for keys and secrets tests. + */ + public static String getVaultUri() { + return getLiveVaultUri1(); + } + + /** + * Secondary vault URI, used to verify ability to transparently authenticate + * against a different resource. + */ + public static String getSecondaryVaultUri() { + return getLiveVaultUri2(); + } + + private static String getLiveVaultUri1() { + return getenvOrDefault("keyvault.vaulturi", "https://javasdktestvault.vault.azure.net"); + } + + private static String getLiveVaultUri2() { + return getenvOrDefault("keyvault.vaulturi.alt", "https://javasdktestvault2.vault.azure.net"); + } + + private static String getenvOrDefault(String varName, String defValue) { + String value = System.getenv(varName); + return value != null ? value : defValue; + } + + protected static void createKeyVaultClient() throws Exception { + keyVaultClient = new KeyVaultClient(createTestCredentials()); + } + + private static ServiceClientCredentials createTestCredentials() throws Exception { + return new KeyVaultCredentials() { + + @Override + public String doAuthenticate(String authorization, String resource, String scope) { + try { + AuthenticationResult authResult = getAccessToken(authorization, resource); + return authResult.getAccessToken(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + }; + } + + private static AuthenticationResult getAccessToken(String authorization, String resource) throws Exception { + + String clientId = System.getenv("arm.clientid"); + + if (clientId == null) { + throw new Exception("Please inform arm.clientid in the environment settings."); + } + + String clientKey = System.getenv("arm.clientkey"); + String username = System.getenv("arm.username"); + String password = System.getenv("arm.password"); + + AuthenticationResult result = null; + ExecutorService service = null; + try { + service = Executors.newFixedThreadPool(1); + AuthenticationContext context = new AuthenticationContext(authorization, false, service); + + Future future = null; + + if (clientKey != null && password == null) { + ClientCredential credentials = new ClientCredential(clientId, clientKey); + future = context.acquireToken(resource, credentials, null); + } + + if (password != null && clientKey == null) { + future = context.acquireToken(resource, clientId, username, password, null); + } + + if (future == null) { + throw new Exception("Missing or ambiguous credentials - please inform exactly one of arm.clientkey or arm.password in the environment settings."); + } + + result = future.get(); + } finally { + service.shutdown(); + } + + if (result == null) { + throw new RuntimeException("authentication result was null"); + } + return result; + } + + protected static ObjectWriter jsonWriter; + protected static ObjectReader jsonReader; + + @BeforeClass + public static void setup() throws Exception { + createKeyVaultClient(); + jsonWriter = new ObjectMapper().writer().withDefaultPrettyPrinter(); + jsonReader = new ObjectMapper().reader(); + } + + @AfterClass + public static void cleanup() throws Exception { + } + + @Before + public void beforeTest() throws Exception { + //setupTest(getClass().getSimpleName() + "-" + "??"); + } + + @After + public void afterTest() throws Exception { + //resetTest(getClass().getSimpleName() + "-" + "??"); + } + +} \ No newline at end of file diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java new file mode 100644 index 0000000000000..e6b3ef7d7b9cf --- /dev/null +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java @@ -0,0 +1,294 @@ +// +//Copyright © Microsoft Corporation, All Rights Reserved +// +//Licensed under the Apache License, Version 2.0 (the "License"); +//you may not use this file except in compliance with the License. +//You may obtain a copy of the License at +// +//http://www.apache.org/licenses/LICENSE-2.0 +// +//THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +//OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +//ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A +//PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. +// +//See the Apache License, Version 2.0 for the specific language +//governing permissions and limitations under the License. + +package com.microsoft.azure.keyvault.extensions.test; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.fail; + +import java.security.Provider; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +import org.apache.commons.codec.binary.Base64; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.azure.keyvault.core.IKey; +import com.microsoft.azure.keyvault.extensions.KeyVaultKeyResolver; +import com.microsoft.azure.keyvault.implementation.requests.CreateKeyRequest; +import com.microsoft.azure.keyvault.implementation.requests.SetSecretRequest; +import com.microsoft.azure.keyvault.models.KeyBundle; +import com.microsoft.azure.keyvault.models.SecretBundle; +import com.microsoft.rest.ServiceResponse; + +public class KeyVaultKeyResolverBCProviderTest extends KeyVaultClientIntegrationTestBase { + + private Provider _provider = null; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + try { + _provider = (Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance(); + } catch (ClassNotFoundException ex) { + throw new RuntimeException(ex.getMessage()); + } catch (IllegalAccessException ex) { + throw new RuntimeException(ex.getMessage()); + } catch (InstantiationException ex) { + throw new RuntimeException(ex.getMessage()); + } + } + + @After + public void tearDown() throws Exception { + } + + private static final String KEY_NAME = "JavaExtensionKey"; + private static final String SECRET_NAME = "JavaExtensionSecret"; + + private static final Base64 _base64 = new Base64(-1, null, true); + + @Test + public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, ExecutionException + { + try { + // Create a key on a vault. + CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); + ServiceResponse response = keyVaultClient.createKey(request); + KeyBundle bundle = response != null ? response.getBody() : null; + + if ( bundle != null ) + { + try + { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient, _provider ); + + Future baseKeyFuture = resolver.resolveKeyAsync( bundle.keyIdentifier().baseIdentifier() ); + Future versionKeyFuture = resolver.resolveKeyAsync( bundle.keyIdentifier().identifier() ); + + IKey baseKey = baseKeyFuture.get(); + IKey versionKey = versionKeyFuture.get(); + + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + } + finally + { + // Delete the key + keyVaultClient.deleteKey( getVaultUri(), KEY_NAME ); + } + } + } + catch ( Exception ex ) + { + Assert.fail(ex.getMessage()); + } + } + + /* + * Test resolving a key from a 128bit secret encoded as base64 in a vault using various KeyVaultKeyResolver constructors. + */ + @Test + public void KeyVault_KeyVaultKeyResolver_Secret128Base64() throws InterruptedException, ExecutionException + { + // Arrange + byte[] keyBytes = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; + + try { + + SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + + if ( secretBundle != null ) + { + try { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); + + IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); + + // Check for correct key identifiers + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + + // Ensure key operations give the expected results + byte[] encrypted = null; + + try { + encrypted = baseKey.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + + try { + encrypted = versionKey.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + finally + { + // Delete the secret + keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); + } + } + } + catch ( Exception ex ) { + Assert.fail(ex.getMessage()); + } + } + + /* + * Test resolving a key from a 128bit secret encoded as base64 in a vault using various KeyVaultKeyResolver constructors. + */ + @Test + public void KeyVault_KeyVaultKeyResolver_Secret192Base64() throws InterruptedException, ExecutionException + { + // Arrange + byte[] keyBytes = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + try { + SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + + if ( secretBundle != null ) + { + try + { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient, _provider ); + + IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); + + // Check for correct key identifiers + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + + // Ensure key operations give the expected results + byte[] encrypted = null; + + try { + encrypted = baseKey.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + + try { + encrypted = versionKey.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + finally + { + // Delete the key + keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); + } + } + } catch (Exception ex) { + Assert.fail(ex.getMessage()); + } + } + + /* + * Test resolving a key from a 256bit secret encoded as base64 in a vault using various KeyVaultKeyResolver constructors. + */ + @Test + public void KeyVault_KeyVaultKeyResolver_Secret256Base64() throws InterruptedException, ExecutionException + { + // Arrange + byte[] keyBytes = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + + try { + SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + + if ( secretBundle != null ) + { + try + { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient, _provider ); + + IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); + + // Check for correct key identifiers + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + + // Ensure key operations give the expected results + byte[] encrypted = null; + + try { + encrypted = baseKey.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + + try { + encrypted = versionKey.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + finally + { + // Delete the key + keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); + } + } + } catch ( Exception ex ) { + fail(ex.getMessage()); + } + } +} diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java new file mode 100644 index 0000000000000..c7102db7f411a --- /dev/null +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java @@ -0,0 +1,316 @@ +package com.microsoft.azure.keyvault.extensions.test; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.fail; + +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.concurrent.ExecutionException; +import javax.crypto.Cipher; + +import org.apache.commons.codec.binary.Base64; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.azure.keyvault.core.IKey; +import com.microsoft.azure.keyvault.extensions.KeyVaultKeyResolver; +import com.microsoft.azure.keyvault.implementation.requests.CreateKeyRequest; +import com.microsoft.azure.keyvault.implementation.requests.SetSecretRequest; +import com.microsoft.azure.keyvault.models.KeyBundle; +import com.microsoft.azure.keyvault.models.SecretBundle; + +// +//Copyright © Microsoft Corporation, All Rights Reserved +// +//Licensed under the Apache License, Version 2.0 (the "License"); +//you may not use this file except in compliance with the License. +//You may obtain a copy of the License at +// +//http://www.apache.org/licenses/LICENSE-2.0 +// +//THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS +//OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION +//ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A +//PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. +// +//See the Apache License, Version 2.0 for the specific language +//governing permissions and limitations under the License. + +public class KeyVaultKeyResolverDefaultProviderTest extends KeyVaultClientIntegrationTestBase { + + private static boolean hasUnlimitedCrypto() { + try { + return Cipher.getMaxAllowedKeyLength("RC5") >= 256; + } catch (NoSuchAlgorithmException e) { + return false; + } + } + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + private static final boolean _unlimited = hasUnlimitedCrypto(); + + + private static final String KEY_NAME = "JavaExtensionKey"; + private static final String SECRET_NAME = "JavaExtensionSecret"; + + private static final Base64 _base64 = new Base64(-1, null, true); + + @Test + public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, ExecutionException + { + try { + // Create a key on a vault. + CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); + KeyBundle keyBundle = keyVaultClient.createKey(request).getBody(); + + try + { + // ctor with client + final KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); + + IKey baseKey = resolver.resolveKeyAsync( keyBundle.keyIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( keyBundle.keyIdentifier().identifier() ).get(); + + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + } + finally + { + // Delete the key + keyVaultClient.deleteKey( getVaultUri(), KEY_NAME ); + } + } catch(Exception ex) { + fail(ex.getMessage()); + } + } + + /* + * Test resolving a key from a 128bit secret encoded as base64 in a vault using various KeyVaultKeyResolver constructors. + */ + @Test + public void KeyVault_KeyVaultKeyResolver_Secret128Base64() throws InterruptedException, ExecutionException + { + // Arrange + byte[] keyBytes = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; + + try { + SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); + SecretBundle secretBundle = keyVaultClient.setSecret(request).getBody(); + + if ( secretBundle != null ) + { + try + { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); + + IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); + + // Check for correct key identifiers + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + + // Ensure key operations give the expected results + byte[] encrypted = null; + + try { + encrypted = baseKey.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch ( Exception ex ) { + fail(ex.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + + try { + encrypted = versionKey.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch ( Exception ex ) { + fail(ex.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + finally + { + // Delete the key + keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); + } + } + } catch ( Exception ex ) { + fail(ex.getMessage()); + } + } + + /* + * Test resolving a key from a 128bit secret encoded as base64 in a vault using various KeyVaultKeyResolver constructors. + */ + @Test + public void KeyVault_KeyVaultKeyResolver_Secret192Base64() throws InterruptedException, ExecutionException + { + // Arrange + byte[] keyBytes = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + try { + SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + + if ( secretBundle != null ) + { + try + { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); + + IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); + + // Check for correct key identifiers + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + + // Ensure key operations give the expected results + byte[] encrypted = null; + + try { + encrypted = baseKey.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + + if (!_unlimited) fail("Expected ExecutionException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!_unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch ( Exception ex ) { + fail(ex.getMessage()); + } + + if ( _unlimited ) { + // Assert + assertArrayEquals(EK, encrypted); + + try { + encrypted = versionKey.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + } catch ( Exception ex ) { + fail(ex.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + } + finally + { + // Delete the key + keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); + } + } + } catch ( Exception ex ) { + fail(ex.getMessage()); + } + } + + /* + * Test resolving a key from a 256bit secret encoded as base64 in a vault using various KeyVaultKeyResolver constructors. + */ + @Test + public void KeyVault_KeyVaultKeyResolver_Secret256Base64() throws InterruptedException, ExecutionException + { + // Arrange + byte[] keyBytes = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + + try { + SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + + if ( secretBundle != null ) + { + try + { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); + + IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); + + // Check for correct key identifiers + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + + // Ensure key operations give the expected results + byte[] encrypted = null; + + try { + encrypted = baseKey.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + + if (!_unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!_unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if ( _unlimited ) { + // Assert + assertArrayEquals(EK, encrypted); + + try { + encrypted = versionKey.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + } + finally + { + // Delete the key + keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); + } + } + } catch ( Exception ex ) { + fail(ex.getMessage()); + } + } +} diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index 1adbfe52e1f61..17974ee1202f0 100644 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -63,6 +63,7 @@ com.microsoft.azure azure-client-authentication 1.0.0-SNAPSHOT + test From 6831a3d381dcc7cac856a7bee156fe4f2a4ab770 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Tue, 2 Aug 2016 10:23:56 -0700 Subject: [PATCH 07/56] Update POM packages for core, cryptography, extensions --- azure-keyvault-core/pom.xml | 40 +++++++++-------------------- azure-keyvault-cryptography/pom.xml | 5 ---- azure-keyvault-extensions/pom.xml | 33 ++++++++++-------------- 3 files changed, 26 insertions(+), 52 deletions(-) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index 86897281875d3..f74716d0dcdbb 100644 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -54,34 +54,6 @@ - - - com.microsoft.azure - azure-client-runtime - 1.0.0-SNAPSHOT - - - org.apache.httpcomponents - httpclient - 4.5.2 - - - junit - junit - test - - - com.microsoft.azure - azure-client-authentication - 1.0.0-beta1 - test - - - com.microsoft.azure - azure-core - 0.9.3 - - @@ -127,4 +99,16 @@ + + + org.apache.commons + commons-lang3 + 3.4 + + + com.google.guava + guava + 18.0 + + diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index a8991d80d2da3..7870e8c3f23c7 100644 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -43,11 +43,6 @@ - - org.apache.commons - commons-lang3 - 3.4 - junit junit diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 8568ec6facddf..1059acb7cf02c 100644 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -51,17 +51,6 @@ azure-client-runtime 1.0.0-SNAPSHOT - - org.apache.httpcomponents - httpclient - 4.5.2 - - - com.microsoft.azure - azure-client-authentication - 1.0.0-beta1 - test - junit junit @@ -74,19 +63,19 @@ 1.54 - ${project.groupId} - azure-keyvault - ${project.version} + ${project.groupId} + azure-keyvault-core + ${project.version} - ${project.groupId} + ${project.groupId} azure-keyvault-cryptography - ${project.version} + ${project.version} - com.microsoft.azure - azure-keyvault-core - 1.0.0-SNAPSHOT + ${project.groupId} + azure-keyvault + ${project.version} org.mockito @@ -94,6 +83,12 @@ 1.10.19 test + + com.microsoft.azure + azure-client-authentication + 1.0.0-beta2 + test + From 97b7c86ab462a9b7bbccc2b04b59dce794e1ff4a Mon Sep 17 00:00:00 2001 From: Pooneh Date: Wed, 3 Aug 2016 13:27:54 -0700 Subject: [PATCH 08/56] Dropping implementation namespace, fix test bug and adding comments --- .../keyvault/extensions/KeyVaultKey.java | 2 +- .../extensions/KeyVaultKeyResolver.java | 6 ++-- .../KeyVaultClientIntegrationTestBase.java | 3 +- .../KeyVaultKeyResolverBCProviderTest.java | 4 +-- ...eyVaultKeyResolverDefaultProviderTest.java | 4 +-- azure-keyvault/pom.xml | 2 +- .../CertificateIdentifier.java | 2 +- .../CertificateOperationIdentifier.java | 2 +- .../IssuerIdentifier.java | 2 +- .../{implementation => }/KeyIdentifier.java | 2 +- .../{implementation => }/KeyVaultClient.java | 34 +++++++++---------- .../KeyVaultClientImpl.java | 2 +- .../ObjectIdentifier.java | 2 +- .../SecretIdentifier.java | 2 +- .../authentication/KeyVaultCredentials.java | 8 +++++ .../keyvault/implementation/package-info.java | 9 ----- .../keyvault/models/CertificateBundle.java | 6 ++-- .../keyvault/models/CertificateItem.java | 3 +- .../keyvault/models/CertificateOperation.java | 2 +- .../azure/keyvault/models/IssuerBundle.java | 2 +- .../azure/keyvault/models/KeyBundle.java | 2 +- .../azure/keyvault/models/KeyItem.java | 2 +- .../azure/keyvault/models/SecretBundle.java | 2 +- .../azure/keyvault/models/SecretItem.java | 2 +- .../requests/CreateCertificateRequest.java | 3 +- .../requests/CreateKeyRequest.java | 3 +- .../requests/ImportCertificateRequest.java | 3 +- .../requests/ImportKeyRequest.java | 3 +- .../requests/MergeCertificateRequest.java | 3 +- .../requests/SetCertificateIssuerRequest.java | 3 +- .../requests/SetSecretRequest.java | 3 +- .../UpdateCertificateIssuerRequest.java | 3 +- .../UpdateCertificateOperationRequest.java | 3 +- .../UpdateCertificatePolicyRequest.java | 3 +- .../requests/UpdateCertificateRequest.java | 3 +- .../requests/UpdateKeyRequest.java | 5 +-- .../requests/UpdateSecretRequest.java | 5 +-- .../test/CertificateOperationsTest.java | 29 ++++++++++------ .../keyvault/test/KeyOperationsTest.java | 8 ++--- .../KeyVaultClientIntegrationTestBase.java | 3 +- .../keyvault/test/SecretOperationsTest.java | 6 ++-- 41 files changed, 108 insertions(+), 88 deletions(-) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/CertificateIdentifier.java (95%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/CertificateOperationIdentifier.java (97%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/IssuerIdentifier.java (98%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/KeyIdentifier.java (95%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/KeyVaultClient.java (98%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/KeyVaultClientImpl.java (99%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/ObjectIdentifier.java (99%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/SecretIdentifier.java (95%) delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/CreateCertificateRequest.java (98%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/CreateKeyRequest.java (97%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/ImportCertificateRequest.java (98%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/ImportKeyRequest.java (97%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/MergeCertificateRequest.java (97%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/SetCertificateIssuerRequest.java (95%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/SetSecretRequest.java (97%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/UpdateCertificateIssuerRequest.java (95%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/UpdateCertificateOperationRequest.java (95%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/UpdateCertificatePolicyRequest.java (97%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/UpdateCertificateRequest.java (97%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/UpdateKeyRequest.java (96%) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/requests/UpdateSecretRequest.java (96%) diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index c9b1c0a2876a4..46bbb19b6fd47 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -25,7 +25,7 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; -import com.microsoft.azure.keyvault.implementation.KeyVaultClient; +import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.cryptography.RsaKey; import com.microsoft.azure.keyvault.cryptography.Strings; diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java index ac6bbf7560904..7fe6c34e5ddc1 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java @@ -23,17 +23,17 @@ import org.apache.commons.codec.binary.Base64; -import com.microsoft.azure.keyvault.implementation.KeyVaultClient; +import com.microsoft.azure.keyvault.KeyIdentifier; +import com.microsoft.azure.keyvault.KeyVaultClient; +import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.core.IKeyResolver; import com.microsoft.azure.keyvault.cryptography.SymmetricKey; import com.microsoft.azure.keyvault.models.KeyBundle; -import com.microsoft.azure.keyvault.implementation.KeyIdentifier; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; -import com.microsoft.azure.keyvault.implementation.SecretIdentifier; public class KeyVaultKeyResolver implements IKeyResolver { diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java index f764ece79d26b..7ee4da2e0c841 100644 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java @@ -28,8 +28,6 @@ import org.junit.Before; import org.junit.BeforeClass; - -import com.microsoft.azure.keyvault.implementation.KeyVaultClient; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; @@ -37,6 +35,7 @@ import com.microsoft.aad.adal4j.AuthenticationContext; import com.microsoft.aad.adal4j.AuthenticationResult; import com.microsoft.aad.adal4j.ClientCredential; +import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.authentication.KeyVaultCredentials; public class KeyVaultClientIntegrationTestBase { diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java index e6b3ef7d7b9cf..0f7e57fc6af6c 100644 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java @@ -34,10 +34,10 @@ import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.extensions.KeyVaultKeyResolver; -import com.microsoft.azure.keyvault.implementation.requests.CreateKeyRequest; -import com.microsoft.azure.keyvault.implementation.requests.SetSecretRequest; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.SecretBundle; +import com.microsoft.azure.keyvault.requests.CreateKeyRequest; +import com.microsoft.azure.keyvault.requests.SetSecretRequest; import com.microsoft.rest.ServiceResponse; public class KeyVaultKeyResolverBCProviderTest extends KeyVaultClientIntegrationTestBase { diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java index c7102db7f411a..8a0a5ab533c77 100644 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java @@ -18,10 +18,10 @@ import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.extensions.KeyVaultKeyResolver; -import com.microsoft.azure.keyvault.implementation.requests.CreateKeyRequest; -import com.microsoft.azure.keyvault.implementation.requests.SetSecretRequest; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.SecretBundle; +import com.microsoft.azure.keyvault.requests.CreateKeyRequest; +import com.microsoft.azure.keyvault.requests.SetSecretRequest; // //Copyright © Microsoft Corporation, All Rights Reserved diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index 17974ee1202f0..498a5805aa355 100644 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -100,7 +100,7 @@ maven-javadoc-plugin 2.8 - *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.storage + *.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.storage /**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java similarity index 95% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateIdentifier.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java index 3212b73970f92..0e1bc942d8620 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java @@ -16,7 +16,7 @@ * */ -package com.microsoft.azure.keyvault.implementation; +package com.microsoft.azure.keyvault; public final class CertificateIdentifier extends ObjectIdentifier { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateOperationIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java similarity index 97% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateOperationIdentifier.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java index 95819298f24a6..9c6a4aab0d395 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/CertificateOperationIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java @@ -16,7 +16,7 @@ * */ -package com.microsoft.azure.keyvault.implementation; +package com.microsoft.azure.keyvault; import java.net.URI; import java.net.URISyntaxException; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/IssuerIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java similarity index 98% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/IssuerIdentifier.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java index ef0b4c6334844..bbc435c681893 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/IssuerIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java @@ -16,7 +16,7 @@ * */ -package com.microsoft.azure.keyvault.implementation; +package com.microsoft.azure.keyvault; import java.net.URI; import java.net.URISyntaxException; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java similarity index 95% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyIdentifier.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java index bf67ff2164183..3d492f693046b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java @@ -16,7 +16,7 @@ * */ -package com.microsoft.azure.keyvault.implementation; +package com.microsoft.azure.keyvault; public final class KeyIdentifier extends ObjectIdentifier { public static boolean isKeyIdentifier(String identifier) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java similarity index 98% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClient.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 878d6d5393db7..9284ef8aca85b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -1,10 +1,10 @@ /** - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ -package com.microsoft.azure.keyvault.implementation; +package com.microsoft.azure.keyvault; import java.io.IOException; @@ -12,19 +12,6 @@ import com.microsoft.azure.AzureClient; import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.PagedList; -import com.microsoft.azure.keyvault.implementation.requests.CreateCertificateRequest; -import com.microsoft.azure.keyvault.implementation.requests.CreateKeyRequest; -import com.microsoft.azure.keyvault.implementation.requests.ImportCertificateRequest; -import com.microsoft.azure.keyvault.implementation.requests.ImportKeyRequest; -import com.microsoft.azure.keyvault.implementation.requests.MergeCertificateRequest; -import com.microsoft.azure.keyvault.implementation.requests.SetCertificateIssuerRequest; -import com.microsoft.azure.keyvault.implementation.requests.SetSecretRequest; -import com.microsoft.azure.keyvault.implementation.requests.UpdateCertificateIssuerRequest; -import com.microsoft.azure.keyvault.implementation.requests.UpdateCertificateOperationRequest; -import com.microsoft.azure.keyvault.implementation.requests.UpdateCertificatePolicyRequest; -import com.microsoft.azure.keyvault.implementation.requests.UpdateCertificateRequest; -import com.microsoft.azure.keyvault.implementation.requests.UpdateKeyRequest; -import com.microsoft.azure.keyvault.implementation.requests.UpdateSecretRequest; import com.microsoft.azure.keyvault.models.BackupKeyResult; import com.microsoft.azure.keyvault.models.CertificateBundle; import com.microsoft.azure.keyvault.models.CertificateIssuerItem; @@ -41,6 +28,19 @@ import com.microsoft.azure.keyvault.models.PageImpl; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.models.SecretItem; +import com.microsoft.azure.keyvault.requests.CreateCertificateRequest; +import com.microsoft.azure.keyvault.requests.CreateKeyRequest; +import com.microsoft.azure.keyvault.requests.ImportCertificateRequest; +import com.microsoft.azure.keyvault.requests.ImportKeyRequest; +import com.microsoft.azure.keyvault.requests.MergeCertificateRequest; +import com.microsoft.azure.keyvault.requests.SetCertificateIssuerRequest; +import com.microsoft.azure.keyvault.requests.SetSecretRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateIssuerRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateOperationRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificatePolicyRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateRequest; +import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; +import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; import com.microsoft.azure.RestClient; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java similarity index 99% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 058578a8e63a7..fe8f4ed5fd181 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -4,7 +4,7 @@ * regenerated. */ -package com.microsoft.azure.keyvault.implementation; +package com.microsoft.azure.keyvault; import com.google.common.base.Joiner; import com.google.common.reflect.TypeToken; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/ObjectIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java similarity index 99% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/ObjectIdentifier.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java index c564a8db45dd4..ed9d5e2c01531 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/ObjectIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java @@ -16,7 +16,7 @@ * */ -package com.microsoft.azure.keyvault.implementation; +package com.microsoft.azure.keyvault; import java.net.URI; import java.net.URISyntaxException; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/SecretIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java similarity index 95% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/SecretIdentifier.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java index 477304b1024d8..c83faa61cdfae 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/SecretIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java @@ -16,7 +16,7 @@ * */ -package com.microsoft.azure.keyvault.implementation; +package com.microsoft.azure.keyvault; public final class SecretIdentifier extends ObjectIdentifier { public static boolean isSecretIdentifier(String identifier) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java index f3f4e48edb419..a3f94c3c49704 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java @@ -156,6 +156,14 @@ private boolean isValidChallenge(String authenticateHeader, String authChallenge } /** + * Abstract method to be implemented + * + * @param authorization Identifier of the authority, a URL. + * @param resource Identifier of the target resource that is the recipient of the requested token, a URL. + * @param scope The scope of the authentication request. + * + * @return The access token + * * Answers a server challenge with a token header. *

* Implementations typically use ADAL to get a token, as performed in the diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java deleted file mode 100644 index 1251b3303e03b..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. - -/** - * This package contains the implementation classes for KeyVaultClient. - * Perform cryptographic key operations and vault operations against the Key Vault service. - */ -package com.microsoft.azure.keyvault.implementation; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java index a67937cc1d0d9..c23d371ba632f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java @@ -6,9 +6,9 @@ package com.microsoft.azure.keyvault.models; -import com.microsoft.azure.keyvault.implementation.CertificateIdentifier; -import com.microsoft.azure.keyvault.implementation.KeyIdentifier; -import com.microsoft.azure.keyvault.implementation.SecretIdentifier; +import com.microsoft.azure.keyvault.CertificateIdentifier; +import com.microsoft.azure.keyvault.KeyIdentifier; +import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.rest.Base64Url; import java.io.IOException; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java index 4cf89baf08bf2..5ba8c54f6625b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java @@ -7,9 +7,10 @@ package com.microsoft.azure.keyvault.models; import java.util.Map; + +import com.microsoft.azure.keyvault.CertificateIdentifier; import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; -import com.microsoft.azure.keyvault.implementation.CertificateIdentifier; /** * The certificate item containing certificate metadata. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java index d455ed507da3f..ff4f78da2dc8b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java @@ -12,7 +12,7 @@ import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.keyvault.implementation.CertificateOperationIdentifier; +import com.microsoft.azure.keyvault.CertificateOperationIdentifier; /** * A certificate operation is returned in case of async requests. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java index 9ebcdc6161c6e..028d42733ec8a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -12,7 +12,7 @@ import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.keyvault.implementation.IssuerIdentifier; +import com.microsoft.azure.keyvault.IssuerIdentifier; /** * The issuer for Key Vault certificate. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index 744bc82515910..4bda5d4a98dd6 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -12,7 +12,7 @@ import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.keyvault.implementation.KeyIdentifier; +import com.microsoft.azure.keyvault.KeyIdentifier; /** * A KeyBundle consisting of a WebKey plus its Attributes. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index 4b7ed86c6f657..b57cbab5a54c1 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -8,7 +8,7 @@ import java.util.Map; -import com.microsoft.azure.keyvault.implementation.KeyIdentifier; +import com.microsoft.azure.keyvault.KeyIdentifier; /** * The key item containing key metadata. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index f4dea9b870674..039ebc020068d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -12,7 +12,7 @@ import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.keyvault.implementation.SecretIdentifier; +import com.microsoft.azure.keyvault.SecretIdentifier; /** * A Secret consisting of a value, id and its attributes. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index 1eab37d1fe431..6e01d6c795fa0 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -8,7 +8,7 @@ import java.util.Map; -import com.microsoft.azure.keyvault.implementation.SecretIdentifier; +import com.microsoft.azure.keyvault.SecretIdentifier; /** * The secret item containing secret metadata. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java similarity index 98% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateCertificateRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java index 08825d02bcbff..0a968581b6727 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import java.util.ArrayList; import java.util.Collections; @@ -82,6 +82,7 @@ public Builder withTags(Map tags) { /** * builds the {@link CreateCertificateRequest} object + * @return the {@link CreateCertificateRequest} object */ public CreateCertificateRequest build() { return new CreateCertificateRequest(this); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java similarity index 97% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateKeyRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java index 23a2c464056c9..e8c57f1b1723d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/CreateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import java.util.ArrayList; import java.util.Collections; @@ -97,6 +97,7 @@ public Builder withTags(Map tags) { /** * builds the {@link CreateKeyRequest} object + * @return the {@link CreateKeyRequest} object */ public CreateKeyRequest build() { return new CreateKeyRequest(this); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java similarity index 98% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportCertificateRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java index 3b3ac0b615dec..c13d98a03c551 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import java.util.ArrayList; import java.util.Collections; @@ -102,6 +102,7 @@ public Builder withTags(Map tags) { /** * builds the {@link ImportCertificateRequest} object + * @return the {@link ImportCertificateRequest} object */ public ImportCertificateRequest build() { return new ImportCertificateRequest(this); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java similarity index 97% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportKeyRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java index 7862870103949..427bc79e2108f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/ImportKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import java.util.ArrayList; import java.util.Collections; @@ -83,6 +83,7 @@ public Builder withTags(Map tags) { /** * builds the {@link ImportKeyRequest} object + * @return the {@link ImportKeyRequest} object */ public ImportKeyRequest build() { return new ImportKeyRequest(this); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/MergeCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java similarity index 97% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/MergeCertificateRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java index 708dc6ee19236..524fb1cb996f1 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/MergeCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import java.util.ArrayList; import java.util.Collections; @@ -67,6 +67,7 @@ public Builder withTags(Map tags) { /** * builds the {@link MergeCertificateRequest} object + * @return the {@link MergeCertificateRequest} object */ public MergeCertificateRequest build() { return new MergeCertificateRequest(this); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java similarity index 95% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetCertificateIssuerRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java index 9a45b5233c24b..81c0eef5396bb 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetCertificateIssuerRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import com.microsoft.azure.keyvault.models.IssuerAttributes; import com.microsoft.azure.keyvault.models.IssuerBundle; @@ -45,6 +45,7 @@ public Builder withIssuer(IssuerBundle issuer) { /** * builds the {@link SetCertificateIssuerRequest} object + * @return the {@link SetCertificateIssuerRequest} object */ public SetCertificateIssuerRequest build() { return new SetCertificateIssuerRequest(this); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetSecretRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java similarity index 97% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetSecretRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java index f6bebdb17199e..7ba775a2595d6 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/SetSecretRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import java.util.Collections; import java.util.Map; @@ -79,6 +79,7 @@ public Builder withTags(Map tags) { /** * builds the {@link SetSecretRequest} object + * @return the {@link SetSecretRequest} object */ public SetSecretRequest build() { return new SetSecretRequest(this); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java similarity index 95% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateIssuerRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java index c1a9f151e16c9..13b512b0392a5 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateIssuerRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import com.microsoft.azure.keyvault.models.IssuerAttributes; import com.microsoft.azure.keyvault.models.IssuerBundle; @@ -45,6 +45,7 @@ public Builder withIssuer(IssuerBundle issuer) { /** * builds the {@link UpdateCertificateIssuerRequest} object + * @return the {@link UpdateCertificateIssuerRequest} object */ public UpdateCertificateIssuerRequest build() { return new UpdateCertificateIssuerRequest(this); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateOperationRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java similarity index 95% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateOperationRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java index 406e619809471..53e9f6e40858f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateOperationRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import com.microsoft.azure.keyvault.models.CertificateOperation; @@ -44,6 +44,7 @@ public Builder withCancellationRequested(Boolean cancellationRequested) { /** * builds the {@link UpdateCertificateOperationRequest} object + * @return the {@link UpdateCertificateOperationRequest} object */ public UpdateCertificateOperationRequest build() { return new UpdateCertificateOperationRequest(this); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificatePolicyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java similarity index 97% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificatePolicyRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java index ab32687a7559d..b3c0e616c47de 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificatePolicyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import java.util.ArrayList; @@ -52,6 +52,7 @@ public Builder withPolicy(CertificatePolicy certificatePolicy) { /** * builds the {@link UpdateCertificatePolicyRequest} object + * @return the {@link UpdateCertificatePolicyRequest} object */ public UpdateCertificatePolicyRequest build() { return new UpdateCertificatePolicyRequest(this); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java similarity index 97% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java index e80d84acbe77b..8cf417fd3ee5b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java @@ -1,4 +1,4 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import java.util.Collections; import java.util.Map; @@ -74,6 +74,7 @@ public Builder withTags(Map tags) { /** * builds the {@link UpdateCertificateRequest} object + * @return the {@link UpdateCertificateRequest} object */ public UpdateCertificateRequest build() { return new UpdateCertificateRequest(this); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java similarity index 96% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateKeyRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java index 7e0f7fa2f23f6..7a0eea55027ab 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java @@ -1,11 +1,11 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import com.microsoft.azure.keyvault.implementation.KeyIdentifier; +import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.models.KeyAttributes; public class UpdateKeyRequest { @@ -107,6 +107,7 @@ public Builder withTags(Map tags) { /** * builds the {@link UpdateKeyRequest} object + * @return the {@link UpdateKeyRequest} object */ public UpdateKeyRequest build() { return new UpdateKeyRequest(this); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateSecretRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java similarity index 96% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateSecretRequest.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java index 33df1aa2a48da..a777820320195 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/requests/UpdateSecretRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java @@ -1,9 +1,9 @@ -package com.microsoft.azure.keyvault.implementation.requests; +package com.microsoft.azure.keyvault.requests; import java.util.Collections; import java.util.Map; -import com.microsoft.azure.keyvault.implementation.SecretIdentifier; +import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.azure.keyvault.models.SecretAttributes; public class UpdateSecretRequest { @@ -97,6 +97,7 @@ public Builder withTags(Map tags) { /** * builds the {@link UpdateSecretRequest} object + * @return the {@link UpdateSecretRequest} object */ public UpdateSecretRequest build() { return new UpdateSecretRequest(this); diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index 12c1922493e48..c556c3584aad2 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -52,12 +52,8 @@ import org.junit.Test; import com.microsoft.azure.PagedList; -import com.microsoft.azure.keyvault.implementation.CertificateIdentifier; -import com.microsoft.azure.keyvault.implementation.SecretIdentifier; -import com.microsoft.azure.keyvault.implementation.requests.CreateCertificateRequest; -import com.microsoft.azure.keyvault.implementation.requests.ImportCertificateRequest; -import com.microsoft.azure.keyvault.implementation.requests.SetCertificateIssuerRequest; -import com.microsoft.azure.keyvault.implementation.requests.UpdateCertificateIssuerRequest; +import com.microsoft.azure.keyvault.CertificateIdentifier; +import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.azure.keyvault.models.AdministratorDetails; import com.microsoft.azure.keyvault.models.CertificateBundle; import com.microsoft.azure.keyvault.models.Contact; @@ -73,6 +69,10 @@ import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.models.SecretProperties; import com.microsoft.azure.keyvault.models.X509CertificateProperties; +import com.microsoft.azure.keyvault.requests.CreateCertificateRequest; +import com.microsoft.azure.keyvault.requests.ImportCertificateRequest; +import com.microsoft.azure.keyvault.requests.SetCertificateIssuerRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateIssuerRequest; public class CertificateOperationsTest extends KeyVaultClientIntegrationTestBase { @@ -656,9 +656,8 @@ public void importCertificatePkcs12() throws Exception { Assert.assertNotNull(certificateBundle.sid()); Assert.assertNotNull(certificateBundle.x5t()); - //TODO the x5t is different - fix it - //Assert.assertTrue(toHexString(certificateBundle.x5t()).equalsIgnoreCase("7cb8b7539d87ba7215357b9b9049dff2d3fa59ba")); - + Assert.assertTrue(toHexString(certificateBundle.x5t()).equalsIgnoreCase("7cb8b7539d87ba7215357b9b9049dff2d3fa59ba")); + // Load the CER part into X509Certificate object Assert.assertNotNull(certificateBundle.cer()); ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); @@ -1251,9 +1250,19 @@ private static void verifyRSAKeyPair(KeyPair keyPair) throws NoSuchAlgorithmExce } private String toHexString(byte[] x5t) { + if(x5t == null) return ""; - return new String(x5t, StandardCharsets.UTF_8).replace("-", ""); + StringBuilder hexString = new StringBuilder(); + for (int i = 0; i < x5t.length; i++) { + String hex = Integer.toHexString(0xFF & x5t[i]); + if (hex.length() == 1) { + hexString.append('0'); + } + hexString.append(hex); + } + + return hexString.toString().replace("-", ""); } } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 963985e7b6994..08ff519858b73 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -39,14 +39,14 @@ import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.PagedList; -import com.microsoft.azure.keyvault.implementation.KeyIdentifier; -import com.microsoft.azure.keyvault.implementation.requests.CreateKeyRequest; -import com.microsoft.azure.keyvault.implementation.requests.ImportKeyRequest; -import com.microsoft.azure.keyvault.implementation.requests.UpdateKeyRequest; +import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.models.KeyItem; import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyResult; +import com.microsoft.azure.keyvault.requests.CreateKeyRequest; +import com.microsoft.azure.keyvault.requests.ImportKeyRequest; +import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java index 412e9591fbd8f..be6906865cd25 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java @@ -28,8 +28,6 @@ import org.junit.Before; import org.junit.BeforeClass; - -import com.microsoft.azure.keyvault.implementation.KeyVaultClient; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; @@ -37,6 +35,7 @@ import com.microsoft.aad.adal4j.AuthenticationContext; import com.microsoft.aad.adal4j.AuthenticationResult; import com.microsoft.aad.adal4j.ClientCredential; +import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.authentication.KeyVaultCredentials; public class KeyVaultClientIntegrationTestBase { diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index 9ca02891c2b50..aac73d56cf5c1 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -28,10 +28,10 @@ import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.PagedList; -import com.microsoft.azure.keyvault.implementation.SecretIdentifier; -import com.microsoft.azure.keyvault.implementation.requests.SetSecretRequest; -import com.microsoft.azure.keyvault.implementation.requests.UpdateSecretRequest; +import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.azure.keyvault.models.SecretItem; +import com.microsoft.azure.keyvault.requests.SetSecretRequest; +import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; public class SecretOperationsTest extends KeyVaultClientIntegrationTestBase { From ff3276e9311267feeb719bc6a2eb9cf2bec48959 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Wed, 3 Aug 2016 13:55:17 -0700 Subject: [PATCH 09/56] changing x5t to x509Thumbprint, adding key ID to secret and updating documentations for the WebKey types to reflect the accepted types --- .../azure/keyvault/KeyVaultClientImpl.java | 51 ++++++------ .../keyvault/models/CertificateBundle.java | 14 ++-- .../keyvault/models/CertificateItem.java | 24 +++--- .../azure/keyvault/models/JsonWebKey.java | 3 +- .../keyvault/models/KeyCreateParameters.java | 5 +- .../models/KeyOperationsParameters.java | 2 +- .../azure/keyvault/models/KeyProperties.java | 2 +- .../keyvault/models/KeySignParameters.java | 77 +++++++++++++++++++ .../keyvault/models/KeyVerifyParameters.java | 3 +- .../azure/keyvault/models/SecretBundle.java | 26 ++++++- .../azure/keyvault/models/package-info.java | 2 +- .../azure/keyvault/package-info.java | 2 +- .../test/CertificateOperationsTest.java | 16 ++-- 13 files changed, 166 insertions(+), 61 deletions(-) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index fe8f4ed5fd181..2cb4ea69a81db 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -33,6 +33,7 @@ import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.models.KeyOperationsParameters; import com.microsoft.azure.keyvault.models.KeyRestoreParameters; +import com.microsoft.azure.keyvault.models.KeySignParameters; import com.microsoft.azure.keyvault.models.KeyUpdateParameters; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyParameters; @@ -277,7 +278,7 @@ interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/sign") - Call sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeySignParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/verify") @@ -434,7 +435,7 @@ interface KeyVaultClientService { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. For valid key types, see WebKeyTypes. + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -473,7 +474,7 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. For valid key types, see WebKeyTypes. + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object @@ -529,8 +530,8 @@ public void onResponse(Call call, Response response) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. For valid key types, see WebKeyTypes. - * @param keySize Size of the key + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param keySize The key size in bytes. e.g. 1024 or 2048. * @param keyOps * @param keyAttributes * @param tags Application-specific metadata in the form of key-value pairs @@ -571,8 +572,8 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. For valid key types, see WebKeyTypes. - * @param keySize Size of the key + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param keySize The key size in bytes. e.g. 1024 or 2048. * @param keyOps * @param keyAttributes * @param tags Application-specific metadata in the form of key-value pairs @@ -1650,12 +1651,12 @@ private ServiceResponse restoreKeyDelegate(Response res } /** - * Encrypts a single block of data. The amount of data that may be encrypted is determined. + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization @@ -1690,12 +1691,12 @@ public ServiceResponse encrypt(String vaultBaseUrl, String k } /** - * Encrypts a single block of data. The amount of data that may be encrypted is determined. + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null @@ -1761,7 +1762,7 @@ private ServiceResponse encryptDelegate(Response decrypt(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null @@ -1867,7 +1868,7 @@ private ServiceResponse decryptDelegate(Response sign(String vaultBaseUrl, String keyN if (value == null) { throw new IllegalArgumentException("Parameter value is required and cannot be null."); } - KeyOperationsParameters parameters = new KeyOperationsParameters(); + KeySignParameters parameters = new KeySignParameters(); parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -1907,7 +1908,7 @@ public ServiceResponse sign(String vaultBaseUrl, String keyN * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null @@ -1941,7 +1942,7 @@ public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVers serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); return null; } - KeyOperationsParameters parameters = new KeyOperationsParameters(); + KeySignParameters parameters = new KeySignParameters(); parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -1973,7 +1974,7 @@ private ServiceResponse signDelegate(Response * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param digest The digest used for signing * @param signature The signature to be verified * @throws KeyVaultErrorException exception thrown from REST call @@ -2018,7 +2019,7 @@ public ServiceResponse verify(String vaultBaseUrl, String keyNa * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param digest The digest used for signing * @param signature The signature to be verified * @param serviceCallback the async ServiceCallback to handle successful and failed responses. @@ -2090,7 +2091,7 @@ private ServiceResponse verifyDelegate(Response r * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization @@ -2130,7 +2131,7 @@ public ServiceResponse wrapKey(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null @@ -2196,7 +2197,7 @@ private ServiceResponse wrapKeyDelegate(Response unwrapKey(String vaultBaseUrl, String * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null @@ -3740,7 +3741,7 @@ private ServiceResponse> getCertificateIssuersDe } /** - * Sets the certificate contacts for the specified vault. + * Sets the specified certificate issuer. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. @@ -3770,7 +3771,7 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S } /** - * Sets the certificate contacts for the specified vault. + * Sets the specified certificate issuer. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java index c23d371ba632f..7b42c24f3d1cb 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java @@ -43,8 +43,8 @@ public class CertificateBundle { /** * Thumbprint of the certificate. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) - private Base64Url x5t; + @JsonProperty(value = "x5t", access = JsonProperty.Access.WRITE_ONLY) + private Base64Url x509Thumbprint; /** * The management policy. @@ -100,15 +100,15 @@ public String sid() { } /** - * Get the x5t value. + * Get the x509Thumbprint value. * - * @return the x5t value + * @return the x509Thumbprint value */ - public byte[] x5t() { - if (this.x5t == null) { + public byte[] x509Thumbprint() { + if (this.x509Thumbprint == null) { return null; } - return this.x5t.getDecodedBytes(); + return this.x509Thumbprint.getDecodedBytes(); } /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java index 5ba8c54f6625b..f0cff43eaa2e1 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java @@ -35,7 +35,7 @@ public class CertificateItem { * Thumbprint of the certificate. */ @JsonProperty(value = "x5t") - private Base64Url x5T; + private Base64Url x509Thumbprint; /** * Get the id value. @@ -98,28 +98,28 @@ public CertificateItem withTags(Map tags) { } /** - * Get the x5T value. + * Get the x509Thumbprint value. * - * @return the x5T value + * @return the x509Thumbprint value */ - public byte[] x5T() { - if (this.x5T == null) { + public byte[] x509Thumbprint() { + if (this.x509Thumbprint == null) { return null; } - return this.x5T.getDecodedBytes(); + return this.x509Thumbprint.getDecodedBytes(); } /** - * Set the x5T value. + * Set the x509Thumbprint value. * - * @param x5T the x5T value to set + * @param x509Thumbprint the x509Thumbprint value to set * @return the CertificateItem object itself. */ - public CertificateItem withX5T(byte[] x5T) { - if (x5T == null) { - this.x5T = null; + public CertificateItem withX509Thumbprint(byte[] x509Thumbprint) { + if (x509Thumbprint == null) { + this.x509Thumbprint = null; } else { - this.x5T = Base64Url.encode(x5T); + this.x509Thumbprint = Base64Url.encode(x509Thumbprint); } return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java index 15df227b48437..f1a4f586fe796 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java @@ -37,7 +37,8 @@ public class JsonWebKey { private String kid; /** - * Key type, usually RSA. + * Key type, usually RSA. Possible values include: 'EC', 'RSA', 'RSA-HSM', + * 'oct'. */ private String kty; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java index 4c384abeac0d7..1a8bad0f1a74c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java @@ -15,13 +15,14 @@ */ public class KeyCreateParameters { /** - * The type of key to create. For valid key types, see WebKeyTypes. + * The type of key to create. Valid key types, see JsonWebKeyType. + * Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'. */ @JsonProperty(required = true) private String kty; /** - * Size of the key. + * The key size in bytes. e.g. 1024 or 2048. */ @JsonProperty(value = "key_size") private Integer keySize; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java index 0115785ea2798..5c27239f943d0 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java @@ -14,7 +14,7 @@ */ public class KeyOperationsParameters { /** - * algorithm identifier. + * algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5'. */ @JsonProperty(value = "alg", required = true) private String algorithm; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java index c88ff228583e6..816b27a2fe2e6 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java @@ -24,7 +24,7 @@ public class KeyProperties { private String keyType; /** - * The key size. + * The key size in bytes. e.g. 1024 or 2048. */ @JsonProperty(value = "key_size") private Integer keySize; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java new file mode 100644 index 0000000000000..c2c81892a5111 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java @@ -0,0 +1,77 @@ +/** + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +import com.microsoft.rest.Base64Url; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The key operations parameters. + */ +public class KeySignParameters { + /** + * The signing/verification algorithm identifier. For more information on + * possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible + * values include: 'RS256', 'RS384', 'RS512', 'RSNULL'. + */ + @JsonProperty(value = "alg", required = true) + private String algorithm; + + /** + * The value property. + */ + @JsonProperty(required = true) + private Base64Url value; + + /** + * Get the algorithm value. + * + * @return the algorithm value + */ + public String algorithm() { + return this.algorithm; + } + + /** + * Set the algorithm value. + * + * @param algorithm the algorithm value to set + * @return the KeySignParameters object itself. + */ + public KeySignParameters withAlgorithm(String algorithm) { + this.algorithm = algorithm; + return this; + } + + /** + * Get the value value. + * + * @return the value value + */ + public byte[] value() { + if (this.value == null) { + return null; + } + return this.value.getDecodedBytes(); + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the KeySignParameters object itself. + */ + public KeySignParameters withValue(byte[] value) { + if (value == null) { + this.value = null; + } else { + this.value = Base64Url.encode(value); + } + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java index 6c2d0d6a56494..300284101634b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java @@ -15,7 +15,8 @@ public class KeyVerifyParameters { /** * The signing/verification algorithm. For more information on possible - * algorithm types, see JsonWebKeySignatureAlgorithm. + * algorithm types, see JsonWebKeySignatureAlgorithm. Possible values + * include: 'RS256', 'RS384', 'RS512', 'RSNULL'. */ @JsonProperty(value = "alg", required = true) private String algorithm; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index 039ebc020068d..9b0beebe8efd6 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -43,6 +43,11 @@ public class SecretBundle { */ private Map tags; + /** + * The key id for certificate. + */ + private String kid; + /** * Get the value value. * @@ -143,14 +148,33 @@ public SecretBundle withTags(Map tags) { return this; } + /** + * Get the kid value. + * + * @return the kid value + */ + public String kid() { + return this.kid; + } + /** + * Set the kid value. + * + * @param kid the kid value to set + * @return the SecretBundle object itself. + */ + public SecretBundle withKid(String kid) { + this.kid = kid; + return this; + } + public SecretIdentifier secretIdentifier() { if (id() == null || id().length() == 0) { return null; } return new SecretIdentifier(id()); } - + @Override public String toString() { ObjectMapper mapper = new ObjectMapper(); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java index 91ac9f584403a..f5cbd38e531fe 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java @@ -4,6 +4,6 @@ /** * This package contains the models classes for KeyVaultClient. - * Perform cryptographic key operations and vault operations against the Key Vault service. + * Performs cryptographic key operations and vault operations against the Key Vault service. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java index 140c3c675f762..6c07835d77ea2 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java @@ -4,6 +4,6 @@ /** * This package contains the classes for KeyVaultClient. - * Perform cryptographic key operations and vault operations against the Key Vault service. + * Performs cryptographic key operations and vault operations against the Key Vault service. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index c556c3584aad2..daa3f644c3ca6 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -149,7 +149,7 @@ public void createSelfSignedCertificatePkcs12() throws Exception { Assert.assertNotNull(certificateBundle.id()); Assert.assertNotNull(certificateBundle.keyIdentifier()); Assert.assertNotNull(certificateBundle.secretIdentifier()); - Assert.assertNotNull(certificateBundle.x5t()); + Assert.assertNotNull(certificateBundle.x509Thumbprint()); // Load the CER part into X509Certificate object Assert.assertNotNull(certificateBundle.cer()); @@ -247,7 +247,7 @@ public void createSelfSignedCertificatePem() throws Exception { Assert.assertNotNull(certificateBundle.id()); Assert.assertNotNull(certificateBundle.kid()); Assert.assertNotNull(certificateBundle.sid()); - Assert.assertNotNull(certificateBundle.x5t()); + Assert.assertNotNull(certificateBundle.x509Thumbprint()); // Load the CER part into X509Certificate object Assert.assertNotNull(certificateBundle.cer()); @@ -376,7 +376,7 @@ public void createCertificatePkcs12() throws Exception { Assert.assertNotNull(certificateBundle.id()); Assert.assertNotNull(certificateBundle.keyIdentifier()); Assert.assertNotNull(certificateBundle.secretIdentifier()); - Assert.assertNotNull(certificateBundle.x5t()); + Assert.assertNotNull(certificateBundle.x509Thumbprint()); Assert.assertNotNull(certificateBundle.policy()); Assert.assertNotNull(certificateBundle.policy().issuerReference()); Assert.assertNotNull(certificateBundle.policy().issuerReference().name()); @@ -514,7 +514,7 @@ public void createCertificatePem() throws Exception { Assert.assertNotNull(certificateBundle.id()); Assert.assertNotNull(certificateBundle.kid()); Assert.assertNotNull(certificateBundle.sid()); - Assert.assertNotNull(certificateBundle.x5t()); + Assert.assertNotNull(certificateBundle.x509Thumbprint()); Assert.assertNotNull(certificateBundle.policy()); Assert.assertNotNull(certificateBundle.policy().issuerReference()); Assert.assertNotNull(certificateBundle.policy().issuerReference().name()); @@ -654,9 +654,9 @@ public void importCertificatePkcs12() throws Exception { Assert.assertNotNull(certificateBundle.id()); Assert.assertNotNull(certificateBundle.kid()); Assert.assertNotNull(certificateBundle.sid()); - Assert.assertNotNull(certificateBundle.x5t()); + Assert.assertNotNull(certificateBundle.x509Thumbprint()); - Assert.assertTrue(toHexString(certificateBundle.x5t()).equalsIgnoreCase("7cb8b7539d87ba7215357b9b9049dff2d3fa59ba")); + Assert.assertTrue(toHexString(certificateBundle.x509Thumbprint()).equalsIgnoreCase("7cb8b7539d87ba7215357b9b9049dff2d3fa59ba")); // Load the CER part into X509Certificate object Assert.assertNotNull(certificateBundle.cer()); @@ -793,8 +793,8 @@ public void importCertificatePem() throws Exception { Assert.assertNotNull(certificateBundle.id()); Assert.assertNotNull(certificateBundle.kid()); Assert.assertNotNull(certificateBundle.sid()); - Assert.assertNotNull(certificateBundle.x5t()); - Assert.assertTrue(toHexString(certificateBundle.x5t()).equalsIgnoreCase("d86db6736c335f08ef39aa27ef83836e8eba95b9")); + Assert.assertNotNull(certificateBundle.x509Thumbprint()); + Assert.assertTrue(toHexString(certificateBundle.x509Thumbprint()).equalsIgnoreCase("d86db6736c335f08ef39aa27ef83836e8eba95b9")); // Load the CER part into X509Certificate object Assert.assertNotNull(certificateBundle.cer()); From 88ac2e838b9f224489d1e1487abc30643ac5fe13 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Fri, 5 Aug 2016 15:34:23 -0700 Subject: [PATCH 10/56] Use Guava Futures --- .../microsoft/azure/keyvault/core/IKey.java | 17 ++- .../azure/keyvault/core/IKeyResolver.java | 4 +- .../keyvault/cryptography/FutureBase.java | 71 --------- .../FutureExecutionException.java | 45 ------ .../cryptography/FutureImmediate.java | 56 ------- .../azure/keyvault/cryptography/RsaKey.java | 53 +++---- .../keyvault/cryptography/SymmetricKey.java | 47 +++--- azure-keyvault-extensions/pom.xml | 5 + .../extensions/AggregateKeyResolver.java | 6 +- .../extensions/CachingKeyResolver.java | 11 +- .../keyvault/extensions/FutureAdapter.java | 138 ------------------ .../azure/keyvault/extensions/FutureBase.java | 61 -------- .../extensions/FutureExecutionException.java | 45 ------ .../keyvault/extensions/FutureImmediate.java | 56 ------- .../extensions/FutureServiceCall.java | 82 +++++++++++ .../keyvault/extensions/KeyVaultKey.java | 66 ++++----- .../extensions/KeyVaultKeyResolver.java | 38 +++-- .../test/CachingKeyResolverTest.java | 5 +- 18 files changed, 210 insertions(+), 596 deletions(-) delete mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureBase.java delete mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureExecutionException.java delete mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureImmediate.java delete mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureAdapter.java delete mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureBase.java delete mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureExecutionException.java delete mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureImmediate.java create mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureServiceCall.java diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java index c604c4b5c3052..52852f34c5cd3 100644 --- a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java @@ -20,11 +20,12 @@ import java.io.Closeable; import java.security.NoSuchAlgorithmException; -import java.util.concurrent.Future; - import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; +import com.google.common.util.concurrent.ListenableFuture; + + /** * Interface for representing cryptographic keys with the Microsoft Azure Key * Vault libraries. @@ -80,7 +81,7 @@ public interface IKey extends Closeable { * @return A {@link:Future} containing the plain text * @throws NoSuchAlgorithmException */ - Future decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm) throws NoSuchAlgorithmException; + ListenableFuture decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm) throws NoSuchAlgorithmException; /** * Encrypts the specified plain text. Note that not all algorithms require, @@ -99,7 +100,7 @@ public interface IKey extends Closeable { * tag and the algorithm that was used * @throws NoSuchAlgorithmException */ - Future> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm) throws NoSuchAlgorithmException; + ListenableFuture> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm) throws NoSuchAlgorithmException; /** * Wraps (encrypts) the specified symmetric key material using the specified @@ -114,7 +115,7 @@ public interface IKey extends Closeable { * that was used * @throws NoSuchAlgorithmException */ - Future> wrapKeyAsync(final byte[] key, final String algorithm) throws NoSuchAlgorithmException; + ListenableFuture> wrapKeyAsync(final byte[] key, final String algorithm) throws NoSuchAlgorithmException; /** * Unwraps (decrypts) the specified encryped key material. @@ -126,7 +127,7 @@ public interface IKey extends Closeable { * @return A {@link:Future} containing the unwrapped key * @throws NoSuchAlgorithmException */ - Future unwrapKeyAsync(final byte[] encryptedKey, final String algorithm) throws NoSuchAlgorithmException; + ListenableFuture unwrapKeyAsync(final byte[] encryptedKey, final String algorithm) throws NoSuchAlgorithmException; /** * Signs the specified digest using the specified algorithm, or the keys @@ -138,7 +139,7 @@ public interface IKey extends Closeable { * The signature algorithm to use * @return A {@link:Future} containing the signature and the algorithm used. */ - Future> signAsync(final byte[] digest, final String algorithm); + ListenableFuture> signAsync(final byte[] digest, final String algorithm); /** * Verifies the supplied signature value using the supplied digest and @@ -152,5 +153,5 @@ public interface IKey extends Closeable { * The algorithm to use, must be provided * @return A {@link:Future} containing a boolean result */ - Future verifyAsync(final byte[] digest, final byte[] signature, final String algorithm); + ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm); } diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java index 2a3238e5716d9..6fa7787c597d9 100644 --- a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java @@ -19,7 +19,7 @@ package com.microsoft.azure.keyvault.core; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; +import com.google.common.util.concurrent.ListenableFuture; public interface IKeyResolver { @@ -35,5 +35,5 @@ public interface IKeyResolver { * @throws InterruptedException * @throws ExecutionException */ - Future resolveKeyAsync(String kid); + ListenableFuture resolveKeyAsync(String kid); } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureBase.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureBase.java deleted file mode 100644 index 3f2a53ebd57b2..0000000000000 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureBase.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.cryptography; - -import java.util.concurrent.Future; - -abstract class FutureBase implements Future { - - private boolean _cancelled = false; - private boolean _done = false; - - protected FutureBase() { - this(false, false); - } - - protected FutureBase(boolean done) { - this(done, false); - } - - protected FutureBase(boolean done, boolean cancelled) { - _done = done; - _cancelled = cancelled; - } - - protected void setDone() { - _cancelled = false; - _done = true; - } - - protected void setCancelled() { - _cancelled = true; - _done = true; - } - - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - - // mark cancelled - _cancelled = true; - - return _cancelled; - } - - @Override - public boolean isCancelled() { - - return _cancelled; - } - - @Override - public boolean isDone() { - - return _done; - } -} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureExecutionException.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureExecutionException.java deleted file mode 100644 index f070e7149eebb..0000000000000 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureExecutionException.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.cryptography; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -class FutureExecutionException extends FutureBase { - - private final ExecutionException _e; - - FutureExecutionException(Throwable t) { - super(true,false); - - _e = new ExecutionException(t); - } - - @Override - public T get() throws InterruptedException, ExecutionException { - throw _e; - } - - @Override - public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - throw _e; - } - -} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureImmediate.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureImmediate.java deleted file mode 100644 index 35b6e2ecd9344..0000000000000 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/FutureImmediate.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.cryptography; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -class FutureImmediate extends FutureBase { - - private final T _result; - - FutureImmediate(T result) { - super(true); - - _result = result; - } - - @Override - public T get() throws InterruptedException, ExecutionException { - - // throw if cancelled - if (isCancelled()) { - throw new InterruptedException(); - } - - return _result; - } - - @Override - public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - - // throw if cancelled - if (isCancelled()) { - throw new InterruptedException(); - } - - return _result; - } -} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java index e34910c847a9a..c64359259927f 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java @@ -24,22 +24,23 @@ import java.security.NoSuchAlgorithmException; import java.security.interfaces.RSAPublicKey; import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; +import com.google.common.util.concurrent.AbstractFuture; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; -import com.microsoft.azure.keyvault.cryptography.FutureBase; -import com.microsoft.azure.keyvault.cryptography.FutureExecutionException; import com.microsoft.azure.keyvault.cryptography.Strings; public class RsaKey implements IKey { - class FutureDecrypt extends FutureBase { + class FutureDecrypt extends AbstractFuture { private final byte[] _data; private final ICryptoTransform _transform; @@ -68,7 +69,7 @@ public byte[] get(long timeout, TimeUnit unit) throws InterruptedException, Exec } } - class FutureEncrypt extends FutureBase> { + class FutureEncrypt extends AbstractFuture> { private final String _algorithm; private final byte[] _data; @@ -99,7 +100,7 @@ public Triple get(long timeout, TimeUnit unit) throws In } } - class FutureWrap extends FutureBase> { + class FutureWrap extends AbstractFuture> { private final String _algorithm; private final byte[] _data; @@ -198,7 +199,7 @@ public String getKid() { } @Override - public Future decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm) throws NoSuchAlgorithmException { + public ListenableFuture decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm) throws NoSuchAlgorithmException { if (ciphertext == null) { throw new IllegalArgumentException("ciphertext"); @@ -217,21 +218,21 @@ public Future decryptAsync(final byte[] ciphertext, final byte[] iv, fin AsymmetricEncryptionAlgorithm algo = (AsymmetricEncryptionAlgorithm)baseAlgorithm; - ICryptoTransform transform; - Future result; + ICryptoTransform transform; + ListenableFuture result; try { transform = algo.CreateDecryptor(_keyPair); result = new FutureDecrypt(transform, ciphertext); } catch (Exception e) { - result = new FutureExecutionException(e); + result = Futures.immediateFailedFuture(e); } return result; } @Override - public Future> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm) throws NoSuchAlgorithmException { + public ListenableFuture> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm) throws NoSuchAlgorithmException { if (plaintext == null) { throw new IllegalArgumentException("plaintext"); @@ -247,21 +248,21 @@ public Future> encryptAsync(final byte[] plaintex AsymmetricEncryptionAlgorithm algo = (AsymmetricEncryptionAlgorithm)baseAlgorithm; - ICryptoTransform transform; - Future> result; + ICryptoTransform transform; + ListenableFuture> result; try { transform = algo.CreateEncryptor(_keyPair); result = new FutureEncrypt(algorithmName, plaintext, transform); } catch (Exception e) { - result = new FutureExecutionException>(e); + result = Futures.immediateFailedFuture(e); } return result; } @Override - public Future> wrapKeyAsync(final byte[] key, final String algorithm) throws NoSuchAlgorithmException { + public ListenableFuture> wrapKeyAsync(final byte[] key, final String algorithm) throws NoSuchAlgorithmException { if (key == null) { throw new IllegalArgumentException("key"); @@ -277,21 +278,21 @@ public Future> wrapKeyAsync(final byte[] key, final String AsymmetricEncryptionAlgorithm algo = (AsymmetricEncryptionAlgorithm)baseAlgorithm; - ICryptoTransform transform; - Future> result; + ICryptoTransform transform; + ListenableFuture> result; try { transform = algo.CreateEncryptor(_keyPair); result = new FutureWrap(algorithmName, key, transform); } catch (Exception e) { - result = new FutureExecutionException>(e); + result = Futures.immediateFailedFuture(e); } return result; } @Override - public Future unwrapKeyAsync(final byte[] encryptedKey, final String algorithm) throws NoSuchAlgorithmException { + public ListenableFuture unwrapKeyAsync(final byte[] encryptedKey, final String algorithm) throws NoSuchAlgorithmException { if (encryptedKey == null) { throw new IllegalArgumentException("encryptedKey "); @@ -311,27 +312,27 @@ public Future unwrapKeyAsync(final byte[] encryptedKey, final String alg AsymmetricEncryptionAlgorithm algo = (AsymmetricEncryptionAlgorithm)baseAlgorithm; - ICryptoTransform transform; - Future result; + ICryptoTransform transform; + ListenableFuture result; try { transform = algo.CreateDecryptor(_keyPair); result = new FutureDecrypt(transform, encryptedKey); } catch (Exception e) { - result = new FutureExecutionException(e); + result = Futures.immediateFailedFuture(e); } return result; } @Override - public Future> signAsync(final byte[] digest, final String algorithm) { - return null; + public ListenableFuture> signAsync(final byte[] digest, final String algorithm) { + return Futures.immediateFailedFuture(new NotImplementedException("signAsync is not currently supported")); } @Override - public Future verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) { - return null; + public ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) { + return Futures.immediateFailedFuture(new NotImplementedException("verifyAsync is not currently supported")); } @Override diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java index f8614de47de94..f9900d592b3de 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java @@ -21,11 +21,12 @@ import java.io.IOException; import java.security.NoSuchAlgorithmException; import java.security.Provider; -import java.util.concurrent.Future; - +import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128CbcHmacSha256; @@ -35,8 +36,6 @@ import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw128; import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw192; import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256; -import com.microsoft.azure.keyvault.cryptography.FutureExecutionException; -import com.microsoft.azure.keyvault.cryptography.FutureImmediate; import com.microsoft.azure.keyvault.cryptography.Strings; public class SymmetricKey implements IKey { @@ -135,7 +134,7 @@ public String getKid() { } @Override - public Future decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm) throws NoSuchAlgorithmException { + public ListenableFuture decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm) throws NoSuchAlgorithmException { if (Strings.isNullOrWhiteSpace(algorithm)) { throw new IllegalArgumentException("algorithm"); @@ -163,7 +162,7 @@ public Future decryptAsync(final byte[] ciphertext, final byte[] iv, fin try { transform = algo.CreateDecryptor(_key, iv, authenticationData, _provider ); } catch (Exception e) { - return new FutureExecutionException(e); + return Futures.immediateFailedFuture(e); } byte[] result = null; @@ -171,7 +170,7 @@ public Future decryptAsync(final byte[] ciphertext, final byte[] iv, fin try { result = transform.doFinal(ciphertext); } catch (Exception e) { - return new FutureExecutionException(e); + return Futures.immediateFailedFuture(e); } if (transform instanceof IAuthenticatedCryptoTransform) { @@ -187,11 +186,11 @@ public Future decryptAsync(final byte[] ciphertext, final byte[] iv, fin } } - return new FutureImmediate(result); + return Futures.immediateFuture(result); } @Override - public Future> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm) throws NoSuchAlgorithmException { + public ListenableFuture> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm) throws NoSuchAlgorithmException { if (plaintext == null) { throw new IllegalArgumentException("plaintext"); @@ -216,7 +215,7 @@ public Future> encryptAsync(final byte[] plaintex try { transform = algo.CreateEncryptor(_key, iv, authenticationData, _provider); } catch (Exception e) { - return new FutureExecutionException>(e); + return Futures.immediateFailedFuture(e); } byte[] cipherText = null; @@ -224,7 +223,7 @@ public Future> encryptAsync(final byte[] plaintex try { cipherText = transform.doFinal(plaintext); } catch (Exception e) { - return new FutureExecutionException>(e); + return Futures.immediateFailedFuture(e); } byte[] authenticationTag = null; @@ -236,11 +235,11 @@ public Future> encryptAsync(final byte[] plaintex authenticationTag = authenticatedTransform.getTag().clone(); } - return new FutureImmediate>(Triple.of(cipherText, authenticationTag, algorithm)); + return Futures.immediateFuture(Triple.of(cipherText, authenticationTag, algorithm)); } @Override - public Future> wrapKeyAsync(final byte[] key, final String algorithm) throws NoSuchAlgorithmException { + public ListenableFuture> wrapKeyAsync(final byte[] key, final String algorithm) throws NoSuchAlgorithmException { if (key == null || key.length == 0) { throw new IllegalArgumentException("key"); @@ -261,7 +260,7 @@ public Future> wrapKeyAsync(final byte[] key, final String try { transform = algo.CreateEncryptor(_key, null, _provider); } catch (Exception e) { - return new FutureExecutionException>(e); + return Futures.immediateFailedFuture(e); } byte[] encrypted = null; @@ -269,14 +268,14 @@ public Future> wrapKeyAsync(final byte[] key, final String try { encrypted = transform.doFinal(key); } catch (Exception e) { - return new FutureExecutionException>(e); + return Futures.immediateFailedFuture(e); } - return new FutureImmediate>(Pair.of(encrypted, algorithmName)); + return Futures.immediateFuture(Pair.of(encrypted, algorithmName)); } @Override - public Future unwrapKeyAsync(final byte[] encryptedKey, final String algorithm) throws NoSuchAlgorithmException { + public ListenableFuture unwrapKeyAsync(final byte[] encryptedKey, final String algorithm) throws NoSuchAlgorithmException { if (Strings.isNullOrWhiteSpace(algorithm)) { throw new IllegalArgumentException("algorithm"); @@ -299,7 +298,7 @@ public Future unwrapKeyAsync(final byte[] encryptedKey, final String alg try { transform = algo.CreateDecryptor(_key, null, _provider); } catch (Exception e) { - return new FutureExecutionException(e); + return Futures.immediateFailedFuture(e); } byte[] decrypted = null; @@ -307,20 +306,20 @@ public Future unwrapKeyAsync(final byte[] encryptedKey, final String alg try { decrypted = transform.doFinal(encryptedKey); } catch (Exception e) { - return new FutureExecutionException(e); + return Futures.immediateFailedFuture(e); } - return new FutureImmediate(decrypted); + return Futures.immediateFuture(decrypted); } @Override - public Future> signAsync(final byte[] digest, final String algorithm) { - return null; + public ListenableFuture> signAsync(final byte[] digest, final String algorithm) { + return Futures.immediateFailedFuture(new NotImplementedException("signAsync is not currently supported")); } @Override - public Future verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) { - return null; + public ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) { + return Futures.immediateFailedFuture(new NotImplementedException("verifyAsync is not currently supported")); } @Override diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 1059acb7cf02c..8774c2bd9ee8e 100644 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -89,6 +89,11 @@ 1.0.0-beta2 test + + com.google.guava + guava + 18.0 + diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java index bd55a075bdb18..e6edb5301d09b 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java @@ -26,12 +26,14 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import com.google.common.util.concurrent.AbstractFuture; +import com.google.common.util.concurrent.ListenableFuture; import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.core.IKeyResolver; public class AggregateKeyResolver implements IKeyResolver { - class FutureKey implements Future { + class FutureKey extends AbstractFuture { private final String _kid; @@ -132,7 +134,7 @@ public void Add(IKeyResolver resolver) { } @Override - public Future resolveKeyAsync(String kid) { + public ListenableFuture resolveKeyAsync(String kid) { return new FutureKey(kid); } diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java index cd93c8fdaf913..14d1e1da9f5ea 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java @@ -18,25 +18,24 @@ package com.microsoft.azure.keyvault.extensions; -import java.util.concurrent.Future; - import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; +import com.google.common.util.concurrent.ListenableFuture; import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.core.IKeyResolver; public class CachingKeyResolver implements IKeyResolver { - private final LoadingCache> _cache; + private final LoadingCache> _cache; private final IKeyResolver _inner; public CachingKeyResolver(int capacity, IKeyResolver inner) { _cache = CacheBuilder.newBuilder().maximumSize(capacity) - .build( new CacheLoader>(){ + .build( new CacheLoader>(){ @Override - public Future load(String kid) { + public ListenableFuture load(String kid) { return _inner.resolveKeyAsync(kid); }}); @@ -44,7 +43,7 @@ public Future load(String kid) { } @Override - public Future resolveKeyAsync(String kid) { + public ListenableFuture resolveKeyAsync(String kid) { return _cache.getUnchecked(kid); } } diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureAdapter.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureAdapter.java deleted file mode 100644 index 25723415db3d3..0000000000000 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureAdapter.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.extensions; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import com.microsoft.rest.ServiceCall; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceResponse; - -abstract class FutureAdapter extends ServiceCallback implements Future { - - private final Object _lock = new Object(); - - private ServiceCall _call; - - private S _source; - private Throwable _throwable; - - protected FutureAdapter() { - _call = null; - _source = null; - _throwable = null; - } - - public void setServiceCall(ServiceCall call) { - _call = call; - } - - // ServiceCallback overrides - - @Override - public void failure(Throwable t) { - synchronized( _lock ) { - _throwable = t; - - _lock.notifyAll(); - } - } - - - @Override - public void success(ServiceResponse result) { - synchronized( _lock ) { - _source = result.getBody(); - - _lock.notifyAll(); - } - } - - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - - if ( !isCancelled()) { - // TODO: Call.cancel has no return value and does not support mayInterruptIfRunning - _call.getCall().cancel(); - } - - return true; - } - - // Future implementation - - @Override - public boolean isCancelled() { - return _call.getCall().isCanceled(); - } - - @Override - public boolean isDone() { - // _call.getCall().isExecuted() is not the same as done as it will be true when the request is enqueued but not actually - // completed. So we check our results to determine whether we are actually done. - synchronized(_lock) { - return ( _source != null || _throwable != null ); - } - } - - @Override - public T get() throws InterruptedException, ExecutionException { - try { - synchronized( _lock ) { - if ( _source == null && _throwable == null ) { - _lock.wait(); - } - } - - if ( _source != null ) { - return translate(_source); - } else { - throw _throwable; - } - } catch (Throwable e) { - throw new ExecutionException(e); - } - } - - @Override - public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - try { - synchronized( _lock ) { - if ( _source == null && _throwable == null ) { - _lock.wait(); - } - } - - if ( _source != null ) { - return translate(_source); - } else { - throw _throwable; - } - } catch (Throwable e) { - throw new ExecutionException(e); - } - } - - protected abstract T translate(S result) throws IOException; - -} \ No newline at end of file diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureBase.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureBase.java deleted file mode 100644 index b25bcde3203d0..0000000000000 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureBase.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.extensions; - -import java.util.concurrent.Future; - -abstract class FutureBase implements Future { - - private boolean _cancelled = false; - private boolean _done = false; - - protected FutureBase() { - this(false, false); - } - - protected FutureBase(boolean done) { - this(done, false); - } - - protected FutureBase(boolean done, boolean cancelled) { - _done = done; - _cancelled = cancelled; - } - - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - - // mark cancelled - _cancelled = true; - - return _cancelled; - } - - @Override - public boolean isCancelled() { - - return _cancelled; - } - - @Override - public boolean isDone() { - - return _done; - } -} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureExecutionException.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureExecutionException.java deleted file mode 100644 index a3744fb037efb..0000000000000 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureExecutionException.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.extensions; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -class FutureExecutionException extends FutureBase { - - private final ExecutionException _e; - - FutureExecutionException(Throwable t) { - super(true); - - _e = new ExecutionException(t); - } - - @Override - public T get() throws InterruptedException, ExecutionException { - throw _e; - } - - @Override - public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - throw _e; - } - -} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureImmediate.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureImmediate.java deleted file mode 100644 index 0e086cec82698..0000000000000 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureImmediate.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.extensions; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -class FutureImmediate extends FutureBase { - - private final T _result; - - FutureImmediate(T result) { - super(true); - - _result = result; - } - - @Override - public T get() throws InterruptedException, ExecutionException { - - // throw if cancelled - if (isCancelled()) { - throw new InterruptedException(); - } - - return _result; - } - - @Override - public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - - // throw if cancelled - if (isCancelled()) { - throw new InterruptedException(); - } - - return _result; - } -} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureServiceCall.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureServiceCall.java new file mode 100644 index 0000000000000..6506879e7d329 --- /dev/null +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureServiceCall.java @@ -0,0 +1,82 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.extensions; + +import com.google.common.util.concurrent.AbstractFuture; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; + +class FutureServiceCall extends AbstractFuture { + + private final Object _lock = new Object(); + + private ServiceCall _call; + private Callback _callback; + + class Callback extends ServiceCallback { + + @Override + public void failure(Throwable t) { + synchronized( _lock ) { + // Set the exception + FutureServiceCall.this.setException(t); + } + } + + @Override + public void success(ServiceResponse result) { + synchronized( _lock ) { + // Set the result + FutureServiceCall.this.set(result.getBody()); + } + } + } + + protected FutureServiceCall() { + _call = null; + _callback = new Callback(); + } + + public ServiceCallback getServiceCallback() { + return _callback; + } + + public void setServiceCall(ServiceCall call) { + _call = call; + } + + @Override + public boolean cancel(boolean mayInterruptIfRunning) { + + if ( !isCancelled()) { + // TODO: Call.cancel has no return value and does not support mayInterruptIfRunning + _call.getCall().cancel(); + } + + return super.cancel(mayInterruptIfRunning); + } + + // Future implementation + + @Override + public boolean isCancelled() { + return _call.getCall().isCanceled(); + } +} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index 46bbb19b6fd47..46efa00b60003 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -20,11 +20,12 @@ import java.io.IOException; import java.security.NoSuchAlgorithmException; -import java.util.concurrent.Future; - import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; +import com.google.common.base.Function; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.cryptography.RsaKey; @@ -33,37 +34,35 @@ import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; -import com.microsoft.rest.ServiceCall; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceResponse; public class KeyVaultKey implements IKey { + + class DecryptResultTransform implements Function { - class FutureDecryptResult extends FutureAdapter { - - FutureDecryptResult() { + DecryptResultTransform() { super(); } @Override - protected byte[] translate(KeyOperationResult result) throws IOException { + public byte[] apply(KeyOperationResult result) { return result.result(); } } - class FutureSignResult extends FutureAdapter> { + class SignResultTransform implements Function> { - private final String _algorithm; + private final String _algorithm; - FutureSignResult(String algorithm) { + SignResultTransform(String algorithm) { super(); _algorithm = algorithm; } + + @Override + public Pair apply(KeyOperationResult input) { - @Override - protected Pair translate(KeyOperationResult result) throws IOException { - return Pair.of(result.result(), _algorithm); - } + return Pair.of(input.result(), _algorithm); + } } private final KeyVaultClient _client; @@ -147,7 +146,7 @@ public String getKid() { } @Override - public Future decryptAsync(byte[] ciphertext, byte[] iv, byte[] authenticationData, byte[] authenticationTag, String algorithm) { + public ListenableFuture decryptAsync(byte[] ciphertext, byte[] iv, byte[] authenticationData, byte[] authenticationTag, String algorithm) { if (_implementation == null) { return null; @@ -158,20 +157,21 @@ public Future decryptAsync(byte[] ciphertext, byte[] iv, byte[] authenti } // Never local - FutureDecryptResult result = new FutureDecryptResult(); + FutureServiceCall futureCall = new FutureServiceCall(); + ListenableFuture result = Futures.transform(futureCall, new DecryptResultTransform() ); - result.setServiceCall( + futureCall.setServiceCall( _client.decrypt( _implementation.getKid(), algorithm, ciphertext, - result ) ); + futureCall.getServiceCallback() ) ); return result; } @Override - public Future> encryptAsync(byte[] plaintext, byte[] iv, byte[] authenticationData, String algorithm) throws NoSuchAlgorithmException { + public ListenableFuture> encryptAsync(byte[] plaintext, byte[] iv, byte[] authenticationData, String algorithm) throws NoSuchAlgorithmException { if (_implementation == null) { return null; } @@ -180,7 +180,7 @@ public Future> encryptAsync(byte[] plaintext, byt } @Override - public Future> wrapKeyAsync(byte[] plaintext, String algorithm) throws NoSuchAlgorithmException { + public ListenableFuture> wrapKeyAsync(byte[] plaintext, String algorithm) throws NoSuchAlgorithmException { if (_implementation == null) { return null; } @@ -189,7 +189,7 @@ public Future> wrapKeyAsync(byte[] plaintext, String algori } @Override - public Future unwrapKeyAsync(byte[] ciphertext, String algorithm) { + public ListenableFuture unwrapKeyAsync(byte[] ciphertext, String algorithm) { if (_implementation == null) { return null; } @@ -199,21 +199,21 @@ public Future unwrapKeyAsync(byte[] ciphertext, String algorithm) { } // Never local - FutureDecryptResult result = new FutureDecryptResult(); + FutureServiceCall futureCall = new FutureServiceCall(); + ListenableFuture result = Futures.transform(futureCall, new DecryptResultTransform() ); - result.setServiceCall( + futureCall.setServiceCall( _client.unwrapKey( _implementation.getKid(), algorithm, ciphertext, - result ) ); + futureCall.getServiceCallback() ) ); return result; - } @Override - public Future> signAsync(byte[] digest, String algorithm) { + public ListenableFuture> signAsync(byte[] digest, String algorithm) { if (_implementation == null) { return null; } @@ -223,21 +223,21 @@ public Future> signAsync(byte[] digest, String algorithm) { } // Never local - FutureSignResult result = new FutureSignResult(algorithm); + FutureServiceCall futureCall = new FutureServiceCall(); + ListenableFuture> result = Futures.transform(futureCall, new SignResultTransform(algorithm) ); - result.setServiceCall( + futureCall.setServiceCall( _client.sign( _implementation.getKid(), algorithm, digest, - result ) ); + futureCall.getServiceCallback() ) ); return result; - } @Override - public Future verifyAsync(byte[] digest, byte[] signature, String algorithm) { + public ListenableFuture verifyAsync(byte[] digest, byte[] signature, String algorithm) { if (_implementation == null) { return null; } diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java index 7fe6c34e5ddc1..3080c99ec21ab 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java @@ -19,10 +19,11 @@ package com.microsoft.azure.keyvault.extensions; import java.security.Provider; -import java.util.concurrent.Future; - import org.apache.commons.codec.binary.Base64; +import com.google.common.base.Function; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.SecretIdentifier; @@ -31,22 +32,19 @@ import com.microsoft.azure.keyvault.cryptography.SymmetricKey; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.SecretBundle; -import com.microsoft.rest.ServiceCall; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceResponse; public class KeyVaultKeyResolver implements IKeyResolver { static final Base64 _base64 = new Base64(-1, null, true); - class FutureKeyFromKey extends FutureAdapter { + class FutureKeyFromKey implements Function { protected FutureKeyFromKey() { super(); } @Override - protected IKey translate(KeyBundle keyBundle) { + public IKey apply(KeyBundle keyBundle) { if (keyBundle != null) { return new KeyVaultKey(_client, keyBundle); @@ -56,15 +54,14 @@ protected IKey translate(KeyBundle keyBundle) { } } - class FutureKeyFromSecret extends FutureAdapter { - + class FutureKeyFromSecret implements Function { protected FutureKeyFromSecret() { super(); } @Override - protected IKey translate(SecretBundle secretBundle) { + public IKey apply(SecretBundle secretBundle) { if (secretBundle != null && secretBundle.contentType().equalsIgnoreCase("application/octet-stream")) { byte[] keyBytes = _base64.decode(secretBundle.value()); @@ -91,27 +88,28 @@ public KeyVaultKeyResolver(KeyVaultClient client, Provider provider) { _provider = provider; } - private Future resolveKeyFromSecretAsync(String kid) { + private ListenableFuture resolveKeyFromSecretAsync(String kid) { - FutureKeyFromSecret result = new FutureKeyFromSecret(); + FutureServiceCall futureCall = new FutureServiceCall(); + ListenableFuture result = Futures.transform(futureCall, new FutureKeyFromSecret()); - result.setServiceCall( _client.getSecret(kid, result) ); + futureCall.setServiceCall( _client.getSecret(kid, futureCall.getServiceCallback()) ); return result; } - private Future resolveKeyFromKeyAsync(String kid) { + private ListenableFuture resolveKeyFromKeyAsync(String kid) { - FutureKeyFromKey result = new FutureKeyFromKey(); + FutureServiceCall futureCall = new FutureServiceCall(); + ListenableFuture result = Futures.transform(futureCall, new FutureKeyFromKey()); + futureCall.setServiceCall( _client.getKey(kid, futureCall.getServiceCallback()) ); - result.setServiceCall( _client.getKey(kid, result ) ); - - return result; + return result; } @Override - public Future resolveKeyAsync(String kid) { + public ListenableFuture resolveKeyAsync(String kid) { if (KeyIdentifier.isKeyIdentifier(kid)) { return resolveKeyFromKeyAsync(kid); @@ -119,7 +117,7 @@ public Future resolveKeyAsync(String kid) { return resolveKeyFromSecretAsync(kid); } - return new FutureImmediate(null); + return Futures.immediateFuture(null); } } diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java index 44c64e6a863ce..5625660e3f86f 100644 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java @@ -20,10 +20,9 @@ import static org.junit.Assert.*; -import java.util.concurrent.Future; - import org.junit.Test; +import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.UncheckedExecutionException; import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.core.IKeyResolver; @@ -33,7 +32,7 @@ public class CachingKeyResolverTest { @SuppressWarnings("unchecked") - final Future ikeyAsync = mock(Future.class); + final ListenableFuture ikeyAsync = mock(ListenableFuture.class); final static String keyId = "keyID"; final static String keyId2 = "keyID2"; final static String keyId3 = "keyID3"; From 14f369007196ed8e0787d0f83126364904bc960c Mon Sep 17 00:00:00 2001 From: Pooneh Date: Tue, 9 Aug 2016 13:23:42 -0700 Subject: [PATCH 11/56] Using ListenableFuture as async return type for Key Vault --- .../extensions/FutureServiceCall.java | 82 - .../keyvault/extensions/KeyVaultKey.java | 67 +- .../extensions/KeyVaultKeyResolver.java | 27 +- .../azure/keyvault/KeyVaultClient.java | 279 +-- .../azure/keyvault/KeyVaultClientImpl.java | 2192 ++++++++--------- .../azure/keyvault/models/KeyUsageType.java | 56 +- .../models/X509CertificateProperties.java | 6 +- 7 files changed, 1233 insertions(+), 1476 deletions(-) delete mode 100644 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureServiceCall.java diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureServiceCall.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureServiceCall.java deleted file mode 100644 index 6506879e7d329..0000000000000 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/FutureServiceCall.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.extensions; - -import com.google.common.util.concurrent.AbstractFuture; -import com.microsoft.rest.ServiceCall; -import com.microsoft.rest.ServiceCallback; -import com.microsoft.rest.ServiceResponse; - -class FutureServiceCall extends AbstractFuture { - - private final Object _lock = new Object(); - - private ServiceCall _call; - private Callback _callback; - - class Callback extends ServiceCallback { - - @Override - public void failure(Throwable t) { - synchronized( _lock ) { - // Set the exception - FutureServiceCall.this.setException(t); - } - } - - @Override - public void success(ServiceResponse result) { - synchronized( _lock ) { - // Set the result - FutureServiceCall.this.set(result.getBody()); - } - } - } - - protected FutureServiceCall() { - _call = null; - _callback = new Callback(); - } - - public ServiceCallback getServiceCallback() { - return _callback; - } - - public void setServiceCall(ServiceCall call) { - _call = call; - } - - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - - if ( !isCancelled()) { - // TODO: Call.cancel has no return value and does not support mayInterruptIfRunning - _call.getCall().cancel(); - } - - return super.cancel(mayInterruptIfRunning); - } - - // Future implementation - - @Override - public boolean isCancelled() { - return _call.getCall().isCanceled(); - } -} diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index 46efa00b60003..89387af830ebc 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -34,22 +34,23 @@ import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; +import com.microsoft.rest.ServiceResponse; public class KeyVaultKey implements IKey { - class DecryptResultTransform implements Function { + class DecryptResultTransform implements Function, byte[]> { DecryptResultTransform() { super(); } @Override - public byte[] apply(KeyOperationResult result) { - return result.result(); + public byte[] apply(ServiceResponse result) { + return result.getBody().result(); } } - class SignResultTransform implements Function> { + class SignResultTransform implements Function, Pair> { private final String _algorithm; @@ -59,9 +60,9 @@ class SignResultTransform implements Function apply(KeyOperationResult input) { + public Pair apply(ServiceResponse input) { - return Pair.of(input.result(), _algorithm); + return Pair.of(input.getBody().result(), _algorithm); } } @@ -157,17 +158,13 @@ public ListenableFuture decryptAsync(byte[] ciphertext, byte[] iv, byte[ } // Never local - FutureServiceCall futureCall = new FutureServiceCall(); - ListenableFuture result = Futures.transform(futureCall, new DecryptResultTransform() ); - - futureCall.setServiceCall( - _client.decrypt( - _implementation.getKid(), - algorithm, - ciphertext, - futureCall.getServiceCallback() ) ); - - return result; + ListenableFuture> futureCall = + _client.decryptAsync( + _implementation.getKid(), + algorithm, + ciphertext, + null ); + return Futures.transform(futureCall, new DecryptResultTransform() ); } @Override @@ -199,17 +196,13 @@ public ListenableFuture unwrapKeyAsync(byte[] ciphertext, String algorit } // Never local - FutureServiceCall futureCall = new FutureServiceCall(); - ListenableFuture result = Futures.transform(futureCall, new DecryptResultTransform() ); - - futureCall.setServiceCall( - _client.unwrapKey( - _implementation.getKid(), - algorithm, - ciphertext, - futureCall.getServiceCallback() ) ); - - return result; + ListenableFuture> futureCall = + _client.unwrapKeyAsync( + _implementation.getKid(), + algorithm, + ciphertext, + null ); + return Futures.transform(futureCall, new DecryptResultTransform() ); } @Override @@ -223,17 +216,13 @@ public ListenableFuture> signAsync(byte[] digest, String al } // Never local - FutureServiceCall futureCall = new FutureServiceCall(); - ListenableFuture> result = Futures.transform(futureCall, new SignResultTransform(algorithm) ); - - futureCall.setServiceCall( - _client.sign( - _implementation.getKid(), - algorithm, - digest, - futureCall.getServiceCallback() ) ); - - return result; + ListenableFuture> futureCall = + _client.signAsync( + _implementation.getKid(), + algorithm, + digest, + null ); + return Futures.transform(futureCall, new SignResultTransform(algorithm) ); } @Override diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java index 3080c99ec21ab..d5dc9605800fd 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java @@ -32,20 +32,22 @@ import com.microsoft.azure.keyvault.cryptography.SymmetricKey; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.SecretBundle; +import com.microsoft.rest.ServiceResponse; public class KeyVaultKeyResolver implements IKeyResolver { static final Base64 _base64 = new Base64(-1, null, true); - class FutureKeyFromKey implements Function { + class FutureKeyFromKey implements Function, IKey> { protected FutureKeyFromKey() { super(); } @Override - public IKey apply(KeyBundle keyBundle) { + public IKey apply(ServiceResponse keyBundleResponse) { + KeyBundle keyBundle = keyBundleResponse.getBody(); if (keyBundle != null) { return new KeyVaultKey(_client, keyBundle); } @@ -54,15 +56,16 @@ public IKey apply(KeyBundle keyBundle) { } } - class FutureKeyFromSecret implements Function { + class FutureKeyFromSecret implements Function, IKey> { protected FutureKeyFromSecret() { super(); } @Override - public IKey apply(SecretBundle secretBundle) { + public IKey apply(ServiceResponse secretBundleResponse) { + SecretBundle secretBundle = secretBundleResponse.getBody(); if (secretBundle != null && secretBundle.contentType().equalsIgnoreCase("application/octet-stream")) { byte[] keyBytes = _base64.decode(secretBundle.value()); @@ -90,22 +93,14 @@ public KeyVaultKeyResolver(KeyVaultClient client, Provider provider) { private ListenableFuture resolveKeyFromSecretAsync(String kid) { - FutureServiceCall futureCall = new FutureServiceCall(); - ListenableFuture result = Futures.transform(futureCall, new FutureKeyFromSecret()); - - futureCall.setServiceCall( _client.getSecret(kid, futureCall.getServiceCallback()) ); - - return result; + ListenableFuture> futureCall = _client.getSecretAsync(kid, null); + return Futures.transform(futureCall, new FutureKeyFromSecret()); } private ListenableFuture resolveKeyFromKeyAsync(String kid) { - FutureServiceCall futureCall = new FutureServiceCall(); - ListenableFuture result = Futures.transform(futureCall, new FutureKeyFromKey()); - - futureCall.setServiceCall( _client.getKey(kid, futureCall.getServiceCallback()) ); - - return result; + ListenableFuture> futureCall = _client.getKeyAsync(kid, null); + return Futures.transform(futureCall, new FutureKeyFromKey()); } @Override diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 9284ef8aca85b..b1978c52c28cf 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -7,6 +7,7 @@ package com.microsoft.azure.keyvault; import java.io.IOException; +import java.util.List; import com.google.common.base.Joiner; import com.microsoft.azure.AzureClient; @@ -209,11 +210,9 @@ public ServiceResponse createKey(CreateKeyRequest createKeyRequest) * @param createKeyRequest the grouped properties for creating a key request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ - public ServiceCall createKey(CreateKeyRequest createKeyRequest, ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall createKeyAsync(CreateKeyRequest createKeyRequest, ServiceCallback serviceCallback) { return innerKeyVaultClient.createKeyAsync( createKeyRequest.vaultBaseUrl(), createKeyRequest.keyName(), @@ -252,11 +251,9 @@ public ServiceResponse importKey(ImportKeyRequest importKeyRequest) * @param importKeyRequest the grouped properties for importing a key request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall importKey(ImportKeyRequest importKeyRequest, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall importKeyAsync(ImportKeyRequest importKeyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.importKeyAsync( importKeyRequest.vaultBaseUrl(), importKeyRequest.keyName(), @@ -288,11 +285,9 @@ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall deleteKey(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteKeyAsync(vaultBaseUrl, keyName, serviceCallback); } @@ -323,11 +318,9 @@ public ServiceResponse updateKey(UpdateKeyRequest updateKeyRequest) * @param updateKeyRequest the grouped properties for updating a key request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall updateKey(UpdateKeyRequest updateKeyRequest, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall updateKeyAsync(UpdateKeyRequest updateKeyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateKeyAsync( updateKeyRequest.vaultBaseUrl(), updateKeyRequest.keyName(), @@ -358,11 +351,9 @@ public ServiceResponse getKey(String keyIdentifier) * * @param keyIdentifier The full key identifier * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getKey(String keyIdentifier, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getKeyAsync(String keyIdentifier, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.getKeyAsync(id.vault, id.name, id.version == null? "" : id.version, serviceCallback); } @@ -388,11 +379,9 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyName) * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getKey(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getKeyAsync(vaultBaseUrl, keyName, "", serviceCallback); } @@ -419,11 +408,9 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyName, St * @param keyName The name of the key * @param keyVersion The version of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getKey(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getKeyAsync(vaultBaseUrl, keyName, keyVersion, serviceCallback); } @@ -448,11 +435,9 @@ public ServiceResponse> getKeyVersions(final String vaultBase * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getKeyVersions(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, serviceCallback); } /** @@ -478,11 +463,9 @@ public ServiceResponse> getKeyVersions(final String vaultBase * @param keyName The name of the key * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, maxresults, serviceCallback); } @@ -505,11 +488,9 @@ public ServiceResponse> getKeys(final String vaultBaseUrl) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getKeys(final String vaultBaseUrl, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, serviceCallback); } /** @@ -533,11 +514,9 @@ public ServiceResponse> getKeys(final String vaultBaseUrl, fi * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getKeys(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -562,11 +541,9 @@ public ServiceResponse backupKey(String vaultBaseUrl, String ke * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall backupKey(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.backupKeyAsync(vaultBaseUrl, keyName, serviceCallback); } @@ -591,11 +568,9 @@ public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBund * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyBundleBackup the backup blob associated with a key bundle * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall restoreKey(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { return innerKeyVaultClient.restoreKeyAsync(vaultBaseUrl, keyBundleBackup, serviceCallback); } @@ -623,11 +598,9 @@ public ServiceResponse encrypt(String keyIdentifier, String * @param algorithm algorithm identifier * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall encrypt(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall encryptAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encryptAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); } @@ -655,12 +628,10 @@ public ServiceResponse decrypt(String keyIdentifier, String * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier * @param value - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall decrypt(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall decryptAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decryptAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); } @@ -689,11 +660,9 @@ public ServiceResponse sign(String keyIdentifier, String alg * @param algorithm algorithm identifier * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall sign(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall signAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.signAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); } @@ -724,11 +693,9 @@ public ServiceResponse verify(String keyIdentifier, String algo * @param digest The digest used for signing * @param signature The signature to be verified * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall verify(String keyIdentifier, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall verifyAsync(String keyIdentifier, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verifyAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, digest, signature, serviceCallback); } @@ -757,11 +724,9 @@ public ServiceResponse wrapKey(String keyIdentifier, String * @param algorithm algorithm identifier * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall wrapKey(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall wrapKeyAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKeyAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); } @@ -790,11 +755,9 @@ public ServiceResponse unwrapKey(String keyIdentifier, Strin * @param algorithm algorithm identifier * @param value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall unwrapKey(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall unwrapKeyAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKeyAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); } @@ -826,11 +789,9 @@ public ServiceResponse setSecret(SetSecretRequest setSecretRequest * @param setSecretRequest the grouped properties for setting a secret request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall setSecret(SetSecretRequest setSecretRequest, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall setSecretAsync(SetSecretRequest setSecretRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.setSecretAsync( setSecretRequest.vaultBaseUrl(), setSecretRequest.secretName(), @@ -862,11 +823,9 @@ public ServiceResponse deleteSecret(String vaultBaseUrl, String se * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall deleteSecret(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteSecretAsync(vaultBaseUrl, secretName, serviceCallback); } @@ -897,11 +856,9 @@ public ServiceResponse updateSecret(UpdateSecretRequest updateSecr * @param updateSecretRequest the grouped properties for updating a secret request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall updateSecret(UpdateSecretRequest updateSecretRequest, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall updateSecretAsync(UpdateSecretRequest updateSecretRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateSecretAsync( updateSecretRequest.vaultBaseUrl(), updateSecretRequest.secretName(), @@ -932,11 +889,9 @@ public ServiceResponse getSecret(String secretIdentifier) * * @param secretIdentifier The URL for the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getSecret(String secretIdentifier, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getSecretAsync(String secretIdentifier, final ServiceCallback serviceCallback) { SecretIdentifier id = new SecretIdentifier(secretIdentifier); return innerKeyVaultClient.getSecretAsync(id.vault, id.name, id.version == null? "" : id.version, serviceCallback); } @@ -962,11 +917,9 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getSecret(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getSecretAsync(vaultBaseUrl, secretName, "", serviceCallback); } @@ -993,11 +946,9 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getSecret(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getSecretAsync(vaultBaseUrl, secretName, secretVersion == null? "" : secretVersion, serviceCallback); } @@ -1020,11 +971,9 @@ public ServiceResponse> getSecrets(final String vaultBaseU * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getSecrets(final String vaultBaseUrl, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, serviceCallback); } /** @@ -1048,11 +997,9 @@ public ServiceResponse> getSecrets(final String vaultBaseU * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of secrets to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getSecrets(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -1077,11 +1024,9 @@ public ServiceResponse> getSecretVersions(final String vau * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getSecretVersions(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, serviceCallback); } /** @@ -1107,11 +1052,9 @@ public ServiceResponse> getSecretVersions(final String vau * @param secretName The name of the secret in the given vault * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, maxresults, serviceCallback); } @@ -1134,11 +1077,9 @@ public ServiceResponse> getCertificates(final String * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificates(final String vaultBaseUrl, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, serviceCallback); } /** @@ -1162,11 +1103,9 @@ public ServiceResponse> getCertificates(final String * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificates(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -1191,11 +1130,9 @@ public ServiceResponse deleteCertificate(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall deleteCertificate(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteCertificateAsync(vaultBaseUrl, certificateName, serviceCallback); } @@ -1220,11 +1157,9 @@ public ServiceResponse setCertificateContacts(String vaultBaseUrl, Con * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param contacts The contacts for the vault certificates. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall setCertificateContacts(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { return innerKeyVaultClient.setCertificateContactsAsync(vaultBaseUrl, contacts, serviceCallback); } @@ -1247,11 +1182,9 @@ public ServiceResponse getCertificateContacts(String vaultBaseUrl) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificateContacts(String vaultBaseUrl, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificateContactsAsync(vaultBaseUrl, serviceCallback); } @@ -1274,11 +1207,9 @@ public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall deleteCertificateContacts(String vaultBaseUrl, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteCertificateContactsAsync(vaultBaseUrl, serviceCallback); } @@ -1301,11 +1232,9 @@ public ServiceResponse> getCertificateIssuers(f * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificateIssuers(final String vaultBaseUrl, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, serviceCallback); } /** @@ -1329,11 +1258,9 @@ public ServiceResponse> getCertificateIssuers(f * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -1361,11 +1288,9 @@ public ServiceResponse setCertificateIssuer(SetCertificateIssuerRe * @param setCertificateIssuerRequest the grouped properties for setting a certificate issuer request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerRequest setCertificateIssuerRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.setCertificateIssuerAsync( setCertificateIssuerRequest.vaultBaseUrl(), setCertificateIssuerRequest.issuerName(), @@ -1400,8 +1325,7 @@ public ServiceResponse updateCertificateIssuer(UpdateCertificateIs * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall updateCertificateIssuer(UpdateCertificateIssuerRequest updateCertificateIssuerRequest, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall updateCertificateIssuerAsync(UpdateCertificateIssuerRequest updateCertificateIssuerRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateIssuerAsync( updateCertificateIssuerRequest.vaultBaseUrl(), updateCertificateIssuerRequest.issuerName(), @@ -1430,11 +1354,9 @@ public ServiceResponse getCertificateIssuer(String vaultBaseUrl, S * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificateIssuer(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); } @@ -1459,11 +1381,9 @@ public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall deleteCertificateIssuer(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); } @@ -1493,11 +1413,9 @@ public ServiceResponse createCertificate(CreateCertificate * @param createCertificateRequest the grouped properties for creating a certificate request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall createCertificate(CreateCertificateRequest createCertificateRequest, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall createCertificateAsync(CreateCertificateRequest createCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.createCertificateAsync( createCertificateRequest.vaultBaseUrl(), createCertificateRequest.certificateName(), @@ -1535,11 +1453,9 @@ public ServiceResponse importCertificate(ImportCertificateReq * @param importCertificateRequest the grouped properties for importing a certificate request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall importCertificate(ImportCertificateRequest importCertificateRequest, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall importCertificateAsync(ImportCertificateRequest importCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.importCertificateAsync( importCertificateRequest.vaultBaseUrl(), importCertificateRequest.certificateName(), @@ -1572,11 +1488,9 @@ public ServiceResponse> getCertificateVersions(final * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificateVersions(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback); } /** @@ -1602,11 +1516,9 @@ public ServiceResponse> getCertificateVersions(final * @param certificateName The name of the certificate * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, maxresults, serviceCallback); } @@ -1631,11 +1543,9 @@ public ServiceResponse getCertificatePolicy(String vaultBaseU * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificatePolicy(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificatePolicyAsync(vaultBaseUrl, certificateName, serviceCallback); } @@ -1663,11 +1573,9 @@ public ServiceResponse updateCertificatePolicy(UpdateCertific * @param updateCertificatePolicyRequest the grouped properties for updating a certificate policy request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificatePolicyAsync( updateCertificatePolicyRequest.vaultBaseUrl(), updateCertificatePolicyRequest.certificateName(), @@ -1701,11 +1609,9 @@ public ServiceResponse updateCertificate(UpdateCertificateReq * @param updateCertificateRequest the grouped properties for updating a certificate request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall updateCertificate(UpdateCertificateRequest updateCertificateRequest, final ServiceCallback serviceCallback) - throws IllegalArgumentException{ + public ServiceCall updateCertificateAsync(UpdateCertificateRequest updateCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateAsync( updateCertificateRequest.vaultBaseUrl(), updateCertificateRequest.certificateName(), @@ -1735,11 +1641,9 @@ public ServiceResponse getCertificate(String certificateIdent * * @param certificateIdentifier The certificate identifier * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificate(String certificateIdentifier, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getCertificateAsync(String certificateIdentifier, final ServiceCallback serviceCallback) { CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); return innerKeyVaultClient.getCertificateAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); } @@ -1765,11 +1669,9 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificate(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificateAsync(vaultBaseUrl, certificateName, "", serviceCallback); } @@ -1796,11 +1698,9 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, serviceCallback); } @@ -1828,11 +1728,9 @@ public ServiceResponse updateCertificateOperation(UpdateCe * @param updateCertificateOperationRequest the grouped properties for updating a certificate operation request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall updateCertificateOperationAsync(UpdateCertificateOperationRequest updateCertificateOperationRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateOperationAsync( updateCertificateOperationRequest.vaultBaseUrl(), updateCertificateOperationRequest.certificateName(), @@ -1861,11 +1759,9 @@ public ServiceResponse getCertificateOperation(String vaul * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificateOperation(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificateOperationAsync(vaultBaseUrl, certificateName, serviceCallback); } @@ -1890,11 +1786,9 @@ public ServiceResponse deleteCertificateOperation(String v * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - ServiceCall deleteCertificateOperation(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteCertificateOperationAsync(vaultBaseUrl, certificateName, serviceCallback); } @@ -1924,11 +1818,9 @@ public ServiceResponse mergeCertificate(MergeCertificateReque * @param mergeCertificateRequest the grouped properties for merging a certificate request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall mergeCertificate(MergeCertificateRequest mergeCertificateRequest, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall mergeCertificateAsync(MergeCertificateRequest mergeCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.mergeCertificateAsync( mergeCertificateRequest.vaultBaseUrl(), mergeCertificateRequest.certificateName(), @@ -1972,36 +1864,37 @@ public ServiceResponse getPendingCertificateSigningRequest(String vaultB * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { if (serviceCallback == null) { throw new IllegalArgumentException("ServiceCallback is required for async calls."); } if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(new ServiceResponse(response.body().string(), response)); + if(serviceCallback != null) { + serviceCallback.success(new ServiceResponse(response.body().string(), response)); + } + serviceCall.success(new ServiceResponse(response.body().string(), response)); } catch (IOException exception) { - serviceCallback.failure(exception); + if(serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -2028,11 +1921,9 @@ public ServiceResponse> getKeyVersionsNext(final String nextPa * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getKeyVersionsNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeyVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); } @@ -2056,11 +1947,9 @@ public ServiceResponse> getKeysNext(final String nextPageLink) * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getKeysNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getKeysNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeysNextAsync(nextPageLink, serviceCall, serviceCallback); } @@ -2084,11 +1973,9 @@ public ServiceResponse> getSecretsNext(final String nextPag * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getSecretsNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getSecretsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretsNextAsync(nextPageLink, serviceCall, serviceCallback); } @@ -2112,11 +1999,9 @@ public ServiceResponse> getSecretVersionsNext(final String * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getSecretVersionsNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); } @@ -2140,11 +2025,9 @@ public ServiceResponse> getCertificatesNext(final Stri * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificatesNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getCertificatesNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificatesNextAsync(nextPageLink, serviceCall, serviceCallback); } @@ -2168,11 +2051,9 @@ public ServiceResponse> getCertificateIssuersNex * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificateIssuersNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateIssuersNextAsync(nextPageLink, serviceCall, serviceCallback); } @@ -2196,11 +2077,9 @@ public ServiceResponse> getCertificateVersionsNext(fin * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ - public ServiceCall getCertificateVersionsNext(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) - throws IllegalArgumentException { + public ServiceCall> getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 2cb4ea69a81db..0c61ac6076aeb 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -476,28 +476,20 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (kty == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter kty is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter kty is required and cannot be null."); } final Integer keySize = null; final List keyOps = null; @@ -511,14 +503,21 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kt parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(createKeyDelegate(response)); + ServiceResponse clientResponse = createKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -532,8 +531,8 @@ public void onResponse(Call call, Response response) * @param keyName The name of the key * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param keySize The key size in bytes. e.g. 1024 or 2048. - * @param keyOps - * @param keyAttributes + * @param keyOps the List<String> value + * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization @@ -574,36 +573,28 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param keySize The key size in bytes. e.g. 1024 or 2048. - * @param keyOps - * @param keyAttributes + * @param keyOps the List<String> value + * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (kty == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter kty is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter kty is required and cannot be null."); } - Validator.validate(keyOps, serviceCallback); - Validator.validate(keyAttributes, serviceCallback); - Validator.validate(tags, serviceCallback); + Validator.validate(keyOps); + Validator.validate(keyAttributes); + Validator.validate(tags); KeyCreateParameters parameters = new KeyCreateParameters(); parameters.withKty(kty); parameters.withKeySize(keySize); @@ -612,14 +603,21 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kt parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(createKeyDelegate(response)); + ServiceResponse clientResponse = createKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -678,30 +676,22 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param key The Json web key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (key == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter key is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter key is required and cannot be null."); } - Validator.validate(key, serviceCallback); + Validator.validate(key); final Boolean hsm = null; final KeyAttributes keyAttributes = null; final Map tags = null; @@ -712,14 +702,21 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKe parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(importKeyDelegate(response)); + ServiceResponse clientResponse = importKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -776,32 +773,24 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @param keyAttributes The key management attributes * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (key == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter key is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter key is required and cannot be null."); } - Validator.validate(key, serviceCallback); - Validator.validate(keyAttributes, serviceCallback); - Validator.validate(tags, serviceCallback); + Validator.validate(key); + Validator.validate(keyAttributes); + Validator.validate(tags); KeyImportParameters parameters = new KeyImportParameters(); parameters.withHsm(hsm); parameters.withKey(key); @@ -809,14 +798,21 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKe parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(importKeyDelegate(response)); + ServiceResponse clientResponse = importKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -861,35 +857,35 @@ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(deleteKeyDelegate(response)); + ServiceResponse clientResponse = deleteKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -946,28 +942,20 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param keyVersion The version of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (keyVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final List keyOps = null; final KeyAttributes keyAttributes = null; @@ -978,14 +966,21 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String ke parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(updateKeyDelegate(response)); + ServiceResponse clientResponse = updateKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -999,7 +994,7 @@ public void onResponse(Call call, Response response) * @param keyName The name of the key * @param keyVersion The version of the key * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. - * @param keyAttributes + * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization @@ -1038,49 +1033,48 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param keyVersion The version of the key * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. - * @param keyAttributes + * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (keyVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(keyOps, serviceCallback); - Validator.validate(keyAttributes, serviceCallback); - Validator.validate(tags, serviceCallback); + Validator.validate(keyOps); + Validator.validate(keyAttributes); + Validator.validate(tags); KeyUpdateParameters parameters = new KeyUpdateParameters(); parameters.withKeyOps(keyOps); parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(updateKeyDelegate(response)); + ServiceResponse clientResponse = updateKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -1130,39 +1124,38 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyName, St * @param keyName The name of the key * @param keyVersion The version of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (keyVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(getKeyDelegate(response)); + ServiceResponse clientResponse = getKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -1215,43 +1208,42 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getKeyVersionsDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -1298,42 +1290,41 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * @param keyName The name of the key * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getKeyVersionsDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -1381,39 +1372,39 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getKeysDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -1455,38 +1446,38 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getKeysDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -1531,35 +1522,35 @@ public ServiceResponse backupKey(String vaultBaseUrl, String ke * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(backupKeyDelegate(response)); + ServiceResponse clientResponse = backupKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -1606,37 +1597,37 @@ public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBund * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyBundleBackup the backup blob associated with a key bundle * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (keyBundleBackup == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyBundleBackup is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyBundleBackup is required and cannot be null."); } KeyRestoreParameters parameters = new KeyRestoreParameters(); parameters.withKeyBundleBackup(keyBundleBackup); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(restoreKeyDelegate(response)); + ServiceResponse clientResponse = restoreKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -1656,8 +1647,8 @@ private ServiceResponse restoreKeyDelegate(Response res * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' - * @param value + * @param algorithm algorithm identifier + * @param value the Base64Url value * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -1696,53 +1687,50 @@ public ServiceResponse encrypt(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' - * @param value + * @param algorithm algorithm identifier + * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (keyVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (algorithm == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter algorithm is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); } if (value == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter value is required and cannot be null."); } KeyOperationsParameters parameters = new KeyOperationsParameters(); parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(encryptDelegate(response)); + ServiceResponse clientResponse = encryptDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -1762,8 +1750,8 @@ private ServiceResponse encryptDelegate(Response decrypt(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' - * @param value + * @param algorithm algorithm identifier + * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (keyVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (algorithm == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter algorithm is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); } if (value == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter value is required and cannot be null."); } KeyOperationsParameters parameters = new KeyOperationsParameters(); parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(decryptDelegate(response)); + ServiceResponse clientResponse = decryptDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -1868,8 +1853,8 @@ private ServiceResponse decryptDelegate(Response sign(String vaultBaseUrl, String keyN * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' - * @param value + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (keyVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (algorithm == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter algorithm is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); } if (value == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter value is required and cannot be null."); } KeySignParameters parameters = new KeySignParameters(); parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(signDelegate(response)); + ServiceResponse clientResponse = signDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -1974,7 +1956,7 @@ private ServiceResponse signDelegate(Response * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. * @param digest The digest used for signing * @param signature The signature to be verified * @throws KeyVaultErrorException exception thrown from REST call @@ -2019,44 +2001,33 @@ public ServiceResponse verify(String vaultBaseUrl, String keyNa * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. * @param digest The digest used for signing * @param signature The signature to be verified * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (keyVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (algorithm == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter algorithm is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); } if (digest == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter digest is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter digest is required and cannot be null."); } if (signature == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter signature is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter signature is required and cannot be null."); } KeyVerifyParameters parameters = new KeyVerifyParameters(); parameters.withAlgorithm(algorithm); @@ -2064,14 +2035,21 @@ public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVe parameters.withSignature(signature); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(verifyDelegate(response)); + ServiceResponse clientResponse = verifyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -2091,8 +2069,8 @@ private ServiceResponse verifyDelegate(Response r * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' - * @param value + * @param algorithm algorithm identifier + * @param value the Base64Url value * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -2131,53 +2109,50 @@ public ServiceResponse wrapKey(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' - * @param value + * @param algorithm algorithm identifier + * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (keyVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (algorithm == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter algorithm is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); } if (value == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter value is required and cannot be null."); } KeyOperationsParameters parameters = new KeyOperationsParameters(); parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(wrapKeyDelegate(response)); + ServiceResponse clientResponse = wrapKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -2197,8 +2172,8 @@ private ServiceResponse wrapKeyDelegate(Response unwrapKey(String vaultBaseUrl, String * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' - * @param value + * @param algorithm algorithm identifier + * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (keyName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); } if (keyVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter keyVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (algorithm == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter algorithm is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); } if (value == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter value is required and cannot be null."); } KeyOperationsParameters parameters = new KeyOperationsParameters(); parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(unwrapKeyDelegate(response)); + ServiceResponse clientResponse = unwrapKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -2341,28 +2313,20 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @param secretName The name of the secret in the given vault * @param value The value of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (secretName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (value == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter value is required and cannot be null."); } final Map tags = null; final String contentType = null; @@ -2374,14 +2338,21 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String parameters.withSecretAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(setSecretDelegate(response)); + ServiceResponse clientResponse = setSecretDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -2437,31 +2408,23 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @param contentType Type of the secret value such as a password * @param secretAttributes The secret management attributes * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (secretName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (value == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter value is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter value is required and cannot be null."); } - Validator.validate(tags, serviceCallback); - Validator.validate(secretAttributes, serviceCallback); + Validator.validate(tags); + Validator.validate(secretAttributes); SecretSetParameters parameters = new SecretSetParameters(); parameters.withValue(value); parameters.withTags(tags); @@ -2469,14 +2432,21 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String parameters.withSecretAttributes(secretAttributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(setSecretDelegate(response)); + ServiceResponse clientResponse = setSecretDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -2521,35 +2491,35 @@ public ServiceResponse deleteSecret(String vaultBaseUrl, String se * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (secretName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(deleteSecretDelegate(response)); + ServiceResponse clientResponse = deleteSecretDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -2606,28 +2576,20 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (secretName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); } if (secretVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter secretVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final String contentType = null; final SecretAttributes secretAttributes = null; @@ -2638,14 +2600,21 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, Str parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(updateSecretDelegate(response)); + ServiceResponse clientResponse = updateSecretDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -2700,45 +2669,44 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @param secretAttributes The secret management attributes * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (secretName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); } if (secretVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter secretVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(secretAttributes, serviceCallback); - Validator.validate(tags, serviceCallback); + Validator.validate(secretAttributes); + Validator.validate(tags); SecretUpdateParameters parameters = new SecretUpdateParameters(); parameters.withContentType(contentType); parameters.withSecretAttributes(secretAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(updateSecretDelegate(response)); + ServiceResponse clientResponse = updateSecretDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -2788,39 +2756,38 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (secretName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); } if (secretVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter secretVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(getSecretDelegate(response)); + ServiceResponse clientResponse = getSecretDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -2868,39 +2835,39 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getSecretsDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -2942,38 +2909,38 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of secrets to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getSecretsDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3026,43 +2993,42 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (secretName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getSecretVersionsDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3109,42 +3075,41 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * @param secretName The name of the secret in the given vault * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (secretName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter secretName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getSecretVersionsDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3192,39 +3157,39 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getCertificatesDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3266,38 +3231,38 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getCertificatesDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3342,35 +3307,35 @@ public ServiceResponse deleteCertificate(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(deleteCertificateDelegate(response)); + ServiceResponse clientResponse = deleteCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3416,36 +3381,36 @@ public ServiceResponse setCertificateContacts(String vaultBaseUrl, Con * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param contacts The contacts for the vault certificates. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (contacts == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter contacts is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter contacts is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(contacts, serviceCallback); + Validator.validate(contacts); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(setCertificateContactsDelegate(response)); + ServiceResponse clientResponse = setCertificateContactsDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3485,31 +3450,32 @@ public ServiceResponse getCertificateContacts(String vaultBaseUrl) thr * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(getCertificateContactsDelegate(response)); + ServiceResponse clientResponse = getCertificateContactsDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3549,31 +3515,32 @@ public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(deleteCertificateContactsDelegate(response)); + ServiceResponse clientResponse = deleteCertificateContactsDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3621,39 +3588,39 @@ public Page nextPage(String nextPageLink) throws KeyVault * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getCertificateIssuersDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3695,38 +3662,38 @@ public Page nextPage(String nextPageLink) throws KeyVault * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getCertificateIssuersDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3777,40 +3744,39 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * @param issuerName The name of the issuer. * @param issuer The issuer bundle. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (issuerName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter issuerName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } if (issuer == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter issuer is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(issuer, serviceCallback); + Validator.validate(issuer); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(setCertificateIssuerDelegate(response)); + ServiceResponse clientResponse = setCertificateIssuerDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3861,40 +3827,39 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * @param issuerName The name of the issuer. * @param issuer The issuer bundle. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (issuerName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter issuerName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } if (issuer == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter issuer is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(issuer, serviceCallback); + Validator.validate(issuer); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(updateCertificateIssuerDelegate(response)); + ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -3939,35 +3904,35 @@ public ServiceResponse getCertificateIssuer(String vaultBaseUrl, S * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (issuerName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter issuerName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(getCertificateIssuerDelegate(response)); + ServiceResponse clientResponse = getCertificateIssuerDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -4012,35 +3977,35 @@ public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (issuerName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter issuerName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(deleteCertificateIssuerDelegate(response)); + ServiceResponse clientResponse = deleteCertificateIssuerDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -4092,24 +4057,17 @@ public ServiceResponse createCertificate(String vaultBaseU * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final CertificatePolicy certificatePolicy = null; final CertificateAttributes certificateAttributes = null; @@ -4120,14 +4078,21 @@ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificat parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(createCertificateDelegate(response)); + ServiceResponse clientResponse = createCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -4178,42 +4143,42 @@ public ServiceResponse createCertificate(String vaultBaseU * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(certificatePolicy, serviceCallback); - Validator.validate(certificateAttributes, serviceCallback); - Validator.validate(tags, serviceCallback); + Validator.validate(certificatePolicy); + Validator.validate(certificateAttributes); + Validator.validate(tags); CertificateCreateParameters parameters = new CertificateCreateParameters(); parameters.withCertificatePolicy(certificatePolicy); parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(createCertificateDelegate(response)); + ServiceResponse clientResponse = createCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -4273,28 +4238,20 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (base64EncodedCertificate == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); } final String password = null; final CertificatePolicy certificatePolicy = null; @@ -4308,14 +4265,21 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificat parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(importCertificateDelegate(response)); + ServiceResponse clientResponse = importCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -4375,32 +4339,24 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (base64EncodedCertificate == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); } - Validator.validate(certificatePolicy, serviceCallback); - Validator.validate(certificateAttributes, serviceCallback); - Validator.validate(tags, serviceCallback); + Validator.validate(certificatePolicy); + Validator.validate(certificateAttributes); + Validator.validate(tags); CertificateImportParameters parameters = new CertificateImportParameters(); parameters.withBase64EncodedCertificate(base64EncodedCertificate); parameters.withPassword(password); @@ -4409,14 +4365,21 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificat parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(importCertificateDelegate(response)); + ServiceResponse clientResponse = importCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -4469,43 +4432,42 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getCertificateVersionsDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -4552,42 +4514,41 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @param certificateName The name of the certificate * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { ServiceResponse> result = getCertificateVersionsDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -4632,35 +4593,35 @@ public ServiceResponse getCertificatePolicy(String vaultBaseU * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(getCertificatePolicyDelegate(response)); + ServiceResponse clientResponse = getCertificatePolicyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -4711,40 +4672,39 @@ public ServiceResponse updateCertificatePolicy(String vaultBa * @param certificateName The name of the certificate in the given vault. * @param certificatePolicy The policy for the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (certificatePolicy == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(certificatePolicy, serviceCallback); + Validator.validate(certificatePolicy); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(updateCertificatePolicyDelegate(response)); + ServiceResponse clientResponse = updateCertificatePolicyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -4799,28 +4759,20 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (certificateVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } final CertificateAttributes certificateAttributes = null; final Map tags = null; @@ -4829,14 +4781,21 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificat parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(updateCertificateDelegate(response)); + ServiceResponse clientResponse = updateCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -4888,44 +4847,43 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (certificateVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(certificateAttributes, serviceCallback); - Validator.validate(tags, serviceCallback); + Validator.validate(certificateAttributes); + Validator.validate(tags); CertificateUpdateParameters parameters = new CertificateUpdateParameters(); parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(updateCertificateDelegate(response)); + ServiceResponse clientResponse = updateCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -4975,39 +4933,38 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (certificateVersion == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateVersion is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(getCertificateDelegate(response)); + ServiceResponse clientResponse = getCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -5058,40 +5015,39 @@ public ServiceResponse updateCertificateOperation(String v * @param certificateName The name of the certificate * @param certificateOperation The certificate operation response. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (certificateOperation == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateOperation is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateOperation is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(certificateOperation, serviceCallback); + Validator.validate(certificateOperation); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(updateCertificateOperationDelegate(response)); + ServiceResponse clientResponse = updateCertificateOperationDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -5136,35 +5092,35 @@ public ServiceResponse getCertificateOperation(String vaul * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(getCertificateOperationDelegate(response)); + ServiceResponse clientResponse = getCertificateOperationDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -5209,35 +5165,35 @@ public ServiceResponse deleteCertificateOperation(String v * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(deleteCertificateOperationDelegate(response)); + ServiceResponse clientResponse = deleteCertificateOperationDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -5294,30 +5250,22 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate * @param x509Certificates The certificate or the certificate chain to merge * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (x509Certificates == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter x509Certificates is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); } - Validator.validate(x509Certificates, serviceCallback); + Validator.validate(x509Certificates); final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateMergeParameters parameters = new CertificateMergeParameters(); @@ -5326,14 +5274,21 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificate parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(mergeCertificateDelegate(response)); + ServiceResponse clientResponse = mergeCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -5387,46 +5342,45 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter certificateName is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } if (this.apiVersion() == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } if (x509Certificates == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter x509Certificates is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); } - Validator.validate(x509Certificates, serviceCallback); - Validator.validate(certificateAttributes, serviceCallback); - Validator.validate(tags, serviceCallback); + Validator.validate(x509Certificates); + Validator.validate(certificateAttributes); + Validator.validate(tags); CertificateMergeParameters parameters = new CertificateMergeParameters(); parameters.withX509Certificates(x509Certificates); parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCallback) { + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { - serviceCallback.success(mergeCertificateDelegate(response)); + ServiceResponse clientResponse = mergeCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -5463,20 +5417,15 @@ public ServiceResponse> getKeyVersionsNext(final String nextPa * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { if (nextPageLink == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5489,7 +5438,10 @@ public void onResponse(Call call, Response response) serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); } } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -5526,20 +5478,15 @@ public ServiceResponse> getKeysNext(final String nextPageLink) * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getKeysNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getKeysNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { if (nextPageLink == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5552,7 +5499,10 @@ public void onResponse(Call call, Response response) serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); } } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -5589,20 +5539,15 @@ public ServiceResponse> getSecretsNext(final String nextPag * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getSecretsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { if (nextPageLink == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5615,7 +5560,10 @@ public void onResponse(Call call, Response response) serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); } } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -5652,20 +5600,15 @@ public ServiceResponse> getSecretVersionsNext(final String * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { if (nextPageLink == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5678,7 +5621,10 @@ public void onResponse(Call call, Response response) serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); } } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -5715,20 +5661,15 @@ public ServiceResponse> getCertificatesNext(final Stri * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificatesNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getCertificatesNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { if (nextPageLink == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5741,7 +5682,10 @@ public void onResponse(Call call, Response response) serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); } } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -5778,20 +5722,15 @@ public ServiceResponse> getCertificateIssuersNex * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { if (nextPageLink == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5804,7 +5743,10 @@ public void onResponse(Call call, Response response) serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); } } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -5841,20 +5783,15 @@ public ServiceResponse> getCertificateVersionsNext(fin * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @throws IllegalArgumentException thrown if callback is null * @return the {@link Call} object */ - public ServiceCall getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall serviceCall, final ListOperationCallback serviceCallback) throws IllegalArgumentException { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + public ServiceCall> getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { if (nextPageLink == null) { - serviceCallback.failure(new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.")); - return null; + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCallback) { + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { @Override public void onResponse(Call call, Response response) { try { @@ -5867,7 +5804,10 @@ public void onResponse(Call call, Response response) serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); } } catch (KeyVaultErrorException | IOException exception) { - serviceCallback.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java index 020a9073e1b50..b595c15479ddc 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java @@ -6,37 +6,73 @@ package com.microsoft.azure.keyvault.models; +import com.fasterxml.jackson.annotation.JsonValue; + /** * Defines values for KeyUsageType. */ public final class KeyUsageType { /** Static value digitalSignature for KeyUsageType. */ - public static final String DIGITAL_SIGNATURE = "digitalSignature"; + public static final KeyUsageType DIGITAL_SIGNATURE = new KeyUsageType("digitalSignature"); /** Static value nonRepudiation for KeyUsageType. */ - public static final String NON_REPUDIATION = "nonRepudiation"; + public static final KeyUsageType NON_REPUDIATION = new KeyUsageType("nonRepudiation"); /** Static value keyEncipherment for KeyUsageType. */ - public static final String KEY_ENCIPHERMENT = "keyEncipherment"; + public static final KeyUsageType KEY_ENCIPHERMENT = new KeyUsageType("keyEncipherment"); /** Static value dataEncipherment for KeyUsageType. */ - public static final String DATA_ENCIPHERMENT = "dataEncipherment"; + public static final KeyUsageType DATA_ENCIPHERMENT = new KeyUsageType("dataEncipherment"); /** Static value keyAgreement for KeyUsageType. */ - public static final String KEY_AGREEMENT = "keyAgreement"; + public static final KeyUsageType KEY_AGREEMENT = new KeyUsageType("keyAgreement"); /** Static value keyCertSign for KeyUsageType. */ - public static final String KEY_CERT_SIGN = "keyCertSign"; + public static final KeyUsageType KEY_CERT_SIGN = new KeyUsageType("keyCertSign"); /** Static value cRLSign for KeyUsageType. */ - public static final String C_RLSIGN = "cRLSign"; + public static final KeyUsageType C_RLSIGN = new KeyUsageType("cRLSign"); /** Static value encipherOnly for KeyUsageType. */ - public static final String ENCIPHER_ONLY = "encipherOnly"; + public static final KeyUsageType ENCIPHER_ONLY = new KeyUsageType("encipherOnly"); /** Static value decipherOnly for KeyUsageType. */ - public static final String DECIPHER_ONLY = "decipherOnly"; + public static final KeyUsageType DECIPHER_ONLY = new KeyUsageType("decipherOnly"); + + private String value; + + /** + * Creates a custom value for KeyUsageType. + * @param value the custom value + */ + public KeyUsageType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } + + @Override + public int hashCode() { + return value.hashCode(); + } - private KeyUsageType() { + @Override + public boolean equals(Object obj) { + if (!(obj instanceof KeyUsageType)) { + return false; + } + if (obj == this) { + return true; + } + KeyUsageType rhs = (KeyUsageType) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java index c291be20c8123..60bf432540ae5 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java @@ -33,7 +33,7 @@ public class X509CertificateProperties { * List of key usages. */ @JsonProperty(value = "key_usage") - private List keyUsage; + private List keyUsage; /** * The subject alternate names. @@ -106,7 +106,7 @@ public X509CertificateProperties withSubjectAlternativeNames(SubjectAlternativeN * * @return the keyUsage value */ - public List keyUsage() { + public List keyUsage() { return this.keyUsage; } @@ -116,7 +116,7 @@ public List keyUsage() { * @param keyUsage the keyUsage value to set * @return the X509CertificateProperties object itself. */ - public X509CertificateProperties withKeyUsage(List keyUsage) { + public X509CertificateProperties withKeyUsage(List keyUsage) { this.keyUsage = keyUsage; return this; } From aae68df27be32e4264e94fd70b914d2c0dceb44d Mon Sep 17 00:00:00 2001 From: Pooneh Date: Tue, 9 Aug 2016 13:34:52 -0700 Subject: [PATCH 12/56] Adding the MIT License Header --- .../main/java/com/microsoft/azure/keyvault/models/Action.java | 4 ++++ .../java/com/microsoft/azure/keyvault/models/ActionType.java | 4 ++++ .../microsoft/azure/keyvault/models/AdministratorDetails.java | 4 ++++ .../java/com/microsoft/azure/keyvault/models/Attributes.java | 4 ++++ .../com/microsoft/azure/keyvault/models/BackupKeyResult.java | 4 ++++ .../azure/keyvault/models/CertificateAttributes.java | 4 ++++ .../microsoft/azure/keyvault/models/CertificateBundle.java | 4 ++++ .../azure/keyvault/models/CertificateCreateParameters.java | 4 ++++ .../azure/keyvault/models/CertificateImportParameters.java | 4 ++++ .../azure/keyvault/models/CertificateIssuerItem.java | 4 ++++ .../com/microsoft/azure/keyvault/models/CertificateItem.java | 4 ++++ .../azure/keyvault/models/CertificateMergeParameters.java | 4 ++++ .../microsoft/azure/keyvault/models/CertificateOperation.java | 4 ++++ .../microsoft/azure/keyvault/models/CertificatePolicy.java | 4 ++++ .../azure/keyvault/models/CertificateUpdateParameters.java | 4 ++++ .../java/com/microsoft/azure/keyvault/models/Contact.java | 4 ++++ .../java/com/microsoft/azure/keyvault/models/Contacts.java | 4 ++++ .../main/java/com/microsoft/azure/keyvault/models/Error.java | 4 ++++ .../com/microsoft/azure/keyvault/models/IssuerAttributes.java | 4 ++++ .../com/microsoft/azure/keyvault/models/IssuerBundle.java | 4 ++++ .../microsoft/azure/keyvault/models/IssuerCredentials.java | 4 ++++ .../com/microsoft/azure/keyvault/models/IssuerReference.java | 4 ++++ .../java/com/microsoft/azure/keyvault/models/JsonWebKey.java | 4 ++++ .../com/microsoft/azure/keyvault/models/KeyAttributes.java | 4 ++++ .../java/com/microsoft/azure/keyvault/models/KeyBundle.java | 4 ++++ .../microsoft/azure/keyvault/models/KeyCreateParameters.java | 4 ++++ .../microsoft/azure/keyvault/models/KeyImportParameters.java | 4 ++++ .../java/com/microsoft/azure/keyvault/models/KeyItem.java | 4 ++++ .../microsoft/azure/keyvault/models/KeyOperationResult.java | 4 ++++ .../azure/keyvault/models/KeyOperationsParameters.java | 4 ++++ .../com/microsoft/azure/keyvault/models/KeyProperties.java | 4 ++++ .../microsoft/azure/keyvault/models/KeyRestoreParameters.java | 4 ++++ .../microsoft/azure/keyvault/models/KeySignParameters.java | 4 ++++ .../microsoft/azure/keyvault/models/KeyUpdateParameters.java | 4 ++++ .../com/microsoft/azure/keyvault/models/KeyUsageType.java | 4 ++++ .../com/microsoft/azure/keyvault/models/KeyVaultError.java | 4 ++++ .../azure/keyvault/models/KeyVaultErrorException.java | 4 ++++ .../microsoft/azure/keyvault/models/KeyVerifyParameters.java | 4 ++++ .../com/microsoft/azure/keyvault/models/KeyVerifyResult.java | 4 ++++ .../com/microsoft/azure/keyvault/models/LifetimeAction.java | 4 ++++ .../microsoft/azure/keyvault/models/OrganizationDetails.java | 4 ++++ .../java/com/microsoft/azure/keyvault/models/PageImpl.java | 4 ++++ .../models/PendingCertificateSigningRequestResult.java | 4 ++++ .../com/microsoft/azure/keyvault/models/SecretAttributes.java | 4 ++++ .../com/microsoft/azure/keyvault/models/SecretBundle.java | 4 ++++ .../java/com/microsoft/azure/keyvault/models/SecretItem.java | 4 ++++ .../com/microsoft/azure/keyvault/models/SecretProperties.java | 4 ++++ .../microsoft/azure/keyvault/models/SecretSetParameters.java | 4 ++++ .../azure/keyvault/models/SecretUpdateParameters.java | 4 ++++ .../azure/keyvault/models/SubjectAlternativeNames.java | 4 ++++ .../java/com/microsoft/azure/keyvault/models/Trigger.java | 4 ++++ .../azure/keyvault/models/X509CertificateProperties.java | 4 ++++ .../com/microsoft/azure/keyvault/models/package-info.java | 4 ++++ .../main/java/com/microsoft/azure/keyvault/package-info.java | 4 ++++ 54 files changed, 216 insertions(+) diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java index d95af8df0185b..b87d376d8bdde 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java index fa8aca689e543..3bd73fd386216 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java index 790aef8054b95..580ac6b5d62f2 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java index f4b4da10feb09..ed187ccd0cab0 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java index 6d8a48e0187e1..b5a6a72351240 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java index a42aec24d1c36..d821e2490bc60 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java index 7b42c24f3d1cb..f99badba1c43c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java index 61727eacb5f76..9de3d7a36bebb 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java index f0c1a3e80049c..6cd918a00cb14 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java index 97c7e6231ba76..f90e86cd39fdb 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java index f0cff43eaa2e1..ba4afedaccf1e 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java index 6c24fe1e941c5..46454283ded8f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java index ff4f78da2dc8b..04079baeb1620 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java index 6eed27f2610fa..6243eb4a805e4 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java index 68dca444f6e2e..0e3d426eed6cf 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java index e92efcb58400c..7fe0c7baeb017 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java index 1cbd4321f1785..8d0d542cbeb2b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java index fcbfce15499c2..4d231d644f92a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java index 475da1d65800f..592e36229ecc7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java index 028d42733ec8a..8929000ab3384 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java index 17de164137dd0..23ef3eced7f05 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java index 2a3d0f7dd05bd..6f971897b7dbb 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java index f1a4f586fe796..7180f7967e846 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java index 7ce170c5baa24..25c37fede46de 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index 4bda5d4a98dd6..b906859dd18fa 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java index 1a8bad0f1a74c..a799ee36fb6e7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java index 57d738de2eace..0cd6eb0a956e5 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index b57cbab5a54c1..3e29afb4dc57b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java index 738ffda32dfa0..229b85ec52d70 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java index 5c27239f943d0..228a944624152 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java index 816b27a2fe2e6..999ed545fd0be 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java index 97adc31e5034b..2d32495d4074e 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java index c2c81892a5111..1af4965c7b756 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java index e10e3aa0335dc..33c51dc4d697b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java index b595c15479ddc..7b4b390b1cb65 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java index 81c51587804cc..aa2a6f81d1c74 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java index 1501eb1adc162..bdcfc617fc14c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java index 300284101634b..1f370f7494ed7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java index 317c6ef3a7aab..2295ece7edb6a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java index 27d6d074e7da5..9f2f520dfaf7a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java index 531f1171db4da..44e80f582186f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java index 9d209d1c4472e..ba40e0b446269 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java index dbb7d57926145..51b5fc32aee52 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java index 4edba47d30062..e6cdbe4d40db0 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index 9b0beebe8efd6..dfa4910df3a89 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index 6e01d6c795fa0..f3b41e85debe4 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java index 4ba5abada96a7..daa4ec324e4cc 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java index 810e96bece7ef..c6aa346335c08 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java index 06174214cc161..ac9361fffbe73 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java index 4b09ad331a801..317cc22925354 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java index 6f780dea882c7..52fa1a031dd3a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java index 60bf432540ae5..ae9267dba24d6 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java index f5cbd38e531fe..79c10e9f21e65 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java @@ -1,3 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// // Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java index 6c07835d77ea2..ec9b976c5096b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java @@ -1,3 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// // Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. From 21de0036b5c00ad1357df31180a45bac6b8e27ec Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Wed, 10 Aug 2016 15:55:29 -0700 Subject: [PATCH 13/56] Remove various Future subclasses and use futures.immediateFuture instead. --- .../azure/keyvault/cryptography/RsaKey.java | 111 ++---------------- 1 file changed, 12 insertions(+), 99 deletions(-) diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java index c64359259927f..4bdfca31ad87e 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java @@ -19,6 +19,7 @@ package com.microsoft.azure.keyvault.cryptography; import java.io.IOException; +import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; @@ -27,6 +28,9 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; + import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; @@ -40,97 +44,6 @@ public class RsaKey implements IKey { - class FutureDecrypt extends AbstractFuture { - - private final byte[] _data; - private final ICryptoTransform _transform; - - FutureDecrypt(ICryptoTransform transform, byte[] data) { - _data = data; - _transform = transform; - } - - @Override - public byte[] get() throws InterruptedException, ExecutionException { - try { - return _transform.doFinal(_data); - } catch (Exception e) { - throw new ExecutionException(e); - } - } - - @Override - public byte[] get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - try { - return _transform.doFinal(_data); - } catch (Exception e) { - throw new ExecutionException(e); - } - } - } - - class FutureEncrypt extends AbstractFuture> { - - private final String _algorithm; - private final byte[] _data; - private final ICryptoTransform _transform; - - FutureEncrypt(String algorithm, byte[] data, ICryptoTransform transform) { - _algorithm = algorithm; - _data = data; - _transform = transform; - } - - @Override - public Triple get() throws InterruptedException, ExecutionException { - try { - return Triple.of(_transform.doFinal(_data), (byte[]) null, _algorithm); - } catch (Exception e) { - throw new ExecutionException(e); - } - } - - @Override - public Triple get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - try { - return Triple.of(_transform.doFinal(_data), (byte[]) null, _algorithm); - } catch (Exception e) { - throw new ExecutionException(e); - } - } - } - - class FutureWrap extends AbstractFuture> { - - private final String _algorithm; - private final byte[] _data; - private final ICryptoTransform _transform; - - FutureWrap(String algorithm, byte[] data, ICryptoTransform transform) { - _algorithm = algorithm; - _data = data; - _transform = transform; - } - - @Override - public Pair get() throws InterruptedException, ExecutionException { - try { - return Pair.of(_transform.doFinal(_data), _algorithm); - } catch (Exception e) { - throw new ExecutionException(e); - } - } - - @Override - public Pair get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - try { - return Pair.of(_transform.doFinal(_data), _algorithm); - } catch (Exception e) { - throw new ExecutionException(e); - } - } - } - public static int KeySize1024 = 1024; public static int KeySize2048 = 2048; @@ -223,9 +136,9 @@ public ListenableFuture decryptAsync(final byte[] ciphertext, final byte try { transform = algo.CreateDecryptor(_keyPair); - result = new FutureDecrypt(transform, ciphertext); + result = Futures.immediateFuture(transform.doFinal(ciphertext)); } catch (Exception e) { - result = Futures.immediateFailedFuture(e); + result = Futures.immediateFailedFuture(e); } return result; @@ -253,9 +166,9 @@ public ListenableFuture> encryptAsync(final byte[ try { transform = algo.CreateEncryptor(_keyPair); - result = new FutureEncrypt(algorithmName, plaintext, transform); + result = Futures.immediateFuture(Triple.of(transform.doFinal(plaintext), (byte[]) null, algorithmName)); } catch (Exception e) { - result = Futures.immediateFailedFuture(e); + result = Futures.immediateFailedFuture(e); } return result; @@ -283,9 +196,9 @@ public ListenableFuture> wrapKeyAsync(final byte[] key, fin try { transform = algo.CreateEncryptor(_keyPair); - result = new FutureWrap(algorithmName, key, transform); + result = Futures.immediateFuture(Pair.of(transform.doFinal(key), algorithmName)); } catch (Exception e) { - result = Futures.immediateFailedFuture(e); + result = Futures.immediateFailedFuture(e); } return result; @@ -317,9 +230,9 @@ public ListenableFuture unwrapKeyAsync(final byte[] encryptedKey, final try { transform = algo.CreateDecryptor(_keyPair); - result = new FutureDecrypt(transform, encryptedKey); + result = Futures.immediateFuture(transform.doFinal(encryptedKey)); } catch (Exception e) { - result = Futures.immediateFailedFuture(e); + result = Futures.immediateFailedFuture(e); } return result; From 07b9c536fd5220b6bbb936d5932c01b9f871b01c Mon Sep 17 00:00:00 2001 From: Pooneh Date: Wed, 10 Aug 2016 17:27:00 -0700 Subject: [PATCH 14/56] Fixing projects name and dependency --- azure-keyvault-core/pom.xml | 4 ++-- azure-keyvault-cryptography/pom.xml | 4 ++-- azure-keyvault-extensions/pom.xml | 9 +++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index f74716d0dcdbb..738aa6c57a4f3 100644 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -24,8 +24,8 @@ azure-keyvault-core jar - Microsoft Azure SDK for Key Vault - This package contains Microsoft Azure Key Vault SDK. + Microsoft Azure SDK for Key Vault Core + This package contains Microsoft Azure Key Vault Core SDK. https://github.com/Azure/azure-sdk-for-java diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index 7870e8c3f23c7..17b3766ef8184 100644 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -16,8 +16,8 @@ azure-keyvault-cryptography jar - Microsoft Azure SDK for Key Vault - This package contains Microsoft Azure SDK for Key Vault. + Microsoft Azure SDK for Key Vault Cryptography + This package contains Microsoft Azure SDK for Key Vault Cryptography. https://github.com/Azure/azure-sdk-for-java diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 8774c2bd9ee8e..15c95ba3eac12 100644 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -15,8 +15,8 @@ azure-keyvault-extensions jar - Microsoft Azure SDK for Key Vault - This package contains Microsoft Azure Key Vault SDK. + Microsoft Azure SDK for Key Vault Extensions + This package contains Microsoft Azure Key Vault SDK Extensions. https://github.com/Azure/azure-sdk-for-java @@ -51,6 +51,11 @@ azure-client-runtime 1.0.0-SNAPSHOT + + commons-codec + commons-codec + 1.7 + junit junit From 53fff028f34174f74b8b200468e6f5450fb62ef2 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Thu, 11 Aug 2016 10:28:59 -0700 Subject: [PATCH 15/56] Updating documentations --- azure-keyvault-core/pom.xml | 2 +- .../microsoft/azure/keyvault/core/IKey.java | 19 +++++++++--------- .../azure/keyvault/core/IKeyResolver.java | 6 +++--- azure-keyvault/pom.xml | 2 +- .../azure/keyvault/KeyVaultClient.java | 20 +++++++++---------- .../azure/keyvault/ObjectIdentifier.java | 10 +++++----- .../keyvault/requests/CreateKeyRequest.java | 11 +++++----- .../keyvault/requests/ImportKeyRequest.java | 8 ++++---- .../keyvault/requests/UpdateKeyRequest.java | 4 ++-- 9 files changed, 40 insertions(+), 42 deletions(-) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index 738aa6c57a4f3..32a541dce7d91 100644 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -88,7 +88,7 @@ maven-javadoc-plugin 2.8 - *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.storage + com.microsoft.schemas._2003._10.serialization /**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java index 52852f34c5cd3..f734ef0feb249 100644 --- a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java @@ -78,8 +78,8 @@ public interface IKey extends Closeable { * with some algorithms) * @param algorithm * The encryption algorithm to use, must be supplied - * @return A {@link:Future} containing the plain text - * @throws NoSuchAlgorithmException + * @return A {@link:ListenableFuture} containing the plain text + * @throws NoSuchAlgorithmException the algorithm is not valid */ ListenableFuture decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm) throws NoSuchAlgorithmException; @@ -96,9 +96,9 @@ public interface IKey extends Closeable { * @param algorithm * The encryption algorithm to use, defaults to the keys * DefaultEncryptionAlgorithm - * @return A {@link:Future} containing the cipher text, the authentication + * @return A {@link:ListenableFuture} containing the cipher text, the authentication * tag and the algorithm that was used - * @throws NoSuchAlgorithmException + * @throws NoSuchAlgorithmException the algorithm is not valid */ ListenableFuture> encryptAsync(final byte[] plaintext, final byte[] iv, final byte[] authenticationData, final String algorithm) throws NoSuchAlgorithmException; @@ -111,9 +111,9 @@ public interface IKey extends Closeable { * @param algorithm * The wrapping algorithm to use, defaults to the keys * DefaultKeyWrapAlgorithm - * @return A {@link:Future} containing the encrypted key and the algorithm + * @return {@link:ListenableFuture} containing the encrypted key and the algorithm * that was used - * @throws NoSuchAlgorithmException + * @throws NoSuchAlgorithmException the algorithm is not valid */ ListenableFuture> wrapKeyAsync(final byte[] key, final String algorithm) throws NoSuchAlgorithmException; @@ -124,8 +124,7 @@ public interface IKey extends Closeable { * The encrypted key to decrypt * @param algorithm * The algorithm to use, must be supplied - * @return A {@link:Future} containing the unwrapped key - * @throws NoSuchAlgorithmException + * @return A {@link:ListenableFuture} containing the unwrapped key */ ListenableFuture unwrapKeyAsync(final byte[] encryptedKey, final String algorithm) throws NoSuchAlgorithmException; @@ -137,7 +136,7 @@ public interface IKey extends Closeable { * The digest to sign * @param algorithm * The signature algorithm to use - * @return A {@link:Future} containing the signature and the algorithm used. + * @return A {@link:ListenableFuture} containing the signature and the algorithm used. */ ListenableFuture> signAsync(final byte[] digest, final String algorithm); @@ -151,7 +150,7 @@ public interface IKey extends Closeable { * The signature to verify * @param algorithm * The algorithm to use, must be provided - * @return A {@link:Future} containing a boolean result + * @return A {@link:ListenableFuture} containing a boolean result */ ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm); } diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java index 6fa7787c597d9..edc2bb3fe8253 100644 --- a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java @@ -31,9 +31,9 @@ public interface IKeyResolver { * * @param kid * The key identifier to resolve. - * @return A {@link:Future} containing the resolved IKey - * @throws InterruptedException - * @throws ExecutionException + * @return A {@link:ListenableFuture} containing the resolved IKey + * @throws InterruptedException + * @throws ExecutionException */ ListenableFuture resolveKeyAsync(String kid); } diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index 498a5805aa355..a1a3830259410 100644 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -100,7 +100,7 @@ maven-javadoc-plugin 2.8 - *.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.storage + com.microsoft.schemas._2003._10.serialization; /**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index b1978c52c28cf..0312180666e2d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -579,7 +579,7 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier - * @param value + * @param value the content to be encrypted * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -596,7 +596,7 @@ public ServiceResponse encrypt(String keyIdentifier, String * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier - * @param value + * @param value the content to be encrypted * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -610,7 +610,7 @@ public ServiceCall encryptAsync(String keyIdentifier, String * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier - * @param value + * @param value the content to be decrypted * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -627,7 +627,7 @@ public ServiceResponse decrypt(String keyIdentifier, String * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier - * @param value + * @param value the content to be decrypted * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -641,7 +641,7 @@ public ServiceCall decryptAsync(String keyIdentifier, String * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier - * @param value + * @param value the content to be signed * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -658,7 +658,7 @@ public ServiceResponse sign(String keyIdentifier, String alg * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier - * @param value + * @param value the content to be signed * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -705,7 +705,7 @@ public ServiceCall verifyAsync(String keyIdentifier, String alg * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier - * @param value + * @param value the key to be wrapped * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -722,7 +722,7 @@ public ServiceResponse wrapKey(String keyIdentifier, String * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier - * @param value + * @param value the key to be wrapped * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -736,7 +736,7 @@ public ServiceCall wrapKeyAsync(String keyIdentifier, String * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier - * @param value + * @param value the key to be unwrapped * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -753,7 +753,7 @@ public ServiceResponse unwrapKey(String keyIdentifier, Strin * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier - * @param value + * @param value the key to be unwrapped * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java index ed9d5e2c01531..b95f81bfe219a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java @@ -144,35 +144,35 @@ protected String getFullAuthority(URI uri) { } /** - * The base identifier for an object, does not include the object version. + * @return The base identifier for an object, does not include the object version. */ public String baseIdentifier() { return baseIdentifier; } /** - * The identifier for an object, includes the objects version. + * @return The identifier for an object, includes the objects version. */ public String identifier() { return identifier; } /** - * The name of the object. + * @return The name of the object. */ public String name() { return name; } /** - * The vault containing the object + * @return The vault containing the object */ public String vault() { return vault; } /** - * The version of the object. + * @return The version of the object. */ public String version() { return version; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java index e8c57f1b1723d..5398b890511f7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java @@ -38,8 +38,7 @@ public static class Builder { * @param keyName * The name of the key in the given vault * @param keyType - * The type of key to create. For valid key types, see - * {@link WebKeyTypes}. + * The type of key to create. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' */ public Builder(String vaultBaseUrl, String keyName, String keyType) { this.vaultBaseUrl = vaultBaseUrl; @@ -62,12 +61,12 @@ public Builder withKeySize(Integer size) { /** * Set the key operations value. * - * @param size - * the size of the key + * @param keyOperations + * the key operation list * @return the Builder object itself. */ - public Builder withKeyOperations(List keyOps) { - this.keyOperations = keyOps; + public Builder withKeyOperations(List keyOperations) { + this.keyOperations = keyOperations; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java index 427bc79e2108f..88e382aa07f1a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java @@ -48,8 +48,8 @@ public Builder(String vaultBaseUrl, String keyName, JsonWebKey key) { * Set the isHsm to true if the key is imported as a hardware key to HSM, * false otherwise. * - * @param size - * the size of the key + * @param isHsm + * True, if the key is hardware key to be stored in HSM. false otherwise * @return the Builder object itself. */ public Builder withHsm(boolean isHsm) { @@ -64,8 +64,8 @@ public Builder withHsm(boolean isHsm) { * the key management attributes value to set * @return the Builder object itself. */ - public Builder withAttributes(KeyAttributes value) { - this.attributes = value; + public Builder withAttributes(KeyAttributes attributes) { + this.attributes = attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java index 7a0eea55027ab..9014c49bfd77a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java @@ -72,8 +72,8 @@ public Builder withVersion(String keyVersion) { /** * Set the key operations value. * - * @param size - * the size of the key + * @param keyOperations + * the key operation list * @return the Builder object itself. */ public Builder withKeyOperations(List keyOperations) { From 87b0962b096f333ddf14387f38225d701501e044 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Thu, 11 Aug 2016 17:34:15 -0700 Subject: [PATCH 16/56] Fixing the javadoc error and formatting errors for key vault --- .../microsoft/azure/keyvault/core/IKey.java | 26 +- .../azure/keyvault/core/IKeyResolver.java | 11 +- .../azure/keyvault/core/package-info.java | 9 + .../azure/keyvault/cryptography/RsaKey.java | 8 - azure-keyvault-extensions/pom.xml | 1 - .../extensions/AggregateKeyResolver.java | 95 ++- .../extensions/CachingKeyResolver.java | 31 +- .../keyvault/extensions/KeyVaultKey.java | 119 +-- .../extensions/KeyVaultKeyResolver.java | 55 +- .../azure/keyvault/extensions/Strings.java | 14 +- .../test/CachingKeyResolverTest.java | 126 +-- .../KeyVaultClientIntegrationTestBase.java | 2 +- .../KeyVaultKeyResolverBCProviderTest.java | 340 ++++----- ...eyVaultKeyResolverDefaultProviderTest.java | 390 +++++----- .../azure/keyvault/CertificateIdentifier.java | 25 +- .../CertificateOperationIdentifier.java | 78 +- .../azure/keyvault/IssuerIdentifier.java | 39 +- .../azure/keyvault/KeyIdentifier.java | 24 + .../azure/keyvault/KeyVaultClient.java | 717 +++++++++--------- .../azure/keyvault/KeyVaultClientImpl.java | 4 +- .../azure/keyvault/ObjectIdentifier.java | 69 +- .../azure/keyvault/SecretIdentifier.java | 24 + .../authentication/ChallengeCache.java | 42 +- .../authentication/KeyVaultCredentials.java | 244 +++--- .../keyvault/authentication/package-info.java | 9 + .../keyvault/models/CertificateBundle.java | 18 +- .../keyvault/models/CertificateItem.java | 11 +- .../keyvault/models/CertificateOperation.java | 6 +- .../azure/keyvault/models/IssuerBundle.java | 6 +- .../azure/keyvault/models/JsonWebKey.java | 80 +- .../azure/keyvault/models/KeyBundle.java | 4 + .../azure/keyvault/models/KeyItem.java | 9 +- .../azure/keyvault/models/SecretBundle.java | 10 +- .../azure/keyvault/models/SecretItem.java | 7 +- .../requests/CreateCertificateRequest.java | 297 ++++---- .../keyvault/requests/CreateKeyRequest.java | 287 +++---- .../requests/ImportCertificateRequest.java | 357 ++++----- .../keyvault/requests/ImportKeyRequest.java | 272 ++++--- .../requests/MergeCertificateRequest.java | 207 ++--- .../requests/SetCertificateIssuerRequest.java | 144 ++-- .../keyvault/requests/SetSecretRequest.java | 242 +++--- .../UpdateCertificateIssuerRequest.java | 147 ++-- .../UpdateCertificateOperationRequest.java | 133 ++-- .../UpdateCertificatePolicyRequest.java | 199 ++--- .../requests/UpdateCertificateRequest.java | 220 +++--- .../keyvault/requests/UpdateKeyRequest.java | 290 +++---- .../requests/UpdateSecretRequest.java | 275 +++---- .../azure/keyvault/requests/package-info.java | 10 + .../webkey/JsonWebKeyEncryptionAlgorithm.java | 16 +- .../keyvault/webkey/JsonWebKeyOperation.java | 32 +- .../webkey/JsonWebKeySignatureAlgorithm.java | 24 +- .../azure/keyvault/webkey/JsonWebKeyType.java | 24 +- .../azure/keyvault/webkey/package-info.java | 9 + 53 files changed, 3179 insertions(+), 2659 deletions(-) create mode 100644 azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/package-info.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/package-info.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/package-info.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java index f734ef0feb249..264024d42b153 100644 --- a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java @@ -20,6 +20,7 @@ import java.io.Closeable; import java.security.NoSuchAlgorithmException; + import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; @@ -34,7 +35,7 @@ public interface IKey extends Closeable { /** * The default encryption algorithm for this key, using the representations - * from Json Web Key Algorithms, RFC7513 + * from Json Web Key Algorithms, RFC7513. * * @return The default encryption algorithm for this key. */ @@ -42,7 +43,7 @@ public interface IKey extends Closeable { /** * The default key wrap algorithm for this key, using the representations - * from Json Web Key Algorithms, RFC7513 + * from Json Web Key Algorithms, RFC7513. * * @return The default key wrap algorithm for this key. */ @@ -50,7 +51,7 @@ public interface IKey extends Closeable { /** * The default signature algorithm for this key, using the representations - * from Json Web Key Algorithms, RFC7513 + * from Json Web Key Algorithms, RFC7513. * * @return The default signature algorithm for this key. */ @@ -78,7 +79,7 @@ public interface IKey extends Closeable { * with some algorithms) * @param algorithm * The encryption algorithm to use, must be supplied - * @return A {@link:ListenableFuture} containing the plain text + * @return A ListenableFuture containing the plain text * @throws NoSuchAlgorithmException the algorithm is not valid */ ListenableFuture decryptAsync(final byte[] ciphertext, final byte[] iv, final byte[] authenticationData, final byte[] authenticationTag, final String algorithm) throws NoSuchAlgorithmException; @@ -96,7 +97,7 @@ public interface IKey extends Closeable { * @param algorithm * The encryption algorithm to use, defaults to the keys * DefaultEncryptionAlgorithm - * @return A {@link:ListenableFuture} containing the cipher text, the authentication + * @return A ListenableFuture containing the cipher text, the authentication * tag and the algorithm that was used * @throws NoSuchAlgorithmException the algorithm is not valid */ @@ -111,7 +112,7 @@ public interface IKey extends Closeable { * @param algorithm * The wrapping algorithm to use, defaults to the keys * DefaultKeyWrapAlgorithm - * @return {@link:ListenableFuture} containing the encrypted key and the algorithm + * @return ListenableFuture containing the encrypted key and the algorithm * that was used * @throws NoSuchAlgorithmException the algorithm is not valid */ @@ -124,7 +125,8 @@ public interface IKey extends Closeable { * The encrypted key to decrypt * @param algorithm * The algorithm to use, must be supplied - * @return A {@link:ListenableFuture} containing the unwrapped key + * @return A ListenableFuture containing the unwrapped key + * @throws NoSuchAlgorithmException the algorithm is not valid */ ListenableFuture unwrapKeyAsync(final byte[] encryptedKey, final String algorithm) throws NoSuchAlgorithmException; @@ -136,9 +138,10 @@ public interface IKey extends Closeable { * The digest to sign * @param algorithm * The signature algorithm to use - * @return A {@link:ListenableFuture} containing the signature and the algorithm used. + * @return A ListenableFuture containing the signature and the algorithm used. + * @throws NoSuchAlgorithmException the algorithm is not valid */ - ListenableFuture> signAsync(final byte[] digest, final String algorithm); + ListenableFuture> signAsync(final byte[] digest, final String algorithm) throws NoSuchAlgorithmException; /** * Verifies the supplied signature value using the supplied digest and @@ -150,7 +153,8 @@ public interface IKey extends Closeable { * The signature to verify * @param algorithm * The algorithm to use, must be provided - * @return A {@link:ListenableFuture} containing a boolean result + * @return A ListenableFuture containing a boolean result + * @throws NoSuchAlgorithmException the algorithm is not valid */ - ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm); + ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) throws NoSuchAlgorithmException; } diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java index edc2bb3fe8253..e0b08e9ea200a 100644 --- a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java @@ -18,9 +18,12 @@ package com.microsoft.azure.keyvault.core; -import java.util.concurrent.ExecutionException; import com.google.common.util.concurrent.ListenableFuture; +/** + * Interface for representing key resolving operations with the Microsoft Azure Key + * Vault libraries. + */ public interface IKeyResolver { /** @@ -31,9 +34,7 @@ public interface IKeyResolver { * * @param kid * The key identifier to resolve. - * @return A {@link:ListenableFuture} containing the resolved IKey - * @throws InterruptedException - * @throws ExecutionException + * @return A ListenableFuture containing the resolved IKey */ - ListenableFuture resolveKeyAsync(String kid); + ListenableFuture resolveKeyAsync(String kid); } diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/package-info.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/package-info.java new file mode 100644 index 0000000000000..b3417f38285d4 --- /dev/null +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// + +/** + * This package contains the interface for IKey and IKeyResolver. + */ +package com.microsoft.azure.keyvault.core; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java index 4bdfca31ad87e..d8fe513c31c7b 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java @@ -19,23 +19,15 @@ package com.microsoft.azure.keyvault.cryptography; import java.io.IOException; -import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; import java.security.interfaces.RSAPublicKey; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; -import com.google.common.util.concurrent.AbstractFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.microsoft.azure.keyvault.core.IKey; diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 15c95ba3eac12..3c9f92ea238a1 100644 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -54,7 +54,6 @@ commons-codec commons-codec - 1.7 junit diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java index e6edb5301d09b..30062e6ab527e 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java @@ -31,106 +31,119 @@ import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.core.IKeyResolver; +/** + * The collection of key resolvers that would iterate on a key id to resolve to {@link IKey}. + */ public class AggregateKeyResolver implements IKeyResolver { + /** + * Future key class that resolves a key id after the async result is available. + */ class FutureKey extends AbstractFuture { - private final String _kid; + private final String kid; - private boolean _cancelled = false; - private boolean _done = false; - private IKey _result = null; + private boolean isCancelled = false; + private boolean isDone = false; + private IKey result = null; FutureKey(String kid) { - _kid = kid; + this.kid = kid; } @Override public boolean cancel(boolean mayInterruptIfRunning) { // mark cancelled - _cancelled = true; + isCancelled = true; - return _cancelled; + return isCancelled; } @Override public boolean isCancelled() { - return _cancelled; + return isCancelled; } @Override public boolean isDone() { // always true - return _done; + return isDone; } @Override public IKey get() throws InterruptedException, ExecutionException { // throw if cancelled - if (_cancelled) { + if (isCancelled) { throw new InterruptedException(); } - synchronized( _resolvers ) { - for (IKeyResolver resolver : _resolvers) { - Future futureKey = resolver.resolveKeyAsync(_kid); - - _result = futureKey.get(); - - if (_result != null) { - break; - } - } + synchronized (resolvers) { + for (IKeyResolver resolver : resolvers) { + Future futureKey = resolver.resolveKeyAsync(kid); + + result = futureKey.get(); + + if (result != null) { + break; + } + } } // Mark done - _done = true; + isDone = true; - return _result; + return result; } @Override public IKey get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { // throw if cancelled - if (_cancelled) { + if (isCancelled) { throw new InterruptedException(); } - synchronized( _resolvers ) { - for (IKeyResolver resolver : _resolvers) { - Future futureKey = resolver.resolveKeyAsync(_kid); - - _result = futureKey.get(timeout, unit); - - if (_result != null) { - break; - } - } + synchronized (resolvers) { + for (IKeyResolver resolver : resolvers) { + Future futureKey = resolver.resolveKeyAsync(kid); + + result = futureKey.get(timeout, unit); + + if (result != null) { + break; + } + } } // Mark done - _done = true; + isDone = true; - return _result; + return result; } } - private final List _resolvers; + private final List resolvers; + /** + * Constructor. + */ public AggregateKeyResolver() { - _resolvers = Collections.synchronizedList(new ArrayList()); + resolvers = Collections.synchronizedList(new ArrayList()); } - public void Add(IKeyResolver resolver) { + /** + * Adds a key resolver to the collection of key resolvers. + * @param resolver the key resolver + */ + public void add(IKeyResolver resolver) { - synchronized( _resolvers ) { - _resolvers.add(resolver); - } + synchronized (resolvers) { + resolvers.add(resolver); + } } @Override diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java index 14d1e1da9f5ea..f86a98b0916b3 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java @@ -25,25 +25,30 @@ import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.core.IKeyResolver; +/** + * The key resolver that caches the key after resolving to {@link IKey}. + */ public class CachingKeyResolver implements IKeyResolver { - private final LoadingCache> _cache; - private final IKeyResolver _inner; - - public CachingKeyResolver(int capacity, IKeyResolver inner) { - _cache = CacheBuilder.newBuilder().maximumSize(capacity) - .build( new CacheLoader>(){ + private final LoadingCache> cache; + + /** + * Constructor. + * @param capacity the cache size + * @param keyResolver the key resolver + */ + public CachingKeyResolver(int capacity, final IKeyResolver keyResolver) { + cache = CacheBuilder.newBuilder().maximumSize(capacity) + .build(new CacheLoader>() { - @Override - public ListenableFuture load(String kid) { - return _inner.resolveKeyAsync(kid); - }}); - - _inner = inner; + @Override + public ListenableFuture load(String kid) { + return keyResolver.resolveKeyAsync(kid); + } }); } @Override public ListenableFuture resolveKeyAsync(String kid) { - return _cache.getUnchecked(kid); + return cache.getUnchecked(kid); } } diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index 89387af830ebc..485fa3a0b797f 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -36,8 +36,14 @@ import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; import com.microsoft.rest.ServiceResponse; +/** + * The key vault key that performs cryptography operations. + */ public class KeyVaultKey implements IKey { - + + /** + * Transforms the result of decrypt operation to byte array. + */ class DecryptResultTransform implements Function, byte[]> { DecryptResultTransform() { @@ -50,24 +56,27 @@ public byte[] apply(ServiceResponse result) { } } + /** + * Transforms the result of sign operation to byte array and algorithm pair. + */ class SignResultTransform implements Function, Pair> { - private final String _algorithm; + private final String algorithm; SignResultTransform(String algorithm) { super(); - _algorithm = algorithm; + this.algorithm = algorithm; } - - @Override - public Pair apply(ServiceResponse input) { + + @Override + public Pair apply(ServiceResponse input) { - return Pair.of(input.getBody().result(), _algorithm); - } + return Pair.of(input.getBody().result(), algorithm); + } } - private final KeyVaultClient _client; - private IKey _implementation; + private final KeyVaultClient client; + private IKey implementation; protected KeyVaultKey(KeyVaultClient client, KeyBundle keyBundle) { @@ -86,70 +95,70 @@ protected KeyVaultKey(KeyVaultClient client, KeyBundle keyBundle) { } if (key.kty().equals(JsonWebKeyType.RSA)) { - // The private key is not available for KeyVault keys - _implementation = new RsaKey(key.kid(), key.toRSA(false)); + // The private key is not available for KeyVault keys + implementation = new RsaKey(key.kid(), key.toRSA(false)); } else if (key.kty().equals(JsonWebKeyType.RSAHSM)) { - // The private key is not available for KeyVault keys - _implementation = new RsaKey(key.kid(), key.toRSA(false)); + // The private key is not available for KeyVault keys + implementation = new RsaKey(key.kid(), key.toRSA(false)); } - if (_implementation == null) { + if (implementation == null) { throw new IllegalArgumentException(String.format("The key type %s is not supported", key.kty())); } - _client = client; + this.client = client; } @Override public void close() throws IOException { - if (_implementation != null) { - _implementation.close(); + if (implementation != null) { + implementation.close(); } } @Override public String getDefaultEncryptionAlgorithm() { - if (_implementation == null) { + if (implementation == null) { return null; } - return _implementation.getDefaultEncryptionAlgorithm(); + return implementation.getDefaultEncryptionAlgorithm(); } @Override public String getDefaultKeyWrapAlgorithm() { - if (_implementation == null) { + if (implementation == null) { return null; } - return _implementation.getDefaultKeyWrapAlgorithm(); + return implementation.getDefaultKeyWrapAlgorithm(); } @Override public String getDefaultSignatureAlgorithm() { - if (_implementation == null) { + if (implementation == null) { return null; } - return _implementation.getDefaultSignatureAlgorithm(); + return implementation.getDefaultSignatureAlgorithm(); } @Override public String getKid() { - if (_implementation == null) { + if (implementation == null) { return null; } - return _implementation.getKid(); + return implementation.getKid(); } @Override public ListenableFuture decryptAsync(byte[] ciphertext, byte[] iv, byte[] authenticationData, byte[] authenticationTag, String algorithm) { - if (_implementation == null) { + if (implementation == null) { return null; } @@ -159,35 +168,35 @@ public ListenableFuture decryptAsync(byte[] ciphertext, byte[] iv, byte[ // Never local ListenableFuture> futureCall = - _client.decryptAsync( - _implementation.getKid(), - algorithm, - ciphertext, - null ); - return Futures.transform(futureCall, new DecryptResultTransform() ); + client.decryptAsync( + implementation.getKid(), + algorithm, + ciphertext, + null); + return Futures.transform(futureCall, new DecryptResultTransform()); } @Override public ListenableFuture> encryptAsync(byte[] plaintext, byte[] iv, byte[] authenticationData, String algorithm) throws NoSuchAlgorithmException { - if (_implementation == null) { + if (implementation == null) { return null; } - return _implementation.encryptAsync(plaintext, iv, authenticationData, algorithm); + return implementation.encryptAsync(plaintext, iv, authenticationData, algorithm); } @Override public ListenableFuture> wrapKeyAsync(byte[] plaintext, String algorithm) throws NoSuchAlgorithmException { - if (_implementation == null) { + if (implementation == null) { return null; } - return _implementation.wrapKeyAsync(plaintext, algorithm); + return implementation.wrapKeyAsync(plaintext, algorithm); } @Override public ListenableFuture unwrapKeyAsync(byte[] ciphertext, String algorithm) { - if (_implementation == null) { + if (implementation == null) { return null; } @@ -197,17 +206,17 @@ public ListenableFuture unwrapKeyAsync(byte[] ciphertext, String algorit // Never local ListenableFuture> futureCall = - _client.unwrapKeyAsync( - _implementation.getKid(), - algorithm, - ciphertext, - null ); - return Futures.transform(futureCall, new DecryptResultTransform() ); + client.unwrapKeyAsync( + implementation.getKid(), + algorithm, + ciphertext, + null); + return Futures.transform(futureCall, new DecryptResultTransform()); } @Override - public ListenableFuture> signAsync(byte[] digest, String algorithm) { - if (_implementation == null) { + public ListenableFuture> signAsync(byte[] digest, String algorithm) throws NoSuchAlgorithmException { + if (implementation == null) { return null; } @@ -217,20 +226,20 @@ public ListenableFuture> signAsync(byte[] digest, String al // Never local ListenableFuture> futureCall = - _client.signAsync( - _implementation.getKid(), - algorithm, - digest, - null ); - return Futures.transform(futureCall, new SignResultTransform(algorithm) ); + client.signAsync( + implementation.getKid(), + algorithm, + digest, + null); + return Futures.transform(futureCall, new SignResultTransform(algorithm)); } @Override - public ListenableFuture verifyAsync(byte[] digest, byte[] signature, String algorithm) { - if (_implementation == null) { + public ListenableFuture verifyAsync(byte[] digest, byte[] signature, String algorithm) throws NoSuchAlgorithmException { + if (implementation == null) { return null; } - return _implementation.verifyAsync(digest, signature, algorithm); + return implementation.verifyAsync(digest, signature, algorithm); } } diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java index d5dc9605800fd..92f66ddba0c50 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java @@ -34,10 +34,17 @@ import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.rest.ServiceResponse; +/** + * The key resolver class that handles resolving key id to type {@link IKey} + * to be used for cryptography operations. + */ public class KeyVaultKeyResolver implements IKeyResolver { - static final Base64 _base64 = new Base64(-1, null, true); + static final Base64 BASE64 = new Base64(-1, null, true); + /** + * Transforms {@link KeyBundle} to {@link IKey}. + */ class FutureKeyFromKey implements Function, IKey> { protected FutureKeyFromKey() { @@ -47,15 +54,18 @@ protected FutureKeyFromKey() { @Override public IKey apply(ServiceResponse keyBundleResponse) { - KeyBundle keyBundle = keyBundleResponse.getBody(); + KeyBundle keyBundle = keyBundleResponse.getBody(); if (keyBundle != null) { - return new KeyVaultKey(_client, keyBundle); + return new KeyVaultKey(client, keyBundle); } return null; } } + /** + * Transforms {@link SecretBundle} to {@link IKey}. + */ class FutureKeyFromSecret implements Function, IKey> { protected FutureKeyFromSecret() { @@ -65,12 +75,12 @@ protected FutureKeyFromSecret() { @Override public IKey apply(ServiceResponse secretBundleResponse) { - SecretBundle secretBundle = secretBundleResponse.getBody(); + SecretBundle secretBundle = secretBundleResponse.getBody(); if (secretBundle != null && secretBundle.contentType().equalsIgnoreCase("application/octet-stream")) { - byte[] keyBytes = _base64.decode(secretBundle.value()); + byte[] keyBytes = BASE64.decode(secretBundle.value()); if (keyBytes != null) { - return new SymmetricKey(secretBundle.id(), keyBytes, _provider ); + return new SymmetricKey(secretBundle.id(), keyBytes, provider); } } @@ -78,29 +88,38 @@ public IKey apply(ServiceResponse secretBundleResponse) { } } - private final KeyVaultClient _client; - private final Provider _provider; + private final KeyVaultClient client; + private final Provider provider; + /** + * Constructor. + * @param client the key vault client + */ public KeyVaultKeyResolver(KeyVaultClient client) { - _client = client; - _provider = null; + this.client = client; + this.provider = null; } + /** + * Constructor. + * @param client the key vault client + * @param provider the java security provider + */ public KeyVaultKeyResolver(KeyVaultClient client, Provider provider) { - _client = client; - _provider = provider; + this.client = client; + this.provider = provider; } private ListenableFuture resolveKeyFromSecretAsync(String kid) { - - ListenableFuture> futureCall = _client.getSecretAsync(kid, null); - return Futures.transform(futureCall, new FutureKeyFromSecret()); + + ListenableFuture> futureCall = client.getSecretAsync(kid, null); + return Futures.transform(futureCall, new FutureKeyFromSecret()); } private ListenableFuture resolveKeyFromKeyAsync(String kid) { - - ListenableFuture> futureCall = _client.getKeyAsync(kid, null); - return Futures.transform(futureCall, new FutureKeyFromKey()); + + ListenableFuture> futureCall = client.getKeyAsync(kid, null); + return Futures.transform(futureCall, new FutureKeyFromKey()); } @Override diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java index 495e17811a1f5..3b4d8ad3b1afb 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java @@ -18,9 +18,16 @@ package com.microsoft.azure.keyvault.extensions; - +/** + * String handlers. + */ public class Strings { + /** + * Verifier if the string is empty or null. + * @param arg the string to verify + * @return true if the string is empty or null and false otherwise + */ public static boolean isNullOrEmpty(String arg) { if (arg == null || arg.isEmpty()) { @@ -30,6 +37,11 @@ public static boolean isNullOrEmpty(String arg) { return false; } + /** + * Verifier if the string is empty, contains only whitespace or is null. + * @param arg the string to verify + * @return true if the string is empty, contains only whitespace or is null and false otherwise + */ public static boolean isNullOrWhiteSpace(String arg) { if (Strings.isNullOrEmpty(arg) || arg.trim().isEmpty()) { diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java index 5625660e3f86f..a5263c820a6dd 100644 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java @@ -30,68 +30,68 @@ import static org.mockito.Mockito.*; public class CachingKeyResolverTest { - - @SuppressWarnings("unchecked") - final ListenableFuture ikeyAsync = mock(ListenableFuture.class); - final static String keyId = "keyID"; - final static String keyId2 = "keyID2"; - final static String keyId3 = "keyID3"; - + + @SuppressWarnings("unchecked") + final ListenableFuture ikeyAsync = mock(ListenableFuture.class); + final static String keyId = "keyID"; + final static String keyId2 = "keyID2"; + final static String keyId3 = "keyID3"; + - /* - * Tests the capacity limit of CachingKeyResolver by adding more keys - * than the cache limit and verifying that least recently used entity is evicted. - */ - @Test - public void KeyVault_CapacityLimitOfCachingKeyResolver() - { - IKeyResolver mockedKeyResolver = mock(IKeyResolver.class); - CachingKeyResolver resolver = new CachingKeyResolver(2, mockedKeyResolver); - - when(mockedKeyResolver.resolveKeyAsync(keyId)).thenReturn(ikeyAsync); - when(mockedKeyResolver.resolveKeyAsync(keyId2)).thenReturn(ikeyAsync); - when(mockedKeyResolver.resolveKeyAsync(keyId3)).thenReturn(ikeyAsync); - - resolver.resolveKeyAsync(keyId); - resolver.resolveKeyAsync(keyId2); - resolver.resolveKeyAsync(keyId3); - - resolver.resolveKeyAsync(keyId2); - resolver.resolveKeyAsync(keyId3); - resolver.resolveKeyAsync(keyId); - resolver.resolveKeyAsync(keyId3); - - verify(mockedKeyResolver, times(1)).resolveKeyAsync(keyId2); - verify(mockedKeyResolver, times(1)).resolveKeyAsync(keyId3); - verify(mockedKeyResolver, times(2)).resolveKeyAsync(keyId); - } - - /* - * Tests the behavior of CachingKeyResolver when resolving key throws - * and validate that the failed entity is not added to the cache. - */ - @Test - public void KeyVault_CachingKeyResolverThrows() - { - IKeyResolver mockedKeyResolver = mock(IKeyResolver.class); - CachingKeyResolver resolver = new CachingKeyResolver(10, mockedKeyResolver); - - // First throw exception and for the second call return a value - when(mockedKeyResolver.resolveKeyAsync(keyId)) - .thenThrow(new RuntimeException("test")) - .thenReturn(ikeyAsync); - - try { - resolver.resolveKeyAsync(keyId); - assertFalse("Should have thrown an exception.", true); - } - catch (UncheckedExecutionException e) { - assertTrue("RuntimeException is expected.", e.getCause() instanceof RuntimeException); - } - - resolver.resolveKeyAsync(keyId); - resolver.resolveKeyAsync(keyId); - - verify(mockedKeyResolver, times(2)).resolveKeyAsync(keyId); - } + /* + * Tests the capacity limit of CachingKeyResolver by adding more keys + * than the cache limit and verifying that least recently used entity is evicted. + */ + @Test + public void KeyVault_CapacityLimitOfCachingKeyResolver() + { + IKeyResolver mockedKeyResolver = mock(IKeyResolver.class); + CachingKeyResolver resolver = new CachingKeyResolver(2, mockedKeyResolver); + + when(mockedKeyResolver.resolveKeyAsync(keyId)).thenReturn(ikeyAsync); + when(mockedKeyResolver.resolveKeyAsync(keyId2)).thenReturn(ikeyAsync); + when(mockedKeyResolver.resolveKeyAsync(keyId3)).thenReturn(ikeyAsync); + + resolver.resolveKeyAsync(keyId); + resolver.resolveKeyAsync(keyId2); + resolver.resolveKeyAsync(keyId3); + + resolver.resolveKeyAsync(keyId2); + resolver.resolveKeyAsync(keyId3); + resolver.resolveKeyAsync(keyId); + resolver.resolveKeyAsync(keyId3); + + verify(mockedKeyResolver, times(1)).resolveKeyAsync(keyId2); + verify(mockedKeyResolver, times(1)).resolveKeyAsync(keyId3); + verify(mockedKeyResolver, times(2)).resolveKeyAsync(keyId); + } + + /* + * Tests the behavior of CachingKeyResolver when resolving key throws + * and validate that the failed entity is not added to the cache. + */ + @Test + public void KeyVault_CachingKeyResolverThrows() + { + IKeyResolver mockedKeyResolver = mock(IKeyResolver.class); + CachingKeyResolver resolver = new CachingKeyResolver(10, mockedKeyResolver); + + // First throw exception and for the second call return a value + when(mockedKeyResolver.resolveKeyAsync(keyId)) + .thenThrow(new RuntimeException("test")) + .thenReturn(ikeyAsync); + + try { + resolver.resolveKeyAsync(keyId); + assertFalse("Should have thrown an exception.", true); + } + catch (UncheckedExecutionException e) { + assertTrue("RuntimeException is expected.", e.getCause() instanceof RuntimeException); + } + + resolver.resolveKeyAsync(keyId); + resolver.resolveKeyAsync(keyId); + + verify(mockedKeyResolver, times(2)).resolveKeyAsync(keyId); + } } diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java index 7ee4da2e0c841..dad23b7d49d6d 100644 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java @@ -95,7 +95,7 @@ public String doAuthenticate(String authorization, String resource, String scope private static AuthenticationResult getAccessToken(String authorization, String resource) throws Exception { String clientId = System.getenv("arm.clientid"); - + if (clientId == null) { throw new Exception("Please inform arm.clientid in the environment settings."); } diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java index 0f7e57fc6af6c..58948e52d9bb2 100644 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java @@ -69,47 +69,47 @@ public void setUp() throws Exception { public void tearDown() throws Exception { } - private static final String KEY_NAME = "JavaExtensionKey"; - private static final String SECRET_NAME = "JavaExtensionSecret"; - + private static final String KEY_NAME = "JavaExtensionKey"; + private static final String SECRET_NAME = "JavaExtensionSecret"; + private static final Base64 _base64 = new Base64(-1, null, true); - @Test - public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, ExecutionException - { - try { - // Create a key on a vault. - CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); - ServiceResponse response = keyVaultClient.createKey(request); - KeyBundle bundle = response != null ? response.getBody() : null; - - if ( bundle != null ) - { - try - { - // ctor with client - KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient, _provider ); - - Future baseKeyFuture = resolver.resolveKeyAsync( bundle.keyIdentifier().baseIdentifier() ); - Future versionKeyFuture = resolver.resolveKeyAsync( bundle.keyIdentifier().identifier() ); - - IKey baseKey = baseKeyFuture.get(); - IKey versionKey = versionKeyFuture.get(); - - Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); - } - finally - { - // Delete the key - keyVaultClient.deleteKey( getVaultUri(), KEY_NAME ); - } - } - } - catch ( Exception ex ) - { - Assert.fail(ex.getMessage()); - } - } + @Test + public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, ExecutionException + { + try { + // Create a key on a vault. + CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); + ServiceResponse response = keyVaultClient.createKey(request); + KeyBundle bundle = response != null ? response.getBody() : null; + + if ( bundle != null ) + { + try + { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient, _provider ); + + Future baseKeyFuture = resolver.resolveKeyAsync( bundle.keyIdentifier().baseIdentifier() ); + Future versionKeyFuture = resolver.resolveKeyAsync( bundle.keyIdentifier().identifier() ); + + IKey baseKey = baseKeyFuture.get(); + IKey versionKey = versionKeyFuture.get(); + + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + } + finally + { + // Delete the key + keyVaultClient.deleteKey( getVaultUri(), KEY_NAME ); + } + } + } + catch ( Exception ex ) + { + Assert.fail(ex.getMessage()); + } + } /* * Test resolving a key from a 128bit secret encoded as base64 in a vault using various KeyVaultKeyResolver constructors. @@ -124,51 +124,51 @@ public void KeyVault_KeyVaultKeyResolver_Secret128Base64() throws InterruptedExc try { - SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); - - if ( secretBundle != null ) - { - try { - // ctor with client - KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); - - IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); - IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); - - // Check for correct key identifiers - Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); - - // Ensure key operations give the expected results - byte[] encrypted = null; - - try { - encrypted = baseKey.wrapKeyAsync(CEK, "A128KW").get().getLeft(); - } catch (Exception e) { - fail(e.getMessage()); - } - - // Assert - assertArrayEquals(EK, encrypted); - - try { - encrypted = versionKey.wrapKeyAsync(CEK, "A128KW").get().getLeft(); - } catch (Exception e) { - fail(e.getMessage()); - } - - // Assert - assertArrayEquals(EK, encrypted); - } - finally - { - // Delete the secret - keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); - } - } + SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + + if ( secretBundle != null ) + { + try { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); + + IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); + + // Check for correct key identifiers + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + + // Ensure key operations give the expected results + byte[] encrypted = null; + + try { + encrypted = baseKey.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + + try { + encrypted = versionKey.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + finally + { + // Delete the secret + keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); + } + } } catch ( Exception ex ) { - Assert.fail(ex.getMessage()); + Assert.fail(ex.getMessage()); } } @@ -184,51 +184,51 @@ public void KeyVault_KeyVaultKeyResolver_Secret192Base64() throws InterruptedExc byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; try { - SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); - - if ( secretBundle != null ) - { - try - { - // ctor with client - KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient, _provider ); - - IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); - IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); - - // Check for correct key identifiers - Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); - - // Ensure key operations give the expected results - byte[] encrypted = null; - - try { - encrypted = baseKey.wrapKeyAsync(CEK, "A192KW").get().getLeft(); - } catch (Exception e) { - fail(e.getMessage()); - } - - // Assert - assertArrayEquals(EK, encrypted); - - try { - encrypted = versionKey.wrapKeyAsync(CEK, "A192KW").get().getLeft(); - } catch (Exception e) { - fail(e.getMessage()); - } - - // Assert - assertArrayEquals(EK, encrypted); - } - finally - { - // Delete the key - keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); - } - } + SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + + if ( secretBundle != null ) + { + try + { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient, _provider ); + + IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); + + // Check for correct key identifiers + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + + // Ensure key operations give the expected results + byte[] encrypted = null; + + try { + encrypted = baseKey.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + + try { + encrypted = versionKey.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + finally + { + // Delete the key + keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); + } + } } catch (Exception ex) { - Assert.fail(ex.getMessage()); + Assert.fail(ex.getMessage()); } } @@ -244,51 +244,51 @@ public void KeyVault_KeyVaultKeyResolver_Secret256Base64() throws InterruptedExc byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; try { - SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); - - if ( secretBundle != null ) - { - try - { - // ctor with client - KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient, _provider ); - - IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); - IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); - - // Check for correct key identifiers - Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); - - // Ensure key operations give the expected results - byte[] encrypted = null; - - try { - encrypted = baseKey.wrapKeyAsync(CEK, "A256KW").get().getLeft(); - } catch (Exception e) { - fail(e.getMessage()); - } - - // Assert - assertArrayEquals(EK, encrypted); - - try { - encrypted = versionKey.wrapKeyAsync(CEK, "A256KW").get().getLeft(); - } catch (Exception e) { - fail(e.getMessage()); - } - - // Assert - assertArrayEquals(EK, encrypted); - } - finally - { - // Delete the key - keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); - } - } + SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + + if ( secretBundle != null ) + { + try + { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient, _provider ); + + IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); + + // Check for correct key identifiers + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + + // Ensure key operations give the expected results + byte[] encrypted = null; + + try { + encrypted = baseKey.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + + try { + encrypted = versionKey.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + finally + { + // Delete the key + keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); + } + } } catch ( Exception ex ) { - fail(ex.getMessage()); + fail(ex.getMessage()); } } } diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java index 8a0a5ab533c77..e6932d917cda1 100644 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java @@ -66,41 +66,41 @@ public void setUp() throws Exception { public void tearDown() throws Exception { } - private static final boolean _unlimited = hasUnlimitedCrypto(); - + private static final boolean _unlimited = hasUnlimitedCrypto(); + - private static final String KEY_NAME = "JavaExtensionKey"; - private static final String SECRET_NAME = "JavaExtensionSecret"; - + private static final String KEY_NAME = "JavaExtensionKey"; + private static final String SECRET_NAME = "JavaExtensionSecret"; + private static final Base64 _base64 = new Base64(-1, null, true); - @Test - public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, ExecutionException - { - try { - // Create a key on a vault. - CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); - KeyBundle keyBundle = keyVaultClient.createKey(request).getBody(); - - try - { - // ctor with client - final KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); + @Test + public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, ExecutionException + { + try { + // Create a key on a vault. + CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); + KeyBundle keyBundle = keyVaultClient.createKey(request).getBody(); + + try + { + // ctor with client + final KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); - IKey baseKey = resolver.resolveKeyAsync( keyBundle.keyIdentifier().baseIdentifier() ).get(); - IKey versionKey = resolver.resolveKeyAsync( keyBundle.keyIdentifier().identifier() ).get(); - - Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); - } - finally - { - // Delete the key - keyVaultClient.deleteKey( getVaultUri(), KEY_NAME ); - } - } catch(Exception ex) { - fail(ex.getMessage()); - } - } + IKey baseKey = resolver.resolveKeyAsync( keyBundle.keyIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( keyBundle.keyIdentifier().identifier() ).get(); + + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + } + finally + { + // Delete the key + keyVaultClient.deleteKey( getVaultUri(), KEY_NAME ); + } + } catch(Exception ex) { + fail(ex.getMessage()); + } + } /* * Test resolving a key from a 128bit secret encoded as base64 in a vault using various KeyVaultKeyResolver constructors. @@ -114,51 +114,51 @@ public void KeyVault_KeyVaultKeyResolver_Secret128Base64() throws InterruptedExc byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; try { - SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret(request).getBody(); - - if ( secretBundle != null ) - { - try - { - // ctor with client - KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); - - IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); - IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); - - // Check for correct key identifiers - Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); - - // Ensure key operations give the expected results - byte[] encrypted = null; - - try { - encrypted = baseKey.wrapKeyAsync(CEK, "A128KW").get().getLeft(); - } catch ( Exception ex ) { - fail(ex.getMessage()); - } - - // Assert - assertArrayEquals(EK, encrypted); - - try { - encrypted = versionKey.wrapKeyAsync(CEK, "A128KW").get().getLeft(); - } catch ( Exception ex ) { - fail(ex.getMessage()); - } - - // Assert - assertArrayEquals(EK, encrypted); - } - finally - { - // Delete the key - keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); - } - } + SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); + SecretBundle secretBundle = keyVaultClient.setSecret(request).getBody(); + + if ( secretBundle != null ) + { + try + { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); + + IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); + + // Check for correct key identifiers + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + + // Ensure key operations give the expected results + byte[] encrypted = null; + + try { + encrypted = baseKey.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch ( Exception ex ) { + fail(ex.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + + try { + encrypted = versionKey.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch ( Exception ex ) { + fail(ex.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + finally + { + // Delete the key + keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); + } + } } catch ( Exception ex ) { - fail(ex.getMessage()); + fail(ex.getMessage()); } } @@ -174,64 +174,64 @@ public void KeyVault_KeyVaultKeyResolver_Secret192Base64() throws InterruptedExc byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; try { - SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); - - if ( secretBundle != null ) - { - try - { - // ctor with client - KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); - - IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); - IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); - - // Check for correct key identifiers - Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); - - // Ensure key operations give the expected results - byte[] encrypted = null; - - try { - encrypted = baseKey.wrapKeyAsync(CEK, "A192KW").get().getLeft(); - - if (!_unlimited) fail("Expected ExecutionException"); - } catch (ExecutionException e) { - // In the limited case, the failure should be InvalidKeyException - // In the unlimited case, this should not fail - if (!_unlimited) { - Throwable cause = e.getCause(); - if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); - } else { - fail("ExecutionException"); - } - } catch ( Exception ex ) { - fail(ex.getMessage()); - } - - if ( _unlimited ) { - // Assert - assertArrayEquals(EK, encrypted); - - try { - encrypted = versionKey.wrapKeyAsync(CEK, "A192KW").get().getLeft(); - } catch ( Exception ex ) { - fail(ex.getMessage()); - } - - // Assert - assertArrayEquals(EK, encrypted); - } - } - finally - { - // Delete the key - keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); - } - } + SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + + if ( secretBundle != null ) + { + try + { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); + + IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); + + // Check for correct key identifiers + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + + // Ensure key operations give the expected results + byte[] encrypted = null; + + try { + encrypted = baseKey.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + + if (!_unlimited) fail("Expected ExecutionException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!_unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch ( Exception ex ) { + fail(ex.getMessage()); + } + + if ( _unlimited ) { + // Assert + assertArrayEquals(EK, encrypted); + + try { + encrypted = versionKey.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + } catch ( Exception ex ) { + fail(ex.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + } + finally + { + // Delete the key + keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); + } + } } catch ( Exception ex ) { - fail(ex.getMessage()); + fail(ex.getMessage()); } } @@ -247,70 +247,70 @@ public void KeyVault_KeyVaultKeyResolver_Secret256Base64() throws InterruptedExc byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; try { - SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); - - if ( secretBundle != null ) - { - try - { - // ctor with client - KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); - - IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); - IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); - - // Check for correct key identifiers - Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); - - // Ensure key operations give the expected results - byte[] encrypted = null; - - try { - encrypted = baseKey.wrapKeyAsync(CEK, "A256KW").get().getLeft(); - - if (!_unlimited) fail("Expected ExecutionException"); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - // In the limited case, the failure should be InvalidKeyException - // In the unlimited case, this should not fail - if (!_unlimited) { - Throwable cause = e.getCause(); - if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); - } else { - fail("ExecutionException"); - } - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - if ( _unlimited ) { - // Assert - assertArrayEquals(EK, encrypted); - - try { - encrypted = versionKey.wrapKeyAsync(CEK, "A256KW").get().getLeft(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - } - } - finally - { - // Delete the key - keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); - } - } + SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + + if ( secretBundle != null ) + { + try + { + // ctor with client + KeyVaultKeyResolver resolver = new KeyVaultKeyResolver( keyVaultClient ); + + IKey baseKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().baseIdentifier() ).get(); + IKey versionKey = resolver.resolveKeyAsync( secretBundle.secretIdentifier().identifier() ).get(); + + // Check for correct key identifiers + Assert.assertEquals( baseKey.getKid(), versionKey.getKid() ); + + // Ensure key operations give the expected results + byte[] encrypted = null; + + try { + encrypted = baseKey.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + + if (!_unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!_unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if ( _unlimited ) { + // Assert + assertArrayEquals(EK, encrypted); + + try { + encrypted = versionKey.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + } + finally + { + // Delete the key + keyVaultClient.deleteSecret( getVaultUri(), SECRET_NAME ); + } + } } catch ( Exception ex ) { - fail(ex.getMessage()); + fail(ex.getMessage()); } } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java index 0e1bc942d8620..334ad65b5f3d4 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java @@ -18,20 +18,43 @@ package com.microsoft.azure.keyvault; +/** + * The certificate identifier. + */ public final class CertificateIdentifier extends ObjectIdentifier { - + + /** + * Verify whether the identifier is for certificate. + * @param identifier the certificate identifier + * @return true if the identifier is the certificate identifier. False otherwise. + */ public static boolean isCertificateIdentifier(String identifier) { return ObjectIdentifier.isObjectIdentifier("certificates", identifier); } + /** + * Constructor. + * @param vault The vault url + * @param name the certificate name + */ public CertificateIdentifier(String vault, String name) { this(vault, name, ""); } + /** + * Constructor. + * @param vault the vault url + * @param name the certificate name + * @param version the certificate version + */ public CertificateIdentifier(String vault, String name, String version) { super(vault, "certificates", name, version); } + /** + * Constructor. + * @param identifier the certificate identifier + */ public CertificateIdentifier(String identifier) { super("certificates", identifier); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java index 9c6a4aab0d395..e902dad696565 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java @@ -21,44 +21,62 @@ import java.net.URI; import java.net.URISyntaxException; +/** + * The certificate operation identifier. + */ public final class CertificateOperationIdentifier extends ObjectIdentifier { - + + /** + * Verifies whether the identifier belongs to a key vault certificate operation. + * @param identifier the key vault certificate operation identifier. + * @return true if the identifier belongs to a key vault certificate operation. False otherwise. + */ public static boolean isCertificateOperationIdentifier(String identifier) { - identifier = verifyNonEmpty(identifier, "identifier"); + identifier = verifyNonEmpty(identifier, "identifier"); - URI baseUri; - try { - baseUri = new URI(identifier); - } catch (URISyntaxException e) { - return false; - } + URI baseUri; + try { + baseUri = new URI(identifier); + } catch (URISyntaxException e) { + return false; + } - // Path is of the form "/certificates/[name]/pending" - String[] segments = baseUri.getPath().split("/"); - if (segments.length != 4) { - return false; - } + // Path is of the form "/certificates/[name]/pending" + String[] segments = baseUri.getPath().split("/"); + if (segments.length != 4) { + return false; + } - if (!(segments[1]).equals("certificates")) { - return false; - } + if (!(segments[1]).equals("certificates")) { + return false; + } - if (!(segments[3]).equals("pending")) { - return false; - } + if (!(segments[3]).equals("pending")) { + return false; + } - return true; + return true; } - public CertificateOperationIdentifier(String vault, String name, String version) { - super(vault, "certificates", name, "pending"); - } + /** + * Constructor. + * @param vault the vault url + * @param name the name of certificate + * @param version the certificate version + */ + public CertificateOperationIdentifier(String vault, String name, String version) { + super(vault, "certificates", name, "pending"); + } - public CertificateOperationIdentifier(String identifier) { - super("certificates", identifier); - if (!version().equals("pending")) { - throw new IllegalArgumentException( - String.format("Invalid CertificateOperationIdentifier: {0}", identifier)); - } - } + /** + * Constructor. + * @param identifier the key vault certificate operation identifier. + */ + public CertificateOperationIdentifier(String identifier) { + super("certificates", identifier); + if (!version().equals("pending")) { + throw new IllegalArgumentException( + String.format("Invalid CertificateOperationIdentifier: {0}", identifier)); + } + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java index bbc435c681893..69b685c50ea40 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java @@ -22,8 +22,16 @@ import java.net.URISyntaxException; import java.security.InvalidParameterException; +/** + * The issuer identifier. + */ public final class IssuerIdentifier extends ObjectIdentifier { - + + /** + * Verifies whether the identifier belongs to a key vault issuer. + * @param identifier the key vault issuer identifier. + * @return true if the identifier belongs to a key vault issuer. False otherwise. + */ public static boolean isIssuerIdentifier(String identifier) { identifier = verifyNonEmpty(identifier, "identifier"); @@ -42,14 +50,19 @@ public static boolean isIssuerIdentifier(String identifier) { return true; } + /** + * Constructor. + * @param vault the vault url. + * @param name the name of issuer. + */ public IssuerIdentifier(String vault, String name) { vault = verifyNonEmpty(vault, "vault"); name = verifyNonEmpty(name, "name"); URI baseUri; - try { - baseUri = new URI(vault); + try { + baseUri = new URI(vault); } catch (URISyntaxException e) { throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. Not a valid URI", vault)); } @@ -57,11 +70,15 @@ public IssuerIdentifier(String vault, String name) { this.name = name; this.version = null; this.vault = String.format("%s://%s", baseUri.getScheme(), getFullAuthority(baseUri)); - + baseIdentifier = String.format("%s/%s/%s", this.vault, "certificates/issuers", this.name); identifier = baseIdentifier; } + /** + * Constructor. + * @param identifier the key vault issuer identifier. + */ public IssuerIdentifier(String identifier) { identifier = verifyNonEmpty(identifier, "identifier"); @@ -70,22 +87,26 @@ public IssuerIdentifier(String identifier) { try { baseUri = new URI(identifier); } catch (URISyntaxException e) { - throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. Not a valid URI", identifier)); + throw new InvalidParameterException( + String.format("Invalid ObjectIdentifier: %s. Not a valid URI", identifier)); } // Path is of the form "/collection/name[/version]" String[] segments = baseUri.getPath().split("/"); if (segments.length != 4) { - throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. Bad number of segments: %d", identifier, segments.length)); + throw new InvalidParameterException(String + .format("Invalid ObjectIdentifier: %s. Bad number of segments: %d", identifier, segments.length)); } - + if (!segments[1].equals("certificates")) { throw new InvalidParameterException( - String.format("Invalid ObjectIdentifier: %s. Segment [1] should be '%s', found '%s'", identifier, "certificates", segments[1])); + String.format("Invalid ObjectIdentifier: %s. Segment [1] should be '%s', found '%s'", identifier, + "certificates", segments[1])); } if (!segments[2].equals("issuers")) { throw new InvalidParameterException( - String.format("Invalid ObjectIdentifier: %s. Segment [2] should be '%s', found '%s'", identifier, "issuers", segments[2])); + String.format("Invalid ObjectIdentifier: %s. Segment [2] should be '%s', found '%s'", identifier, + "issuers", segments[2])); } name = segments[3]; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java index 3d492f693046b..b28d4464449e2 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java @@ -18,19 +18,43 @@ package com.microsoft.azure.keyvault; +/** + * The Key Vault key identifier. + */ public final class KeyIdentifier extends ObjectIdentifier { + + /** + * Verifies whether the identifier belongs to a key vault key. + * @param identifier the key vault key identifier. + * @return true if the identifier belongs to a key vault key. False otherwise. + */ public static boolean isKeyIdentifier(String identifier) { return ObjectIdentifier.isObjectIdentifier("keys", identifier); } + /** + * Constructor. + * @param vault the vault url. + * @param name the name of key. + */ public KeyIdentifier(String vault, String name) { this(vault, name, ""); } + /** + * Constructor. + * @param vault the vault url. + * @param name the name of key. + * @param version the key version. + */ public KeyIdentifier(String vault, String name, String version) { super(vault, "keys", name, version); } + /** + * Constructor. + * @param identifier the key vault key identifier. + */ public KeyIdentifier(String identifier) { super("keys", identifier); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 0312180666e2d..52cbba1b6abbe 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -67,9 +67,10 @@ public final class KeyVaultClient { /** The Retrofit service to perform REST calls. */ private KeyVaultClientService service; - + /** * Gets the {@link AzureClient} used for long running operations. + * * @return the azure client; */ public AzureClient getAzureClient() { @@ -84,7 +85,7 @@ public AzureClient getAzureClient() { public String apiVersion() { return innerKeyVaultClient.apiVersion(); } - + /** * Gets Gets or sets the preferred language for the response. * @@ -193,15 +194,15 @@ interface KeyVaultClientService { * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse createKey(CreateKeyRequest createKeyRequest) - throws KeyVaultErrorException, IllegalArgumentException, IOException { - return innerKeyVaultClient.createKey( - createKeyRequest.vaultBaseUrl(), - createKeyRequest.keyName(), - createKeyRequest.keyType(), - createKeyRequest.keySize(), - createKeyRequest.keyOperations(), - createKeyRequest.keyAttributes(), - createKeyRequest.tags()); + throws KeyVaultErrorException, IllegalArgumentException, IOException { + return innerKeyVaultClient.createKey( + createKeyRequest.vaultBaseUrl(), + createKeyRequest.keyName(), + createKeyRequest.keyType(), + createKeyRequest.keySize(), + createKeyRequest.keyOperations(), + createKeyRequest.keyAttributes(), + createKeyRequest.tags()); } /** @@ -213,15 +214,15 @@ public ServiceResponse createKey(CreateKeyRequest createKeyRequest) * @return the {@link ServiceCall} object */ public ServiceCall createKeyAsync(CreateKeyRequest createKeyRequest, ServiceCallback serviceCallback) { - return innerKeyVaultClient.createKeyAsync( - createKeyRequest.vaultBaseUrl(), - createKeyRequest.keyName(), - createKeyRequest.keyType(), - createKeyRequest.keySize(), - createKeyRequest.keyOperations(), - createKeyRequest.keyAttributes(), - createKeyRequest.tags(), - serviceCallback); + return innerKeyVaultClient.createKeyAsync( + createKeyRequest.vaultBaseUrl(), + createKeyRequest.keyName(), + createKeyRequest.keyType(), + createKeyRequest.keySize(), + createKeyRequest.keyOperations(), + createKeyRequest.keyAttributes(), + createKeyRequest.tags(), + serviceCallback); } /** @@ -235,14 +236,14 @@ public ServiceCall createKeyAsync(CreateKeyRequest createKeyRequest, * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importKey(ImportKeyRequest importKeyRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.importKey( - importKeyRequest.vaultBaseUrl(), - importKeyRequest.keyName(), - importKeyRequest.key(), - importKeyRequest.isHsm(), - importKeyRequest.keyAttributes(), - importKeyRequest.tags()); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.importKey( + importKeyRequest.vaultBaseUrl(), + importKeyRequest.keyName(), + importKeyRequest.key(), + importKeyRequest.isHsm(), + importKeyRequest.keyAttributes(), + importKeyRequest.tags()); } /** @@ -254,14 +255,14 @@ public ServiceResponse importKey(ImportKeyRequest importKeyRequest) * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(ImportKeyRequest importKeyRequest, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.importKeyAsync( - importKeyRequest.vaultBaseUrl(), - importKeyRequest.keyName(), - importKeyRequest.key(), - importKeyRequest.isHsm(), - importKeyRequest.keyAttributes(), - importKeyRequest.tags(), - serviceCallback); + return innerKeyVaultClient.importKeyAsync( + importKeyRequest.vaultBaseUrl(), + importKeyRequest.keyName(), + importKeyRequest.key(), + importKeyRequest.isHsm(), + importKeyRequest.keyAttributes(), + importKeyRequest.tags(), + serviceCallback); } /** @@ -275,8 +276,8 @@ public ServiceCall importKeyAsync(ImportKeyRequest importKeyRequest, * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.deleteKey(vaultBaseUrl, keyName); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.deleteKey(vaultBaseUrl, keyName); } /** @@ -288,7 +289,7 @@ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) * @return the {@link ServiceCall} object */ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.deleteKeyAsync(vaultBaseUrl, keyName, serviceCallback); + return innerKeyVaultClient.deleteKeyAsync(vaultBaseUrl, keyName, serviceCallback); } /** @@ -302,14 +303,14 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateKey(UpdateKeyRequest updateKeyRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.updateKey( - updateKeyRequest.vaultBaseUrl(), - updateKeyRequest.keyName(), - updateKeyRequest.keyVersion(), - updateKeyRequest.keyOperations(), - updateKeyRequest.keyAttributes(), - updateKeyRequest.tags()); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.updateKey( + updateKeyRequest.vaultBaseUrl(), + updateKeyRequest.keyName(), + updateKeyRequest.keyVersion(), + updateKeyRequest.keyOperations(), + updateKeyRequest.keyAttributes(), + updateKeyRequest.tags()); } /** @@ -321,14 +322,14 @@ public ServiceResponse updateKey(UpdateKeyRequest updateKeyRequest) * @return the {@link ServiceCall} object */ public ServiceCall updateKeyAsync(UpdateKeyRequest updateKeyRequest, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.updateKeyAsync( - updateKeyRequest.vaultBaseUrl(), - updateKeyRequest.keyName(), - updateKeyRequest.keyVersion(), - updateKeyRequest.keyOperations(), - updateKeyRequest.keyAttributes(), - updateKeyRequest.tags(), - serviceCallback); + return innerKeyVaultClient.updateKeyAsync( + updateKeyRequest.vaultBaseUrl(), + updateKeyRequest.keyName(), + updateKeyRequest.keyVersion(), + updateKeyRequest.keyOperations(), + updateKeyRequest.keyAttributes(), + updateKeyRequest.tags(), + serviceCallback); } /** @@ -341,9 +342,9 @@ public ServiceCall updateKeyAsync(UpdateKeyRequest updateKeyRequest, * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getKey(String keyIdentifier) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.getKey(id.vault, id.name, id.version == null? "" : id.version); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.getKey(id.vault, id.name, id.version == null ? "" : id.version); } /** @@ -354,8 +355,8 @@ public ServiceResponse getKey(String keyIdentifier) * @return the {@link ServiceCall} object */ public ServiceCall getKeyAsync(String keyIdentifier, final ServiceCallback serviceCallback) { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.getKeyAsync(id.vault, id.name, id.version == null? "" : id.version, serviceCallback); + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.getKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); } /** @@ -369,8 +370,8 @@ public ServiceCall getKeyAsync(String keyIdentifier, final ServiceCal * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getKey(String vaultBaseUrl, String keyName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, ""); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, ""); } /** @@ -382,7 +383,7 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyName) * @return the {@link ServiceCall} object */ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.getKeyAsync(vaultBaseUrl, keyName, "", serviceCallback); + return innerKeyVaultClient.getKeyAsync(vaultBaseUrl, keyName, "", serviceCallback); } /** @@ -397,8 +398,8 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, f * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, keyVersion); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, keyVersion); } /** @@ -411,7 +412,7 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyName, St * @return the {@link ServiceCall} object */ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.getKeyAsync(vaultBaseUrl, keyName, keyVersion, serviceCallback); + return innerKeyVaultClient.getKeyAsync(vaultBaseUrl, keyName, keyVersion, serviceCallback); } /** @@ -425,8 +426,8 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName); } /** @@ -438,7 +439,7 @@ public ServiceResponse> getKeyVersions(final String vaultBase * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, serviceCallback); + return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, serviceCallback); } /** * List the versions of the specified key. @@ -452,8 +453,8 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName, maxresults); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName, maxresults); } /** @@ -466,7 +467,7 @@ public ServiceResponse> getKeyVersions(final String vaultBase * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, maxresults, serviceCallback); + return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, maxresults, serviceCallback); } /** @@ -479,8 +480,8 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeys(final String vaultBaseUrl) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getKeys(vaultBaseUrl); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKeys(vaultBaseUrl); } /** @@ -491,7 +492,7 @@ public ServiceResponse> getKeys(final String vaultBaseUrl) * @return the {@link ServiceCall} object */ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, serviceCallback); + return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, serviceCallback); } /** * List keys in the specified vault. @@ -504,8 +505,8 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getKeys(vaultBaseUrl, maxresults); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKeys(vaultBaseUrl, maxresults); } /** @@ -517,7 +518,7 @@ public ServiceResponse> getKeys(final String vaultBaseUrl, fi * @return the {@link ServiceCall} object */ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, maxresults, serviceCallback); + return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, maxresults, serviceCallback); } /** @@ -531,8 +532,8 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final * @return the BackupKeyResult object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse backupKey(String vaultBaseUrl, String keyName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.backupKey(vaultBaseUrl, keyName); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.backupKey(vaultBaseUrl, keyName); } /** @@ -544,7 +545,7 @@ public ServiceResponse backupKey(String vaultBaseUrl, String ke * @return the {@link ServiceCall} object */ public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.backupKeyAsync(vaultBaseUrl, keyName, serviceCallback); + return innerKeyVaultClient.backupKeyAsync(vaultBaseUrl, keyName, serviceCallback); } /** @@ -558,8 +559,8 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String k * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.restoreKey(vaultBaseUrl, keyBundleBackup); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.restoreKey(vaultBaseUrl, keyBundleBackup); } /** @@ -571,7 +572,7 @@ public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBund * @return the {@link ServiceCall} object */ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.restoreKeyAsync(vaultBaseUrl, keyBundleBackup, serviceCallback); + return innerKeyVaultClient.restoreKeyAsync(vaultBaseUrl, keyBundleBackup, serviceCallback); } /** @@ -586,9 +587,9 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse encrypt(String keyIdentifier, String algorithm, byte[] value) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.encrypt(id.vault, id.name, id.version == null? "" : id.version, algorithm, value); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.encrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); } /** @@ -601,8 +602,8 @@ public ServiceResponse encrypt(String keyIdentifier, String * @return the {@link ServiceCall} object */ public ServiceCall encryptAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.encryptAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.encryptAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } /** @@ -617,9 +618,9 @@ public ServiceCall encryptAsync(String keyIdentifier, String * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse decrypt(String keyIdentifier, String algorithm, byte[] value) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.decrypt(id.vault, id.name, id.version == null? "" : id.version, algorithm, value); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.decrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); } /** @@ -632,8 +633,8 @@ public ServiceResponse decrypt(String keyIdentifier, String * @return the {@link ServiceCall} object */ public ServiceCall decryptAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.decryptAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.decryptAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } /** @@ -648,9 +649,9 @@ public ServiceCall decryptAsync(String keyIdentifier, String * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse sign(String keyIdentifier, String algorithm, byte[] value) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.sign(id.vault, id.name, id.version == null? "" : id.version, algorithm, value); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.sign(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); } /** @@ -663,8 +664,8 @@ public ServiceResponse sign(String keyIdentifier, String alg * @return the {@link ServiceCall} object */ public ServiceCall signAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.signAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.signAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } /** @@ -680,9 +681,9 @@ public ServiceCall signAsync(String keyIdentifier, String al * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse verify(String keyIdentifier, String algorithm, byte[] digest, byte[] signature) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.verify(id.vault, id.name, id.version == null? "" : id.version, algorithm, digest, signature); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.verify(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature); } /** @@ -696,8 +697,8 @@ public ServiceResponse verify(String keyIdentifier, String algo * @return the {@link ServiceCall} object */ public ServiceCall verifyAsync(String keyIdentifier, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.verifyAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, digest, signature, serviceCallback); + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.verifyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature, serviceCallback); } /** @@ -712,9 +713,9 @@ public ServiceCall verifyAsync(String keyIdentifier, String alg * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse wrapKey(String keyIdentifier, String algorithm, byte[] value) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.wrapKey(id.vault, id.name, id.version == null? "" : id.version, algorithm, value); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.wrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); } /** @@ -727,8 +728,8 @@ public ServiceResponse wrapKey(String keyIdentifier, String * @return the {@link ServiceCall} object */ public ServiceCall wrapKeyAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.wrapKeyAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.wrapKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } /** @@ -743,9 +744,9 @@ public ServiceCall wrapKeyAsync(String keyIdentifier, String * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse unwrapKey(String keyIdentifier, String algorithm, byte[] value) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.unwrapKey(id.vault, id.name, id.version == null? "" : id.version, algorithm, value); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.unwrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); } /** @@ -758,8 +759,8 @@ public ServiceResponse unwrapKey(String keyIdentifier, Strin * @return the {@link ServiceCall} object */ public ServiceCall unwrapKeyAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.unwrapKeyAsync(id.vault, id.name, id.version == null? "" : id.version, algorithm, value, serviceCallback); + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + return innerKeyVaultClient.unwrapKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } /** @@ -773,14 +774,14 @@ public ServiceCall unwrapKeyAsync(String keyIdentifier, Stri * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse setSecret(SetSecretRequest setSecretRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.setSecret( - setSecretRequest.vaultBaseUrl(), - setSecretRequest.secretName(), - setSecretRequest.value(), - setSecretRequest.tags(), - setSecretRequest.contentType(), - setSecretRequest.secretAttributes()); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.setSecret( + setSecretRequest.vaultBaseUrl(), + setSecretRequest.secretName(), + setSecretRequest.value(), + setSecretRequest.tags(), + setSecretRequest.contentType(), + setSecretRequest.secretAttributes()); } /** @@ -792,14 +793,14 @@ public ServiceResponse setSecret(SetSecretRequest setSecretRequest * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(SetSecretRequest setSecretRequest, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.setSecretAsync( - setSecretRequest.vaultBaseUrl(), - setSecretRequest.secretName(), - setSecretRequest.value(), - setSecretRequest.tags(), - setSecretRequest.contentType(), - setSecretRequest.secretAttributes(), - serviceCallback); + return innerKeyVaultClient.setSecretAsync( + setSecretRequest.vaultBaseUrl(), + setSecretRequest.secretName(), + setSecretRequest.value(), + setSecretRequest.tags(), + setSecretRequest.contentType(), + setSecretRequest.secretAttributes(), + serviceCallback); } /** @@ -813,8 +814,8 @@ public ServiceCall setSecretAsync(SetSecretRequest setSecretReques * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.deleteSecret(vaultBaseUrl, secretName); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.deleteSecret(vaultBaseUrl, secretName); } /** @@ -826,7 +827,7 @@ public ServiceResponse deleteSecret(String vaultBaseUrl, String se * @return the {@link ServiceCall} object */ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.deleteSecretAsync(vaultBaseUrl, secretName, serviceCallback); + return innerKeyVaultClient.deleteSecretAsync(vaultBaseUrl, secretName, serviceCallback); } /** @@ -840,14 +841,14 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String s * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateSecret(UpdateSecretRequest updateSecretRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.updateSecret( - updateSecretRequest.vaultBaseUrl(), - updateSecretRequest.secretName(), - updateSecretRequest.secretVersion(), - updateSecretRequest.contentType(), - updateSecretRequest.secretAttributes(), - updateSecretRequest.tags()); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.updateSecret( + updateSecretRequest.vaultBaseUrl(), + updateSecretRequest.secretName(), + updateSecretRequest.secretVersion(), + updateSecretRequest.contentType(), + updateSecretRequest.secretAttributes(), + updateSecretRequest.tags()); } /** @@ -859,14 +860,14 @@ public ServiceResponse updateSecret(UpdateSecretRequest updateSecr * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(UpdateSecretRequest updateSecretRequest, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.updateSecretAsync( - updateSecretRequest.vaultBaseUrl(), - updateSecretRequest.secretName(), - updateSecretRequest.secretVersion(), - updateSecretRequest.contentType(), - updateSecretRequest.secretAttributes(), - updateSecretRequest.tags(), - serviceCallback); + return innerKeyVaultClient.updateSecretAsync( + updateSecretRequest.vaultBaseUrl(), + updateSecretRequest.secretName(), + updateSecretRequest.secretVersion(), + updateSecretRequest.contentType(), + updateSecretRequest.secretAttributes(), + updateSecretRequest.tags(), + serviceCallback); } /** @@ -879,9 +880,9 @@ public ServiceCall updateSecretAsync(UpdateSecretRequest updateSec * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getSecret(String secretIdentifier) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - SecretIdentifier id = new SecretIdentifier(secretIdentifier); - return innerKeyVaultClient.getSecret(id.vault, id.name, id.version == null? "" : id.version); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + SecretIdentifier id = new SecretIdentifier(secretIdentifier); + return innerKeyVaultClient.getSecret(id.vault, id.name, id.version == null ? "" : id.version); } /** @@ -892,8 +893,8 @@ public ServiceResponse getSecret(String secretIdentifier) * @return the {@link ServiceCall} object */ public ServiceCall getSecretAsync(String secretIdentifier, final ServiceCallback serviceCallback) { - SecretIdentifier id = new SecretIdentifier(secretIdentifier); - return innerKeyVaultClient.getSecretAsync(id.vault, id.name, id.version == null? "" : id.version, serviceCallback); + SecretIdentifier id = new SecretIdentifier(secretIdentifier); + return innerKeyVaultClient.getSecretAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); } /** @@ -907,8 +908,8 @@ public ServiceCall getSecretAsync(String secretIdentifier, final S * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getSecret(String vaultBaseUrl, String secretName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, ""); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, ""); } /** @@ -920,7 +921,7 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre * @return the {@link ServiceCall} object */ public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.getSecretAsync(vaultBaseUrl, secretName, "", serviceCallback); + return innerKeyVaultClient.getSecretAsync(vaultBaseUrl, secretName, "", serviceCallback); } /** @@ -935,8 +936,8 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getSecret(String vaultBaseUrl, String secretName, String secretVersion) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, secretVersion == null? "" : secretVersion); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, secretVersion == null ? "" : secretVersion); } /** @@ -949,7 +950,7 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre * @return the {@link ServiceCall} object */ public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.getSecretAsync(vaultBaseUrl, secretName, secretVersion == null? "" : secretVersion, serviceCallback); + return innerKeyVaultClient.getSecretAsync(vaultBaseUrl, secretName, secretVersion == null ? "" : secretVersion, serviceCallback); } /** @@ -962,8 +963,8 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecrets(final String vaultBaseUrl) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getSecrets(vaultBaseUrl); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecrets(vaultBaseUrl); } /** @@ -974,7 +975,7 @@ public ServiceResponse> getSecrets(final String vaultBaseU * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, serviceCallback); + return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, serviceCallback); } /** * List secrets in the specified vault. @@ -987,8 +988,8 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getSecrets(vaultBaseUrl, maxresults); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecrets(vaultBaseUrl, maxresults); } /** @@ -1000,7 +1001,7 @@ public ServiceResponse> getSecrets(final String vaultBaseU * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, maxresults, serviceCallback); + return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, maxresults, serviceCallback); } /** @@ -1014,8 +1015,8 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName); } /** @@ -1027,7 +1028,7 @@ public ServiceResponse> getSecretVersions(final String vau * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, serviceCallback); + return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, serviceCallback); } /** * List the versions of the specified secret. @@ -1041,8 +1042,8 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName, maxresults); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName, maxresults); } /** @@ -1055,7 +1056,7 @@ public ServiceResponse> getSecretVersions(final String vau * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, maxresults, serviceCallback); + return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, maxresults, serviceCallback); } /** @@ -1068,8 +1069,8 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificates(final String vaultBaseUrl) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificates(vaultBaseUrl); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificates(vaultBaseUrl); } /** @@ -1080,7 +1081,7 @@ public ServiceResponse> getCertificates(final String * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, serviceCallback); + return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, serviceCallback); } /** * List certificates in the specified vault. @@ -1093,8 +1094,8 @@ public ServiceCall> getCertificatesAsync(final String vaul * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificates(final String vaultBaseUrl, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificates(vaultBaseUrl, maxresults); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificates(vaultBaseUrl, maxresults); } /** @@ -1106,7 +1107,7 @@ public ServiceResponse> getCertificates(final String * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, maxresults, serviceCallback); + return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, maxresults, serviceCallback); } /** @@ -1120,8 +1121,8 @@ public ServiceCall> getCertificatesAsync(final String vaul * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.deleteCertificate(vaultBaseUrl, certificateName); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.deleteCertificate(vaultBaseUrl, certificateName); } /** @@ -1133,7 +1134,7 @@ public ServiceResponse deleteCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.deleteCertificateAsync(vaultBaseUrl, certificateName, serviceCallback); + return innerKeyVaultClient.deleteCertificateAsync(vaultBaseUrl, certificateName, serviceCallback); } /** @@ -1147,8 +1148,8 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl * @return the Contacts object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse setCertificateContacts(String vaultBaseUrl, Contacts contacts) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.setCertificateContacts(vaultBaseUrl, contacts); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.setCertificateContacts(vaultBaseUrl, contacts); } /** @@ -1160,7 +1161,7 @@ public ServiceResponse setCertificateContacts(String vaultBaseUrl, Con * @return the {@link ServiceCall} object */ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.setCertificateContactsAsync(vaultBaseUrl, contacts, serviceCallback); + return innerKeyVaultClient.setCertificateContactsAsync(vaultBaseUrl, contacts, serviceCallback); } /** @@ -1173,8 +1174,8 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Co * @return the Contacts object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificateContacts(String vaultBaseUrl) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateContacts(vaultBaseUrl); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateContacts(vaultBaseUrl); } /** @@ -1185,7 +1186,7 @@ public ServiceResponse getCertificateContacts(String vaultBaseUrl) * @return the {@link ServiceCall} object */ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.getCertificateContactsAsync(vaultBaseUrl, serviceCallback); + return innerKeyVaultClient.getCertificateContactsAsync(vaultBaseUrl, serviceCallback); } /** @@ -1198,8 +1199,8 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, fi * @return the Contacts object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.deleteCertificateContacts(vaultBaseUrl); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.deleteCertificateContacts(vaultBaseUrl); } /** @@ -1210,7 +1211,7 @@ public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.deleteCertificateContactsAsync(vaultBaseUrl, serviceCallback); + return innerKeyVaultClient.deleteCertificateContactsAsync(vaultBaseUrl, serviceCallback); } /** @@ -1223,8 +1224,8 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl); } /** @@ -1235,7 +1236,7 @@ public ServiceResponse> getCertificateIssuers(f * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, serviceCallback); + return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, serviceCallback); } /** * List certificate issuers for the specified vault. @@ -1248,8 +1249,8 @@ public ServiceCall> getCertificateIssuersAsync(final * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl, maxresults); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl, maxresults); } /** @@ -1261,7 +1262,7 @@ public ServiceResponse> getCertificateIssuers(f * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, maxresults, serviceCallback); + return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, maxresults, serviceCallback); } /** @@ -1275,11 +1276,11 @@ public ServiceCall> getCertificateIssuersAsync(final * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.setCertificateIssuer( - setCertificateIssuerRequest.vaultBaseUrl(), - setCertificateIssuerRequest.issuerName(), - setCertificateIssuerRequest.issuer()); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.setCertificateIssuer( + setCertificateIssuerRequest.vaultBaseUrl(), + setCertificateIssuerRequest.issuerName(), + setCertificateIssuerRequest.issuer()); } /** @@ -1291,11 +1292,11 @@ public ServiceResponse setCertificateIssuer(SetCertificateIssuerRe * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerRequest setCertificateIssuerRequest, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.setCertificateIssuerAsync( - setCertificateIssuerRequest.vaultBaseUrl(), - setCertificateIssuerRequest.issuerName(), - setCertificateIssuerRequest.issuer(), - serviceCallback); + return innerKeyVaultClient.setCertificateIssuerAsync( + setCertificateIssuerRequest.vaultBaseUrl(), + setCertificateIssuerRequest.issuerName(), + setCertificateIssuerRequest.issuer(), + serviceCallback); } /** @@ -1309,11 +1310,11 @@ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerR * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificateIssuer(UpdateCertificateIssuerRequest updateCertificateIssuerRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.updateCertificateIssuer( - updateCertificateIssuerRequest.vaultBaseUrl(), - updateCertificateIssuerRequest.issuerName(), - updateCertificateIssuerRequest.issuer()); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.updateCertificateIssuer( + updateCertificateIssuerRequest.vaultBaseUrl(), + updateCertificateIssuerRequest.issuerName(), + updateCertificateIssuerRequest.issuer()); } /** @@ -1326,11 +1327,11 @@ public ServiceResponse updateCertificateIssuer(UpdateCertificateIs * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateIssuerAsync(UpdateCertificateIssuerRequest updateCertificateIssuerRequest, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.updateCertificateIssuerAsync( - updateCertificateIssuerRequest.vaultBaseUrl(), - updateCertificateIssuerRequest.issuerName(), - updateCertificateIssuerRequest.issuer(), - serviceCallback); + return innerKeyVaultClient.updateCertificateIssuerAsync( + updateCertificateIssuerRequest.vaultBaseUrl(), + updateCertificateIssuerRequest.issuerName(), + updateCertificateIssuerRequest.issuer(), + serviceCallback); } /** @@ -1344,8 +1345,8 @@ public ServiceCall updateCertificateIssuerAsync(UpdateCertificateI * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificateIssuer(String vaultBaseUrl, String issuerName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateIssuer(vaultBaseUrl, issuerName); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateIssuer(vaultBaseUrl, issuerName); } /** @@ -1357,7 +1358,7 @@ public ServiceResponse getCertificateIssuer(String vaultBaseUrl, S * @return the {@link ServiceCall} object */ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.getCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); + return innerKeyVaultClient.getCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); } /** @@ -1371,8 +1372,8 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl, String issuerName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.deleteCertificateIssuer(vaultBaseUrl, issuerName); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.deleteCertificateIssuer(vaultBaseUrl, issuerName); } /** @@ -1384,7 +1385,7 @@ public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.deleteCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); + return innerKeyVaultClient.deleteCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); } /** @@ -1398,13 +1399,13 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUr * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse createCertificate(CreateCertificateRequest createCertificateRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.createCertificate( - createCertificateRequest.vaultBaseUrl(), - createCertificateRequest.certificateName(), - createCertificateRequest.certificatePolicy(), - createCertificateRequest.certificateAttributes(), - createCertificateRequest.tags()); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.createCertificate( + createCertificateRequest.vaultBaseUrl(), + createCertificateRequest.certificateName(), + createCertificateRequest.certificatePolicy(), + createCertificateRequest.certificateAttributes(), + createCertificateRequest.tags()); } /** @@ -1416,13 +1417,13 @@ public ServiceResponse createCertificate(CreateCertificate * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(CreateCertificateRequest createCertificateRequest, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.createCertificateAsync( - createCertificateRequest.vaultBaseUrl(), - createCertificateRequest.certificateName(), - createCertificateRequest.certificatePolicy(), - createCertificateRequest.certificateAttributes(), - createCertificateRequest.tags(), - serviceCallback); + return innerKeyVaultClient.createCertificateAsync( + createCertificateRequest.vaultBaseUrl(), + createCertificateRequest.certificateName(), + createCertificateRequest.certificatePolicy(), + createCertificateRequest.certificateAttributes(), + createCertificateRequest.tags(), + serviceCallback); } /** @@ -1436,15 +1437,15 @@ public ServiceCall createCertificateAsync(CreateCertificat * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importCertificate(ImportCertificateRequest importCertificateRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.importCertificate( - importCertificateRequest.vaultBaseUrl(), - importCertificateRequest.certificateName(), - importCertificateRequest.base64EncodedCertificate(), - importCertificateRequest.password(), - importCertificateRequest.certificatePolicy(), - importCertificateRequest.certificateAttributes(), - importCertificateRequest.tags()); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.importCertificate( + importCertificateRequest.vaultBaseUrl(), + importCertificateRequest.certificateName(), + importCertificateRequest.base64EncodedCertificate(), + importCertificateRequest.password(), + importCertificateRequest.certificatePolicy(), + importCertificateRequest.certificateAttributes(), + importCertificateRequest.tags()); } /** @@ -1456,15 +1457,15 @@ public ServiceResponse importCertificate(ImportCertificateReq * @return the {@link ServiceCall} object */ public ServiceCall importCertificateAsync(ImportCertificateRequest importCertificateRequest, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.importCertificateAsync( - importCertificateRequest.vaultBaseUrl(), - importCertificateRequest.certificateName(), - importCertificateRequest.base64EncodedCertificate(), - importCertificateRequest.password(), - importCertificateRequest.certificatePolicy(), - importCertificateRequest.certificateAttributes(), - importCertificateRequest.tags(), - serviceCallback); + return innerKeyVaultClient.importCertificateAsync( + importCertificateRequest.vaultBaseUrl(), + importCertificateRequest.certificateName(), + importCertificateRequest.base64EncodedCertificate(), + importCertificateRequest.password(), + importCertificateRequest.certificatePolicy(), + importCertificateRequest.certificateAttributes(), + importCertificateRequest.tags(), + serviceCallback); } /** @@ -1478,8 +1479,8 @@ public ServiceCall importCertificateAsync(ImportCertificateRe * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName); } /** @@ -1491,7 +1492,7 @@ public ServiceResponse> getCertificateVersions(final * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback); + return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback); } /** * List the versions of a certificate. @@ -1505,8 +1506,8 @@ public ServiceCall> getCertificateVersionsAsync(final Stri * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName, maxresults); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName, maxresults); } /** @@ -1519,7 +1520,7 @@ public ServiceResponse> getCertificateVersions(final * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, maxresults, serviceCallback); + return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, maxresults, serviceCallback); } /** @@ -1533,8 +1534,8 @@ public ServiceCall> getCertificateVersionsAsync(final Stri * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificatePolicy(vaultBaseUrl, certificateName); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificatePolicy(vaultBaseUrl, certificateName); } /** @@ -1546,7 +1547,7 @@ public ServiceResponse getCertificatePolicy(String vaultBaseU * @return the {@link ServiceCall} object */ public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.getCertificatePolicyAsync(vaultBaseUrl, certificateName, serviceCallback); + return innerKeyVaultClient.getCertificatePolicyAsync(vaultBaseUrl, certificateName, serviceCallback); } /** @@ -1560,11 +1561,11 @@ public ServiceCall getCertificatePolicyAsync(String vaultBase * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.updateCertificatePolicy( - updateCertificatePolicyRequest.vaultBaseUrl(), - updateCertificatePolicyRequest.certificateName(), - updateCertificatePolicyRequest.certificatePolicy()); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.updateCertificatePolicy( + updateCertificatePolicyRequest.vaultBaseUrl(), + updateCertificatePolicyRequest.certificateName(), + updateCertificatePolicyRequest.certificatePolicy()); } /** @@ -1576,11 +1577,11 @@ public ServiceResponse updateCertificatePolicy(UpdateCertific * @return the {@link ServiceCall} object */ public ServiceCall updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.updateCertificatePolicyAsync( - updateCertificatePolicyRequest.vaultBaseUrl(), - updateCertificatePolicyRequest.certificateName(), - updateCertificatePolicyRequest.certificatePolicy(), - serviceCallback); + return innerKeyVaultClient.updateCertificatePolicyAsync( + updateCertificatePolicyRequest.vaultBaseUrl(), + updateCertificatePolicyRequest.certificateName(), + updateCertificatePolicyRequest.certificatePolicy(), + serviceCallback); } /** @@ -1594,13 +1595,13 @@ public ServiceCall updateCertificatePolicy(UpdateCertificateP * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificate(UpdateCertificateRequest updateCertificateRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.updateCertificate( - updateCertificateRequest.vaultBaseUrl(), - updateCertificateRequest.certificateName(), - updateCertificateRequest.certificateVersion(), - updateCertificateRequest.certificateAttributes(), - updateCertificateRequest.tags()); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.updateCertificate( + updateCertificateRequest.vaultBaseUrl(), + updateCertificateRequest.certificateName(), + updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificateAttributes(), + updateCertificateRequest.tags()); } /** @@ -1612,13 +1613,13 @@ public ServiceResponse updateCertificate(UpdateCertificateReq * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(UpdateCertificateRequest updateCertificateRequest, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.updateCertificateAsync( - updateCertificateRequest.vaultBaseUrl(), - updateCertificateRequest.certificateName(), - updateCertificateRequest.certificateVersion(), - updateCertificateRequest.certificateAttributes(), - updateCertificateRequest.tags(), - serviceCallback); + return innerKeyVaultClient.updateCertificateAsync( + updateCertificateRequest.vaultBaseUrl(), + updateCertificateRequest.certificateName(), + updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificateAttributes(), + updateCertificateRequest.tags(), + serviceCallback); } /** @@ -1631,9 +1632,9 @@ public ServiceCall updateCertificateAsync(UpdateCertificateRe * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificate(String certificateIdentifier) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); - return innerKeyVaultClient.getCertificate(id.vault, id.name, id.version == null ? "" : id.version); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); + return innerKeyVaultClient.getCertificate(id.vault, id.name, id.version == null ? "" : id.version); } /** @@ -1644,8 +1645,8 @@ public ServiceResponse getCertificate(String certificateIdent * @return the {@link ServiceCall} object */ public ServiceCall getCertificateAsync(String certificateIdentifier, final ServiceCallback serviceCallback) { - CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); - return innerKeyVaultClient.getCertificateAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); + CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); + return innerKeyVaultClient.getCertificateAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); } /** @@ -1659,8 +1660,8 @@ public ServiceCall getCertificateAsync(String certificateIden * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, ""); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, ""); } /** @@ -1672,7 +1673,7 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St * @return the {@link ServiceCall} object */ public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.getCertificateAsync(vaultBaseUrl, certificateName, "", serviceCallback); + return innerKeyVaultClient.getCertificateAsync(vaultBaseUrl, certificateName, "", serviceCallback); } /** @@ -1687,8 +1688,8 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, certificateVersion); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, certificateVersion); } /** @@ -1701,7 +1702,7 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St * @return the {@link ServiceCall} object */ public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, serviceCallback); + return innerKeyVaultClient.getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, serviceCallback); } /** @@ -1715,11 +1716,11 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.updateCertificateOperation( - updateCertificateOperationRequest.vaultBaseUrl(), - updateCertificateOperationRequest.certificateName(), - updateCertificateOperationRequest.certificateOperation()); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.updateCertificateOperation( + updateCertificateOperationRequest.vaultBaseUrl(), + updateCertificateOperationRequest.certificateName(), + updateCertificateOperationRequest.certificateOperation()); } /** @@ -1731,11 +1732,11 @@ public ServiceResponse updateCertificateOperation(UpdateCe * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateOperationAsync(UpdateCertificateOperationRequest updateCertificateOperationRequest, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.updateCertificateOperationAsync( - updateCertificateOperationRequest.vaultBaseUrl(), - updateCertificateOperationRequest.certificateName(), - updateCertificateOperationRequest.certificateOperation(), - serviceCallback); + return innerKeyVaultClient.updateCertificateOperationAsync( + updateCertificateOperationRequest.vaultBaseUrl(), + updateCertificateOperationRequest.certificateName(), + updateCertificateOperationRequest.certificateOperation(), + serviceCallback); } /** @@ -1749,8 +1750,8 @@ public ServiceCall updateCertificateOperationAsync(UpdateC * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateOperation(vaultBaseUrl, certificateName); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateOperation(vaultBaseUrl, certificateName); } /** @@ -1762,7 +1763,7 @@ public ServiceResponse getCertificateOperation(String vaul * @return the {@link ServiceCall} object */ public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.getCertificateOperationAsync(vaultBaseUrl, certificateName, serviceCallback); + return innerKeyVaultClient.getCertificateOperationAsync(vaultBaseUrl, certificateName, serviceCallback); } /** @@ -1776,8 +1777,8 @@ public ServiceCall getCertificateOperationAsync(String vau * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.deleteCertificateOperation(vaultBaseUrl, certificateName); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.deleteCertificateOperation(vaultBaseUrl, certificateName); } /** @@ -1789,7 +1790,7 @@ public ServiceResponse deleteCertificateOperation(String v * @return the {@link ServiceCall} object */ ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.deleteCertificateOperationAsync(vaultBaseUrl, certificateName, serviceCallback); + return innerKeyVaultClient.deleteCertificateOperationAsync(vaultBaseUrl, certificateName, serviceCallback); } /** @@ -1803,13 +1804,13 @@ ServiceCall deleteCertificateOperationAsync(String vaultBa * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse mergeCertificate(MergeCertificateRequest mergeCertificateRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.mergeCertificate( - mergeCertificateRequest.vaultBaseUrl(), - mergeCertificateRequest.certificateName(), - mergeCertificateRequest.x509Certificates(), - mergeCertificateRequest.certificateAttributes(), - mergeCertificateRequest.tags()); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.mergeCertificate( + mergeCertificateRequest.vaultBaseUrl(), + mergeCertificateRequest.certificateName(), + mergeCertificateRequest.x509Certificates(), + mergeCertificateRequest.certificateAttributes(), + mergeCertificateRequest.tags()); } /** @@ -1821,13 +1822,13 @@ public ServiceResponse mergeCertificate(MergeCertificateReque * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(MergeCertificateRequest mergeCertificateRequest, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.mergeCertificateAsync( - mergeCertificateRequest.vaultBaseUrl(), - mergeCertificateRequest.certificateName(), - mergeCertificateRequest.x509Certificates(), - mergeCertificateRequest.certificateAttributes(), - mergeCertificateRequest.tags(), - serviceCallback); + return innerKeyVaultClient.mergeCertificateAsync( + mergeCertificateRequest.vaultBaseUrl(), + mergeCertificateRequest.certificateName(), + mergeCertificateRequest.x509Certificates(), + mergeCertificateRequest.certificateAttributes(), + mergeCertificateRequest.tags(), + serviceCallback); } @@ -1842,7 +1843,7 @@ public ServiceCall mergeCertificateAsync(MergeCertificateRequ * @return the String object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1886,15 +1887,15 @@ public ServiceCall getPendingCertificateSigningRequestAsync(String vault @Override public void onResponse(Call call, Response response) { try { - if(serviceCallback != null) { - serviceCallback.success(new ServiceResponse(response.body().string(), response)); - } - serviceCall.success(new ServiceResponse(response.body().string(), response)); + if (serviceCallback != null) { + serviceCallback.success(new ServiceResponse(response.body().string(), response)); + } + serviceCall.success(new ServiceResponse(response.body().string(), response)); } catch (IOException exception) { - if(serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } } }); @@ -1911,8 +1912,8 @@ public void onResponse(Call call, Response response) * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeyVersionsNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getKeyVersionsNext(nextPageLink); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKeyVersionsNext(nextPageLink); } /** @@ -1924,7 +1925,7 @@ public ServiceResponse> getKeyVersionsNext(final String nextPa * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getKeyVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); + return innerKeyVaultClient.getKeyVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); } /** @@ -1937,8 +1938,8 @@ public ServiceCall> getKeyVersionsNextAsync(final String nextPageL * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeysNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getKeysNext(nextPageLink); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getKeysNext(nextPageLink); } /** @@ -1950,7 +1951,7 @@ public ServiceResponse> getKeysNext(final String nextPageLink) * @return the {@link ServiceCall} object */ public ServiceCall> getKeysNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getKeysNextAsync(nextPageLink, serviceCall, serviceCallback); + return innerKeyVaultClient.getKeysNextAsync(nextPageLink, serviceCall, serviceCallback); } /** @@ -1963,8 +1964,8 @@ public ServiceCall> getKeysNextAsync(final String nextPageLink, fi * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecretsNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getSecretsNext(nextPageLink); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecretsNext(nextPageLink); } /** @@ -1976,7 +1977,7 @@ public ServiceResponse> getSecretsNext(final String nextPag * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getSecretsNextAsync(nextPageLink, serviceCall, serviceCallback); + return innerKeyVaultClient.getSecretsNextAsync(nextPageLink, serviceCall, serviceCallback); } /** @@ -1989,8 +1990,8 @@ public ServiceCall> getSecretsNextAsync(final String nextPageLi * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecretVersionsNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getSecretVersionsNext(nextPageLink); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getSecretVersionsNext(nextPageLink); } /** @@ -2002,7 +2003,7 @@ public ServiceResponse> getSecretVersionsNext(final String * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getSecretVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); + return innerKeyVaultClient.getSecretVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); } /** @@ -2015,8 +2016,8 @@ public ServiceCall> getSecretVersionsNextAsync(final String nex * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificatesNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificatesNext(nextPageLink); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificatesNext(nextPageLink); } /** @@ -2028,7 +2029,7 @@ public ServiceResponse> getCertificatesNext(final Stri * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificatesNextAsync(nextPageLink, serviceCall, serviceCallback); + return innerKeyVaultClient.getCertificatesNextAsync(nextPageLink, serviceCall, serviceCallback); } /** @@ -2041,8 +2042,8 @@ public ServiceCall> getCertificatesNextAsync(final String * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateIssuersNext(nextPageLink); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateIssuersNext(nextPageLink); } /** @@ -2054,7 +2055,7 @@ public ServiceResponse> getCertificateIssuersNex * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificateIssuersNextAsync(nextPageLink, serviceCall, serviceCallback); + return innerKeyVaultClient.getCertificateIssuersNextAsync(nextPageLink, serviceCall, serviceCallback); } /** @@ -2067,8 +2068,8 @@ public ServiceCall> getCertificateIssuersNextAsync(f * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateVersionsNext(nextPageLink); + throws KeyVaultErrorException, IOException, IllegalArgumentException { + return innerKeyVaultClient.getCertificateVersionsNext(nextPageLink); } /** @@ -2080,7 +2081,7 @@ public ServiceResponse> getCertificateVersionsNext(fin * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificateVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); + return innerKeyVaultClient.getCertificateVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 0c61ac6076aeb..5d3610adf8074 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -175,7 +175,7 @@ public KeyVaultClientImpl withGenerateClientRequestId(boolean generateClientRequ * * @param credentials the management credentials for Azure */ - public KeyVaultClientImpl(ServiceClientCredentials credentials) { + KeyVaultClientImpl(ServiceClientCredentials credentials) { this("https://{vaultBaseUrl}", credentials); } @@ -197,7 +197,7 @@ private KeyVaultClientImpl(String baseUrl, ServiceClientCredentials credentials) * * @param restClient the REST client to connect to Azure. */ - public KeyVaultClientImpl(RestClient restClient) { + KeyVaultClientImpl(RestClient restClient) { super(restClient); initialize(); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java index b95f81bfe219a..290a07c94003e 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java @@ -22,8 +22,17 @@ import java.net.URISyntaxException; import java.security.InvalidParameterException; +/** + * The key vault object identifier. + */ public class ObjectIdentifier { + /** + * Verifies whether the identifier belongs to a key vault object. + * @param collection the object collection e.g. 'keys', 'secrets' and 'certificates'. + * @param identifier the key vault object identifier. + * @return true if the identifier belongs to a key vault object. False otherwise. + */ protected static boolean isObjectIdentifier(String collection, String identifier) { collection = verifyNonEmpty(collection, "collection"); @@ -49,6 +58,12 @@ protected static boolean isObjectIdentifier(String collection, String identifier return true; } + /** + * Verifies a value is null or empty. Returns the value if non-empty and throws exception if empty. + * @param value the value to verify. + * @param argName the name of the value. + * @return Returns the value if non-empty. + */ protected static String verifyNonEmpty(String value, String argName) { if (value != null) { value = value.trim(); @@ -68,13 +83,29 @@ protected static String verifyNonEmpty(String value, String argName) { protected String baseIdentifier; protected String identifier; - protected ObjectIdentifier() { + /** + * Constructor. + */ + protected ObjectIdentifier() { } - + + /** + * Constructor. + * @param vault the vault url. + * @param collection the object collection name. e.g. 'keys', 'secrets' and 'certificates'. + * @param name the object name. + */ protected ObjectIdentifier(String vault, String collection, String name) { this(vault, collection, name, null); } + /** + * Constructor. + * @param vault the vault url. + * @param collection the object collection name. e.g. 'keys', 'secrets' and 'certificates'. + * @param name the object name. + * @param version the object version. + */ protected ObjectIdentifier(String vault, String collection, String name, String version) { vault = verifyNonEmpty(vault, "vault"); @@ -83,8 +114,9 @@ protected ObjectIdentifier(String vault, String collection, String name, String if (version != null) { version = version.trim(); + } else { + version = ""; } - else version = ""; URI baseUri; try { @@ -97,9 +129,15 @@ protected ObjectIdentifier(String vault, String collection, String name, String this.version = version; this.vault = String.format("%s://%s", baseUri.getScheme(), getFullAuthority(baseUri)); baseIdentifier = String.format("%s/%s/%s", this.vault, collection, this.name); - identifier = (version == null || version.isEmpty()) ? baseIdentifier : String.format("%s/%s", baseIdentifier, version); + identifier = (version == null || version.isEmpty()) ? baseIdentifier + : String.format("%s/%s", baseIdentifier, version); } + /** + * Constructor. + * @param collection the object collection name. e.g. 'keys', 'secrets' and 'certificates'. + * @param identifier the object identifier. + */ protected ObjectIdentifier(String collection, String identifier) { if (collection == null || collection.length() == 0) { @@ -114,26 +152,36 @@ protected ObjectIdentifier(String collection, String identifier) { try { baseUri = new URI(identifier); } catch (URISyntaxException e) { - throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. Not a valid URI", identifier)); + throw new InvalidParameterException( + String.format("Invalid ObjectIdentifier: %s. Not a valid URI", identifier)); } // Path is of the form "/collection/name[/version]" String[] segments = baseUri.getPath().split("/"); if (segments.length != 3 && segments.length != 4) { - throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. Bad number of segments: %d", identifier, segments.length)); + throw new InvalidParameterException(String + .format("Invalid ObjectIdentifier: %s. Bad number of segments: %d", identifier, segments.length)); } if (!collection.equals(segments[1])) { - throw new InvalidParameterException(String.format("Invalid ObjectIdentifier: %s. segment [1] should be '%s', found '%s'", identifier, collection, segments[1])); + throw new InvalidParameterException( + String.format("Invalid ObjectIdentifier: %s. segment [1] should be '%s', found '%s'", identifier, + collection, segments[1])); } name = segments[2]; version = segments.length == 4 ? segments[3] : null; vault = String.format("%s://%s", baseUri.getScheme(), getFullAuthority(baseUri)); baseIdentifier = String.format("%s/%s/%s", vault, collection, name); - this.identifier = (version == null || version.equals("")) ? baseIdentifier : String.format("%s/%s", baseIdentifier, version); + this.identifier = (version == null || version.equals("")) ? baseIdentifier + : String.format("%s/%s", baseIdentifier, version); } + /** + * Gets full authority for a URL by appending port to the url authority. + * @param uri the URL to get the full authority for. + * @return the full authority. + */ protected String getFullAuthority(URI uri) { String authority = uri.getAuthority(); if (!authority.contains(":") && uri.getPort() > 0) { @@ -144,7 +192,8 @@ protected String getFullAuthority(URI uri) { } /** - * @return The base identifier for an object, does not include the object version. + * @return The base identifier for an object, does not include the object + * version. */ public String baseIdentifier() { return baseIdentifier; @@ -165,7 +214,7 @@ public String name() { } /** - * @return The vault containing the object + * @return The vault containing the object. */ public String vault() { return vault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java index c83faa61cdfae..60d3d927bcdee 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java @@ -18,19 +18,43 @@ package com.microsoft.azure.keyvault; +/** + * Key Vault secret identifier. + */ public final class SecretIdentifier extends ObjectIdentifier { + + /** + * Verifies whether the identifier belongs to a key vault secret. + * @param identifier the key vault secret identifier. + * @return true if the identifier belongs to a key vault secret. False otherwise. + */ public static boolean isSecretIdentifier(String identifier) { return ObjectIdentifier.isObjectIdentifier("secrets", identifier); } + /** + * Constructor. + * @param vault the vault url. + * @param name the name of secret. + */ public SecretIdentifier(String vault, String name) { this(vault, name, ""); } + /** + * Constructor. + * @param vault the vault url. + * @param name the name of secret. + * @param version the secret version. + */ public SecretIdentifier(String vault, String name, String version) { super(vault, "secrets", name, version); } + /** + * Constructor. + * @param identifier the object identifier. + */ public SecretIdentifier(String identifier) { super("secrets", identifier); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java index 3b25b0737de36..7f0a1fbd287d0 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java @@ -27,42 +27,52 @@ import okhttp3.HttpUrl; /** - * An implementation of {@link ServiceClientCredentials} that supports automatic bearer - * token refresh. + * An implementation of {@link ServiceClientCredentials} that supports automatic bearer token refresh. * */ class ChallengeCache { - + private final HashMap> cachedChallenges = new HashMap>(); - + /** - * Uses authority to retrieve the cached values - * @param url the url that is used as a cache key - * @return cached value or null if value is not available + * Uses authority to retrieve the cached values. + * + * @param url + * the url that is used as a cache key. + * @return cached value or null if value is not available. */ public Map getCachedChallenge(HttpUrl url) { - if(url == null) return null; + if (url == null) { + return null; + } String authority = getAuthority(url); authority = authority.toLowerCase(Locale.ENGLISH); return cachedChallenges.get(authority); } - + /** - * Uses authority to cache challenge - * @param url the url that is used as a cache key - * @param challenge the challenge to cache + * Uses authority to cache challenge. + * + * @param url + * the url that is used as a cache key. + * @param challenge + * the challenge to cache. */ public void addCachedChallenge(HttpUrl url, Map challenge) { - if(url == null || challenge == null) return; + if (url == null || challenge == null) { + return; + } String authority = getAuthority(url); authority = authority.toLowerCase(Locale.ENGLISH); cachedChallenges.put(authority, challenge); } /** - * Gets authority of a url - * @param url the url to get the authority for - * @return the authority + * Gets authority of a url. + * + * @param url + * the url to get the authority for. + * @return the authority. */ public String getAuthority(HttpUrl url) { String scheme = url.scheme(); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java index a3f94c3c49704..ad1a3e8206271 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java @@ -33,144 +33,160 @@ import okhttp3.Route; /** - * An implementation of {@link ServiceClientCredentials} that supports automatic bearer - * token refresh. + * An implementation of {@link ServiceClientCredentials} that supports automatic bearer token refresh. * */ public abstract class KeyVaultCredentials implements ServiceClientCredentials { - private static final String wwwAuthenticate = "WWW-Authenticate"; - private static final String authorization = "Authorization"; - private static final String bearerTokenPrefix = "Bearer "; - + private static final String WWW_AUTHENTICATE = "WWW-Authenticate"; + private static final String AUTHENTICATE = "Authorization"; + private static final String BEARER_TOKEP_REFIX = "Bearer "; + private final ChallengeCache cache = new ChallengeCache(); - @Override + @Override public void applyCredentialsFilter(OkHttpClient.Builder clientBuilder) { - - clientBuilder.addInterceptor(new Interceptor() { - - @Override - public Response intercept(Chain chain) throws IOException { + + clientBuilder.addInterceptor(new Interceptor() { + + @Override + public Response intercept(Chain chain) throws IOException { HttpUrl url = chain.request().url(); - + Map challengeMap = cache.getCachedChallenge(url); - if(challengeMap != null) { - // Get the bearer token - String credential = getAuthenticationCredentials(challengeMap); + if (challengeMap != null) { + // Get the bearer token + String credential = getAuthenticationCredentials(challengeMap); + + Request newRequest = chain.request().newBuilder() + .header(AUTHENTICATE, BEARER_TOKEP_REFIX + credential).build(); - Request newRequest = chain.request().newBuilder() - .header(authorization, bearerTokenPrefix + credential) - .build(); - - return chain.proceed(newRequest); + return chain.proceed(newRequest); + } else { + // challenge is new for the URL and is not cached, + // so the request is sent out to get the challenges in + // response + return chain.proceed(chain.request()); } - else { - // challenge is new for the URL and is not cached, - // so the request is sent out to get the challenges in response - return chain.proceed(chain.request()); - } - } - }); - - // Caches the challenge for failed request and re-send the request with access token - clientBuilder.authenticator(new Authenticator() { - - @Override - public Request authenticate(Route route, Response response) throws IOException { - - //if challenge is not cached then extract and cache it - String authenticateHeader = response.header(wwwAuthenticate); - - Map challengeMap = extractChallenge(authenticateHeader, bearerTokenPrefix); - - //Cache the challenge - cache.addCachedChallenge(response.request().url(), challengeMap); - - // Get the bearer token from the callback by providing the challenges - String credential = getAuthenticationCredentials(challengeMap); - - if (credential == null) return null; - + } + }); + + // Caches the challenge for failed request and re-send the request with + // access token. + clientBuilder.authenticator(new Authenticator() { + + @Override + public Request authenticate(Route route, Response response) throws IOException { + + // if challenge is not cached then extract and cache it + String authenticateHeader = response.header(WWW_AUTHENTICATE); + + Map challengeMap = extractChallenge(authenticateHeader, BEARER_TOKEP_REFIX); + + // Cache the challenge + cache.addCachedChallenge(response.request().url(), challengeMap); + + // Get the bearer token from the callback by providing the + // challenges + String credential = getAuthenticationCredentials(challengeMap); + + if (credential == null) { + return null; + } + // Add the token header and resume the call. // The token should live for duration of this request and never // be cached anywhere in our code. - return response.request().newBuilder() - .header(authorization, bearerTokenPrefix + credential) - .build(); - } + return response.request().newBuilder().header(AUTHENTICATE, BEARER_TOKEP_REFIX + credential).build(); + } }); } - + /** - * Extracts the authentication challenges from the challenge map and - * calls the authentication callback to get the bearer token and return it - * @param challengeMap the challenge map - * @return the bearer token + * Extracts the authentication challenges from the challenge map and calls + * the authentication callback to get the bearer token and return it. + * + * @param challengeMap + * the challenge map. + * @return the bearer token. */ private String getAuthenticationCredentials(Map challengeMap) { String authorization = challengeMap.get("authorization"); - if(authorization == null) authorization = challengeMap.get("authorization_uri"); - + if (authorization == null) { + authorization = challengeMap.get("authorization_uri"); + } + String resource = challengeMap.get("resource"); String scope = challengeMap.get("scope"); - + return doAuthenticate(authorization, resource, scope); - } - - /** - * Extracts the challenge off the authentication header - * @param authenticateHeader the authentication header containing all the challenges - * @param authChallengePrefix the authentication challenge name - * @return a challenge map - */ - private Map extractChallenge(String authenticateHeader, String authChallengePrefix) { - if (!isValidChallenge(authenticateHeader, authChallengePrefix)) return null; - - authenticateHeader = authenticateHeader.toLowerCase() - .replace(authChallengePrefix.toLowerCase(), ""); - - String [] challenges = authenticateHeader.split(", "); + } + + /** + * Extracts the challenge off the authentication header. + * + * @param authenticateHeader + * the authentication header containing all the challenges. + * @param authChallengePrefix + * the authentication challenge name. + * @return a challenge map. + */ + private Map extractChallenge(String authenticateHeader, String authChallengePrefix) { + if (!isValidChallenge(authenticateHeader, authChallengePrefix)) { + return null; + } + + authenticateHeader = authenticateHeader.toLowerCase().replace(authChallengePrefix.toLowerCase(), ""); + + String[] challenges = authenticateHeader.split(", "); Map challengeMap = new HashMap(); - for(String pair : challenges) { - String [] keyValue = pair.split("="); - challengeMap.put(keyValue[0].replaceAll("\"", ""), keyValue[1].replaceAll("\"", "")); + for (String pair : challenges) { + String[] keyValue = pair.split("="); + challengeMap.put(keyValue[0].replaceAll("\"", ""), keyValue[1].replaceAll("\"", "")); } return challengeMap; - } - - /** - * Verifies whether a challenge is bearer or not - * @param authenticateHeader the authentication header containing all the challenges - * @param authChallengePrefix the authentication challenge name - * @return - */ - private boolean isValidChallenge(String authenticateHeader, String authChallengePrefix) { - if(authenticateHeader!= null && !authenticateHeader.isEmpty() - && authenticateHeader.toLowerCase().startsWith(authChallengePrefix.toLowerCase())) - return true; - return false; - } - - /** - * Abstract method to be implemented - * - * @param authorization Identifier of the authority, a URL. - * @param resource Identifier of the target resource that is the recipient of the requested token, a URL. - * @param scope The scope of the authentication request. - * - * @return The access token - * - * Answers a server challenge with a token header. - *

- * Implementations typically use ADAL to get a token, as performed in the - * sample below: - *

+ } + + /** + * Verifies whether a challenge is bearer or not. + * + * @param authenticateHeader + * the authentication header containing all the challenges. + * @param authChallengePrefix + * the authentication challenge name. + * @return + */ + private boolean isValidChallenge(String authenticateHeader, String authChallengePrefix) { + if (authenticateHeader != null && !authenticateHeader.isEmpty() + && authenticateHeader.toLowerCase().startsWith(authChallengePrefix.toLowerCase())) { + return true; + } + return false; + } + + /** + * Abstract method to be implemented. + * + * @param authorization + * Identifier of the authority, a URL. + * @param resource + * Identifier of the target resource that is the recipient of the + * requested token, a URL. + * @param scope + * The scope of the authentication request. + * + * @return The access token + * + * Answers a server challenge with a token header. + *

+ * Implementations typically use ADAL to get a token, as performed + * in the sample below: + *

* - *
+     *         
      * @Override
      * public String doAuthenticate(String authorization, String resource, String scope) {
      *     String clientId = ...; // client GUID as shown in Azure portal.
@@ -200,13 +216,13 @@ private boolean isValidChallenge(String authenticateHeader, String authChallenge
      *     }
      *     return result;
      * }
-     * 
+ *
* - *

- * Note: The client key must be securely stored. It's advised to use two - * client applications - one for development and other for production - - * managed by separate parties. - *

+ *

+ * Note: The client key must be securely stored. It's advised to + * use two client applications - one for development and other for + * production - managed by separate parties. + *

* */ public abstract String doAuthenticate(String authorization, String resource, String scope); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/package-info.java new file mode 100644 index 0000000000000..8b2adca34c717 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +/** + * This package contains the classes for KeyVaultClient. Performs cryptographic + * key operations and vault operations against the Key Vault service. + */ +package com.microsoft.azure.keyvault.authentication; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java index f99badba1c43c..eda7dfbc9da3a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java @@ -203,21 +203,33 @@ public CertificateBundle withTags(Map tags) { this.tags = tags; return this; } - + + /** + * The certificate identifier. + * @return certificate identifier + */ public CertificateIdentifier certificateIdentifier() { if (id() == null || id().isEmpty()) { return null; } return new CertificateIdentifier(id()); } - + + /** + * The secret identifier. + * @return secret identifier + */ public SecretIdentifier secretIdentifier() { if (sid() == null || sid().isEmpty()) { return null; } return new SecretIdentifier(sid()); } - + + /** + * The key identifier. + * @return key identifier + */ public KeyIdentifier keyIdentifier() { if (kid() == null || kid().isEmpty()) { return null; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java index ba4afedaccf1e..cf13fa529bb36 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java @@ -127,15 +127,16 @@ public CertificateItem withX509Thumbprint(byte[] x509Thumbprint) { } return this; } - + /** - * @return The Identifier value + * The certificate identifier. + * @return The Identifier value. */ public CertificateIdentifier identifier() { - CertificateIdentifier identifier = null; - + CertificateIdentifier identifier = null; + if (id() != null && !id().isEmpty()) { - identifier = new CertificateIdentifier(id()); + identifier = new CertificateIdentifier(id()); } return identifier; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java index 04079baeb1620..c8aea174e4bf3 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java @@ -241,7 +241,11 @@ public CertificateOperation withRequestId(String requestId) { this.requestId = requestId; return this; } - + + /** + * The certificate operation identifier. + * @return the identifier value + */ public CertificateOperationIdentifier certificateOperationIdentifier() { if (id() == null || id().isEmpty()) { return null; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java index 8929000ab3384..3dd318e5139f8 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -137,7 +137,11 @@ public IssuerBundle withAttributes(IssuerAttributes attributes) { this.attributes = attributes; return this; } - + + /** + * The issuer identifier. + * @return identifier for issuer + */ public IssuerIdentifier issuerIdentifier() { if (id() == null || id().isEmpty()) { return null; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java index 7180f7967e846..ed9bb700c1543 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java @@ -448,16 +448,32 @@ public String toString() { } } + /** + * Get the RSA public key spec value. + * + * @return the RSA public key spec value + */ private RSAPublicKeySpec getRSAPublicKeySpec() { return new RSAPublicKeySpec(toBigInteger(n()), toBigInteger(e())); } + /** + * Get the RSA private key spec value. + * + * @return the RSA private key spec value + */ private RSAPrivateKeySpec getRSAPrivateKeySpec() { - return new RSAPrivateCrtKeySpec(toBigInteger(n()), toBigInteger(e()), toBigInteger(d()), toBigInteger(p()), toBigInteger(q()), toBigInteger(dp()), toBigInteger(dq()), toBigInteger(qi())); + return new RSAPrivateCrtKeySpec(toBigInteger(n()), toBigInteger(e()), toBigInteger(d()), toBigInteger(p()), + toBigInteger(q()), toBigInteger(dp()), toBigInteger(dq()), toBigInteger(qi())); } + /** + * Get the RSA public key value. + * + * @return the RSA public key value + */ private PublicKey getRSAPublicKey() { try { @@ -470,7 +486,12 @@ private PublicKey getRSAPublicKey() { } } - private PrivateKey RSAPrivateKey() { + /** + * Get the RSA private key value. + * + * @return the RSA private key value + */ + private PrivateKey getRSAPrivateKey() { try { RSAPrivateKeySpec privateKeySpec = getRSAPrivateKeySpec(); @@ -482,6 +503,9 @@ private PrivateKey RSAPrivateKey() { } } + /** + * Verifies if the key is an RSA key. + */ private void checkRSACompatible() { if (!JsonWebKeyType.RSA.equals(kty()) && !JsonWebKeyType.RSAHSM.equals(kty())) { throw new UnsupportedOperationException("Not an RSA key"); @@ -510,6 +534,11 @@ private static BigInteger toBigInteger(byte[] b) { return new BigInteger(b); } + /** + * Converts RSA key pair to JSON web key. + * @param keyPair RSA key pair + * @return the JSON web key, converted from RSA key pair. + */ public static JsonWebKey fromRSA(KeyPair keyPair) { RSAPrivateCrtKey privateKey = (RSAPrivateCrtKey) keyPair.getPrivate(); @@ -518,45 +547,54 @@ public static JsonWebKey fromRSA(KeyPair keyPair) { if (privateKey != null) { key = new JsonWebKey() - .withKty(JsonWebKeyType.RSA) - .withN(toByteArray(privateKey.getModulus())) - .withE(toByteArray(privateKey.getPublicExponent())) - .withD(toByteArray(privateKey.getPrivateExponent())) - .withP(toByteArray(privateKey.getPrimeP())) - .withQ(toByteArray(privateKey.getPrimeQ())) - .withDp(toByteArray(privateKey.getPrimeExponentP())) - .withDq(toByteArray(privateKey.getPrimeExponentQ())) - .withQi(toByteArray(privateKey.getCrtCoefficient())); + .withKty(JsonWebKeyType.RSA) + .withN(toByteArray(privateKey.getModulus())) + .withE(toByteArray(privateKey.getPublicExponent())) + .withD(toByteArray(privateKey.getPrivateExponent())) + .withP(toByteArray(privateKey.getPrimeP())) + .withQ(toByteArray(privateKey.getPrimeQ())) + .withDp(toByteArray(privateKey.getPrimeExponentP())) + .withDq(toByteArray(privateKey.getPrimeExponentQ())) + .withQi(toByteArray(privateKey.getCrtCoefficient())); } else { RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); key = new JsonWebKey() - .withKty(JsonWebKeyType.RSA) - .withN(toByteArray(publicKey.getModulus())) - .withE(toByteArray(publicKey.getPublicExponent())) - .withD(null) - .withP(null) - .withQ(null) - .withDp(null) - .withDq(null) - .withQi(null); + .withKty(JsonWebKeyType.RSA) + .withN(toByteArray(publicKey.getModulus())) + .withE(toByteArray(publicKey.getPublicExponent())) + .withD(null) + .withP(null) + .withQ(null) + .withDp(null) + .withDq(null) + .withQi(null); } return key; } + /** + * Converts JSON web key to RSA key pair. + * @return RSA key pair + */ public KeyPair toRSA() { return this.toRSA(false); } + /** + * Converts JSON web key to RSA key pair and include the private key if set to true. + * @param includePrivateParameters true if the RSA key pair should include the private key. False otherwise. + * @return RSA key pair + */ public KeyPair toRSA(boolean includePrivateParameters) { // Must be RSA checkRSACompatible(); if (includePrivateParameters) { - return new KeyPair(getRSAPublicKey(), RSAPrivateKey()); + return new KeyPair(getRSAPublicKey(), getRSAPrivateKey()); } else { return new KeyPair(getRSAPublicKey(), null); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index b906859dd18fa..4c13b1490a64d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -97,6 +97,10 @@ public KeyBundle withTags(Map tags) { return this; } + /** + * The key identifier. + * @return identifier for the key + */ public KeyIdentifier keyIdentifier() { if (key() == null || key().kid() == null || key().kid().length() == 0) { return null; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index 3e29afb4dc57b..05584de30f1ac 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -92,15 +92,16 @@ public KeyItem withTags(Map tags) { this.tags = tags; return this; } - + /** + * The key identifier. * @return The Identifier value */ public KeyIdentifier identifier() { - KeyIdentifier identifier = null; - + KeyIdentifier identifier = null; + if (kid() != null && !kid().isEmpty()) { - identifier = new KeyIdentifier(kid()); + identifier = new KeyIdentifier(kid()); } return identifier; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index dfa4910df3a89..52d7e736fb451 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -151,7 +151,7 @@ public SecretBundle withTags(Map tags) { this.tags = tags; return this; } - + /** * Get the kid value. * @@ -171,14 +171,18 @@ public SecretBundle withKid(String kid) { this.kid = kid; return this; } - + + /** + * the secret identifier. + * @return The Identifier value + */ public SecretIdentifier secretIdentifier() { if (id() == null || id().length() == 0) { return null; } return new SecretIdentifier(id()); } - + @Override public String toString() { ObjectMapper mapper = new ObjectMapper(); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index f3b41e85debe4..5359f9cba67ca 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -119,13 +119,14 @@ public SecretItem withContentType(String contentType) { } /** + * the secret identifier. * @return The Identifier value */ public SecretIdentifier identifier() { - SecretIdentifier identifier = null; - + SecretIdentifier identifier = null; + if (id() != null && !id().isEmpty()) { - identifier = new SecretIdentifier(id()); + identifier = new SecretIdentifier(id()); } return identifier; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java index 0a968581b6727..fb9a8e5db704b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java @@ -12,172 +12,181 @@ import com.microsoft.azure.keyvault.models.SecretProperties; import com.microsoft.azure.keyvault.models.X509CertificateProperties; -public class CreateCertificateRequest { - private final String vaultBaseUrl; - private final String certificateName; - private final CertificatePolicy certificatePolicy; - private final CertificateAttributes certificateAttributes; - private final Map tags; - - public static class Builder { - - // Required parameters +/** + * The create certificate request class. + */ +public final class CreateCertificateRequest { private final String vaultBaseUrl; private final String certificateName; - - // Optional parameters - private CertificatePolicy policy; - private CertificateAttributes attributes; - private Map tags; + private final CertificatePolicy certificatePolicy; + private final CertificateAttributes certificateAttributes; + private final Map tags; /** - * The builder for constructing {@link CreateCertificateRequest} object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName - * The name of the certificate in the given vault + * the {@link CreateCertificateRequest} builder. */ - public Builder(String vaultBaseUrl, String certificateName) { - this.vaultBaseUrl = vaultBaseUrl; - this.certificateName = certificateName; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String certificateName; + + // Optional parameters + private CertificatePolicy policy; + private CertificateAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link CreateCertificateRequest} object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net. + * @param certificateName + * The name of the certificate in the given vault + */ + public Builder(String vaultBaseUrl, String certificateName) { + this.vaultBaseUrl = vaultBaseUrl; + this.certificateName = certificateName; + } + + /** + * Set the certificatePolicy value. Mandatory if sending the create + * request for the first time. + * + * @param certificatePolicy + * The management policy for the certificate. + * @return the Builder object itself. + */ + public Builder withPolicy(CertificatePolicy certificatePolicy) { + this.policy = certificatePolicy; + return this; + } + + /** + * Set the attributes value. + * + * @param attributes + * The attributes of the certificate. + * @return the Builder object itself. + */ + public Builder withAttributes(CertificateAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value + * pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link CreateCertificateRequest} object. + * + * @return the {@link CreateCertificateRequest} object. + */ + public CreateCertificateRequest build() { + return new CreateCertificateRequest(this); + } } - /** - * Set the certificatePolicy value. Mandatory if sending the create request - * for the first time - * - * @param certificatePolicy - * The management policy for the certificate. - * @return the Builder object itself. - */ - public Builder withPolicy(CertificatePolicy certificatePolicy) { - this.policy = certificatePolicy; - return this; + private CreateCertificateRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + certificateName = builder.certificateName; + + if (builder.attributes != null) { + certificateAttributes = (CertificateAttributes) new CertificateAttributes() + .withNotBefore(builder.attributes.notBefore()).withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()); + } else { + certificateAttributes = null; + } + + if (builder.policy != null) { + certificatePolicy = new CertificatePolicy(); + if (builder.policy.attributes() != null) { + certificatePolicy.withAttributes((CertificateAttributes) new CertificateAttributes() + .withEnabled(builder.policy.attributes().enabled()) + .withExpires(builder.policy.attributes().expires()) + .withNotBefore(builder.policy.attributes().notBefore())); + } + if (builder.policy.issuerReference() != null) { + certificatePolicy + .withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); + } + if (builder.policy.x509CertificateProperties() != null) { + certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() + .withValidityInMonths(builder.policy.x509CertificateProperties().validityInMonths()) + .withSubjectAlternativeNames( + builder.policy.x509CertificateProperties().subjectAlternativeNames()) + .withSubject(builder.policy.x509CertificateProperties().subject()) + .withEkus(builder.policy.x509CertificateProperties().ekus()) + .withKeyUsage(builder.policy.x509CertificateProperties().keyUsage())); + } + if (builder.policy.lifetimeActions() != null) { + certificatePolicy.withLifetimeActions(new ArrayList(builder.policy.lifetimeActions())); + } + if (builder.policy.keyProperties() != null) { + certificatePolicy.withKeyProperties( + new KeyProperties().withExportable(builder.policy.keyProperties().exportable()) + .withKeySize(builder.policy.keyProperties().keySize()) + .withKeyType(builder.policy.keyProperties().keyType()) + .withReuseKey(builder.policy.keyProperties().reuseKey())); + } + if (builder.policy.secretProperties() != null) { + certificatePolicy.withSecretProperties( + new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); + } + } else { + certificatePolicy = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } } /** - * Set the attributes value. - * - * @param attributes - * The attributes of the certificate. - * @return the Builder object itself. + * @return the vault base url */ - public Builder withAttributes(CertificateAttributes attributes) { - this.attributes = attributes; - return this; + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * Set the tags value. - * - * @param tags - * Application-specific metadata in the form of key-value pairs. - * @return the Builder object itself. + * @return the certificate name */ - public Builder withTags(Map tags) { - this.tags = tags; - return this; + public String certificateName() { + return certificateName; } /** - * builds the {@link CreateCertificateRequest} object - * @return the {@link CreateCertificateRequest} object + * @return the certificate policy */ - public CreateCertificateRequest build() { - return new CreateCertificateRequest(this); - } - } - - private CreateCertificateRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - certificateName = builder.certificateName; - - if (builder.attributes != null) { - certificateAttributes = (CertificateAttributes) new CertificateAttributes() - .withNotBefore(builder.attributes.notBefore()) - .withEnabled(builder.attributes.enabled()) - .withExpires(builder.attributes.expires()); - } else { - certificateAttributes = null; + public CertificatePolicy certificatePolicy() { + return certificatePolicy; } - if (builder.policy != null) { - certificatePolicy = new CertificatePolicy(); - if (builder.policy.attributes() != null) { - certificatePolicy.withAttributes((CertificateAttributes) new CertificateAttributes() - .withEnabled(builder.policy.attributes().enabled()) - .withExpires(builder.policy.attributes().expires()) - .withNotBefore(builder.policy.attributes().notBefore())); - } - if (builder.policy.issuerReference() != null) { - certificatePolicy.withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); - } - if (builder.policy.x509CertificateProperties() != null) { - certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() - .withValidityInMonths(builder.policy.x509CertificateProperties().validityInMonths()) - .withSubjectAlternativeNames(builder.policy.x509CertificateProperties().subjectAlternativeNames()) - .withSubject(builder.policy.x509CertificateProperties().subject()) - .withEkus(builder.policy.x509CertificateProperties().ekus()) - .withKeyUsage(builder.policy.x509CertificateProperties().keyUsage())); - } - if (builder.policy.lifetimeActions() != null) { - certificatePolicy.withLifetimeActions(new ArrayList(builder.policy.lifetimeActions())); - } - if (builder.policy.keyProperties() != null) { - certificatePolicy.withKeyProperties(new KeyProperties() - .withExportable(builder.policy.keyProperties().exportable()) - .withKeySize(builder.policy.keyProperties().keySize()) - .withKeyType(builder.policy.keyProperties().keyType()) - .withReuseKey(builder.policy.keyProperties().reuseKey())); - } - if (builder.policy.secretProperties() != null) { - certificatePolicy.withSecretProperties( - new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); - } - } else { - certificatePolicy = null; + /** + * @return the certificate attributes + */ + public CertificateAttributes certificateAttributes() { + return certificateAttributes; } - if (builder.tags != null) { - tags = Collections.unmodifiableMap(builder.tags); - } else { - tags = null; + /** + * @return the tags + */ + public Map tags() { + return tags; } - } - - /** - * @return the vault base url - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the certificate name - */ - public String certificateName() { - return certificateName; - } - - /** - * @return the certificate policy - */ - public CertificatePolicy certificatePolicy() { - return certificatePolicy; - } - - /** - * @return the certificate attributes - */ - public CertificateAttributes certificateAttributes() { - return certificateAttributes; - } - - /** - * @return the tags - */ - public Map tags() { - return tags; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java index 5398b890511f7..96f416bb9cf36 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java @@ -7,176 +7,183 @@ import com.microsoft.azure.keyvault.models.KeyAttributes; -public class CreateKeyRequest { +/** + * The create key request class. + */ +public final class CreateKeyRequest { - private final String vaultBaseUrl; - private final String keyName; - private final String keyType; - private final Integer keySize; - private final List keyOperations; - private final KeyAttributes keyAttributes; - private final Map tags; - - public static class Builder { - - // Required parameters private final String vaultBaseUrl; private final String keyName; private final String keyType; - - // Optional parameters - private Integer keySize; - private List keyOperations; - private KeyAttributes attributes; - private Map tags; + private final Integer keySize; + private final List keyOperations; + private final KeyAttributes keyAttributes; + private final Map tags; /** - * The builder for constructing {@link CreateKeyRequest} object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param keyName - * The name of the key in the given vault - * @param keyType - * The type of key to create. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * The {@link CreateKeyRequest} builder. */ - public Builder(String vaultBaseUrl, String keyName, String keyType) { - this.vaultBaseUrl = vaultBaseUrl; - this.keyName = keyName; - this.keyType = keyType; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String keyName; + private final String keyType; + + // Optional parameters + private Integer keySize; + private List keyOperations; + private KeyAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link CreateKeyRequest} object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param keyName + * The name of the key in the given vault + * @param keyType + * The type of key to create. Possible values include: 'EC', + * 'RSA', 'RSA-HSM', 'oct' + */ + public Builder(String vaultBaseUrl, String keyName, String keyType) { + this.vaultBaseUrl = vaultBaseUrl; + this.keyName = keyName; + this.keyType = keyType; + } + + /** + * Set the key size value. + * + * @param size + * the size of the key. + * @return the Builder object itself. + */ + public Builder withKeySize(Integer size) { + this.keySize = size; + return this; + } + + /** + * Set the key operations value. + * + * @param keyOperations + * the key operation list. + * @return the Builder object itself. + */ + public Builder withKeyOperations(List keyOperations) { + this.keyOperations = keyOperations; + return this; + } + + /** + * Set the key attributes value. + * + * @param attributes + * the key management attributes value to set. + * @return the Builder object itself. + */ + public Builder withAttributes(KeyAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value + * pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link CreateKeyRequest} object. + * + * @return the {@link CreateKeyRequest} object. + */ + public CreateKeyRequest build() { + return new CreateKeyRequest(this); + } + } + + private CreateKeyRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + keyName = builder.keyName; + keyType = builder.keyType; + keySize = builder.keySize; + + if (builder.keyOperations != null) { + keyOperations = new ArrayList(builder.keyOperations); + } else { + keyOperations = null; + } + + if (builder.attributes != null) { + keyAttributes = (KeyAttributes) new KeyAttributes().withNotBefore(builder.attributes.notBefore()) + .withEnabled(builder.attributes.enabled()).withExpires(builder.attributes.expires()); + } else { + keyAttributes = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } } /** - * Set the key size value. - * - * @param size - * the size of the key - * @return the Builder object itself. + * @return the vault base url */ - public Builder withKeySize(Integer size) { - this.keySize = size; - return this; + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * Set the key operations value. - * - * @param keyOperations - * the key operation list - * @return the Builder object itself. + * @return the key name */ - public Builder withKeyOperations(List keyOperations) { - this.keyOperations = keyOperations; - return this; + public String keyName() { + return keyName; } /** - * Set the key attributes value. - * - * @param attributes - * the key management attributes value to set - * @return the Builder object itself. + * @return the key type */ - public Builder withAttributes(KeyAttributes attributes) { - this.attributes = attributes; - return this; + public String keyType() { + return keyType; } /** - * Set the tags value. - * - * @param tags - * Application-specific metadata in the form of key-value pairs. - * @return the Builder object itself. + * @return the key size */ - public Builder withTags(Map tags) { - this.tags = tags; - return this; + public Integer keySize() { + return keySize; } /** - * builds the {@link CreateKeyRequest} object - * @return the {@link CreateKeyRequest} object + * @return the key operations */ - public CreateKeyRequest build() { - return new CreateKeyRequest(this); - } - } - - private CreateKeyRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - keyName = builder.keyName; - keyType = builder.keyType; - keySize = builder.keySize; - - if (builder.keyOperations != null) { - keyOperations = new ArrayList(builder.keyOperations); - } else { - keyOperations = null; + public List keyOperations() { + return keyOperations; } - if (builder.attributes != null) { - keyAttributes = (KeyAttributes) new KeyAttributes() - .withNotBefore(builder.attributes.notBefore()) - .withEnabled(builder.attributes.enabled()) - .withExpires(builder.attributes.expires()); - } else { - keyAttributes = null; + /** + * @return the key attributes + */ + public KeyAttributes keyAttributes() { + return keyAttributes; } - if (builder.tags != null) { - tags = Collections.unmodifiableMap(builder.tags); - } else { - tags = null; + /** + * @return the tags + */ + public Map tags() { + return tags; } - } - - /** - * @return the vault base url - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the key name - */ - public String keyName() { - return keyName; - } - - /** - * @return the key type - */ - public String keyType() { - return keyType; - } - - /** - * @return the key size - */ - public Integer keySize() { - return keySize; - } - - /** - * @return the key operations - */ - public List keyOperations() { - return keyOperations; - } - - /** - * @return the key attributes - */ - public KeyAttributes keyAttributes() { - return keyAttributes; - } - - /** - * @return the tags - */ - public Map tags() { - return tags; - } } \ No newline at end of file diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java index c13d98a03c551..56f04bd98a454 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java @@ -12,207 +12,218 @@ import com.microsoft.azure.keyvault.models.SecretProperties; import com.microsoft.azure.keyvault.models.X509CertificateProperties; -public class ImportCertificateRequest { - private final String vaultBaseUrl; - private final String certificateName; - private final String base64EncodedCertificate; - private final String password; - private final CertificatePolicy certificatePolicy; - private final CertificateAttributes certificateAttributes; - private final Map tags; - - public static class Builder { - - // Required parameters +/** + * The import certificate request class. + */ +public final class ImportCertificateRequest { private final String vaultBaseUrl; private final String certificateName; private final String base64EncodedCertificate; - - // Optional parameters - private String password; - private CertificatePolicy policy; - private CertificateAttributes attributes; - private Map tags; + private final String password; + private final CertificatePolicy certificatePolicy; + private final CertificateAttributes certificateAttributes; + private final Map tags; /** - * The builder for constructing {@link ImportCertificateRequest} object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName - * The name of the certificate in the given vault - * @param base64EncodedCertificate - * Base64 encoded representation of the certificate object to - * import. This certificate needs to contain the private key. + * the {@link ImportCertificateRequest} builder. */ - public Builder(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { - this.vaultBaseUrl = vaultBaseUrl; - this.certificateName = certificateName; - this.base64EncodedCertificate = base64EncodedCertificate; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String certificateName; + private final String base64EncodedCertificate; + + // Optional parameters + private String password; + private CertificatePolicy policy; + private CertificateAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link ImportCertificateRequest} object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName + * The name of the certificate in the given vault + * @param base64EncodedCertificate + * Base64 encoded representation of the certificate object to + * import. This certificate needs to contain the private key. + */ + public Builder(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { + this.vaultBaseUrl = vaultBaseUrl; + this.certificateName = certificateName; + this.base64EncodedCertificate = base64EncodedCertificate; + } + + /** + * Set the password. + * + * @param password + * If the private key in base64EncodedCertificate is + * encrypted, the password used for encryption. + * @return the Builder object itself. + */ + public Builder withPassword(String password) { + this.password = password; + return this; + } + + /** + * Set the certificate policy. + * + * @param policy + * The management policy for the certificate. + * @return the Builder object itself. + */ + public Builder withPolicy(CertificatePolicy policy) { + this.policy = policy; + return this; + } + + /** + * Set the certificate attributes. + * + * @param attributes + * The attributes of the certificate. + * @return the Builder object itself. + */ + public Builder withAttributes(CertificateAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value + * pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link ImportCertificateRequest} object. + * + * @return the {@link ImportCertificateRequest} object. + */ + public ImportCertificateRequest build() { + return new ImportCertificateRequest(this); + } + } + + private ImportCertificateRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + certificateName = builder.certificateName; + base64EncodedCertificate = builder.base64EncodedCertificate; + password = builder.password; + + if (builder.attributes != null) { + certificateAttributes = (CertificateAttributes) new CertificateAttributes() + .withNotBefore(builder.attributes.notBefore()).withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()); + } + else { + certificateAttributes = null; + } + + if (builder.policy != null) { + certificatePolicy = new CertificatePolicy(); + if (builder.policy.attributes() != null) { + certificatePolicy.withAttributes((CertificateAttributes) new CertificateAttributes() + .withEnabled(builder.policy.attributes().enabled()) + .withExpires(builder.policy.attributes().expires()) + .withNotBefore(builder.policy.attributes().notBefore())); + } + if (builder.policy.issuerReference() != null) { + certificatePolicy + .withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); + } + if (builder.policy.x509CertificateProperties() != null) { + certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() + .withValidityInMonths(builder.policy.x509CertificateProperties().validityInMonths()) + .withSubjectAlternativeNames( + builder.policy.x509CertificateProperties().subjectAlternativeNames()) + .withSubject(builder.policy.x509CertificateProperties().subject()) + .withEkus(builder.policy.x509CertificateProperties().ekus()) + .withKeyUsage(builder.policy.x509CertificateProperties().keyUsage())); + } + if (builder.policy.lifetimeActions() != null) { + certificatePolicy.withLifetimeActions(new ArrayList(builder.policy.lifetimeActions())); + } + if (builder.policy.keyProperties() != null) { + certificatePolicy.withKeyProperties( + new KeyProperties().withExportable(builder.policy.keyProperties().exportable()) + .withKeySize(builder.policy.keyProperties().keySize()) + .withKeyType(builder.policy.keyProperties().keyType()) + .withReuseKey(builder.policy.keyProperties().reuseKey())); + } + if (builder.policy.secretProperties() != null) { + certificatePolicy.withSecretProperties( + new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); + } + } else { + certificatePolicy = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } } /** - * Set the password - * - * @param password - * If the private key in base64EncodedCertificate is encrypted, the - * password used for encryption - * @return the Builder object itself. + * @return the vault base url */ - public Builder withPassword(String password) { - this.password = password; - return this; + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * Set the certificate policy - * - * @param policy - * The management policy for the certificate - * @return the Builder object itself. + * @return the certificate name */ - public Builder withPolicy(CertificatePolicy policy) { - this.policy = policy; - return this; + public String certificateName() { + return certificateName; } /** - * Set the certificate attributes - * - * @param attributes - * The attributes of the certificate - * @return the Builder object itself. + * @return the base64 encoded certificate */ - public Builder withAttributes(CertificateAttributes attributes) { - this.attributes = attributes; - return this; + public String base64EncodedCertificate() { + return base64EncodedCertificate; } /** - * Set the tags value. - * - * @param tags - * Application-specific metadata in the form of key-value pairs. - * @return the Builder object itself. + * @return the password */ - public Builder withTags(Map tags) { - this.tags = tags; - return this; + public String password() { + return password; } /** - * builds the {@link ImportCertificateRequest} object - * @return the {@link ImportCertificateRequest} object + * @return the certificatePolicy */ - public ImportCertificateRequest build() { - return new ImportCertificateRequest(this); + public CertificatePolicy certificatePolicy() { + return certificatePolicy; } - } - - private ImportCertificateRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - certificateName = builder.certificateName; - base64EncodedCertificate = builder.base64EncodedCertificate; - password = builder.password; - - if (builder.attributes != null) - certificateAttributes = (CertificateAttributes) new CertificateAttributes() - .withNotBefore(builder.attributes.notBefore()) - .withEnabled(builder.attributes.enabled()) - .withExpires(builder.attributes.expires()); - else - certificateAttributes = null; - - if (builder.policy != null) { - certificatePolicy = new CertificatePolicy(); - if (builder.policy.attributes() != null) { - certificatePolicy.withAttributes((CertificateAttributes) new CertificateAttributes() - .withEnabled(builder.policy.attributes().enabled()) - .withExpires(builder.policy.attributes().expires()) - .withNotBefore(builder.policy.attributes().notBefore())); - } - if (builder.policy.issuerReference() != null) { - certificatePolicy.withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); - } - if (builder.policy.x509CertificateProperties() != null) { - certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() - .withValidityInMonths(builder.policy.x509CertificateProperties().validityInMonths()) - .withSubjectAlternativeNames(builder.policy.x509CertificateProperties().subjectAlternativeNames()) - .withSubject(builder.policy.x509CertificateProperties().subject()) - .withEkus(builder.policy.x509CertificateProperties().ekus()) - .withKeyUsage(builder.policy.x509CertificateProperties().keyUsage())); - } - if (builder.policy.lifetimeActions() != null) { - certificatePolicy.withLifetimeActions(new ArrayList(builder.policy.lifetimeActions())); - } - if (builder.policy.keyProperties() != null) { - certificatePolicy.withKeyProperties(new KeyProperties() - .withExportable(builder.policy.keyProperties().exportable()) - .withKeySize(builder.policy.keyProperties().keySize()) - .withKeyType(builder.policy.keyProperties().keyType()) - .withReuseKey(builder.policy.keyProperties().reuseKey())); - } - if (builder.policy.secretProperties() != null) { - certificatePolicy.withSecretProperties( - new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); - } - } else { - certificatePolicy = null; + + /** + * @return the certificateAttributes + */ + public CertificateAttributes certificateAttributes() { + return certificateAttributes; } - if (builder.tags != null) { - tags = Collections.unmodifiableMap(builder.tags); - } else { - tags = null; + /** + * @return the tags + */ + public Map tags() { + return tags; } - } - - /** - * @return the vault base url - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the certificate name - */ - public String certificateName() { - return certificateName; - } - - /** - * @return the base64 encoded certificate - */ - public String base64EncodedCertificate() { - return base64EncodedCertificate; - } - - /** - * @return the password - */ - public String password() { - return password; - } - - /** - * @return the certificatePolicy - */ - public CertificatePolicy certificatePolicy() { - return certificatePolicy; - } - - /** - * @return the certificateAttributes - */ - public CertificateAttributes certificateAttributes() { - return certificateAttributes; - } - - /** - * @return the tags - */ - public Map tags() { - return tags; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java index 88e382aa07f1a..8fb02162ff3da 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java @@ -7,170 +7,168 @@ import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; -public class ImportKeyRequest { +/** + * The import key request class. + */ +public final class ImportKeyRequest { - private final String vaultBaseUrl; - private final String keyName; - private final JsonWebKey key; - private final boolean isHsm; - private final KeyAttributes keyAttributes; - private final Map tags; - - public static class Builder { - - // Required parameters private final String vaultBaseUrl; private final String keyName; private final JsonWebKey key; - - // Optional parameters - private boolean isHsm; - private KeyAttributes attributes; - private Map tags; + private final boolean isHsm; + private final KeyAttributes keyAttributes; + private final Map tags; /** - * The builder for constructing {@link ImportKeyRequest} object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param keyName - * The name of the key in the given vault - * @param key - * The Json web key. + * The {@link ImportKeyRequest} builder. */ - public Builder(String vaultBaseUrl, String keyName, JsonWebKey key) { - this.vaultBaseUrl = vaultBaseUrl; - this.keyName = keyName; - this.key = key; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String keyName; + private final JsonWebKey key; + + // Optional parameters + private boolean isHsm; + private KeyAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link ImportKeyRequest} object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net. + * @param keyName + * The name of the key in the given vault. + * @param key + * The Json web key. + */ + public Builder(String vaultBaseUrl, String keyName, JsonWebKey key) { + this.vaultBaseUrl = vaultBaseUrl; + this.keyName = keyName; + this.key = key; + } + + /** + * Set the isHsm to true if the key is imported as a hardware key to + * HSM, false otherwise. + * + * @param isHsm + * True, if the key is hardware key to be stored in HSM. + * false otherwise + * @return the Builder object itself. + */ + public Builder withHsm(boolean isHsm) { + this.isHsm = isHsm; + return this; + } + + /** + * Set the key attributes value. + * + * @param attributes + * the key management attributes value to set + * @return the Builder object itself. + */ + public Builder withAttributes(KeyAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value + * pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link ImportKeyRequest} object. + * + * @return the {@link ImportKeyRequest} object. + */ + public ImportKeyRequest build() { + return new ImportKeyRequest(this); + } + } + + private ImportKeyRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + keyName = builder.keyName; + isHsm = builder.isHsm; + + if (builder.key != null) { + key = new JsonWebKey().withKty(builder.key.kty()).withN(builder.key.n()).withE(builder.key.e()) + .withD(builder.key.d()).withP(builder.key.p()).withQ(builder.key.q()).withDp(builder.key.dp()) + .withDq(builder.key.dq()).withQi(builder.key.qi()).withK(builder.key.k()).withT(builder.key.t()); + if (builder.key.keyOps() != null) { + key.withKeyOps(new ArrayList(builder.key.keyOps())); + } + } else { + key = null; + } + + if (builder.attributes != null) { + keyAttributes = (KeyAttributes) new KeyAttributes().withNotBefore(builder.attributes.notBefore()) + .withEnabled(builder.attributes.enabled()).withExpires(builder.attributes.expires()); + } else { + keyAttributes = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } } /** - * Set the isHsm to true if the key is imported as a hardware key to HSM, - * false otherwise. - * - * @param isHsm - * True, if the key is hardware key to be stored in HSM. false otherwise - * @return the Builder object itself. + * @return the vault base url */ - public Builder withHsm(boolean isHsm) { - this.isHsm = isHsm; - return this; + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * Set the key attributes value. - * - * @param attributes - * the key management attributes value to set - * @return the Builder object itself. + * @return the key name */ - public Builder withAttributes(KeyAttributes attributes) { - this.attributes = attributes; - return this; + public String keyName() { + return keyName; } /** - * Set the tags value. - * - * @param tags - * Application-specific metadata in the form of key-value pairs. - * @return the Builder object itself. + * @return the key */ - public Builder withTags(Map tags) { - this.tags = tags; - return this; + public JsonWebKey key() { + return key; } /** - * builds the {@link ImportKeyRequest} object - * @return the {@link ImportKeyRequest} object + * @return the isHsm */ - public ImportKeyRequest build() { - return new ImportKeyRequest(this); - } - } - - private ImportKeyRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - keyName = builder.keyName; - isHsm = builder.isHsm; - - if (builder.key != null) { - key = new JsonWebKey() - .withKty(builder.key.kty()) - .withN(builder.key.n()) - .withE(builder.key.e()) - .withD(builder.key.d()) - .withP(builder.key.p()) - .withQ(builder.key.q()) - .withDp(builder.key.dp()) - .withDq(builder.key.dq()) - .withQi(builder.key.qi()) - .withK(builder.key.k()) - .withT(builder.key.t()); - if (builder.key.keyOps() != null) { - key.withKeyOps(new ArrayList(builder.key.keyOps())); - } - } else { - key = null; + public boolean isHsm() { + return isHsm; } - if (builder.attributes != null) { - keyAttributes = (KeyAttributes) new KeyAttributes() - .withNotBefore(builder.attributes.notBefore()) - .withEnabled(builder.attributes.enabled()) - .withExpires(builder.attributes.expires()); - } else { - keyAttributes = null; + /** + * @return the key attribute + */ + public KeyAttributes keyAttributes() { + return keyAttributes; } - if (builder.tags != null) { - tags = Collections.unmodifiableMap(builder.tags); - } else { - tags = null; + /** + * @return the tags + */ + public Map tags() { + return tags; } - } - - /** - * @return the vault base url - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the key name - */ - public String keyName() { - return keyName; - } - - /** - * @return the key - */ - public JsonWebKey key() { - return key; - } - - /** - * @return the isHsm - */ - public boolean isHsm() { - return isHsm; - } - - /** - * @return the key attribute - */ - public KeyAttributes keyAttributes() { - return keyAttributes; - } - - /** - * @return the tags - */ - public Map tags() { - return tags; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java index 524fb1cb996f1..9ad223c6a4816 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java @@ -7,125 +7,132 @@ import com.microsoft.azure.keyvault.models.CertificateAttributes; -public class MergeCertificateRequest { - private final String vaultBaseUrl; - private final String certificateName; - private final List x509Certificates; - private final CertificateAttributes certificateAttributes; - private final Map tags; - - public static class Builder { - - // Required parameters +/** + * The merge certificate request class. + */ +public final class MergeCertificateRequest { private final String vaultBaseUrl; private final String certificateName; private final List x509Certificates; - - // Optional parameters - private CertificateAttributes attributes; - private Map tags; + private final CertificateAttributes certificateAttributes; + private final Map tags; /** - * The builder for constructing {@link MergeCertificateRequest} object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName - * The name of the certificate in the given vault - * @param x509Certificates - * The certificate or the certificate chain to merge + * The {@link MergeCertificateRequest} builder. */ - public Builder(String vaultBaseUrl, String certificateName, List x509Certificates) { - this.vaultBaseUrl = vaultBaseUrl; - this.certificateName = certificateName; - this.x509Certificates = x509Certificates; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String certificateName; + private final List x509Certificates; + + // Optional parameters + private CertificateAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link MergeCertificateRequest} object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net. + * @param certificateName + * The name of the certificate in the given vault. + * @param x509Certificates + * The certificate or the certificate chain to merge. + */ + public Builder(String vaultBaseUrl, String certificateName, List x509Certificates) { + this.vaultBaseUrl = vaultBaseUrl; + this.certificateName = certificateName; + this.x509Certificates = x509Certificates; + } + + /** + * Set the attributes value. + * + * @param attributes + * The attributes of the certificate. + * @return the Builder object itself. + */ + public Builder withAttributes(CertificateAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value + * pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link MergeCertificateRequest} object. + * + * @return the {@link MergeCertificateRequest} object. + */ + public MergeCertificateRequest build() { + return new MergeCertificateRequest(this); + } + } + + private MergeCertificateRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + certificateName = builder.certificateName; + x509Certificates = new ArrayList(builder.x509Certificates); + + if (builder.attributes != null) { + certificateAttributes = (CertificateAttributes) new CertificateAttributes() + .withNotBefore(builder.attributes.notBefore()).withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()); + } else { + certificateAttributes = null; + } + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } } /** - * Set the attributes value. - * - * @param attributes - * The attributes of the certificate. - * @return the Builder object itself. + * @return the vault base url */ - public Builder withAttributes(CertificateAttributes attributes) { - this.attributes = attributes; - return this; + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * Set the tags value. - * - * @param tags - * Application-specific metadata in the form of key-value pairs. - * @return the Builder object itself. + * @return the certificate name */ - public Builder withTags(Map tags) { - this.tags = tags; - return this; + public String certificateName() { + return certificateName; } /** - * builds the {@link MergeCertificateRequest} object - * @return the {@link MergeCertificateRequest} object + * @return the x509 certificates */ - public MergeCertificateRequest build() { - return new MergeCertificateRequest(this); + public List x509Certificates() { + return x509Certificates; } - } - - private MergeCertificateRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - certificateName = builder.certificateName; - x509Certificates = new ArrayList(builder.x509Certificates); - - if (builder.attributes != null) { - certificateAttributes = (CertificateAttributes) new CertificateAttributes() - .withNotBefore(builder.attributes.notBefore()) - .withEnabled(builder.attributes.enabled()) - .withExpires(builder.attributes.expires()); - } else { - certificateAttributes = null; + + /** + * @return the certificate attributes + */ + public CertificateAttributes certificateAttributes() { + return certificateAttributes; } - if (builder.tags != null) { - tags = Collections.unmodifiableMap(builder.tags); - } else { - tags = null; + + /** + * @return the tags + */ + public Map tags() { + return tags; } - } - - /** - * @return the vault base url - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the certificate name - */ - public String certificateName() { - return certificateName; - } - - /** - * @return the x509 certificates - */ - public List x509Certificates() { - return x509Certificates; - } - - /** - * @return the certificate attributes - */ - public CertificateAttributes certificateAttributes() { - return certificateAttributes; - } - - /** - * @return the tags - */ - public Map tags() { - return tags; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java index 81c0eef5396bb..5c2d00f4d82e6 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java @@ -3,91 +3,97 @@ import com.microsoft.azure.keyvault.models.IssuerAttributes; import com.microsoft.azure.keyvault.models.IssuerBundle; -public class SetCertificateIssuerRequest { +/** + * The set certificate issuer request class. + */ +public final class SetCertificateIssuerRequest { - private final String vaultBaseUrl; - private final String issuerName; - private final IssuerBundle issuer; - - public static class Builder { - - // Required parameters private final String vaultBaseUrl; private final String issuerName; - - // Optional parameters - private IssuerBundle issuer; + private final IssuerBundle issuer; /** - * The builder for constructing {@link SetCertificateIssuerRequest} object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param issuerName - * The name of the issuer. + * The {@link SetCertificateIssuerRequest} builder. */ - public Builder(String vaultBaseUrl, String issuerName) { - this.vaultBaseUrl = vaultBaseUrl; - this.issuerName = issuerName; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String issuerName; + + // Optional parameters + private IssuerBundle issuer; + + /** + * The builder for constructing {@link SetCertificateIssuerRequest} + * object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net. + * @param issuerName + * The name of the issuer. + */ + public Builder(String vaultBaseUrl, String issuerName) { + this.vaultBaseUrl = vaultBaseUrl; + this.issuerName = issuerName; + } + + /** + * Set the issuer value. + * + * @param issuer + * The issuer bundle. + * @return the Builder object itself. + */ + public Builder withIssuer(IssuerBundle issuer) { + this.issuer = issuer; + return this; + } + + /** + * builds the {@link SetCertificateIssuerRequest} object. + * + * @return the {@link SetCertificateIssuerRequest} object. + */ + public SetCertificateIssuerRequest build() { + return new SetCertificateIssuerRequest(this); + } + } + + private SetCertificateIssuerRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + issuerName = builder.issuerName; + if (builder.issuer != null) { + issuer = new IssuerBundle().withProvider(builder.issuer.provider()) + .withOrganizationDetails(builder.issuer.organizationDetails()) + .withCredentials(builder.issuer.credentials()); + if (builder.issuer.attributes() != null) { + issuer.withAttributes(new IssuerAttributes().withEnabled(builder.issuer.attributes().enabled())); + } + } else { + issuer = null; + } } /** - * Set the issuer value. - * - * @param issuer - * The issuer bundle. - * @return the Builder object itself. + * @return the vault base url */ - public Builder withIssuer(IssuerBundle issuer) { - this.issuer = issuer; - return this; + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * builds the {@link SetCertificateIssuerRequest} object - * @return the {@link SetCertificateIssuerRequest} object + * @return the issuer name */ - public SetCertificateIssuerRequest build() { - return new SetCertificateIssuerRequest(this); + public String issuerName() { + return issuerName; } - } - private SetCertificateIssuerRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - issuerName = builder.issuerName; - if (builder.issuer != null) { - issuer = new IssuerBundle() - .withProvider(builder.issuer.provider()) - .withOrganizationDetails(builder.issuer.organizationDetails()) - .withCredentials(builder.issuer.credentials()); - if (builder.issuer.attributes() != null) { - issuer.withAttributes(new IssuerAttributes() - .withEnabled(builder.issuer.attributes().enabled())); - } - } else { - issuer = null; + /** + * @return the issuer + */ + public IssuerBundle issuer() { + return issuer; } - } - - /** - * @return the vault base url - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the issuer name - */ - public String issuerName() { - return issuerName; - } - - /** - * @return the issuer - */ - public IssuerBundle issuer() { - return issuer; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java index 7ba775a2595d6..a34c08d296f73 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java @@ -5,149 +5,155 @@ import com.microsoft.azure.keyvault.models.SecretAttributes; -public class SetSecretRequest { - private final String vaultBaseUrl; - private final String secretName; - private final String value; - private final String contentType; - private final SecretAttributes secretAttributes; - private final Map tags; - - public static class Builder { - - // Required parameters +/** + * The set secret request class. + */ +public final class SetSecretRequest { private final String vaultBaseUrl; private final String secretName; private final String value; - - // Optional parameters - private String contentType; - private SecretAttributes attributes; - private Map tags; + private final String contentType; + private final SecretAttributes secretAttributes; + private final Map tags; /** - * The builder for constructing {@link SetSecretRequest} object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param secretName - * The name of the secret in the given vault - * @param value - * The value of the secret + * The {@link SetSecretRequest} builder. */ - public Builder(String vaultBaseUrl, String secretName, String value) { - this.vaultBaseUrl = vaultBaseUrl; - this.secretName = secretName; - this.value = value; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String secretName; + private final String value; + + // Optional parameters + private String contentType; + private SecretAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link SetSecretRequest} object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net + * @param secretName + * The name of the secret in the given vault + * @param value + * The value of the secret + */ + public Builder(String vaultBaseUrl, String secretName, String value) { + this.vaultBaseUrl = vaultBaseUrl; + this.secretName = secretName; + this.value = value; + } + + /** + * Set the content type value. + * + * @param contentType + * Type of the secret value such as a password + * @return the Builder object itself. + */ + public Builder withContentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the attributes value. + * + * @param attributes + * The secret management attributes. + * @return the Builder object itself. + */ + public Builder withAttributes(SecretAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value + * pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link SetSecretRequest} object. + * + * @return the {@link SetSecretRequest} object. + */ + public SetSecretRequest build() { + return new SetSecretRequest(this); + } + } + + private SetSecretRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + secretName = builder.secretName; + value = builder.value; + contentType = builder.contentType; + + if (builder.attributes != null) { + secretAttributes = (SecretAttributes) new SecretAttributes().withNotBefore(builder.attributes.notBefore()) + .withEnabled(builder.attributes.enabled()).withExpires(builder.attributes.expires()); + } else { + secretAttributes = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } } /** - * Set the content type value. - * - * @param contentType - * Type of the secret value such as a password - * @return the Builder object itself. + * @return the vaultBaseUrl */ - public Builder withContentType(String contentType) { - this.contentType = contentType; - return this; + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * Set the attributes value. - * - * @param attributes - * The secret management attributes. - * @return the Builder object itself. + * @return the secretName */ - public Builder withAttributes(SecretAttributes attributes) { - this.attributes = attributes; - return this; + public String secretName() { + return secretName; } /** - * Set the tags value. - * - * @param tags - * Application-specific metadata in the form of key-value pairs. - * @return the Builder object itself. + * @return the value */ - public Builder withTags(Map tags) { - this.tags = tags; - return this; + public String value() { + return value; } /** - * builds the {@link SetSecretRequest} object - * @return the {@link SetSecretRequest} object + * @return the contentType */ - public SetSecretRequest build() { - return new SetSecretRequest(this); + public String contentType() { + return contentType; } - } - - private SetSecretRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - secretName = builder.secretName; - value = builder.value; - contentType = builder.contentType; - - if (builder.attributes != null) { - secretAttributes = (SecretAttributes) new SecretAttributes() - .withNotBefore(builder.attributes.notBefore()) - .withEnabled(builder.attributes.enabled()) - .withExpires(builder.attributes.expires()); - } else { - secretAttributes = null; + + /** + * @return the secretAttributes + */ + public SecretAttributes secretAttributes() { + return secretAttributes; } - if (builder.tags != null) { - tags = Collections.unmodifiableMap(builder.tags); - } else { - tags = null; + /** + * @return the tags + */ + public Map tags() { + return tags; } - } - - /** - * @return the vaultBaseUrl - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the secretName - */ - public String secretName() { - return secretName; - } - - /** - * @return the value - */ - public String value() { - return value; - } - - /** - * @return the contentType - */ - public String contentType() { - return contentType; - } - - /** - * @return the secretAttributes - */ - public SecretAttributes secretAttributes() { - return secretAttributes; - } - - /** - * @return the tags - */ - public Map tags() { - return tags; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java index 13b512b0392a5..633d16a2e7a70 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java @@ -3,91 +3,96 @@ import com.microsoft.azure.keyvault.models.IssuerAttributes; import com.microsoft.azure.keyvault.models.IssuerBundle; -public class UpdateCertificateIssuerRequest { - private final String vaultBaseUrl; - private final String issuerName; - private final IssuerBundle issuer; - - public static class Builder { - - // Required parameters +/** + * The update certificate issuer request class. + */ +public final class UpdateCertificateIssuerRequest { private final String vaultBaseUrl; private final String issuerName; - - // Optional parameters - private IssuerBundle issuer; + private final IssuerBundle issuer; /** - * The builder for constructing {@link UpdateCertificateIssuerRequest} - * object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param issuerName - * The name of the issuer in the given vault + * The {@link UpdateCertificateIssuerRequest} builder. */ - public Builder(String vaultBaseUrl, String issuerName) { - this.vaultBaseUrl = vaultBaseUrl; - this.issuerName = issuerName; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String issuerName; + + // Optional parameters + private IssuerBundle issuer; + + /** + * The builder for constructing {@link UpdateCertificateIssuerRequest} + * object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net. + * @param issuerName + * The name of the issuer in the given vault. + */ + public Builder(String vaultBaseUrl, String issuerName) { + this.vaultBaseUrl = vaultBaseUrl; + this.issuerName = issuerName; + } + + /** + * Set the issuer value. + * + * @param issuer + * The issuer bundle. + * @return the Builder object itself. + */ + public Builder withIssuer(IssuerBundle issuer) { + this.issuer = issuer; + return this; + } + + /** + * builds the {@link UpdateCertificateIssuerRequest} object. + * + * @return the {@link UpdateCertificateIssuerRequest} object. + */ + public UpdateCertificateIssuerRequest build() { + return new UpdateCertificateIssuerRequest(this); + } + } + + private UpdateCertificateIssuerRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + issuerName = builder.issuerName; + + if (builder.issuer != null) { + issuer = new IssuerBundle().withProvider(builder.issuer.provider()) + .withOrganizationDetails(builder.issuer.organizationDetails()) + .withCredentials(builder.issuer.credentials()); + if (builder.issuer.attributes() != null) { + issuer.withAttributes(new IssuerAttributes().withEnabled(builder.issuer.attributes().enabled())); + } + } else { + issuer = null; + } } /** - * Set the issuer value. - * - * @param issuer - * The issuer bundle. - * @return the Builder object itself. + * @return the vault base url */ - public Builder withIssuer(IssuerBundle issuer) { - this.issuer = issuer; - return this; + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * builds the {@link UpdateCertificateIssuerRequest} object - * @return the {@link UpdateCertificateIssuerRequest} object + * @return the issuer name */ - public UpdateCertificateIssuerRequest build() { - return new UpdateCertificateIssuerRequest(this); + public String issuerName() { + return issuerName; } - } - private UpdateCertificateIssuerRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - issuerName = builder.issuerName; - - if (builder.issuer != null) { - issuer = new IssuerBundle() - .withProvider(builder.issuer.provider()) - .withOrganizationDetails(builder.issuer.organizationDetails()) - .withCredentials(builder.issuer.credentials()); - if (builder.issuer.attributes() != null) { - issuer.withAttributes(new IssuerAttributes() - .withEnabled(builder.issuer.attributes().enabled())); - } - } else { - issuer = null; + /** + * @return the issuer + */ + public IssuerBundle issuer() { + return issuer; } - } - - /** - * @return the vault base url - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the issuer name - */ - public String issuerName() { - return issuerName; - } - - /** - * @return the issuer - */ - public IssuerBundle issuer() { - return issuer; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java index 53e9f6e40858f..95bd2af87a2e7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java @@ -2,83 +2,90 @@ import com.microsoft.azure.keyvault.models.CertificateOperation; -public class UpdateCertificateOperationRequest { - private final String vaultBaseUrl; - private final String certificateName; - private final CertificateOperation certificateOperation; - - public static class Builder { - - // Required parameters +/** + * The update certificate operation request class. + */ +public final class UpdateCertificateOperationRequest { private final String vaultBaseUrl; private final String certificateName; - - // Optional parameters - private Boolean cancellationRequested; + private final CertificateOperation certificateOperation; /** - * The builder for constructing {@link CreateCertificateRequest} object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName - * The name of the certificate in the given vault + * The {@link UpdateCertificateOperationRequest} builder. */ - public Builder(String vaultBaseUrl, String certificateName) { - this.vaultBaseUrl = vaultBaseUrl; - this.certificateName = certificateName; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String certificateName; + + // Optional parameters + private Boolean cancellationRequested; + + /** + * The builder for constructing {@link CreateCertificateRequest} object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net. + * @param certificateName + * The name of the certificate in the given vault. + */ + public Builder(String vaultBaseUrl, String certificateName) { + this.vaultBaseUrl = vaultBaseUrl; + this.certificateName = certificateName; + } + + /** + * Set the cancellationRequested value. + * + * @param cancellationRequested + * Indicates if cancellation was requested on the certificate + * operation. + * @return the Builder object itself. + */ + public Builder withCancellationRequested(Boolean cancellationRequested) { + this.cancellationRequested = cancellationRequested; + return this; + } + + /** + * builds the {@link UpdateCertificateOperationRequest} object. + * + * @return the {@link UpdateCertificateOperationRequest} object. + */ + public UpdateCertificateOperationRequest build() { + return new UpdateCertificateOperationRequest(this); + } + } + + private UpdateCertificateOperationRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + certificateName = builder.certificateName; + if (builder.cancellationRequested != null) { + certificateOperation = new CertificateOperation().withCancellationRequested(builder.cancellationRequested); + } else { + certificateOperation = null; + } } /** - * Set the cancellationRequested value. - * - * @param cancellationRequested - * Indicates if cancellation was requested on the certificate - * operation. - * @return the Builder object itself. + * @return the vault base url */ - public Builder withCancellationRequested(Boolean cancellationRequested) { - this.cancellationRequested = cancellationRequested; - return this; + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * builds the {@link UpdateCertificateOperationRequest} object - * @return the {@link UpdateCertificateOperationRequest} object + * @return the certificate name */ - public UpdateCertificateOperationRequest build() { - return new UpdateCertificateOperationRequest(this); + public String certificateName() { + return certificateName; } - } - private UpdateCertificateOperationRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - certificateName = builder.certificateName; - if (builder.cancellationRequested != null) { - certificateOperation = new CertificateOperation().withCancellationRequested(builder.cancellationRequested); - } else { - certificateOperation = null; + /** + * @return the certificate policy + */ + public CertificateOperation certificateOperation() { + return certificateOperation; } - } - - /** - * @return the vault base url - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the certificate name - */ - public String certificateName() { - return certificateName; - } - - /** - * @return the certificate policy - */ - public CertificateOperation certificateOperation() { - return certificateOperation; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java index b3c0e616c47de..da062e1ca5220 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java @@ -10,115 +10,124 @@ import com.microsoft.azure.keyvault.models.SecretProperties; import com.microsoft.azure.keyvault.models.X509CertificateProperties; -public class UpdateCertificatePolicyRequest { - private final String vaultBaseUrl; - private final String certificateName; - private final CertificatePolicy certificatePolicy; - - public static class Builder { - - // Required parameters +/** + * The update certificate policy request class. + */ +public final class UpdateCertificatePolicyRequest { private final String vaultBaseUrl; private final String certificateName; - - // Optional parameters - private CertificatePolicy policy; + private final CertificatePolicy certificatePolicy; /** - * The builder for constructing {@link UpdateCertificatePolicyRequest} - * object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName - * The name of the certificate in the given vault + * The {@link UpdateCertificatePolicyRequest} builder. */ - public Builder(String vaultBaseUrl, String certificateName) { - this.vaultBaseUrl = vaultBaseUrl; - this.certificateName = certificateName; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String certificateName; + + // Optional parameters + private CertificatePolicy policy; + + /** + * The builder for constructing {@link UpdateCertificatePolicyRequest} + * object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net. + * @param certificateName + * The name of the certificate in the given vault. + */ + public Builder(String vaultBaseUrl, String certificateName) { + this.vaultBaseUrl = vaultBaseUrl; + this.certificateName = certificateName; + } + + /** + * Set the certificatePolicy value. + * + * @param certificatePolicy + * The management policy for the certificate. + * @return the Builder object itself. + */ + public Builder withPolicy(CertificatePolicy certificatePolicy) { + this.policy = certificatePolicy; + return this; + } + + /** + * builds the {@link UpdateCertificatePolicyRequest} object. + * + * @return the {@link UpdateCertificatePolicyRequest} object. + */ + public UpdateCertificatePolicyRequest build() { + return new UpdateCertificatePolicyRequest(this); + } + } + + private UpdateCertificatePolicyRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + certificateName = builder.certificateName; + + if (builder.policy != null) { + certificatePolicy = new CertificatePolicy(); + if (builder.policy.attributes() != null) { + certificatePolicy.withAttributes((CertificateAttributes) new CertificateAttributes() + .withEnabled(builder.policy.attributes().enabled()) + .withExpires(builder.policy.attributes().expires()) + .withNotBefore(builder.policy.attributes().notBefore())); + } + if (builder.policy.issuerReference() != null) { + certificatePolicy + .withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); + } + if (builder.policy.x509CertificateProperties() != null) { + certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() + .withValidityInMonths(builder.policy.x509CertificateProperties().validityInMonths()) + .withSubjectAlternativeNames( + builder.policy.x509CertificateProperties().subjectAlternativeNames()) + .withSubject(builder.policy.x509CertificateProperties().subject()) + .withEkus(builder.policy.x509CertificateProperties().ekus()) + .withKeyUsage(builder.policy.x509CertificateProperties().keyUsage())); + } + if (builder.policy.lifetimeActions() != null) { + certificatePolicy.withLifetimeActions(new ArrayList(builder.policy.lifetimeActions())); + } + if (builder.policy.keyProperties() != null) { + certificatePolicy.withKeyProperties( + new KeyProperties().withExportable(builder.policy.keyProperties().exportable()) + .withKeySize(builder.policy.keyProperties().keySize()) + .withKeyType(builder.policy.keyProperties().keyType()) + .withReuseKey(builder.policy.keyProperties().reuseKey())); + } + if (builder.policy.secretProperties() != null) { + certificatePolicy.withSecretProperties( + new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); + } + } else { + certificatePolicy = null; + } } /** - * Set the certificatePolicy value. - * - * @param certificatePolicy - * The management policy for the certificate. - * @return the Builder object itself. + * @return the vault base url */ - public Builder withPolicy(CertificatePolicy certificatePolicy) { - this.policy = certificatePolicy; - return this; + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * builds the {@link UpdateCertificatePolicyRequest} object - * @return the {@link UpdateCertificatePolicyRequest} object + * @return the certificate name */ - public UpdateCertificatePolicyRequest build() { - return new UpdateCertificatePolicyRequest(this); + public String certificateName() { + return certificateName; } - } - private UpdateCertificatePolicyRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - certificateName = builder.certificateName; - - if (builder.policy != null) { - certificatePolicy = new CertificatePolicy(); - if (builder.policy.attributes() != null) { - certificatePolicy.withAttributes((CertificateAttributes) new CertificateAttributes() - .withEnabled(builder.policy.attributes().enabled()) - .withExpires(builder.policy.attributes().expires()) - .withNotBefore(builder.policy.attributes().notBefore())); - } - if (builder.policy.issuerReference() != null) { - certificatePolicy.withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); - } - if (builder.policy.x509CertificateProperties() != null) { - certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() - .withValidityInMonths(builder.policy.x509CertificateProperties().validityInMonths()) - .withSubjectAlternativeNames(builder.policy.x509CertificateProperties().subjectAlternativeNames()) - .withSubject(builder.policy.x509CertificateProperties().subject()) - .withEkus(builder.policy.x509CertificateProperties().ekus()) - .withKeyUsage(builder.policy.x509CertificateProperties().keyUsage())); - } - if (builder.policy.lifetimeActions() != null) { - certificatePolicy.withLifetimeActions(new ArrayList(builder.policy.lifetimeActions())); - } - if (builder.policy.keyProperties() != null) { - certificatePolicy.withKeyProperties(new KeyProperties() - .withExportable(builder.policy.keyProperties().exportable()) - .withKeySize(builder.policy.keyProperties().keySize()) - .withKeyType(builder.policy.keyProperties().keyType()) - .withReuseKey(builder.policy.keyProperties().reuseKey())); - } - if (builder.policy.secretProperties() != null) { - certificatePolicy.withSecretProperties( - new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); - } - } else { - certificatePolicy = null; + /** + * @return the certificate policy + */ + public CertificatePolicy certificatePolicy() { + return certificatePolicy; } - } - - /** - * @return the vault base url - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the certificate name - */ - public String certificateName() { - return certificateName; - } - - /** - * @return the certificate policy - */ - public CertificatePolicy certificatePolicy() { - return certificatePolicy; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java index 8cf417fd3ee5b..009caeded6ce7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java @@ -5,134 +5,142 @@ import com.microsoft.azure.keyvault.models.CertificateAttributes; -public class UpdateCertificateRequest { - private final String vaultBaseUrl; - private final String certificateName; - private final String certificateVersion; - private final CertificateAttributes certificateAttributes; - private final Map tags; - - public static class Builder { - - // Required parameters +/** + * The update certificate request class. + */ +public final class UpdateCertificateRequest { private final String vaultBaseUrl; private final String certificateName; - - // Optional parameters - private String certificateVersion; - private CertificateAttributes attributes; - private Map tags; + private final String certificateVersion; + private final CertificateAttributes certificateAttributes; + private final Map tags; /** - * The builder for constructing {@link UpdateCertificateRequest} object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName - * The name of the certificate in the given vault + * The {@link UpdateCertificateRequest} builder. */ - public Builder(String vaultBaseUrl, String certificateName) { - this.vaultBaseUrl = vaultBaseUrl; - this.certificateName = certificateName; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String certificateName; + + // Optional parameters + private String certificateVersion; + private CertificateAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link UpdateCertificateRequest} object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net. + * @param certificateName + * The name of the certificate in the given vault. + */ + public Builder(String vaultBaseUrl, String certificateName) { + this.vaultBaseUrl = vaultBaseUrl; + this.certificateName = certificateName; + } + + /** + * Set the certificate version value. + * + * @param version + * The version of the certificate. + * @return the Builder object itself. + */ + public Builder withCertificateVersion(String version) { + this.certificateVersion = version; + return this; + } + + /** + * Set the attributes value. + * + * @param attributes + * The attributes of the certificate. + * @return the Builder object itself. + */ + public Builder withAttributes(CertificateAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value + * pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link UpdateCertificateRequest} object. + * + * @return the {@link UpdateCertificateRequest} object. + */ + public UpdateCertificateRequest build() { + return new UpdateCertificateRequest(this); + } + } + + private UpdateCertificateRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + certificateName = builder.certificateName; + certificateVersion = builder.certificateVersion == null ? "" : builder.certificateVersion; + + if (builder.attributes != null) { + certificateAttributes = (CertificateAttributes) new CertificateAttributes() + .withNotBefore(builder.attributes.notBefore()).withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()); + } else { + certificateAttributes = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } } /** - * Set the certificate version value. - * - * @param version - * The version of the certificate - * @return the Builder object itself. + * @return the vault base url */ - public Builder withCertificateVersion(String version) { - this.certificateVersion = version; - return this; + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * Set the attributes value. - * - * @param attributes - * The attributes of the certificate. - * @return the Builder object itself. + * @return the certificate name */ - public Builder withAttributes(CertificateAttributes attributes) { - this.attributes = attributes; - return this; + public String certificateName() { + return certificateName; } /** - * Set the tags value. - * - * @param tags - * Application-specific metadata in the form of key-value pairs. - * @return the Builder object itself. + * @return the certificate version */ - public Builder withTags(Map tags) { - this.tags = tags; - return this; + public String certificateVersion() { + return certificateVersion; } /** - * builds the {@link UpdateCertificateRequest} object - * @return the {@link UpdateCertificateRequest} object + * @return the certificate attributes */ - public UpdateCertificateRequest build() { - return new UpdateCertificateRequest(this); - } - } - - private UpdateCertificateRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - certificateName = builder.certificateName; - certificateVersion = builder.certificateVersion == null ? "" : builder.certificateVersion; - - if (builder.attributes != null) { - certificateAttributes = (CertificateAttributes) new CertificateAttributes() - .withNotBefore(builder.attributes.notBefore()).withEnabled(builder.attributes.enabled()) - .withExpires(builder.attributes.expires()); - } else { - certificateAttributes = null; + public CertificateAttributes certificateAttributes() { + return certificateAttributes; } - if (builder.tags != null) { - tags = Collections.unmodifiableMap(builder.tags); - } else { - tags = null; + /** + * @return the tags + */ + public Map tags() { + return tags; } - } - - /** - * @return the vault base url - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the certificate name - */ - public String certificateName() { - return certificateName; - } - - /** - * @return the certificate version - */ - public String certificateVersion() { - return certificateVersion; - } - - /** - * @return the certificate attributes - */ - public CertificateAttributes certificateAttributes() { - return certificateAttributes; - } - - /** - * @return the tags - */ - public Map tags() { - return tags; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java index 9014c49bfd77a..d87b8c798c583 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java @@ -8,176 +8,184 @@ import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.models.KeyAttributes; -public class UpdateKeyRequest { +/** + * The key update request class. + */ +public final class UpdateKeyRequest { - private final String vaultBaseUrl; - private final String keyName; - private final String keyVersion; - private final List keyOperations; - private final KeyAttributes keyAttributes; - private final Map tags; - - public static class Builder { - - // Required parameters private final String vaultBaseUrl; private final String keyName; - - // Optional parameters - private String keyVersion; - private List keyOperations; - private KeyAttributes attributes; - private Map tags; + private final String keyVersion; + private final List keyOperations; + private final KeyAttributes keyAttributes; + private final Map tags; /** - * The builder for constructing {@link UpdateKeyRequest} object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param keyName - * The name of the key in the given vault + * The {@link UpdateKeyRequest} builder. */ - public Builder(String vaultBaseUrl, String keyName) { - this.vaultBaseUrl = vaultBaseUrl; - this.keyName = keyName; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String keyName; + + // Optional parameters + private String keyVersion; + private List keyOperations; + private KeyAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link UpdateKeyRequest} object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net. + * @param keyName + * The name of the key in the given vault. + */ + public Builder(String vaultBaseUrl, String keyName) { + this.vaultBaseUrl = vaultBaseUrl; + this.keyName = keyName; + } + + /** + * The builder for constructing {@link UpdateKeyRequest} object. + * + * @param keyIdentifier + * The key identifier, e.g. + * https://{vault-name}.vault.azure.net/keys/{key-name}/{key- + * version}. + */ + public Builder(String keyIdentifier) { + KeyIdentifier id = new KeyIdentifier(keyIdentifier); + this.vaultBaseUrl = id.vault(); + this.keyName = id.name(); + this.keyVersion = id.version(); + } + + /** + * Set the key version value. + * + * @param keyVersion + * the key version. + * @return the Builder object itself. + */ + public Builder withVersion(String keyVersion) { + this.keyVersion = keyVersion; + return this; + } + + /** + * Set the key operations value. + * + * @param keyOperations + * the key operation list + * @return the Builder object itself. + */ + public Builder withKeyOperations(List keyOperations) { + this.keyOperations = keyOperations; + return this; + } + + /** + * Set the key attributes value. + * + * @param attributes + * the key management attributes value to set + * @return the Builder object itself. + */ + public Builder withAttributes(KeyAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value + * pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link UpdateKeyRequest} object. + * + * @return the {@link UpdateKeyRequest} object. + */ + public UpdateKeyRequest build() { + return new UpdateKeyRequest(this); + } } - /** - * The builder for constructing {@link UpdateKeyRequest} object - * - * @param keyIdentifier - * The key identifier, e.g. - * https://{vault-name}.vault.azure.net/keys/{key-name}/{key- - * version} - */ - public Builder(String keyIdentifier) { - KeyIdentifier id = new KeyIdentifier(keyIdentifier); - this.vaultBaseUrl = id.vault(); - this.keyName = id.name(); - this.keyVersion = id.version(); + private UpdateKeyRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + keyName = builder.keyName; + keyVersion = builder.keyVersion == null ? "" : builder.keyVersion; + + if (builder.keyOperations != null) { + keyOperations = new ArrayList(builder.keyOperations); + } else { + keyOperations = null; + } + + if (builder.attributes != null) { + keyAttributes = (KeyAttributes) new KeyAttributes().withEnabled(builder.attributes.enabled()) + .withExpires(builder.attributes.expires()).withNotBefore(builder.attributes.notBefore()); + } else { + keyAttributes = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } } /** - * Set the key version value. - * - * @param keyVersion - * the key version - * @return the Builder object itself. + * @return the vault base url */ - public Builder withVersion(String keyVersion) { - this.keyVersion = keyVersion; - return this; + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * Set the key operations value. - * - * @param keyOperations - * the key operation list - * @return the Builder object itself. + * @return the key name */ - public Builder withKeyOperations(List keyOperations) { - this.keyOperations = keyOperations; - return this; + public String keyName() { + return keyName; } /** - * Set the key attributes value. - * - * @param attributes - * the key management attributes value to set - * @return the Builder object itself. + * @return the key version */ - public Builder withAttributes(KeyAttributes attributes) { - this.attributes = attributes; - return this; + public String keyVersion() { + return keyVersion; } /** - * Set the tags value. - * - * @param tags - * Application-specific metadata in the form of key-value pairs. - * @return the Builder object itself. + * @return the key operations */ - public Builder withTags(Map tags) { - this.tags = tags; - return this; + public List keyOperations() { + return keyOperations; } /** - * builds the {@link UpdateKeyRequest} object - * @return the {@link UpdateKeyRequest} object + * @return the key attributes */ - public UpdateKeyRequest build() { - return new UpdateKeyRequest(this); - } - } - - private UpdateKeyRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - keyName = builder.keyName; - keyVersion = builder.keyVersion == null ? "" : builder.keyVersion; - - if (builder.keyOperations != null) { - keyOperations = new ArrayList(builder.keyOperations); - } else { - keyOperations = null; - } - - if (builder.attributes != null) { - keyAttributes = (KeyAttributes) new KeyAttributes().withEnabled(builder.attributes.enabled()) - .withExpires(builder.attributes.expires()).withNotBefore(builder.attributes.notBefore()); - } else { - keyAttributes = null; + public KeyAttributes keyAttributes() { + return keyAttributes; } - if (builder.tags != null) { - tags = Collections.unmodifiableMap(builder.tags); - } else { - tags = null; + /** + * @return the tags + */ + public Map tags() { + return tags; } - } - - /** - * @return the vault base url - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the key name - */ - public String keyName() { - return keyName; - } - - /** - * @return the key version - */ - public String keyVersion() { - return keyVersion; - } - - /** - * @return the key operations - */ - public List keyOperations() { - return keyOperations; - } - - /** - * @return the key attributes - */ - public KeyAttributes keyAttributes() { - return keyAttributes; - } - - /** - * @return the tags - */ - public Map tags() { - return tags; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java index a777820320195..732aa8843ae33 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java @@ -6,163 +6,176 @@ import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.azure.keyvault.models.SecretAttributes; -public class UpdateSecretRequest { - private final String vaultBaseUrl; - private final String secretName; - private final String secretVersion; - private final String contentType; - private final SecretAttributes secretAttributes; - private final Map tags; - - public static class Builder { - - // Required parameters +/** + * The update secret request class. + */ +public final class UpdateSecretRequest { private final String vaultBaseUrl; private final String secretName; - - // Optional parameters - private String secretVersion; - private String contentType; - private SecretAttributes attributes; - private Map tags; + private final String secretVersion; + private final String contentType; + private final SecretAttributes secretAttributes; + private final Map tags; /** - * The builder for constructing {@link UpdateSecretRequest} object - * - * @param vaultBaseUrl - * The vault name, e.g. https://myvault.vault.azure.net - * @param secretName - * The name of the secret in the given vault + * The {@link UpdateSecretRequest} builder. */ - public Builder(String vaultBaseUrl, String secretName) { - this.vaultBaseUrl = vaultBaseUrl; - this.secretName = secretName; + public static class Builder { + + // Required parameters + private final String vaultBaseUrl; + private final String secretName; + + // Optional parameters + private String secretVersion; + private String contentType; + private SecretAttributes attributes; + private Map tags; + + /** + * The builder for constructing {@link UpdateSecretRequest} object. + * + * @param vaultBaseUrl + * The vault name, e.g. https://myvault.vault.azure.net. + * @param secretName + * The name of the secret in the given vault. + */ + public Builder(String vaultBaseUrl, String secretName) { + this.vaultBaseUrl = vaultBaseUrl; + this.secretName = secretName; + } + + /** + * The builder for constructing {@link UpdateSecretRequest} object. + * + * @param secretId + * The secret identifier, e.g. + * https://{vault-name}.vault.azure.net/secrets/{secret-name} + * /{ secret-version}. + */ + public Builder(String secretId) { + SecretIdentifier id = new SecretIdentifier(secretId); + this.vaultBaseUrl = id.vault(); + this.secretName = id.name(); + this.secretVersion = id.version(); + } + + /** + * Sets the secret version. + * @param version the secret version. + * @return the Builder object itself. + */ + public Builder withVersion(String version) { + this.secretVersion = version; + return this; + } + + /** + * Set the content type value. + * + * @param contentType + * Type of the secret value such as a password. + * @return the Builder object itself. + */ + public Builder withContentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the attributes value. + * + * @param attributes + * The secret management attributes. + * @return the Builder object itself. + */ + public Builder withAttributes(SecretAttributes attributes) { + this.attributes = attributes; + return this; + } + + /** + * Set the tags value. + * + * @param tags + * Application-specific metadata in the form of key-value + * pairs. + * @return the Builder object itself. + */ + public Builder withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * builds the {@link UpdateSecretRequest} object. + * + * @return the {@link UpdateSecretRequest} object. + */ + public UpdateSecretRequest build() { + return new UpdateSecretRequest(this); + } } - /** - * The builder for constructing {@link UpdateSecretRequest} object - * - * @param secretId - * The secret identifier, e.g. - * https://{vault-name}.vault.azure.net/secrets/{secret-name}/{ - * secret-version} - */ - public Builder(String secretId) { - SecretIdentifier id = new SecretIdentifier(secretId); - this.vaultBaseUrl = id.vault(); - this.secretName = id.name(); - this.secretVersion = id.version(); + private UpdateSecretRequest(Builder builder) { + vaultBaseUrl = builder.vaultBaseUrl; + secretName = builder.secretName; + secretVersion = builder.secretVersion == null ? "" : builder.secretVersion; + contentType = builder.contentType; + + if (builder.attributes != null) { + secretAttributes = (SecretAttributes) new SecretAttributes().withNotBefore(builder.attributes.notBefore()) + .withEnabled(builder.attributes.enabled()).withExpires(builder.attributes.expires()); + } else { + secretAttributes = null; + } + + if (builder.tags != null) { + tags = Collections.unmodifiableMap(builder.tags); + } else { + tags = null; + } } - public Builder withVersion(String version) { - this.secretVersion = version; - return this; + /** + * @return the vaultBaseUrl + */ + public String vaultBaseUrl() { + return vaultBaseUrl; } /** - * Set the content type value. - * - * @param contentType - * Type of the secret value such as a password - * @return the Builder object itself. + * @return the secretName */ - public Builder withContentType(String contentType) { - this.contentType = contentType; - return this; + public String secretName() { + return secretName; } /** - * Set the attributes value. - * - * @param attributes - * The secret management attributes. - * @return the Builder object itself. + * @return the secretVersion */ - public Builder withAttributes(SecretAttributes attributes) { - this.attributes = attributes; - return this; + public String secretVersion() { + return secretVersion; } /** - * Set the tags value. - * - * @param tags - * Application-specific metadata in the form of key-value pairs. - * @return the Builder object itself. + * @return the contentType */ - public Builder withTags(Map tags) { - this.tags = tags; - return this; + public String contentType() { + return contentType; } /** - * builds the {@link UpdateSecretRequest} object - * @return the {@link UpdateSecretRequest} object + * @return the secretAttributes */ - public UpdateSecretRequest build() { - return new UpdateSecretRequest(this); - } - } - - private UpdateSecretRequest(Builder builder) { - vaultBaseUrl = builder.vaultBaseUrl; - secretName = builder.secretName; - secretVersion = builder.secretVersion == null ? "" : builder.secretVersion; - contentType = builder.contentType; - - if (builder.attributes != null) { - secretAttributes = (SecretAttributes) new SecretAttributes().withNotBefore(builder.attributes.notBefore()) - .withEnabled(builder.attributes.enabled()).withExpires(builder.attributes.expires()); - } else { - secretAttributes = null; + public SecretAttributes secretAttributes() { + return secretAttributes; } - if (builder.tags != null) { - tags = Collections.unmodifiableMap(builder.tags); - } else { - tags = null; + /** + * @return the tags + */ + public Map tags() { + return tags; } - } - - /** - * @return the vaultBaseUrl - */ - public String vaultBaseUrl() { - return vaultBaseUrl; - } - - /** - * @return the secretName - */ - public String secretName() { - return secretName; - } - - /** - * @return the secretVersion - */ - public String secretVersion() { - return secretVersion; - } - - /** - * @return the contentType - */ - public String contentType() { - return contentType; - } - - /** - * @return the secretAttributes - */ - public SecretAttributes secretAttributes() { - return secretAttributes; - } - - /** - * @return the tags - */ - public Map tags() { - return tags; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/package-info.java new file mode 100644 index 0000000000000..bc203912e1f90 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// + +/** + * This package contains the classes for KeyVaultClient. Performs cryptographic + * key operations and vault operations against the Key Vault service. + */ +package com.microsoft.azure.keyvault.requests; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java index 6a39ee15891d0..96ee1a2d303e8 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java @@ -23,14 +23,26 @@ import java.util.List; /** - * Supported JsonWebKey Algorithms + * Supported JsonWebKey Algorithms. */ public final class JsonWebKeyEncryptionAlgorithm { + /** + * The 'RSA-OAEP' algorithm. + */ public static final String RSAOAEP = "RSA-OAEP"; + + /** + * The 'RSA1_5' algorithm. + */ public static final String RSA15 = "RSA1_5"; - public static final List ALL_ALGORITHMS = Collections.unmodifiableList(Arrays.asList(new String[] { RSA15, RSAOAEP })); + /** + * All the JWK encryption algorithms. + */ + public static final List ALL_ALGORITHMS = + Collections.unmodifiableList( + Arrays.asList(new String[] {RSA15, RSAOAEP})); private JsonWebKeyEncryptionAlgorithm() { // not instantiable diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java index cceb635f4a88a..50360fee81496 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java @@ -23,18 +23,46 @@ import java.util.List; /** - * Supported JsonWebKey operations + * Supported JsonWebKey operations. */ public final class JsonWebKeyOperation { + /** + * Encrypt operation. + */ public static final String ENCRYPT = "encrypt"; + + /** + * Decrypt operation. + */ public static final String DECRYPT = "decrypt"; + + /** + * Sign operation. + */ public static final String SIGN = "sign"; + + /** + * Verify operation. + */ public static final String VERIFY = "verify"; + + /** + * WrapKey operation. + */ public static final String WRAP = "wrapKey"; + + /** + * UnwrapKey operation. + */ public static final String UNWRAP = "unwrapKey"; - public static final List ALL_OPERATIONS = Collections.unmodifiableList(Arrays.asList(new String[] { ENCRYPT, DECRYPT, SIGN, VERIFY, WRAP, UNWRAP })); + /** + * All JWK operations. + */ + public static final List ALL_OPERATIONS = + Collections.unmodifiableList( + Arrays.asList(new String[] {ENCRYPT, DECRYPT, SIGN, VERIFY, WRAP, UNWRAP })); private JsonWebKeyOperation() { // not instantiable diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java index 0c2d856aec0c0..fa9737305d268 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java @@ -23,16 +23,36 @@ import java.util.List; /** - * Supported JsonWebKey Algorithms + * Supported JsonWebKey Algorithms. */ public final class JsonWebKeySignatureAlgorithm { + /** + * The 'RS256' algorithm. + */ public static final String RS256 = "RS256"; + + /** + * The 'RS384' algorithm. + */ public static final String RS384 = "RS384"; + + /** + * The 'RS512' algorithm. + */ public static final String RS512 = "RS512"; + + /** + * The 'RSNULL' algorithm. + */ public static final String RSNULL = "RSNULL"; - public static final List ALL_ALGORITHMS = Collections.unmodifiableList(Arrays.asList(new String[] { RS256, RS384, RS512, RSNULL })); + /** + * All JWK algorithms. + */ + public static final List ALL_ALGORITHMS = + Collections.unmodifiableList( + Arrays.asList(new String[] {RS256, RS384, RS512, RSNULL})); private JsonWebKeySignatureAlgorithm() { // not instantiable diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java index af2dbf6b9351a..a04d9b3c40540 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java @@ -23,16 +23,36 @@ import java.util.List; /** - * Supported JsonWebKey key types (kty) + * Supported JsonWebKey key types (kty). */ public final class JsonWebKeyType { + /** + * The Elliptic Curve 'EC' key type. + */ public static final String EC = "EC"; + + /** + * The 'RSA' key type. + */ public static final String RSA = "RSA"; + + /** + * The 'RSA-HSM' key type. + */ public static final String RSAHSM = "RSA-HSM"; + + /** + * The Octet 'oct' key type. + */ public static final String OCT = "oct"; - public static final List ALL_TYPES = Collections.unmodifiableList(Arrays.asList(new String[] { EC, RSA, RSAHSM, OCT })); + /** + * All JWK key types. + */ + public static final List ALL_TYPES = + Collections.unmodifiableList( + Arrays.asList(new String[] {EC, RSA, RSAHSM, OCT})); private JsonWebKeyType() { // not instantiable diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java new file mode 100644 index 0000000000000..30b69d136c2b7 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +/** + * This package contains the classes for KeyVaultClient. Performs cryptographic + * key operations and vault operations against the Key Vault service. + */ +package com.microsoft.azure.keyvault.webkey; From 5b86f0d7c56a26c11f92b45d8de9211ddc25908e Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Fri, 26 Aug 2016 16:30:30 -0700 Subject: [PATCH 17/56] Generated code returns observables --- .../azure/keyvault/KeyVaultClient.java | 506 +- .../azure/keyvault/KeyVaultClientImpl.java | 4895 ++++++++--------- .../keyvault/implementation/package-info.java | 11 + .../azure/keyvault/models/Action.java | 4 +- .../azure/keyvault/models/ActionType.java | 4 +- .../keyvault/models/AdministratorDetails.java | 4 +- .../azure/keyvault/models/Attributes.java | 4 +- .../keyvault/models/BackupKeyResult.java | 4 +- .../models/CertificateAttributes.java | 4 +- .../keyvault/models/CertificateBundle.java | 58 +- .../models/CertificateCreateParameters.java | 4 +- .../models/CertificateImportParameters.java | 4 +- .../models/CertificateIssuerItem.java | 4 +- .../keyvault/models/CertificateItem.java | 19 +- .../models/CertificateMergeParameters.java | 4 +- .../keyvault/models/CertificateOperation.java | 34 +- .../keyvault/models/CertificatePolicy.java | 4 +- .../models/CertificateUpdateParameters.java | 4 +- .../azure/keyvault/models/Contact.java | 4 +- .../azure/keyvault/models/Contacts.java | 4 +- .../azure/keyvault/models/Error.java | 4 +- .../keyvault/models/IssuerAttributes.java | 4 +- .../azure/keyvault/models/IssuerBundle.java | 34 +- .../keyvault/models/IssuerCredentials.java | 4 +- .../keyvault/models/IssuerReference.java | 4 +- .../azure/keyvault/models/JsonWebKey.java | 197 +- .../models/JsonWebKeyEncryptionAlgorithm.java | 59 + .../keyvault/models/JsonWebKeyOperation.java | 71 + .../models/JsonWebKeySignatureAlgorithm.java | 65 + .../azure/keyvault/models/JsonWebKeyType.java | 65 + .../azure/keyvault/models/KeyAttributes.java | 4 +- .../azure/keyvault/models/KeyBundle.java | 34 +- .../keyvault/models/KeyCreateParameters.java | 19 +- .../keyvault/models/KeyImportParameters.java | 4 +- .../azure/keyvault/models/KeyItem.java | 19 +- .../keyvault/models/KeyOperationResult.java | 4 +- .../models/KeyOperationsParameters.java | 10 +- .../azure/keyvault/models/KeyProperties.java | 4 +- .../keyvault/models/KeyRestoreParameters.java | 4 +- .../keyvault/models/KeySignParameters.java | 10 +- .../keyvault/models/KeyUpdateParameters.java | 10 +- .../azure/keyvault/models/KeyUsageType.java | 4 +- .../azure/keyvault/models/KeyVaultError.java | 4 +- .../models/KeyVaultErrorException.java | 4 +- .../keyvault/models/KeyVerifyParameters.java | 10 +- .../keyvault/models/KeyVerifyResult.java | 4 +- .../azure/keyvault/models/LifetimeAction.java | 4 +- .../keyvault/models/OrganizationDetails.java | 4 +- .../azure/keyvault/models/PageImpl.java | 4 +- ...endingCertificateSigningRequestResult.java | 4 +- .../keyvault/models/SecretAttributes.java | 4 +- .../azure/keyvault/models/SecretBundle.java | 35 +- .../azure/keyvault/models/SecretItem.java | 19 +- .../keyvault/models/SecretProperties.java | 4 +- .../keyvault/models/SecretSetParameters.java | 4 +- .../models/SecretUpdateParameters.java | 4 +- .../models/SubjectAlternativeNames.java | 4 +- .../azure/keyvault/models/Trigger.java | 4 +- .../models/X509CertificateProperties.java | 4 +- .../azure/keyvault/models/package-info.java | 4 +- .../azure/keyvault/package-info.java | 4 +- .../keyvault/requests/CreateKeyRequest.java | 20 +- .../keyvault/requests/UpdateKeyRequest.java | 11 +- 63 files changed, 2968 insertions(+), 3403 deletions(-) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyEncryptionAlgorithm.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyOperation.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeySignatureAlgorithm.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyType.java diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 52cbba1b6abbe..313cc75af9826 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -1,7 +1,7 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. + * license information. */ package com.microsoft.azure.keyvault; @@ -12,6 +12,7 @@ import com.google.common.base.Joiner; import com.microsoft.azure.AzureClient; import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; import com.microsoft.azure.keyvault.models.BackupKeyResult; import com.microsoft.azure.keyvault.models.CertificateBundle; @@ -21,6 +22,8 @@ import com.microsoft.azure.keyvault.models.CertificatePolicy; import com.microsoft.azure.keyvault.models.Contacts; import com.microsoft.azure.keyvault.models.IssuerBundle; +import com.microsoft.azure.keyvault.models.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.models.JsonWebKeySignatureAlgorithm; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyItem; import com.microsoft.azure.keyvault.models.KeyOperationResult; @@ -46,7 +49,6 @@ import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.ServiceResponseCallback; import com.microsoft.rest.credentials.ServiceClientCredentials; import okhttp3.ResponseBody; @@ -57,6 +59,8 @@ import retrofit2.http.Headers; import retrofit2.http.Path; import retrofit2.http.Query; +import rx.Observable; +import rx.functions.Func1; /** * Initializes a new instance of the KeyVaultClient class. @@ -70,7 +74,7 @@ public final class KeyVaultClient { /** * Gets the {@link AzureClient} used for long running operations. - * + * * @return the azure client; */ public AzureClient getAzureClient() { @@ -121,7 +125,7 @@ public int longRunningOperationRetryTimeout() { public void withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { innerKeyVaultClient.withLongRunningOperationRetryTimeout(longRunningOperationRetryTimeout); } - + /** * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. * @@ -139,7 +143,7 @@ public boolean getGenerateClientRequestId() { public void withGenerateClientRequestId(boolean generateClientRequestId) { innerKeyVaultClient.withGenerateClientRequestId(generateClientRequestId); } - + /** * Initializes an instance of KeyVaultClient client. * @@ -180,69 +184,69 @@ private void initializeService() { interface KeyVaultClientService { @Headers({"Content-Type: application/json; charset=utf-8", "Accept: application/pkcs10"}) @GET("certificates/{certificate-name}/pending") - Call getPendingCertificateSigningRequest(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getPendingCertificateSigningRequest(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); } - + /** * Creates a new, named, key in the specified vault. * * @param createKeyRequest the grouped properties for creating a key request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createKey(CreateKeyRequest createKeyRequest) + public ServiceResponse createKey(CreateKeyRequest createKeyRequest) throws KeyVaultErrorException, IllegalArgumentException, IOException { return innerKeyVaultClient.createKey( - createKeyRequest.vaultBaseUrl(), - createKeyRequest.keyName(), - createKeyRequest.keyType(), - createKeyRequest.keySize(), - createKeyRequest.keyOperations(), - createKeyRequest.keyAttributes(), - createKeyRequest.tags()); + createKeyRequest.vaultBaseUrl(), + createKeyRequest.keyName(), + createKeyRequest.keyType(), + createKeyRequest.keySize(), + createKeyRequest.keyOperations(), + createKeyRequest.keyAttributes(), + createKeyRequest.tags()); } - + /** * Creates a new, named, key in the specified vault. * * @param createKeyRequest the grouped properties for creating a key request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall createKeyAsync(CreateKeyRequest createKeyRequest, ServiceCallback serviceCallback) { return innerKeyVaultClient.createKeyAsync( - createKeyRequest.vaultBaseUrl(), - createKeyRequest.keyName(), - createKeyRequest.keyType(), - createKeyRequest.keySize(), - createKeyRequest.keyOperations(), - createKeyRequest.keyAttributes(), - createKeyRequest.tags(), + createKeyRequest.vaultBaseUrl(), + createKeyRequest.keyName(), + createKeyRequest.keyType(), + createKeyRequest.keySize(), + createKeyRequest.keyOperations(), + createKeyRequest.keyAttributes(), + createKeyRequest.tags(), serviceCallback); } - + /** * Imports a key into the specified vault. * * @param importKeyRequest the grouped properties for importing a key request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse importKey(ImportKeyRequest importKeyRequest) + public ServiceResponse importKey(ImportKeyRequest importKeyRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.importKey( - importKeyRequest.vaultBaseUrl(), - importKeyRequest.keyName(), - importKeyRequest.key(), - importKeyRequest.isHsm(), - importKeyRequest.keyAttributes(), + importKeyRequest.vaultBaseUrl(), + importKeyRequest.keyName(), + importKeyRequest.key(), + importKeyRequest.isHsm(), + importKeyRequest.keyAttributes(), importKeyRequest.tags()); } @@ -250,18 +254,18 @@ public ServiceResponse importKey(ImportKeyRequest importKeyRequest) * Imports a key into the specified vault. * * @param importKeyRequest the grouped properties for importing a key request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(ImportKeyRequest importKeyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.importKeyAsync( - importKeyRequest.vaultBaseUrl(), - importKeyRequest.keyName(), - importKeyRequest.key(), - importKeyRequest.isHsm(), - importKeyRequest.keyAttributes(), - importKeyRequest.tags(), + importKeyRequest.vaultBaseUrl(), + importKeyRequest.keyName(), + importKeyRequest.key(), + importKeyRequest.isHsm(), + importKeyRequest.keyAttributes(), + importKeyRequest.tags(), serviceCallback); } @@ -275,7 +279,7 @@ public ServiceCall importKeyAsync(ImportKeyRequest importKeyRequest, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) + public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteKey(vaultBaseUrl, keyName); } @@ -296,20 +300,20 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName * Updates the Key Attributes associated with the specified key. * * @param updateKeyRequest the grouped properties for updating a key request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateKey(UpdateKeyRequest updateKeyRequest) + public ServiceResponse updateKey(UpdateKeyRequest updateKeyRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateKey( - updateKeyRequest.vaultBaseUrl(), - updateKeyRequest.keyName(), - updateKeyRequest.keyVersion(), - updateKeyRequest.keyOperations(), - updateKeyRequest.keyAttributes(), + updateKeyRequest.vaultBaseUrl(), + updateKeyRequest.keyName(), + updateKeyRequest.keyVersion(), + updateKeyRequest.keyOperations(), + updateKeyRequest.keyAttributes(), updateKeyRequest.tags()); } @@ -317,21 +321,21 @@ public ServiceResponse updateKey(UpdateKeyRequest updateKeyRequest) * Updates the Key Attributes associated with the specified key. * * @param updateKeyRequest the grouped properties for updating a key request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateKeyAsync(UpdateKeyRequest updateKeyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateKeyAsync( - updateKeyRequest.vaultBaseUrl(), - updateKeyRequest.keyName(), - updateKeyRequest.keyVersion(), - updateKeyRequest.keyOperations(), - updateKeyRequest.keyAttributes(), + updateKeyRequest.vaultBaseUrl(), + updateKeyRequest.keyName(), + updateKeyRequest.keyVersion(), + updateKeyRequest.keyOperations(), + updateKeyRequest.keyAttributes(), updateKeyRequest.tags(), serviceCallback); } - + /** * Retrieves the public portion of a key plus its attributes. * @@ -358,7 +362,7 @@ public ServiceCall getKeyAsync(String keyIdentifier, final ServiceCal KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.getKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); } - + /** * Retrieves the public portion of a key plus its attributes. * @@ -369,7 +373,7 @@ public ServiceCall getKeyAsync(String keyIdentifier, final ServiceCal * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getKey(String vaultBaseUrl, String keyName) + public ServiceResponse getKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, ""); } @@ -385,7 +389,7 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyName) public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getKeyAsync(vaultBaseUrl, keyName, "", serviceCallback); } - + /** * Retrieves the public portion of a key plus its attributes. * @@ -397,7 +401,7 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, f * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) + public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, keyVersion); } @@ -425,7 +429,7 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) + public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName); } @@ -452,7 +456,7 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) + public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName, maxresults); } @@ -479,7 +483,7 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeys(final String vaultBaseUrl) + public ServiceResponse> getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeys(vaultBaseUrl); } @@ -504,7 +508,7 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) + public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeys(vaultBaseUrl, maxresults); } @@ -531,7 +535,7 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final * @throws IllegalArgumentException exception thrown from invalid parameters * @return the BackupKeyResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse backupKey(String vaultBaseUrl, String keyName) + public ServiceResponse backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.backupKey(vaultBaseUrl, keyName); } @@ -558,7 +562,7 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String k * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) + public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.restoreKey(vaultBaseUrl, keyBundleBackup); } @@ -586,7 +590,7 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse encrypt(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse encrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -601,7 +605,7 @@ public ServiceResponse encrypt(String keyIdentifier, String * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall encryptAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall encryptAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encryptAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -617,7 +621,7 @@ public ServiceCall encryptAsync(String keyIdentifier, String * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse decrypt(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse decrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -629,10 +633,10 @@ public ServiceResponse decrypt(String keyIdentifier, String * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier * @param value the content to be decrypted - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall decryptAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall decryptAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decryptAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -648,7 +652,7 @@ public ServiceCall decryptAsync(String keyIdentifier, String * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse sign(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse sign(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.sign(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -663,9 +667,9 @@ public ServiceResponse sign(String keyIdentifier, String alg * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall signAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall signAsync(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.signAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); + return innerKeyVaultClient.signAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } /** @@ -680,7 +684,7 @@ public ServiceCall signAsync(String keyIdentifier, String al * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse verify(String keyIdentifier, String algorithm, byte[] digest, byte[] signature) + public ServiceResponse verify(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verify(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature); @@ -696,7 +700,7 @@ public ServiceResponse verify(String keyIdentifier, String algo * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall verifyAsync(String keyIdentifier, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { + public ServiceCall verifyAsync(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verifyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature, serviceCallback); } @@ -712,7 +716,7 @@ public ServiceCall verifyAsync(String keyIdentifier, String alg * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse wrapKey(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse wrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -727,7 +731,7 @@ public ServiceResponse wrapKey(String keyIdentifier, String * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall wrapKeyAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall wrapKeyAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -743,7 +747,7 @@ public ServiceCall wrapKeyAsync(String keyIdentifier, String * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse unwrapKey(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse unwrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -758,7 +762,7 @@ public ServiceResponse unwrapKey(String keyIdentifier, Strin * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall unwrapKeyAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall unwrapKeyAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -767,20 +771,20 @@ public ServiceCall unwrapKeyAsync(String keyIdentifier, Stri * Sets a secret in the specified vault. * * @param setSecretRequest the grouped properties for setting a secret request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setSecret(SetSecretRequest setSecretRequest) + public ServiceResponse setSecret(SetSecretRequest setSecretRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setSecret( - setSecretRequest.vaultBaseUrl(), - setSecretRequest.secretName(), - setSecretRequest.value(), - setSecretRequest.tags(), - setSecretRequest.contentType(), + setSecretRequest.vaultBaseUrl(), + setSecretRequest.secretName(), + setSecretRequest.value(), + setSecretRequest.tags(), + setSecretRequest.contentType(), setSecretRequest.secretAttributes()); } @@ -788,17 +792,17 @@ public ServiceResponse setSecret(SetSecretRequest setSecretRequest * Sets a secret in the specified vault. * * @param setSecretRequest the grouped properties for setting a secret request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(SetSecretRequest setSecretRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.setSecretAsync( - setSecretRequest.vaultBaseUrl(), - setSecretRequest.secretName(), - setSecretRequest.value(), - setSecretRequest.tags(), - setSecretRequest.contentType(), + setSecretRequest.vaultBaseUrl(), + setSecretRequest.secretName(), + setSecretRequest.value(), + setSecretRequest.tags(), + setSecretRequest.contentType(), setSecretRequest.secretAttributes(), serviceCallback); } @@ -813,7 +817,7 @@ public ServiceCall setSecretAsync(SetSecretRequest setSecretReques * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) + public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteSecret(vaultBaseUrl, secretName); } @@ -834,19 +838,19 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String s * Updates the attributes associated with the specified secret. * * @param updateSecretRequest the grouped properties for updating a secret request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateSecret(UpdateSecretRequest updateSecretRequest) + public ServiceResponse updateSecret(UpdateSecretRequest updateSecretRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateSecret( - updateSecretRequest.vaultBaseUrl(), - updateSecretRequest.secretName(), + updateSecretRequest.vaultBaseUrl(), + updateSecretRequest.secretName(), updateSecretRequest.secretVersion(), - updateSecretRequest.contentType(), + updateSecretRequest.contentType(), updateSecretRequest.secretAttributes(), updateSecretRequest.tags()); } @@ -855,18 +859,18 @@ public ServiceResponse updateSecret(UpdateSecretRequest updateSecr * Updates the attributes associated with the specified secret. * * @param updateSecretRequest the grouped properties for updating a secret request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(UpdateSecretRequest updateSecretRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateSecretAsync( - updateSecretRequest.vaultBaseUrl(), - updateSecretRequest.secretName(), + updateSecretRequest.vaultBaseUrl(), + updateSecretRequest.secretName(), updateSecretRequest.secretVersion(), - updateSecretRequest.contentType(), + updateSecretRequest.contentType(), updateSecretRequest.secretAttributes(), - updateSecretRequest.tags(), + updateSecretRequest.tags(), serviceCallback); } @@ -879,8 +883,8 @@ public ServiceCall updateSecretAsync(UpdateSecretRequest updateSec * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getSecret(String secretIdentifier) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getSecret(String secretIdentifier) + throws KeyVaultErrorException, IOException, IllegalArgumentException { SecretIdentifier id = new SecretIdentifier(secretIdentifier); return innerKeyVaultClient.getSecret(id.vault, id.name, id.version == null ? "" : id.version); } @@ -907,8 +911,8 @@ public ServiceCall getSecretAsync(String secretIdentifier, final S * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getSecret(String vaultBaseUrl, String secretName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getSecret(String vaultBaseUrl, String secretName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, ""); } @@ -923,7 +927,7 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getSecretAsync(vaultBaseUrl, secretName, "", serviceCallback); } - + /** * Gets a secret. * @@ -935,8 +939,8 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getSecret(String vaultBaseUrl, String secretName, String secretVersion) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getSecret(String vaultBaseUrl, String secretName, String secretVersion) + throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, secretVersion == null ? "" : secretVersion); } @@ -962,7 +966,7 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecrets(final String vaultBaseUrl) + public ServiceResponse> getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecrets(vaultBaseUrl); } @@ -1014,7 +1018,7 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName) + public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName); } @@ -1041,7 +1045,7 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) + public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName, maxresults); } @@ -1120,7 +1124,7 @@ public ServiceCall> getCertificatesAsync(final String vaul * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) + public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificate(vaultBaseUrl, certificateName); } @@ -1147,7 +1151,7 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Contacts object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setCertificateContacts(String vaultBaseUrl, Contacts contacts) + public ServiceResponse setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setCertificateContacts(vaultBaseUrl, contacts); } @@ -1173,7 +1177,7 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Co * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Contacts object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificateContacts(String vaultBaseUrl) + public ServiceResponse getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateContacts(vaultBaseUrl); } @@ -1198,7 +1202,7 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, fi * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Contacts object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) + public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificateContacts(vaultBaseUrl); } @@ -1223,7 +1227,7 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl) + public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl); } @@ -1248,7 +1252,7 @@ public ServiceCall> getCertificateIssuersAsync(final * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) + public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl, maxresults); } @@ -1269,17 +1273,17 @@ public ServiceCall> getCertificateIssuersAsync(final * Sets the certificate contacts for the specified vault. * * @param setCertificateIssuerRequest the grouped properties for setting a certificate issuer request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest) + public ServiceResponse setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setCertificateIssuer( - setCertificateIssuerRequest.vaultBaseUrl(), - setCertificateIssuerRequest.issuerName(), + setCertificateIssuerRequest.vaultBaseUrl(), + setCertificateIssuerRequest.issuerName(), setCertificateIssuerRequest.issuer()); } @@ -1287,15 +1291,15 @@ public ServiceResponse setCertificateIssuer(SetCertificateIssuerRe * Sets the certificate contacts for the specified vault. * * @param setCertificateIssuerRequest the grouped properties for setting a certificate issuer request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerRequest setCertificateIssuerRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.setCertificateIssuerAsync( - setCertificateIssuerRequest.vaultBaseUrl(), - setCertificateIssuerRequest.issuerName(), - setCertificateIssuerRequest.issuer(), + setCertificateIssuerRequest.vaultBaseUrl(), + setCertificateIssuerRequest.issuerName(), + setCertificateIssuerRequest.issuer(), serviceCallback); } @@ -1303,7 +1307,7 @@ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerR * Updates the specified certificate issuer. * * @param updateCertificateIssuerRequest the grouped properties for updating a certificate issuer request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -1312,8 +1316,8 @@ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerR public ServiceResponse updateCertificateIssuer(UpdateCertificateIssuerRequest updateCertificateIssuerRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificateIssuer( - updateCertificateIssuerRequest.vaultBaseUrl(), - updateCertificateIssuerRequest.issuerName(), + updateCertificateIssuerRequest.vaultBaseUrl(), + updateCertificateIssuerRequest.issuerName(), updateCertificateIssuerRequest.issuer()); } @@ -1321,15 +1325,15 @@ public ServiceResponse updateCertificateIssuer(UpdateCertificateIs * Updates the specified certificate issuer. * * @param updateCertificateIssuerRequest the grouped properties for updating a certificate issuer request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateIssuerAsync(UpdateCertificateIssuerRequest updateCertificateIssuerRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateIssuerAsync( - updateCertificateIssuerRequest.vaultBaseUrl(), - updateCertificateIssuerRequest.issuerName(), + updateCertificateIssuerRequest.vaultBaseUrl(), + updateCertificateIssuerRequest.issuerName(), updateCertificateIssuerRequest.issuer(), serviceCallback); } @@ -1344,7 +1348,7 @@ public ServiceCall updateCertificateIssuerAsync(UpdateCertificateI * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificateIssuer(String vaultBaseUrl, String issuerName) + public ServiceResponse getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuer(vaultBaseUrl, issuerName); } @@ -1358,7 +1362,7 @@ public ServiceResponse getCertificateIssuer(String vaultBaseUrl, S * @return the {@link ServiceCall} object */ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.getCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); + return innerKeyVaultClient.getCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); } /** @@ -1371,7 +1375,7 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl, String issuerName) + public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificateIssuer(vaultBaseUrl, issuerName); } @@ -1392,19 +1396,19 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUr * Creates a new certificate version. If this is the first version, the certificate resource is created. * * @param createCertificateRequest the grouped properties for creating a certificate request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createCertificate(CreateCertificateRequest createCertificateRequest) + public ServiceResponse createCertificate(CreateCertificateRequest createCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.createCertificate( - createCertificateRequest.vaultBaseUrl(), - createCertificateRequest.certificateName(), - createCertificateRequest.certificatePolicy(), - createCertificateRequest.certificateAttributes(), + createCertificateRequest.vaultBaseUrl(), + createCertificateRequest.certificateName(), + createCertificateRequest.certificatePolicy(), + createCertificateRequest.certificateAttributes(), createCertificateRequest.tags()); } @@ -1412,17 +1416,17 @@ public ServiceResponse createCertificate(CreateCertificate * Creates a new certificate version. If this is the first version, the certificate resource is created. * * @param createCertificateRequest the grouped properties for creating a certificate request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(CreateCertificateRequest createCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.createCertificateAsync( - createCertificateRequest.vaultBaseUrl(), - createCertificateRequest.certificateName(), - createCertificateRequest.certificatePolicy(), - createCertificateRequest.certificateAttributes(), - createCertificateRequest.tags(), + createCertificateRequest.vaultBaseUrl(), + createCertificateRequest.certificateName(), + createCertificateRequest.certificatePolicy(), + createCertificateRequest.certificateAttributes(), + createCertificateRequest.tags(), serviceCallback); } @@ -1430,21 +1434,21 @@ public ServiceCall createCertificateAsync(CreateCertificat * Imports a certificate into the specified vault. * * @param importCertificateRequest the grouped properties for importing a certificate request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse importCertificate(ImportCertificateRequest importCertificateRequest) + public ServiceResponse importCertificate(ImportCertificateRequest importCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.importCertificate( - importCertificateRequest.vaultBaseUrl(), - importCertificateRequest.certificateName(), + importCertificateRequest.vaultBaseUrl(), + importCertificateRequest.certificateName(), importCertificateRequest.base64EncodedCertificate(), - importCertificateRequest.password(), - importCertificateRequest.certificatePolicy(), - importCertificateRequest.certificateAttributes(), + importCertificateRequest.password(), + importCertificateRequest.certificatePolicy(), + importCertificateRequest.certificateAttributes(), importCertificateRequest.tags()); } @@ -1452,22 +1456,22 @@ public ServiceResponse importCertificate(ImportCertificateReq * Imports a certificate into the specified vault. * * @param importCertificateRequest the grouped properties for importing a certificate request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall importCertificateAsync(ImportCertificateRequest importCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.importCertificateAsync( - importCertificateRequest.vaultBaseUrl(), - importCertificateRequest.certificateName(), - importCertificateRequest.base64EncodedCertificate(), - importCertificateRequest.password(), - importCertificateRequest.certificatePolicy(), - importCertificateRequest.certificateAttributes(), - importCertificateRequest.tags(), + importCertificateRequest.vaultBaseUrl(), + importCertificateRequest.certificateName(), + importCertificateRequest.base64EncodedCertificate(), + importCertificateRequest.password(), + importCertificateRequest.certificatePolicy(), + importCertificateRequest.certificateAttributes(), + importCertificateRequest.tags(), serviceCallback); } - + /** * List the versions of a certificate. * @@ -1478,7 +1482,7 @@ public ServiceCall importCertificateAsync(ImportCertificateRe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName) + public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName); } @@ -1492,7 +1496,7 @@ public ServiceResponse> getCertificateVersions(final * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback); + return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback); } /** * List the versions of a certificate. @@ -1533,7 +1537,7 @@ public ServiceCall> getCertificateVersionsAsync(final Stri * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) + public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificatePolicy(vaultBaseUrl, certificateName); } @@ -1554,17 +1558,17 @@ public ServiceCall getCertificatePolicyAsync(String vaultBase * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. * * @param updateCertificatePolicyRequest the grouped properties for updating a certificate policy request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest) + public ServiceResponse updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificatePolicy( - updateCertificatePolicyRequest.vaultBaseUrl(), - updateCertificatePolicyRequest.certificateName(), + updateCertificatePolicyRequest.vaultBaseUrl(), + updateCertificatePolicyRequest.certificateName(), updateCertificatePolicyRequest.certificatePolicy()); } @@ -1572,15 +1576,15 @@ public ServiceResponse updateCertificatePolicy(UpdateCertific * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. * * @param updateCertificatePolicyRequest the grouped properties for updating a certificate policy request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificatePolicyAsync( - updateCertificatePolicyRequest.vaultBaseUrl(), - updateCertificatePolicyRequest.certificateName(), - updateCertificatePolicyRequest.certificatePolicy(), + updateCertificatePolicyRequest.vaultBaseUrl(), + updateCertificatePolicyRequest.certificateName(), + updateCertificatePolicyRequest.certificatePolicy(), serviceCallback); } @@ -1588,19 +1592,19 @@ public ServiceCall updateCertificatePolicy(UpdateCertificateP * Updates the attributes associated with the specified certificate. * * @param updateCertificateRequest the grouped properties for updating a certificate request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificate(UpdateCertificateRequest updateCertificateRequest) + public ServiceResponse updateCertificate(UpdateCertificateRequest updateCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificate( - updateCertificateRequest.vaultBaseUrl(), - updateCertificateRequest.certificateName(), - updateCertificateRequest.certificateVersion(), - updateCertificateRequest.certificateAttributes(), + updateCertificateRequest.vaultBaseUrl(), + updateCertificateRequest.certificateName(), + updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificateAttributes(), updateCertificateRequest.tags()); } @@ -1608,20 +1612,20 @@ public ServiceResponse updateCertificate(UpdateCertificateReq * Updates the attributes associated with the specified certificate. * * @param updateCertificateRequest the grouped properties for updating a certificate request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(UpdateCertificateRequest updateCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateAsync( - updateCertificateRequest.vaultBaseUrl(), - updateCertificateRequest.certificateName(), - updateCertificateRequest.certificateVersion(), - updateCertificateRequest.certificateAttributes(), - updateCertificateRequest.tags(), + updateCertificateRequest.vaultBaseUrl(), + updateCertificateRequest.certificateName(), + updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificateAttributes(), + updateCertificateRequest.tags(), serviceCallback); } - + /** * Gets a Certificate. * @@ -1631,9 +1635,9 @@ public ServiceCall updateCertificateAsync(UpdateCertificateRe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificate(String certificateIdentifier) + public ServiceResponse getCertificate(String certificateIdentifier) throws KeyVaultErrorException, IOException, IllegalArgumentException { - CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); + CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); return innerKeyVaultClient.getCertificate(id.vault, id.name, id.version == null ? "" : id.version); } @@ -1648,7 +1652,7 @@ public ServiceCall getCertificateAsync(String certificateIden CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); return innerKeyVaultClient.getCertificateAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); } - + /** * Gets a Certificate. * @@ -1659,7 +1663,7 @@ public ServiceCall getCertificateAsync(String certificateIden * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName) + public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, ""); } @@ -1675,7 +1679,7 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificateAsync(vaultBaseUrl, certificateName, "", serviceCallback); } - + /** * Gets a Certificate. * @@ -1687,7 +1691,7 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) + public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, certificateVersion); } @@ -1707,19 +1711,19 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S /** * Updates a certificate operation. - * + * * @param updateCertificateOperationRequest the grouped properties for updating a certificate operation request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest) + public ServiceResponse updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificateOperation( - updateCertificateOperationRequest.vaultBaseUrl(), - updateCertificateOperationRequest.certificateName(), + updateCertificateOperationRequest.vaultBaseUrl(), + updateCertificateOperationRequest.certificateName(), updateCertificateOperationRequest.certificateOperation()); } @@ -1727,14 +1731,14 @@ public ServiceResponse updateCertificateOperation(UpdateCe * Updates a certificate operation. * * @param updateCertificateOperationRequest the grouped properties for updating a certificate operation request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateOperationAsync(UpdateCertificateOperationRequest updateCertificateOperationRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateOperationAsync( - updateCertificateOperationRequest.vaultBaseUrl(), - updateCertificateOperationRequest.certificateName(), + updateCertificateOperationRequest.vaultBaseUrl(), + updateCertificateOperationRequest.certificateName(), updateCertificateOperationRequest.certificateOperation(), serviceCallback); } @@ -1749,7 +1753,7 @@ public ServiceCall updateCertificateOperationAsync(UpdateC * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) + public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateOperation(vaultBaseUrl, certificateName); } @@ -1776,7 +1780,7 @@ public ServiceCall getCertificateOperationAsync(String vau * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) + public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificateOperation(vaultBaseUrl, certificateName); } @@ -1797,19 +1801,19 @@ ServiceCall deleteCertificateOperationAsync(String vaultBa * Merges a certificate or a certificate chain with a key pair existing on the server. * * @param mergeCertificateRequest the grouped properties for merging a certificate request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse mergeCertificate(MergeCertificateRequest mergeCertificateRequest) + public ServiceResponse mergeCertificate(MergeCertificateRequest mergeCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.mergeCertificate( - mergeCertificateRequest.vaultBaseUrl(), - mergeCertificateRequest.certificateName(), - mergeCertificateRequest.x509Certificates(), - mergeCertificateRequest.certificateAttributes(), + mergeCertificateRequest.vaultBaseUrl(), + mergeCertificateRequest.certificateName(), + mergeCertificateRequest.x509Certificates(), + mergeCertificateRequest.certificateAttributes(), mergeCertificateRequest.tags()); } @@ -1817,17 +1821,17 @@ public ServiceResponse mergeCertificate(MergeCertificateReque * Merges a certificate or a certificate chain with a key pair existing on the server. * * @param mergeCertificateRequest the grouped properties for merging a certificate request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(MergeCertificateRequest mergeCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.mergeCertificateAsync( - mergeCertificateRequest.vaultBaseUrl(), - mergeCertificateRequest.certificateName(), - mergeCertificateRequest.x509Certificates(), - mergeCertificateRequest.certificateAttributes(), - mergeCertificateRequest.tags(), + mergeCertificateRequest.vaultBaseUrl(), + mergeCertificateRequest.certificateName(), + mergeCertificateRequest.x509Certificates(), + mergeCertificateRequest.certificateAttributes(), + mergeCertificateRequest.tags(), serviceCallback); } @@ -1842,21 +1846,9 @@ public ServiceCall mergeCertificateAsync(MergeCertificateRequ * @throws IllegalArgumentException exception thrown from invalid parameters * @return the String object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) + public ServiceResponse getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - Response response = call.execute(); - return new ServiceResponse(response.body().string(), response); + return getPendingCertificateSigningRequestAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -1868,9 +1860,10 @@ public ServiceResponse getPendingCertificateSigningRequest(String vaultB * @return the {@link ServiceCall} object */ public ServiceCall getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } + return ServiceCall.create(getPendingCertificateSigningRequestAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + private Observable> getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1881,27 +1874,20 @@ public ServiceCall getPendingCertificateSigningRequestAsync(String vault throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - if (serviceCallback != null) { - serviceCallback.success(new ServiceResponse(response.body().string(), response)); - } - serviceCall.success(new ServiceResponse(response.body().string(), response)); - } catch (IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = new ServiceResponse<>(response.body().string(), response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } } - serviceCall.failure(exception); - } - } - }); - return serviceCall; + }); } - + /** * List the versions of the specified key. * @@ -1911,7 +1897,7 @@ public void onResponse(Call call, Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersionsNext(final String nextPageLink) + public ServiceResponse> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersionsNext(nextPageLink); } @@ -1937,7 +1923,7 @@ public ServiceCall> getKeyVersionsNextAsync(final String nextPageL * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeysNext(final String nextPageLink) + public ServiceResponse> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeysNext(nextPageLink); } @@ -1963,7 +1949,7 @@ public ServiceCall> getKeysNextAsync(final String nextPageLink, fi * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretsNext(final String nextPageLink) + public ServiceResponse> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretsNext(nextPageLink); } @@ -1989,7 +1975,7 @@ public ServiceCall> getSecretsNextAsync(final String nextPageLi * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretVersionsNext(final String nextPageLink) + public ServiceResponse> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersionsNext(nextPageLink); } @@ -2015,7 +2001,7 @@ public ServiceCall> getSecretVersionsNextAsync(final String nex * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificatesNext(final String nextPageLink) + public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificatesNext(nextPageLink); } @@ -2041,7 +2027,7 @@ public ServiceCall> getCertificatesNextAsync(final String * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) + public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuersNext(nextPageLink); } @@ -2067,7 +2053,7 @@ public ServiceCall> getCertificateIssuersNextAsync(f * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) + public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateVersionsNext(nextPageLink); } @@ -2084,4 +2070,4 @@ public ServiceCall> getCertificateVersionsNextAsync(final return innerKeyVaultClient.getCertificateVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); } -} +} \ No newline at end of file diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 5d3610adf8074..86290ba76c513 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -1,7 +1,9 @@ /** - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault; @@ -9,6 +11,7 @@ import com.google.common.base.Joiner; import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceCall; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.AzureServiceResponseBuilder; import com.microsoft.azure.keyvault.models.BackupKeyResult; @@ -25,6 +28,10 @@ import com.microsoft.azure.keyvault.models.Contacts; import com.microsoft.azure.keyvault.models.IssuerBundle; import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.models.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.models.JsonWebKeyOperation; +import com.microsoft.azure.keyvault.models.JsonWebKeySignatureAlgorithm; +import com.microsoft.azure.keyvault.models.JsonWebKeyType; import com.microsoft.azure.keyvault.models.KeyAttributes; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyCreateParameters; @@ -49,16 +56,15 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.RestClient; import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.ServiceResponseCallback; import com.microsoft.rest.Validator; import java.io.IOException; import java.util.List; import java.util.Map; import okhttp3.ResponseBody; -import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.GET; import retrofit2.http.Header; @@ -69,13 +75,14 @@ import retrofit2.http.POST; import retrofit2.http.PUT; import retrofit2.http.Query; -import retrofit2.http.Url; import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; /** * Initializes a new instance of the KeyVaultClientImpl class. */ -final class KeyVaultClientImpl extends AzureServiceClient { +public final class KeyVaultClientImpl extends AzureServiceClient implements KeyVaultClient { /** The Retrofit service to perform REST calls. */ private KeyVaultClientService service; /** the {@link AzureClient} used for long running operations. */ @@ -175,7 +182,7 @@ public KeyVaultClientImpl withGenerateClientRequestId(boolean generateClientRequ * * @param credentials the management credentials for Azure */ - KeyVaultClientImpl(ServiceClientCredentials credentials) { + public KeyVaultClientImpl(ServiceClientCredentials credentials) { this("https://{vaultBaseUrl}", credentials); } @@ -197,7 +204,7 @@ private KeyVaultClientImpl(String baseUrl, ServiceClientCredentials credentials) * * @param restClient the REST client to connect to Azure. */ - KeyVaultClientImpl(RestClient restClient) { + public KeyVaultClientImpl(RestClient restClient) { super(restClient); initialize(); } @@ -234,199 +241,199 @@ private void initializeService() { interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/create") - Call createKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> createKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("keys/{key-name}") - Call importKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> importKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "keys/{key-name}", method = "DELETE", hasBody = true) - Call deleteKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("keys/{key-name}/{key-version}") - Call updateKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys/{key-name}/{key-version}") - Call getKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys/{key-name}/versions") - Call getKeyVersions(@Path("key-name") String keyName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getKeyVersions(@Path("key-name") String keyName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys") - Call getKeys(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getKeys(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/backup") - Call backupKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> backupKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/restore") - Call restoreKey(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyRestoreParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> restoreKey(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyRestoreParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/encrypt") - Call encrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> encrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/decrypt") - Call decrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> decrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/sign") - Call sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeySignParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeySignParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/verify") - Call verify(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyVerifyParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> verify(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyVerifyParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/wrapkey") - Call wrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> wrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/unwrapkey") - Call unwrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> unwrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("secrets/{secret-name}") - Call setSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretSetParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> setSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretSetParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "secrets/{secret-name}", method = "DELETE", hasBody = true) - Call deleteSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("secrets/{secret-name}/{secret-version}") - Call updateSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets/{secret-name}/{secret-version}") - Call getSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets") - Call getSecrets(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getSecrets(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets/{secret-name}/versions") - Call getSecretVersions(@Path("secret-name") String secretName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getSecretVersions(@Path("secret-name") String secretName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates") - Call getCertificates(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificates(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/{certificate-name}", method = "DELETE", hasBody = true) - Call deleteCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/contacts") - Call setCertificateContacts(@Body Contacts contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> setCertificateContacts(@Body Contacts contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/contacts") - Call getCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/contacts", method = "DELETE", hasBody = true) - Call deleteCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers") - Call getCertificateIssuers(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateIssuers(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/issuers/{issuer-name}") - Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> setCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/issuers/{issuer-name}") - Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers/{issuer-name}") - Call getCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/issuers/{issuer-name}", method = "DELETE", hasBody = true) - Call deleteCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/create") - Call createCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> createCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/import") - Call importCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> importCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/versions") - Call getCertificateVersions(@Path("certificate-name") String certificateName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateVersions(@Path("certificate-name") String certificateName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/policy") - Call getCertificatePolicy(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificatePolicy(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/policy") - Call updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicy certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicy certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/{certificate-version}") - Call updateCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/{certificate-version}") - Call getCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/pending") - Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Body CertificateOperation certificateOperation, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateCertificateOperation(@Path("certificate-name") String certificateName, @Body CertificateOperation certificateOperation, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/pending") - Call getCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/{certificate-name}/pending", method = "DELETE", hasBody = true) - Call deleteCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/pending/merge") - Call mergeCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateMergeParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> mergeCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateMergeParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET - Call getKeyVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET("{nextLink}") + Observable> getKeyVersionsNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET - Call getKeysNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET("{nextLink}") + Observable> getKeysNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET - Call getSecretsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET("{nextLink}") + Observable> getSecretsNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET - Call getSecretVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET("{nextLink}") + Observable> getSecretVersionsNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET - Call getCertificatesNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET("{nextLink}") + Observable> getCertificatesNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET - Call getCertificateIssuersNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET("{nextLink}") + Observable> getCertificateIssuersNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET - Call getCertificateVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET("{nextLink}") + Observable> getCertificateVersionsNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); } @@ -435,38 +442,14 @@ interface KeyVaultClientService { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (kty == null) { - throw new IllegalArgumentException("Parameter kty is required and cannot be null."); - } - final Integer keySize = null; - final List keyOps = null; - final KeyAttributes keyAttributes = null; - final Map tags = null; - KeyCreateParameters parameters = new KeyCreateParameters(); - parameters.withKty(kty); - parameters.withKeySize(null); - parameters.withKeyOps(null); - parameters.withKeyAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return createKeyDelegate(call.execute()); + public ServiceResponse createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createKeyAsync(vaultBaseUrl, keyName, kty).toBlocking().single(); } /** @@ -474,11 +457,23 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, final ServiceCallback serviceCallback) { + return ServiceCall.create(createKeyAsync(vaultBaseUrl, keyName, kty), serviceCallback); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @return the observable to the KeyBundle object */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, final ServiceCallback serviceCallback) { + public Observable> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -492,7 +487,7 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName throw new IllegalArgumentException("Parameter kty is required and cannot be null."); } final Integer keySize = null; - final List keyOps = null; + final List keyOps = null; final KeyAttributes keyAttributes = null; final Map tags = null; KeyCreateParameters parameters = new KeyCreateParameters(); @@ -502,26 +497,18 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = createKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -529,9 +516,9 @@ public void onResponse(Call call, Response response) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param keySize The key size in bytes. e.g. 1024 or 2048. - * @param keyOps the List<String> value + * @param keyOps the List<JsonWebKeyOperation> value * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call @@ -539,31 +526,8 @@ public void onResponse(Call call, Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (kty == null) { - throw new IllegalArgumentException("Parameter kty is required and cannot be null."); - } - Validator.validate(keyOps); - Validator.validate(keyAttributes); - Validator.validate(tags); - KeyCreateParameters parameters = new KeyCreateParameters(); - parameters.withKty(kty); - parameters.withKeySize(keySize); - parameters.withKeyOps(keyOps); - parameters.withKeyAttributes(keyAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return createKeyDelegate(call.execute()); + public ServiceResponse createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createKeyAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).toBlocking().single(); } /** @@ -571,15 +535,31 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param keySize The key size in bytes. e.g. 1024 or 2048. - * @param keyOps the List<String> value + * @param keyOps the List<JsonWebKeyOperation> value * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(createKeyAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags), serviceCallback); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param keySize The key size in bytes. e.g. 1024 or 2048. + * @param keyOps the List<JsonWebKeyOperation> value + * @param keyAttributes the KeyAttributes value + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + public Observable> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -602,26 +582,18 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = createKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse createKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -643,30 +615,7 @@ private ServiceResponse createKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (key == null) { - throw new IllegalArgumentException("Parameter key is required and cannot be null."); - } - Validator.validate(key); - final Boolean hsm = null; - final KeyAttributes keyAttributes = null; - final Map tags = null; - KeyImportParameters parameters = new KeyImportParameters(); - parameters.withHsm(null); - parameters.withKey(key); - parameters.withKeyAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return importKeyDelegate(call.execute()); + return importKeyAsync(vaultBaseUrl, keyName, key).toBlocking().single(); } /** @@ -676,9 +625,21 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param key The Json web key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, final ServiceCallback serviceCallback) { + return ServiceCall.create(importKeyAsync(vaultBaseUrl, keyName, key), serviceCallback); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @return the observable to the KeyBundle object + */ + public Observable> importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -701,26 +662,18 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = importKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = importKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -738,29 +691,7 @@ public void onResponse(Call call, Response response) * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (key == null) { - throw new IllegalArgumentException("Parameter key is required and cannot be null."); - } - Validator.validate(key); - Validator.validate(keyAttributes); - Validator.validate(tags); - KeyImportParameters parameters = new KeyImportParameters(); - parameters.withHsm(hsm); - parameters.withKey(key); - parameters.withKeyAttributes(keyAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return importKeyDelegate(call.execute()); + return importKeyAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).toBlocking().single(); } /** @@ -773,9 +704,24 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @param keyAttributes The key management attributes * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(importKeyAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags), serviceCallback); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @param hsm Whether to import as a hardware key (HSM) or software key + * @param keyAttributes The key management attributes + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object + */ + public Observable> importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -797,26 +743,18 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = importKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = importKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse importKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -837,18 +775,7 @@ private ServiceResponse importKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteKeyDelegate(call.execute()); + return deleteKeyAsync(vaultBaseUrl, keyName).toBlocking().single(); } /** @@ -857,9 +784,20 @@ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteKeyAsync(vaultBaseUrl, keyName), serviceCallback); + } + + /** + * Deletes the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the KeyBundle object + */ + public Observable> deleteKeyAsync(String vaultBaseUrl, String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -870,26 +808,18 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -911,28 +841,7 @@ private ServiceResponse deleteKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final List keyOps = null; - final KeyAttributes keyAttributes = null; - final Map tags = null; - KeyUpdateParameters parameters = new KeyUpdateParameters(); - parameters.withKeyOps(null); - parameters.withKeyAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateKeyDelegate(call.execute()); + return updateKeyAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single(); } /** @@ -942,9 +851,21 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param keyVersion The version of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateKeyAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @return the observable to the KeyBundle object + */ + public Observable> updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -957,7 +878,7 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - final List keyOps = null; + final List keyOps = null; final KeyAttributes keyAttributes = null; final Map tags = null; KeyUpdateParameters parameters = new KeyUpdateParameters(); @@ -965,26 +886,18 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -1001,29 +914,8 @@ public void onResponse(Call call, Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(keyOps); - Validator.validate(keyAttributes); - Validator.validate(tags); - KeyUpdateParameters parameters = new KeyUpdateParameters(); - parameters.withKeyOps(keyOps); - parameters.withKeyAttributes(keyAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateKeyDelegate(call.execute()); + public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateKeyAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).toBlocking().single(); } /** @@ -1036,9 +928,24 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateKeyAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags), serviceCallback); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. + * @param keyAttributes the KeyAttributes value + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object */ - public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + public Observable> updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1059,26 +966,18 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1100,21 +999,7 @@ private ServiceResponse updateKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getKeyDelegate(call.execute()); + return getKeyAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single(); } /** @@ -1124,9 +1009,21 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyName, St * @param keyName The name of the key * @param keyVersion The version of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(getKeyAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @return the observable to the KeyBundle object + */ + public Observable> getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1140,26 +1037,18 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1180,26 +1069,14 @@ private ServiceResponse getKeyDelegate(Response respons * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeyVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getKeyVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -1208,9 +1085,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName) { + return getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1222,32 +1136,18 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeyVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeyVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -1262,25 +1162,14 @@ public void onResponse(Call call, Response response) * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeyVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getKeyVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -1290,9 +1179,48 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * @param keyName The name of the key * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param maxresults Maximum number of results to return. + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { + return getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param maxresults Maximum number of results to return. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1303,32 +1231,18 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeyVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeyVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getKeyVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1348,23 +1262,14 @@ private ServiceResponse> getKeyVersionsDelegate(Response> getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeysDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getKeysNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -1372,9 +1277,44 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeysSinglePageAsync(vaultBaseUrl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeysAsync(final String vaultBaseUrl) { + return getKeysSinglePageAsync(vaultBaseUrl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeysNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeysSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1383,32 +1323,18 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeysDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeysDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -1422,22 +1348,14 @@ public void onResponse(Call call, Response response) * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeysDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getKeysNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -1446,9 +1364,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeysSinglePageAsync(vaultBaseUrl, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeysAsync(final String vaultBaseUrl, final Integer maxresults) { + return getKeysSinglePageAsync(vaultBaseUrl, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeysNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeysSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1456,32 +1411,18 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeysDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeysDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getKeysDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1502,18 +1443,7 @@ private ServiceResponse> getKeysDelegate(Response backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return backupKeyDelegate(call.execute()); + return backupKeyAsync(vaultBaseUrl, keyName).toBlocking().single(); } /** @@ -1522,9 +1452,20 @@ public ServiceResponse backupKey(String vaultBaseUrl, String ke * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { + return ServiceCall.create(backupKeyAsync(vaultBaseUrl, keyName), serviceCallback); + } + + /** + * Requests that a backup of the specified key be downloaded to the client. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the BackupKeyResult object + */ + public Observable> backupKeyAsync(String vaultBaseUrl, String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1535,26 +1476,18 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String k throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = backupKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = backupKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse backupKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1575,20 +1508,7 @@ private ServiceResponse backupKeyDelegate(Response restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (keyBundleBackup == null) { - throw new IllegalArgumentException("Parameter keyBundleBackup is required and cannot be null."); - } - KeyRestoreParameters parameters = new KeyRestoreParameters(); - parameters.withKeyBundleBackup(keyBundleBackup); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return restoreKeyDelegate(call.execute()); + return restoreKeyAsync(vaultBaseUrl, keyBundleBackup).toBlocking().single(); } /** @@ -1597,9 +1517,20 @@ public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBund * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyBundleBackup the backup blob associated with a key bundle * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { + return ServiceCall.create(restoreKeyAsync(vaultBaseUrl, keyBundleBackup), serviceCallback); + } + + /** + * Restores the backup key in to a vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyBundleBackup the backup blob associated with a key bundle + * @return the observable to the KeyBundle object + */ + public Observable> restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1612,26 +1543,18 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun KeyRestoreParameters parameters = new KeyRestoreParameters(); parameters.withKeyBundleBackup(keyBundleBackup); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = restoreKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = restoreKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse restoreKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1647,38 +1570,15 @@ private ServiceResponse restoreKeyDelegate(Response res * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse encrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return encryptDelegate(call.execute()); + public ServiceResponse encrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return encryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); } /** @@ -1687,12 +1587,26 @@ public ServiceResponse encrypt(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(encryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object */ - public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public Observable> encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1715,26 +1629,18 @@ public ServiceCall encryptAsync(String vaultBaseUrl, String parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = encryptDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = encryptDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse encryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1750,38 +1656,15 @@ private ServiceResponse encryptDelegate(Response decrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return decryptDelegate(call.execute()); + public ServiceResponse decrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return decryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); } /** @@ -1790,12 +1673,26 @@ public ServiceResponse decrypt(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(decryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Decrypts a single block of encrypted data. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object */ - public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public Observable> decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1818,26 +1715,18 @@ public ServiceCall decryptAsync(String vaultBaseUrl, String parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = decryptDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = decryptDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse decryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1853,14 +1742,43 @@ private ServiceResponse decryptDelegate(Response sign(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse sign(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return signAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + } + + /** + * Creates a signature from a digest using the specified key in the vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param value the Base64Url value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(signAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Creates a signature from a digest using the specified key in the vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1883,64 +1801,18 @@ public ServiceResponse sign(String vaultBaseUrl, String keyN parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return signDelegate(call.execute()); - } - - /** - * Creates a signature from a digest using the specified key in the vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. - * @param value the Base64Url value - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object - */ - public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeySignParameters parameters = new KeySignParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = signDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); - } - } - }); - return serviceCall; + return service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = signDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); } private ServiceResponse signDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1956,7 +1828,7 @@ private ServiceResponse signDelegate(Response * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param digest The digest used for signing * @param signature The signature to be verified * @throws KeyVaultErrorException exception thrown from REST call @@ -1964,35 +1836,8 @@ private ServiceResponse signDelegate(Response * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse verify(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (digest == null) { - throw new IllegalArgumentException("Parameter digest is required and cannot be null."); - } - if (signature == null) { - throw new IllegalArgumentException("Parameter signature is required and cannot be null."); - } - KeyVerifyParameters parameters = new KeyVerifyParameters(); - parameters.withAlgorithm(algorithm); - parameters.withDigest(digest); - parameters.withSignature(signature); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return verifyDelegate(call.execute()); + public ServiceResponse verify(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return verifyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).toBlocking().single(); } /** @@ -2001,13 +1846,28 @@ public ServiceResponse verify(String vaultBaseUrl, String keyNa * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param digest The digest used for signing * @param signature The signature to be verified * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { + return ServiceCall.create(verifyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature), serviceCallback); + } + + /** + * Verifies a signature using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param digest The digest used for signing + * @param signature The signature to be verified + * @return the observable to the KeyVerifyResult object */ - public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { + public Observable> verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2034,26 +1894,18 @@ public ServiceCall verifyAsync(String vaultBaseUrl, String keyN parameters.withDigest(digest); parameters.withSignature(signature); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = verifyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = verifyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse verifyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2069,38 +1921,15 @@ private ServiceResponse verifyDelegate(Response r * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse wrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return wrapKeyDelegate(call.execute()); + public ServiceResponse wrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return wrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); } /** @@ -2109,12 +1938,26 @@ public ServiceResponse wrapKey(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ - public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(wrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Wraps a symmetric key using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2137,26 +1980,18 @@ public ServiceCall wrapKeyAsync(String vaultBaseUrl, String parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = wrapKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = wrapKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse wrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2172,38 +2007,15 @@ private ServiceResponse wrapKeyDelegate(Response unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return unwrapKeyDelegate(call.execute()); + public ServiceResponse unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return unwrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); } /** @@ -2212,12 +2024,26 @@ public ServiceResponse unwrapKey(String vaultBaseUrl, String * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(unwrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object */ - public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public Observable> unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2240,26 +2066,18 @@ public ServiceCall unwrapKeyAsync(String vaultBaseUrl, Strin parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = unwrapKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = unwrapKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse unwrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2281,29 +2099,7 @@ private ServiceResponse unwrapKeyDelegate(Response setSecret(String vaultBaseUrl, String secretName, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - final Map tags = null; - final String contentType = null; - final SecretAttributes secretAttributes = null; - SecretSetParameters parameters = new SecretSetParameters(); - parameters.withValue(value); - parameters.withTags(null); - parameters.withContentType(null); - parameters.withSecretAttributes(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return setSecretDelegate(call.execute()); + return setSecretAsync(vaultBaseUrl, secretName, value).toBlocking().single(); } /** @@ -2313,9 +2109,21 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @param secretName The name of the secret in the given vault * @param value The value of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) { + return ServiceCall.create(setSecretAsync(vaultBaseUrl, secretName, value), serviceCallback); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @return the observable to the SecretBundle object + */ + public Observable> setSecretAsync(String vaultBaseUrl, String secretName, String value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2337,26 +2145,18 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secr parameters.withContentType(null); parameters.withSecretAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -2374,28 +2174,7 @@ public void onResponse(Call call, Response response) * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - Validator.validate(tags); - Validator.validate(secretAttributes); - SecretSetParameters parameters = new SecretSetParameters(); - parameters.withValue(value); - parameters.withTags(tags); - parameters.withContentType(contentType); - parameters.withSecretAttributes(secretAttributes); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return setSecretDelegate(call.execute()); + return setSecretAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).toBlocking().single(); } /** @@ -2408,9 +2187,24 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @param contentType Type of the secret value such as a password * @param secretAttributes The secret management attributes * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes, final ServiceCallback serviceCallback) { + return ServiceCall.create(setSecretAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes), serviceCallback); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @param tags Application-specific metadata in the form of key-value pairs + * @param contentType Type of the secret value such as a password + * @param secretAttributes The secret management attributes + * @return the observable to the SecretBundle object + */ + public Observable> setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2431,26 +2225,18 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secr parameters.withContentType(contentType); parameters.withSecretAttributes(secretAttributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse setSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2471,18 +2257,7 @@ private ServiceResponse setSecretDelegate(Response r * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteSecretDelegate(call.execute()); + return deleteSecretAsync(vaultBaseUrl, secretName).toBlocking().single(); } /** @@ -2491,9 +2266,20 @@ public ServiceResponse deleteSecret(String vaultBaseUrl, String se * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteSecretAsync(vaultBaseUrl, secretName), serviceCallback); + } + + /** + * Deletes a secret from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the observable to the SecretBundle object + */ + public Observable> deleteSecretAsync(String vaultBaseUrl, String secretName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2504,26 +2290,18 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String s throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2545,6 +2323,31 @@ private ServiceResponse deleteSecretDelegate(Response updateSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateSecretAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single(); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateSecretAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @return the observable to the SecretBundle object + */ + public Observable> updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2565,8 +2368,18 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se parameters.withSecretAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateSecretDelegate(call.execute()); + return service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); } /** @@ -2575,50 +2388,16 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @param contentType Type of the secret value such as a password + * @param secretAttributes The secret management attributes + * @param tags Application-specific metadata in the form of key-value pairs + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (secretVersion == null) { - throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final String contentType = null; - final SecretAttributes secretAttributes = null; - final Map tags = null; - SecretUpdateParameters parameters = new SecretUpdateParameters(); - parameters.withContentType(null); - parameters.withSecretAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); - } - } - }); - return serviceCall; + public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateSecretAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).toBlocking().single(); } /** @@ -2630,33 +2409,11 @@ public void onResponse(Call call, Response response) * @param contentType Type of the secret value such as a password * @param secretAttributes The secret management attributes * @param tags Application-specific metadata in the form of key-value pairs - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object */ - public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (secretVersion == null) { - throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(secretAttributes); - Validator.validate(tags); - SecretUpdateParameters parameters = new SecretUpdateParameters(); - parameters.withContentType(contentType); - parameters.withSecretAttributes(secretAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateSecretDelegate(call.execute()); + public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateSecretAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags), serviceCallback); } /** @@ -2668,10 +2425,9 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @param contentType Type of the secret value such as a password * @param secretAttributes The secret management attributes * @param tags Application-specific metadata in the form of key-value pairs - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the observable to the SecretBundle object */ - public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) { + public Observable> updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2691,26 +2447,18 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String s parameters.withSecretAttributes(secretAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2732,21 +2480,7 @@ private ServiceResponse updateSecretDelegate(Response getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (secretVersion == null) { - throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getSecretDelegate(call.execute()); + return getSecretAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single(); } /** @@ -2756,9 +2490,21 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(getSecretAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + } + + /** + * Gets a secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @return the observable to the SecretBundle object + */ + public Observable> getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2772,26 +2518,18 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2811,23 +2549,14 @@ private ServiceResponse getSecretDelegate(Response r * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getSecretsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -2835,9 +2564,44 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretsSinglePageAsync(vaultBaseUrl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretsAsync(final String vaultBaseUrl) { + return getSecretsSinglePageAsync(vaultBaseUrl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretsSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2846,32 +2610,18 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -2885,22 +2635,14 @@ public void onResponse(Call call, Response response) * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getSecretsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -2909,9 +2651,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of secrets to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretsSinglePageAsync(vaultBaseUrl, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of secrets to return. + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults) { + return getSecretsSinglePageAsync(vaultBaseUrl, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of secrets to return. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretsSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2919,32 +2698,18 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getSecretsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2965,26 +2730,14 @@ private ServiceResponse> getSecretsDelegate(Response> getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getSecretVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -2993,9 +2746,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName) { + return getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3007,32 +2797,18 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -3047,25 +2823,14 @@ public void onResponse(Call call, Response response) * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getSecretVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -3075,9 +2840,48 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * @param secretName The name of the secret in the given vault * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param maxresults Maximum number of results to return. + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { + return getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param maxresults Maximum number of results to return. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3088,32 +2892,18 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getSecretVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3133,23 +2923,14 @@ private ServiceResponse> getSecretVersionsDelegate(Response * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificatesDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificatesNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -3157,9 +2938,44 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificatesSinglePageAsync(vaultBaseUrl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificatesAsync(final String vaultBaseUrl) { + return getCertificatesSinglePageAsync(vaultBaseUrl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificatesSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3168,32 +2984,18 @@ public ServiceCall> getCertificatesAsync(final String vaul } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificatesDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificatesDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -3207,22 +3009,14 @@ public void onResponse(Call call, Response response) * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificatesDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificatesNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -3231,9 +3025,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificatesSinglePageAsync(vaultBaseUrl, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults) { + return getCertificatesSinglePageAsync(vaultBaseUrl, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificatesSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3241,32 +3072,18 @@ public ServiceCall> getCertificatesAsync(final String vaul throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificatesDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificatesDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificatesDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3287,18 +3104,7 @@ private ServiceResponse> getCertificatesDelegate(Respo * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteCertificateDelegate(call.execute()); + return deleteCertificateAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -3307,9 +3113,20 @@ public ServiceResponse deleteCertificate(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteCertificateAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Deletes a certificate from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @return the observable to the CertificateBundle object + */ + public Observable> deleteCertificateAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3320,26 +3137,18 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3360,19 +3169,7 @@ private ServiceResponse deleteCertificateDelegate(Response setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (contacts == null) { - throw new IllegalArgumentException("Parameter contacts is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(contacts); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return setCertificateContactsDelegate(call.execute()); + return setCertificateContactsAsync(vaultBaseUrl, contacts).toBlocking().single(); } /** @@ -3381,9 +3178,20 @@ public ServiceResponse setCertificateContacts(String vaultBaseUrl, Con * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param contacts The contacts for the vault certificates. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { + return ServiceCall.create(setCertificateContactsAsync(vaultBaseUrl, contacts), serviceCallback); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param contacts The contacts for the vault certificates. + * @return the observable to the Contacts object + */ + public Observable> setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3395,26 +3203,18 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Co } Validator.validate(contacts); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setCertificateContactsDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setCertificateContactsDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse setCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3434,15 +3234,7 @@ private ServiceResponse setCertificateContactsDelegate(Response getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificateContactsDelegate(call.execute()); + return getCertificateContactsAsync(vaultBaseUrl).toBlocking().single(); } /** @@ -3450,9 +3242,19 @@ public ServiceResponse getCertificateContacts(String vaultBaseUrl) thr * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificateContactsAsync(vaultBaseUrl), serviceCallback); + } + + /** + * Gets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the Contacts object + */ + public Observable> getCertificateContactsAsync(String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3460,26 +3262,18 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, fi throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificateContactsDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificateContactsDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3499,15 +3293,7 @@ private ServiceResponse getCertificateContactsDelegate(Response deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteCertificateContactsDelegate(call.execute()); + return deleteCertificateContactsAsync(vaultBaseUrl).toBlocking().single(); } /** @@ -3515,9 +3301,19 @@ public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteCertificateContactsAsync(vaultBaseUrl), serviceCallback); + } + + /** + * Deletes the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the Contacts object + */ + public Observable> deleteCertificateContactsAsync(String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3525,26 +3321,18 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteCertificateContactsDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteCertificateContactsDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3564,23 +3352,14 @@ private ServiceResponse deleteCertificateContactsDelegate(Response> getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificateIssuersNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -3588,9 +3367,44 @@ public Page nextPage(String nextPageLink) throws KeyVault * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateIssuersSinglePageAsync(vaultBaseUrl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the List<CertificateIssuerItem> object + */ + public Observable>> getCertificateIssuersAsync(final String vaultBaseUrl) { + return getCertificateIssuersSinglePageAsync(vaultBaseUrl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3599,32 +3413,18 @@ public ServiceCall> getCertificateIssuersAsync(final } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateIssuersDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateIssuersDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -3638,22 +3438,14 @@ public void onResponse(Call call, Response response) * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificateIssuersNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -3662,9 +3454,46 @@ public Page nextPage(String nextPageLink) throws KeyVault * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @return the observable to the List<CertificateIssuerItem> object + */ + public Observable>> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults) { + return getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3672,32 +3501,18 @@ public ServiceCall> getCertificateIssuersAsync(final throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateIssuersDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateIssuersDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificateIssuersDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3719,22 +3534,7 @@ private ServiceResponse> getCertificateIssuersDe * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundle issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (issuer == null) { - throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(issuer); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return setCertificateIssuerDelegate(call.execute()); + return setCertificateIssuerAsync(vaultBaseUrl, issuerName, issuer).toBlocking().single(); } /** @@ -3744,9 +3544,21 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * @param issuerName The name of the issuer. * @param issuer The issuer bundle. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) { + return ServiceCall.create(setCertificateIssuerAsync(vaultBaseUrl, issuerName, issuer), serviceCallback); + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param issuer The issuer bundle. + * @return the observable to the IssuerBundle object + */ + public Observable> setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3761,26 +3573,18 @@ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, } Validator.validate(issuer); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse setCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3802,22 +3606,7 @@ private ServiceResponse setCertificateIssuerDelegate(Response updateCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundle issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (issuer == null) { - throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(issuer); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return updateCertificateIssuerDelegate(call.execute()); + return updateCertificateIssuerAsync(vaultBaseUrl, issuerName, issuer).toBlocking().single(); } /** @@ -3827,9 +3616,21 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * @param issuerName The name of the issuer. * @param issuer The issuer bundle. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateIssuerAsync(vaultBaseUrl, issuerName, issuer), serviceCallback); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param issuer The issuer bundle. + * @return the observable to the IssuerBundle object + */ + public Observable> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3844,26 +3645,18 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUr } Validator.validate(issuer); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3884,18 +3677,7 @@ private ServiceResponse updateCertificateIssuerDelegate(Response getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificateIssuerDelegate(call.execute()); + return getCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); } /** @@ -3904,9 +3686,20 @@ public ServiceResponse getCertificateIssuer(String vaultBaseUrl, S * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Gets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object + */ + public Observable> getCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3917,26 +3710,18 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3957,18 +3742,7 @@ private ServiceResponse getCertificateIssuerDelegate(Response deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteCertificateIssuerDelegate(call.execute()); + return deleteCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); } /** @@ -3977,9 +3751,20 @@ public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Deletes the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object + */ + public Observable> deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3990,26 +3775,18 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUr throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4030,25 +3807,7 @@ private ServiceResponse deleteCertificateIssuerDelegate(Response createCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final CertificatePolicy certificatePolicy = null; - final CertificateAttributes certificateAttributes = null; - final Map tags = null; - CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.withCertificatePolicy(null); - parameters.withCertificateAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return createCertificateDelegate(call.execute()); + return createCertificateAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -4057,9 +3816,20 @@ public ServiceResponse createCertificate(String vaultBaseU * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(createCertificateAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable> createCertificateAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4077,26 +3847,18 @@ public ServiceCall createCertificateAsync(String vaultBase parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = createCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -4113,25 +3875,7 @@ public void onResponse(Call call, Response response) * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(certificatePolicy); - Validator.validate(certificateAttributes); - Validator.validate(tags); - CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.withCertificatePolicy(certificatePolicy); - parameters.withCertificateAttributes(certificateAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return createCertificateDelegate(call.execute()); + return createCertificateAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).toBlocking().single(); } /** @@ -4143,9 +3887,23 @@ public ServiceResponse createCertificate(String vaultBaseU * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(createCertificateAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags), serviceCallback); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateOperation object + */ + public Observable> createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4163,26 +3921,18 @@ public ServiceCall createCertificateAsync(String vaultBase parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = createCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse createCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4204,31 +3954,7 @@ private ServiceResponse createCertificateDelegate(Response * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (base64EncodedCertificate == null) { - throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); - } - final String password = null; - final CertificatePolicy certificatePolicy = null; - final CertificateAttributes certificateAttributes = null; - final Map tags = null; - CertificateImportParameters parameters = new CertificateImportParameters(); - parameters.withBase64EncodedCertificate(base64EncodedCertificate); - parameters.withPassword(null); - parameters.withCertificatePolicy(null); - parameters.withCertificateAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return importCertificateDelegate(call.execute()); + return importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).toBlocking().single(); } /** @@ -4238,9 +3964,21 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) { + return ServiceCall.create(importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate), serviceCallback); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. + * @return the observable to the CertificateBundle object + */ + public Observable> importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4264,26 +4002,18 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = importCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = importCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -4302,30 +4032,7 @@ public void onResponse(Call call, Response response) * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (base64EncodedCertificate == null) { - throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); - } - Validator.validate(certificatePolicy); - Validator.validate(certificateAttributes); - Validator.validate(tags); - CertificateImportParameters parameters = new CertificateImportParameters(); - parameters.withBase64EncodedCertificate(base64EncodedCertificate); - parameters.withPassword(password); - parameters.withCertificatePolicy(certificatePolicy); - parameters.withCertificateAttributes(certificateAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return importCertificateDelegate(call.execute()); + return importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).toBlocking().single(); } /** @@ -4339,9 +4046,25 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags), serviceCallback); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable> importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4364,26 +4087,18 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = importCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = importCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse importCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4398,32 +4113,58 @@ private ServiceResponse importCertificateDelegate(Response> getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { - @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificateVersionsNext(nextPageLink).getBody(); - } - }; - return new ServiceResponse<>(result, response.getResponse()); + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse<>(pagedList, response.getResponse()); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName) { + return getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }); } /** @@ -4431,10 +4172,9 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { + public Observable>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4446,32 +4186,18 @@ public ServiceCall> getCertificateVersionsAsync(final Stri } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -4486,25 +4212,14 @@ public void onResponse(Call call, Response response) * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificateVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -4514,9 +4229,48 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @param certificateName The name of the certificate * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param maxresults Maximum number of results to return. + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { + return getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param maxresults Maximum number of results to return. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4527,32 +4281,18 @@ public ServiceCall> getCertificateVersionsAsync(final Stri throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificateVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4573,18 +4313,7 @@ private ServiceResponse> getCertificateVersionsDelegat * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificatePolicyDelegate(call.execute()); + return getCertificatePolicyAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -4593,9 +4322,20 @@ public ServiceResponse getCertificatePolicy(String vaultBaseU * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificatePolicyAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Gets the policy for a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @return the observable to the CertificatePolicy object + */ + public Observable> getCertificatePolicyAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4606,26 +4346,18 @@ public ServiceCall getCertificatePolicyAsync(String vaultBase throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificatePolicyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificatePolicyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4647,22 +4379,7 @@ private ServiceResponse getCertificatePolicyDelegate(Response * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificatePolicy == null) { - throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(certificatePolicy); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return updateCertificatePolicyDelegate(call.execute()); + return updateCertificatePolicyAsync(vaultBaseUrl, certificateName, certificatePolicy).toBlocking().single(); } /** @@ -4672,9 +4389,21 @@ public ServiceResponse updateCertificatePolicy(String vaultBa * @param certificateName The name of the certificate in the given vault. * @param certificatePolicy The policy for the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificatePolicyAsync(vaultBaseUrl, certificateName, certificatePolicy), serviceCallback); + } + + /** + * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @param certificatePolicy The policy for the certificate. + * @return the observable to the CertificatePolicy object + */ + public Observable> updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4689,26 +4418,18 @@ public ServiceCall updateCertificatePolicyAsync(String vaultB } Validator.validate(certificatePolicy); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificatePolicyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificatePolicyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4730,26 +4451,7 @@ private ServiceResponse updateCertificatePolicyDelegate(Respo * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificateVersion == null) { - throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final CertificateAttributes certificateAttributes = null; - final Map tags = null; - CertificateUpdateParameters parameters = new CertificateUpdateParameters(); - parameters.withCertificateAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateCertificateDelegate(call.execute()); + return updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single(); } /** @@ -4759,9 +4461,21 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @return the observable to the CertificateBundle object + */ + public Observable> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4780,26 +4494,18 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -4816,26 +4522,7 @@ public void onResponse(Call call, Response response) * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificateVersion == null) { - throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(certificateAttributes); - Validator.validate(tags); - CertificateUpdateParameters parameters = new CertificateUpdateParameters(); - parameters.withCertificateAttributes(certificateAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateCertificateDelegate(call.execute()); + return updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, certificateAttributes, tags).toBlocking().single(); } /** @@ -4847,9 +4534,23 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, certificateAttributes, tags), serviceCallback); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4868,26 +4569,18 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4909,21 +4602,7 @@ private ServiceResponse updateCertificateDelegate(Response getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificateVersion == null) { - throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificateDelegate(call.execute()); + return getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single(); } /** @@ -4933,9 +4612,21 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + } + + /** + * Gets a Certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @return the observable to the CertificateBundle object + */ + public Observable> getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4949,26 +4640,18 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4990,22 +4673,7 @@ private ServiceResponse getCertificateDelegate(Response updateCertificateOperation(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificateOperation == null) { - throw new IllegalArgumentException("Parameter certificateOperation is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(certificateOperation); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return updateCertificateOperationDelegate(call.execute()); + return updateCertificateOperationAsync(vaultBaseUrl, certificateName, certificateOperation).toBlocking().single(); } /** @@ -5015,9 +4683,21 @@ public ServiceResponse updateCertificateOperation(String v * @param certificateName The name of the certificate * @param certificateOperation The certificate operation response. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateOperationAsync(vaultBaseUrl, certificateName, certificateOperation), serviceCallback); + } + + /** + * Updates a certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param certificateOperation The certificate operation response. + * @return the observable to the CertificateOperation object + */ + public Observable> updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5032,26 +4712,18 @@ public ServiceCall updateCertificateOperationAsync(String } Validator.validate(certificateOperation); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateOperationDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateOperationDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5072,18 +4744,7 @@ private ServiceResponse updateCertificateOperationDelegate * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificateOperationDelegate(call.execute()); + return getCertificateOperationAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -5092,9 +4753,20 @@ public ServiceResponse getCertificateOperation(String vaul * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificateOperationAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Gets the certificate operation response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable> getCertificateOperationAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5105,26 +4777,18 @@ public ServiceCall getCertificateOperationAsync(String vau throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificateOperationDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificateOperationDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5141,22 +4805,11 @@ private ServiceResponse getCertificateOperationDelegate(Re * @param certificateName The name of the certificate * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteCertificateOperationDelegate(call.execute()); + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteCertificateOperationAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -5165,9 +4818,20 @@ public ServiceResponse deleteCertificateOperation(String v * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteCertificateOperationAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Deletes the certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable> deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5178,26 +4842,18 @@ public ServiceCall deleteCertificateOperationAsync(String throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteCertificateOperationDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteCertificateOperationDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5219,28 +4875,7 @@ private ServiceResponse deleteCertificateOperationDelegate * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (x509Certificates == null) { - throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); - } - Validator.validate(x509Certificates); - final CertificateAttributes certificateAttributes = null; - final Map tags = null; - CertificateMergeParameters parameters = new CertificateMergeParameters(); - parameters.withX509Certificates(x509Certificates); - parameters.withCertificateAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return mergeCertificateDelegate(call.execute()); + return mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates).toBlocking().single(); } /** @@ -5250,9 +4885,21 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate * @param x509Certificates The certificate or the certificate chain to merge * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) { + return ServiceCall.create(mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates), serviceCallback); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificate chain to merge + * @return the observable to the CertificateBundle object + */ + public Observable> mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5273,26 +4920,18 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = mergeCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = mergeCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -5309,28 +4948,7 @@ public void onResponse(Call call, Response response) * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (x509Certificates == null) { - throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); - } - Validator.validate(x509Certificates); - Validator.validate(certificateAttributes); - Validator.validate(tags); - CertificateMergeParameters parameters = new CertificateMergeParameters(); - parameters.withX509Certificates(x509Certificates); - parameters.withCertificateAttributes(certificateAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return mergeCertificateDelegate(call.execute()); + return mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).toBlocking().single(); } /** @@ -5342,9 +4960,23 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags), serviceCallback); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificate chain to merge + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable> mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5365,26 +4997,18 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = mergeCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = mergeCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse mergeCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5403,12 +5027,15 @@ private ServiceResponse mergeCertificateDelegate(Response> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getKeyVersionsNextDelegate(call.execute()); + public ServiceResponse> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -5417,35 +5044,59 @@ public ServiceResponse> getKeyVersionsNext(final String nextPa * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeyVersionsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified key. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeyVersionsNextAsync(final String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified key. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeyVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeyVersionsNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeyVersionsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getKeyVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5464,12 +5115,15 @@ private ServiceResponse> getKeyVersionsNextDelegate(Response> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getKeysNextDelegate(call.execute()); + public ServiceResponse> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getKeysNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -5478,35 +5132,59 @@ public ServiceResponse> getKeysNext(final String nextPageLink) * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeysNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeysNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List keys in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeysNextAsync(final String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeysNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List keys in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeysNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeysNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeysNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getKeysNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5525,12 +5203,15 @@ private ServiceResponse> getKeysNextDelegate(Response> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getSecretsNextDelegate(call.execute()); + public ServiceResponse> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -5539,35 +5220,59 @@ public ServiceResponse> getSecretsNext(final String nextPag * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List secrets in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretsNextAsync(final String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List secrets in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretsNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getSecretsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5586,12 +5291,15 @@ private ServiceResponse> getSecretsNextDelegate(Response> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getSecretVersionsNextDelegate(call.execute()); + public ServiceResponse> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -5600,35 +5308,59 @@ public ServiceResponse> getSecretVersionsNext(final String * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretVersionsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified secret. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretVersionsNextAsync(final String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified secret. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretVersionsNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretVersionsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getSecretVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5647,12 +5379,15 @@ private ServiceResponse> getSecretVersionsNextDelegate(Resp * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getCertificatesNextDelegate(call.execute()); + public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -5661,35 +5396,59 @@ public ServiceResponse> getCertificatesNext(final Stri * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificatesNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificates in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificatesNextAsync(final String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificates in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificatesNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificatesNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificatesNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificatesNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5708,12 +5467,15 @@ private ServiceResponse> getCertificatesNextDelegate(R * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getCertificateIssuersNextDelegate(call.execute()); + public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -5722,35 +5484,59 @@ public ServiceResponse> getCertificateIssuersNex * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateIssuersNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificate issuers for the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<CertificateIssuerItem> object + */ + public Observable>> getCertificateIssuersNextAsync(final String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateIssuersNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateIssuersNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateIssuersNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificateIssuersNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5769,12 +5555,15 @@ private ServiceResponse> getCertificateIssuersNe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getCertificateVersionsNextDelegate(call.execute()); + public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse<>(pagedList, response.getResponse()); } /** @@ -5783,35 +5572,59 @@ public ServiceResponse> getCertificateVersionsNext(fin * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateVersionsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of a certificate. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificateVersionsNextAsync(final String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of a certificate. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateVersionsNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateVersionsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificateVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java new file mode 100644 index 0000000000000..027b37b3588e7 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the implementation classes for KeyVaultClient. + * Performs cryptographic key operations and vault operations against the Key Vault service. + */ +package com.microsoft.azure.keyvault.implementation; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java index b87d376d8bdde..903784187e16e 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java index 3bd73fd386216..872cf84b8c219 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java index 580ac6b5d62f2..5889bace83753 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java index ed187ccd0cab0..cb8fd0cfcae73 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java index b5a6a72351240..7a069513a17cd 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java index d821e2490bc60..0fe27a6925258 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java index eda7dfbc9da3a..22d728473cd88 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java @@ -3,24 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; -import com.microsoft.azure.keyvault.CertificateIdentifier; -import com.microsoft.azure.keyvault.KeyIdentifier; -import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.rest.Base64Url; - -import java.io.IOException; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; /** * A certificate bundle consists of a certificate (X509) plus its attributes. @@ -204,50 +194,4 @@ public CertificateBundle withTags(Map tags) { return this; } - /** - * The certificate identifier. - * @return certificate identifier - */ - public CertificateIdentifier certificateIdentifier() { - if (id() == null || id().isEmpty()) { - return null; - } - return new CertificateIdentifier(id()); - } - - /** - * The secret identifier. - * @return secret identifier - */ - public SecretIdentifier secretIdentifier() { - if (sid() == null || sid().isEmpty()) { - return null; - } - return new SecretIdentifier(sid()); - } - - /** - * The key identifier. - * @return key identifier - */ - public KeyIdentifier keyIdentifier() { - if (kid() == null || kid().isEmpty()) { - return null; - } - return new KeyIdentifier(kid()); - } - - @Override - public String toString() { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.writeValueAsString(this); - } catch (JsonGenerationException e) { - throw new IllegalStateException(e); - } catch (JsonMappingException e) { - throw new IllegalStateException(e); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java index 9de3d7a36bebb..d85d2eb430def 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java index 6cd918a00cb14..6e0ec8791cfd9 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java index f90e86cd39fdb..119aed73128b5 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java index cf13fa529bb36..c303d1fbaecc8 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java @@ -3,16 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; import java.util.Map; - -import com.microsoft.azure.keyvault.CertificateIdentifier; import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; @@ -128,17 +124,4 @@ public CertificateItem withX509Thumbprint(byte[] x509Thumbprint) { return this; } - /** - * The certificate identifier. - * @return The Identifier value. - */ - public CertificateIdentifier identifier() { - CertificateIdentifier identifier = null; - - if (id() != null && !id().isEmpty()) { - identifier = new CertificateIdentifier(id()); - } - - return identifier; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java index 46454283ded8f..bf6b9e58bbd28 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java index c8aea174e4bf3..d306cdf04cf5d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java @@ -3,20 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; -import java.io.IOException; - import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.keyvault.CertificateOperationIdentifier; /** * A certificate operation is returned in case of async requests. @@ -242,28 +234,4 @@ public CertificateOperation withRequestId(String requestId) { return this; } - /** - * The certificate operation identifier. - * @return the identifier value - */ - public CertificateOperationIdentifier certificateOperationIdentifier() { - if (id() == null || id().isEmpty()) { - return null; - } - return new CertificateOperationIdentifier(id()); - } - - @Override - public String toString() { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.writeValueAsString(this); - } catch (JsonGenerationException e) { - throw new IllegalStateException(e); - } catch (JsonMappingException e) { - throw new IllegalStateException(e); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java index 6243eb4a805e4..cb3047ca19d63 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java index 0e3d426eed6cf..26316932dfb48 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java index 7fe0c7baeb017..9be09f829e031 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java index 8d0d542cbeb2b..21d0001a70d70 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java index 4d231d644f92a..9caf41131e546 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java index 592e36229ecc7..866aebdb8d05a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java index 3dd318e5139f8..427957894b10b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -3,20 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; -import java.io.IOException; - import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.keyvault.IssuerIdentifier; /** * The issuer for Key Vault certificate. @@ -138,28 +130,4 @@ public IssuerBundle withAttributes(IssuerAttributes attributes) { return this; } - /** - * The issuer identifier. - * @return identifier for issuer - */ - public IssuerIdentifier issuerIdentifier() { - if (id() == null || id().isEmpty()) { - return null; - } - return new IssuerIdentifier(id()); - } - - @Override - public String toString() { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.writeValueAsString(this); - } catch (JsonGenerationException e) { - throw new IllegalStateException(e); - } catch (JsonMappingException e) { - throw new IllegalStateException(e); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java index 23ef3eced7f05..5651c64bf2ea4 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java index 6f971897b7dbb..88f47a517aed9 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java index ed9bb700c1543..a1df07c01c11d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java @@ -3,33 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; -import java.io.IOException; -import java.math.BigInteger; -import java.security.GeneralSecurityException; -import java.security.KeyFactory; -import java.security.KeyPair; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.interfaces.RSAPrivateCrtKey; -import java.security.interfaces.RSAPublicKey; -import java.security.spec.RSAPrivateCrtKeySpec; -import java.security.spec.RSAPrivateKeySpec; -import java.security.spec.RSAPublicKeySpec; -import java.util.Arrays; import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; import com.microsoft.rest.Base64Url; +import com.fasterxml.jackson.annotation.JsonProperty; /** * As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18. @@ -41,10 +22,11 @@ public class JsonWebKey { private String kid; /** - * Key type, usually RSA. Possible values include: 'EC', 'RSA', 'RSA-HSM', + * Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, + * Octet, usually RSA. Possible values include: 'EC', 'RSA', 'RSA-HSM', * 'oct'. */ - private String kty; + private JsonWebKeyType kty; /** * The keyOps property. @@ -129,7 +111,7 @@ public JsonWebKey withKid(String kid) { * * @return the kty value */ - public String kty() { + public JsonWebKeyType kty() { return this.kty; } @@ -139,7 +121,7 @@ public String kty() { * @param kty the kty value to set * @return the JsonWebKey object itself. */ - public JsonWebKey withKty(String kty) { + public JsonWebKey withKty(JsonWebKeyType kty) { this.kty = kty; return this; } @@ -434,169 +416,4 @@ public JsonWebKey withT(byte[] t) { return this; } - @Override - public String toString() { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.writeValueAsString(this); - } catch (JsonGenerationException e) { - throw new IllegalStateException(e); - } catch (JsonMappingException e) { - throw new IllegalStateException(e); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - - /** - * Get the RSA public key spec value. - * - * @return the RSA public key spec value - */ - private RSAPublicKeySpec getRSAPublicKeySpec() { - - return new RSAPublicKeySpec(toBigInteger(n()), toBigInteger(e())); - } - - /** - * Get the RSA private key spec value. - * - * @return the RSA private key spec value - */ - private RSAPrivateKeySpec getRSAPrivateKeySpec() { - - return new RSAPrivateCrtKeySpec(toBigInteger(n()), toBigInteger(e()), toBigInteger(d()), toBigInteger(p()), - toBigInteger(q()), toBigInteger(dp()), toBigInteger(dq()), toBigInteger(qi())); - } - - /** - * Get the RSA public key value. - * - * @return the RSA public key value - */ - private PublicKey getRSAPublicKey() { - - try { - RSAPublicKeySpec publicKeySpec = getRSAPublicKeySpec(); - KeyFactory factory = KeyFactory.getInstance("RSA"); - - return factory.generatePublic(publicKeySpec); - } catch (GeneralSecurityException e) { - throw new IllegalStateException(e); - } - } - - /** - * Get the RSA private key value. - * - * @return the RSA private key value - */ - private PrivateKey getRSAPrivateKey() { - - try { - RSAPrivateKeySpec privateKeySpec = getRSAPrivateKeySpec(); - KeyFactory factory = KeyFactory.getInstance("RSA"); - - return factory.generatePrivate(privateKeySpec); - } catch (GeneralSecurityException e) { - throw new IllegalStateException(e); - } - } - - /** - * Verifies if the key is an RSA key. - */ - private void checkRSACompatible() { - if (!JsonWebKeyType.RSA.equals(kty()) && !JsonWebKeyType.RSAHSM.equals(kty())) { - throw new UnsupportedOperationException("Not an RSA key"); - } - } - - private static byte[] toByteArray(BigInteger n) { - byte[] result = n.toByteArray(); - if (result[0] == 0) { - // The leading zero is used to let the number positive. Since RSA - // parameters are always positive, we remove it. - return Arrays.copyOfRange(result, 1, result.length); - } - return result; - } - - private static BigInteger toBigInteger(byte[] b) { - if (b[0] < 0) { - // RSA parameters are always positive numbers, so if the first byte - // is negative, we need to add a leading zero - // to make the entire BigInteger positive. - byte[] temp = new byte[1 + b.length]; - System.arraycopy(b, 0, temp, 1, b.length); - b = temp; - } - return new BigInteger(b); - } - - /** - * Converts RSA key pair to JSON web key. - * @param keyPair RSA key pair - * @return the JSON web key, converted from RSA key pair. - */ - public static JsonWebKey fromRSA(KeyPair keyPair) { - - RSAPrivateCrtKey privateKey = (RSAPrivateCrtKey) keyPair.getPrivate(); - JsonWebKey key = null; - - if (privateKey != null) { - - key = new JsonWebKey() - .withKty(JsonWebKeyType.RSA) - .withN(toByteArray(privateKey.getModulus())) - .withE(toByteArray(privateKey.getPublicExponent())) - .withD(toByteArray(privateKey.getPrivateExponent())) - .withP(toByteArray(privateKey.getPrimeP())) - .withQ(toByteArray(privateKey.getPrimeQ())) - .withDp(toByteArray(privateKey.getPrimeExponentP())) - .withDq(toByteArray(privateKey.getPrimeExponentQ())) - .withQi(toByteArray(privateKey.getCrtCoefficient())); - } else { - - RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); - - key = new JsonWebKey() - .withKty(JsonWebKeyType.RSA) - .withN(toByteArray(publicKey.getModulus())) - .withE(toByteArray(publicKey.getPublicExponent())) - .withD(null) - .withP(null) - .withQ(null) - .withDp(null) - .withDq(null) - .withQi(null); - } - - return key; - } - - /** - * Converts JSON web key to RSA key pair. - * @return RSA key pair - */ - public KeyPair toRSA() { - return this.toRSA(false); - } - - /** - * Converts JSON web key to RSA key pair and include the private key if set to true. - * @param includePrivateParameters true if the RSA key pair should include the private key. False otherwise. - * @return RSA key pair - */ - public KeyPair toRSA(boolean includePrivateParameters) { - - // Must be RSA - checkRSACompatible(); - - if (includePrivateParameters) { - return new KeyPair(getRSAPublicKey(), getRSAPrivateKey()); - } else { - return new KeyPair(getRSAPublicKey(), null); - } - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyEncryptionAlgorithm.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyEncryptionAlgorithm.java new file mode 100644 index 0000000000000..e164c8e06e9fb --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyEncryptionAlgorithm.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.keyvault.models; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for JsonWebKeyEncryptionAlgorithm. + */ +public final class JsonWebKeyEncryptionAlgorithm { + /** Static value RSA-OAEP for JsonWebKeyEncryptionAlgorithm. */ + public static final JsonWebKeyEncryptionAlgorithm RSA_OAEP = new JsonWebKeyEncryptionAlgorithm("RSA-OAEP"); + + /** Static value RSA1_5 for JsonWebKeyEncryptionAlgorithm. */ + public static final JsonWebKeyEncryptionAlgorithm RSA1_5 = new JsonWebKeyEncryptionAlgorithm("RSA1_5"); + + private String value; + + /** + * Creates a custom value for JsonWebKeyEncryptionAlgorithm. + * @param value the custom value + */ + public JsonWebKeyEncryptionAlgorithm(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } + + @Override + public int hashCode() { + return value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JsonWebKeyEncryptionAlgorithm)) { + return false; + } + if (obj == this) { + return true; + } + JsonWebKeyEncryptionAlgorithm rhs = (JsonWebKeyEncryptionAlgorithm) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyOperation.java new file mode 100644 index 0000000000000..614f32905b234 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyOperation.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.keyvault.models; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for JsonWebKeyOperation. + */ +public final class JsonWebKeyOperation { + /** Static value encrypt for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation ENCRYPT = new JsonWebKeyOperation("encrypt"); + + /** Static value decrypt for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation DECRYPT = new JsonWebKeyOperation("decrypt"); + + /** Static value sign for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation SIGN = new JsonWebKeyOperation("sign"); + + /** Static value verify for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation VERIFY = new JsonWebKeyOperation("verify"); + + /** Static value wrapKey for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation WRAP_KEY = new JsonWebKeyOperation("wrapKey"); + + /** Static value unwrapKey for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation UNWRAP_KEY = new JsonWebKeyOperation("unwrapKey"); + + private String value; + + /** + * Creates a custom value for JsonWebKeyOperation. + * @param value the custom value + */ + public JsonWebKeyOperation(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } + + @Override + public int hashCode() { + return value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JsonWebKeyOperation)) { + return false; + } + if (obj == this) { + return true; + } + JsonWebKeyOperation rhs = (JsonWebKeyOperation) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeySignatureAlgorithm.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeySignatureAlgorithm.java new file mode 100644 index 0000000000000..752b278b5b5ea --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeySignatureAlgorithm.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.keyvault.models; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for JsonWebKeySignatureAlgorithm. + */ +public final class JsonWebKeySignatureAlgorithm { + /** Static value RS256 for JsonWebKeySignatureAlgorithm. */ + public static final JsonWebKeySignatureAlgorithm RS256 = new JsonWebKeySignatureAlgorithm("RS256"); + + /** Static value RS384 for JsonWebKeySignatureAlgorithm. */ + public static final JsonWebKeySignatureAlgorithm RS384 = new JsonWebKeySignatureAlgorithm("RS384"); + + /** Static value RS512 for JsonWebKeySignatureAlgorithm. */ + public static final JsonWebKeySignatureAlgorithm RS512 = new JsonWebKeySignatureAlgorithm("RS512"); + + /** Static value RSNULL for JsonWebKeySignatureAlgorithm. */ + public static final JsonWebKeySignatureAlgorithm RSNULL = new JsonWebKeySignatureAlgorithm("RSNULL"); + + private String value; + + /** + * Creates a custom value for JsonWebKeySignatureAlgorithm. + * @param value the custom value + */ + public JsonWebKeySignatureAlgorithm(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } + + @Override + public int hashCode() { + return value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JsonWebKeySignatureAlgorithm)) { + return false; + } + if (obj == this) { + return true; + } + JsonWebKeySignatureAlgorithm rhs = (JsonWebKeySignatureAlgorithm) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyType.java new file mode 100644 index 0000000000000..9bfcef3fbb5cb --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyType.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.keyvault.models; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Defines values for JsonWebKeyType. + */ +public final class JsonWebKeyType { + /** Static value EC for JsonWebKeyType. */ + public static final JsonWebKeyType EC = new JsonWebKeyType("EC"); + + /** Static value RSA for JsonWebKeyType. */ + public static final JsonWebKeyType RSA = new JsonWebKeyType("RSA"); + + /** Static value RSA-HSM for JsonWebKeyType. */ + public static final JsonWebKeyType RSA_HSM = new JsonWebKeyType("RSA-HSM"); + + /** Static value oct for JsonWebKeyType. */ + public static final JsonWebKeyType OCT = new JsonWebKeyType("oct"); + + private String value; + + /** + * Creates a custom value for JsonWebKeyType. + * @param value the custom value + */ + public JsonWebKeyType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } + + @Override + public int hashCode() { + return value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JsonWebKeyType)) { + return false; + } + if (obj == this) { + return true; + } + JsonWebKeyType rhs = (JsonWebKeyType) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java index 25c37fede46de..53b43c1f72fe8 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index 4c13b1490a64d..16ce789c2d11c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -3,21 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; -import java.io.IOException; import java.util.Map; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.keyvault.KeyIdentifier; - /** * A KeyBundle consisting of a WebKey plus its Attributes. */ @@ -97,28 +89,4 @@ public KeyBundle withTags(Map tags) { return this; } - /** - * The key identifier. - * @return identifier for the key - */ - public KeyIdentifier keyIdentifier() { - if (key() == null || key().kid() == null || key().kid().length() == 0) { - return null; - } - return new KeyIdentifier(key().kid()); - } - - @Override - public String toString() { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.writeValueAsString(this); - } catch (JsonGenerationException e) { - throw new IllegalStateException(e); - } catch (JsonMappingException e) { - throw new IllegalStateException(e); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java index a799ee36fb6e7..1a56c8e43670e 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; @@ -20,10 +18,11 @@ public class KeyCreateParameters { /** * The type of key to create. Valid key types, see JsonWebKeyType. - * Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'. + * Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, + * Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'. */ @JsonProperty(required = true) - private String kty; + private JsonWebKeyType kty; /** * The key size in bytes. e.g. 1024 or 2048. @@ -35,7 +34,7 @@ public class KeyCreateParameters { * The keyOps property. */ @JsonProperty(value = "key_ops") - private List keyOps; + private List keyOps; /** * The keyAttributes property. @@ -53,7 +52,7 @@ public class KeyCreateParameters { * * @return the kty value */ - public String kty() { + public JsonWebKeyType kty() { return this.kty; } @@ -63,7 +62,7 @@ public String kty() { * @param kty the kty value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters withKty(String kty) { + public KeyCreateParameters withKty(JsonWebKeyType kty) { this.kty = kty; return this; } @@ -93,7 +92,7 @@ public KeyCreateParameters withKeySize(Integer keySize) { * * @return the keyOps value */ - public List keyOps() { + public List keyOps() { return this.keyOps; } @@ -103,7 +102,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters withKeyOps(List keyOps) { + public KeyCreateParameters withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java index 0cd6eb0a956e5..46b16eea221dd 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index 05584de30f1ac..72d42a1ddeced 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -3,17 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; import java.util.Map; -import com.microsoft.azure.keyvault.KeyIdentifier; - /** * The key item containing key metadata. */ @@ -93,17 +89,4 @@ public KeyItem withTags(Map tags) { return this; } - /** - * The key identifier. - * @return The Identifier value - */ - public KeyIdentifier identifier() { - KeyIdentifier identifier = null; - - if (kid() != null && !kid().isEmpty()) { - identifier = new KeyIdentifier(kid()); - } - - return identifier; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java index 229b85ec52d70..ed09546bd0c5f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java index 228a944624152..9b5503509891a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; @@ -21,7 +19,7 @@ public class KeyOperationsParameters { * algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5'. */ @JsonProperty(value = "alg", required = true) - private String algorithm; + private JsonWebKeyEncryptionAlgorithm algorithm; /** * The value property. @@ -34,7 +32,7 @@ public class KeyOperationsParameters { * * @return the algorithm value */ - public String algorithm() { + public JsonWebKeyEncryptionAlgorithm algorithm() { return this.algorithm; } @@ -44,7 +42,7 @@ public String algorithm() { * @param algorithm the algorithm value to set * @return the KeyOperationsParameters object itself. */ - public KeyOperationsParameters withAlgorithm(String algorithm) { + public KeyOperationsParameters withAlgorithm(JsonWebKeyEncryptionAlgorithm algorithm) { this.algorithm = algorithm; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java index 999ed545fd0be..3780e73a8f341 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java index 2d32495d4074e..273bbeb7fa2da 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java index 1af4965c7b756..d28acbc964c64 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; @@ -23,7 +21,7 @@ public class KeySignParameters { * values include: 'RS256', 'RS384', 'RS512', 'RSNULL'. */ @JsonProperty(value = "alg", required = true) - private String algorithm; + private JsonWebKeySignatureAlgorithm algorithm; /** * The value property. @@ -36,7 +34,7 @@ public class KeySignParameters { * * @return the algorithm value */ - public String algorithm() { + public JsonWebKeySignatureAlgorithm algorithm() { return this.algorithm; } @@ -46,7 +44,7 @@ public String algorithm() { * @param algorithm the algorithm value to set * @return the KeySignParameters object itself. */ - public KeySignParameters withAlgorithm(String algorithm) { + public KeySignParameters withAlgorithm(JsonWebKeySignatureAlgorithm algorithm) { this.algorithm = algorithm; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java index 33c51dc4d697b..01cc940d4ee34 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; @@ -23,7 +21,7 @@ public class KeyUpdateParameters { * operations, see JsonWebKeyOperation. */ @JsonProperty(value = "key_ops") - private List keyOps; + private List keyOps; /** * The keyAttributes property. @@ -41,7 +39,7 @@ public class KeyUpdateParameters { * * @return the keyOps value */ - public List keyOps() { + public List keyOps() { return this.keyOps; } @@ -51,7 +49,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the KeyUpdateParameters object itself. */ - public KeyUpdateParameters withKeyOps(List keyOps) { + public KeyUpdateParameters withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java index 7b4b390b1cb65..316286608217f 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java index aa2a6f81d1c74..83c9aa7d202e6 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java index bdcfc617fc14c..6606b0ab2fb4d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java index 1f370f7494ed7..204e2fdf80ca7 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; @@ -23,7 +21,7 @@ public class KeyVerifyParameters { * include: 'RS256', 'RS384', 'RS512', 'RSNULL'. */ @JsonProperty(value = "alg", required = true) - private String algorithm; + private JsonWebKeySignatureAlgorithm algorithm; /** * The digest used for signing. @@ -42,7 +40,7 @@ public class KeyVerifyParameters { * * @return the algorithm value */ - public String algorithm() { + public JsonWebKeySignatureAlgorithm algorithm() { return this.algorithm; } @@ -52,7 +50,7 @@ public String algorithm() { * @param algorithm the algorithm value to set * @return the KeyVerifyParameters object itself. */ - public KeyVerifyParameters withAlgorithm(String algorithm) { + public KeyVerifyParameters withAlgorithm(JsonWebKeySignatureAlgorithm algorithm) { this.algorithm = algorithm; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java index 2295ece7edb6a..da66a2594aeca 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java index 9f2f520dfaf7a..3b113d3b67b34 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java index 44e80f582186f..c9e219bd14be1 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java index ba40e0b446269..71d801b06a166 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java index 51b5fc32aee52..65c1d613093d0 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java index e6cdbe4d40db0..90c38a6b223b1 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index 52d7e736fb451..c69a1d61bbbee 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -3,21 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; -import java.io.IOException; import java.util.Map; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.keyvault.SecretIdentifier; - /** * A Secret consisting of a value, id and its attributes. */ @@ -172,29 +164,4 @@ public SecretBundle withKid(String kid) { return this; } - /** - * the secret identifier. - * @return The Identifier value - */ - public SecretIdentifier secretIdentifier() { - if (id() == null || id().length() == 0) { - return null; - } - return new SecretIdentifier(id()); - } - - @Override - public String toString() { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.writeValueAsString(this); - } catch (JsonGenerationException e) { - throw new IllegalStateException(e); - } catch (JsonMappingException e) { - throw new IllegalStateException(e); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index 5359f9cba67ca..a52b488a3e1cd 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -3,17 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; import java.util.Map; -import com.microsoft.azure.keyvault.SecretIdentifier; - /** * The secret item containing secret metadata. */ @@ -118,17 +114,4 @@ public SecretItem withContentType(String contentType) { return this; } - /** - * the secret identifier. - * @return The Identifier value - */ - public SecretIdentifier identifier() { - SecretIdentifier identifier = null; - - if (id() != null && !id().isEmpty()) { - identifier = new SecretIdentifier(id()); - } - - return identifier; - } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java index daa4ec324e4cc..384c7bed74f9d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java index c6aa346335c08..ccfa3361129fd 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java index ac9361fffbe73..bf3f590edefe2 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java index 317cc22925354..fbbe4915c966c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java index 52fa1a031dd3a..efcfa4e3a2249 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java index ae9267dba24d6..44febbf283c47 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java @@ -3,9 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * Code generated by Microsoft (R) AutoRest Code Generator. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java index 79c10e9f21e65..1ad477613c6d3 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java @@ -2,9 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. +// Code generated by Microsoft (R) AutoRest Code Generator. /** * This package contains the models classes for KeyVaultClient. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java index ec9b976c5096b..0f6aa06721867 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java @@ -2,9 +2,7 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 -// Changes may cause incorrect behavior and will be lost if the code is -// regenerated. +// Code generated by Microsoft (R) AutoRest Code Generator. /** * This package contains the classes for KeyVaultClient. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java index 96f416bb9cf36..5b90a72048233 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java @@ -5,6 +5,8 @@ import java.util.List; import java.util.Map; +import com.microsoft.azure.keyvault.models.JsonWebKeyOperation; +import com.microsoft.azure.keyvault.models.JsonWebKeyType; import com.microsoft.azure.keyvault.models.KeyAttributes; /** @@ -14,9 +16,9 @@ public final class CreateKeyRequest { private final String vaultBaseUrl; private final String keyName; - private final String keyType; + private final JsonWebKeyType keyType; private final Integer keySize; - private final List keyOperations; + private final List keyOperations; private final KeyAttributes keyAttributes; private final Map tags; @@ -28,11 +30,11 @@ public static class Builder { // Required parameters private final String vaultBaseUrl; private final String keyName; - private final String keyType; + private final JsonWebKeyType keyType; // Optional parameters private Integer keySize; - private List keyOperations; + private List keyOperations; private KeyAttributes attributes; private Map tags; @@ -47,7 +49,7 @@ public static class Builder { * The type of key to create. Possible values include: 'EC', * 'RSA', 'RSA-HSM', 'oct' */ - public Builder(String vaultBaseUrl, String keyName, String keyType) { + public Builder(String vaultBaseUrl, String keyName, JsonWebKeyType keyType) { this.vaultBaseUrl = vaultBaseUrl; this.keyName = keyName; this.keyType = keyType; @@ -72,7 +74,7 @@ public Builder withKeySize(Integer size) { * the key operation list. * @return the Builder object itself. */ - public Builder withKeyOperations(List keyOperations) { + public Builder withKeyOperations(List keyOperations) { this.keyOperations = keyOperations; return this; } @@ -119,7 +121,7 @@ private CreateKeyRequest(Builder builder) { keySize = builder.keySize; if (builder.keyOperations != null) { - keyOperations = new ArrayList(builder.keyOperations); + keyOperations = new ArrayList(builder.keyOperations); } else { keyOperations = null; } @@ -155,7 +157,7 @@ public String keyName() { /** * @return the key type */ - public String keyType() { + public JsonWebKeyType keyType() { return keyType; } @@ -169,7 +171,7 @@ public Integer keySize() { /** * @return the key operations */ - public List keyOperations() { + public List keyOperations() { return keyOperations; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java index d87b8c798c583..db90cb537b57d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java @@ -6,6 +6,7 @@ import java.util.Map; import com.microsoft.azure.keyvault.KeyIdentifier; +import com.microsoft.azure.keyvault.models.JsonWebKeyOperation; import com.microsoft.azure.keyvault.models.KeyAttributes; /** @@ -16,7 +17,7 @@ public final class UpdateKeyRequest { private final String vaultBaseUrl; private final String keyName; private final String keyVersion; - private final List keyOperations; + private final List keyOperations; private final KeyAttributes keyAttributes; private final Map tags; @@ -31,7 +32,7 @@ public static class Builder { // Optional parameters private String keyVersion; - private List keyOperations; + private List keyOperations; private KeyAttributes attributes; private Map tags; @@ -82,7 +83,7 @@ public Builder withVersion(String keyVersion) { * the key operation list * @return the Builder object itself. */ - public Builder withKeyOperations(List keyOperations) { + public Builder withKeyOperations(List keyOperations) { this.keyOperations = keyOperations; return this; } @@ -128,7 +129,7 @@ private UpdateKeyRequest(Builder builder) { keyVersion = builder.keyVersion == null ? "" : builder.keyVersion; if (builder.keyOperations != null) { - keyOperations = new ArrayList(builder.keyOperations); + keyOperations = new ArrayList(builder.keyOperations); } else { keyOperations = null; } @@ -171,7 +172,7 @@ public String keyVersion() { /** * @return the key operations */ - public List keyOperations() { + public List keyOperations() { return keyOperations; } From ac592738bf14b83b2486a4304e98888fe7bdafee Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Fri, 26 Aug 2016 17:37:03 -0700 Subject: [PATCH 18/56] Keyvault refactoring --- .../keyvault/extensions/KeyVaultKey.java | 24 ++- .../KeyVaultKeyResolverBCProviderTest.java | 5 +- ...eyVaultKeyResolverDefaultProviderTest.java | 3 +- .../azure/keyvault/KeyVaultClient.java | 13 +- .../KeyVaultClientImpl.java | 5 +- .../keyvault/models/CertificateBundle.java | 54 +++++ .../keyvault/models/CertificateOperation.java | 30 +++ .../azure/keyvault/models/IssuerBundle.java | 30 +++ .../azure/keyvault/models/JsonWebKey.java | 192 +++++++++++++++++- .../azure/keyvault/models/KeyBundle.java | 30 +++ .../azure/keyvault/models/SecretBundle.java | 30 +++ .../keyvault/requests/ImportKeyRequest.java | 3 +- .../webkey/JsonWebKeyEncryptionAlgorithm.java | 51 ----- .../keyvault/webkey/JsonWebKeyOperation.java | 71 ------- .../webkey/JsonWebKeySignatureAlgorithm.java | 60 ------ .../azure/keyvault/webkey/JsonWebKeyType.java | 60 ------ .../azure/keyvault/webkey/package-info.java | 9 - .../keyvault/test/KeyOperationsTest.java | 62 +++--- 18 files changed, 420 insertions(+), 312 deletions(-) rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{ => implementation}/KeyVaultClientImpl.java (99%) delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index 485fa3a0b797f..498c3e85e3ef0 100644 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -18,11 +18,6 @@ package com.microsoft.azure.keyvault.extensions; -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.commons.lang3.tuple.Triple; - import com.google.common.base.Function; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -30,11 +25,18 @@ import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.cryptography.RsaKey; import com.microsoft.azure.keyvault.cryptography.Strings; +import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.models.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.models.JsonWebKeySignatureAlgorithm; +import com.microsoft.azure.keyvault.models.JsonWebKeyType; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyOperationResult; -import com.microsoft.azure.keyvault.models.JsonWebKey; -import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; import com.microsoft.rest.ServiceResponse; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.commons.lang3.tuple.Triple; + +import java.io.IOException; +import java.security.NoSuchAlgorithmException; /** * The key vault key that performs cryptography operations. @@ -97,7 +99,7 @@ protected KeyVaultKey(KeyVaultClient client, KeyBundle keyBundle) { if (key.kty().equals(JsonWebKeyType.RSA)) { // The private key is not available for KeyVault keys implementation = new RsaKey(key.kid(), key.toRSA(false)); - } else if (key.kty().equals(JsonWebKeyType.RSAHSM)) { + } else if (key.kty().equals(JsonWebKeyType.RSA_HSM)) { // The private key is not available for KeyVault keys implementation = new RsaKey(key.kid(), key.toRSA(false)); } @@ -170,7 +172,7 @@ public ListenableFuture decryptAsync(byte[] ciphertext, byte[] iv, byte[ ListenableFuture> futureCall = client.decryptAsync( implementation.getKid(), - algorithm, + new JsonWebKeyEncryptionAlgorithm(algorithm), ciphertext, null); return Futures.transform(futureCall, new DecryptResultTransform()); @@ -208,7 +210,7 @@ public ListenableFuture unwrapKeyAsync(byte[] ciphertext, String algorit ListenableFuture> futureCall = client.unwrapKeyAsync( implementation.getKid(), - algorithm, + new JsonWebKeyEncryptionAlgorithm(algorithm), ciphertext, null); return Futures.transform(futureCall, new DecryptResultTransform()); @@ -228,7 +230,7 @@ public ListenableFuture> signAsync(byte[] digest, String al ListenableFuture> futureCall = client.signAsync( implementation.getKid(), - algorithm, + new JsonWebKeySignatureAlgorithm(algorithm), digest, null); return Futures.transform(futureCall, new SignResultTransform(algorithm)); diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java index 58948e52d9bb2..89633da4c091a 100644 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java @@ -24,6 +24,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import com.microsoft.azure.keyvault.models.JsonWebKeyType; import org.apache.commons.codec.binary.Base64; import org.junit.After; import org.junit.AfterClass; @@ -79,7 +80,7 @@ public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, Exec { try { // Create a key on a vault. - CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); + CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build(); ServiceResponse response = keyVaultClient.createKey(request); KeyBundle bundle = response != null ? response.getBody() : null; @@ -125,7 +126,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret128Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret(request).getBody(); if ( secretBundle != null ) { diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java index e6932d917cda1..5a4bc5759cf9b 100644 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java @@ -8,6 +8,7 @@ import java.util.concurrent.ExecutionException; import javax.crypto.Cipher; +import com.microsoft.azure.keyvault.models.JsonWebKeyType; import org.apache.commons.codec.binary.Base64; import org.junit.After; import org.junit.AfterClass; @@ -79,7 +80,7 @@ public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, Exec { try { // Create a key on a vault. - CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); + CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build(); KeyBundle keyBundle = keyVaultClient.createKey(request).getBody(); try diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 313cc75af9826..97ce366d9f094 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -6,14 +6,12 @@ package com.microsoft.azure.keyvault; -import java.io.IOException; -import java.util.List; - import com.google.common.base.Joiner; import com.microsoft.azure.AzureClient; import com.microsoft.azure.ListOperationCallback; -import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; +import com.microsoft.azure.RestClient; +import com.microsoft.azure.keyvault.implementation.KeyVaultClientImpl; import com.microsoft.azure.keyvault.models.BackupKeyResult; import com.microsoft.azure.keyvault.models.CertificateBundle; import com.microsoft.azure.keyvault.models.CertificateIssuerItem; @@ -29,7 +27,6 @@ import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyResult; -import com.microsoft.azure.keyvault.models.PageImpl; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.models.SecretItem; import com.microsoft.azure.keyvault.requests.CreateCertificateRequest; @@ -45,14 +42,11 @@ import com.microsoft.azure.keyvault.requests.UpdateCertificateRequest; import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; -import com.microsoft.azure.RestClient; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.credentials.ServiceClientCredentials; - import okhttp3.ResponseBody; -import retrofit2.Call; import retrofit2.Response; import retrofit2.http.GET; import retrofit2.http.Header; @@ -62,6 +56,9 @@ import rx.Observable; import rx.functions.Func1; +import java.io.IOException; +import java.util.List; + /** * Initializes a new instance of the KeyVaultClient class. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java similarity index 99% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java index 86290ba76c513..2826f898686a0 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java @@ -6,7 +6,7 @@ * Code generated by Microsoft (R) AutoRest Code Generator. */ -package com.microsoft.azure.keyvault; +package com.microsoft.azure.keyvault.implementation; import com.google.common.base.Joiner; import com.google.common.reflect.TypeToken; @@ -14,6 +14,7 @@ import com.microsoft.azure.AzureServiceCall; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.AzureServiceResponseBuilder; +import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.models.BackupKeyResult; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificateBundle; @@ -82,7 +83,7 @@ /** * Initializes a new instance of the KeyVaultClientImpl class. */ -public final class KeyVaultClientImpl extends AzureServiceClient implements KeyVaultClient { +public final class KeyVaultClientImpl extends AzureServiceClient { /** The Retrofit service to perform REST calls. */ private KeyVaultClientService service; /** the {@link AzureClient} used for long running operations. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java index 22d728473cd88..0c8ed5961262a 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java @@ -8,7 +8,15 @@ package com.microsoft.azure.keyvault.models; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.CertificateIdentifier; +import com.microsoft.azure.keyvault.KeyIdentifier; +import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.rest.Base64Url; + +import java.io.IOException; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; @@ -194,4 +202,50 @@ public CertificateBundle withTags(Map tags) { return this; } + /** + * The certificate identifier. + * @return certificate identifier + */ + public CertificateIdentifier certificateIdentifier() { + if (id() == null || id().isEmpty()) { + return null; + } + return new CertificateIdentifier(id()); + } + + /** + * The secret identifier. + * @return secret identifier + */ + public SecretIdentifier secretIdentifier() { + if (sid() == null || sid().isEmpty()) { + return null; + } + return new SecretIdentifier(sid()); + } + + /** + * The key identifier. + * @return key identifier + */ + public KeyIdentifier keyIdentifier() { + if (kid() == null || kid().isEmpty()) { + return null; + } + return new KeyIdentifier(kid()); + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java index d306cdf04cf5d..11cb636e6fe09 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java @@ -9,6 +9,12 @@ package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.CertificateOperationIdentifier; + +import java.io.IOException; /** * A certificate operation is returned in case of async requests. @@ -234,4 +240,28 @@ public CertificateOperation withRequestId(String requestId) { return this; } + /** + * The certificate operation identifier. + * @return the identifier value + */ + public CertificateOperationIdentifier certificateOperationIdentifier() { + if (id() == null || id().isEmpty()) { + return null; + } + return new CertificateOperationIdentifier(id()); + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java index 427957894b10b..72653a0d66efa 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -9,6 +9,12 @@ package com.microsoft.azure.keyvault.models; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.IssuerIdentifier; + +import java.io.IOException; /** * The issuer for Key Vault certificate. @@ -130,4 +136,28 @@ public IssuerBundle withAttributes(IssuerAttributes attributes) { return this; } + /** + * The issuer identifier. + * @return identifier for issuer + */ + public IssuerIdentifier issuerIdentifier() { + if (id() == null || id().isEmpty()) { + return null; + } + return new IssuerIdentifier(id()); + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java index a1df07c01c11d..325b1c2898d34 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java @@ -8,9 +8,26 @@ package com.microsoft.azure.keyvault.models; -import java.util.List; -import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.rest.Base64Url; + +import java.io.IOException; +import java.math.BigInteger; +import java.security.GeneralSecurityException; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.interfaces.RSAPrivateCrtKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.RSAPrivateCrtKeySpec; +import java.security.spec.RSAPrivateKeySpec; +import java.security.spec.RSAPublicKeySpec; +import java.util.Arrays; +import java.util.List; /** * As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18. @@ -32,7 +49,7 @@ public class JsonWebKey { * The keyOps property. */ @JsonProperty(value = "key_ops") - private List keyOps; + private List keyOps; /** * RSA modulus. @@ -131,7 +148,7 @@ public JsonWebKey withKty(JsonWebKeyType kty) { * * @return the keyOps value */ - public List keyOps() { + public List keyOps() { return this.keyOps; } @@ -141,7 +158,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the JsonWebKey object itself. */ - public JsonWebKey withKeyOps(List keyOps) { + public JsonWebKey withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } @@ -416,4 +433,169 @@ public JsonWebKey withT(byte[] t) { return this; } + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + /** + * Get the RSA public key spec value. + * + * @return the RSA public key spec value + */ + private RSAPublicKeySpec getRSAPublicKeySpec() { + + return new RSAPublicKeySpec(toBigInteger(n()), toBigInteger(e())); + } + + /** + * Get the RSA private key spec value. + * + * @return the RSA private key spec value + */ + private RSAPrivateKeySpec getRSAPrivateKeySpec() { + + return new RSAPrivateCrtKeySpec(toBigInteger(n()), toBigInteger(e()), toBigInteger(d()), toBigInteger(p()), + toBigInteger(q()), toBigInteger(dp()), toBigInteger(dq()), toBigInteger(qi())); + } + + /** + * Get the RSA public key value. + * + * @return the RSA public key value + */ + private PublicKey getRSAPublicKey() { + + try { + RSAPublicKeySpec publicKeySpec = getRSAPublicKeySpec(); + KeyFactory factory = KeyFactory.getInstance("RSA"); + + return factory.generatePublic(publicKeySpec); + } catch (GeneralSecurityException e) { + throw new IllegalStateException(e); + } + } + + /** + * Get the RSA private key value. + * + * @return the RSA private key value + */ + private PrivateKey getRSAPrivateKey() { + + try { + RSAPrivateKeySpec privateKeySpec = getRSAPrivateKeySpec(); + KeyFactory factory = KeyFactory.getInstance("RSA"); + + return factory.generatePrivate(privateKeySpec); + } catch (GeneralSecurityException e) { + throw new IllegalStateException(e); + } + } + + /** + * Verifies if the key is an RSA key. + */ + private void checkRSACompatible() { + if (!JsonWebKeyType.RSA.equals(kty()) && !JsonWebKeyType.RSA_HSM.equals(kty())) { + throw new UnsupportedOperationException("Not an RSA key"); + } + } + + private static byte[] toByteArray(BigInteger n) { + byte[] result = n.toByteArray(); + if (result[0] == 0) { + // The leading zero is used to let the number positive. Since RSA + // parameters are always positive, we remove it. + return Arrays.copyOfRange(result, 1, result.length); + } + return result; + } + + private static BigInteger toBigInteger(byte[] b) { + if (b[0] < 0) { + // RSA parameters are always positive numbers, so if the first byte + // is negative, we need to add a leading zero + // to make the entire BigInteger positive. + byte[] temp = new byte[1 + b.length]; + System.arraycopy(b, 0, temp, 1, b.length); + b = temp; + } + return new BigInteger(b); + } + + /** + * Converts RSA key pair to JSON web key. + * @param keyPair RSA key pair + * @return the JSON web key, converted from RSA key pair. + */ + public static JsonWebKey fromRSA(KeyPair keyPair) { + + RSAPrivateCrtKey privateKey = (RSAPrivateCrtKey) keyPair.getPrivate(); + JsonWebKey key = null; + + if (privateKey != null) { + + key = new JsonWebKey() + .withKty(JsonWebKeyType.RSA) + .withN(toByteArray(privateKey.getModulus())) + .withE(toByteArray(privateKey.getPublicExponent())) + .withD(toByteArray(privateKey.getPrivateExponent())) + .withP(toByteArray(privateKey.getPrimeP())) + .withQ(toByteArray(privateKey.getPrimeQ())) + .withDp(toByteArray(privateKey.getPrimeExponentP())) + .withDq(toByteArray(privateKey.getPrimeExponentQ())) + .withQi(toByteArray(privateKey.getCrtCoefficient())); + } else { + + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + + key = new JsonWebKey() + .withKty(JsonWebKeyType.RSA) + .withN(toByteArray(publicKey.getModulus())) + .withE(toByteArray(publicKey.getPublicExponent())) + .withD(null) + .withP(null) + .withQ(null) + .withDp(null) + .withDq(null) + .withQi(null); + } + + return key; + } + + /** + * Converts JSON web key to RSA key pair. + * @return RSA key pair + */ + public KeyPair toRSA() { + return this.toRSA(false); + } + + /** + * Converts JSON web key to RSA key pair and include the private key if set to true. + * @param includePrivateParameters true if the RSA key pair should include the private key. False otherwise. + * @return RSA key pair + */ + public KeyPair toRSA(boolean includePrivateParameters) { + + // Must be RSA + checkRSACompatible(); + + if (includePrivateParameters) { + return new KeyPair(getRSAPublicKey(), getRSAPrivateKey()); + } else { + return new KeyPair(getRSAPublicKey(), null); + } + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index 16ce789c2d11c..2054fbfc7366c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -8,6 +8,12 @@ package com.microsoft.azure.keyvault.models; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.KeyIdentifier; + +import java.io.IOException; import java.util.Map; /** @@ -89,4 +95,28 @@ public KeyBundle withTags(Map tags) { return this; } + /** + * The key identifier. + * @return identifier for the key + */ + public KeyIdentifier keyIdentifier() { + if (key() == null || key().kid() == null || key().kid().length() == 0) { + return null; + } + return new KeyIdentifier(key().kid()); + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index c69a1d61bbbee..23e5d5b6c5ed8 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -8,6 +8,12 @@ package com.microsoft.azure.keyvault.models; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.SecretIdentifier; + +import java.io.IOException; import java.util.Map; /** @@ -164,4 +170,28 @@ public SecretBundle withKid(String kid) { return this; } + /** + * the secret identifier. + * @return The Identifier value + */ + public SecretIdentifier secretIdentifier() { + if (id() == null || id().length() == 0) { + return null; + } + return new SecretIdentifier(id()); + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java index 8fb02162ff3da..f8a1313d0839c 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java @@ -5,6 +5,7 @@ import java.util.Map; import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.models.JsonWebKeyOperation; import com.microsoft.azure.keyvault.models.KeyAttributes; /** @@ -109,7 +110,7 @@ private ImportKeyRequest(Builder builder) { .withD(builder.key.d()).withP(builder.key.p()).withQ(builder.key.q()).withDp(builder.key.dp()) .withDq(builder.key.dq()).withQi(builder.key.qi()).withK(builder.key.k()).withT(builder.key.t()); if (builder.key.keyOps() != null) { - key.withKeyOps(new ArrayList(builder.key.keyOps())); + key.withKeyOps(new ArrayList(builder.key.keyOps())); } } else { key = null; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java deleted file mode 100644 index 96ee1a2d303e8..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.webkey; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * Supported JsonWebKey Algorithms. - */ -public final class JsonWebKeyEncryptionAlgorithm { - - /** - * The 'RSA-OAEP' algorithm. - */ - public static final String RSAOAEP = "RSA-OAEP"; - - /** - * The 'RSA1_5' algorithm. - */ - public static final String RSA15 = "RSA1_5"; - - /** - * All the JWK encryption algorithms. - */ - public static final List ALL_ALGORITHMS = - Collections.unmodifiableList( - Arrays.asList(new String[] {RSA15, RSAOAEP})); - - private JsonWebKeyEncryptionAlgorithm() { - // not instantiable - } - -} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java deleted file mode 100644 index 50360fee81496..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.webkey; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * Supported JsonWebKey operations. - */ -public final class JsonWebKeyOperation { - - /** - * Encrypt operation. - */ - public static final String ENCRYPT = "encrypt"; - - /** - * Decrypt operation. - */ - public static final String DECRYPT = "decrypt"; - - /** - * Sign operation. - */ - public static final String SIGN = "sign"; - - /** - * Verify operation. - */ - public static final String VERIFY = "verify"; - - /** - * WrapKey operation. - */ - public static final String WRAP = "wrapKey"; - - /** - * UnwrapKey operation. - */ - public static final String UNWRAP = "unwrapKey"; - - /** - * All JWK operations. - */ - public static final List ALL_OPERATIONS = - Collections.unmodifiableList( - Arrays.asList(new String[] {ENCRYPT, DECRYPT, SIGN, VERIFY, WRAP, UNWRAP })); - - private JsonWebKeyOperation() { - // not instantiable - } - -} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java deleted file mode 100644 index fa9737305d268..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.webkey; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * Supported JsonWebKey Algorithms. - */ -public final class JsonWebKeySignatureAlgorithm { - - /** - * The 'RS256' algorithm. - */ - public static final String RS256 = "RS256"; - - /** - * The 'RS384' algorithm. - */ - public static final String RS384 = "RS384"; - - /** - * The 'RS512' algorithm. - */ - public static final String RS512 = "RS512"; - - /** - * The 'RSNULL' algorithm. - */ - public static final String RSNULL = "RSNULL"; - - /** - * All JWK algorithms. - */ - public static final List ALL_ALGORITHMS = - Collections.unmodifiableList( - Arrays.asList(new String[] {RS256, RS384, RS512, RSNULL})); - - private JsonWebKeySignatureAlgorithm() { - // not instantiable - } -} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java deleted file mode 100644 index a04d9b3c40540..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.webkey; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * Supported JsonWebKey key types (kty). - */ -public final class JsonWebKeyType { - - /** - * The Elliptic Curve 'EC' key type. - */ - public static final String EC = "EC"; - - /** - * The 'RSA' key type. - */ - public static final String RSA = "RSA"; - - /** - * The 'RSA-HSM' key type. - */ - public static final String RSAHSM = "RSA-HSM"; - - /** - * The Octet 'oct' key type. - */ - public static final String OCT = "oct"; - - /** - * All JWK key types. - */ - public static final List ALL_TYPES = - Collections.unmodifiableList( - Arrays.asList(new String[] {EC, RSA, RSAHSM, OCT})); - - private JsonWebKeyType() { - // not instantiable - } -} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java deleted file mode 100644 index 30b69d136c2b7..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. - -/** - * This package contains the classes for KeyVaultClient. Performs cryptographic - * key operations and vault operations against the Key Vault service. - */ -package com.microsoft.azure.keyvault.webkey; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 08ff519858b73..b4155c00d1b08 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -33,6 +33,10 @@ import java.util.Random; import javax.crypto.Cipher; +import com.microsoft.azure.keyvault.models.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.models.JsonWebKeyOperation; +import com.microsoft.azure.keyvault.models.JsonWebKeySignatureAlgorithm; +import com.microsoft.azure.keyvault.models.JsonWebKeyType; import org.joda.time.DateTime; import org.junit.Assert; import org.junit.Test; @@ -48,10 +52,6 @@ import com.microsoft.azure.keyvault.requests.ImportKeyRequest; import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; import com.microsoft.azure.keyvault.models.JsonWebKey; -import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; -import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; -import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; -import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; public class KeyOperationsTest extends KeyVaultClientIntegrationTestBase { @@ -64,15 +64,15 @@ public void transparentAuthentication() throws Exception { // Create a key on a vault. { - KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, "RSA", null); + KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null); } // Create a key on a different vault. Key Vault Data Plane returns 401, // which must be transparently handled by KeyVaultCredentials. { - KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, "RSA", null); + KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null); } } @@ -98,7 +98,7 @@ private void checkImportOperation(KeyBundle keyBundle, boolean importToHardware) .Builder(getVaultUri(), KEY_NAME, keyBundle.key()) .withHsm(importToHardware) .build()).getBody(); - validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? "RSA-HSM" : "RSA", importedJwk.keyOps()); + validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? JsonWebKeyType.RSA_HSM : JsonWebKeyType.RSA, importedJwk.keyOps()); checkEncryptDecryptSequence(importedJwk, importResultBundle); } @@ -111,7 +111,7 @@ private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle impor // Encrypt in the service. { - KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); } @@ -136,7 +136,7 @@ private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle impor // Decrypt in the service. { - KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA15, cipherText).getBody(); + KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA1_5, cipherText).getBody(); byte[] beforeEncrypt = plainText; byte[] afterDecrypt = result.result(); @@ -150,8 +150,8 @@ public void crudOperations() throws Exception { KeyBundle createdBundle; { // Create key - createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null); + createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null); } // Key identifier. @@ -195,7 +195,7 @@ public void crudOperations() throws Exception { .withMonthOfYear(2) .withDayOfMonth(1) .withYear(2050)); - List key_ops = Arrays.asList("encrypt", "decrypt"); + List key_ops = Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT); Map tags = new HashMap(); tags.put("foo", "baz"); createdBundle.key().withKeyOps(key_ops); @@ -224,7 +224,7 @@ public void crudOperations() throws Exception { .withMonthOfYear(2) .withDayOfMonth(1) .withYear(2000)); - List key_ops = Arrays.asList("sign", "verify"); + List key_ops = Arrays.asList(JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY); createdBundle.key().withKeyOps(key_ops); Map tags = new HashMap(); tags.put("foo", "baz"); @@ -268,9 +268,9 @@ public void backupRestore() throws Exception { // Creates a key { createdBundle = keyVaultClient.createKey( - new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA") + new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA) .build()).getBody(); - validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null); } // Creates a backup of key. @@ -300,7 +300,7 @@ public void listKeys() throws Exception { int failureCount = 0; for (;;) { try { - KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, "RSA").build()).getBody(); + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, JsonWebKeyType.RSA).build()).getBody(); KeyIdentifier kid = new KeyIdentifier(createdBundle.key().kid()); keys.add(kid.baseIdentifier()); break; @@ -349,7 +349,7 @@ public void listKeyVersions() throws Exception { int failureCount = 0; for (;;) { try { - KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); keys.add(createdBundle.key().kid()); break; } catch (KeyVaultErrorException e) { @@ -400,19 +400,19 @@ public void encryptDecryptOperations() throws Exception { // encrypt and decrypt using kid WO version { - result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } // encrypt and decrypt using full kid { - result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } } @@ -432,19 +432,19 @@ public void wrapUnwrapOperations() throws Exception { // wrap and unwrap using kid WO version { - result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } // wrap and unwrap using full kid { - result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } } @@ -492,7 +492,7 @@ private static JsonWebKey importTestKey() throws Exception { JsonWebKey key = JsonWebKey.fromRSA(getTestKeyMaterial()); key.withKty(JsonWebKeyType.RSA); - key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT, JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY, JsonWebKeyOperation.WRAP, JsonWebKeyOperation.UNWRAP)); + key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT, JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY, JsonWebKeyOperation.WRAP_KEY, JsonWebKeyOperation.UNWRAP_KEY)); keyBundle = keyVaultClient.importKey( new ImportKeyRequest @@ -500,7 +500,7 @@ private static JsonWebKey importTestKey() throws Exception { .withHsm(false) .build()).getBody(); - validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, "RSA", null); + validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null); return keyBundle.key(); } @@ -521,12 +521,12 @@ private static KeyPair getWellKnownKey() throws Exception { KeySpec publicKeySpec = new RSAPublicKeySpec(modulus, publicExponent); KeySpec privateKeySpec = new RSAPrivateCrtKeySpec(modulus, publicExponent, privateExponent, primeP, primeQ, primeExponentP, primeExponentQ, crtCoefficient); - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + KeyFactory keyFactory = KeyFactory.getInstance(JsonWebKeyType.RSA.toString()); return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); } - private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops) throws Exception { + private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, JsonWebKeyType kty, List key_ops) throws Exception { String prefix = vault + "/keys/" + keyName + "/"; String kid = bundle.key().kid(); Assert.assertTrue( From 72d6c5ecab586924924873347ce0f9c7aff9371c Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Sat, 27 Aug 2016 15:21:49 -0700 Subject: [PATCH 19/56] Fix checkstyle errors --- .../implementation/KeyVaultClientImpl.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java index 2826f898686a0..5169594cfa830 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java @@ -14,7 +14,10 @@ import com.microsoft.azure.AzureServiceCall; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.AzureServiceResponseBuilder; -import com.microsoft.azure.keyvault.KeyVaultClient; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.RestClient; import com.microsoft.azure.keyvault.models.BackupKeyResult; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificateBundle; @@ -52,33 +55,30 @@ import com.microsoft.azure.keyvault.models.SecretItem; import com.microsoft.azure.keyvault.models.SecretSetParameters; import com.microsoft.azure.keyvault.models.SecretUpdateParameters; -import com.microsoft.azure.ListOperationCallback; -import com.microsoft.azure.Page; -import com.microsoft.azure.PagedList; -import com.microsoft.azure.RestClient; -import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.Validator; -import java.io.IOException; -import java.util.List; -import java.util.Map; +import com.microsoft.rest.credentials.ServiceClientCredentials; import okhttp3.ResponseBody; +import retrofit2.Response; import retrofit2.http.Body; import retrofit2.http.GET; +import retrofit2.http.HTTP; import retrofit2.http.Header; import retrofit2.http.Headers; -import retrofit2.http.HTTP; import retrofit2.http.PATCH; -import retrofit2.http.Path; import retrofit2.http.POST; import retrofit2.http.PUT; +import retrofit2.http.Path; import retrofit2.http.Query; -import retrofit2.Response; -import rx.functions.Func1; import rx.Observable; +import rx.functions.Func1; + +import java.io.IOException; +import java.util.List; +import java.util.Map; /** * Initializes a new instance of the KeyVaultClientImpl class. From 8b00b653892388f8c2928e9294a1003abacf24f3 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 29 Aug 2016 16:34:45 -0700 Subject: [PATCH 20/56] Revert keyvault changes --- azure-keyvault-core/pom.xml | 0 .../microsoft/azure/keyvault/core/IKey.java | 0 .../azure/keyvault/core/IKeyResolver.java | 0 .../azure/keyvault/core/package-info.java | 0 azure-keyvault-cryptography/pom.xml | 0 .../keyvault/cryptography/Algorithm.java | 0 .../cryptography/AlgorithmResolver.java | 0 .../AsymmetricEncryptionAlgorithm.java | 0 .../AsymmetricSignatureAlgorithm.java | 0 .../cryptography/EncryptionAlgorithm.java | 0 .../IAuthenticatedCryptoTransform.java | 0 .../cryptography/ICryptoTransform.java | 0 .../cryptography/KeyWrapAlgorithm.java | 0 .../azure/keyvault/cryptography/RsaKey.java | 0 .../cryptography/SignatureAlgorithm.java | 0 .../azure/keyvault/cryptography/Strings.java | 0 .../SymmetricEncryptionAlgorithm.java | 0 .../keyvault/cryptography/SymmetricKey.java | 0 .../cryptography/algorithms/Aes128Cbc.java | 0 .../algorithms/Aes128CbcHmacSha256.java | 0 .../cryptography/algorithms/Aes192Cbc.java | 0 .../algorithms/Aes192CbcHmacSha384.java | 0 .../cryptography/algorithms/Aes256Cbc.java | 0 .../algorithms/Aes256CbcHmacSha512.java | 0 .../cryptography/algorithms/AesCbc.java | 0 .../algorithms/AesCbcHmacSha2.java | 0 .../cryptography/algorithms/AesKw.java | 0 .../cryptography/algorithms/AesKw128.java | 0 .../cryptography/algorithms/AesKw192.java | 0 .../cryptography/algorithms/AesKw256.java | 0 .../cryptography/algorithms/Rsa15.java | 0 .../algorithms/RsaEncryption.java | 0 .../cryptography/algorithms/RsaOaep.java | 0 .../cryptography/algorithms/package.html | 0 .../azure/keyvault/cryptography/package.html | 0 .../test/AesCbcBCProviderTest.java | 0 .../test/AesCbcDefaultProviderTest.java | 0 .../cryptography/test/AesCbcHmacShaTest.java | 0 .../test/AesKwBCProviderTest.java | 0 .../test/AesKwDefaultProviderTest.java | 0 .../cryptography/test/RsaKeyTest.java | 0 .../test/SymmetricKeyBCProviderTest.java | 0 .../test/SymmetricKeyDefaultProviderTest.java | 0 azure-keyvault-extensions/pom.xml | 0 .../extensions/AggregateKeyResolver.java | 0 .../extensions/CachingKeyResolver.java | 0 .../keyvault/extensions/KeyVaultKey.java | 24 +- .../extensions/KeyVaultKeyResolver.java | 0 .../azure/keyvault/extensions/Strings.java | 0 .../azure/keyvault/extensions/package.html | 0 .../test/CachingKeyResolverTest.java | 0 .../KeyVaultClientIntegrationTestBase.java | 0 .../KeyVaultKeyResolverBCProviderTest.java | 5 +- ...eyVaultKeyResolverDefaultProviderTest.java | 3 +- azure-keyvault/pom.xml | 0 .../azure/keyvault/CertificateIdentifier.java | 0 .../CertificateOperationIdentifier.java | 0 .../azure/keyvault/IssuerIdentifier.java | 0 .../azure/keyvault/KeyIdentifier.java | 0 .../azure/keyvault/KeyVaultClient.java | 517 +- .../KeyVaultClientImpl.java | 4870 +++++++++-------- .../azure/keyvault/ObjectIdentifier.java | 0 .../azure/keyvault/SecretIdentifier.java | 0 .../authentication/ChallengeCache.java | 0 .../authentication/KeyVaultCredentials.java | 0 .../keyvault/authentication/package-info.java | 0 .../keyvault/implementation/package-info.java | 11 - .../azure/keyvault/models/Action.java | 4 +- .../azure/keyvault/models/ActionType.java | 4 +- .../keyvault/models/AdministratorDetails.java | 4 +- .../azure/keyvault/models/Attributes.java | 4 +- .../keyvault/models/BackupKeyResult.java | 4 +- .../models/CertificateAttributes.java | 4 +- .../keyvault/models/CertificateBundle.java | 10 +- .../models/CertificateCreateParameters.java | 4 +- .../models/CertificateImportParameters.java | 4 +- .../models/CertificateIssuerItem.java | 4 +- .../keyvault/models/CertificateItem.java | 19 +- .../models/CertificateMergeParameters.java | 4 +- .../keyvault/models/CertificateOperation.java | 8 +- .../keyvault/models/CertificatePolicy.java | 4 +- .../models/CertificateUpdateParameters.java | 4 +- .../azure/keyvault/models/Contact.java | 4 +- .../azure/keyvault/models/Contacts.java | 4 +- .../azure/keyvault/models/Error.java | 4 +- .../keyvault/models/IssuerAttributes.java | 4 +- .../azure/keyvault/models/IssuerBundle.java | 8 +- .../keyvault/models/IssuerCredentials.java | 4 +- .../keyvault/models/IssuerReference.java | 4 +- .../azure/keyvault/models/JsonWebKey.java | 33 +- .../models/JsonWebKeyEncryptionAlgorithm.java | 59 - .../keyvault/models/JsonWebKeyOperation.java | 71 - .../models/JsonWebKeySignatureAlgorithm.java | 65 - .../azure/keyvault/models/JsonWebKeyType.java | 65 - .../azure/keyvault/models/KeyAttributes.java | 4 +- .../azure/keyvault/models/KeyBundle.java | 10 +- .../keyvault/models/KeyCreateParameters.java | 19 +- .../keyvault/models/KeyImportParameters.java | 4 +- .../azure/keyvault/models/KeyItem.java | 19 +- .../keyvault/models/KeyOperationResult.java | 4 +- .../models/KeyOperationsParameters.java | 10 +- .../azure/keyvault/models/KeyProperties.java | 4 +- .../keyvault/models/KeyRestoreParameters.java | 4 +- .../keyvault/models/KeySignParameters.java | 10 +- .../keyvault/models/KeyUpdateParameters.java | 10 +- .../azure/keyvault/models/KeyUsageType.java | 4 +- .../azure/keyvault/models/KeyVaultError.java | 4 +- .../models/KeyVaultErrorException.java | 4 +- .../keyvault/models/KeyVerifyParameters.java | 10 +- .../keyvault/models/KeyVerifyResult.java | 4 +- .../azure/keyvault/models/LifetimeAction.java | 4 +- .../keyvault/models/OrganizationDetails.java | 4 +- .../azure/keyvault/models/PageImpl.java | 4 +- ...endingCertificateSigningRequestResult.java | 4 +- .../keyvault/models/SecretAttributes.java | 4 +- .../azure/keyvault/models/SecretBundle.java | 11 +- .../azure/keyvault/models/SecretItem.java | 19 +- .../keyvault/models/SecretProperties.java | 4 +- .../keyvault/models/SecretSetParameters.java | 4 +- .../models/SecretUpdateParameters.java | 4 +- .../models/SubjectAlternativeNames.java | 4 +- .../azure/keyvault/models/Trigger.java | 4 +- .../models/X509CertificateProperties.java | 4 +- .../azure/keyvault/models/package-info.java | 4 +- .../azure/keyvault/package-info.java | 4 +- .../requests/CreateCertificateRequest.java | 0 .../keyvault/requests/CreateKeyRequest.java | 20 +- .../requests/ImportCertificateRequest.java | 0 .../keyvault/requests/ImportKeyRequest.java | 3 +- .../requests/MergeCertificateRequest.java | 0 .../requests/SetCertificateIssuerRequest.java | 0 .../keyvault/requests/SetSecretRequest.java | 0 .../UpdateCertificateIssuerRequest.java | 0 .../UpdateCertificateOperationRequest.java | 0 .../UpdateCertificatePolicyRequest.java | 0 .../requests/UpdateCertificateRequest.java | 0 .../keyvault/requests/UpdateKeyRequest.java | 11 +- .../requests/UpdateSecretRequest.java | 0 .../azure/keyvault/requests/package-info.java | 0 .../webkey/JsonWebKeyEncryptionAlgorithm.java | 51 + .../keyvault/webkey/JsonWebKeyOperation.java | 71 + .../webkey/JsonWebKeySignatureAlgorithm.java | 60 + .../azure/keyvault/webkey/JsonWebKeyType.java | 60 + .../azure/keyvault/webkey/package-info.java | 9 + .../test/CertificateOperationsTest.java | 0 .../keyvault/test/KeyOperationsTest.java | 62 +- .../KeyVaultClientIntegrationTestBase.java | 0 .../keyvault/test/SecretOperationsTest.java | 0 148 files changed, 3360 insertions(+), 3033 deletions(-) mode change 100644 => 100755 azure-keyvault-core/pom.xml mode change 100644 => 100755 azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java mode change 100644 => 100755 azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java mode change 100644 => 100755 azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/package-info.java mode change 100644 => 100755 azure-keyvault-cryptography/pom.xml mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html mode change 100644 => 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html mode change 100644 => 100755 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java mode change 100644 => 100755 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java mode change 100644 => 100755 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java mode change 100644 => 100755 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java mode change 100644 => 100755 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java mode change 100644 => 100755 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java mode change 100644 => 100755 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java mode change 100644 => 100755 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java mode change 100644 => 100755 azure-keyvault-extensions/pom.xml mode change 100644 => 100755 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java mode change 100644 => 100755 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java mode change 100644 => 100755 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java mode change 100644 => 100755 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java mode change 100644 => 100755 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java mode change 100644 => 100755 azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/package.html mode change 100644 => 100755 azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java mode change 100644 => 100755 azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java mode change 100644 => 100755 azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java mode change 100644 => 100755 azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java mode change 100644 => 100755 azure-keyvault/pom.xml mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java rename azure-keyvault/src/main/java/com/microsoft/azure/keyvault/{implementation => }/KeyVaultClientImpl.java (52%) mode change 100644 => 100755 mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/package-info.java delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyEncryptionAlgorithm.java delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyOperation.java delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeySignatureAlgorithm.java delete mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyType.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java mode change 100644 => 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/package-info.java create mode 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java create mode 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java create mode 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java create mode 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java create mode 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java mode change 100644 => 100755 azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java mode change 100644 => 100755 azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java mode change 100644 => 100755 azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java mode change 100644 => 100755 azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml old mode 100644 new mode 100755 diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKeyResolver.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/package-info.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/package-info.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml old mode 100644 new mode 100755 diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/AggregateKeyResolver.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/CachingKeyResolver.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java old mode 100644 new mode 100755 index 498c3e85e3ef0..485fa3a0b797f --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -18,6 +18,11 @@ package com.microsoft.azure.keyvault.extensions; +import java.io.IOException; +import java.security.NoSuchAlgorithmException; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.commons.lang3.tuple.Triple; + import com.google.common.base.Function; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; @@ -25,18 +30,11 @@ import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.cryptography.RsaKey; import com.microsoft.azure.keyvault.cryptography.Strings; -import com.microsoft.azure.keyvault.models.JsonWebKey; -import com.microsoft.azure.keyvault.models.JsonWebKeyEncryptionAlgorithm; -import com.microsoft.azure.keyvault.models.JsonWebKeySignatureAlgorithm; -import com.microsoft.azure.keyvault.models.JsonWebKeyType; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyOperationResult; +import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; import com.microsoft.rest.ServiceResponse; -import org.apache.commons.lang3.tuple.Pair; -import org.apache.commons.lang3.tuple.Triple; - -import java.io.IOException; -import java.security.NoSuchAlgorithmException; /** * The key vault key that performs cryptography operations. @@ -99,7 +97,7 @@ protected KeyVaultKey(KeyVaultClient client, KeyBundle keyBundle) { if (key.kty().equals(JsonWebKeyType.RSA)) { // The private key is not available for KeyVault keys implementation = new RsaKey(key.kid(), key.toRSA(false)); - } else if (key.kty().equals(JsonWebKeyType.RSA_HSM)) { + } else if (key.kty().equals(JsonWebKeyType.RSAHSM)) { // The private key is not available for KeyVault keys implementation = new RsaKey(key.kid(), key.toRSA(false)); } @@ -172,7 +170,7 @@ public ListenableFuture decryptAsync(byte[] ciphertext, byte[] iv, byte[ ListenableFuture> futureCall = client.decryptAsync( implementation.getKid(), - new JsonWebKeyEncryptionAlgorithm(algorithm), + algorithm, ciphertext, null); return Futures.transform(futureCall, new DecryptResultTransform()); @@ -210,7 +208,7 @@ public ListenableFuture unwrapKeyAsync(byte[] ciphertext, String algorit ListenableFuture> futureCall = client.unwrapKeyAsync( implementation.getKid(), - new JsonWebKeyEncryptionAlgorithm(algorithm), + algorithm, ciphertext, null); return Futures.transform(futureCall, new DecryptResultTransform()); @@ -230,7 +228,7 @@ public ListenableFuture> signAsync(byte[] digest, String al ListenableFuture> futureCall = client.signAsync( implementation.getKid(), - new JsonWebKeySignatureAlgorithm(algorithm), + algorithm, digest, null); return Futures.transform(futureCall, new SignResultTransform(algorithm)); diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/package.html b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/package.html old mode 100644 new mode 100755 diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/CachingKeyResolverTest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultClientIntegrationTestBase.java old mode 100644 new mode 100755 diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java old mode 100644 new mode 100755 index 89633da4c091a..58948e52d9bb2 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java @@ -24,7 +24,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import com.microsoft.azure.keyvault.models.JsonWebKeyType; import org.apache.commons.codec.binary.Base64; import org.junit.After; import org.junit.AfterClass; @@ -80,7 +79,7 @@ public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, Exec { try { // Create a key on a vault. - CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build(); + CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); ServiceResponse response = keyVaultClient.createKey(request); KeyBundle bundle = response != null ? response.getBody() : null; @@ -126,7 +125,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret128Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret(request).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); if ( secretBundle != null ) { diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java old mode 100644 new mode 100755 index 5a4bc5759cf9b..e6932d917cda1 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java @@ -8,7 +8,6 @@ import java.util.concurrent.ExecutionException; import javax.crypto.Cipher; -import com.microsoft.azure.keyvault.models.JsonWebKeyType; import org.apache.commons.codec.binary.Base64; import org.junit.After; import org.junit.AfterClass; @@ -80,7 +79,7 @@ public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, Exec { try { // Create a key on a vault. - CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build(); + CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); KeyBundle keyBundle = keyVaultClient.createKey(request).getBody(); try diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java old mode 100644 new mode 100755 index 97ce366d9f094..52cbba1b6abbe --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -1,17 +1,18 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. + * license information. */ package com.microsoft.azure.keyvault; +import java.io.IOException; +import java.util.List; + import com.google.common.base.Joiner; import com.microsoft.azure.AzureClient; import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.PagedList; -import com.microsoft.azure.RestClient; -import com.microsoft.azure.keyvault.implementation.KeyVaultClientImpl; import com.microsoft.azure.keyvault.models.BackupKeyResult; import com.microsoft.azure.keyvault.models.CertificateBundle; import com.microsoft.azure.keyvault.models.CertificateIssuerItem; @@ -20,13 +21,12 @@ import com.microsoft.azure.keyvault.models.CertificatePolicy; import com.microsoft.azure.keyvault.models.Contacts; import com.microsoft.azure.keyvault.models.IssuerBundle; -import com.microsoft.azure.keyvault.models.JsonWebKeyEncryptionAlgorithm; -import com.microsoft.azure.keyvault.models.JsonWebKeySignatureAlgorithm; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyItem; import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyResult; +import com.microsoft.azure.keyvault.models.PageImpl; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.models.SecretItem; import com.microsoft.azure.keyvault.requests.CreateCertificateRequest; @@ -42,22 +42,21 @@ import com.microsoft.azure.keyvault.requests.UpdateCertificateRequest; import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; +import com.microsoft.azure.RestClient; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseCallback; import com.microsoft.rest.credentials.ServiceClientCredentials; + import okhttp3.ResponseBody; +import retrofit2.Call; import retrofit2.Response; import retrofit2.http.GET; import retrofit2.http.Header; import retrofit2.http.Headers; import retrofit2.http.Path; import retrofit2.http.Query; -import rx.Observable; -import rx.functions.Func1; - -import java.io.IOException; -import java.util.List; /** * Initializes a new instance of the KeyVaultClient class. @@ -71,7 +70,7 @@ public final class KeyVaultClient { /** * Gets the {@link AzureClient} used for long running operations. - * + * * @return the azure client; */ public AzureClient getAzureClient() { @@ -122,7 +121,7 @@ public int longRunningOperationRetryTimeout() { public void withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { innerKeyVaultClient.withLongRunningOperationRetryTimeout(longRunningOperationRetryTimeout); } - + /** * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. * @@ -140,7 +139,7 @@ public boolean getGenerateClientRequestId() { public void withGenerateClientRequestId(boolean generateClientRequestId) { innerKeyVaultClient.withGenerateClientRequestId(generateClientRequestId); } - + /** * Initializes an instance of KeyVaultClient client. * @@ -181,69 +180,69 @@ private void initializeService() { interface KeyVaultClientService { @Headers({"Content-Type: application/json; charset=utf-8", "Accept: application/pkcs10"}) @GET("certificates/{certificate-name}/pending") - Observable> getPendingCertificateSigningRequest(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getPendingCertificateSigningRequest(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); } - + /** * Creates a new, named, key in the specified vault. * * @param createKeyRequest the grouped properties for creating a key request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createKey(CreateKeyRequest createKeyRequest) + public ServiceResponse createKey(CreateKeyRequest createKeyRequest) throws KeyVaultErrorException, IllegalArgumentException, IOException { return innerKeyVaultClient.createKey( - createKeyRequest.vaultBaseUrl(), - createKeyRequest.keyName(), - createKeyRequest.keyType(), - createKeyRequest.keySize(), - createKeyRequest.keyOperations(), - createKeyRequest.keyAttributes(), - createKeyRequest.tags()); + createKeyRequest.vaultBaseUrl(), + createKeyRequest.keyName(), + createKeyRequest.keyType(), + createKeyRequest.keySize(), + createKeyRequest.keyOperations(), + createKeyRequest.keyAttributes(), + createKeyRequest.tags()); } - + /** * Creates a new, named, key in the specified vault. * * @param createKeyRequest the grouped properties for creating a key request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall createKeyAsync(CreateKeyRequest createKeyRequest, ServiceCallback serviceCallback) { return innerKeyVaultClient.createKeyAsync( - createKeyRequest.vaultBaseUrl(), - createKeyRequest.keyName(), - createKeyRequest.keyType(), - createKeyRequest.keySize(), - createKeyRequest.keyOperations(), - createKeyRequest.keyAttributes(), - createKeyRequest.tags(), + createKeyRequest.vaultBaseUrl(), + createKeyRequest.keyName(), + createKeyRequest.keyType(), + createKeyRequest.keySize(), + createKeyRequest.keyOperations(), + createKeyRequest.keyAttributes(), + createKeyRequest.tags(), serviceCallback); } - + /** * Imports a key into the specified vault. * * @param importKeyRequest the grouped properties for importing a key request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse importKey(ImportKeyRequest importKeyRequest) + public ServiceResponse importKey(ImportKeyRequest importKeyRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.importKey( - importKeyRequest.vaultBaseUrl(), - importKeyRequest.keyName(), - importKeyRequest.key(), - importKeyRequest.isHsm(), - importKeyRequest.keyAttributes(), + importKeyRequest.vaultBaseUrl(), + importKeyRequest.keyName(), + importKeyRequest.key(), + importKeyRequest.isHsm(), + importKeyRequest.keyAttributes(), importKeyRequest.tags()); } @@ -251,18 +250,18 @@ public ServiceResponse importKey(ImportKeyRequest importKeyRequest) * Imports a key into the specified vault. * * @param importKeyRequest the grouped properties for importing a key request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(ImportKeyRequest importKeyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.importKeyAsync( - importKeyRequest.vaultBaseUrl(), - importKeyRequest.keyName(), - importKeyRequest.key(), - importKeyRequest.isHsm(), - importKeyRequest.keyAttributes(), - importKeyRequest.tags(), + importKeyRequest.vaultBaseUrl(), + importKeyRequest.keyName(), + importKeyRequest.key(), + importKeyRequest.isHsm(), + importKeyRequest.keyAttributes(), + importKeyRequest.tags(), serviceCallback); } @@ -276,7 +275,7 @@ public ServiceCall importKeyAsync(ImportKeyRequest importKeyRequest, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) + public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteKey(vaultBaseUrl, keyName); } @@ -297,20 +296,20 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName * Updates the Key Attributes associated with the specified key. * * @param updateKeyRequest the grouped properties for updating a key request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateKey(UpdateKeyRequest updateKeyRequest) + public ServiceResponse updateKey(UpdateKeyRequest updateKeyRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateKey( - updateKeyRequest.vaultBaseUrl(), - updateKeyRequest.keyName(), - updateKeyRequest.keyVersion(), - updateKeyRequest.keyOperations(), - updateKeyRequest.keyAttributes(), + updateKeyRequest.vaultBaseUrl(), + updateKeyRequest.keyName(), + updateKeyRequest.keyVersion(), + updateKeyRequest.keyOperations(), + updateKeyRequest.keyAttributes(), updateKeyRequest.tags()); } @@ -318,21 +317,21 @@ public ServiceResponse updateKey(UpdateKeyRequest updateKeyRequest) * Updates the Key Attributes associated with the specified key. * * @param updateKeyRequest the grouped properties for updating a key request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateKeyAsync(UpdateKeyRequest updateKeyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateKeyAsync( - updateKeyRequest.vaultBaseUrl(), - updateKeyRequest.keyName(), - updateKeyRequest.keyVersion(), - updateKeyRequest.keyOperations(), - updateKeyRequest.keyAttributes(), + updateKeyRequest.vaultBaseUrl(), + updateKeyRequest.keyName(), + updateKeyRequest.keyVersion(), + updateKeyRequest.keyOperations(), + updateKeyRequest.keyAttributes(), updateKeyRequest.tags(), serviceCallback); } - + /** * Retrieves the public portion of a key plus its attributes. * @@ -359,7 +358,7 @@ public ServiceCall getKeyAsync(String keyIdentifier, final ServiceCal KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.getKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); } - + /** * Retrieves the public portion of a key plus its attributes. * @@ -370,7 +369,7 @@ public ServiceCall getKeyAsync(String keyIdentifier, final ServiceCal * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getKey(String vaultBaseUrl, String keyName) + public ServiceResponse getKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, ""); } @@ -386,7 +385,7 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyName) public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getKeyAsync(vaultBaseUrl, keyName, "", serviceCallback); } - + /** * Retrieves the public portion of a key plus its attributes. * @@ -398,7 +397,7 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, f * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) + public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, keyVersion); } @@ -426,7 +425,7 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) + public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName); } @@ -453,7 +452,7 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) + public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName, maxresults); } @@ -480,7 +479,7 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeys(final String vaultBaseUrl) + public ServiceResponse> getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeys(vaultBaseUrl); } @@ -505,7 +504,7 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) + public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeys(vaultBaseUrl, maxresults); } @@ -532,7 +531,7 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final * @throws IllegalArgumentException exception thrown from invalid parameters * @return the BackupKeyResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse backupKey(String vaultBaseUrl, String keyName) + public ServiceResponse backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.backupKey(vaultBaseUrl, keyName); } @@ -559,7 +558,7 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String k * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) + public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.restoreKey(vaultBaseUrl, keyBundleBackup); } @@ -587,7 +586,7 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse encrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) + public ServiceResponse encrypt(String keyIdentifier, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -602,7 +601,7 @@ public ServiceResponse encrypt(String keyIdentifier, JsonWeb * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall encryptAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall encryptAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encryptAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -618,7 +617,7 @@ public ServiceCall encryptAsync(String keyIdentifier, JsonWe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse decrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) + public ServiceResponse decrypt(String keyIdentifier, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -630,10 +629,10 @@ public ServiceResponse decrypt(String keyIdentifier, JsonWeb * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier * @param value the content to be decrypted - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall decryptAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall decryptAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decryptAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -649,7 +648,7 @@ public ServiceCall decryptAsync(String keyIdentifier, JsonWe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse sign(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value) + public ServiceResponse sign(String keyIdentifier, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.sign(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -664,9 +663,9 @@ public ServiceResponse sign(String keyIdentifier, JsonWebKey * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall signAsync(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall signAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); - return innerKeyVaultClient.signAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); + return innerKeyVaultClient.signAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } /** @@ -681,7 +680,7 @@ public ServiceCall signAsync(String keyIdentifier, JsonWebKe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse verify(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) + public ServiceResponse verify(String keyIdentifier, String algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verify(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature); @@ -697,7 +696,7 @@ public ServiceResponse verify(String keyIdentifier, JsonWebKeyS * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall verifyAsync(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { + public ServiceCall verifyAsync(String keyIdentifier, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verifyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature, serviceCallback); } @@ -713,7 +712,7 @@ public ServiceCall verifyAsync(String keyIdentifier, JsonWebKey * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse wrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) + public ServiceResponse wrapKey(String keyIdentifier, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -728,7 +727,7 @@ public ServiceResponse wrapKey(String keyIdentifier, JsonWeb * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall wrapKeyAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall wrapKeyAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -744,7 +743,7 @@ public ServiceCall wrapKeyAsync(String keyIdentifier, JsonWe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse unwrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) + public ServiceResponse unwrapKey(String keyIdentifier, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -759,7 +758,7 @@ public ServiceResponse unwrapKey(String keyIdentifier, JsonW * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall unwrapKeyAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall unwrapKeyAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -768,20 +767,20 @@ public ServiceCall unwrapKeyAsync(String keyIdentifier, Json * Sets a secret in the specified vault. * * @param setSecretRequest the grouped properties for setting a secret request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setSecret(SetSecretRequest setSecretRequest) + public ServiceResponse setSecret(SetSecretRequest setSecretRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setSecret( - setSecretRequest.vaultBaseUrl(), - setSecretRequest.secretName(), - setSecretRequest.value(), - setSecretRequest.tags(), - setSecretRequest.contentType(), + setSecretRequest.vaultBaseUrl(), + setSecretRequest.secretName(), + setSecretRequest.value(), + setSecretRequest.tags(), + setSecretRequest.contentType(), setSecretRequest.secretAttributes()); } @@ -789,17 +788,17 @@ public ServiceResponse setSecret(SetSecretRequest setSecretRequest * Sets a secret in the specified vault. * * @param setSecretRequest the grouped properties for setting a secret request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(SetSecretRequest setSecretRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.setSecretAsync( - setSecretRequest.vaultBaseUrl(), - setSecretRequest.secretName(), - setSecretRequest.value(), - setSecretRequest.tags(), - setSecretRequest.contentType(), + setSecretRequest.vaultBaseUrl(), + setSecretRequest.secretName(), + setSecretRequest.value(), + setSecretRequest.tags(), + setSecretRequest.contentType(), setSecretRequest.secretAttributes(), serviceCallback); } @@ -814,7 +813,7 @@ public ServiceCall setSecretAsync(SetSecretRequest setSecretReques * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) + public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteSecret(vaultBaseUrl, secretName); } @@ -835,19 +834,19 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String s * Updates the attributes associated with the specified secret. * * @param updateSecretRequest the grouped properties for updating a secret request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateSecret(UpdateSecretRequest updateSecretRequest) + public ServiceResponse updateSecret(UpdateSecretRequest updateSecretRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateSecret( - updateSecretRequest.vaultBaseUrl(), - updateSecretRequest.secretName(), + updateSecretRequest.vaultBaseUrl(), + updateSecretRequest.secretName(), updateSecretRequest.secretVersion(), - updateSecretRequest.contentType(), + updateSecretRequest.contentType(), updateSecretRequest.secretAttributes(), updateSecretRequest.tags()); } @@ -856,18 +855,18 @@ public ServiceResponse updateSecret(UpdateSecretRequest updateSecr * Updates the attributes associated with the specified secret. * * @param updateSecretRequest the grouped properties for updating a secret request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(UpdateSecretRequest updateSecretRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateSecretAsync( - updateSecretRequest.vaultBaseUrl(), - updateSecretRequest.secretName(), + updateSecretRequest.vaultBaseUrl(), + updateSecretRequest.secretName(), updateSecretRequest.secretVersion(), - updateSecretRequest.contentType(), + updateSecretRequest.contentType(), updateSecretRequest.secretAttributes(), - updateSecretRequest.tags(), + updateSecretRequest.tags(), serviceCallback); } @@ -880,8 +879,8 @@ public ServiceCall updateSecretAsync(UpdateSecretRequest updateSec * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getSecret(String secretIdentifier) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getSecret(String secretIdentifier) + throws KeyVaultErrorException, IOException, IllegalArgumentException { SecretIdentifier id = new SecretIdentifier(secretIdentifier); return innerKeyVaultClient.getSecret(id.vault, id.name, id.version == null ? "" : id.version); } @@ -908,8 +907,8 @@ public ServiceCall getSecretAsync(String secretIdentifier, final S * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getSecret(String vaultBaseUrl, String secretName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getSecret(String vaultBaseUrl, String secretName) + throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, ""); } @@ -924,7 +923,7 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getSecretAsync(vaultBaseUrl, secretName, "", serviceCallback); } - + /** * Gets a secret. * @@ -936,8 +935,8 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getSecret(String vaultBaseUrl, String secretName, String secretVersion) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse getSecret(String vaultBaseUrl, String secretName, String secretVersion) + throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, secretVersion == null ? "" : secretVersion); } @@ -963,7 +962,7 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecrets(final String vaultBaseUrl) + public ServiceResponse> getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecrets(vaultBaseUrl); } @@ -1015,7 +1014,7 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName) + public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName); } @@ -1042,7 +1041,7 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) + public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName, maxresults); } @@ -1121,7 +1120,7 @@ public ServiceCall> getCertificatesAsync(final String vaul * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) + public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificate(vaultBaseUrl, certificateName); } @@ -1148,7 +1147,7 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Contacts object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setCertificateContacts(String vaultBaseUrl, Contacts contacts) + public ServiceResponse setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setCertificateContacts(vaultBaseUrl, contacts); } @@ -1174,7 +1173,7 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Co * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Contacts object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificateContacts(String vaultBaseUrl) + public ServiceResponse getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateContacts(vaultBaseUrl); } @@ -1199,7 +1198,7 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, fi * @throws IllegalArgumentException exception thrown from invalid parameters * @return the Contacts object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) + public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificateContacts(vaultBaseUrl); } @@ -1224,7 +1223,7 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl) + public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl); } @@ -1249,7 +1248,7 @@ public ServiceCall> getCertificateIssuersAsync(final * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) + public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl, maxresults); } @@ -1270,17 +1269,17 @@ public ServiceCall> getCertificateIssuersAsync(final * Sets the certificate contacts for the specified vault. * * @param setCertificateIssuerRequest the grouped properties for setting a certificate issuer request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest) + public ServiceResponse setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setCertificateIssuer( - setCertificateIssuerRequest.vaultBaseUrl(), - setCertificateIssuerRequest.issuerName(), + setCertificateIssuerRequest.vaultBaseUrl(), + setCertificateIssuerRequest.issuerName(), setCertificateIssuerRequest.issuer()); } @@ -1288,15 +1287,15 @@ public ServiceResponse setCertificateIssuer(SetCertificateIssuerRe * Sets the certificate contacts for the specified vault. * * @param setCertificateIssuerRequest the grouped properties for setting a certificate issuer request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerRequest setCertificateIssuerRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.setCertificateIssuerAsync( - setCertificateIssuerRequest.vaultBaseUrl(), - setCertificateIssuerRequest.issuerName(), - setCertificateIssuerRequest.issuer(), + setCertificateIssuerRequest.vaultBaseUrl(), + setCertificateIssuerRequest.issuerName(), + setCertificateIssuerRequest.issuer(), serviceCallback); } @@ -1304,7 +1303,7 @@ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerR * Updates the specified certificate issuer. * * @param updateCertificateIssuerRequest the grouped properties for updating a certificate issuer request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters @@ -1313,8 +1312,8 @@ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerR public ServiceResponse updateCertificateIssuer(UpdateCertificateIssuerRequest updateCertificateIssuerRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificateIssuer( - updateCertificateIssuerRequest.vaultBaseUrl(), - updateCertificateIssuerRequest.issuerName(), + updateCertificateIssuerRequest.vaultBaseUrl(), + updateCertificateIssuerRequest.issuerName(), updateCertificateIssuerRequest.issuer()); } @@ -1322,15 +1321,15 @@ public ServiceResponse updateCertificateIssuer(UpdateCertificateIs * Updates the specified certificate issuer. * * @param updateCertificateIssuerRequest the grouped properties for updating a certificate issuer request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateIssuerAsync(UpdateCertificateIssuerRequest updateCertificateIssuerRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateIssuerAsync( - updateCertificateIssuerRequest.vaultBaseUrl(), - updateCertificateIssuerRequest.issuerName(), + updateCertificateIssuerRequest.vaultBaseUrl(), + updateCertificateIssuerRequest.issuerName(), updateCertificateIssuerRequest.issuer(), serviceCallback); } @@ -1345,7 +1344,7 @@ public ServiceCall updateCertificateIssuerAsync(UpdateCertificateI * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificateIssuer(String vaultBaseUrl, String issuerName) + public ServiceResponse getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuer(vaultBaseUrl, issuerName); } @@ -1359,7 +1358,7 @@ public ServiceResponse getCertificateIssuer(String vaultBaseUrl, S * @return the {@link ServiceCall} object */ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return innerKeyVaultClient.getCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); + return innerKeyVaultClient.getCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); } /** @@ -1372,7 +1371,7 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl, String issuerName) + public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificateIssuer(vaultBaseUrl, issuerName); } @@ -1393,19 +1392,19 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUr * Creates a new certificate version. If this is the first version, the certificate resource is created. * * @param createCertificateRequest the grouped properties for creating a certificate request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createCertificate(CreateCertificateRequest createCertificateRequest) + public ServiceResponse createCertificate(CreateCertificateRequest createCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.createCertificate( - createCertificateRequest.vaultBaseUrl(), - createCertificateRequest.certificateName(), - createCertificateRequest.certificatePolicy(), - createCertificateRequest.certificateAttributes(), + createCertificateRequest.vaultBaseUrl(), + createCertificateRequest.certificateName(), + createCertificateRequest.certificatePolicy(), + createCertificateRequest.certificateAttributes(), createCertificateRequest.tags()); } @@ -1413,17 +1412,17 @@ public ServiceResponse createCertificate(CreateCertificate * Creates a new certificate version. If this is the first version, the certificate resource is created. * * @param createCertificateRequest the grouped properties for creating a certificate request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(CreateCertificateRequest createCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.createCertificateAsync( - createCertificateRequest.vaultBaseUrl(), - createCertificateRequest.certificateName(), - createCertificateRequest.certificatePolicy(), - createCertificateRequest.certificateAttributes(), - createCertificateRequest.tags(), + createCertificateRequest.vaultBaseUrl(), + createCertificateRequest.certificateName(), + createCertificateRequest.certificatePolicy(), + createCertificateRequest.certificateAttributes(), + createCertificateRequest.tags(), serviceCallback); } @@ -1431,21 +1430,21 @@ public ServiceCall createCertificateAsync(CreateCertificat * Imports a certificate into the specified vault. * * @param importCertificateRequest the grouped properties for importing a certificate request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse importCertificate(ImportCertificateRequest importCertificateRequest) + public ServiceResponse importCertificate(ImportCertificateRequest importCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.importCertificate( - importCertificateRequest.vaultBaseUrl(), - importCertificateRequest.certificateName(), + importCertificateRequest.vaultBaseUrl(), + importCertificateRequest.certificateName(), importCertificateRequest.base64EncodedCertificate(), - importCertificateRequest.password(), - importCertificateRequest.certificatePolicy(), - importCertificateRequest.certificateAttributes(), + importCertificateRequest.password(), + importCertificateRequest.certificatePolicy(), + importCertificateRequest.certificateAttributes(), importCertificateRequest.tags()); } @@ -1453,22 +1452,22 @@ public ServiceResponse importCertificate(ImportCertificateReq * Imports a certificate into the specified vault. * * @param importCertificateRequest the grouped properties for importing a certificate request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall importCertificateAsync(ImportCertificateRequest importCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.importCertificateAsync( - importCertificateRequest.vaultBaseUrl(), - importCertificateRequest.certificateName(), - importCertificateRequest.base64EncodedCertificate(), - importCertificateRequest.password(), - importCertificateRequest.certificatePolicy(), - importCertificateRequest.certificateAttributes(), - importCertificateRequest.tags(), + importCertificateRequest.vaultBaseUrl(), + importCertificateRequest.certificateName(), + importCertificateRequest.base64EncodedCertificate(), + importCertificateRequest.password(), + importCertificateRequest.certificatePolicy(), + importCertificateRequest.certificateAttributes(), + importCertificateRequest.tags(), serviceCallback); } - + /** * List the versions of a certificate. * @@ -1479,7 +1478,7 @@ public ServiceCall importCertificateAsync(ImportCertificateRe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName) + public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName); } @@ -1493,7 +1492,7 @@ public ServiceResponse> getCertificateVersions(final * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback); + return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback); } /** * List the versions of a certificate. @@ -1534,7 +1533,7 @@ public ServiceCall> getCertificateVersionsAsync(final Stri * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) + public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificatePolicy(vaultBaseUrl, certificateName); } @@ -1555,17 +1554,17 @@ public ServiceCall getCertificatePolicyAsync(String vaultBase * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. * * @param updateCertificatePolicyRequest the grouped properties for updating a certificate policy request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest) + public ServiceResponse updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificatePolicy( - updateCertificatePolicyRequest.vaultBaseUrl(), - updateCertificatePolicyRequest.certificateName(), + updateCertificatePolicyRequest.vaultBaseUrl(), + updateCertificatePolicyRequest.certificateName(), updateCertificatePolicyRequest.certificatePolicy()); } @@ -1573,15 +1572,15 @@ public ServiceResponse updateCertificatePolicy(UpdateCertific * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. * * @param updateCertificatePolicyRequest the grouped properties for updating a certificate policy request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificatePolicyAsync( - updateCertificatePolicyRequest.vaultBaseUrl(), - updateCertificatePolicyRequest.certificateName(), - updateCertificatePolicyRequest.certificatePolicy(), + updateCertificatePolicyRequest.vaultBaseUrl(), + updateCertificatePolicyRequest.certificateName(), + updateCertificatePolicyRequest.certificatePolicy(), serviceCallback); } @@ -1589,19 +1588,19 @@ public ServiceCall updateCertificatePolicy(UpdateCertificateP * Updates the attributes associated with the specified certificate. * * @param updateCertificateRequest the grouped properties for updating a certificate request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificate(UpdateCertificateRequest updateCertificateRequest) + public ServiceResponse updateCertificate(UpdateCertificateRequest updateCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificate( - updateCertificateRequest.vaultBaseUrl(), - updateCertificateRequest.certificateName(), - updateCertificateRequest.certificateVersion(), - updateCertificateRequest.certificateAttributes(), + updateCertificateRequest.vaultBaseUrl(), + updateCertificateRequest.certificateName(), + updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificateAttributes(), updateCertificateRequest.tags()); } @@ -1609,20 +1608,20 @@ public ServiceResponse updateCertificate(UpdateCertificateReq * Updates the attributes associated with the specified certificate. * * @param updateCertificateRequest the grouped properties for updating a certificate request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(UpdateCertificateRequest updateCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateAsync( - updateCertificateRequest.vaultBaseUrl(), - updateCertificateRequest.certificateName(), - updateCertificateRequest.certificateVersion(), - updateCertificateRequest.certificateAttributes(), - updateCertificateRequest.tags(), + updateCertificateRequest.vaultBaseUrl(), + updateCertificateRequest.certificateName(), + updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificateAttributes(), + updateCertificateRequest.tags(), serviceCallback); } - + /** * Gets a Certificate. * @@ -1632,9 +1631,9 @@ public ServiceCall updateCertificateAsync(UpdateCertificateRe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificate(String certificateIdentifier) + public ServiceResponse getCertificate(String certificateIdentifier) throws KeyVaultErrorException, IOException, IllegalArgumentException { - CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); + CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); return innerKeyVaultClient.getCertificate(id.vault, id.name, id.version == null ? "" : id.version); } @@ -1649,7 +1648,7 @@ public ServiceCall getCertificateAsync(String certificateIden CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); return innerKeyVaultClient.getCertificateAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); } - + /** * Gets a Certificate. * @@ -1660,7 +1659,7 @@ public ServiceCall getCertificateAsync(String certificateIden * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName) + public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, ""); } @@ -1676,7 +1675,7 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificateAsync(vaultBaseUrl, certificateName, "", serviceCallback); } - + /** * Gets a Certificate. * @@ -1688,7 +1687,7 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) + public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, certificateVersion); } @@ -1708,19 +1707,19 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S /** * Updates a certificate operation. - * + * * @param updateCertificateOperationRequest the grouped properties for updating a certificate operation request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest) + public ServiceResponse updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificateOperation( - updateCertificateOperationRequest.vaultBaseUrl(), - updateCertificateOperationRequest.certificateName(), + updateCertificateOperationRequest.vaultBaseUrl(), + updateCertificateOperationRequest.certificateName(), updateCertificateOperationRequest.certificateOperation()); } @@ -1728,14 +1727,14 @@ public ServiceResponse updateCertificateOperation(UpdateCe * Updates a certificate operation. * * @param updateCertificateOperationRequest the grouped properties for updating a certificate operation request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateOperationAsync(UpdateCertificateOperationRequest updateCertificateOperationRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateOperationAsync( - updateCertificateOperationRequest.vaultBaseUrl(), - updateCertificateOperationRequest.certificateName(), + updateCertificateOperationRequest.vaultBaseUrl(), + updateCertificateOperationRequest.certificateName(), updateCertificateOperationRequest.certificateOperation(), serviceCallback); } @@ -1750,7 +1749,7 @@ public ServiceCall updateCertificateOperationAsync(UpdateC * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) + public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateOperation(vaultBaseUrl, certificateName); } @@ -1777,7 +1776,7 @@ public ServiceCall getCertificateOperationAsync(String vau * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) + public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificateOperation(vaultBaseUrl, certificateName); } @@ -1798,19 +1797,19 @@ ServiceCall deleteCertificateOperationAsync(String vaultBa * Merges a certificate or a certificate chain with a key pair existing on the server. * * @param mergeCertificateRequest the grouped properties for merging a certificate request - * + * * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse mergeCertificate(MergeCertificateRequest mergeCertificateRequest) + public ServiceResponse mergeCertificate(MergeCertificateRequest mergeCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.mergeCertificate( - mergeCertificateRequest.vaultBaseUrl(), - mergeCertificateRequest.certificateName(), - mergeCertificateRequest.x509Certificates(), - mergeCertificateRequest.certificateAttributes(), + mergeCertificateRequest.vaultBaseUrl(), + mergeCertificateRequest.certificateName(), + mergeCertificateRequest.x509Certificates(), + mergeCertificateRequest.certificateAttributes(), mergeCertificateRequest.tags()); } @@ -1818,17 +1817,17 @@ public ServiceResponse mergeCertificate(MergeCertificateReque * Merges a certificate or a certificate chain with a key pair existing on the server. * * @param mergeCertificateRequest the grouped properties for merging a certificate request - * + * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(MergeCertificateRequest mergeCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.mergeCertificateAsync( - mergeCertificateRequest.vaultBaseUrl(), - mergeCertificateRequest.certificateName(), - mergeCertificateRequest.x509Certificates(), - mergeCertificateRequest.certificateAttributes(), - mergeCertificateRequest.tags(), + mergeCertificateRequest.vaultBaseUrl(), + mergeCertificateRequest.certificateName(), + mergeCertificateRequest.x509Certificates(), + mergeCertificateRequest.certificateAttributes(), + mergeCertificateRequest.tags(), serviceCallback); } @@ -1843,9 +1842,21 @@ public ServiceCall mergeCertificateAsync(MergeCertificateRequ * @throws IllegalArgumentException exception thrown from invalid parameters * @return the String object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) + public ServiceResponse getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getPendingCertificateSigningRequestAsync(vaultBaseUrl, certificateName).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Response response = call.execute(); + return new ServiceResponse(response.body().string(), response); } /** @@ -1857,10 +1868,9 @@ public ServiceResponse getPendingCertificateSigningRequest(String vaultB * @return the {@link ServiceCall} object */ public ServiceCall getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getPendingCertificateSigningRequestAsync(vaultBaseUrl, certificateName), serviceCallback); - } - - private Observable> getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName) { + if (serviceCallback == null) { + throw new IllegalArgumentException("ServiceCallback is required for async calls."); + } if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1871,20 +1881,27 @@ private Observable> getPendingCertificateSigningRequestA throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = new ServiceResponse<>(response.body().string(), response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } + Call call = service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + if (serviceCallback != null) { + serviceCallback.success(new ServiceResponse(response.body().string(), response)); } - }); + serviceCall.success(new ServiceResponse(response.body().string(), response)); + } catch (IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); + } + } + }); + return serviceCall; } - + /** * List the versions of the specified key. * @@ -1894,7 +1911,7 @@ public Observable> call(Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersionsNext(final String nextPageLink) + public ServiceResponse> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersionsNext(nextPageLink); } @@ -1920,7 +1937,7 @@ public ServiceCall> getKeyVersionsNextAsync(final String nextPageL * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeysNext(final String nextPageLink) + public ServiceResponse> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeysNext(nextPageLink); } @@ -1946,7 +1963,7 @@ public ServiceCall> getKeysNextAsync(final String nextPageLink, fi * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretsNext(final String nextPageLink) + public ServiceResponse> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretsNext(nextPageLink); } @@ -1972,7 +1989,7 @@ public ServiceCall> getSecretsNextAsync(final String nextPageLi * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretVersionsNext(final String nextPageLink) + public ServiceResponse> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersionsNext(nextPageLink); } @@ -1998,7 +2015,7 @@ public ServiceCall> getSecretVersionsNextAsync(final String nex * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificatesNext(final String nextPageLink) + public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificatesNext(nextPageLink); } @@ -2024,7 +2041,7 @@ public ServiceCall> getCertificatesNextAsync(final String * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) + public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuersNext(nextPageLink); } @@ -2050,7 +2067,7 @@ public ServiceCall> getCertificateIssuersNextAsync(f * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) + public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateVersionsNext(nextPageLink); } @@ -2067,4 +2084,4 @@ public ServiceCall> getCertificateVersionsNextAsync(final return innerKeyVaultClient.getCertificateVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); } -} \ No newline at end of file +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java old mode 100644 new mode 100755 similarity index 52% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java rename to azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 5169594cfa830..5d3610adf8074 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -1,23 +1,16 @@ /** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ -package com.microsoft.azure.keyvault.implementation; +package com.microsoft.azure.keyvault; import com.google.common.base.Joiner; import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureClient; -import com.microsoft.azure.AzureServiceCall; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.AzureServiceResponseBuilder; -import com.microsoft.azure.ListOperationCallback; -import com.microsoft.azure.Page; -import com.microsoft.azure.PagedList; -import com.microsoft.azure.RestClient; import com.microsoft.azure.keyvault.models.BackupKeyResult; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificateBundle; @@ -32,10 +25,6 @@ import com.microsoft.azure.keyvault.models.Contacts; import com.microsoft.azure.keyvault.models.IssuerBundle; import com.microsoft.azure.keyvault.models.JsonWebKey; -import com.microsoft.azure.keyvault.models.JsonWebKeyEncryptionAlgorithm; -import com.microsoft.azure.keyvault.models.JsonWebKeyOperation; -import com.microsoft.azure.keyvault.models.JsonWebKeySignatureAlgorithm; -import com.microsoft.azure.keyvault.models.JsonWebKeyType; import com.microsoft.azure.keyvault.models.KeyAttributes; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyCreateParameters; @@ -55,35 +44,38 @@ import com.microsoft.azure.keyvault.models.SecretItem; import com.microsoft.azure.keyvault.models.SecretSetParameters; import com.microsoft.azure.keyvault.models.SecretUpdateParameters; -import com.microsoft.rest.RestException; +import com.microsoft.azure.ListOperationCallback; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.azure.RestClient; +import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.ServiceResponseCallback; import com.microsoft.rest.Validator; -import com.microsoft.rest.credentials.ServiceClientCredentials; +import java.io.IOException; +import java.util.List; +import java.util.Map; import okhttp3.ResponseBody; -import retrofit2.Response; +import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.GET; -import retrofit2.http.HTTP; import retrofit2.http.Header; import retrofit2.http.Headers; +import retrofit2.http.HTTP; import retrofit2.http.PATCH; +import retrofit2.http.Path; import retrofit2.http.POST; import retrofit2.http.PUT; -import retrofit2.http.Path; import retrofit2.http.Query; -import rx.Observable; -import rx.functions.Func1; - -import java.io.IOException; -import java.util.List; -import java.util.Map; +import retrofit2.http.Url; +import retrofit2.Response; /** * Initializes a new instance of the KeyVaultClientImpl class. */ -public final class KeyVaultClientImpl extends AzureServiceClient { +final class KeyVaultClientImpl extends AzureServiceClient { /** The Retrofit service to perform REST calls. */ private KeyVaultClientService service; /** the {@link AzureClient} used for long running operations. */ @@ -183,7 +175,7 @@ public KeyVaultClientImpl withGenerateClientRequestId(boolean generateClientRequ * * @param credentials the management credentials for Azure */ - public KeyVaultClientImpl(ServiceClientCredentials credentials) { + KeyVaultClientImpl(ServiceClientCredentials credentials) { this("https://{vaultBaseUrl}", credentials); } @@ -205,7 +197,7 @@ private KeyVaultClientImpl(String baseUrl, ServiceClientCredentials credentials) * * @param restClient the REST client to connect to Azure. */ - public KeyVaultClientImpl(RestClient restClient) { + KeyVaultClientImpl(RestClient restClient) { super(restClient); initialize(); } @@ -242,199 +234,199 @@ private void initializeService() { interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/create") - Observable> createKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call createKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("keys/{key-name}") - Observable> importKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call importKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "keys/{key-name}", method = "DELETE", hasBody = true) - Observable> deleteKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call deleteKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("keys/{key-name}/{key-version}") - Observable> updateKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys/{key-name}/{key-version}") - Observable> getKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys/{key-name}/versions") - Observable> getKeyVersions(@Path("key-name") String keyName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getKeyVersions(@Path("key-name") String keyName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys") - Observable> getKeys(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getKeys(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/backup") - Observable> backupKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call backupKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/restore") - Observable> restoreKey(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyRestoreParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call restoreKey(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyRestoreParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/encrypt") - Observable> encrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call encrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/decrypt") - Observable> decrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call decrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/sign") - Observable> sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeySignParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeySignParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/verify") - Observable> verify(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyVerifyParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call verify(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyVerifyParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/wrapkey") - Observable> wrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call wrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/unwrapkey") - Observable> unwrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call unwrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("secrets/{secret-name}") - Observable> setSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretSetParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call setSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretSetParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "secrets/{secret-name}", method = "DELETE", hasBody = true) - Observable> deleteSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call deleteSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("secrets/{secret-name}/{secret-version}") - Observable> updateSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets/{secret-name}/{secret-version}") - Observable> getSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets") - Observable> getSecrets(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getSecrets(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets/{secret-name}/versions") - Observable> getSecretVersions(@Path("secret-name") String secretName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getSecretVersions(@Path("secret-name") String secretName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates") - Observable> getCertificates(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getCertificates(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/{certificate-name}", method = "DELETE", hasBody = true) - Observable> deleteCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call deleteCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/contacts") - Observable> setCertificateContacts(@Body Contacts contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call setCertificateContacts(@Body Contacts contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/contacts") - Observable> getCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/contacts", method = "DELETE", hasBody = true) - Observable> deleteCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call deleteCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers") - Observable> getCertificateIssuers(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getCertificateIssuers(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/issuers/{issuer-name}") - Observable> setCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/issuers/{issuer-name}") - Observable> updateCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers/{issuer-name}") - Observable> getCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/issuers/{issuer-name}", method = "DELETE", hasBody = true) - Observable> deleteCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call deleteCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/create") - Observable> createCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call createCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/import") - Observable> importCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call importCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/versions") - Observable> getCertificateVersions(@Path("certificate-name") String certificateName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getCertificateVersions(@Path("certificate-name") String certificateName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/policy") - Observable> getCertificatePolicy(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getCertificatePolicy(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/policy") - Observable> updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicy certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicy certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/{certificate-version}") - Observable> updateCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/{certificate-version}") - Observable> getCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/pending") - Observable> updateCertificateOperation(@Path("certificate-name") String certificateName, @Body CertificateOperation certificateOperation, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Body CertificateOperation certificateOperation, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/pending") - Observable> getCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call getCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/{certificate-name}/pending", method = "DELETE", hasBody = true) - Observable> deleteCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call deleteCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/pending/merge") - Observable> mergeCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateMergeParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call mergeCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateMergeParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET("{nextLink}") - Observable> getKeyVersionsNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET + Call getKeyVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET("{nextLink}") - Observable> getKeysNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET + Call getKeysNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET("{nextLink}") - Observable> getSecretsNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET + Call getSecretsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET("{nextLink}") - Observable> getSecretVersionsNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET + Call getSecretVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET("{nextLink}") - Observable> getCertificatesNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET + Call getCertificatesNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET("{nextLink}") - Observable> getCertificateIssuersNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET + Call getCertificateIssuersNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") - @GET("{nextLink}") - Observable> getCertificateVersionsNext(@Path(value = "nextLink", encoded = true) String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @GET + Call getCertificateVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); } @@ -443,14 +435,38 @@ interface KeyVaultClientService { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createKeyAsync(vaultBaseUrl, keyName, kty).toBlocking().single(); + public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (kty == null) { + throw new IllegalArgumentException("Parameter kty is required and cannot be null."); + } + final Integer keySize = null; + final List keyOps = null; + final KeyAttributes keyAttributes = null; + final Map tags = null; + KeyCreateParameters parameters = new KeyCreateParameters(); + parameters.withKty(kty); + parameters.withKeySize(null); + parameters.withKeyOps(null); + parameters.withKeyAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return createKeyDelegate(call.execute()); } /** @@ -458,23 +474,11 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, final ServiceCallback serviceCallback) { - return ServiceCall.create(createKeyAsync(vaultBaseUrl, keyName, kty), serviceCallback); - } - - /** - * Creates a new, named, key in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' - * @return the observable to the KeyBundle object + * @return the {@link Call} object */ - public Observable> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -488,7 +492,7 @@ public Observable> createKeyAsync(String vaultBaseUrl throw new IllegalArgumentException("Parameter kty is required and cannot be null."); } final Integer keySize = null; - final List keyOps = null; + final List keyOps = null; final KeyAttributes keyAttributes = null; final Map tags = null; KeyCreateParameters parameters = new KeyCreateParameters(); @@ -498,18 +502,26 @@ public Observable> createKeyAsync(String vaultBaseUrl parameters.withKeyAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = createKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = createKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -517,9 +529,9 @@ public Observable> call(Response respon * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param keySize The key size in bytes. e.g. 1024 or 2048. - * @param keyOps the List<JsonWebKeyOperation> value + * @param keyOps the List<String> value * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call @@ -527,8 +539,31 @@ public Observable> call(Response respon * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createKeyAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).toBlocking().single(); + public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (kty == null) { + throw new IllegalArgumentException("Parameter kty is required and cannot be null."); + } + Validator.validate(keyOps); + Validator.validate(keyAttributes); + Validator.validate(tags); + KeyCreateParameters parameters = new KeyCreateParameters(); + parameters.withKty(kty); + parameters.withKeySize(keySize); + parameters.withKeyOps(keyOps); + parameters.withKeyAttributes(keyAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return createKeyDelegate(call.execute()); } /** @@ -536,31 +571,15 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param keySize The key size in bytes. e.g. 1024 or 2048. - * @param keyOps the List<JsonWebKeyOperation> value + * @param keyOps the List<String> value * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(createKeyAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags), serviceCallback); - } - - /** - * Creates a new, named, key in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' - * @param keySize The key size in bytes. e.g. 1024 or 2048. - * @param keyOps the List<JsonWebKeyOperation> value - * @param keyAttributes the KeyAttributes value - * @param tags Application-specific metadata in the form of key-value pairs - * @return the observable to the KeyBundle object + * @return the {@link Call} object */ - public Observable> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -583,18 +602,26 @@ public Observable> createKeyAsync(String vaultBaseUrl parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = createKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = createKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse createKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -616,7 +643,30 @@ private ServiceResponse createKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importKeyAsync(vaultBaseUrl, keyName, key).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (key == null) { + throw new IllegalArgumentException("Parameter key is required and cannot be null."); + } + Validator.validate(key); + final Boolean hsm = null; + final KeyAttributes keyAttributes = null; + final Map tags = null; + KeyImportParameters parameters = new KeyImportParameters(); + parameters.withHsm(null); + parameters.withKey(key); + parameters.withKeyAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return importKeyDelegate(call.execute()); } /** @@ -626,21 +676,9 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param key The Json web key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, final ServiceCallback serviceCallback) { - return ServiceCall.create(importKeyAsync(vaultBaseUrl, keyName, key), serviceCallback); - } - - /** - * Imports a key into the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param key The Json web key - * @return the observable to the KeyBundle object - */ - public Observable> importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -663,18 +701,26 @@ public Observable> importKeyAsync(String vaultBaseUrl parameters.withKeyAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = importKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = importKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -692,7 +738,29 @@ public Observable> call(Response respon * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importKeyAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (key == null) { + throw new IllegalArgumentException("Parameter key is required and cannot be null."); + } + Validator.validate(key); + Validator.validate(keyAttributes); + Validator.validate(tags); + KeyImportParameters parameters = new KeyImportParameters(); + parameters.withHsm(hsm); + parameters.withKey(key); + parameters.withKeyAttributes(keyAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return importKeyDelegate(call.execute()); } /** @@ -705,24 +773,9 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @param keyAttributes The key management attributes * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(importKeyAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags), serviceCallback); - } - - /** - * Imports a key into the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param key The Json web key - * @param hsm Whether to import as a hardware key (HSM) or software key - * @param keyAttributes The key management attributes - * @param tags Application-specific metadata in the form of key-value pairs - * @return the observable to the KeyBundle object - */ - public Observable> importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -744,18 +797,26 @@ public Observable> importKeyAsync(String vaultBaseUrl parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = importKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = importKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse importKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -776,7 +837,18 @@ private ServiceResponse importKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteKeyAsync(vaultBaseUrl, keyName).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return deleteKeyDelegate(call.execute()); } /** @@ -785,20 +857,9 @@ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteKeyAsync(vaultBaseUrl, keyName), serviceCallback); - } - - /** - * Deletes the specified key. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @return the observable to the KeyBundle object - */ - public Observable> deleteKeyAsync(String vaultBaseUrl, String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -809,18 +870,26 @@ public Observable> deleteKeyAsync(String vaultBaseUrl throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = deleteKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = deleteKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse deleteKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -842,7 +911,28 @@ private ServiceResponse deleteKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateKeyAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final List keyOps = null; + final KeyAttributes keyAttributes = null; + final Map tags = null; + KeyUpdateParameters parameters = new KeyUpdateParameters(); + parameters.withKeyOps(null); + parameters.withKeyAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return updateKeyDelegate(call.execute()); } /** @@ -852,21 +942,9 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param keyVersion The version of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateKeyAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); - } - - /** - * Updates the Key Attributes associated with the specified key. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @return the observable to the KeyBundle object - */ - public Observable> updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -879,7 +957,7 @@ public Observable> updateKeyAsync(String vaultBaseUrl if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - final List keyOps = null; + final List keyOps = null; final KeyAttributes keyAttributes = null; final Map tags = null; KeyUpdateParameters parameters = new KeyUpdateParameters(); @@ -887,18 +965,26 @@ public Observable> updateKeyAsync(String vaultBaseUrl parameters.withKeyAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = updateKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = updateKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -915,8 +1001,29 @@ public Observable> call(Response respon * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateKeyAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).toBlocking().single(); + public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(keyOps); + Validator.validate(keyAttributes); + Validator.validate(tags); + KeyUpdateParameters parameters = new KeyUpdateParameters(); + parameters.withKeyOps(keyOps); + parameters.withKeyAttributes(keyAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return updateKeyDelegate(call.execute()); } /** @@ -929,24 +1036,9 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateKeyAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags), serviceCallback); - } - - /** - * Updates the Key Attributes associated with the specified key. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. - * @param keyAttributes the KeyAttributes value - * @param tags Application-specific metadata in the form of key-value pairs - * @return the observable to the KeyBundle object + * @return the {@link Call} object */ - public Observable> updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { + public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -967,18 +1059,26 @@ public Observable> updateKeyAsync(String vaultBaseUrl parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = updateKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = updateKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse updateKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1000,20 +1100,21 @@ private ServiceResponse updateKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getKeyAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single(); - } - - /** - * Retrieves the public portion of a key plus its attributes. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(getKeyAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return getKeyDelegate(call.execute()); } /** @@ -1022,9 +1123,10 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @return the observable to the KeyBundle object + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link Call} object */ - public Observable> getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { + public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1038,18 +1140,26 @@ public Observable> getKeyAsync(String vaultBaseUrl, S throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = getKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse getKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1070,14 +1180,26 @@ private ServiceResponse getKeyDelegate(Response respons * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getKeyVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getKeyVersionsNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -1086,46 +1208,9 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcep * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getKeyVersionsNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List the versions of the specified key. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @return the observable to the List<KeyItem> object - */ - public Observable>> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName) { - return getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getKeyVersionsNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List the versions of the specified key. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1137,18 +1222,32 @@ public Observable>> getKeyVersionsSinglePageAsync( } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getKeyVersionsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getKeyVersionsDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -1163,14 +1262,25 @@ public Observable>> call(Response re * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getKeyVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getKeyVersionsNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -1180,48 +1290,9 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcep * @param keyName The name of the key * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getKeyVersionsNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List the versions of the specified key. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param maxresults Maximum number of results to return. - * @return the observable to the List<KeyItem> object - */ - public Observable>> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { - return getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getKeyVersionsNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List the versions of the specified key. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param maxresults Maximum number of results to return. - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1232,18 +1303,32 @@ public Observable>> getKeyVersionsSinglePageAsync( throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getKeyVersionsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getKeyVersionsDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getKeyVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1263,14 +1348,23 @@ private ServiceResponse> getKeyVersionsDelegate(Response> getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getKeysDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getKeysNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -1278,44 +1372,9 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcep * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getKeysSinglePageAsync(vaultBaseUrl), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getKeysNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List keys in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the List<KeyItem> object - */ - public Observable>> getKeysAsync(final String vaultBaseUrl) { - return getKeysSinglePageAsync(vaultBaseUrl) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getKeysNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List keys in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getKeysSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1324,18 +1383,32 @@ public Observable>> getKeysSinglePageAsync(final S } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getKeysDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getKeysDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -1349,14 +1422,22 @@ public Observable>> call(Response re * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getKeysDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getKeysNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -1365,46 +1446,9 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcep * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getKeysSinglePageAsync(vaultBaseUrl, maxresults), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getKeysNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List keys in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. - * @return the observable to the List<KeyItem> object - */ - public Observable>> getKeysAsync(final String vaultBaseUrl, final Integer maxresults) { - return getKeysSinglePageAsync(vaultBaseUrl, maxresults) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getKeysNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List keys in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getKeysSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1412,18 +1456,32 @@ public Observable>> getKeysSinglePageAsync(final S throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getKeysDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getKeysDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getKeysDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1444,7 +1502,18 @@ private ServiceResponse> getKeysDelegate(Response backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return backupKeyAsync(vaultBaseUrl, keyName).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return backupKeyDelegate(call.execute()); } /** @@ -1453,20 +1522,9 @@ public ServiceResponse backupKey(String vaultBaseUrl, String ke * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return ServiceCall.create(backupKeyAsync(vaultBaseUrl, keyName), serviceCallback); - } - - /** - * Requests that a backup of the specified key be downloaded to the client. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @return the observable to the BackupKeyResult object - */ - public Observable> backupKeyAsync(String vaultBaseUrl, String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1477,18 +1535,26 @@ public Observable> backupKeyAsync(String vaultB throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = backupKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = backupKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse backupKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1509,7 +1575,20 @@ private ServiceResponse backupKeyDelegate(Response restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return restoreKeyAsync(vaultBaseUrl, keyBundleBackup).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (keyBundleBackup == null) { + throw new IllegalArgumentException("Parameter keyBundleBackup is required and cannot be null."); + } + KeyRestoreParameters parameters = new KeyRestoreParameters(); + parameters.withKeyBundleBackup(keyBundleBackup); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return restoreKeyDelegate(call.execute()); } /** @@ -1518,20 +1597,9 @@ public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBund * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyBundleBackup the backup blob associated with a key bundle * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { - return ServiceCall.create(restoreKeyAsync(vaultBaseUrl, keyBundleBackup), serviceCallback); - } - - /** - * Restores the backup key in to a vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyBundleBackup the backup blob associated with a key bundle - * @return the observable to the KeyBundle object - */ - public Observable> restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1544,18 +1612,26 @@ public Observable> restoreKeyAsync(String vaultBaseUr KeyRestoreParameters parameters = new KeyRestoreParameters(); parameters.withKeyBundleBackup(keyBundleBackup); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = restoreKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = restoreKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse restoreKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1571,15 +1647,38 @@ private ServiceResponse restoreKeyDelegate(Response res * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param algorithm algorithm identifier * @param value the Base64Url value * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse encrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return encryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public ServiceResponse encrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (algorithm == null) { + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return encryptDelegate(call.execute()); } /** @@ -1588,26 +1687,12 @@ public ServiceResponse encrypt(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param algorithm algorithm identifier * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ - public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(encryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); - } - - /** - * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' - * @param value the Base64Url value - * @return the observable to the KeyOperationResult object - */ - public Observable> encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1630,18 +1715,26 @@ public Observable> encryptAsync(String vault parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = encryptDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = encryptDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse encryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1657,15 +1750,38 @@ private ServiceResponse encryptDelegate(Response decrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return decryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public ServiceResponse decrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (algorithm == null) { + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return decryptDelegate(call.execute()); } /** @@ -1674,26 +1790,12 @@ public ServiceResponse decrypt(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param algorithm algorithm identifier * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(decryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); - } - - /** - * Decrypts a single block of encrypted data. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' - * @param value the Base64Url value - * @return the observable to the KeyOperationResult object + * @return the {@link Call} object */ - public Observable> decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1716,18 +1818,26 @@ public Observable> decryptAsync(String vault parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = decryptDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = decryptDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse decryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1743,15 +1853,38 @@ private ServiceResponse decryptDelegate(Response sign(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return signAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public ServiceResponse sign(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (algorithm == null) { + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + KeySignParameters parameters = new KeySignParameters(); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return signDelegate(call.execute()); } /** @@ -1760,26 +1893,12 @@ public ServiceResponse sign(String vaultBaseUrl, String keyN * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(signAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); - } - - /** - * Creates a signature from a digest using the specified key in the vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' - * @param value the Base64Url value - * @return the observable to the KeyOperationResult object + * @return the {@link Call} object */ - public Observable> signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { + public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1802,18 +1921,26 @@ public Observable> signAsync(String vaultBas parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = signDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = signDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse signDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1829,7 +1956,7 @@ private ServiceResponse signDelegate(Response * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. * @param digest The digest used for signing * @param signature The signature to be verified * @throws KeyVaultErrorException exception thrown from REST call @@ -1837,8 +1964,35 @@ private ServiceResponse signDelegate(Response * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse verify(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return verifyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).toBlocking().single(); + public ServiceResponse verify(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (algorithm == null) { + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); + } + if (digest == null) { + throw new IllegalArgumentException("Parameter digest is required and cannot be null."); + } + if (signature == null) { + throw new IllegalArgumentException("Parameter signature is required and cannot be null."); + } + KeyVerifyParameters parameters = new KeyVerifyParameters(); + parameters.withAlgorithm(algorithm); + parameters.withDigest(digest); + parameters.withSignature(signature); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return verifyDelegate(call.execute()); } /** @@ -1847,28 +2001,13 @@ public ServiceResponse verify(String vaultBaseUrl, String keyNa * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. * @param digest The digest used for signing * @param signature The signature to be verified * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { - return ServiceCall.create(verifyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature), serviceCallback); - } - - /** - * Verifies a signature using the specified key. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' - * @param digest The digest used for signing - * @param signature The signature to be verified - * @return the observable to the KeyVerifyResult object + * @return the {@link Call} object */ - public Observable> verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { + public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1895,18 +2034,26 @@ public Observable> verifyAsync(String vaultBase parameters.withDigest(digest); parameters.withSignature(signature); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = verifyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = verifyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse verifyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1922,15 +2069,38 @@ private ServiceResponse verifyDelegate(Response r * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param algorithm algorithm identifier * @param value the Base64Url value * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse wrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return wrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public ServiceResponse wrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (algorithm == null) { + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return wrapKeyDelegate(call.execute()); } /** @@ -1939,26 +2109,12 @@ public ServiceResponse wrapKey(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param algorithm algorithm identifier * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(wrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); - } - - /** - * Wraps a symmetric key using the specified key. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' - * @param value the Base64Url value - * @return the observable to the KeyOperationResult object + * @return the {@link Call} object */ - public Observable> wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1981,18 +2137,26 @@ public Observable> wrapKeyAsync(String vault parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = wrapKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = wrapKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse wrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2008,15 +2172,38 @@ private ServiceResponse wrapKeyDelegate(Response unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return unwrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public ServiceResponse unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (keyName == null) { + throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); + } + if (keyVersion == null) { + throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (algorithm == null) { + throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + KeyOperationsParameters parameters = new KeyOperationsParameters(); + parameters.withAlgorithm(algorithm); + parameters.withValue(value); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return unwrapKeyDelegate(call.execute()); } /** @@ -2025,26 +2212,12 @@ public ServiceResponse unwrapKey(String vaultBaseUrl, String * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param algorithm algorithm identifier * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(unwrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); - } - - /** - * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' - * @param value the Base64Url value - * @return the observable to the KeyOperationResult object + * @return the {@link Call} object */ - public Observable> unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2067,18 +2240,26 @@ public Observable> unwrapKeyAsync(String vau parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = unwrapKeyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = unwrapKeyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse unwrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2100,7 +2281,29 @@ private ServiceResponse unwrapKeyDelegate(Response setSecret(String vaultBaseUrl, String secretName, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setSecretAsync(vaultBaseUrl, secretName, value).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + final Map tags = null; + final String contentType = null; + final SecretAttributes secretAttributes = null; + SecretSetParameters parameters = new SecretSetParameters(); + parameters.withValue(value); + parameters.withTags(null); + parameters.withContentType(null); + parameters.withSecretAttributes(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return setSecretDelegate(call.execute()); } /** @@ -2110,21 +2313,9 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @param secretName The name of the secret in the given vault * @param value The value of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) { - return ServiceCall.create(setSecretAsync(vaultBaseUrl, secretName, value), serviceCallback); - } - - /** - * Sets a secret in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param value The value of the secret - * @return the observable to the SecretBundle object - */ - public Observable> setSecretAsync(String vaultBaseUrl, String secretName, String value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2146,18 +2337,26 @@ public Observable> setSecretAsync(String vaultBase parameters.withContentType(null); parameters.withSecretAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = setSecretDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = setSecretDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -2175,7 +2374,28 @@ public Observable> call(Response res * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setSecretAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (value == null) { + throw new IllegalArgumentException("Parameter value is required and cannot be null."); + } + Validator.validate(tags); + Validator.validate(secretAttributes); + SecretSetParameters parameters = new SecretSetParameters(); + parameters.withValue(value); + parameters.withTags(tags); + parameters.withContentType(contentType); + parameters.withSecretAttributes(secretAttributes); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return setSecretDelegate(call.execute()); } /** @@ -2188,24 +2408,9 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @param contentType Type of the secret value such as a password * @param secretAttributes The secret management attributes * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes, final ServiceCallback serviceCallback) { - return ServiceCall.create(setSecretAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes), serviceCallback); - } - - /** - * Sets a secret in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param value The value of the secret - * @param tags Application-specific metadata in the form of key-value pairs - * @param contentType Type of the secret value such as a password - * @param secretAttributes The secret management attributes - * @return the observable to the SecretBundle object - */ - public Observable> setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2226,18 +2431,26 @@ public Observable> setSecretAsync(String vaultBase parameters.withContentType(contentType); parameters.withSecretAttributes(secretAttributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = setSecretDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = setSecretDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse setSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2258,7 +2471,18 @@ private ServiceResponse setSecretDelegate(Response r * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteSecretAsync(vaultBaseUrl, secretName).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return deleteSecretDelegate(call.execute()); } /** @@ -2267,20 +2491,9 @@ public ServiceResponse deleteSecret(String vaultBaseUrl, String se * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteSecretAsync(vaultBaseUrl, secretName), serviceCallback); - } - - /** - * Deletes a secret from the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @return the observable to the SecretBundle object - */ - public Observable> deleteSecretAsync(String vaultBaseUrl, String secretName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2291,18 +2504,26 @@ public Observable> deleteSecretAsync(String vaultB throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = deleteSecretDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = deleteSecretDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse deleteSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2324,31 +2545,6 @@ private ServiceResponse deleteSecretDelegate(Response updateSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateSecretAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single(); - } - - /** - * Updates the attributes associated with the specified secret. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateSecretAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); - } - - /** - * Updates the attributes associated with the specified secret. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret - * @return the observable to the SecretBundle object - */ - public Observable> updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2369,18 +2565,8 @@ public Observable> updateSecretAsync(String vaultB parameters.withSecretAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = updateSecretDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); - } - } - }); + Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return updateSecretDelegate(call.execute()); } /** @@ -2389,16 +2575,50 @@ public Observable> call(Response res * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret - * @param contentType Type of the secret value such as a password - * @param secretAttributes The secret management attributes - * @param tags Application-specific metadata in the form of key-value pairs - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link Call} object */ - public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateSecretAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).toBlocking().single(); + public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (secretVersion == null) { + throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final String contentType = null; + final SecretAttributes secretAttributes = null; + final Map tags = null; + SecretUpdateParameters parameters = new SecretUpdateParameters(); + parameters.withContentType(null); + parameters.withSecretAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = updateSecretDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); + } + } + }); + return serviceCall; } /** @@ -2410,11 +2630,33 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @param contentType Type of the secret value such as a password * @param secretAttributes The secret management attributes * @param tags Application-specific metadata in the form of key-value pairs - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateSecretAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags), serviceCallback); + public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (secretVersion == null) { + throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(secretAttributes); + Validator.validate(tags); + SecretUpdateParameters parameters = new SecretUpdateParameters(); + parameters.withContentType(contentType); + parameters.withSecretAttributes(secretAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return updateSecretDelegate(call.execute()); } /** @@ -2426,9 +2668,10 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String s * @param contentType Type of the secret value such as a password * @param secretAttributes The secret management attributes * @param tags Application-specific metadata in the form of key-value pairs - * @return the observable to the SecretBundle object + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link Call} object */ - public Observable> updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { + public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2448,18 +2691,26 @@ public Observable> updateSecretAsync(String vaultB parameters.withSecretAttributes(secretAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = updateSecretDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = updateSecretDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse updateSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2481,7 +2732,21 @@ private ServiceResponse updateSecretDelegate(Response getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getSecretAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (secretVersion == null) { + throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return getSecretDelegate(call.execute()); } /** @@ -2491,21 +2756,9 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(getSecretAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); - } - - /** - * Gets a secret. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret - * @return the observable to the SecretBundle object - */ - public Observable> getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2519,18 +2772,26 @@ public Observable> getSecretAsync(String vaultBase throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getSecretDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = getSecretDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse getSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2550,14 +2811,23 @@ private ServiceResponse getSecretDelegate(Response r * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getSecretsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getSecretsNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -2565,44 +2835,9 @@ public Page nextPage(String nextPageLink) throws RestException, IOEx * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getSecretsSinglePageAsync(vaultBaseUrl), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getSecretsNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List secrets in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the List<SecretItem> object - */ - public Observable>> getSecretsAsync(final String vaultBaseUrl) { - return getSecretsSinglePageAsync(vaultBaseUrl) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getSecretsNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List secrets in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getSecretsSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2611,18 +2846,32 @@ public Observable>> getSecretsSinglePageAsync(f } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getSecretsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getSecretsDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -2636,14 +2885,22 @@ public Observable>> call(Response * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getSecretsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getSecretsNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -2652,46 +2909,9 @@ public Page nextPage(String nextPageLink) throws RestException, IOEx * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of secrets to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getSecretsSinglePageAsync(vaultBaseUrl, maxresults), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getSecretsNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List secrets in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of secrets to return. - * @return the observable to the List<SecretItem> object - */ - public Observable>> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults) { - return getSecretsSinglePageAsync(vaultBaseUrl, maxresults) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getSecretsNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List secrets in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of secrets to return. - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getSecretsSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2699,18 +2919,32 @@ public Observable>> getSecretsSinglePageAsync(f throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getSecretsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getSecretsDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getSecretsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2731,14 +2965,26 @@ private ServiceResponse> getSecretsDelegate(Response> getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getSecretVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getSecretVersionsNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -2747,46 +2993,9 @@ public Page nextPage(String nextPageLink) throws RestException, IOEx * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getSecretVersionsNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List the versions of the specified secret. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @return the observable to the List<SecretItem> object - */ - public Observable>> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName) { - return getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getSecretVersionsNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List the versions of the specified secret. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2798,18 +3007,32 @@ public Observable>> getSecretVersionsSinglePage } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getSecretVersionsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getSecretVersionsDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -2824,14 +3047,25 @@ public Observable>> call(Response * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (secretName == null) { + throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getSecretVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getSecretVersionsNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -2841,48 +3075,9 @@ public Page nextPage(String nextPageLink) throws RestException, IOEx * @param secretName The name of the secret in the given vault * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getSecretVersionsNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List the versions of the specified secret. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param maxresults Maximum number of results to return. - * @return the observable to the List<SecretItem> object - */ - public Observable>> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { - return getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getSecretVersionsNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List the versions of the specified secret. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param maxresults Maximum number of results to return. - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2893,18 +3088,32 @@ public Observable>> getSecretVersionsSinglePage throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getSecretVersionsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getSecretVersionsDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getSecretVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2924,14 +3133,23 @@ private ServiceResponse> getSecretVersionsDelegate(Response * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getCertificatesDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getCertificatesNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -2939,44 +3157,9 @@ public Page nextPage(String nextPageLink) throws RestException, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getCertificatesSinglePageAsync(vaultBaseUrl), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getCertificatesNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List certificates in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the List<CertificateItem> object - */ - public Observable>> getCertificatesAsync(final String vaultBaseUrl) { - return getCertificatesSinglePageAsync(vaultBaseUrl) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getCertificatesNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List certificates in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getCertificatesSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2985,18 +3168,32 @@ public Observable>> getCertificatesSingleP } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getCertificatesDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificatesDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -3010,14 +3207,22 @@ public Observable>> call(Response> getCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getCertificatesDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getCertificatesNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -3026,46 +3231,9 @@ public Page nextPage(String nextPageLink) throws RestException, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getCertificatesSinglePageAsync(vaultBaseUrl, maxresults), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getCertificatesNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List certificates in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. - * @return the observable to the List<CertificateItem> object - */ - public Observable>> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults) { - return getCertificatesSinglePageAsync(vaultBaseUrl, maxresults) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getCertificatesNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List certificates in the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getCertificatesSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3073,18 +3241,32 @@ public Observable>> getCertificatesSingleP throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getCertificatesDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificatesDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getCertificatesDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3105,7 +3287,18 @@ private ServiceResponse> getCertificatesDelegate(Respo * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateAsync(vaultBaseUrl, certificateName).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return deleteCertificateDelegate(call.execute()); } /** @@ -3114,20 +3307,9 @@ public ServiceResponse deleteCertificate(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateAsync(vaultBaseUrl, certificateName), serviceCallback); - } - - /** - * Deletes a certificate from the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @return the observable to the CertificateBundle object - */ - public Observable> deleteCertificateAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3138,18 +3320,26 @@ public Observable> deleteCertificateAsync(Str throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = deleteCertificateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = deleteCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse deleteCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3170,7 +3360,19 @@ private ServiceResponse deleteCertificateDelegate(Response setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setCertificateContactsAsync(vaultBaseUrl, contacts).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (contacts == null) { + throw new IllegalArgumentException("Parameter contacts is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(contacts); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return setCertificateContactsDelegate(call.execute()); } /** @@ -3179,20 +3381,9 @@ public ServiceResponse setCertificateContacts(String vaultBaseUrl, Con * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param contacts The contacts for the vault certificates. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { - return ServiceCall.create(setCertificateContactsAsync(vaultBaseUrl, contacts), serviceCallback); - } - - /** - * Sets the certificate contacts for the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param contacts The contacts for the vault certificates. - * @return the observable to the Contacts object - */ - public Observable> setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3204,18 +3395,26 @@ public Observable> setCertificateContactsAsync(String } Validator.validate(contacts); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = setCertificateContactsDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = setCertificateContactsDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse setCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3235,7 +3434,15 @@ private ServiceResponse setCertificateContactsDelegate(Response getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateContactsAsync(vaultBaseUrl).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return getCertificateContactsDelegate(call.execute()); } /** @@ -3243,19 +3450,9 @@ public ServiceResponse getCertificateContacts(String vaultBaseUrl) thr * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateContactsAsync(vaultBaseUrl), serviceCallback); - } - - /** - * Gets the certificate contacts for the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the Contacts object - */ - public Observable> getCertificateContactsAsync(String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3263,18 +3460,26 @@ public Observable> getCertificateContactsAsync(String throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getCertificateContactsDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = getCertificateContactsDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse getCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3294,7 +3499,15 @@ private ServiceResponse getCertificateContactsDelegate(Response deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateContactsAsync(vaultBaseUrl).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return deleteCertificateContactsDelegate(call.execute()); } /** @@ -3302,19 +3515,9 @@ public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateContactsAsync(vaultBaseUrl), serviceCallback); - } - - /** - * Deletes the certificate contacts for the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the Contacts object - */ - public Observable> deleteCertificateContactsAsync(String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3322,18 +3525,26 @@ public Observable> deleteCertificateContactsAsync(Stri throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = deleteCertificateContactsDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = deleteCertificateContactsDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse deleteCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3353,14 +3564,23 @@ private ServiceResponse deleteCertificateContactsDelegate(Response> getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getCertificateIssuersNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -3368,44 +3588,9 @@ public Page nextPage(String nextPageLink) throws RestExce * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getCertificateIssuersSinglePageAsync(vaultBaseUrl), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getCertificateIssuersNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List certificate issuers for the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the List<CertificateIssuerItem> object - */ - public Observable>> getCertificateIssuersAsync(final String vaultBaseUrl) { - return getCertificateIssuersSinglePageAsync(vaultBaseUrl) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateIssuersNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List certificate issuers for the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + * @return the {@link Call} object */ - public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl) { + public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3414,18 +3599,32 @@ public Observable>> getCertificateIs } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getCertificateIssuersDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificateIssuersDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -3439,14 +3638,22 @@ public Observable>> call(Response> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getCertificateIssuersNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -3455,46 +3662,9 @@ public Page nextPage(String nextPageLink) throws RestExce * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getCertificateIssuersNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List certificate issuers for the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. - * @return the observable to the List<CertificateIssuerItem> object - */ - public Observable>> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults) { - return getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateIssuersNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List certificate issuers for the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3502,18 +3672,32 @@ public Observable>> getCertificateIs throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getCertificateIssuersDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificateIssuersDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getCertificateIssuersDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3535,7 +3719,22 @@ private ServiceResponse> getCertificateIssuersDe * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundle issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setCertificateIssuerAsync(vaultBaseUrl, issuerName, issuer).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); + } + if (issuer == null) { + throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(issuer); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return setCertificateIssuerDelegate(call.execute()); } /** @@ -3545,21 +3744,9 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * @param issuerName The name of the issuer. * @param issuer The issuer bundle. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) { - return ServiceCall.create(setCertificateIssuerAsync(vaultBaseUrl, issuerName, issuer), serviceCallback); - } - - /** - * Sets the specified certificate issuer. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param issuerName The name of the issuer. - * @param issuer The issuer bundle. - * @return the observable to the IssuerBundle object - */ - public Observable> setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3574,18 +3761,26 @@ public Observable> setCertificateIssuerAsync(Strin } Validator.validate(issuer); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = setCertificateIssuerDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = setCertificateIssuerDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse setCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3607,7 +3802,22 @@ private ServiceResponse setCertificateIssuerDelegate(Response updateCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundle issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateIssuerAsync(vaultBaseUrl, issuerName, issuer).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); + } + if (issuer == null) { + throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(issuer); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return updateCertificateIssuerDelegate(call.execute()); } /** @@ -3617,21 +3827,9 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * @param issuerName The name of the issuer. * @param issuer The issuer bundle. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateIssuerAsync(vaultBaseUrl, issuerName, issuer), serviceCallback); - } - - /** - * Updates the specified certificate issuer. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param issuerName The name of the issuer. - * @param issuer The issuer bundle. - * @return the observable to the IssuerBundle object - */ - public Observable> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3646,18 +3844,26 @@ public Observable> updateCertificateIssuerAsync(St } Validator.validate(issuer); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse updateCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3678,7 +3884,18 @@ private ServiceResponse updateCertificateIssuerDelegate(Response getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return getCertificateIssuerDelegate(call.execute()); } /** @@ -3687,20 +3904,9 @@ public ServiceResponse getCertificateIssuer(String vaultBaseUrl, S * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); - } - - /** - * Gets the specified certificate issuer. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param issuerName The name of the issuer. - * @return the observable to the IssuerBundle object - */ - public Observable> getCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3711,18 +3917,26 @@ public Observable> getCertificateIssuerAsync(Strin throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getCertificateIssuerDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = getCertificateIssuerDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse getCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3743,7 +3957,18 @@ private ServiceResponse getCertificateIssuerDelegate(Response deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return deleteCertificateIssuerDelegate(call.execute()); } /** @@ -3752,20 +3977,9 @@ public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); - } - - /** - * Deletes the specified certificate issuer. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param issuerName The name of the issuer. - * @return the observable to the IssuerBundle object - */ - public Observable> deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3776,18 +3990,26 @@ public Observable> deleteCertificateIssuerAsync(St throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = deleteCertificateIssuerDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = deleteCertificateIssuerDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse deleteCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3808,7 +4030,25 @@ private ServiceResponse deleteCertificateIssuerDelegate(Response createCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createCertificateAsync(vaultBaseUrl, certificateName).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final CertificatePolicy certificatePolicy = null; + final CertificateAttributes certificateAttributes = null; + final Map tags = null; + CertificateCreateParameters parameters = new CertificateCreateParameters(); + parameters.withCertificatePolicy(null); + parameters.withCertificateAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return createCertificateDelegate(call.execute()); } /** @@ -3817,20 +4057,9 @@ public ServiceResponse createCertificate(String vaultBaseU * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(createCertificateAsync(vaultBaseUrl, certificateName), serviceCallback); - } - - /** - * Creates a new certificate version. If this is the first version, the certificate resource is created. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @return the observable to the CertificateOperation object - */ - public Observable> createCertificateAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3848,18 +4077,26 @@ public Observable> createCertificateAsync( parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = createCertificateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = createCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -3876,7 +4113,25 @@ public Observable> call(Response createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createCertificateAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(certificatePolicy); + Validator.validate(certificateAttributes); + Validator.validate(tags); + CertificateCreateParameters parameters = new CertificateCreateParameters(); + parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificateAttributes(certificateAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return createCertificateDelegate(call.execute()); } /** @@ -3888,23 +4143,9 @@ public ServiceResponse createCertificate(String vaultBaseU * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(createCertificateAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags), serviceCallback); - } - - /** - * Creates a new certificate version. If this is the first version, the certificate resource is created. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param certificatePolicy The management policy for the certificate - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs - * @return the observable to the CertificateOperation object - */ - public Observable> createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3922,18 +4163,26 @@ public Observable> createCertificateAsync( parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = createCertificateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = createCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse createCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3955,7 +4204,31 @@ private ServiceResponse createCertificateDelegate(Response * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (base64EncodedCertificate == null) { + throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); + } + final String password = null; + final CertificatePolicy certificatePolicy = null; + final CertificateAttributes certificateAttributes = null; + final Map tags = null; + CertificateImportParameters parameters = new CertificateImportParameters(); + parameters.withBase64EncodedCertificate(base64EncodedCertificate); + parameters.withPassword(null); + parameters.withCertificatePolicy(null); + parameters.withCertificateAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return importCertificateDelegate(call.execute()); } /** @@ -3965,21 +4238,9 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) { - return ServiceCall.create(importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate), serviceCallback); - } - - /** - * Imports a certificate into the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. - * @return the observable to the CertificateBundle object - */ - public Observable> importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4003,18 +4264,26 @@ public Observable> importCertificateAsync(Str parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = importCertificateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = importCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -4033,7 +4302,30 @@ public Observable> call(Response importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (base64EncodedCertificate == null) { + throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); + } + Validator.validate(certificatePolicy); + Validator.validate(certificateAttributes); + Validator.validate(tags); + CertificateImportParameters parameters = new CertificateImportParameters(); + parameters.withBase64EncodedCertificate(base64EncodedCertificate); + parameters.withPassword(password); + parameters.withCertificatePolicy(certificatePolicy); + parameters.withCertificateAttributes(certificateAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return importCertificateDelegate(call.execute()); } /** @@ -4047,25 +4339,9 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags), serviceCallback); - } - - /** - * Imports a certificate into the specified vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption - * @param certificatePolicy The management policy for the certificate - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs - * @return the observable to the CertificateBundle object + * @return the {@link Call} object */ - public Observable> importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4088,18 +4364,26 @@ public Observable> importCertificateAsync(Str parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = importCertificateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = importCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse importCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4120,14 +4404,26 @@ private ServiceResponse importCertificateDelegate(Response> getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final Integer maxresults = null; + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getCertificateVersionsNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -4136,46 +4432,9 @@ public Page nextPage(String nextPageLink) throws RestException, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getCertificateVersionsNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List the versions of a certificate. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @return the observable to the List<CertificateItem> object - */ - public Observable>> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName) { - return getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateVersionsNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List the versions of a certificate. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4187,18 +4446,32 @@ public Observable>> getCertificateVersions } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getCertificateVersionsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificateVersionsDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -4213,14 +4486,25 @@ public Observable>> call(Response> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); + PagedList result = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { + return getCertificateVersionsNext(nextPageLink).getBody(); } }; - return new ServiceResponse<>(pagedList, response.getResponse()); + return new ServiceResponse<>(result, response.getResponse()); } /** @@ -4230,48 +4514,9 @@ public Page nextPage(String nextPageLink) throws RestException, * @param certificateName The name of the certificate * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getCertificateVersionsNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List the versions of a certificate. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param maxresults Maximum number of results to return. - * @return the observable to the List<CertificateItem> object - */ - public Observable>> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { - return getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateVersionsNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List the versions of a certificate. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param maxresults Maximum number of results to return. - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4282,18 +4527,32 @@ public Observable>> getCertificateVersions throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getCertificateVersionsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall> serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificateVersionsDelegate(response); + if (serviceCallback != null) { + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } + serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getCertificateVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4314,7 +4573,18 @@ private ServiceResponse> getCertificateVersionsDelegat * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificatePolicyAsync(vaultBaseUrl, certificateName).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return getCertificatePolicyDelegate(call.execute()); } /** @@ -4323,20 +4593,9 @@ public ServiceResponse getCertificatePolicy(String vaultBaseU * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificatePolicyAsync(vaultBaseUrl, certificateName), serviceCallback); - } - - /** - * Gets the policy for a certificate. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault. - * @return the observable to the CertificatePolicy object - */ - public Observable> getCertificatePolicyAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4347,18 +4606,26 @@ public Observable> getCertificatePolicyAsync( throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getCertificatePolicyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = getCertificatePolicyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse getCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4380,7 +4647,22 @@ private ServiceResponse getCertificatePolicyDelegate(Response * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificatePolicyAsync(vaultBaseUrl, certificateName, certificatePolicy).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (certificatePolicy == null) { + throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(certificatePolicy); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return updateCertificatePolicyDelegate(call.execute()); } /** @@ -4390,21 +4672,9 @@ public ServiceResponse updateCertificatePolicy(String vaultBa * @param certificateName The name of the certificate in the given vault. * @param certificatePolicy The policy for the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificatePolicyAsync(vaultBaseUrl, certificateName, certificatePolicy), serviceCallback); - } - - /** - * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault. - * @param certificatePolicy The policy for the certificate. - * @return the observable to the CertificatePolicy object - */ - public Observable> updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4419,18 +4689,26 @@ public Observable> updateCertificatePolicyAsy } Validator.validate(certificatePolicy); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = updateCertificatePolicyDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = updateCertificatePolicyDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse updateCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4452,7 +4730,26 @@ private ServiceResponse updateCertificatePolicyDelegate(Respo * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (certificateVersion == null) { + throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + final CertificateAttributes certificateAttributes = null; + final Map tags = null; + CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.withCertificateAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return updateCertificateDelegate(call.execute()); } /** @@ -4462,21 +4759,9 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); - } - - /** - * Updates the attributes associated with the specified certificate. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate - * @return the observable to the CertificateBundle object - */ - public Observable> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4495,18 +4780,26 @@ public Observable> updateCertificateAsync(Str parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = updateCertificateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = updateCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -4523,7 +4816,26 @@ public Observable> call(Response updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, certificateAttributes, tags).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (certificateVersion == null) { + throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(certificateAttributes); + Validator.validate(tags); + CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.withCertificateAttributes(certificateAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return updateCertificateDelegate(call.execute()); } /** @@ -4535,23 +4847,9 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, certificateAttributes, tags), serviceCallback); - } - - /** - * Updates the attributes associated with the specified certificate. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs - * @return the observable to the CertificateBundle object - */ - public Observable> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4570,18 +4868,26 @@ public Observable> updateCertificateAsync(Str parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = updateCertificateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = updateCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse updateCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4603,7 +4909,21 @@ private ServiceResponse updateCertificateDelegate(Response getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (certificateVersion == null) { + throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return getCertificateDelegate(call.execute()); } /** @@ -4613,21 +4933,9 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); - } - - /** - * Gets a Certificate. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate - * @return the observable to the CertificateBundle object - */ - public Observable> getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4641,18 +4949,26 @@ public Observable> getCertificateAsync(String throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getCertificateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = getCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse getCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4674,7 +4990,22 @@ private ServiceResponse getCertificateDelegate(Response updateCertificateOperation(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateOperationAsync(vaultBaseUrl, certificateName, certificateOperation).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (certificateOperation == null) { + throw new IllegalArgumentException("Parameter certificateOperation is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + Validator.validate(certificateOperation); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return updateCertificateOperationDelegate(call.execute()); } /** @@ -4684,21 +5015,9 @@ public ServiceResponse updateCertificateOperation(String v * @param certificateName The name of the certificate * @param certificateOperation The certificate operation response. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateOperationAsync(vaultBaseUrl, certificateName, certificateOperation), serviceCallback); - } - - /** - * Updates a certificate operation. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param certificateOperation The certificate operation response. - * @return the observable to the CertificateOperation object - */ - public Observable> updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4713,18 +5032,26 @@ public Observable> updateCertificateOperat } Validator.validate(certificateOperation); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = updateCertificateOperationDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = updateCertificateOperationDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse updateCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4745,7 +5072,18 @@ private ServiceResponse updateCertificateOperationDelegate * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateOperationAsync(vaultBaseUrl, certificateName).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return getCertificateOperationDelegate(call.execute()); } /** @@ -4754,20 +5092,9 @@ public ServiceResponse getCertificateOperation(String vaul * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateOperationAsync(vaultBaseUrl, certificateName), serviceCallback); - } - - /** - * Gets the certificate operation response. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @return the observable to the CertificateOperation object - */ - public Observable> getCertificateOperationAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4778,18 +5105,26 @@ public Observable> getCertificateOperation throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = getCertificateOperationDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = getCertificateOperationDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse getCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4810,7 +5145,18 @@ private ServiceResponse getCertificateOperationDelegate(Re * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateOperationAsync(vaultBaseUrl, certificateName).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + return deleteCertificateOperationDelegate(call.execute()); } /** @@ -4819,20 +5165,9 @@ public ServiceResponse deleteCertificateOperation(String v * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateOperationAsync(vaultBaseUrl, certificateName), serviceCallback); - } - - /** - * Deletes the certificate operation. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @return the observable to the CertificateOperation object - */ - public Observable> deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4843,18 +5178,26 @@ public Observable> deleteCertificateOperat throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = deleteCertificateOperationDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = deleteCertificateOperationDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse deleteCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4876,7 +5219,28 @@ private ServiceResponse deleteCertificateOperationDelegate * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (x509Certificates == null) { + throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); + } + Validator.validate(x509Certificates); + final CertificateAttributes certificateAttributes = null; + final Map tags = null; + CertificateMergeParameters parameters = new CertificateMergeParameters(); + parameters.withX509Certificates(x509Certificates); + parameters.withCertificateAttributes(null); + parameters.withTags(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return mergeCertificateDelegate(call.execute()); } /** @@ -4886,21 +5250,9 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate * @param x509Certificates The certificate or the certificate chain to merge * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) { - return ServiceCall.create(mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates), serviceCallback); - } - - /** - * Merges a certificate or a certificate chain with a key pair existing on the server. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificate chain to merge - * @return the observable to the CertificateBundle object - */ - public Observable> mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4921,18 +5273,26 @@ public Observable> mergeCertificateAsync(Stri parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = mergeCertificateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = mergeCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } /** @@ -4949,7 +5309,28 @@ public Observable> call(Response mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).toBlocking().single(); + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (certificateName == null) { + throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (x509Certificates == null) { + throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); + } + Validator.validate(x509Certificates); + Validator.validate(certificateAttributes); + Validator.validate(tags); + CertificateMergeParameters parameters = new CertificateMergeParameters(); + parameters.withX509Certificates(x509Certificates); + parameters.withCertificateAttributes(certificateAttributes); + parameters.withTags(tags); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + return mergeCertificateDelegate(call.execute()); } /** @@ -4961,23 +5342,9 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags), serviceCallback); - } - - /** - * Merges a certificate or a certificate chain with a key pair existing on the server. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificate chain to merge - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs - * @return the observable to the CertificateBundle object - */ - public Observable> mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4998,18 +5365,26 @@ public Observable> mergeCertificateAsync(Stri parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - return service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) - .flatMap(new Func1, Observable>>() { - @Override - public Observable> call(Response response) { - try { - ServiceResponse clientResponse = mergeCertificateDelegate(response); - return Observable.just(clientResponse); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = mergeCertificateDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse mergeCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5028,15 +5403,12 @@ private ServiceResponse mergeCertificateDelegate(Response> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { - @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); - } - }; - return new ServiceResponse<>(pagedList, response.getResponse()); + public ServiceResponse> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getKeyVersionsNextDelegate(call.execute()); } /** @@ -5045,59 +5417,35 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcep * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getKeyVersionsNextSinglePageAsync(nextPageLink), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getKeyVersionsNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List the versions of the specified key. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<KeyItem> object - */ - public Observable>> getKeyVersionsNextAsync(final String nextPageLink) { - return getKeyVersionsNextSinglePageAsync(nextPageLink) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getKeyVersionsNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List the versions of the specified key. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getKeyVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getKeyVersionsNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getKeyVersionsNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); } + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getKeyVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5116,15 +5464,12 @@ private ServiceResponse> getKeyVersionsNextDelegate(Response> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getKeysNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { - @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); - } - }; - return new ServiceResponse<>(pagedList, response.getResponse()); + public ServiceResponse> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getKeysNextDelegate(call.execute()); } /** @@ -5133,59 +5478,35 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcep * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getKeysNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getKeysNextSinglePageAsync(nextPageLink), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getKeysNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List keys in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<KeyItem> object - */ - public Observable>> getKeysNextAsync(final String nextPageLink) { - return getKeysNextSinglePageAsync(nextPageLink) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getKeysNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List keys in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getKeysNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getKeysNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getKeysNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getKeysNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5204,15 +5525,12 @@ private ServiceResponse> getKeysNextDelegate(Response> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { - @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); - } - }; - return new ServiceResponse<>(pagedList, response.getResponse()); + public ServiceResponse> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getSecretsNextDelegate(call.execute()); } /** @@ -5221,59 +5539,35 @@ public Page nextPage(String nextPageLink) throws RestException, IOEx * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getSecretsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getSecretsNextSinglePageAsync(nextPageLink), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getSecretsNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List secrets in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<SecretItem> object - */ - public Observable>> getSecretsNextAsync(final String nextPageLink) { - return getSecretsNextSinglePageAsync(nextPageLink) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getSecretsNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List secrets in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getSecretsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getSecretsNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getSecretsNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); } + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getSecretsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5292,15 +5586,12 @@ private ServiceResponse> getSecretsNextDelegate(Response> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { - @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); - } - }; - return new ServiceResponse<>(pagedList, response.getResponse()); + public ServiceResponse> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getSecretVersionsNextDelegate(call.execute()); } /** @@ -5309,59 +5600,35 @@ public Page nextPage(String nextPageLink) throws RestException, IOEx * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getSecretVersionsNextSinglePageAsync(nextPageLink), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getSecretVersionsNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List the versions of the specified secret. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<SecretItem> object - */ - public Observable>> getSecretVersionsNextAsync(final String nextPageLink) { - return getSecretVersionsNextSinglePageAsync(nextPageLink) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getSecretVersionsNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List the versions of the specified secret. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getSecretVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getSecretVersionsNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getSecretVersionsNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getSecretVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5380,15 +5647,12 @@ private ServiceResponse> getSecretVersionsNextDelegate(Resp * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { - @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); - } - }; - return new ServiceResponse<>(pagedList, response.getResponse()); + public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getCertificatesNextDelegate(call.execute()); } /** @@ -5397,59 +5661,35 @@ public Page nextPage(String nextPageLink) throws RestException, * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getCertificatesNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getCertificatesNextSinglePageAsync(nextPageLink), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getCertificatesNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List certificates in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<CertificateItem> object - */ - public Observable>> getCertificatesNextAsync(final String nextPageLink) { - return getCertificatesNextSinglePageAsync(nextPageLink) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getCertificatesNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List certificates in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getCertificatesNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getCertificatesNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificatesNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); } + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getCertificatesNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5468,15 +5708,12 @@ private ServiceResponse> getCertificatesNextDelegate(R * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { - @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); - } - }; - return new ServiceResponse<>(pagedList, response.getResponse()); + public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getCertificateIssuersNextDelegate(call.execute()); } /** @@ -5485,59 +5722,35 @@ public Page nextPage(String nextPageLink) throws RestExce * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getCertificateIssuersNextSinglePageAsync(nextPageLink), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getCertificateIssuersNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List certificate issuers for the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<CertificateIssuerItem> object - */ - public Observable>> getCertificateIssuersNextAsync(final String nextPageLink) { - return getCertificateIssuersNextSinglePageAsync(nextPageLink) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateIssuersNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List certificate issuers for the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getCertificateIssuersNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getCertificateIssuersNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificateIssuersNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + } + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getCertificateIssuersNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5556,15 +5769,12 @@ private ServiceResponse> getCertificateIssuersNe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - ServiceResponse> response = getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { - @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); - } - }; - return new ServiceResponse<>(pagedList, response.getResponse()); + public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + if (nextPageLink == null) { + throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); + } + Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + return getCertificateVersionsNextDelegate(call.execute()); } /** @@ -5573,59 +5783,35 @@ public Page nextPage(String nextPageLink) throws RestException, * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link Call} object */ public ServiceCall> getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( - getCertificateVersionsNextSinglePageAsync(nextPageLink), - new Func1>>>() { - @Override - public Observable>> call(String nextPageLink) { - return getCertificateVersionsNextSinglePageAsync(nextPageLink); - } - }, - serviceCallback); - } - - /** - * List the versions of a certificate. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<CertificateItem> object - */ - public Observable>> getCertificateVersionsNextAsync(final String nextPageLink) { - return getCertificateVersionsNextSinglePageAsync(nextPageLink) - .concatMap(new Func1>, Observable>>>() { - @Override - public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateVersionsNextSinglePageAsync(nextPageLink); - } - }); - } - - /** - * List the versions of a certificate. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. - */ - public Observable>> getCertificateVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) - .flatMap(new Func1, Observable>>>() { - @Override - public Observable>> call(Response response) { - try { - ServiceResponse> result = getCertificateVersionsNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); - } catch (Throwable t) { - return Observable.error(t); + Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); + serviceCall.newCall(call); + call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse> result = getCertificateVersionsNextDelegate(response); + serviceCallback.load(result.getBody().getItems()); + if (result.getBody().getNextPageLink() != null + && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { + getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); + } else { + serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); } + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); } - }); + } + }); + return serviceCall; } private ServiceResponse> getCertificateVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/package-info.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java deleted file mode 100644 index 027b37b3588e7..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/implementation/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for -// license information. -// -// Code generated by Microsoft (R) AutoRest Code Generator. - -/** - * This package contains the implementation classes for KeyVaultClient. - * Performs cryptographic key operations and vault operations against the Key Vault service. - */ -package com.microsoft.azure.keyvault.implementation; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java old mode 100644 new mode 100755 index 903784187e16e..b87d376d8bdde --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java old mode 100644 new mode 100755 index 872cf84b8c219..3bd73fd386216 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java old mode 100644 new mode 100755 index 5889bace83753..580ac6b5d62f2 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java old mode 100644 new mode 100755 index cb8fd0cfcae73..ed187ccd0cab0 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java old mode 100644 new mode 100755 index 7a069513a17cd..b5a6a72351240 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java old mode 100644 new mode 100755 index 0fe27a6925258..d821e2490bc60 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java old mode 100644 new mode 100755 index 0c8ed5961262a..eda7dfbc9da3a --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java @@ -3,14 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.CertificateIdentifier; import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.SecretIdentifier; @@ -19,6 +18,9 @@ import java.io.IOException; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; /** * A certificate bundle consists of a certificate (X509) plus its attributes. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java old mode 100644 new mode 100755 index d85d2eb430def..9de3d7a36bebb --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java old mode 100644 new mode 100755 index 6e0ec8791cfd9..6cd918a00cb14 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java old mode 100644 new mode 100755 index 119aed73128b5..f90e86cd39fdb --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java old mode 100644 new mode 100755 index c303d1fbaecc8..cf13fa529bb36 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java @@ -3,12 +3,16 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; import java.util.Map; + +import com.microsoft.azure.keyvault.CertificateIdentifier; import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; @@ -124,4 +128,17 @@ public CertificateItem withX509Thumbprint(byte[] x509Thumbprint) { return this; } + /** + * The certificate identifier. + * @return The Identifier value. + */ + public CertificateIdentifier identifier() { + CertificateIdentifier identifier = null; + + if (id() != null && !id().isEmpty()) { + identifier = new CertificateIdentifier(id()); + } + + return identifier; + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java old mode 100644 new mode 100755 index bf6b9e58bbd28..46454283ded8f --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java old mode 100644 new mode 100755 index 11cb636e6fe09..c8aea174e4bf3 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java @@ -3,19 +3,21 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; +import java.io.IOException; + import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.CertificateOperationIdentifier; -import java.io.IOException; - /** * A certificate operation is returned in case of async requests. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java old mode 100644 new mode 100755 index cb3047ca19d63..6243eb4a805e4 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java old mode 100644 new mode 100755 index 26316932dfb48..0e3d426eed6cf --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java old mode 100644 new mode 100755 index 9be09f829e031..7fe0c7baeb017 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java old mode 100644 new mode 100755 index 21d0001a70d70..8d0d542cbeb2b --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java old mode 100644 new mode 100755 index 9caf41131e546..4d231d644f92a --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java old mode 100644 new mode 100755 index 866aebdb8d05a..592e36229ecc7 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java old mode 100644 new mode 100755 index 72653a0d66efa..3dd318e5139f8 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -3,19 +3,21 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; +import java.io.IOException; + import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.IssuerIdentifier; -import java.io.IOException; - /** * The issuer for Key Vault certificate. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java old mode 100644 new mode 100755 index 5651c64bf2ea4..23ef3eced7f05 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java old mode 100644 new mode 100755 index 88f47a517aed9..6f971897b7dbb --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java old mode 100644 new mode 100755 index 325b1c2898d34..ed9bb700c1543 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java @@ -3,17 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.rest.Base64Url; - import java.io.IOException; import java.math.BigInteger; import java.security.GeneralSecurityException; @@ -28,6 +24,12 @@ import java.security.spec.RSAPublicKeySpec; import java.util.Arrays; import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; +import com.microsoft.rest.Base64Url; /** * As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18. @@ -39,17 +41,16 @@ public class JsonWebKey { private String kid; /** - * Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, - * Octet, usually RSA. Possible values include: 'EC', 'RSA', 'RSA-HSM', + * Key type, usually RSA. Possible values include: 'EC', 'RSA', 'RSA-HSM', * 'oct'. */ - private JsonWebKeyType kty; + private String kty; /** * The keyOps property. */ @JsonProperty(value = "key_ops") - private List keyOps; + private List keyOps; /** * RSA modulus. @@ -128,7 +129,7 @@ public JsonWebKey withKid(String kid) { * * @return the kty value */ - public JsonWebKeyType kty() { + public String kty() { return this.kty; } @@ -138,7 +139,7 @@ public JsonWebKeyType kty() { * @param kty the kty value to set * @return the JsonWebKey object itself. */ - public JsonWebKey withKty(JsonWebKeyType kty) { + public JsonWebKey withKty(String kty) { this.kty = kty; return this; } @@ -148,7 +149,7 @@ public JsonWebKey withKty(JsonWebKeyType kty) { * * @return the keyOps value */ - public List keyOps() { + public List keyOps() { return this.keyOps; } @@ -158,7 +159,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the JsonWebKey object itself. */ - public JsonWebKey withKeyOps(List keyOps) { + public JsonWebKey withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } @@ -506,7 +507,7 @@ private PrivateKey getRSAPrivateKey() { * Verifies if the key is an RSA key. */ private void checkRSACompatible() { - if (!JsonWebKeyType.RSA.equals(kty()) && !JsonWebKeyType.RSA_HSM.equals(kty())) { + if (!JsonWebKeyType.RSA.equals(kty()) && !JsonWebKeyType.RSAHSM.equals(kty())) { throw new UnsupportedOperationException("Not an RSA key"); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyEncryptionAlgorithm.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyEncryptionAlgorithm.java deleted file mode 100644 index e164c8e06e9fb..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyEncryptionAlgorithm.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.keyvault.models; - -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for JsonWebKeyEncryptionAlgorithm. - */ -public final class JsonWebKeyEncryptionAlgorithm { - /** Static value RSA-OAEP for JsonWebKeyEncryptionAlgorithm. */ - public static final JsonWebKeyEncryptionAlgorithm RSA_OAEP = new JsonWebKeyEncryptionAlgorithm("RSA-OAEP"); - - /** Static value RSA1_5 for JsonWebKeyEncryptionAlgorithm. */ - public static final JsonWebKeyEncryptionAlgorithm RSA1_5 = new JsonWebKeyEncryptionAlgorithm("RSA1_5"); - - private String value; - - /** - * Creates a custom value for JsonWebKeyEncryptionAlgorithm. - * @param value the custom value - */ - public JsonWebKeyEncryptionAlgorithm(String value) { - this.value = value; - } - - @JsonValue - @Override - public String toString() { - return value; - } - - @Override - public int hashCode() { - return value.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof JsonWebKeyEncryptionAlgorithm)) { - return false; - } - if (obj == this) { - return true; - } - JsonWebKeyEncryptionAlgorithm rhs = (JsonWebKeyEncryptionAlgorithm) obj; - if (value == null) { - return rhs.value == null; - } else { - return value.equals(rhs.value); - } - } -} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyOperation.java deleted file mode 100644 index 614f32905b234..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyOperation.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.keyvault.models; - -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for JsonWebKeyOperation. - */ -public final class JsonWebKeyOperation { - /** Static value encrypt for JsonWebKeyOperation. */ - public static final JsonWebKeyOperation ENCRYPT = new JsonWebKeyOperation("encrypt"); - - /** Static value decrypt for JsonWebKeyOperation. */ - public static final JsonWebKeyOperation DECRYPT = new JsonWebKeyOperation("decrypt"); - - /** Static value sign for JsonWebKeyOperation. */ - public static final JsonWebKeyOperation SIGN = new JsonWebKeyOperation("sign"); - - /** Static value verify for JsonWebKeyOperation. */ - public static final JsonWebKeyOperation VERIFY = new JsonWebKeyOperation("verify"); - - /** Static value wrapKey for JsonWebKeyOperation. */ - public static final JsonWebKeyOperation WRAP_KEY = new JsonWebKeyOperation("wrapKey"); - - /** Static value unwrapKey for JsonWebKeyOperation. */ - public static final JsonWebKeyOperation UNWRAP_KEY = new JsonWebKeyOperation("unwrapKey"); - - private String value; - - /** - * Creates a custom value for JsonWebKeyOperation. - * @param value the custom value - */ - public JsonWebKeyOperation(String value) { - this.value = value; - } - - @JsonValue - @Override - public String toString() { - return value; - } - - @Override - public int hashCode() { - return value.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof JsonWebKeyOperation)) { - return false; - } - if (obj == this) { - return true; - } - JsonWebKeyOperation rhs = (JsonWebKeyOperation) obj; - if (value == null) { - return rhs.value == null; - } else { - return value.equals(rhs.value); - } - } -} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeySignatureAlgorithm.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeySignatureAlgorithm.java deleted file mode 100644 index 752b278b5b5ea..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeySignatureAlgorithm.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.keyvault.models; - -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for JsonWebKeySignatureAlgorithm. - */ -public final class JsonWebKeySignatureAlgorithm { - /** Static value RS256 for JsonWebKeySignatureAlgorithm. */ - public static final JsonWebKeySignatureAlgorithm RS256 = new JsonWebKeySignatureAlgorithm("RS256"); - - /** Static value RS384 for JsonWebKeySignatureAlgorithm. */ - public static final JsonWebKeySignatureAlgorithm RS384 = new JsonWebKeySignatureAlgorithm("RS384"); - - /** Static value RS512 for JsonWebKeySignatureAlgorithm. */ - public static final JsonWebKeySignatureAlgorithm RS512 = new JsonWebKeySignatureAlgorithm("RS512"); - - /** Static value RSNULL for JsonWebKeySignatureAlgorithm. */ - public static final JsonWebKeySignatureAlgorithm RSNULL = new JsonWebKeySignatureAlgorithm("RSNULL"); - - private String value; - - /** - * Creates a custom value for JsonWebKeySignatureAlgorithm. - * @param value the custom value - */ - public JsonWebKeySignatureAlgorithm(String value) { - this.value = value; - } - - @JsonValue - @Override - public String toString() { - return value; - } - - @Override - public int hashCode() { - return value.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof JsonWebKeySignatureAlgorithm)) { - return false; - } - if (obj == this) { - return true; - } - JsonWebKeySignatureAlgorithm rhs = (JsonWebKeySignatureAlgorithm) obj; - if (value == null) { - return rhs.value == null; - } else { - return value.equals(rhs.value); - } - } -} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyType.java deleted file mode 100644 index 9bfcef3fbb5cb..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKeyType.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - */ - -package com.microsoft.azure.keyvault.models; - -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Defines values for JsonWebKeyType. - */ -public final class JsonWebKeyType { - /** Static value EC for JsonWebKeyType. */ - public static final JsonWebKeyType EC = new JsonWebKeyType("EC"); - - /** Static value RSA for JsonWebKeyType. */ - public static final JsonWebKeyType RSA = new JsonWebKeyType("RSA"); - - /** Static value RSA-HSM for JsonWebKeyType. */ - public static final JsonWebKeyType RSA_HSM = new JsonWebKeyType("RSA-HSM"); - - /** Static value oct for JsonWebKeyType. */ - public static final JsonWebKeyType OCT = new JsonWebKeyType("oct"); - - private String value; - - /** - * Creates a custom value for JsonWebKeyType. - * @param value the custom value - */ - public JsonWebKeyType(String value) { - this.value = value; - } - - @JsonValue - @Override - public String toString() { - return value; - } - - @Override - public int hashCode() { - return value.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof JsonWebKeyType)) { - return false; - } - if (obj == this) { - return true; - } - JsonWebKeyType rhs = (JsonWebKeyType) obj; - if (value == null) { - return rhs.value == null; - } else { - return value.equals(rhs.value); - } - } -} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java old mode 100644 new mode 100755 index 53b43c1f72fe8..25c37fede46de --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java old mode 100644 new mode 100755 index 2054fbfc7366c..4c13b1490a64d --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -3,19 +3,21 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; +import java.io.IOException; +import java.util.Map; + import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.KeyIdentifier; -import java.io.IOException; -import java.util.Map; - /** * A KeyBundle consisting of a WebKey plus its Attributes. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java old mode 100644 new mode 100755 index 1a56c8e43670e..a799ee36fb6e7 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; @@ -18,11 +20,10 @@ public class KeyCreateParameters { /** * The type of key to create. Valid key types, see JsonWebKeyType. - * Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, - * Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'. + * Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'. */ @JsonProperty(required = true) - private JsonWebKeyType kty; + private String kty; /** * The key size in bytes. e.g. 1024 or 2048. @@ -34,7 +35,7 @@ public class KeyCreateParameters { * The keyOps property. */ @JsonProperty(value = "key_ops") - private List keyOps; + private List keyOps; /** * The keyAttributes property. @@ -52,7 +53,7 @@ public class KeyCreateParameters { * * @return the kty value */ - public JsonWebKeyType kty() { + public String kty() { return this.kty; } @@ -62,7 +63,7 @@ public JsonWebKeyType kty() { * @param kty the kty value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters withKty(JsonWebKeyType kty) { + public KeyCreateParameters withKty(String kty) { this.kty = kty; return this; } @@ -92,7 +93,7 @@ public KeyCreateParameters withKeySize(Integer keySize) { * * @return the keyOps value */ - public List keyOps() { + public List keyOps() { return this.keyOps; } @@ -102,7 +103,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters withKeyOps(List keyOps) { + public KeyCreateParameters withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java old mode 100644 new mode 100755 index 46b16eea221dd..0cd6eb0a956e5 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java old mode 100644 new mode 100755 index 72d42a1ddeced..05584de30f1ac --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -3,13 +3,17 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; import java.util.Map; +import com.microsoft.azure.keyvault.KeyIdentifier; + /** * The key item containing key metadata. */ @@ -89,4 +93,17 @@ public KeyItem withTags(Map tags) { return this; } + /** + * The key identifier. + * @return The Identifier value + */ + public KeyIdentifier identifier() { + KeyIdentifier identifier = null; + + if (kid() != null && !kid().isEmpty()) { + identifier = new KeyIdentifier(kid()); + } + + return identifier; + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java old mode 100644 new mode 100755 index ed09546bd0c5f..229b85ec52d70 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java old mode 100644 new mode 100755 index 9b5503509891a..228a944624152 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; @@ -19,7 +21,7 @@ public class KeyOperationsParameters { * algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5'. */ @JsonProperty(value = "alg", required = true) - private JsonWebKeyEncryptionAlgorithm algorithm; + private String algorithm; /** * The value property. @@ -32,7 +34,7 @@ public class KeyOperationsParameters { * * @return the algorithm value */ - public JsonWebKeyEncryptionAlgorithm algorithm() { + public String algorithm() { return this.algorithm; } @@ -42,7 +44,7 @@ public JsonWebKeyEncryptionAlgorithm algorithm() { * @param algorithm the algorithm value to set * @return the KeyOperationsParameters object itself. */ - public KeyOperationsParameters withAlgorithm(JsonWebKeyEncryptionAlgorithm algorithm) { + public KeyOperationsParameters withAlgorithm(String algorithm) { this.algorithm = algorithm; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java old mode 100644 new mode 100755 index 3780e73a8f341..999ed545fd0be --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java old mode 100644 new mode 100755 index 273bbeb7fa2da..2d32495d4074e --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java old mode 100644 new mode 100755 index d28acbc964c64..1af4965c7b756 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; @@ -21,7 +23,7 @@ public class KeySignParameters { * values include: 'RS256', 'RS384', 'RS512', 'RSNULL'. */ @JsonProperty(value = "alg", required = true) - private JsonWebKeySignatureAlgorithm algorithm; + private String algorithm; /** * The value property. @@ -34,7 +36,7 @@ public class KeySignParameters { * * @return the algorithm value */ - public JsonWebKeySignatureAlgorithm algorithm() { + public String algorithm() { return this.algorithm; } @@ -44,7 +46,7 @@ public JsonWebKeySignatureAlgorithm algorithm() { * @param algorithm the algorithm value to set * @return the KeySignParameters object itself. */ - public KeySignParameters withAlgorithm(JsonWebKeySignatureAlgorithm algorithm) { + public KeySignParameters withAlgorithm(String algorithm) { this.algorithm = algorithm; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java old mode 100644 new mode 100755 index 01cc940d4ee34..33c51dc4d697b --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; @@ -21,7 +23,7 @@ public class KeyUpdateParameters { * operations, see JsonWebKeyOperation. */ @JsonProperty(value = "key_ops") - private List keyOps; + private List keyOps; /** * The keyAttributes property. @@ -39,7 +41,7 @@ public class KeyUpdateParameters { * * @return the keyOps value */ - public List keyOps() { + public List keyOps() { return this.keyOps; } @@ -49,7 +51,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the KeyUpdateParameters object itself. */ - public KeyUpdateParameters withKeyOps(List keyOps) { + public KeyUpdateParameters withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java old mode 100644 new mode 100755 index 316286608217f..7b4b390b1cb65 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java old mode 100644 new mode 100755 index 83c9aa7d202e6..aa2a6f81d1c74 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java old mode 100644 new mode 100755 index 6606b0ab2fb4d..bdcfc617fc14c --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java old mode 100644 new mode 100755 index 204e2fdf80ca7..1f370f7494ed7 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; @@ -21,7 +23,7 @@ public class KeyVerifyParameters { * include: 'RS256', 'RS384', 'RS512', 'RSNULL'. */ @JsonProperty(value = "alg", required = true) - private JsonWebKeySignatureAlgorithm algorithm; + private String algorithm; /** * The digest used for signing. @@ -40,7 +42,7 @@ public class KeyVerifyParameters { * * @return the algorithm value */ - public JsonWebKeySignatureAlgorithm algorithm() { + public String algorithm() { return this.algorithm; } @@ -50,7 +52,7 @@ public JsonWebKeySignatureAlgorithm algorithm() { * @param algorithm the algorithm value to set * @return the KeyVerifyParameters object itself. */ - public KeyVerifyParameters withAlgorithm(JsonWebKeySignatureAlgorithm algorithm) { + public KeyVerifyParameters withAlgorithm(String algorithm) { this.algorithm = algorithm; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java old mode 100644 new mode 100755 index da66a2594aeca..2295ece7edb6a --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java old mode 100644 new mode 100755 index 3b113d3b67b34..9f2f520dfaf7a --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java old mode 100644 new mode 100755 index c9e219bd14be1..44e80f582186f --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java old mode 100644 new mode 100755 index 71d801b06a166..ba40e0b446269 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java old mode 100644 new mode 100755 index 65c1d613093d0..51b5fc32aee52 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java old mode 100644 new mode 100755 index 90c38a6b223b1..e6cdbe4d40db0 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java old mode 100644 new mode 100755 index 23e5d5b6c5ed8..52d7e736fb451 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -3,19 +3,21 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; +import java.io.IOException; +import java.util.Map; + import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.SecretIdentifier; -import java.io.IOException; -import java.util.Map; - /** * A Secret consisting of a value, id and its attributes. */ @@ -194,4 +196,5 @@ public String toString() { throw new IllegalStateException(e); } } + } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java old mode 100644 new mode 100755 index a52b488a3e1cd..5359f9cba67ca --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -3,13 +3,17 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; import java.util.Map; +import com.microsoft.azure.keyvault.SecretIdentifier; + /** * The secret item containing secret metadata. */ @@ -114,4 +118,17 @@ public SecretItem withContentType(String contentType) { return this; } + /** + * the secret identifier. + * @return The Identifier value + */ + public SecretIdentifier identifier() { + SecretIdentifier identifier = null; + + if (id() != null && !id().isEmpty()) { + identifier = new SecretIdentifier(id()); + } + + return identifier; + } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java old mode 100644 new mode 100755 index 384c7bed74f9d..daa4ec324e4cc --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java old mode 100644 new mode 100755 index ccfa3361129fd..c6aa346335c08 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java old mode 100644 new mode 100755 index bf3f590edefe2..ac9361fffbe73 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java old mode 100644 new mode 100755 index fbbe4915c966c..317cc22925354 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java old mode 100644 new mode 100755 index efcfa4e3a2249..52fa1a031dd3a --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java old mode 100644 new mode 100755 index 44febbf283c47..ae9267dba24d6 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java @@ -3,7 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator. + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java old mode 100644 new mode 100755 index 1ad477613c6d3..79c10e9f21e65 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java @@ -2,7 +2,9 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. /** * This package contains the models classes for KeyVaultClient. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java old mode 100644 new mode 100755 index 0f6aa06721867..ec9b976c5096b --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java @@ -2,7 +2,9 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. /** * This package contains the classes for KeyVaultClient. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java old mode 100644 new mode 100755 index 5b90a72048233..96f416bb9cf36 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java @@ -5,8 +5,6 @@ import java.util.List; import java.util.Map; -import com.microsoft.azure.keyvault.models.JsonWebKeyOperation; -import com.microsoft.azure.keyvault.models.JsonWebKeyType; import com.microsoft.azure.keyvault.models.KeyAttributes; /** @@ -16,9 +14,9 @@ public final class CreateKeyRequest { private final String vaultBaseUrl; private final String keyName; - private final JsonWebKeyType keyType; + private final String keyType; private final Integer keySize; - private final List keyOperations; + private final List keyOperations; private final KeyAttributes keyAttributes; private final Map tags; @@ -30,11 +28,11 @@ public static class Builder { // Required parameters private final String vaultBaseUrl; private final String keyName; - private final JsonWebKeyType keyType; + private final String keyType; // Optional parameters private Integer keySize; - private List keyOperations; + private List keyOperations; private KeyAttributes attributes; private Map tags; @@ -49,7 +47,7 @@ public static class Builder { * The type of key to create. Possible values include: 'EC', * 'RSA', 'RSA-HSM', 'oct' */ - public Builder(String vaultBaseUrl, String keyName, JsonWebKeyType keyType) { + public Builder(String vaultBaseUrl, String keyName, String keyType) { this.vaultBaseUrl = vaultBaseUrl; this.keyName = keyName; this.keyType = keyType; @@ -74,7 +72,7 @@ public Builder withKeySize(Integer size) { * the key operation list. * @return the Builder object itself. */ - public Builder withKeyOperations(List keyOperations) { + public Builder withKeyOperations(List keyOperations) { this.keyOperations = keyOperations; return this; } @@ -121,7 +119,7 @@ private CreateKeyRequest(Builder builder) { keySize = builder.keySize; if (builder.keyOperations != null) { - keyOperations = new ArrayList(builder.keyOperations); + keyOperations = new ArrayList(builder.keyOperations); } else { keyOperations = null; } @@ -157,7 +155,7 @@ public String keyName() { /** * @return the key type */ - public JsonWebKeyType keyType() { + public String keyType() { return keyType; } @@ -171,7 +169,7 @@ public Integer keySize() { /** * @return the key operations */ - public List keyOperations() { + public List keyOperations() { return keyOperations; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java old mode 100644 new mode 100755 index f8a1313d0839c..8fb02162ff3da --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java @@ -5,7 +5,6 @@ import java.util.Map; import com.microsoft.azure.keyvault.models.JsonWebKey; -import com.microsoft.azure.keyvault.models.JsonWebKeyOperation; import com.microsoft.azure.keyvault.models.KeyAttributes; /** @@ -110,7 +109,7 @@ private ImportKeyRequest(Builder builder) { .withD(builder.key.d()).withP(builder.key.p()).withQ(builder.key.q()).withDp(builder.key.dp()) .withDq(builder.key.dq()).withQi(builder.key.qi()).withK(builder.key.k()).withT(builder.key.t()); if (builder.key.keyOps() != null) { - key.withKeyOps(new ArrayList(builder.key.keyOps())); + key.withKeyOps(new ArrayList(builder.key.keyOps())); } } else { key = null; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java old mode 100644 new mode 100755 index db90cb537b57d..d87b8c798c583 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java @@ -6,7 +6,6 @@ import java.util.Map; import com.microsoft.azure.keyvault.KeyIdentifier; -import com.microsoft.azure.keyvault.models.JsonWebKeyOperation; import com.microsoft.azure.keyvault.models.KeyAttributes; /** @@ -17,7 +16,7 @@ public final class UpdateKeyRequest { private final String vaultBaseUrl; private final String keyName; private final String keyVersion; - private final List keyOperations; + private final List keyOperations; private final KeyAttributes keyAttributes; private final Map tags; @@ -32,7 +31,7 @@ public static class Builder { // Optional parameters private String keyVersion; - private List keyOperations; + private List keyOperations; private KeyAttributes attributes; private Map tags; @@ -83,7 +82,7 @@ public Builder withVersion(String keyVersion) { * the key operation list * @return the Builder object itself. */ - public Builder withKeyOperations(List keyOperations) { + public Builder withKeyOperations(List keyOperations) { this.keyOperations = keyOperations; return this; } @@ -129,7 +128,7 @@ private UpdateKeyRequest(Builder builder) { keyVersion = builder.keyVersion == null ? "" : builder.keyVersion; if (builder.keyOperations != null) { - keyOperations = new ArrayList(builder.keyOperations); + keyOperations = new ArrayList(builder.keyOperations); } else { keyOperations = null; } @@ -172,7 +171,7 @@ public String keyVersion() { /** * @return the key operations */ - public List keyOperations() { + public List keyOperations() { return keyOperations; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/package-info.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java new file mode 100755 index 0000000000000..96ee1a2d303e8 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java @@ -0,0 +1,51 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.webkey; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Supported JsonWebKey Algorithms. + */ +public final class JsonWebKeyEncryptionAlgorithm { + + /** + * The 'RSA-OAEP' algorithm. + */ + public static final String RSAOAEP = "RSA-OAEP"; + + /** + * The 'RSA1_5' algorithm. + */ + public static final String RSA15 = "RSA1_5"; + + /** + * All the JWK encryption algorithms. + */ + public static final List ALL_ALGORITHMS = + Collections.unmodifiableList( + Arrays.asList(new String[] {RSA15, RSAOAEP})); + + private JsonWebKeyEncryptionAlgorithm() { + // not instantiable + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java new file mode 100755 index 0000000000000..50360fee81496 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java @@ -0,0 +1,71 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.webkey; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Supported JsonWebKey operations. + */ +public final class JsonWebKeyOperation { + + /** + * Encrypt operation. + */ + public static final String ENCRYPT = "encrypt"; + + /** + * Decrypt operation. + */ + public static final String DECRYPT = "decrypt"; + + /** + * Sign operation. + */ + public static final String SIGN = "sign"; + + /** + * Verify operation. + */ + public static final String VERIFY = "verify"; + + /** + * WrapKey operation. + */ + public static final String WRAP = "wrapKey"; + + /** + * UnwrapKey operation. + */ + public static final String UNWRAP = "unwrapKey"; + + /** + * All JWK operations. + */ + public static final List ALL_OPERATIONS = + Collections.unmodifiableList( + Arrays.asList(new String[] {ENCRYPT, DECRYPT, SIGN, VERIFY, WRAP, UNWRAP })); + + private JsonWebKeyOperation() { + // not instantiable + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java new file mode 100755 index 0000000000000..fa9737305d268 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java @@ -0,0 +1,60 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.webkey; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Supported JsonWebKey Algorithms. + */ +public final class JsonWebKeySignatureAlgorithm { + + /** + * The 'RS256' algorithm. + */ + public static final String RS256 = "RS256"; + + /** + * The 'RS384' algorithm. + */ + public static final String RS384 = "RS384"; + + /** + * The 'RS512' algorithm. + */ + public static final String RS512 = "RS512"; + + /** + * The 'RSNULL' algorithm. + */ + public static final String RSNULL = "RSNULL"; + + /** + * All JWK algorithms. + */ + public static final List ALL_ALGORITHMS = + Collections.unmodifiableList( + Arrays.asList(new String[] {RS256, RS384, RS512, RSNULL})); + + private JsonWebKeySignatureAlgorithm() { + // not instantiable + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java new file mode 100755 index 0000000000000..a04d9b3c40540 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java @@ -0,0 +1,60 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.webkey; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Supported JsonWebKey key types (kty). + */ +public final class JsonWebKeyType { + + /** + * The Elliptic Curve 'EC' key type. + */ + public static final String EC = "EC"; + + /** + * The 'RSA' key type. + */ + public static final String RSA = "RSA"; + + /** + * The 'RSA-HSM' key type. + */ + public static final String RSAHSM = "RSA-HSM"; + + /** + * The Octet 'oct' key type. + */ + public static final String OCT = "oct"; + + /** + * All JWK key types. + */ + public static final List ALL_TYPES = + Collections.unmodifiableList( + Arrays.asList(new String[] {EC, RSA, RSAHSM, OCT})); + + private JsonWebKeyType() { + // not instantiable + } +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java new file mode 100755 index 0000000000000..30b69d136c2b7 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. + +/** + * This package contains the classes for KeyVaultClient. Performs cryptographic + * key operations and vault operations against the Key Vault service. + */ +package com.microsoft.azure.keyvault.webkey; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java old mode 100644 new mode 100755 index b4155c00d1b08..08ff519858b73 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -33,10 +33,6 @@ import java.util.Random; import javax.crypto.Cipher; -import com.microsoft.azure.keyvault.models.JsonWebKeyEncryptionAlgorithm; -import com.microsoft.azure.keyvault.models.JsonWebKeyOperation; -import com.microsoft.azure.keyvault.models.JsonWebKeySignatureAlgorithm; -import com.microsoft.azure.keyvault.models.JsonWebKeyType; import org.joda.time.DateTime; import org.junit.Assert; import org.junit.Test; @@ -52,6 +48,10 @@ import com.microsoft.azure.keyvault.requests.ImportKeyRequest; import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; public class KeyOperationsTest extends KeyVaultClientIntegrationTestBase { @@ -64,15 +64,15 @@ public void transparentAuthentication() throws Exception { // Create a key on a vault. { - KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); - validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null); + KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); + validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, "RSA", null); } // Create a key on a different vault. Key Vault Data Plane returns 401, // which must be transparently handled by KeyVaultCredentials. { - KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); - validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null); + KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, "RSA").build()).getBody(); + validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, "RSA", null); } } @@ -98,7 +98,7 @@ private void checkImportOperation(KeyBundle keyBundle, boolean importToHardware) .Builder(getVaultUri(), KEY_NAME, keyBundle.key()) .withHsm(importToHardware) .build()).getBody(); - validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? JsonWebKeyType.RSA_HSM : JsonWebKeyType.RSA, importedJwk.keyOps()); + validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? "RSA-HSM" : "RSA", importedJwk.keyOps()); checkEncryptDecryptSequence(importedJwk, importResultBundle); } @@ -111,7 +111,7 @@ private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle impor // Encrypt in the service. { - KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); } @@ -136,7 +136,7 @@ private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle impor // Decrypt in the service. { - KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA1_5, cipherText).getBody(); + KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA15, cipherText).getBody(); byte[] beforeEncrypt = plainText; byte[] afterDecrypt = result.result(); @@ -150,8 +150,8 @@ public void crudOperations() throws Exception { KeyBundle createdBundle; { // Create key - createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); - validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null); + createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null); } // Key identifier. @@ -195,7 +195,7 @@ public void crudOperations() throws Exception { .withMonthOfYear(2) .withDayOfMonth(1) .withYear(2050)); - List key_ops = Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT); + List key_ops = Arrays.asList("encrypt", "decrypt"); Map tags = new HashMap(); tags.put("foo", "baz"); createdBundle.key().withKeyOps(key_ops); @@ -224,7 +224,7 @@ public void crudOperations() throws Exception { .withMonthOfYear(2) .withDayOfMonth(1) .withYear(2000)); - List key_ops = Arrays.asList(JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY); + List key_ops = Arrays.asList("sign", "verify"); createdBundle.key().withKeyOps(key_ops); Map tags = new HashMap(); tags.put("foo", "baz"); @@ -268,9 +268,9 @@ public void backupRestore() throws Exception { // Creates a key { createdBundle = keyVaultClient.createKey( - new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA) + new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA") .build()).getBody(); - validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null); } // Creates a backup of key. @@ -300,7 +300,7 @@ public void listKeys() throws Exception { int failureCount = 0; for (;;) { try { - KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, JsonWebKeyType.RSA).build()).getBody(); + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, "RSA").build()).getBody(); KeyIdentifier kid = new KeyIdentifier(createdBundle.key().kid()); keys.add(kid.baseIdentifier()); break; @@ -349,7 +349,7 @@ public void listKeyVersions() throws Exception { int failureCount = 0; for (;;) { try { - KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); keys.add(createdBundle.key().kid()); break; } catch (KeyVaultErrorException e) { @@ -400,19 +400,19 @@ public void encryptDecryptOperations() throws Exception { // encrypt and decrypt using kid WO version { - result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); + result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } // encrypt and decrypt using full kid { - result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); + result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } } @@ -432,19 +432,19 @@ public void wrapUnwrapOperations() throws Exception { // wrap and unwrap using kid WO version { - result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); + result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } // wrap and unwrap using full kid { - result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); + result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } } @@ -492,7 +492,7 @@ private static JsonWebKey importTestKey() throws Exception { JsonWebKey key = JsonWebKey.fromRSA(getTestKeyMaterial()); key.withKty(JsonWebKeyType.RSA); - key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT, JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY, JsonWebKeyOperation.WRAP_KEY, JsonWebKeyOperation.UNWRAP_KEY)); + key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT, JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY, JsonWebKeyOperation.WRAP, JsonWebKeyOperation.UNWRAP)); keyBundle = keyVaultClient.importKey( new ImportKeyRequest @@ -500,7 +500,7 @@ private static JsonWebKey importTestKey() throws Exception { .withHsm(false) .build()).getBody(); - validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null); + validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, "RSA", null); return keyBundle.key(); } @@ -521,12 +521,12 @@ private static KeyPair getWellKnownKey() throws Exception { KeySpec publicKeySpec = new RSAPublicKeySpec(modulus, publicExponent); KeySpec privateKeySpec = new RSAPrivateCrtKeySpec(modulus, publicExponent, privateExponent, primeP, primeQ, primeExponentP, primeExponentQ, crtCoefficient); - KeyFactory keyFactory = KeyFactory.getInstance(JsonWebKeyType.RSA.toString()); + KeyFactory keyFactory = KeyFactory.getInstance("RSA"); return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); } - private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, JsonWebKeyType kty, List key_ops) throws Exception { + private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops) throws Exception { String prefix = vault + "/keys/" + keyName + "/"; String kid = bundle.key().kid(); Assert.assertTrue( diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java old mode 100644 new mode 100755 diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java old mode 100644 new mode 100755 From 17deec75ac0508d285eaa0f62cef89073466e3c6 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Fri, 19 Aug 2016 12:00:44 -0700 Subject: [PATCH 21/56] Fixed to the key vault certificate feature and tests. 1) getObjests is changed to listObjects 2) Removed getObjectsNext as this is controlled by the library 3) Changes the request parameters for some update* operations to reflect mandatory and optional parameters. 4) Added tests for Async and some additional tests --- .../azure/keyvault/KeyVaultClient.java | 285 +-- .../azure/keyvault/KeyVaultClientImpl.java | 350 ++- .../keyvault/models/CertificateBundle.java | 4 +- .../CertificateIssuerSetParameters.java | 121 + .../CertificateIssuerUpdateParameters.java | 121 + .../keyvault/models/CertificateOperation.java | 4 +- .../CertificateOperationUpdateParameter.java | 45 + .../models/CertificateUpdateParameters.java | 26 + .../azure/keyvault/models/IssuerBundle.java | 4 +- .../azure/keyvault/models/JsonWebKey.java | 5 +- .../azure/keyvault/models/KeyBundle.java | 4 +- .../models/KeyVaultErrorException.java | 11 + .../azure/keyvault/models/SecretBundle.java | 4 +- .../requests/SetCertificateIssuerRequest.java | 110 +- .../UpdateCertificateIssuerRequest.java | 107 +- .../UpdateCertificateOperationRequest.java | 32 +- .../UpdateCertificatePolicyRequest.java | 2 +- .../requests/UpdateCertificateRequest.java | 69 + .../keyvault/test/AsyncOperationsTest.java | 242 ++ .../test/CertificateOperationsTest.java | 2141 ++++++++--------- .../keyvault/test/KeyOperationsTest.java | 166 +- .../KeyVaultClientIntegrationTestBase.java | 12 +- .../keyvault/test/SecretOperationsTest.java | 172 +- 23 files changed, 2383 insertions(+), 1654 deletions(-) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java create mode 100644 azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 52cbba1b6abbe..1c1d45cab33d3 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -26,7 +26,6 @@ import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyResult; -import com.microsoft.azure.keyvault.models.PageImpl; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.models.SecretItem; import com.microsoft.azure.keyvault.requests.CreateCertificateRequest; @@ -425,7 +424,7 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) + public ServiceResponse> listKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName); } @@ -438,7 +437,7 @@ public ServiceResponse> getKeyVersions(final String vaultBase * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { + public ServiceCall> listKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, serviceCallback); } /** @@ -452,7 +451,7 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) + public ServiceResponse> listKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName, maxresults); } @@ -466,7 +465,7 @@ public ServiceResponse> getKeyVersions(final String vaultBase * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, maxresults, serviceCallback); } @@ -479,7 +478,7 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeys(final String vaultBaseUrl) + public ServiceResponse> listKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeys(vaultBaseUrl); } @@ -491,7 +490,7 @@ public ServiceResponse> getKeys(final String vaultBaseUrl) * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + public ServiceCall> listKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, serviceCallback); } /** @@ -504,7 +503,7 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) + public ServiceResponse> listKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeys(vaultBaseUrl, maxresults); } @@ -517,7 +516,7 @@ public ServiceResponse> getKeys(final String vaultBaseUrl, fi * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -962,7 +961,7 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecrets(final String vaultBaseUrl) + public ServiceResponse> listSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecrets(vaultBaseUrl); } @@ -974,7 +973,7 @@ public ServiceResponse> getSecrets(final String vaultBaseU * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + public ServiceCall> listSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, serviceCallback); } /** @@ -987,7 +986,7 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) + public ServiceResponse> listSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecrets(vaultBaseUrl, maxresults); } @@ -1000,7 +999,7 @@ public ServiceResponse> getSecrets(final String vaultBaseU * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -1014,7 +1013,7 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName) + public ServiceResponse> listSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName); } @@ -1027,7 +1026,7 @@ public ServiceResponse> getSecretVersions(final String vau * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { + public ServiceCall> listSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, serviceCallback); } /** @@ -1041,7 +1040,7 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) + public ServiceResponse> listSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName, maxresults); } @@ -1055,7 +1054,7 @@ public ServiceResponse> getSecretVersions(final String vau * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, maxresults, serviceCallback); } @@ -1068,7 +1067,7 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificates(final String vaultBaseUrl) + public ServiceResponse> listCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificates(vaultBaseUrl); } @@ -1080,7 +1079,7 @@ public ServiceResponse> getCertificates(final String * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + public ServiceCall> listCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, serviceCallback); } /** @@ -1093,7 +1092,7 @@ public ServiceCall> getCertificatesAsync(final String vaul * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificates(final String vaultBaseUrl, final Integer maxresults) + public ServiceResponse> listCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificates(vaultBaseUrl, maxresults); } @@ -1106,7 +1105,7 @@ public ServiceResponse> getCertificates(final String * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -1223,7 +1222,7 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl) + public ServiceResponse> listCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl); } @@ -1235,7 +1234,7 @@ public ServiceResponse> getCertificateIssuers(f * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + public ServiceCall> listCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, serviceCallback); } /** @@ -1248,7 +1247,7 @@ public ServiceCall> getCertificateIssuersAsync(final * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) + public ServiceResponse> listCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl, maxresults); } @@ -1261,7 +1260,7 @@ public ServiceResponse> getCertificateIssuers(f * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -1279,8 +1278,11 @@ public ServiceResponse setCertificateIssuer(SetCertificateIssuerRe throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setCertificateIssuer( setCertificateIssuerRequest.vaultBaseUrl(), - setCertificateIssuerRequest.issuerName(), - setCertificateIssuerRequest.issuer()); + setCertificateIssuerRequest.issuerName(), + setCertificateIssuerRequest.provider(), + setCertificateIssuerRequest.credentials(), + setCertificateIssuerRequest.organizationDetails(), + setCertificateIssuerRequest.attributes()); } /** @@ -1295,7 +1297,10 @@ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerR return innerKeyVaultClient.setCertificateIssuerAsync( setCertificateIssuerRequest.vaultBaseUrl(), setCertificateIssuerRequest.issuerName(), - setCertificateIssuerRequest.issuer(), + setCertificateIssuerRequest.provider(), + setCertificateIssuerRequest.credentials(), + setCertificateIssuerRequest.organizationDetails(), + setCertificateIssuerRequest.attributes(), serviceCallback); } @@ -1313,8 +1318,11 @@ public ServiceResponse updateCertificateIssuer(UpdateCertificateIs throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificateIssuer( updateCertificateIssuerRequest.vaultBaseUrl(), - updateCertificateIssuerRequest.issuerName(), - updateCertificateIssuerRequest.issuer()); + updateCertificateIssuerRequest.issuerName(), + updateCertificateIssuerRequest.provider(), + updateCertificateIssuerRequest.credentials(), + updateCertificateIssuerRequest.organizationDetails(), + updateCertificateIssuerRequest.attributes()); } /** @@ -1329,8 +1337,11 @@ public ServiceResponse updateCertificateIssuer(UpdateCertificateIs public ServiceCall updateCertificateIssuerAsync(UpdateCertificateIssuerRequest updateCertificateIssuerRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateIssuerAsync( updateCertificateIssuerRequest.vaultBaseUrl(), - updateCertificateIssuerRequest.issuerName(), - updateCertificateIssuerRequest.issuer(), + updateCertificateIssuerRequest.issuerName(), + updateCertificateIssuerRequest.provider(), + updateCertificateIssuerRequest.credentials(), + updateCertificateIssuerRequest.organizationDetails(), + updateCertificateIssuerRequest.attributes(), serviceCallback); } @@ -1478,7 +1489,7 @@ public ServiceCall importCertificateAsync(ImportCertificateRe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName) + public ServiceResponse> listCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName); } @@ -1491,7 +1502,7 @@ public ServiceResponse> getCertificateVersions(final * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { + public ServiceCall> listCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback); } /** @@ -1505,7 +1516,7 @@ public ServiceCall> getCertificateVersionsAsync(final Stri * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) + public ServiceResponse> listCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName, maxresults); } @@ -1519,7 +1530,7 @@ public ServiceResponse> getCertificateVersions(final * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceCall> listCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, maxresults, serviceCallback); } @@ -1576,7 +1587,7 @@ public ServiceResponse updateCertificatePolicy(UpdateCertific * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest, final ServiceCallback serviceCallback) { + public ServiceCall updateCertificatePolicyAsync(UpdateCertificatePolicyRequest updateCertificatePolicyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificatePolicyAsync( updateCertificatePolicyRequest.vaultBaseUrl(), updateCertificatePolicyRequest.certificateName(), @@ -1598,8 +1609,9 @@ public ServiceResponse updateCertificate(UpdateCertificateReq throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificate( updateCertificateRequest.vaultBaseUrl(), - updateCertificateRequest.certificateName(), - updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificateName(), + updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificatePolicy(), updateCertificateRequest.certificateAttributes(), updateCertificateRequest.tags()); } @@ -1616,7 +1628,8 @@ public ServiceCall updateCertificateAsync(UpdateCertificateRe return innerKeyVaultClient.updateCertificateAsync( updateCertificateRequest.vaultBaseUrl(), updateCertificateRequest.certificateName(), - updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificateVersion(), + updateCertificateRequest.certificatePolicy(), updateCertificateRequest.certificateAttributes(), updateCertificateRequest.tags(), serviceCallback); @@ -1720,7 +1733,7 @@ public ServiceResponse updateCertificateOperation(UpdateCe return innerKeyVaultClient.updateCertificateOperation( updateCertificateOperationRequest.vaultBaseUrl(), updateCertificateOperationRequest.certificateName(), - updateCertificateOperationRequest.certificateOperation()); + updateCertificateOperationRequest.cancellationRequested()); } /** @@ -1735,7 +1748,7 @@ public ServiceCall updateCertificateOperationAsync(UpdateC return innerKeyVaultClient.updateCertificateOperationAsync( updateCertificateOperationRequest.vaultBaseUrl(), updateCertificateOperationRequest.certificateName(), - updateCertificateOperationRequest.certificateOperation(), + updateCertificateOperationRequest.cancellationRequested(), serviceCallback); } @@ -1789,7 +1802,7 @@ public ServiceResponse deleteCertificateOperation(String v * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteCertificateOperationAsync(vaultBaseUrl, certificateName, serviceCallback); } @@ -1868,9 +1881,6 @@ public ServiceResponse getPendingCertificateSigningRequest(String vaultB * @return the {@link ServiceCall} object */ public ServiceCall getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - if (serviceCallback == null) { - throw new IllegalArgumentException("ServiceCallback is required for async calls."); - } if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1901,187 +1911,4 @@ public void onResponse(Call call, Response response) }); return serviceCall; } - - /** - * List the versions of the specified key. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getKeyVersionsNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getKeyVersionsNext(nextPageLink); - } - - /** - * List the versions of the specified key. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getKeyVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); - } - - /** - * List keys in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getKeysNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getKeysNext(nextPageLink); - } - - /** - * List keys in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getKeysNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getKeysNextAsync(nextPageLink, serviceCall, serviceCallback); - } - - /** - * List secrets in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getSecretsNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getSecretsNext(nextPageLink); - } - - /** - * List secrets in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getSecretsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getSecretsNextAsync(nextPageLink, serviceCall, serviceCallback); - } - - /** - * List the versions of the specified secret. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getSecretVersionsNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getSecretVersionsNext(nextPageLink); - } - - /** - * List the versions of the specified secret. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getSecretVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); - } - - /** - * List certificates in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getCertificatesNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificatesNext(nextPageLink); - } - - /** - * List certificates in the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getCertificatesNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificatesNextAsync(nextPageLink, serviceCall, serviceCallback); - } - - /** - * List certificate issuers for the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateIssuersNext(nextPageLink); - } - - /** - * List certificate issuers for the specified vault. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificateIssuersNextAsync(nextPageLink, serviceCall, serviceCallback); - } - - /** - * List the versions of a certificate. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. - */ - public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return innerKeyVaultClient.getCertificateVersionsNext(nextPageLink); - } - - /** - * List the versions of a certificate. - * - * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object - */ - public ServiceCall> getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return innerKeyVaultClient.getCertificateVersionsNextAsync(nextPageLink, serviceCall, serviceCallback); - } - } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 5d3610adf8074..8b5c045ede14a 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -1,4 +1,8 @@ /** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. @@ -17,13 +21,18 @@ import com.microsoft.azure.keyvault.models.CertificateCreateParameters; import com.microsoft.azure.keyvault.models.CertificateImportParameters; import com.microsoft.azure.keyvault.models.CertificateIssuerItem; +import com.microsoft.azure.keyvault.models.CertificateIssuerSetParameters; +import com.microsoft.azure.keyvault.models.CertificateIssuerUpdateParameters; import com.microsoft.azure.keyvault.models.CertificateItem; import com.microsoft.azure.keyvault.models.CertificateMergeParameters; import com.microsoft.azure.keyvault.models.CertificateOperation; +import com.microsoft.azure.keyvault.models.CertificateOperationUpdateParameter; import com.microsoft.azure.keyvault.models.CertificatePolicy; import com.microsoft.azure.keyvault.models.CertificateUpdateParameters; import com.microsoft.azure.keyvault.models.Contacts; +import com.microsoft.azure.keyvault.models.IssuerAttributes; import com.microsoft.azure.keyvault.models.IssuerBundle; +import com.microsoft.azure.keyvault.models.IssuerCredentials; import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; import com.microsoft.azure.keyvault.models.KeyBundle; @@ -38,6 +47,7 @@ import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyParameters; import com.microsoft.azure.keyvault.models.KeyVerifyResult; +import com.microsoft.azure.keyvault.models.OrganizationDetails; import com.microsoft.azure.keyvault.models.PageImpl; import com.microsoft.azure.keyvault.models.SecretAttributes; import com.microsoft.azure.keyvault.models.SecretBundle; @@ -342,11 +352,11 @@ interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/issuers/{issuer-name}") - Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerSetParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/issuers/{issuer-name}") - Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Body IssuerBundle issuer, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerUpdateParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers/{issuer-name}") @@ -386,7 +396,7 @@ interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/pending") - Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Body CertificateOperation certificateOperation, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateOperationUpdateParameter certificateOperation, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/pending") @@ -1647,7 +1657,7 @@ private ServiceResponse restoreKeyDelegate(Response res * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization @@ -1687,7 +1697,7 @@ public ServiceResponse encrypt(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object @@ -1750,7 +1760,7 @@ private ServiceResponse encryptDelegate(Response decrypt(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object @@ -1853,7 +1863,7 @@ private ServiceResponse decryptDelegate(Response sign(String vaultBaseUrl, String keyN * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object @@ -1956,7 +1966,7 @@ private ServiceResponse signDelegate(Response * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param digest The digest used for signing * @param signature The signature to be verified * @throws KeyVaultErrorException exception thrown from REST call @@ -2001,7 +2011,7 @@ public ServiceResponse verify(String vaultBaseUrl, String keyNa * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param digest The digest used for signing * @param signature The signature to be verified * @param serviceCallback the async ServiceCallback to handle successful and failed responses. @@ -2069,7 +2079,7 @@ private ServiceResponse verifyDelegate(Response r * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization @@ -2109,7 +2119,7 @@ public ServiceResponse wrapKey(String vaultBaseUrl, String k * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object @@ -2172,7 +2182,7 @@ private ServiceResponse wrapKeyDelegate(Response unwrapKey(String vaultBaseUrl, String * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @param algorithm algorithm identifier + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object @@ -3712,28 +3722,35 @@ private ServiceResponse> getCertificateIssuersDe * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param issuer The issuer bundle. + * @param provider The name of the issuer. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundle issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (issuerName == null) { throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } - if (issuer == null) { - throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); - } if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(issuer); + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + final IssuerCredentials credentials = null; + final OrganizationDetails organizationDetails = null; + final IssuerAttributes attributes = null; + CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); + parameter.withProvider(provider); + parameter.withCredentials(null); + parameter.withOrganizationDetails(null); + parameter.withAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); return setCertificateIssuerDelegate(call.execute()); } @@ -3742,26 +3759,129 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param issuer The issuer bundle. + * @param provider The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object */ - public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) { + public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + final IssuerCredentials credentials = null; + final OrganizationDetails organizationDetails = null; + final IssuerAttributes attributes = null; + CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); + parameter.withProvider(provider); + parameter.withCredentials(null); + parameter.withOrganizationDetails(null); + parameter.withAttributes(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = setCertificateIssuerDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The name of the issuer. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (issuerName == null) { throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } - if (issuer == null) { - throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + Validator.validate(credentials); + Validator.validate(organizationDetails); + Validator.validate(attributes); + CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); + parameter.withProvider(provider); + parameter.withCredentials(credentials); + parameter.withOrganizationDetails(organizationDetails); + parameter.withAttributes(attributes); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); + return setCertificateIssuerDelegate(call.execute()); + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The name of the issuer. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link Call} object + */ + public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(issuer); + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + Validator.validate(credentials); + Validator.validate(organizationDetails); + Validator.validate(attributes); + CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); + parameter.withProvider(provider); + parameter.withCredentials(credentials); + parameter.withOrganizationDetails(organizationDetails); + parameter.withAttributes(attributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall<>(call); call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override @@ -3795,28 +3915,35 @@ private ServiceResponse setCertificateIssuerDelegate(Response updateCertificateIssuer(String vaultBaseUrl, String issuerName, IssuerBundle issuer) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (issuerName == null) { throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } - if (issuer == null) { - throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); - } if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(issuer); + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + final IssuerCredentials credentials = null; + final OrganizationDetails organizationDetails = null; + final IssuerAttributes attributes = null; + CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); + parameter.withProvider(provider); + parameter.withCredentials(null); + parameter.withOrganizationDetails(null); + parameter.withAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); return updateCertificateIssuerDelegate(call.execute()); } @@ -3825,26 +3952,129 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param issuer The issuer bundle. + * @param provider The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object */ - public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, IssuerBundle issuer, final ServiceCallback serviceCallback) { + public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); + } + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + final IssuerCredentials credentials = null; + final OrganizationDetails organizationDetails = null; + final IssuerAttributes attributes = null; + CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); + parameter.withProvider(provider); + parameter.withCredentials(null); + parameter.withOrganizationDetails(null); + parameter.withAttributes(null); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); + final ServiceCall serviceCall = new ServiceCall<>(call); + call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { + @Override + public void onResponse(Call call, Response response) { + try { + ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); + if (serviceCallback != null) { + serviceCallback.success(clientResponse); + } + serviceCall.success(clientResponse); + } catch (KeyVaultErrorException | IOException exception) { + if (serviceCallback != null) { + serviceCallback.failure(exception); + } + serviceCall.failure(exception); + } + } + }); + return serviceCall; + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The name of the issuer. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @throws KeyVaultErrorException exception thrown from REST call + * @throws IOException exception thrown from serialization/deserialization + * @throws IllegalArgumentException exception thrown from invalid parameters + * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + */ + public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (issuerName == null) { throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } - if (issuer == null) { - throw new IllegalArgumentException("Parameter issuer is required and cannot be null."); + if (this.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); + } + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + Validator.validate(credentials); + Validator.validate(organizationDetails); + Validator.validate(attributes); + CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); + parameter.withProvider(provider); + parameter.withCredentials(credentials); + parameter.withOrganizationDetails(organizationDetails); + parameter.withAttributes(attributes); + String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); + Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); + return updateCertificateIssuerDelegate(call.execute()); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The name of the issuer. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link Call} object + */ + public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { + if (vaultBaseUrl == null) { + throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); + } + if (issuerName == null) { + throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); } if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(issuer); + if (provider == null) { + throw new IllegalArgumentException("Parameter provider is required and cannot be null."); + } + Validator.validate(credentials); + Validator.validate(organizationDetails); + Validator.validate(attributes); + CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); + parameter.withProvider(provider); + parameter.withCredentials(credentials); + parameter.withOrganizationDetails(organizationDetails); + parameter.withAttributes(attributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, issuer, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall<>(call); call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override @@ -4742,9 +4972,11 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } + final CertificatePolicy certificatePolicy = null; final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.withCertificatePolicy(null); parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -4774,9 +5006,11 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } + final CertificatePolicy certificatePolicy = null; final CertificateAttributes certificateAttributes = null; final Map tags = null; CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.withCertificatePolicy(null); parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -4808,6 +5042,7 @@ public void onResponse(Call call, Response response) * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate + * @param certificatePolicy The management policy for the certificate * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call @@ -4815,7 +5050,7 @@ public void onResponse(Call call, Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4828,9 +5063,11 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } + Validator.validate(certificatePolicy); Validator.validate(certificateAttributes); Validator.validate(tags); CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.withCertificatePolicy(certificatePolicy); parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -4844,12 +5081,13 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate + * @param certificatePolicy The management policy for the certificate * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object */ - public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4862,9 +5100,11 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } + Validator.validate(certificatePolicy); Validator.validate(certificateAttributes); Validator.validate(tags); CertificateUpdateParameters parameters = new CertificateUpdateParameters(); + parameters.withCertificatePolicy(certificatePolicy); parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); @@ -4983,28 +5223,26 @@ private ServiceResponse getCertificateDelegate(Response updateCertificateOperation(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse updateCertificateOperation(String vaultBaseUrl, String certificateName, boolean cancellationRequested) throws KeyVaultErrorException, IOException, IllegalArgumentException { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } - if (certificateOperation == null) { - throw new IllegalArgumentException("Parameter certificateOperation is required and cannot be null."); - } if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(certificateOperation); + CertificateOperationUpdateParameter certificateOperation = new CertificateOperationUpdateParameter(); + certificateOperation.withCancellationRequested(cancellationRequested); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Call call = service.updateCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), certificateOperation, parameterizedHost, this.userAgent()); return updateCertificateOperationDelegate(call.execute()); } @@ -5013,26 +5251,24 @@ public ServiceResponse updateCertificateOperation(String v * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param certificateOperation The certificate operation response. + * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object */ - public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, CertificateOperation certificateOperation, final ServiceCallback serviceCallback) { + public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested, final ServiceCallback serviceCallback) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } if (certificateName == null) { throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); } - if (certificateOperation == null) { - throw new IllegalArgumentException("Parameter certificateOperation is required and cannot be null."); - } if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - Validator.validate(certificateOperation); + CertificateOperationUpdateParameter certificateOperation = new CertificateOperationUpdateParameter(); + certificateOperation.withCancellationRequested(cancellationRequested); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateOperation(certificateName, certificateOperation, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); + Call call = service.updateCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), certificateOperation, parameterizedHost, this.userAgent()); final ServiceCall serviceCall = new ServiceCall<>(call); call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { @Override diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java index eda7dfbc9da3a..44417b1eea285 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java @@ -13,6 +13,7 @@ import com.microsoft.azure.keyvault.CertificateIdentifier; import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.SecretIdentifier; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; import com.microsoft.rest.Base64Url; import java.io.IOException; @@ -239,7 +240,8 @@ public KeyIdentifier keyIdentifier() { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java new file mode 100644 index 0000000000000..f9daf44e44fda --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The certificate issuer set parameters. + */ +public class CertificateIssuerSetParameters { + /** + * The name of the issuer. + */ + @JsonProperty(required = true) + private String provider; + + /** + * The credentials to be used for the issuer. + */ + private IssuerCredentials credentials; + + /** + * Details of the organization as provided to the issuer. + */ + @JsonProperty(value = "org_details") + private OrganizationDetails organizationDetails; + + /** + * Attributes of the issuer object. + */ + private IssuerAttributes attributes; + + /** + * Get the provider value. + * + * @return the provider value + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider value. + * + * @param provider the provider value to set + * @return the CertificateIssuerSetParameters object itself. + */ + public CertificateIssuerSetParameters withProvider(String provider) { + this.provider = provider; + return this; + } + + /** + * Get the credentials value. + * + * @return the credentials value + */ + public IssuerCredentials credentials() { + return this.credentials; + } + + /** + * Set the credentials value. + * + * @param credentials the credentials value to set + * @return the CertificateIssuerSetParameters object itself. + */ + public CertificateIssuerSetParameters withCredentials(IssuerCredentials credentials) { + this.credentials = credentials; + return this; + } + + /** + * Get the organizationDetails value. + * + * @return the organizationDetails value + */ + public OrganizationDetails organizationDetails() { + return this.organizationDetails; + } + + /** + * Set the organizationDetails value. + * + * @param organizationDetails the organizationDetails value to set + * @return the CertificateIssuerSetParameters object itself. + */ + public CertificateIssuerSetParameters withOrganizationDetails(OrganizationDetails organizationDetails) { + this.organizationDetails = organizationDetails; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public IssuerAttributes attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the CertificateIssuerSetParameters object itself. + */ + public CertificateIssuerSetParameters withAttributes(IssuerAttributes attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java new file mode 100644 index 0000000000000..7af311457b0ea --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The certificate issuer set parameters. + */ +public class CertificateIssuerUpdateParameters { + /** + * The name of the issuer. + */ + @JsonProperty(required = true) + private String provider; + + /** + * The credentials to be used for the issuer. + */ + private IssuerCredentials credentials; + + /** + * Details of the organization as provided to the issuer. + */ + @JsonProperty(value = "org_details") + private OrganizationDetails organizationDetails; + + /** + * Attributes of the issuer object. + */ + private IssuerAttributes attributes; + + /** + * Get the provider value. + * + * @return the provider value + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider value. + * + * @param provider the provider value to set + * @return the CertificateIssuerUpdateParameters object itself. + */ + public CertificateIssuerUpdateParameters withProvider(String provider) { + this.provider = provider; + return this; + } + + /** + * Get the credentials value. + * + * @return the credentials value + */ + public IssuerCredentials credentials() { + return this.credentials; + } + + /** + * Set the credentials value. + * + * @param credentials the credentials value to set + * @return the CertificateIssuerUpdateParameters object itself. + */ + public CertificateIssuerUpdateParameters withCredentials(IssuerCredentials credentials) { + this.credentials = credentials; + return this; + } + + /** + * Get the organizationDetails value. + * + * @return the organizationDetails value + */ + public OrganizationDetails organizationDetails() { + return this.organizationDetails; + } + + /** + * Set the organizationDetails value. + * + * @param organizationDetails the organizationDetails value to set + * @return the CertificateIssuerUpdateParameters object itself. + */ + public CertificateIssuerUpdateParameters withOrganizationDetails(OrganizationDetails organizationDetails) { + this.organizationDetails = organizationDetails; + return this; + } + + /** + * Get the attributes value. + * + * @return the attributes value + */ + public IssuerAttributes attributes() { + return this.attributes; + } + + /** + * Set the attributes value. + * + * @param attributes the attributes value to set + * @return the CertificateIssuerUpdateParameters object itself. + */ + public CertificateIssuerUpdateParameters withAttributes(IssuerAttributes attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java index c8aea174e4bf3..02fd132ae9754 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.CertificateOperationIdentifier; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** * A certificate operation is returned in case of async requests. @@ -255,7 +256,8 @@ public CertificateOperationIdentifier certificateOperationIdentifier() { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java new file mode 100644 index 0000000000000..dd7c42a5f4ac0 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A certificate operation is returned in case of async requests. + */ +public class CertificateOperationUpdateParameter { + /** + * Indicates if cancellation was requested on the certificate operation. + */ + @JsonProperty(value = "cancellation_requested", required = true) + private boolean cancellationRequested; + + /** + * Get the cancellationRequested value. + * + * @return the cancellationRequested value + */ + public boolean cancellationRequested() { + return this.cancellationRequested; + } + + /** + * Set the cancellationRequested value. + * + * @param cancellationRequested the cancellationRequested value to set + * @return the CertificateOperationUpdateParameter object itself. + */ + public CertificateOperationUpdateParameter withCancellationRequested(boolean cancellationRequested) { + this.cancellationRequested = cancellationRequested; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java index 0e3d426eed6cf..e3e899ff572c6 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java @@ -17,6 +17,12 @@ * The certificate update parameters. */ public class CertificateUpdateParameters { + /** + * The management policy for the certificate. + */ + @JsonProperty(value = "policy") + private CertificatePolicy certificatePolicy; + /** * The attributes of the certificate (optional). */ @@ -28,6 +34,26 @@ public class CertificateUpdateParameters { */ private Map tags; + /** + * Get the certificatePolicy value. + * + * @return the certificatePolicy value + */ + public CertificatePolicy certificatePolicy() { + return this.certificatePolicy; + } + + /** + * Set the certificatePolicy value. + * + * @param certificatePolicy the certificatePolicy value to set + * @return the CertificateUpdateParameters object itself. + */ + public CertificateUpdateParameters withCertificatePolicy(CertificatePolicy certificatePolicy) { + this.certificatePolicy = certificatePolicy; + return this; + } + /** * Get the certificateAttributes value. * diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java index 3dd318e5139f8..e30c98684da69 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.IssuerIdentifier; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** * The issuer for Key Vault certificate. @@ -151,7 +152,8 @@ public IssuerIdentifier issuerIdentifier() { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java index ed9bb700c1543..ef267481ebba1 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java @@ -29,6 +29,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; import com.microsoft.rest.Base64Url; /** @@ -95,7 +96,6 @@ public class JsonWebKey { /** * Symmetric key. */ - @JsonProperty(value = "K") private Base64Url k; /** @@ -436,7 +436,8 @@ public JsonWebKey withT(byte[] t) { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index 4c13b1490a64d..453e5177fab2b 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.KeyIdentifier; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** * A KeyBundle consisting of a WebKey plus its Attributes. @@ -110,7 +111,8 @@ public KeyIdentifier keyIdentifier() { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java index bdcfc617fc14c..43b6a45e162db 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java @@ -29,6 +29,17 @@ public class KeyVaultErrorException extends RestException { * Initializes a new instance of the KeyVaultErrorException class. */ public KeyVaultErrorException() { } + + @Override + public String getMessage() + { + if(body != null && body.error() != null + && body.error().message() != null + && !body.error().message().isEmpty()) { + return body.error().message(); + } + return getMessage(); + } /** * Initializes a new instance of the KeyVaultErrorException class. * diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index 52d7e736fb451..c52baf76b82f9 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.SecretIdentifier; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** * A Secret consisting of a value, id and its attributes. @@ -185,7 +186,8 @@ public SecretIdentifier secretIdentifier() { @Override public String toString() { - ObjectMapper mapper = new ObjectMapper(); + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java index 5c2d00f4d82e6..23201a4a26f4a 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java @@ -1,7 +1,11 @@ package com.microsoft.azure.keyvault.requests; +import java.util.ArrayList; + +import com.microsoft.azure.keyvault.models.AdministratorDetails; import com.microsoft.azure.keyvault.models.IssuerAttributes; -import com.microsoft.azure.keyvault.models.IssuerBundle; +import com.microsoft.azure.keyvault.models.IssuerCredentials; +import com.microsoft.azure.keyvault.models.OrganizationDetails; /** * The set certificate issuer request class. @@ -10,7 +14,10 @@ public final class SetCertificateIssuerRequest { private final String vaultBaseUrl; private final String issuerName; - private final IssuerBundle issuer; + private final String provider; + private final IssuerCredentials credentials; + private final OrganizationDetails organizationDetails; + private final IssuerAttributes attributes; /** * The {@link SetCertificateIssuerRequest} builder. @@ -20,9 +27,12 @@ public static class Builder { // Required parameters private final String vaultBaseUrl; private final String issuerName; + private final String provider; // Optional parameters - private IssuerBundle issuer; + private IssuerCredentials credentials; + private OrganizationDetails organizationDetails; + private IssuerAttributes attributes; /** * The builder for constructing {@link SetCertificateIssuerRequest} @@ -32,24 +42,50 @@ public static class Builder { * The vault name, e.g. https://myvault.vault.azure.net. * @param issuerName * The name of the issuer. + * @param provider The name of the issuer. */ - public Builder(String vaultBaseUrl, String issuerName) { + public Builder(String vaultBaseUrl, String issuerName, String provider) { this.vaultBaseUrl = vaultBaseUrl; this.issuerName = issuerName; + this.provider = provider; } /** - * Set the issuer value. + * Set issuer credentials. * - * @param issuer - * The issuer bundle. + * @param credentials + * The issuer credentials. * @return the Builder object itself. */ - public Builder withIssuer(IssuerBundle issuer) { - this.issuer = issuer; + public Builder withCredentials(IssuerCredentials credentials) { + this.credentials = credentials; return this; } - + + /** + * Set issuer organization details. + * + * @param organizationDetails + * The issuer organization details. + * @return the Builder object itself. + */ + public Builder withOrganizationDetails(OrganizationDetails organizationDetails) { + this.organizationDetails = organizationDetails; + return this; + } + + /** + * Set issuer attributes. + * + * @param organizationDetails + * The issuer attributes. + * @return the Builder object itself. + */ + public Builder withAttributes(IssuerAttributes attributes) { + this.attributes = attributes; + return this; + } + /** * builds the {@link SetCertificateIssuerRequest} object. * @@ -63,15 +99,25 @@ public SetCertificateIssuerRequest build() { private SetCertificateIssuerRequest(Builder builder) { vaultBaseUrl = builder.vaultBaseUrl; issuerName = builder.issuerName; - if (builder.issuer != null) { - issuer = new IssuerBundle().withProvider(builder.issuer.provider()) - .withOrganizationDetails(builder.issuer.organizationDetails()) - .withCredentials(builder.issuer.credentials()); - if (builder.issuer.attributes() != null) { - issuer.withAttributes(new IssuerAttributes().withEnabled(builder.issuer.attributes().enabled())); - } + provider = builder.provider; + if(builder.organizationDetails != null) { + organizationDetails = new OrganizationDetails() + .withId(builder.organizationDetails.id()) + .withAdminDetails(new ArrayList(builder.organizationDetails.adminDetails())); } else { - issuer = null; + organizationDetails = null; + } + if(builder.credentials != null) { + credentials = new IssuerCredentials() + .withAccountId(builder.credentials.accountId()) + .withPassword(builder.credentials.password()); + } else { + credentials = null; + } + if (builder.attributes != null) { + attributes = new IssuerAttributes().withEnabled(builder.attributes.enabled()); + } else { + attributes = null; } } @@ -90,10 +136,30 @@ public String issuerName() { } /** - * @return the issuer + * @return the issuer provider name */ - public IssuerBundle issuer() { - return issuer; + public String provider() { + return provider; + } + + /** + * @return the issuer credentials + */ + public IssuerCredentials credentials() { + return credentials; + } + + /** + * @return the organization details + */ + public OrganizationDetails organizationDetails() { + return organizationDetails; + } + + /** + * @return the issuer attributes + */ + public IssuerAttributes attributes() { + return attributes; } - } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java index 633d16a2e7a70..37d1048673aea 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java @@ -1,7 +1,11 @@ package com.microsoft.azure.keyvault.requests; +import java.util.ArrayList; + +import com.microsoft.azure.keyvault.models.AdministratorDetails; import com.microsoft.azure.keyvault.models.IssuerAttributes; -import com.microsoft.azure.keyvault.models.IssuerBundle; +import com.microsoft.azure.keyvault.models.IssuerCredentials; +import com.microsoft.azure.keyvault.models.OrganizationDetails; /** * The update certificate issuer request class. @@ -9,7 +13,10 @@ public final class UpdateCertificateIssuerRequest { private final String vaultBaseUrl; private final String issuerName; - private final IssuerBundle issuer; + private final String provider; + private final IssuerCredentials credentials; + private final OrganizationDetails organizationDetails; + private final IssuerAttributes attributes; /** * The {@link UpdateCertificateIssuerRequest} builder. @@ -19,9 +26,12 @@ public static class Builder { // Required parameters private final String vaultBaseUrl; private final String issuerName; + private final String provider; // Optional parameters - private IssuerBundle issuer; + private IssuerCredentials credentials; + private OrganizationDetails organizationDetails; + private IssuerAttributes attributes; /** * The builder for constructing {@link UpdateCertificateIssuerRequest} @@ -32,20 +42,45 @@ public static class Builder { * @param issuerName * The name of the issuer in the given vault. */ - public Builder(String vaultBaseUrl, String issuerName) { + public Builder(String vaultBaseUrl, String issuerName, String provider) { this.vaultBaseUrl = vaultBaseUrl; this.issuerName = issuerName; + this.provider = provider; } /** - * Set the issuer value. + * Set issuer credentials. + * + * @param credentials + * The issuer credentials. + * @return the Builder object itself. + */ + public Builder withCredentials(IssuerCredentials credentials) { + this.credentials = credentials; + return this; + } + + /** + * Set issuer organization details. * - * @param issuer - * The issuer bundle. + * @param organizationDetails + * The issuer organization details. * @return the Builder object itself. */ - public Builder withIssuer(IssuerBundle issuer) { - this.issuer = issuer; + public Builder withOrganizationDetails(OrganizationDetails organizationDetails) { + this.organizationDetails = organizationDetails; + return this; + } + + /** + * Set issuer attributes. + * + * @param organizationDetails + * The issuer attributes. + * @return the Builder object itself. + */ + public Builder withAttributes(IssuerAttributes attributes) { + this.attributes = attributes; return this; } @@ -62,16 +97,25 @@ public UpdateCertificateIssuerRequest build() { private UpdateCertificateIssuerRequest(Builder builder) { vaultBaseUrl = builder.vaultBaseUrl; issuerName = builder.issuerName; - - if (builder.issuer != null) { - issuer = new IssuerBundle().withProvider(builder.issuer.provider()) - .withOrganizationDetails(builder.issuer.organizationDetails()) - .withCredentials(builder.issuer.credentials()); - if (builder.issuer.attributes() != null) { - issuer.withAttributes(new IssuerAttributes().withEnabled(builder.issuer.attributes().enabled())); - } + provider = builder.provider; + if(builder.organizationDetails != null) { + organizationDetails = new OrganizationDetails() + .withId(builder.organizationDetails.id()) + .withAdminDetails(new ArrayList(builder.organizationDetails.adminDetails())); } else { - issuer = null; + organizationDetails = null; + } + if(builder.credentials != null) { + credentials = new IssuerCredentials() + .withAccountId(builder.credentials.accountId()) + .withPassword(builder.credentials.password()); + } else { + credentials = null; + } + if (builder.attributes != null) { + attributes = new IssuerAttributes().withEnabled(builder.attributes.enabled()); + } else { + attributes = null; } } @@ -90,9 +134,30 @@ public String issuerName() { } /** - * @return the issuer + * @return the issuer provider name + */ + public String provider() { + return provider; + } + + /** + * @return the issuer credentials + */ + public IssuerCredentials credentials() { + return credentials; + } + + /** + * @return the organization details + */ + public OrganizationDetails organizationDetails() { + return organizationDetails; + } + + /** + * @return the issuer attributes */ - public IssuerBundle issuer() { - return issuer; + public IssuerAttributes attributes() { + return attributes; } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java index 95bd2af87a2e7..24f68899e111c 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateOperationRequest.java @@ -1,14 +1,12 @@ package com.microsoft.azure.keyvault.requests; -import com.microsoft.azure.keyvault.models.CertificateOperation; - /** * The update certificate operation request class. */ public final class UpdateCertificateOperationRequest { private final String vaultBaseUrl; private final String certificateName; - private final CertificateOperation certificateOperation; + private final Boolean cancellationRequested; /** * The {@link UpdateCertificateOperationRequest} builder. @@ -18,9 +16,9 @@ public static class Builder { // Required parameters private final String vaultBaseUrl; private final String certificateName; + private final Boolean cancellationRequested; // Optional parameters - private Boolean cancellationRequested; /** * The builder for constructing {@link CreateCertificateRequest} object. @@ -29,23 +27,13 @@ public static class Builder { * The vault name, e.g. https://myvault.vault.azure.net. * @param certificateName * The name of the certificate in the given vault. + * @param cancellationRequested + * Indicates if cancellation was requested on the certificate operation. */ - public Builder(String vaultBaseUrl, String certificateName) { + public Builder(String vaultBaseUrl, String certificateName, Boolean cancellationRequested) { this.vaultBaseUrl = vaultBaseUrl; this.certificateName = certificateName; - } - - /** - * Set the cancellationRequested value. - * - * @param cancellationRequested - * Indicates if cancellation was requested on the certificate - * operation. - * @return the Builder object itself. - */ - public Builder withCancellationRequested(Boolean cancellationRequested) { this.cancellationRequested = cancellationRequested; - return this; } /** @@ -61,11 +49,7 @@ public UpdateCertificateOperationRequest build() { private UpdateCertificateOperationRequest(Builder builder) { vaultBaseUrl = builder.vaultBaseUrl; certificateName = builder.certificateName; - if (builder.cancellationRequested != null) { - certificateOperation = new CertificateOperation().withCancellationRequested(builder.cancellationRequested); - } else { - certificateOperation = null; - } + cancellationRequested = builder.cancellationRequested; } /** @@ -85,7 +69,7 @@ public String certificateName() { /** * @return the certificate policy */ - public CertificateOperation certificateOperation() { - return certificateOperation; + public Boolean cancellationRequested() { + return cancellationRequested; } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java index da062e1ca5220..ea155328ece75 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java @@ -106,7 +106,7 @@ private UpdateCertificatePolicyRequest(Builder builder) { new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); } } else { - certificatePolicy = null; + certificatePolicy = new CertificatePolicy(); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java index 009caeded6ce7..407b4c1407d27 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java @@ -1,9 +1,17 @@ package com.microsoft.azure.keyvault.requests; +import java.util.ArrayList; import java.util.Collections; import java.util.Map; import com.microsoft.azure.keyvault.models.CertificateAttributes; +import com.microsoft.azure.keyvault.models.CertificatePolicy; +import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.KeyProperties; +import com.microsoft.azure.keyvault.models.LifetimeAction; +import com.microsoft.azure.keyvault.models.SecretProperties; +import com.microsoft.azure.keyvault.models.X509CertificateProperties; +import com.microsoft.azure.keyvault.requests.CreateCertificateRequest.Builder; /** * The update certificate request class. @@ -12,6 +20,7 @@ public final class UpdateCertificateRequest { private final String vaultBaseUrl; private final String certificateName; private final String certificateVersion; + private final CertificatePolicy certificatePolicy; private final CertificateAttributes certificateAttributes; private final Map tags; @@ -28,6 +37,7 @@ public static class Builder { private String certificateVersion; private CertificateAttributes attributes; private Map tags; + private CertificatePolicy policy; /** * The builder for constructing {@link UpdateCertificateRequest} object. @@ -53,6 +63,19 @@ public Builder withCertificateVersion(String version) { this.certificateVersion = version; return this; } + + /** + * Set the certificatePolicy value. Mandatory if sending the create + * request for the first time. + * + * @param certificatePolicy + * The management policy for the certificate. + * @return the Builder object itself. + */ + public Builder withPolicy(CertificatePolicy certificatePolicy) { + this.policy = certificatePolicy; + return this; + } /** * Set the attributes value. @@ -107,6 +130,45 @@ private UpdateCertificateRequest(Builder builder) { } else { tags = null; } + + if (builder.policy != null) { + certificatePolicy = new CertificatePolicy(); + if (builder.policy.attributes() != null) { + certificatePolicy.withAttributes((CertificateAttributes) new CertificateAttributes() + .withEnabled(builder.policy.attributes().enabled()) + .withExpires(builder.policy.attributes().expires()) + .withNotBefore(builder.policy.attributes().notBefore())); + } + if (builder.policy.issuerReference() != null) { + certificatePolicy + .withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); + } + if (builder.policy.x509CertificateProperties() != null) { + certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() + .withValidityInMonths(builder.policy.x509CertificateProperties().validityInMonths()) + .withSubjectAlternativeNames( + builder.policy.x509CertificateProperties().subjectAlternativeNames()) + .withSubject(builder.policy.x509CertificateProperties().subject()) + .withEkus(builder.policy.x509CertificateProperties().ekus()) + .withKeyUsage(builder.policy.x509CertificateProperties().keyUsage())); + } + if (builder.policy.lifetimeActions() != null) { + certificatePolicy.withLifetimeActions(new ArrayList(builder.policy.lifetimeActions())); + } + if (builder.policy.keyProperties() != null) { + certificatePolicy.withKeyProperties( + new KeyProperties().withExportable(builder.policy.keyProperties().exportable()) + .withKeySize(builder.policy.keyProperties().keySize()) + .withKeyType(builder.policy.keyProperties().keyType()) + .withReuseKey(builder.policy.keyProperties().reuseKey())); + } + if (builder.policy.secretProperties() != null) { + certificatePolicy.withSecretProperties( + new SecretProperties().withContentType(builder.policy.secretProperties().contentType())); + } + } else { + certificatePolicy = new CertificatePolicy(); + } } /** @@ -130,6 +192,13 @@ public String certificateVersion() { return certificateVersion; } + /** + * @return the certificate policy + */ + public CertificatePolicy certificatePolicy() { + return certificatePolicy; + } + /** * @return the certificate attributes */ diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java new file mode 100644 index 0000000000000..86410c9ab946f --- /dev/null +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -0,0 +1,242 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.test; + +import java.security.MessageDigest; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import org.junit.Assert; +import org.junit.Test; + +import com.microsoft.azure.keyvault.models.BackupKeyResult; +import com.microsoft.azure.keyvault.models.CertificateBundle; +import com.microsoft.azure.keyvault.models.CertificateIssuerItem; +import com.microsoft.azure.keyvault.models.CertificateItem; +import com.microsoft.azure.keyvault.models.CertificateOperation; +import com.microsoft.azure.keyvault.models.CertificatePolicy; +import com.microsoft.azure.keyvault.models.Contacts; +import com.microsoft.azure.keyvault.models.IssuerBundle; +import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.KeyBundle; +import com.microsoft.azure.keyvault.models.KeyItem; +import com.microsoft.azure.keyvault.models.KeyOperationResult; +import com.microsoft.azure.keyvault.models.KeyVerifyResult; +import com.microsoft.azure.keyvault.models.SecretBundle; +import com.microsoft.azure.keyvault.models.SecretItem; +import com.microsoft.azure.keyvault.models.SecretProperties; +import com.microsoft.azure.keyvault.models.X509CertificateProperties; +import com.microsoft.azure.keyvault.requests.CreateCertificateRequest; +import com.microsoft.azure.keyvault.requests.CreateKeyRequest; +import com.microsoft.azure.keyvault.requests.SetCertificateIssuerRequest; +import com.microsoft.azure.keyvault.requests.SetSecretRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateIssuerRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateOperationRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificatePolicyRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateRequest; +import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; +import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; + + +public class AsyncOperationsTest extends KeyVaultClientIntegrationTestBase { + + @Test + public void keyAsync() throws Exception { + + String vault = getVaultUri(); + String keyname = "mykey"; + + CreateKeyRequest createKeyRequest = new CreateKeyRequest.Builder(vault, keyname, "RSA").build(); + KeyBundle keyBundle = keyVaultClient.createKeyAsync(createKeyRequest, null).get().getBody(); + Assert.assertNotNull(keyBundle); + + UpdateKeyRequest updateKeyRequest = new UpdateKeyRequest.Builder(keyBundle.key().kid()).build(); + keyBundle = keyVaultClient.updateKeyAsync(updateKeyRequest, null).get().getBody(); + Assert.assertNotNull(keyBundle); + + keyBundle = keyVaultClient.getKeyAsync(keyBundle.key().kid(), null).get().getBody(); + Assert.assertNotNull(keyBundle); + + List keyItems = keyVaultClient.listKeysAsync(vault, 2, null).get().getBody(); + Assert.assertNotNull(keyItems); + + List keyVersionItems = keyVaultClient.listKeyVersionsAsync(getVaultUri(), keyname, 2, null).get().getBody(); + Assert.assertNotNull(keyVersionItems); + + BackupKeyResult backupResult = keyVaultClient.backupKeyAsync(vault, keyname, null).get().getBody(); + Assert.assertNotNull(backupResult); + + keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get(); + + KeyBundle restoreResult = keyVaultClient.restoreKeyAsync(vault, backupResult.value(), null).get().getBody(); + Assert.assertNotNull(restoreResult); + + KeyOperationResult encryptResult = keyVaultClient.encryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, new byte[100], null).get().getBody(); + Assert.assertNotNull(encryptResult); + + KeyOperationResult decryptResult = keyVaultClient.decryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, encryptResult.result(), null).get().getBody(); + Assert.assertNotNull(decryptResult); + + KeyOperationResult wrapResult = keyVaultClient.wrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, new byte[100], null).get().getBody(); + Assert.assertNotNull(wrapResult); + + KeyOperationResult unwrapResult = keyVaultClient.unwrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, wrapResult.result(), null).get().getBody(); + Assert.assertNotNull(unwrapResult); + + byte[] plainText = new byte[100]; + new Random(0x1234567L).nextBytes(plainText); + MessageDigest md = MessageDigest.getInstance("SHA-256"); + md.update(plainText); + byte[] digest = md.digest(); + KeyOperationResult signResult = keyVaultClient.signAsync(keyBundle.key().kid(), JsonWebKeySignatureAlgorithm.RS256, digest, null).get().getBody(); + Assert.assertNotNull(signResult); + + KeyVerifyResult verifypResult = keyVaultClient.verifyAsync(keyBundle.key().kid(), JsonWebKeySignatureAlgorithm.RS256, digest, signResult.result(), null).get().getBody(); + Assert.assertTrue(verifypResult.value()); + + keyBundle = keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get().getBody(); + Assert.assertNotNull(keyBundle); + } + + @Test + public void secretAsync() throws Exception { + + String vault = getVaultUri(); + String secretname = "mySecret"; + String password = "password"; + + SetSecretRequest setSecretRequest = new SetSecretRequest.Builder(vault, secretname, password).build(); + SecretBundle secretBundle = keyVaultClient.setSecretAsync(setSecretRequest, null).get().getBody(); + Assert.assertNotNull(secretBundle); + + UpdateSecretRequest updateSecretRequest = new UpdateSecretRequest.Builder(secretBundle.id()).build(); + secretBundle = keyVaultClient.updateSecretAsync(updateSecretRequest, null).get().getBody(); + Assert.assertNotNull(secretBundle); + + secretBundle = keyVaultClient.getSecretAsync(secretBundle.id(), null).get().getBody(); + Assert.assertNotNull(secretBundle); + + List secretItems = keyVaultClient.listSecretsAsync(vault, 2, null).get().getBody(); + Assert.assertNotNull(secretItems); + + List secretVersionItems = keyVaultClient.listSecretVersionsAsync(vault, secretname, 2, null).get().getBody(); + Assert.assertNotNull(secretVersionItems); + + secretBundle = keyVaultClient.deleteSecretAsync(vault, secretname, null).get().getBody(); + Assert.assertNotNull(secretBundle); + } + + @Test + public void certificateAsync() throws Exception { + + String vault = getVaultUri(); + String certificateName = "myCertificate"; + + CreateCertificateRequest createCertificateRequest = + new CreateCertificateRequest + .Builder(vault, certificateName) + .withPolicy(new CertificatePolicy() + .withSecretProperties(new SecretProperties().withContentType("application/x-pkcs12")) + .withIssuerReference(new IssuerReference().withName("Self")) + .withX509CertificateProperties(new X509CertificateProperties() + .withSubject("CN=SelfSignedJavaPkcs12") + .withValidityInMonths(12))) + .build(); + CertificateOperation certificateOperation = keyVaultClient.createCertificateAsync(createCertificateRequest, null).get().getBody(); + Assert.assertNotNull(certificateOperation); + + UpdateCertificateOperationRequest updateCertificateOperationRequest = new UpdateCertificateOperationRequest.Builder(vault, certificateName, false).build(); + certificateOperation = keyVaultClient.updateCertificateOperationAsync(updateCertificateOperationRequest, null).get().getBody(); + Assert.assertNotNull(certificateOperation); + + Map tags = new HashMap(); + tags.put("tag1", "foo"); + UpdateCertificateRequest updateCertificateRequest = new UpdateCertificateRequest.Builder(vault, certificateName).withTags(tags).build(); + CertificateBundle certificateBundle = keyVaultClient.updateCertificateAsync(updateCertificateRequest, null).get().getBody(); + Assert.assertNotNull(certificateBundle); + + UpdateCertificatePolicyRequest updateCertificatePolicyRequest = new UpdateCertificatePolicyRequest.Builder(vault, certificateName).build(); + CertificatePolicy certificatePolicy = keyVaultClient.updateCertificatePolicyAsync(updateCertificatePolicyRequest, null).get().getBody(); + Assert.assertNotNull(certificatePolicy); + + certificatePolicy = keyVaultClient.getCertificatePolicyAsync(vault, certificateName, null).get().getBody(); + Assert.assertNotNull(certificatePolicy); + + certificateOperation = keyVaultClient.getCertificateOperationAsync(vault, certificateName, null).get().getBody(); + Assert.assertNotNull(certificateOperation); + + certificateBundle = keyVaultClient.getCertificateAsync(vault, certificateName, null).get().getBody(); + Assert.assertNotNull(certificateBundle); + + String cert = keyVaultClient.getPendingCertificateSigningRequestAsync(vault, certificateName, null).get().getBody(); + Assert.assertTrue(!cert.isEmpty()); + + List certificateItem = keyVaultClient.listCertificatesAsync(vault, null).get().getBody(); + Assert.assertNotNull(certificateItem); + + List certificateVersionItem = keyVaultClient.listCertificateVersionsAsync(vault, certificateName, null).get().getBody(); + Assert.assertNotNull(certificateVersionItem); + + + keyVaultClient.deleteCertificateOperationAsync(vault, certificateName, null).get().getBody(); + keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get().getBody(); + } + + @Test + public void issuerAsync() throws Exception { + + String vault = getVaultUri(); + String issuerName = "myIssuer"; + + SetCertificateIssuerRequest setCertificateIssuerRequest = new SetCertificateIssuerRequest.Builder(vault, issuerName, "Test").build(); + IssuerBundle certificateIssuer = keyVaultClient.setCertificateIssuerAsync(setCertificateIssuerRequest, null).get().getBody(); + Assert.assertNotNull(certificateIssuer); + + UpdateCertificateIssuerRequest updateCertificateIssuerRequest = new UpdateCertificateIssuerRequest.Builder(vault, issuerName, "SslAdmin").build(); + certificateIssuer = keyVaultClient.updateCertificateIssuerAsync(updateCertificateIssuerRequest, null).get().getBody(); + Assert.assertNotNull(certificateIssuer); + + certificateIssuer = keyVaultClient.getCertificateIssuerAsync(vault, issuerName, null).get().getBody(); + Assert.assertNotNull(certificateIssuer); + + List issuers = keyVaultClient.listCertificateIssuersAsync(vault, null).get().getBody(); + Assert.assertNotNull(issuers); + + keyVaultClient.deleteCertificateIssuerAsync(vault, issuerName, null).get().getBody(); + } + + + @Test + public void certificateContactsAsync() throws Exception { + + String vault = getVaultUri(); + + Contacts contacts = keyVaultClient.setCertificateContactsAsync(vault, new Contacts(), null).get().getBody(); + Assert.assertNotNull(contacts); + + contacts = keyVaultClient.getCertificateContactsAsync(vault, null).get().getBody(); + Assert.assertNotNull(contacts); + + keyVaultClient.deleteCertificateContactsAsync(vault, null).get(); + } +} diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index daa3f644c3ca6..85839d816a2aa 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -20,14 +20,15 @@ import java.io.ByteArrayInputStream; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.Key; import java.security.KeyFactory; import java.security.KeyPair; import java.security.KeyStore; +import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; +import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; @@ -35,8 +36,10 @@ import java.security.spec.PKCS8EncodedKeySpec; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Random; import java.util.concurrent.ExecutionException; import java.util.regex.Matcher; @@ -48,6 +51,7 @@ import javax.crypto.NoSuchPaddingException; import org.apache.commons.codec.binary.Base64; +import org.joda.time.DateTime; import org.junit.Assert; import org.junit.Test; @@ -55,6 +59,7 @@ import com.microsoft.azure.keyvault.CertificateIdentifier; import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.azure.keyvault.models.AdministratorDetails; +import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificateBundle; import com.microsoft.azure.keyvault.models.Contact; import com.microsoft.azure.keyvault.models.Contacts; @@ -73,814 +78,589 @@ import com.microsoft.azure.keyvault.requests.ImportCertificateRequest; import com.microsoft.azure.keyvault.requests.SetCertificateIssuerRequest; import com.microsoft.azure.keyvault.requests.UpdateCertificateIssuerRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateOperationRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificatePolicyRequest; +import com.microsoft.azure.keyvault.requests.UpdateCertificateRequest; public class CertificateOperationsTest extends KeyVaultClientIntegrationTestBase { - static final String ALGO_RSA = "RSA"; + static final String ALGO_RSA = "RSA"; - static final String X509 = "X.509"; + static final String X509 = "X.509"; - static final String PKCS12 = "PKCS12"; + static final String PKCS12 = "PKCS12"; - static final String MIME_PKCS12 = "application/x-pkcs12"; + static final String MIME_PKCS12 = "application/x-pkcs12"; - static final String MIME_PEM = "application/x-pem-file"; + static final String MIME_PEM = "application/x-pem-file"; - static final String ISSUER_SELF = "Self"; + static final String ISSUER_SELF = "Self"; - static final String ISSUER_TEST = "Test"; - - static final String ISSUER_UNKNOWN = "Unknown"; - - static final String STATUS_IN_PROGRESS = "inProgress"; + static final String ISSUER_TEST = "Test"; + + static final String ISSUER_UNKNOWN = "Unknown"; + + static final String STATUS_IN_PROGRESS = "inProgress"; - static final String STATUS_COMPLETED = "Completed"; + static final String STATUS_COMPLETED = "Completed"; - static final Base64 _base64 = new Base64(-1, null, true); + static final Base64 _base64 = new Base64(-1, null, true); - static final Pattern _privateKey = Pattern.compile("-{5}BEGIN PRIVATE KEY-{5}(?:\\s|\\r|\\n)+" - + "([a-zA-Z0-9+/=\r\n]+)" + "-{5}END PRIVATE KEY-{5}(?:\\s|\\r|\\n)+"); + static final Pattern _privateKey = Pattern.compile("-{5}BEGIN PRIVATE KEY-{5}(?:\\s|\\r|\\n)+" + + "([a-zA-Z0-9+/=\r\n]+)" + "-{5}END PRIVATE KEY-{5}(?:\\s|\\r|\\n)+"); - static final Pattern _certificate = Pattern.compile("-{5}BEGIN CERTIFICATE-{5}(?:\\s|\\r|\\n)+" - + "([a-zA-Z0-9+/=\r\n]+)" + "-{5}END CERTIFICATE-{5}(?:\\s|\\r|\\n)+"); + static final Pattern _certificate = Pattern.compile("-{5}BEGIN CERTIFICATE-{5}(?:\\s|\\r|\\n)+" + + "([a-zA-Z0-9+/=\r\n]+)" + "-{5}END CERTIFICATE-{5}(?:\\s|\\r|\\n)+"); - private static final int MAX_CERTS = 4; + private static final int MAX_CERTS = 4; private static final int PAGELIST_MAX_CERTS = 3; - /** - * Create a self-signed certificate in PKCS12 format (which includes the - * private key) certificate. - * - * @throws Exception - */ - @Test - public void createSelfSignedCertificatePkcs12() throws Exception { - // Set content type to indicate the certificate is PKCS12 format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PKCS12); - - X509CertificateProperties x509Properties = new X509CertificateProperties(); - String subjectName = "CN=SelfSignedJavaPkcs12"; - x509Properties.withSubject(subjectName); - x509Properties.withValidityInMonths(12); - - // Set issuer to "Self" - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(ISSUER_SELF); - - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - certificatePolicy.withIssuerReference(issuerReference); - certificatePolicy.withX509CertificateProperties(x509Properties); - - String vaultUri = getVaultUri(); - String certificateName = "createSelfSignedJavaPkcs12"; - CertificateOperation certificateOperation = keyVaultClient.createCertificate( - new CreateCertificateRequest - .Builder(vaultUri, certificateName) - .withPolicy(certificatePolicy) - .build()).getBody(); - - Assert.assertNotNull(certificateOperation); - Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); - - CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); - Assert.assertNotNull(certificateBundle); - Assert.assertNotNull(certificateBundle.id()); - Assert.assertNotNull(certificateBundle.keyIdentifier()); - Assert.assertNotNull(certificateBundle.secretIdentifier()); - Assert.assertNotNull(certificateBundle.x509Thumbprint()); - - // Load the CER part into X509Certificate object - Assert.assertNotNull(certificateBundle.cer()); - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - cerStream.close(); - - Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); - Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); - - // Retrieve the secret backing the certificate - SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - - // Load the secret into a KeyStore - ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); - String secretPassword = ""; - KeyStore keyStore = KeyStore.getInstance(PKCS12); - keyStore.load(secretStream, secretPassword.toCharArray()); - secretStream.close(); - - // Validate the certificate in the KeyStore - String defaultAlias = Collections.list(keyStore.aliases()).get(0); - X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); - Assert.assertNotNull(secretCertificate); - Assert.assertTrue(secretCertificate.getPublicKey().equals(x509Certificate.getPublicKey())); - Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() - .equals(x509Certificate.getSubjectX500Principal().getName())); - Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() - .equals(x509Certificate.getIssuerX500Principal().getName())); - Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); - - // Validate the key in the KeyStore - Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); - Assert.assertNotNull(secretKey); - Assert.assertTrue(secretKey instanceof PrivateKey); - PrivateKey secretPrivateKey = (PrivateKey) secretKey; - - // Create a KeyPair with the private key from the KeyStore and public - // key from the certificate to verify they match - KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); - Assert.assertNotNull(keyPair); - verifyRSAKeyPair(keyPair); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - Assert.assertNotNull(deletedCertificateBundle); - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - - /** - * Create a self-signed certificate in PEM format (which includes the - * private key) certificate. - * - * @throws Exception - */ - @Test - public void createSelfSignedCertificatePem() throws Exception { - // Set content type to indicate the certificate is PKCS12 format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PEM); - - X509CertificateProperties x509Properties = new X509CertificateProperties(); - String subjectName = "CN=SelfSignedJavaPem"; - x509Properties.withSubject(subjectName); - x509Properties.withValidityInMonths(12); - - // Set issuer to "Self" - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(ISSUER_SELF); - - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - certificatePolicy.withIssuerReference(issuerReference); - certificatePolicy.withX509CertificateProperties(x509Properties); - - String vaultUri = getVaultUri(); - String certificateName = "SelfSignedJavaPem"; - CertificateOperation certificateOperation = keyVaultClient.createCertificate( - new CreateCertificateRequest - .Builder(vaultUri, certificateName) - .withPolicy(certificatePolicy) - .build()).getBody(); - - Assert.assertNotNull(certificateOperation); - Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); - - CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); - Assert.assertNotNull(certificateBundle); - Assert.assertNotNull(certificateBundle.id()); - Assert.assertNotNull(certificateBundle.kid()); - Assert.assertNotNull(certificateBundle.sid()); - Assert.assertNotNull(certificateBundle.x509Thumbprint()); - - // Load the CER part into X509Certificate object - Assert.assertNotNull(certificateBundle.cer()); - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - cerStream.close(); - - Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); - Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); - - // Retrieve the secret backing the certificate - SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - String secretValue = secret.value(); - - // Extract private key from PEM - PrivateKey secretPrivateKey = extractPrivateKeyFromPemContents(secretValue); - Assert.assertNotNull(secretPrivateKey); - - // Extract certificates from PEM - List certificates = extractCertificatesFromPemContents(secretValue); - Assert.assertNotNull(certificates); - Assert.assertTrue(certificates.size() == 1); - - // has the public key corresponding to the private key. - X509Certificate secretCertificate = certificates.get(0); - Assert.assertNotNull(secretCertificate); - Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() - .equals(x509Certificate.getSubjectX500Principal().getName())); - Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() - .equals(x509Certificate.getIssuerX500Principal().getName())); - Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); - - // Create a KeyPair with the private key from the KeyStore and public - // key from the certificate to verify they match - KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); - Assert.assertNotNull(keyPair); - verifyRSAKeyPair(keyPair); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - Assert.assertNotNull(deletedCertificateBundle); - - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - - /** - * Create a test-issuer issued certificate in PKCS12 format (which includes - * the private key) certificate. - * - * @throws Exception - */ - @Test - public void createCertificatePkcs12() throws Exception { - // Construct organization administrator details - AdministratorDetails administratorDetails = new AdministratorDetails(); - administratorDetails.withFirstName("John"); - administratorDetails.withLastName("Doe"); - administratorDetails.withEmailAddress("john.doe@contoso.com"); - administratorDetails.withPhone("1234567890"); - - // Construct organization details - OrganizationDetails organizationDetails = new OrganizationDetails(); - List administratorsDetails = new ArrayList(); - administratorsDetails.add(administratorDetails); - organizationDetails.withAdminDetails(administratorsDetails); - - // Construct certificate issuer credentials - IssuerCredentials credentials = new IssuerCredentials(); - credentials.withAccountId("account1"); - credentials.withPassword("Pa$$w0rd"); - - IssuerBundle certificateIssuer = new IssuerBundle(); - certificateIssuer.withProvider(ISSUER_TEST); - certificateIssuer.withCredentials(credentials); - certificateIssuer.withOrganizationDetails(organizationDetails); - - String certificateIssuerName = "createCertificateJavaPkcs12Issuer01"; - IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( - new SetCertificateIssuerRequest - .Builder(getVaultUri(),certificateIssuerName) - .withIssuer(certificateIssuer) - .build()).getBody(); - - Assert.assertNotNull(createdCertificateIssuer); - Assert.assertNotNull(createdCertificateIssuer.issuerIdentifier()); - Assert.assertNotNull(createdCertificateIssuer.issuerIdentifier().name()); - Assert.assertTrue(createdCertificateIssuer.issuerIdentifier().name().equalsIgnoreCase(certificateIssuerName)); - - // Set content type to indicate the certificate is PKCS12 format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PKCS12); - - X509CertificateProperties x509Properties = new X509CertificateProperties(); - String subjectName = "CN=TestJavaPkcs12"; - x509Properties.withSubject(subjectName); - x509Properties.withValidityInMonths(12); - - // Set issuer reference to the created issuer - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(createdCertificateIssuer.issuerIdentifier().name()); - - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - certificatePolicy.withIssuerReference(issuerReference); - certificatePolicy.withX509CertificateProperties(x509Properties); - - String vaultUri = getVaultUri(); - String certificateName = "createTestJavaPkcs12"; - CertificateOperation certificateOperation = keyVaultClient.createCertificate( - new CreateCertificateRequest - .Builder(vaultUri, certificateName) - .withPolicy(certificatePolicy) - .build()).getBody(); - - Assert.assertNotNull(certificateOperation); - Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); - - CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); - Assert.assertNotNull(certificateBundle); - Assert.assertNotNull(certificateBundle.id()); - Assert.assertNotNull(certificateBundle.keyIdentifier()); - Assert.assertNotNull(certificateBundle.secretIdentifier()); - Assert.assertNotNull(certificateBundle.x509Thumbprint()); - Assert.assertNotNull(certificateBundle.policy()); - Assert.assertNotNull(certificateBundle.policy().issuerReference()); - Assert.assertNotNull(certificateBundle.policy().issuerReference().name()); - Assert.assertTrue( - certificateBundle.policy().issuerReference().name().equalsIgnoreCase(certificateIssuerName)); - - // Load the CER part into X509Certificate object - Assert.assertNotNull(certificateBundle.cer()); - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - cerStream.close(); - - Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); - Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); - - // Retrieve the secret backing the certificate - SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - - // Load the secret into a KeyStore - ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); - String secretPassword = ""; - KeyStore keyStore = KeyStore.getInstance(PKCS12); - keyStore.load(secretStream, secretPassword.toCharArray()); - secretStream.close(); - - // Validate the certificate in the KeyStore - String defaultAlias = Collections.list(keyStore.aliases()).get(0); - X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); - Assert.assertNotNull(secretCertificate); - Assert.assertTrue(secretCertificate.getPublicKey().equals(x509Certificate.getPublicKey())); - Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() - .equals(x509Certificate.getSubjectX500Principal().getName())); - Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() - .equals(x509Certificate.getIssuerX500Principal().getName())); - Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); - - // Validate the key in the KeyStore - Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); - Assert.assertNotNull(secretKey); - Assert.assertTrue(secretKey instanceof PrivateKey); - PrivateKey secretPrivateKey = (PrivateKey) secretKey; - - // Create a KeyPair with the private key from the KeyStore and public - // key from the certificate to verify they match - KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); - Assert.assertNotNull(keyPair); - verifyRSAKeyPair(keyPair); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - Assert.assertNotNull(deletedCertificateBundle); - - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - - /** - * Create a test-issuer certificate in PEM format (which includes the - * private key) certificate. - * - * @throws Exception - */ - @Test - public void createCertificatePem() throws Exception { - // Construct organization administrator details - AdministratorDetails administratorDetails = new AdministratorDetails(); - administratorDetails.withFirstName("John"); - administratorDetails.withLastName("Doe"); - administratorDetails.withEmailAddress("john.doe@contoso.com"); - administratorDetails.withPhone("1234567890"); - - // Construct organization details - OrganizationDetails organizationDetails = new OrganizationDetails(); - List administratorsDetails = new ArrayList(); - administratorsDetails.add(administratorDetails); - organizationDetails.withAdminDetails(administratorsDetails); - - // Construct certificate issuer credentials - IssuerCredentials credentials = new IssuerCredentials(); - credentials.withAccountId("account1"); - credentials.withPassword("Pa$$w0rd"); - - IssuerBundle certificateIssuer = new IssuerBundle(); - certificateIssuer.withProvider(ISSUER_TEST); - certificateIssuer.withCredentials(credentials); - certificateIssuer.withOrganizationDetails(organizationDetails); - - String certificateIssuerName = "createCertificateJavaPemIssuer01"; - IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( - new SetCertificateIssuerRequest - .Builder(getVaultUri(), certificateIssuerName) - .withIssuer(certificateIssuer) - .build()).getBody(); - Assert.assertNotNull(createdCertificateIssuer); - Assert.assertNotNull(createdCertificateIssuer.issuerIdentifier()); - Assert.assertNotNull(createdCertificateIssuer.issuerIdentifier().name()); - Assert.assertTrue(createdCertificateIssuer.issuerIdentifier().name().equalsIgnoreCase(certificateIssuerName)); - - // Set content type to indicate the certificate is PEM format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PEM); - - X509CertificateProperties x509Properties = new X509CertificateProperties(); - String subjectName = "CN=TestJavaPem"; - x509Properties.withSubject(subjectName); - x509Properties.withValidityInMonths(12); - - // Set issuer reference to the created issuer - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(createdCertificateIssuer.issuerIdentifier().name()); - - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - certificatePolicy.withIssuerReference(issuerReference); - certificatePolicy.withX509CertificateProperties(x509Properties); - - String vaultUri = getVaultUri(); - String certificateName = "createTestJavaPem"; - CertificateOperation certificateOperation = keyVaultClient.createCertificate( - new CreateCertificateRequest - .Builder(vaultUri, certificateName) - .withPolicy(certificatePolicy) - .build()).getBody(); - - Assert.assertNotNull(certificateOperation); - Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); - - CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); - Assert.assertNotNull(certificateBundle); - Assert.assertNotNull(certificateBundle.id()); - Assert.assertNotNull(certificateBundle.kid()); - Assert.assertNotNull(certificateBundle.sid()); - Assert.assertNotNull(certificateBundle.x509Thumbprint()); - Assert.assertNotNull(certificateBundle.policy()); - Assert.assertNotNull(certificateBundle.policy().issuerReference()); - Assert.assertNotNull(certificateBundle.policy().issuerReference().name()); - Assert.assertTrue( - certificateBundle.policy().issuerReference().name().equalsIgnoreCase(certificateIssuerName)); - - // Load the CER part into X509Certificate object - Assert.assertNotNull(certificateBundle.cer()); - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - cerStream.close(); - - Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); - Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); - - // Retrieve the secret backing the certificate - SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - String secretValue = secret.value(); - - // Extract private key from PEM - PrivateKey secretPrivateKey = extractPrivateKeyFromPemContents(secretValue); - Assert.assertNotNull(secretPrivateKey); - - // Extract certificates from PEM - List certificates = extractCertificatesFromPemContents(secretValue); - Assert.assertNotNull(certificates); - Assert.assertTrue(certificates.size() == 1); - - // has the public key corresponding to the private key. - X509Certificate secretCertificate = certificates.get(0); - Assert.assertNotNull(secretCertificate); - Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() - .equals(x509Certificate.getSubjectX500Principal().getName())); - Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() - .equals(x509Certificate.getIssuerX500Principal().getName())); - Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); - - // Create a KeyPair with the private key from the KeyStore and public - // key from the certificate to verify they match - KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); - Assert.assertNotNull(keyPair); - verifyRSAKeyPair(keyPair); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - Assert.assertNotNull(deletedCertificateBundle); - - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } - catch(KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - - /** - * Create a certificate signing request with key in Key Vault. - * @throws ExecutionException - * @throws InterruptedException - * @throws IOException - * @throws IllegalArgumentException - * @throws KeyVaultErrorException - * - * @throws Exception - */ - @Test - public void createCsr() throws InterruptedException, ExecutionException, KeyVaultErrorException, IllegalArgumentException, IOException { - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PKCS12); - - X509CertificateProperties x509Properties = new X509CertificateProperties(); - String subjectName = "CN=ManualEnrollmentJava"; - x509Properties.withSubject(subjectName); - x509Properties.withValidityInMonths(12); - - // Set issuer to "Unknown" - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(ISSUER_UNKNOWN); - - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - certificatePolicy.withIssuerReference(issuerReference); - certificatePolicy.withX509CertificateProperties(x509Properties); - - String vaultUri = getVaultUri(); - String certificateName = "createManualEnrollmentJava"; - CertificateOperation certificateOperation = keyVaultClient.createCertificate( - new CreateCertificateRequest - .Builder(vaultUri, certificateName) - .withPolicy(certificatePolicy) - .build()).getBody(); - - Assert.assertNotNull(certificateOperation); - Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); - Assert.assertNotNull(certificateOperation.csr()); - - String csr = keyVaultClient.getPendingCertificateSigningRequest(vaultUri, certificateName).getBody(); - Assert.assertNotNull(csr); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - Assert.assertNotNull(deletedCertificateBundle); - - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - /** - * Import a PKCS12 format (which includes the private key) certificate. - */ - @Test - public void importCertificatePkcs12() throws Exception { - String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; - String certificatePassword = "123"; - - // Set content type to indicate the certificate is PKCS12 format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PKCS12); - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - - String vaultUri = getVaultUri(); - String certificateName = "importCertPkcs"; - CertificateBundle certificateBundle = keyVaultClient.importCertificate( - new ImportCertificateRequest - .Builder(vaultUri, certificateName, certificateContent) - .withPassword(certificatePassword) - .withPolicy(certificatePolicy) - .build()).getBody(); - - // Validate the certificate bundle created - Assert.assertNotNull(certificateBundle); - Assert.assertNotNull(certificateBundle.id()); - Assert.assertNotNull(certificateBundle.kid()); - Assert.assertNotNull(certificateBundle.sid()); - Assert.assertNotNull(certificateBundle.x509Thumbprint()); - - Assert.assertTrue(toHexString(certificateBundle.x509Thumbprint()).equalsIgnoreCase("7cb8b7539d87ba7215357b9b9049dff2d3fa59ba")); - - // Load the CER part into X509Certificate object - Assert.assertNotNull(certificateBundle.cer()); - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - cerStream.close(); - - Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals("CN=KeyVaultTest")); - Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals("CN=Root Agency")); - - // Retrieve the secret backing the certificate - SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - - // Load the secret into a KeyStore - ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); - String secretPassword = ""; - KeyStore keyStore = KeyStore.getInstance(PKCS12); - keyStore.load(secretStream, secretPassword.toCharArray()); - secretStream.close(); - - // Validate the certificate in the KeyStore - String defaultAlias = Collections.list(keyStore.aliases()).get(0); - X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); - Assert.assertNotNull(secretCertificate); - Assert.assertTrue(secretCertificate.getPublicKey().equals(x509Certificate.getPublicKey())); - Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() - .equals(x509Certificate.getSubjectX500Principal().getName())); - Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() - .equals(x509Certificate.getIssuerX500Principal().getName())); - Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); - - // Validate the key in the KeyStore - Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); - Assert.assertNotNull(secretKey); - Assert.assertTrue(secretKey instanceof PrivateKey); - PrivateKey secretPrivateKey = (PrivateKey) secretKey; - - // Create a KeyPair with the private key from the KeyStore and public - // key from the certificate to verify they match - KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); - Assert.assertNotNull(keyPair); - verifyRSAKeyPair(keyPair); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - - /** - * Import a PEM format (which includes a encrypted private key) certificate. - * TODO: Server can't handle this yet. - */ - // @Test - public void importCertificatePem() throws Exception { - String certificateContent = "-----BEGIN ENCRYPTED PRIVATE KEY-----\n" - + "MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQI+mprWsX8IMICAggA\n" - + "MBQGCCqGSIb3DQMHBAgu4FUBoWBbGgSCBMhjsFyDgeqAVrMRXKaGpdstAHttWxGw\n" - + "JfkthRr8eULwldl2sYZdxwZaHOWjhhwp3LHZ7M5+6augyo1WxIJ456hPlZQ0nlXO\n" - + "y9pFBXEFSIeemd7JdVPjZ3HWVrkXapcKh12hqhzskdXlBermc5uS5NScOFJhnGFT\n" - + "68Va9KHglOmX2T0fUIagWnxQuP2gu3w3PIbbMt8tB0fN5H2xfd6xjKiTlb+3jHP2\n" - + "kZzAcPCzqgNlCK09fOqD9x+fFO2Zn6SqzPt66E8IMZ/7s41mF5IU8H0rIkA9vOZM\n" - + "oM41r0S+N1nhn1MV52aHcqQETV/odKq968dnLRiSIRLfSI9HQWubXu3jWeDHh3GC\n" - + "gaJbafDZWYjN42xIamm5xv3JEycED3Cqk4ibSJgw72uEIGZmhxzo8cXCelOezCBT\n" - + "aj3IkLfUej9p9UhIZJ6DX3kWFh7Ab5T4c23ZzV1WeDtLSANqh1FHFnWMxAcTOgY0\n" - + "0uPGKW03uz3RQdypI8GbrYlT0QiLAaCT6dijFyGNk8W1eAcFJQS4Vtp7PBG+o1qn\n" - + "+xdXVEiQxpZbiFeSMaydfxWAbin4gr98I55gf2VXq9VOFsRY2LxeNzmmEVt1HjuJ\n" - + "rCl4KB/d7VrB+Ev/zjUHDtD22f/Gca7VRET7FaG9Mdj4trtngKFc3B82Q98a3F2w\n" - + "l7ppYQMwdOFUrDRCCDdmatVJwtg/MAXxaIxwGAow+po0dQx2xyqz/8aIPoSg604d\n" - + "+Z5AEmpyLC7369+OZUtJfQ5bCmFbBLne9YvoDAKXuJ07fx+Sq7Hzrbb3uPQo6vgi\n" - + "QrLJhY8KgCFMMWzsfiVPOIGkWIR2KRiyX2HMbsYGRdhRsGl4xco8mmCv4C9WjR9A\n" - + "AT5mVi6U9/zMG1wJMrnVoPQ1E+pi+nuviWZWKZ8uqYOAOEwewHpuTrdmgPe1yoJ/\n" - + "beIYzTOEt9BemnuQge9/zdhH3U5667xWb08hV5dv1Z9ubLKbZx3Yea/J+EbfNW3B\n" - + "OxuacDsaMSSj1wiKKgeSkusrAikCvlsCJumTRAbu/uR6HgmqIlBpB3JTJHoCx90F\n" - + "BsIcwf73aFs/rQQJ6aZRi/fFgHpxWgtEQ9aTKXmhgbfTjjHYGYGkHvDNdzKaXu46\n" - + "6WliF9G0WAeotaGrRESvqVDswaM0F27KjtSdcmtdUQOtbtVVd84VClZqhbyd6tFh\n" - + "lqFsHO9oN+mQQJNhemqiL/Tdo+BQwGxeWjlstd7HlwUsc1sp0OLA8h8QlteBAnNb\n" - + "KpOQYblZbCZX4uZR5KJYDeCuDmWp/Qg7gcKyRLC9I+PrzYockl375RuK60Lws8B+\n" - + "kW49wYHzJFf7DOwuV/2TwkOwP0jcr9nWkjS1uwryuYbp9zPuqddHWggt2rDIlBIG\n" - + "aCU46hS1cGJmzLcIF8TAg8hPQgSikr1AIseyDnWK96OnrTRVK8TbVWOHwvJWr92g\n" - + "ZLwgAve79qgG4LPCOF1HZSeU9sq81FbzPz+BGdVLn5xkoZ1gyjclR78W6jeeTGH3\n" - + "efiw9atBkAiUKaODMXbtHm93JcSQ5sK0r66J7uAQVjLIMu757V0paJNjfF5WoisC\n" - + "3nwuSbg71YHNgvlx/OYWRBRreT/zDgApvnrYqUsUPSQaybMc/9Pbjj76T4AWmjVa\n" - + "JHA=\n" - + "-----END ENCRYPTED PRIVATE KEY-----\n" - + "-----BEGIN CERTIFICATE-----\n" - + "MIIDozCCAougAwIBAgIJAIvNGnmenqgjMA0GCSqGSIb3DQEBCwUAMGgxCzAJBgNV\n" - + "BAYTAlVTMQswCQYDVQQIDAJXQTEQMA4GA1UEBwwHUmVkbW9uZDEXMBUGA1UECgwO\n" - + "TWljcm9zb2Z0IENvcnAxDjAMBgNVBAsMBUF6dXJlMREwDwYDVQQDDAhLZXlWYXVs\n" - + "dDAeFw0xNjA0MDEyMzAwMjlaFw0xNjA1MzEyMzAwMjlaMGgxCzAJBgNVBAYTAlVT\n" - + "MQswCQYDVQQIDAJXQTEQMA4GA1UEBwwHUmVkbW9uZDEXMBUGA1UECgwOTWljcm9z\n" - + "b2Z0IENvcnAxDjAMBgNVBAsMBUF6dXJlMREwDwYDVQQDDAhLZXlWYXVsdDCCASIw\n" - + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN1udkhsWIwmua3SFJWxS9AJoKK5\n" - + "o7RAHwsQUWWNkSsPiWrzDYXarfUEs1HBEsAjOJDabK1L0ahw4Manx0NXDOmw8kuD\n" - + "lNMs4yTZNxvECvKpq37Z6Q3D9ts4sVSeFbXtOYr81P+8DOOH3Ibk3sldoJBMXJ5h\n" - + "pw4R72988m9CZ9KjcdaKFk3L1baCehpwkJLZD2XD7MzV9YBKNnd15DPCkVZHul1t\n" - + "bW0E7kf7vUOPIfRuNZeN6QvqsKTA+RoGh3CVu9QV+XG/AsHDoHUwGUlJPvOCm3U5\n" - + "tDrrbXAP+Wa/kE/fGAJkZQLPcbappUI4Swtt9u7+CpyQ96H7BY1yHvmBzBUCAwEA\n" - + "AaNQME4wHQYDVR0OBBYEFJ9DSIY/4ODmWY7oIQkGDD7KlQnAMB8GA1UdIwQYMBaA\n" - + "FJ9DSIY/4ODmWY7oIQkGDD7KlQnAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEL\n" - + "BQADggEBAGV3fTAVWd1tdgcaogBirn1LF8d3H45bdDtjD98933dsOCYlXHKNdB62\n" - + "6Qwg6XF9a+p1vuHI1I8MKBu//q+pLJce+bi2jmge64zlz/iO3sLSOFo/q1EWzhal\n" - + "TRglNkvqWr7OvJXdUznQI3AzjB8tbFB2YerSbmD6FxAAihEq8ZoJ1BsMq5vknpPB\n" - + "iETENaNSjdgPEsiapYNALgY4AVxtSS5GJDZ9zpc5Q6HCPmUozLbQheNZf3+D75cy\n" - + "gB2odtfwhKCuIfuMan51UqjupK0JVJuNV4MXRXH0mFPEBxI4pYolFuV8960jGXqE\n" - + "m/26LtCJLW5QaedtCCKpn9fat5VHgso=\n" - + "-----END CERTIFICATE-----\n"; - - String certificatePassword = "1234"; - - // Set content type to indicate the certificate is PEM format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PEM); - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - - String vaultUri = getVaultUri(); - String certificateName = "importCertPem"; - CertificateBundle certificateBundle = keyVaultClient.importCertificate( - new ImportCertificateRequest - .Builder(vaultUri, certificateName, certificateContent) - .withPassword(certificatePassword) - .withPolicy(certificatePolicy) - .build()).getBody(); - - // Validate the certificate bundle created - Assert.assertNotNull(certificateBundle); - Assert.assertNotNull(certificateBundle.id()); - Assert.assertNotNull(certificateBundle.kid()); - Assert.assertNotNull(certificateBundle.sid()); - Assert.assertNotNull(certificateBundle.x509Thumbprint()); - Assert.assertTrue(toHexString(certificateBundle.x509Thumbprint()).equalsIgnoreCase("d86db6736c335f08ef39aa27ef83836e8eba95b9")); - - // Load the CER part into X509Certificate object - Assert.assertNotNull(certificateBundle.cer()); - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - cerStream.close(); - - Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName() - .equals("CN=KeyVault,OU=Azure,O=Microsoft Corp,L=Redmond,ST=WA,C=US")); - Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName() - .equals("CN=KeyVault,OU=Azure,O=Microsoft Corp,L=Redmond,ST=WA,C=US")); - - // Retrieve the secret backing the certificate - SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - - // Load the secret into a KeyStore - ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); - String secretPassword = ""; - KeyStore keyStore = KeyStore.getInstance(PKCS12); - keyStore.load(secretStream, secretPassword.toCharArray()); - secretStream.close(); - - // Validate the certificate in the KeyStore - String defaultAlias = Collections.list(keyStore.aliases()).get(0); - X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); - Assert.assertNotNull(secretCertificate); - Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() - .equals(x509Certificate.getSubjectX500Principal().getName())); - Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() - .equals(x509Certificate.getIssuerX500Principal().getName())); - Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); - - // Validate the key in the KeyStore - Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); - Assert.assertNotNull(secretKey); - Assert.assertTrue(secretKey instanceof PrivateKey); - PrivateKey secretPrivateKey = (PrivateKey) secretKey; - - // Create a KeyPair with the private key from the KeyStore and public - // key from the certificate to verify they match - KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); - Assert.assertNotNull(keyPair); - verifyRSAKeyPair(keyPair); - - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); - Assert.assertNotNull(deletedCertificateBundle); - - try { - keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); - } - } - - /** - * List certificates in a vault. - */ - @Test - public void listCertificates() throws Exception { - String certificateName = "listCertificate"; - String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; - String certificatePassword = "123"; - - // Set content type to indicate the certificate is PKCS12 format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PKCS12); - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - - HashSet certificates = new HashSet(); - for (int i = 0; i < MAX_CERTS; ++i) { - int failureCount = 0; - for (;;) { - try { - CertificateBundle certificateBundle = keyVaultClient.importCertificate( - new ImportCertificateRequest - .Builder(getVaultUri(), certificateName + i, certificateContent) - .withPassword(certificatePassword) - .withPolicy(certificatePolicy) - .build()).getBody(); - CertificateIdentifier id = certificateBundle.certificateIdentifier(); - certificates.add(id.baseIdentifier()); - break; + private static final Map sTags = new HashMap(); + + /** + * Create a self-signed certificate in PKCS12 format (which includes the + * private key) certificate. + * + * @throws Exception + */ + @Test + public void createSelfSignedCertificatePkcs12() throws Exception { + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties() + .withContentType(MIME_PKCS12); + + String subjectName = "CN=SelfSignedJavaPkcs12"; + X509CertificateProperties x509Properties = new X509CertificateProperties() + .withSubject(subjectName) + .withValidityInMonths(12); + + // Set issuer to "Self" + IssuerReference issuerReference = new IssuerReference() + .withName(ISSUER_SELF); + + CertificatePolicy certificatePolicy = new CertificatePolicy() + .withSecretProperties(secretProperties) + .withIssuerReference(issuerReference) + .withX509CertificateProperties(x509Properties); + + CertificateAttributes attribute = (CertificateAttributes) new CertificateAttributes() + .withEnabled(false) + .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) + .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); + + String vaultUri = getVaultUri(); + String certificateName = "createSelfSignedJavaPkcs12"; + + CreateCertificateRequest createCertificateRequest = + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicy) + .withAttributes(attribute) + .withTags(sTags) + .build(); + + CertificateOperation certificateOperation = keyVaultClient.createCertificate(createCertificateRequest).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + + CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); + validateCertificateBundle(certificateBundle, certificatePolicy); + compareAttributes(attribute, createCertificateRequest.certificateAttributes()); + + // Load the CER part into X509Certificate object + X509Certificate x509Certificate = loadCerToX509Certificate(certificateBundle); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + + // Load the secret into a KeyStore + String secretPassword = ""; + KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword); + + // Validate the certificate and key in the KeyStore + validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Create a self-signed certificate in PEM format (which includes the + * private key) certificate. + * + * @throws Exception + */ + @Test + public void createSelfSignedCertificatePem() throws Exception { + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties() + .withContentType(MIME_PEM); + + String subjectName = "CN=SelfSignedJavaPem"; + X509CertificateProperties x509Properties = new X509CertificateProperties() + .withSubject(subjectName) + .withValidityInMonths(12); + + // Set issuer to "Self" + IssuerReference issuerReference = new IssuerReference() + .withName(ISSUER_SELF); + + CertificatePolicy certificatePolicy = new CertificatePolicy() + .withSecretProperties(secretProperties) + .withIssuerReference(issuerReference) + .withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "SelfSignedJavaPem"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + + CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); + validateCertificateBundle(certificateBundle, certificatePolicy); + + validatePem(certificateBundle, subjectName); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Create a test-issuer issued certificate in PKCS12 format (which includes + * the private key) certificate. + * + * @throws Exception + */ + @Test + public void createCertificatePkcs12() throws Exception { + // Construct organization administrator details + AdministratorDetails administratorDetails = new AdministratorDetails() + .withFirstName("John") + .withLastName("Doe") + .withEmailAddress("john.doe@contoso.com") + .withPhone("1234567890"); + + // Construct organization details + List administratorsDetails = new ArrayList(); + administratorsDetails.add(administratorDetails); + OrganizationDetails organizationDetails = new OrganizationDetails() + .withAdminDetails(administratorsDetails); + + // Construct certificate issuer credentials + IssuerCredentials credentials = new IssuerCredentials() + .withAccountId("account1") + .withPassword("Pa$$w0rd"); + + String certificateIssuerName = "createCertificateJavaPkcs12Issuer01"; + IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( + new SetCertificateIssuerRequest + .Builder(getVaultUri(),certificateIssuerName, ISSUER_TEST) + .withCredentials(credentials) + .withOrganizationDetails(organizationDetails) + .build()).getBody(); + + validateCertificateIssuer(createdCertificateIssuer, certificateIssuerName); + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties() + .withContentType(MIME_PKCS12); + + String subjectName = "CN=TestJavaPkcs12"; + X509CertificateProperties x509Properties = new X509CertificateProperties() + .withSubject(subjectName) + .withValidityInMonths(12); + + // Set issuer reference to the created issuer + IssuerReference issuerReference = new IssuerReference(); + issuerReference.withName(createdCertificateIssuer.issuerIdentifier().name()); + + CertificatePolicy certificatePolicy = new CertificatePolicy() + .withSecretProperties(secretProperties) + .withIssuerReference(issuerReference) + .withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "createTestJavaPkcs12"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + + CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); + validateCertificateBundle(certificateBundle, certificatePolicy); + + // Load the CER part into X509Certificate object + X509Certificate x509Certificate = loadCerToX509Certificate(certificateBundle); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + + // Load the secret into a KeyStore + String secretPassword = ""; + KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword); + + // Validate the certificate and key in the KeyStore + validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Create a test-issuer certificate in PEM format (which includes the + * private key) certificate. + * + * @throws Exception + */ + @Test + public void createCertificatePem() throws Exception { + // Construct organization administrator details + AdministratorDetails administratorDetails = new AdministratorDetails() + .withFirstName("John") + .withLastName("Doe") + .withEmailAddress("john.doe@contoso.com") + .withPhone("1234567890"); + + // Construct organization details + OrganizationDetails organizationDetails = new OrganizationDetails(); + List administratorsDetails = new ArrayList(); + administratorsDetails.add(administratorDetails); + organizationDetails.withAdminDetails(administratorsDetails); + + // Construct certificate issuer credentials + IssuerCredentials credentials = new IssuerCredentials() + .withAccountId("account1") + .withPassword("Pa$$w0rd"); + + String certificateIssuerName = "createCertificateJavaPemIssuer01"; + IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( + new SetCertificateIssuerRequest + .Builder(getVaultUri(), certificateIssuerName, ISSUER_TEST) + .withCredentials(credentials) + .withOrganizationDetails(organizationDetails) + .build()).getBody(); + validateCertificateIssuer(createdCertificateIssuer, certificateIssuerName); + + // Set content type to indicate the certificate is PEM format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PEM); + + X509CertificateProperties x509Properties = new X509CertificateProperties(); + String subjectName = "CN=TestJavaPem"; + x509Properties.withSubject(subjectName); + x509Properties.withValidityInMonths(12); + + // Set issuer reference to the created issuer + IssuerReference issuerReference = new IssuerReference(); + issuerReference.withName(createdCertificateIssuer.issuerIdentifier().name()); + + CertificatePolicy certificatePolicy = new CertificatePolicy() + .withSecretProperties(secretProperties) + .withIssuerReference(issuerReference) + .withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "createTestJavaPem"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + + CertificateBundle certificateBundle = pollOnCertificateOperation(certificateOperation); + validateCertificateBundle(certificateBundle, certificatePolicy); + + validatePem(certificateBundle, subjectName); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } + catch(KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Create a certificate signing request with key in Key Vault. + * @throws ExecutionException + * @throws InterruptedException + * @throws IOException + * @throws IllegalArgumentException + * @throws KeyVaultErrorException + * + * @throws Exception + */ + @Test + public void createCsr() throws InterruptedException, ExecutionException, KeyVaultErrorException, IllegalArgumentException, IOException { + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PKCS12); + + X509CertificateProperties x509Properties = new X509CertificateProperties(); + String subjectName = "CN=ManualEnrollmentJava"; + x509Properties.withSubject(subjectName); + x509Properties.withValidityInMonths(12); + + // Set issuer to "Unknown" + IssuerReference issuerReference = new IssuerReference(); + issuerReference.withName(ISSUER_UNKNOWN); + + CertificatePolicy certificatePolicy = new CertificatePolicy() + .withSecretProperties(secretProperties) + .withIssuerReference(issuerReference) + .withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "createManualEnrollmentJava"; + CertificateOperation certificateOperation = keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicy) + .build()).getBody(); + + Assert.assertNotNull(certificateOperation); + Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); + Assert.assertNotNull(certificateOperation.csr()); + + String csr = keyVaultClient.getPendingCertificateSigningRequest(vaultUri, certificateName).getBody(); + Assert.assertNotNull(csr); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + Assert.assertNotNull(deletedCertificateBundle); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Cancel the certificate create asynchronously + * @throws IOException + * @throws IllegalArgumentException + * @throws KeyVaultErrorException + * + */ + @Test + public void certificateAsyncRequestCancellation() throws KeyVaultErrorException, IllegalArgumentException, IOException { + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties() + .withContentType(MIME_PKCS12); + + String subjectName = "CN=SelfSignedJavaPkcs12"; + X509CertificateProperties x509Properties = new X509CertificateProperties() + .withSubject(subjectName) + .withValidityInMonths(12); + + // Set issuer to "Self" + IssuerReference issuerReference = new IssuerReference() + .withName(ISSUER_SELF); + + CertificatePolicy certificatePolicy = new CertificatePolicy() + .withSecretProperties(secretProperties) + .withIssuerReference(issuerReference) + .withX509CertificateProperties(x509Properties); + + String vaultUri = getVaultUri(); + String certificateName = "cancellationRequestedCertJava"; + keyVaultClient.createCertificate( + new CreateCertificateRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicy) + .build()).getBody(); + + CertificateOperation cancelledCertificateOperation = keyVaultClient.updateCertificateOperation( + new UpdateCertificateOperationRequest + .Builder(vaultUri, certificateName, true) + .build()).getBody(); + + Assert.assertNotNull(cancelledCertificateOperation); + Assert.assertTrue(cancelledCertificateOperation.cancellationRequested()); + + keyVaultClient.deleteCertificateOperation(getVaultUri(), certificateName).getBody(); + keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + } + + /** + * Import a PKCS12 format (which includes the private key) certificate. + */ + @Test + public void importCertificatePkcs12() throws Exception { + String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; + String certificatePassword = "123"; + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties().withContentType(MIME_PKCS12); + CertificatePolicy certificatePolicy = new CertificatePolicy().withSecretProperties(secretProperties); + CertificateAttributes attribute = (CertificateAttributes) new CertificateAttributes().withEnabled(true); + + String vaultUri = getVaultUri(); + String certificateName = "importCertPkcs"; + CertificateBundle certificateBundle = keyVaultClient.importCertificate( + new ImportCertificateRequest + .Builder(vaultUri, certificateName, certificateContent) + .withPassword(certificatePassword) + .withPolicy(certificatePolicy) + .withAttributes(attribute) + .withTags(sTags) + .build()).getBody(); + + // Validate the certificate bundle created + validateCertificateBundle(certificateBundle, certificatePolicy); + Assert.assertTrue(toHexString(certificateBundle.x509Thumbprint()).equalsIgnoreCase("7cb8b7539d87ba7215357b9b9049dff2d3fa59ba")); + Assert.assertEquals(attribute.enabled(), certificateBundle.attributes().enabled()); + + // Load the CER part into X509Certificate object + X509Certificate x509Certificate = loadCerToX509Certificate(certificateBundle); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals("CN=KeyVaultTest")); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals("CN=Root Agency")); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + + // Load the secret into a KeyStore + String secretPassword = ""; + KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword); + + // Validate the certificate and key in the KeyStore + validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword); + + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + + try { + keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + } + } + + /** + * Import a PKCS12 format (which includes the private key) certificate. + */ + @Test + public void certificateUpdate() throws Exception { + String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; + String certificatePassword = "123"; + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties().withContentType(MIME_PKCS12); + CertificatePolicy certificatePolicy = new CertificatePolicy().withSecretProperties(secretProperties); + + String vaultUri = getVaultUri(); + String certificateName = "updateCertJava"; + keyVaultClient.importCertificate( + new ImportCertificateRequest + .Builder(vaultUri, certificateName, certificateContent) + .withPassword(certificatePassword) + .withPolicy(certificatePolicy) + .build()).getBody(); + + + CertificateAttributes attribute = (CertificateAttributes) new CertificateAttributes() + .withEnabled(false) + .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) + .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); + CertificateBundle updatedCertBundle = keyVaultClient.updateCertificate( + new UpdateCertificateRequest + .Builder(vaultUri, certificateName) + .withAttributes((CertificateAttributes) attribute.withEnabled(false)) + .withTags(sTags) + .build()).getBody(); + Assert.assertEquals(attribute.enabled(), updatedCertBundle.attributes().enabled()); + Assert.assertEquals(sTags.toString(), updatedCertBundle.tags().toString()); + + CertificatePolicy certificatePolicyUpdate = certificatePolicy.withIssuerReference(new IssuerReference().withName(ISSUER_SELF)); + CertificatePolicy updatedCertificatePolicy = keyVaultClient.updateCertificatePolicy( + new UpdateCertificatePolicyRequest + .Builder(vaultUri, certificateName) + .withPolicy(certificatePolicyUpdate) + .build()).getBody(); + Assert.assertEquals(certificatePolicyUpdate.issuerReference().name(), updatedCertificatePolicy.issuerReference().name()); + + CertificatePolicy policy = keyVaultClient.getCertificatePolicy(vaultUri, certificateName).getBody(); + Assert.assertEquals(certificatePolicyUpdate.issuerReference().name(), policy.issuerReference().name()); + + keyVaultClient.deleteCertificate(getVaultUri(), certificateName); + } + + /** + * List certificates in a vault. + */ + @Test + public void listCertificates() throws Exception { + String certificateName = "listCertificate"; + String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; + String certificatePassword = "123"; + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PKCS12); + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + + HashSet certificates = new HashSet(); + for (int i = 0; i < MAX_CERTS; ++i) { + int failureCount = 0; + for (;;) { + try { + CertificateBundle certificateBundle = keyVaultClient.importCertificate( + new ImportCertificateRequest + .Builder(getVaultUri(), certificateName + i, certificateContent) + .withPassword(certificatePassword) + .withPolicy(certificatePolicy) + .build()).getBody(); + CertificateIdentifier id = certificateBundle.certificateIdentifier(); + certificates.add(id.baseIdentifier()); + break; } catch (KeyVaultErrorException e) { ++failureCount; if (e.getBody().error().code().equals("Throttled")) { @@ -890,13 +670,13 @@ public void listCertificates() throws Exception { } throw e; } - } - } + } + } - PagedList listResult = keyVaultClient.getCertificates(getVaultUri(), PAGELIST_MAX_CERTS).getBody(); - Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); + PagedList listResult = keyVaultClient.listCertificates(getVaultUri(), PAGELIST_MAX_CERTS).getBody(); + Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); - HashSet toDelete = new HashSet(); + HashSet toDelete = new HashSet(); for (CertificateItem item : listResult) { CertificateIdentifier id = new CertificateIdentifier(item.id()); @@ -904,42 +684,42 @@ public void listCertificates() throws Exception { certificates.remove(item.id()); } - Assert.assertEquals(0, certificates.size()); - - for (String toDeleteCertificateName : toDelete) { - keyVaultClient.deleteCertificate(getVaultUri(), toDeleteCertificateName); - } - } - - /** - * List versions of a certificate in a vault. - */ - @Test - public void listCertificateVersions() throws Exception { - String certificateName = "listCertificateVersions"; - String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; - String certificatePassword = "123"; - - // Set content type to indicate the certificate is PKCS12 format. - SecretProperties secretProperties = new SecretProperties(); - secretProperties.withContentType(MIME_PKCS12); - CertificatePolicy certificatePolicy = new CertificatePolicy(); - certificatePolicy.withSecretProperties(secretProperties); - - HashSet certificates = new HashSet(); - for (int i = 0; i < MAX_CERTS; ++i) { - int failureCount = 0; - for (;;) { - try { - CertificateBundle certificateBundle = keyVaultClient.importCertificate( - new ImportCertificateRequest - .Builder(getVaultUri(), certificateName, certificateContent) - .withPassword(certificatePassword) - .withPolicy(certificatePolicy) - .build()).getBody(); - CertificateIdentifier id = certificateBundle.certificateIdentifier(); - certificates.add(id.identifier()); - break; + Assert.assertEquals(0, certificates.size()); + + for (String toDeleteCertificateName : toDelete) { + keyVaultClient.deleteCertificate(getVaultUri(), toDeleteCertificateName); + } + } + + /** + * List versions of a certificate in a vault. + */ + @Test + public void listCertificateVersions() throws Exception { + String certificateName = "listCertificateVersions"; + String certificateContent = "MIIJOwIBAzCCCPcGCSqGSIb3DQEHAaCCCOgEggjkMIII4DCCBgkGCSqGSIb3DQEHAaCCBfoEggX2MIIF8jCCBe4GCyqGSIb3DQEMCgECoIIE/jCCBPowHAYKKoZIhvcNAQwBAzAOBAj15YH9pOE58AICB9AEggTYLrI+SAru2dBZRQRlJY7XQ3LeLkah2FcRR3dATDshZ2h0IA2oBrkQIdsLyAAWZ32qYR1qkWxLHn9AqXgu27AEbOk35+pITZaiy63YYBkkpR+pDdngZt19Z0PWrGwHEq5z6BHS2GLyyN8SSOCbdzCz7blj3+7IZYoMj4WOPgOm/tQ6U44SFWek46QwN2zeA4i97v7ftNNns27ms52jqfhOvTA9c/wyfZKAY4aKJfYYUmycKjnnRl012ldS2lOkASFt+lu4QCa72IY6ePtRudPCvmzRv2pkLYS6z3cI7omT8nHP3DymNOqLbFqr5O2M1ZYaLC63Q3xt3eVvbcPh3N08D1hHkhz/KDTvkRAQpvrW8ISKmgDdmzN55Pe55xHfSWGB7gPw8sZea57IxFzWHTK2yvTslooWoosmGxanYY2IG/no3EbPOWDKjPZ4ilYJe5JJ2immlxPz+2e2EOCKpDI+7fzQcRz3PTd3BK+budZ8aXX8aW/lOgKS8WmxZoKnOJBNWeTNWQFugmktXfdPHAdxMhjUXqeGQd8wTvZ4EzQNNafovwkI7IV/ZYoa++RGofVR3ZbRSiBNF6TDj/qXFt0wN/CQnsGAmQAGNiN+D4mY7i25dtTu/Jc7OxLdhAUFpHyJpyrYWLfvOiS5WYBeEDHkiPUa/8eZSPA3MXWZR1RiuDvuNqMjct1SSwdXADTtF68l/US1ksU657+XSC+6ly1A/upz+X71+C4Ho6W0751j5ZMT6xKjGh5pee7MVuduxIzXjWIy3YSd0fIT3U0A5NLEvJ9rfkx6JiHjRLx6V1tqsrtT6BsGtmCQR1UCJPLqsKVDvAINx3cPA/CGqr5OX2BGZlAihGmN6n7gv8w4O0k0LPTAe5YefgXN3m9pE867N31GtHVZaJ/UVgDNYS2jused4rw76ZWN41akx2QN0JSeMJqHXqVz6AKfz8ICS/dFnEGyBNpXiMRxrY/QPKi/wONwqsbDxRW7vZRVKs78pBkE0ksaShlZk5GkeayDWC/7Hi/NqUFtIloK9XB3paLxo1DGu5qqaF34jZdktzkXp0uZqpp+FfKZaiovMjt8F7yHCPk+LYpRsU2Cyc9DVoDA6rIgf+uEP4jppgehsxyT0lJHax2t869R2jYdsXwYUXjgwHIV0voj7bJYPGFlFjXOp6ZW86scsHM5xfsGQoK2Fp838VT34SHE1ZXU/puM7rviREHYW72pfpgGZUILQMohuTPnd8tFtAkbrmjLDo+k9xx7HUvgoFTiNNWuq/cRjr70FKNguMMTIrid+HwfmbRoaxENWdLcOTNeascER2a+37UQolKD5ksrPJG6RdNA7O2pzp3micDYRs/+s28cCIxO//J/d4nsgHp6RTuCu4+Jm9k0YTw2Xg75b2cWKrxGnDUgyIlvNPaZTB5QbMid4x44/lE0LLi9kcPQhRgrK07OnnrMgZvVGjt1CLGhKUv7KFc3xV1r1rwKkosxnoG99oCoTQtregcX5rIMjHgkc1IdflGJkZzaWMkYVFOJ4Weynz008i4ddkske5vabZs37Lb8iggUYNBYZyGzalruBgnQyK4fz38Fae4nWYjyildVfgyo/fCePR2ovOfphx9OQJi+M9BoFmPrAg+8ARDZ+R+5yzYuEc9ZoVX7nkp7LTGB3DANBgkrBgEEAYI3EQIxADATBgkqhkiG9w0BCRUxBgQEAQAAADBXBgkqhkiG9w0BCRQxSh5IAGEAOAAwAGQAZgBmADgANgAtAGUAOQA2AGUALQA0ADIAMgA0AC0AYQBhADEAMQAtAGIAZAAxADkANABkADUAYQA2AGIANwA3MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMAcgBvAHMAbwBmAHQAIABTAHQAcgBvAG4AZwAgAEMAcgB5AHAAdABvAGcAcgBhAHAAaABpAGMAIABQAHIAbwB2AGkAZABlAHIwggLPBgkqhkiG9w0BBwagggLAMIICvAIBADCCArUGCSqGSIb3DQEHATAcBgoqhkiG9w0BDAEGMA4ECNX+VL2MxzzWAgIH0ICCAojmRBO+CPfVNUO0s+BVuwhOzikAGNBmQHNChmJ/pyzPbMUbx7tO63eIVSc67iERda2WCEmVwPigaVQkPaumsfp8+L6iV/BMf5RKlyRXcwh0vUdu2Qa7qadD+gFQ2kngf4Dk6vYo2/2HxayuIf6jpwe8vql4ca3ZtWXfuRix2fwgltM0bMz1g59d7x/glTfNqxNlsty0A/rWrPJjNbOPRU2XykLuc3AtlTtYsQ32Zsmu67A7UNBw6tVtkEXlFDqhavEhUEO3dvYqMY+QLxzpZhA0q44ZZ9/ex0X6QAFNK5wuWxCbupHWsgxRwKftrxyszMHsAvNoNcTlqcctee+ecNwTJQa1/MDbnhO6/qHA7cfG1qYDq8Th635vGNMW1w3sVS7l0uEvdayAsBHWTcOC2tlMa5bfHrhY8OEIqj5bN5H9RdFy8G/W239tjDu1OYjBDydiBqzBn8HG1DSj1Pjc0kd/82d4ZU0308KFTC3yGcRad0GnEH0Oi3iEJ9HbriUbfVMbXNHOF+MktWiDVqzndGMKmuJSdfTBKvGFvejAWVO5E4mgLvoaMmbchc3BO7sLeraHnJN5hvMBaLcQI38N86mUfTR8AP6AJ9c2k514KaDLclm4z6J8dMz60nUeo5D3YD09G6BavFHxSvJ8MF0Lu5zOFzEePDRFm9mH8W0N/sFlIaYfD/GWU/w44mQucjaBk95YtqOGRIj58tGDWr8iUdHwaYKGqU24zGeRae9DhFXPzZshV1ZGsBQFRaoYkyLAwdJWIXTi+c37YaC8FRSEnnNmS79Dou1Kc3BvK4EYKAD2KxjtUebrV174gD0Q+9YuJ0GXOTspBvCFd5VT2Rw5zDNrA/J3F5fMCk4wOzAfMAcGBSsOAwIaBBSxgh2xyF+88V4vAffBmZXv8Txt4AQU4O/NX4MjxSodbE7ApNAMIvrtREwCAgfQ"; + String certificatePassword = "123"; + + // Set content type to indicate the certificate is PKCS12 format. + SecretProperties secretProperties = new SecretProperties(); + secretProperties.withContentType(MIME_PKCS12); + CertificatePolicy certificatePolicy = new CertificatePolicy(); + certificatePolicy.withSecretProperties(secretProperties); + + HashSet certificates = new HashSet(); + for (int i = 0; i < MAX_CERTS; ++i) { + int failureCount = 0; + for (;;) { + try { + CertificateBundle certificateBundle = keyVaultClient.importCertificate( + new ImportCertificateRequest + .Builder(getVaultUri(), certificateName, certificateContent) + .withPassword(certificatePassword) + .withPolicy(certificatePolicy) + .build()).getBody(); + CertificateIdentifier id = certificateBundle.certificateIdentifier(); + certificates.add(id.identifier()); + break; } catch (KeyVaultErrorException e) { ++failureCount; if (e.getBody().error().code().equals("Throttled")) { @@ -949,320 +729,399 @@ public void listCertificateVersions() throws Exception { } throw e; } - } - } + } + } - PagedList listResult = keyVaultClient.getCertificateVersions(getVaultUri(), certificateName, PAGELIST_MAX_CERTS).getBody(); + PagedList listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName, PAGELIST_MAX_CERTS).getBody(); Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); - listResult = keyVaultClient.getCertificateVersions(getVaultUri(), certificateName).getBody(); - for (;;) { - for (CertificateItem item : listResult) { - certificates.remove(item.id()); + listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName).getBody(); + + for (CertificateItem item : listResult) { + certificates.remove(item.id()); + } + + Assert.assertEquals(0, certificates.size()); + + keyVaultClient.deleteCertificate(getVaultUri(), certificateName); + } + + /** + * CRUD for Certificate issuers + */ + @Test + public void issuerCrudOperations() throws Exception { + // Construct organization administrator details + AdministratorDetails administratorDetails = new AdministratorDetails() + .withFirstName("John") + .withLastName("Doe") + .withEmailAddress("john.doe@contoso.com") + .withPhone("1234567890"); + + // Construct organization details + OrganizationDetails organizationDetails = new OrganizationDetails(); + List administratorsDetails = new ArrayList(); + administratorsDetails.add(administratorDetails); + organizationDetails.withAdminDetails(administratorsDetails); + + // Construct certificate issuer credentials + IssuerCredentials credentials = new IssuerCredentials() + .withAccountId("account1") + .withPassword("Pa$$w0rd"); + + IssuerBundle certificateIssuer = new IssuerBundle() + .withProvider(ISSUER_TEST) + .withCredentials(credentials) + .withOrganizationDetails(organizationDetails); + + IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( + new SetCertificateIssuerRequest + .Builder(getVaultUri(), "issuer1", certificateIssuer.provider()) + .withCredentials(certificateIssuer.credentials()) + .withOrganizationDetails(certificateIssuer.organizationDetails()) + .build()).getBody(); + + validateCertificateIssuer(certificateIssuer, createdCertificateIssuer); + + String certificateIssuerName = createdCertificateIssuer.issuerIdentifier().name(); + IssuerBundle retrievedCertificateIssuer = keyVaultClient.getCertificateIssuer(getVaultUri(), + certificateIssuerName).getBody(); + + validateCertificateIssuer(certificateIssuer, retrievedCertificateIssuer); + + IssuerCredentials updatedCredentials = new IssuerCredentials() + .withAccountId("account2") + .withPassword("Secur!Ty"); + + retrievedCertificateIssuer.withCredentials(updatedCredentials); + IssuerBundle updatedCertificateIssuer = keyVaultClient.updateCertificateIssuer( + new UpdateCertificateIssuerRequest + .Builder(getVaultUri(), certificateIssuerName, ISSUER_TEST) + .withCredentials(updatedCredentials) + .withOrganizationDetails(retrievedCertificateIssuer.organizationDetails()) + .withAttributes(retrievedCertificateIssuer.attributes()) + .build()).getBody(); + + validateCertificateIssuer(retrievedCertificateIssuer, updatedCertificateIssuer); + + Assert.assertNotNull(updatedCertificateIssuer.organizationDetails()); + + IssuerBundle deletedCertificateIssuer = keyVaultClient.deleteCertificateIssuer(getVaultUri(), certificateIssuerName).getBody(); + + validateCertificateIssuer(updatedCertificateIssuer, deletedCertificateIssuer); + + try { + keyVaultClient.getCertificateIssuer(getVaultUri(), certificateIssuerName); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("CertificateIssuerNotFound", e.getBody().error().code()); + } + } + + /** + * CRUD for Certificate contacts + * @throws Exception + */ + @Test + public void contactsCrudOperations() throws Exception { + // Create + Contact contact1 = new Contact(); + contact1.withName("James"); + contact1.withEmailAddress("james@contoso.com"); + contact1.withPhone("7777777777"); + + Contact contact2 = new Contact(); + contact2.withName("Ethan"); + contact2.withEmailAddress("ethan@contoso.com"); + contact2.withPhone("8888888888"); + + List contacts = new ArrayList(); + contacts.add(contact1); + contacts.add(contact2); + + Contacts certificateContacts = new Contacts(); + certificateContacts.withContactList(contacts); + Contacts createdCertificateContacts = keyVaultClient.setCertificateContacts(getVaultUri(), certificateContacts).getBody(); + Assert.assertNotNull(createdCertificateContacts); + Assert.assertNotNull(createdCertificateContacts.contactList()); + Assert.assertTrue(createdCertificateContacts.contactList().size() == 2); + Contact[] createContacts = createdCertificateContacts.contactList().toArray(new Contact[createdCertificateContacts.contactList().size()]); + Assert.assertTrue(createContacts[0].name().equalsIgnoreCase("James")); + Assert.assertTrue(createContacts[0].emailAddress().equalsIgnoreCase("james@contoso.com")); + Assert.assertTrue(createContacts[0].phone().equalsIgnoreCase("7777777777")); + Assert.assertTrue(createContacts[1].name().equalsIgnoreCase("Ethan")); + Assert.assertTrue(createContacts[1].emailAddress().equalsIgnoreCase("ethan@contoso.com")); + Assert.assertTrue(createContacts[1].phone().equalsIgnoreCase("8888888888")); + + // Get + Contacts retrievedCertificateContacts = keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); + Assert.assertNotNull(retrievedCertificateContacts); + Assert.assertNotNull(retrievedCertificateContacts.contactList()); + Assert.assertTrue(retrievedCertificateContacts.contactList().size() == 2); + + // Delete + Contacts deletedCertificateContacts = keyVaultClient.deleteCertificateContacts(getVaultUri()).getBody(); + Assert.assertNotNull(deletedCertificateContacts); + Assert.assertNotNull(deletedCertificateContacts.contactList()); + Assert.assertTrue(deletedCertificateContacts.contactList().size() == 2); + + // Get after delete + try { + keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); + } catch (KeyVaultErrorException e) { + Assert.assertNotNull(e.getBody().error()); + Assert.assertEquals("ContactsNotFound", e.getBody().error().code()); + } + } + + /** + * Polls on a certificate operation for completion. + * + * @throws Exception + */ + private static CertificateBundle pollOnCertificateOperation(CertificateOperation certificateOperation) + throws Exception { + + // Wait for enrollment to complete. We will wait for 200 seconds + int pendingPollCount = 0; + while (pendingPollCount < 21) { + String certificateName = certificateOperation.certificateOperationIdentifier().name(); + CertificateOperation pendingCertificateOperation = keyVaultClient + .getCertificateOperation(getVaultUri(), certificateName).getBody(); + if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)) { + Thread.sleep(10000); + pendingPollCount += 1; + continue; } - String nextLink = listResult.nextPageLink(); - if (nextLink == null) { + + if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_COMPLETED)) { + return keyVaultClient.getCertificate(pendingCertificateOperation.target()).getBody(); + } + + throw new Exception(String.format( + "Polling on pending certificate returned an unexpected result. Error code = {1}, Error message = {2}", + pendingCertificateOperation.error().code(), + pendingCertificateOperation.error().message())); + } + + throw new Exception("Pending certificate processing delayed"); + } + + /** + * Extracts private key from PEM contents + * + * @throws InvalidKeySpecException + * @throws NoSuchAlgorithmException + */ + private static PrivateKey extractPrivateKeyFromPemContents(String pemContents) + throws InvalidKeySpecException, NoSuchAlgorithmException { + Matcher matcher = _privateKey.matcher(pemContents); + if (!matcher.find()) { + throw new IllegalArgumentException("No private key found in PEM contents."); + } + + byte[] privateKeyBytes = _base64.decode(matcher.group(1)); + PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes); + KeyFactory keyFactory = KeyFactory.getInstance(ALGO_RSA); + PrivateKey privateKey = keyFactory.generatePrivate(keySpec); + return privateKey; + } + + /** + * Extracts certificates from PEM contents + * + * @throws CertificateException + * @throws IOException + */ + private static List extractCertificatesFromPemContents(String pemContents) + throws CertificateException, IOException { + Matcher matcher = _certificate.matcher(pemContents); + if (!matcher.find()) { + throw new IllegalArgumentException("No certificate found in PEM contents."); + } + + List result = new ArrayList(); + int offset = 0; + while (true) { + if (!matcher.find(offset)) { break; } - keyVaultClient.getCertificateVersionsNext(nextLink).getBody(); + byte[] certBytes = _base64.decode(matcher.group(1)); + ByteArrayInputStream certStream = new ByteArrayInputStream(certBytes); + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(certStream); + certStream.close(); + + result.add(x509Certificate); + offset = matcher.end(); } - Assert.assertEquals(0, certificates.size()); + return result; + } + + /** + * Verify a RSA key pair with a simple encrypt/decrypt test. + * + * @throws NoSuchPaddingException + * @throws NoSuchAlgorithmException + * @throws InvalidKeyException + * @throws BadPaddingException + * @throws IllegalBlockSizeException + */ + private static void verifyRSAKeyPair(KeyPair keyPair) throws NoSuchAlgorithmException, NoSuchPaddingException, + InvalidKeyException, IllegalBlockSizeException, BadPaddingException { + // Validate algorithm is RSA + Assert.assertTrue(keyPair.getPublic().getAlgorithm().equals(ALGO_RSA)); + Assert.assertTrue(keyPair.getPrivate().getAlgorithm().equals(ALGO_RSA)); + + // Generate an array of 10 random bytes + byte[] plainData = new byte[10]; + Random random = new Random(); + random.nextBytes(plainData); + + // Encrypt using the public key + Cipher encryptCipher = Cipher.getInstance(ALGO_RSA); + encryptCipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic()); + byte[] encryptedData = encryptCipher.doFinal(plainData); + + // Decrypt using the private key + Cipher decryptCipher = Cipher.getInstance(ALGO_RSA); + decryptCipher.init(Cipher.DECRYPT_MODE, keyPair.getPrivate()); + byte[] decryptedData = decryptCipher.doFinal(encryptedData); + + // Validate plainData is equal to decryptedData + Assert.assertArrayEquals(plainData, decryptedData); + } + + private String toHexString(byte[] x5t) { + + if(x5t == null) + return ""; + + StringBuilder hexString = new StringBuilder(); + for (int i = 0; i < x5t.length; i++) { + String hex = Integer.toHexString(0xFF & x5t[i]); + if (hex.length() == 1) { + hexString.append('0'); + } + hexString.append(hex); + } - keyVaultClient.deleteCertificate(getVaultUri(), certificateName); - } - - /** - * CRUD for Certificate issuers - */ - @Test - public void issuerCrudOperations() throws Exception { - // Construct organization administrator details - AdministratorDetails administratorDetails = new AdministratorDetails(); - administratorDetails.withFirstName("John"); - administratorDetails.withLastName("Doe"); - administratorDetails.withEmailAddress("john.doe@contoso.com"); - administratorDetails.withPhone("1234567890"); - - // Construct organization details - OrganizationDetails organizationDetails = new OrganizationDetails(); - List administratorsDetails = new ArrayList(); - administratorsDetails.add(administratorDetails); - organizationDetails.withAdminDetails(administratorsDetails); - - // Construct certificate issuer credentials - IssuerCredentials credentials = new IssuerCredentials(); - credentials.withAccountId("account1"); - credentials.withPassword("Pa$$w0rd"); - - IssuerBundle certificateIssuer = new IssuerBundle(); - certificateIssuer.withProvider(ISSUER_TEST); - certificateIssuer.withCredentials(credentials); - certificateIssuer.withOrganizationDetails(organizationDetails); - - IssuerBundle createdCertificateIssuer = keyVaultClient.setCertificateIssuer( - new SetCertificateIssuerRequest - .Builder(getVaultUri(), "issuer1") - .withIssuer(certificateIssuer) - .build()).getBody(); - - Assert.assertNotNull(createdCertificateIssuer); - Assert.assertNotNull(createdCertificateIssuer.provider()); - Assert.assertTrue(createdCertificateIssuer.provider().equals("Test")); - - Assert.assertNotNull(createdCertificateIssuer.credentials()); - Assert.assertNotNull(createdCertificateIssuer.credentials().accountId()); - Assert.assertTrue(createdCertificateIssuer.credentials().accountId().equals("account1")); - Assert.assertNull(createdCertificateIssuer.credentials().password()); - - Assert.assertNotNull(createdCertificateIssuer.organizationDetails()); - - String certificateIssuerName = createdCertificateIssuer.issuerIdentifier().name(); - IssuerBundle retrievedCertificateIssuer = keyVaultClient.getCertificateIssuer(getVaultUri(), - certificateIssuerName).getBody(); - - Assert.assertNotNull(retrievedCertificateIssuer); - Assert.assertNotNull(retrievedCertificateIssuer.provider()); - Assert.assertTrue(retrievedCertificateIssuer.provider().equals(ISSUER_TEST)); - - Assert.assertNotNull(retrievedCertificateIssuer.credentials()); - Assert.assertNotNull(retrievedCertificateIssuer.credentials().accountId()); - Assert.assertTrue(retrievedCertificateIssuer.credentials().accountId().equals("account1")); - Assert.assertNull(retrievedCertificateIssuer.credentials().password()); - - Assert.assertNotNull(retrievedCertificateIssuer.organizationDetails()); - - IssuerCredentials updatedCredentials = new IssuerCredentials(); - updatedCredentials.withAccountId("account2"); - updatedCredentials.withPassword("Secur!Ty"); - retrievedCertificateIssuer.withCredentials(updatedCredentials); - IssuerBundle updatedCertificateIssuer = keyVaultClient.updateCertificateIssuer( - new UpdateCertificateIssuerRequest - .Builder(getVaultUri(), certificateIssuerName) - .withIssuer(retrievedCertificateIssuer) - .build()).getBody(); - - Assert.assertNotNull(updatedCertificateIssuer); - Assert.assertNotNull(updatedCertificateIssuer.provider()); - Assert.assertTrue(updatedCertificateIssuer.provider().equals(ISSUER_TEST)); - - Assert.assertNotNull(updatedCertificateIssuer.credentials()); - Assert.assertNotNull(updatedCertificateIssuer.credentials().accountId()); - Assert.assertTrue(updatedCertificateIssuer.credentials().accountId().equals("account2")); - Assert.assertNull(updatedCertificateIssuer.credentials().password()); - - Assert.assertNotNull(updatedCertificateIssuer.organizationDetails()); - - IssuerBundle deletedCertificateIssuer = keyVaultClient.deleteCertificateIssuer(getVaultUri(), certificateIssuerName).getBody(); - - Assert.assertNotNull(deletedCertificateIssuer); - Assert.assertNotNull(deletedCertificateIssuer.provider()); - Assert.assertTrue(deletedCertificateIssuer.provider().equals(ISSUER_TEST)); - - Assert.assertNotNull(deletedCertificateIssuer.credentials()); - Assert.assertNotNull(deletedCertificateIssuer.credentials().accountId()); - Assert.assertTrue(deletedCertificateIssuer.credentials().accountId().equals("account2")); - Assert.assertNull(deletedCertificateIssuer.credentials().password()); - - Assert.assertNotNull(deletedCertificateIssuer.organizationDetails()); - - try { - keyVaultClient.getCertificateIssuer(getVaultUri(), certificateIssuerName); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateIssuerNotFound", e.getBody().error().code()); - } - } - - /** - * CRUD for Certificate contacts - * @throws Exception - */ - @Test - public void contactsCrudOperations() throws Exception { - // Create - Contact contact1 = new Contact(); - contact1.withName("James"); - contact1.withEmailAddress("james@contoso.com"); - contact1.withPhone("7777777777"); - - Contact contact2 = new Contact(); - contact2.withName("Ethan"); - contact2.withEmailAddress("ethan@contoso.com"); - contact2.withPhone("8888888888"); - - List contacts = new ArrayList(); - contacts.add(contact1); - contacts.add(contact2); - - Contacts certificateContacts = new Contacts(); - certificateContacts.withContactList(contacts); - Contacts createdCertificateContacts = keyVaultClient.setCertificateContacts(getVaultUri(), certificateContacts).getBody(); - Assert.assertNotNull(createdCertificateContacts); - Assert.assertNotNull(createdCertificateContacts.contactList()); - Assert.assertTrue(createdCertificateContacts.contactList().size() == 2); - Contact[] createContacts = createdCertificateContacts.contactList().toArray(new Contact[createdCertificateContacts.contactList().size()]); - Assert.assertTrue(createContacts[0].name().equalsIgnoreCase("James")); - Assert.assertTrue(createContacts[0].emailAddress().equalsIgnoreCase("james@contoso.com")); - Assert.assertTrue(createContacts[0].phone().equalsIgnoreCase("7777777777")); - Assert.assertTrue(createContacts[1].name().equalsIgnoreCase("Ethan")); - Assert.assertTrue(createContacts[1].emailAddress().equalsIgnoreCase("ethan@contoso.com")); - Assert.assertTrue(createContacts[1].phone().equalsIgnoreCase("8888888888")); - - // Get - Contacts retrievedCertificateContacts = keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); - Assert.assertNotNull(retrievedCertificateContacts); - Assert.assertNotNull(retrievedCertificateContacts.contactList()); - Assert.assertTrue(retrievedCertificateContacts.contactList().size() == 2); - - // Delete - Contacts deletedCertificateContacts = keyVaultClient.deleteCertificateContacts(getVaultUri()).getBody(); - Assert.assertNotNull(deletedCertificateContacts); - Assert.assertNotNull(deletedCertificateContacts.contactList()); - Assert.assertTrue(deletedCertificateContacts.contactList().size() == 2); - - // Get after delete - try { - keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); - } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("ContactsNotFound", e.getBody().error().code()); - } - } - - /** - * Polls on a certificate operation for completion. - * - * @throws Exception - */ - private static CertificateBundle pollOnCertificateOperation(CertificateOperation certificateOperation) - throws Exception { - - // Wait for enrollment to complete. We will wait for 200 seconds - int pendingPollCount = 0; - while (pendingPollCount < 21) { - String certificateName = certificateOperation.certificateOperationIdentifier().name(); - CertificateOperation pendingCertificateOperation = keyVaultClient - .getCertificateOperation(getVaultUri(), certificateName).getBody(); - if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)) { - Thread.sleep(10000); - pendingPollCount += 1; - continue; - } - - if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_COMPLETED)) { - return keyVaultClient.getCertificate(pendingCertificateOperation.target()).getBody(); - } - - throw new Exception(String.format( - "Polling on pending certificate returned an unexpected result. Error code = {1}, Error message = {2}", - pendingCertificateOperation.error().code(), - pendingCertificateOperation.error().message())); - } - - throw new Exception("Pending certificate processing delayed"); - } - - /** - * Extracts private key from PEM contents - * - * @throws InvalidKeySpecException - * @throws NoSuchAlgorithmException - */ - private static PrivateKey extractPrivateKeyFromPemContents(String pemContents) - throws InvalidKeySpecException, NoSuchAlgorithmException { - Matcher matcher = _privateKey.matcher(pemContents); - if (!matcher.find()) { - throw new IllegalArgumentException("No private key found in PEM contents."); - } - - byte[] privateKeyBytes = _base64.decode(matcher.group(1)); - PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes); - KeyFactory keyFactory = KeyFactory.getInstance(ALGO_RSA); - PrivateKey privateKey = keyFactory.generatePrivate(keySpec); - return privateKey; - } - - /** - * Extracts certificates from PEM contents - * - * @throws CertificateException - * @throws IOException - */ - private static List extractCertificatesFromPemContents(String pemContents) - throws CertificateException, IOException { - Matcher matcher = _certificate.matcher(pemContents); - if (!matcher.find()) { - throw new IllegalArgumentException("No certificate found in PEM contents."); - } - - List result = new ArrayList(); - int offset = 0; - while (true) { - if (!matcher.find(offset)) { - break; - } - byte[] certBytes = _base64.decode(matcher.group(1)); - ByteArrayInputStream certStream = new ByteArrayInputStream(certBytes); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(certStream); - certStream.close(); - - result.add(x509Certificate); - offset = matcher.end(); - } - - return result; - } - - /** - * Verify a RSA key pair with a simple encrypt/decrypt test. - * - * @throws NoSuchPaddingException - * @throws NoSuchAlgorithmException - * @throws InvalidKeyException - * @throws BadPaddingException - * @throws IllegalBlockSizeException - */ - private static void verifyRSAKeyPair(KeyPair keyPair) throws NoSuchAlgorithmException, NoSuchPaddingException, - InvalidKeyException, IllegalBlockSizeException, BadPaddingException { - // Validate algorithm is RSA - Assert.assertTrue(keyPair.getPublic().getAlgorithm().equals(ALGO_RSA)); - Assert.assertTrue(keyPair.getPrivate().getAlgorithm().equals(ALGO_RSA)); - - // Generate an array of 10 random bytes - byte[] plainData = new byte[10]; - Random random = new Random(); - random.nextBytes(plainData); - - // Encrypt using the public key - Cipher encryptCipher = Cipher.getInstance(ALGO_RSA); - encryptCipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic()); - byte[] encryptedData = encryptCipher.doFinal(plainData); - - // Decrypt using the private key - Cipher decryptCipher = Cipher.getInstance(ALGO_RSA); - decryptCipher.init(Cipher.DECRYPT_MODE, keyPair.getPrivate()); - byte[] decryptedData = decryptCipher.doFinal(encryptedData); - - // Validate plainData is equal to decryptedData - Assert.assertArrayEquals(plainData, decryptedData); - } - - private String toHexString(byte[] x5t) { - - if(x5t == null) - return ""; - - StringBuilder hexString = new StringBuilder(); - for (int i = 0; i < x5t.length; i++) { - String hex = Integer.toHexString(0xFF & x5t[i]); - if (hex.length() == 1) { - hexString.append('0'); - } - hexString.append(hex); - } - - return hexString.toString().replace("-", ""); - } + return hexString.toString().replace("-", ""); + } + + private void validateCertificateBundle(CertificateBundle certificateBundle, CertificatePolicy certificatePolicy) { + Assert.assertNotNull(certificateBundle); + Assert.assertNotNull(certificateBundle.id()); + Assert.assertNotNull(certificateBundle.keyIdentifier()); + Assert.assertNotNull(certificateBundle.secretIdentifier()); + Assert.assertNotNull(certificateBundle.x509Thumbprint()); + + if (certificatePolicy != null) { + Assert.assertNotNull(certificateBundle.policy()); + Assert.assertNotNull(certificateBundle.policy().issuerReference()); + Assert.assertNotNull(certificateBundle.policy().issuerReference().name()); + if(certificatePolicy.issuerReference() != null) { + Assert.assertTrue(certificateBundle.policy().issuerReference().name().equalsIgnoreCase(certificatePolicy.issuerReference().name())); + } + } + } + + private X509Certificate loadCerToX509Certificate(CertificateBundle certificateBundle) throws CertificateException, IOException { + Assert.assertNotNull(certificateBundle.cer()); + ByteArrayInputStream cerStream = new ByteArrayInputStream(certificateBundle.cer()); + CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); + X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); + cerStream.close(); + return x509Certificate; + } + + private void validateCertificateIssuer(IssuerBundle expecred, IssuerBundle actual) { + Assert.assertNotNull(actual); + Assert.assertNotNull(actual.provider()); + Assert.assertTrue(actual.provider().equals(expecred.provider())); + + Assert.assertNotNull(actual.credentials()); + Assert.assertNotNull(actual.credentials().accountId()); + Assert.assertTrue(actual.credentials().accountId().equals(expecred.credentials().accountId())); + Assert.assertNull(actual.credentials().password()); + + Assert.assertNotNull(actual.organizationDetails()); + } + + private void validateCertificateKeyInKeyStore(KeyStore keyStore, X509Certificate x509Certificate, String secretPassword) throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + String defaultAlias = Collections.list(keyStore.aliases()).get(0); + X509Certificate secretCertificate = (X509Certificate) keyStore.getCertificate(defaultAlias); + Assert.assertNotNull(secretCertificate); + Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() + .equals(x509Certificate.getSubjectX500Principal().getName())); + Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() + .equals(x509Certificate.getIssuerX500Principal().getName())); + Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); + + + // Validate the key in the KeyStore + Key secretKey = keyStore.getKey(defaultAlias, secretPassword.toCharArray()); + Assert.assertNotNull(secretKey); + Assert.assertTrue(secretKey instanceof PrivateKey); + PrivateKey secretPrivateKey = (PrivateKey) secretKey; + + // Create a KeyPair with the private key from the KeyStore and public + // key from the certificate to verify they match + KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); + Assert.assertNotNull(keyPair); + verifyRSAKeyPair(keyPair); + } + + private void validateCertificateIssuer(IssuerBundle issuer, String issuerName) { + Assert.assertNotNull(issuer); + Assert.assertNotNull(issuer.issuerIdentifier()); + Assert.assertNotNull(issuer.issuerIdentifier().name()); + Assert.assertTrue(issuer.issuerIdentifier().name().equalsIgnoreCase(issuerName)); + } + + private KeyStore loadSecretToKeyStore(SecretBundle secret, String secretPassword) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { + ByteArrayInputStream secretStream = new ByteArrayInputStream(_base64.decode(secret.value())); + KeyStore keyStore = KeyStore.getInstance(PKCS12); + keyStore.load(secretStream, secretPassword.toCharArray()); + secretStream.close(); + return keyStore; + } + + private void validatePem(CertificateBundle certificateBundle, String subjectName) throws CertificateException, IOException, KeyVaultErrorException, IllegalArgumentException, InvalidKeySpecException, NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + // Load the CER part into X509Certificate object + X509Certificate x509Certificate = loadCerToX509Certificate(certificateBundle); + + Assert.assertTrue(x509Certificate.getSubjectX500Principal().getName().equals(subjectName)); + Assert.assertTrue(x509Certificate.getIssuerX500Principal().getName().equals(subjectName)); + + // Retrieve the secret backing the certificate + SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + String secretValue = secret.value(); + + // Extract private key from PEM + PrivateKey secretPrivateKey = extractPrivateKeyFromPemContents(secretValue); + Assert.assertNotNull(secretPrivateKey); + + // Extract certificates from PEM + List certificates = extractCertificatesFromPemContents(secretValue); + Assert.assertNotNull(certificates); + Assert.assertTrue(certificates.size() == 1); + + // has the public key corresponding to the private key. + X509Certificate secretCertificate = certificates.get(0); + Assert.assertNotNull(secretCertificate); + Assert.assertTrue(secretCertificate.getSubjectX500Principal().getName() + .equals(x509Certificate.getSubjectX500Principal().getName())); + Assert.assertTrue(secretCertificate.getIssuerX500Principal().getName() + .equals(x509Certificate.getIssuerX500Principal().getName())); + Assert.assertTrue(secretCertificate.getSerialNumber().equals(x509Certificate.getSerialNumber())); + + // Create a KeyPair with the private key from the KeyStore and public + // key from the certificate to verify they match + KeyPair keyPair = new KeyPair(secretCertificate.getPublicKey(), secretPrivateKey); + Assert.assertNotNull(keyPair); + verifyRSAKeyPair(keyPair); + } } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 08ff519858b73..f227d9f5ca3cb 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -48,6 +48,7 @@ import com.microsoft.azure.keyvault.requests.ImportKeyRequest; import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.models.KeyAttributes; import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; @@ -64,15 +65,30 @@ public void transparentAuthentication() throws Exception { // Create a key on a vault. { - KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, "RSA", null); + Map tags = new HashMap(); + tags.put("foo", "baz"); + List keyOps = Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT); + KeyAttributes attribute = (KeyAttributes) new KeyAttributes() + .withEnabled(true) + .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) + .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); + + KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest + .Builder(getVaultUri(), KEY_NAME, "RSA") + .withAttributes(attribute) + .withKeyOperations(keyOps) + .withKeySize(2048) + .withTags(tags) + .build()).getBody(); + + validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, "RSA", keyOps, attribute); } // Create a key on a different vault. Key Vault Data Plane returns 401, // which must be transparently handled by KeyVaultCredentials. { KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, "RSA", null); + validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, "RSA", null, null); } } @@ -92,13 +108,24 @@ public void importKeyOperation() throws Exception { } private void checkImportOperation(KeyBundle keyBundle, boolean importToHardware) throws Exception { + KeyAttributes attribute = (KeyAttributes) new KeyAttributes() + .withEnabled(true) + .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) + .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); + + Map tags = new HashMap(); + tags.put("foo", "baz"); + JsonWebKey importedJwk = keyBundle.key(); KeyBundle importResultBundle = keyVaultClient.importKey( - new ImportKeyRequest - .Builder(getVaultUri(), KEY_NAME, keyBundle.key()) - .withHsm(importToHardware) - .build()).getBody(); - validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? "RSA-HSM" : "RSA", importedJwk.keyOps()); + new ImportKeyRequest + .Builder(getVaultUri(), KEY_NAME, keyBundle.key()) + .withHsm(importToHardware) + .withAttributes(attribute) + .withTags(tags) + .build()).getBody(); + + validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? "RSA-HSM" : "RSA", importedJwk.keyOps(), attribute); checkEncryptDecryptSequence(importedJwk, importResultBundle); } @@ -151,7 +178,7 @@ public void crudOperations() throws Exception { { // Create key createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null, null); } // Key identifier. @@ -192,9 +219,9 @@ public void crudOperations() throws Exception { // First we create a bundle with the modified attributes. createdBundle.attributes().withExpires(new DateTime() - .withMonthOfYear(2) - .withDayOfMonth(1) - .withYear(2050)); + .withMonthOfYear(2) + .withDayOfMonth(1) + .withYear(2050)); List key_ops = Arrays.asList("encrypt", "decrypt"); Map tags = new HashMap(); tags.put("foo", "baz"); @@ -203,12 +230,12 @@ public void crudOperations() throws Exception { // Perform the operation. KeyBundle updatedBundle = keyVaultClient.updateKey( - new UpdateKeyRequest - .Builder(createdBundle.key().kid()) - .withKeyOperations(key_ops) - .withAttributes(createdBundle.attributes()) - .withTags(createdBundle.tags()) - .build()).getBody(); + new UpdateKeyRequest + .Builder(createdBundle.key().kid()) + .withKeyOperations(key_ops) + .withAttributes(createdBundle.attributes()) + .withTags(createdBundle.tags()) + .build()).getBody(); compareKeyBundles(createdBundle, updatedBundle); @@ -220,24 +247,24 @@ public void crudOperations() throws Exception { // Update key using vault and key name. // First we create a bundle with the modified attributes. - createdBundle.attributes().withNotBefore(new DateTime() - .withMonthOfYear(2) - .withDayOfMonth(1) - .withYear(2000)); + createdBundle.attributes().withNotBefore(new DateTime() + .withMonthOfYear(2) + .withDayOfMonth(1) + .withYear(2000)); List key_ops = Arrays.asList("sign", "verify"); createdBundle.key().withKeyOps(key_ops); Map tags = new HashMap(); tags.put("foo", "baz"); createdBundle.withTags(tags); - // Perform the operation. + // Perform the operation. KeyBundle updatedBundle = keyVaultClient.updateKey( - new UpdateKeyRequest - .Builder(getVaultUri(), KEY_NAME) - .withKeyOperations(key_ops) - .withAttributes(createdBundle.attributes()) - .withTags(createdBundle.tags()) - .build()).getBody(); + new UpdateKeyRequest + .Builder(getVaultUri(), KEY_NAME) + .withKeyOperations(key_ops) + .withAttributes(createdBundle.attributes()) + .withTags(createdBundle.tags()) + .build()).getBody(); compareKeyBundles(createdBundle, updatedBundle); } @@ -251,7 +278,7 @@ public void crudOperations() throws Exception { { // Expects a key not found try { - keyVaultClient.getKey(keyId.baseIdentifier()); + keyVaultClient.getKey(keyId.baseIdentifier()); } catch (KeyVaultErrorException e) { Assert.assertNotNull(e.getBody().error()); Assert.assertEquals("KeyNotFound", e.getBody().error().code()); @@ -268,9 +295,9 @@ public void backupRestore() throws Exception { // Creates a key { createdBundle = keyVaultClient.createKey( - new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA") - .build()).getBody(); - validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null); + new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA") + .build()).getBody(); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null, null); } // Creates a backup of key. @@ -316,7 +343,7 @@ public void listKeys() throws Exception { } } - PagedList listResult = keyVaultClient.getKeys(getVaultUri(), PAGELIST_MAX_KEYS).getBody(); + PagedList listResult = keyVaultClient.listKeys(getVaultUri(), PAGELIST_MAX_KEYS).getBody(); Assert.assertTrue(PAGELIST_MAX_KEYS >= listResult.currentPage().getItems().size()); HashSet toDelete = new HashSet(); @@ -330,14 +357,14 @@ public void listKeys() throws Exception { Assert.assertEquals(0, keys.size()); for (String name : toDelete) { - try{ - keyVaultClient.deleteKey(getVaultUri(), name); - } - catch(KeyVaultErrorException e){ - // Ignore forbidden exception for certificate keys that cannot be deleted - if(!e.getBody().error().code().equals("Forbidden")) - throw e; - } + try{ + keyVaultClient.deleteKey(getVaultUri(), name); + } + catch(KeyVaultErrorException e){ + // Ignore forbidden exception for certificate keys that cannot be deleted + if(!e.getBody().error().code().equals("Forbidden")) + throw e; + } } } @@ -364,20 +391,13 @@ public void listKeyVersions() throws Exception { } } - PagedList listResult = keyVaultClient.getKeyVersions(getVaultUri(), KEY_NAME, MAX_KEYS).getBody(); + PagedList listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME, MAX_KEYS).getBody(); //TODO bug: Assert.assertTrue(PAGELIST_MAX_KEYS >= listResult.currentPage().getItems().size()); - listResult = keyVaultClient.getKeyVersions(getVaultUri(), KEY_NAME).getBody(); + listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME).getBody(); - for (;;) { - for (KeyItem item : listResult) { - keys.remove(item.kid()); - } - String nextLink = listResult.nextPageLink(); - if (nextLink == null) { - break; - } - keyVaultClient.getKeyVersionsNext(nextLink).getBody(); + for (KeyItem item : listResult) { + keys.remove(item.kid()); } Assert.assertEquals(0, keys.size()); @@ -400,7 +420,7 @@ public void encryptDecryptOperations() throws Exception { // encrypt and decrypt using kid WO version { - result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); @@ -409,7 +429,7 @@ public void encryptDecryptOperations() throws Exception { // encrypt and decrypt using full kid { - result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); @@ -432,7 +452,7 @@ public void wrapUnwrapOperations() throws Exception { // wrap and unwrap using kid WO version { - result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); @@ -441,7 +461,7 @@ public void wrapUnwrapOperations() throws Exception { // wrap and unwrap using full kid { - result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); cipherText = result.result(); result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); @@ -468,7 +488,7 @@ public void signVerifyOperations() throws Exception { // Using kid WO version { - result = keyVaultClient.sign(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest).getBody(); + result = keyVaultClient.sign(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest).getBody(); signature = result.result(); verifyResult = keyVaultClient.verify(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest, signature).getBody(); @@ -495,18 +515,18 @@ private static JsonWebKey importTestKey() throws Exception { key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT, JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY, JsonWebKeyOperation.WRAP, JsonWebKeyOperation.UNWRAP)); keyBundle = keyVaultClient.importKey( - new ImportKeyRequest - .Builder(getVaultUri(), KEY_NAME, key) - .withHsm(false) - .build()).getBody(); + new ImportKeyRequest + .Builder(getVaultUri(), KEY_NAME, key) + .withHsm(false) + .build()).getBody(); - validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, "RSA", null); + validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, "RSA", null, null); return keyBundle.key(); } private static KeyPair getTestKeyMaterial() throws Exception { - return getWellKnownKey(); + return getWellKnownKey(); } private static KeyPair getWellKnownKey() throws Exception { @@ -526,7 +546,7 @@ private static KeyPair getWellKnownKey() throws Exception { return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); } - private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops) throws Exception { + private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops, KeyAttributes attributes) throws Exception { String prefix = vault + "/keys/" + keyName + "/"; String kid = bundle.key().kid(); Assert.assertTrue( @@ -540,16 +560,18 @@ private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String } Assert.assertNotNull("\"created\" should not be null.", bundle.attributes().created()); Assert.assertNotNull("\"updated\" should not be null.", bundle.attributes().updated()); + + compareAttributes(attributes, bundle.attributes()); } private void compareKeyBundles(KeyBundle expected, KeyBundle actual) { - Assert.assertTrue(expected.key().toString().equals(actual.key().toString())); - Assert.assertEquals(expected.attributes().enabled(), actual.attributes().enabled()); - Assert.assertEquals(expected.attributes().expires(), actual.attributes().expires()); - Assert.assertEquals(expected.attributes().notBefore(), actual.attributes().notBefore()); - if(expected.tags() != null || actual.tags() != null) - Assert.assertTrue(expected.tags().equals(actual.tags())); - } + Assert.assertTrue(expected.key().toString().equals(actual.key().toString())); + Assert.assertEquals(expected.attributes().enabled(), actual.attributes().enabled()); + Assert.assertEquals(expected.attributes().expires(), actual.attributes().expires()); + Assert.assertEquals(expected.attributes().notBefore(), actual.attributes().notBefore()); + if(expected.tags() != null || actual.tags() != null) + Assert.assertTrue(expected.tags().equals(actual.tags())); + } } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java index be6906865cd25..2ebb0c791a977 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java @@ -25,6 +25,7 @@ import org.junit.After; import org.junit.AfterClass; +import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; @@ -37,6 +38,7 @@ import com.microsoft.aad.adal4j.ClientCredential; import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.authentication.KeyVaultCredentials; +import com.microsoft.azure.keyvault.models.Attributes; public class KeyVaultClientIntegrationTestBase { @@ -95,7 +97,7 @@ public String doAuthenticate(String authorization, String resource, String scope private static AuthenticationResult getAccessToken(String authorization, String resource) throws Exception { String clientId = System.getenv("arm.clientid"); - + if (clientId == null) { throw new Exception("Please inform arm.clientid in the environment settings."); } @@ -136,6 +138,14 @@ private static AuthenticationResult getAccessToken(String authorization, String return result; } + protected static void compareAttributes(Attributes expectedAttributes, Attributes actualAttribute) { + if(expectedAttributes != null) { + Assert.assertEquals(expectedAttributes.enabled(), actualAttribute.enabled()); + Assert.assertEquals(expectedAttributes.expires(), actualAttribute.expires()); + Assert.assertEquals(expectedAttributes.notBefore(), actualAttribute.notBefore()); + } + } + protected static ObjectWriter jsonWriter; protected static ObjectReader jsonReader; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index aac73d56cf5c1..7378e9ebc9bee 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -26,6 +26,7 @@ import org.junit.Test; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; +import com.microsoft.azure.keyvault.models.SecretAttributes; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.PagedList; import com.microsoft.azure.keyvault.SecretIdentifier; @@ -45,17 +46,30 @@ public void transparentAuthentication() throws Exception { // Create a secret on a vault. { - SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); - validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, null); + SecretAttributes attributes = (SecretAttributes) new SecretAttributes() + .withEnabled(true) + .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) + .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); + Map tags = new HashMap(); + tags.put("foo", "baz"); + String contentType = "contentType"; + + SecretBundle secret = keyVaultClient.setSecret( + new SetSecretRequest + .Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE) + .withAttributes(attributes) + .withContentType(contentType) + .withTags(tags) + .build()).getBody(); + validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, contentType, attributes); } // Create a secret on a different vault. Secret Vault Data Plane returns // 401, which must be transparently handled by KeyVaultCredentials. { - SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); - validateSecret(secret, getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE, null); + SecretBundle secret = keyVaultClient.setSecret( + new SetSecretRequest.Builder(getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + validateSecret(secret, getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE, null, null); } } @@ -63,12 +77,12 @@ public void transparentAuthentication() throws Exception { @Test public void crudOperations() throws Exception { - SecretBundle secret; + SecretBundle secret; { // Create secret - secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); - validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, null); + secret = keyVaultClient.setSecret( + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, null, null); } // Secret identifier. @@ -76,47 +90,47 @@ public void crudOperations() throws Exception { { // Get secret using kid WO version - SecretBundle readBundle = keyVaultClient.getSecret(secretId.baseIdentifier()).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(secretId.baseIdentifier()).getBody(); compareSecrets(secret, readBundle); } { // Get secret using full kid as defined in the bundle - SecretBundle readBundle = keyVaultClient.getSecret(secret.id()).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(secret.id()).getBody(); compareSecrets(secret, readBundle); } { // Get secret using vault and secret name. - SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME).getBody(); compareSecrets(secret, readBundle); } { // Get secret using vault, secret name and version. - SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME, secretId.version()).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME, secretId.version()).getBody(); compareSecrets(secret, readBundle); } { - secret.attributes().withExpires(new DateTime() - .withMonthOfYear(2) - .withDayOfMonth(1) - .withYear(2050)); - Map tags = new HashMap(); - tags.put("foo", "baz"); - secret.withTags(tags) - .withContentType("application/html") - .withValue(null); // The value doesn't get updated - + secret.attributes().withExpires(new DateTime() + .withMonthOfYear(2) + .withDayOfMonth(1) + .withYear(2050)); + Map tags = new HashMap(); + tags.put("foo", "baz"); + secret.withTags(tags) + .withContentType("application/html") + .withValue(null); // The value doesn't get updated + // Update secret using the kid as defined in the bundle SecretBundle updatedSecret = keyVaultClient.updateSecret( - new UpdateSecretRequest - .Builder(secret.id()) - .withContentType(secret.contentType()) - .withAttributes(secret.attributes()) - .withTags(secret.tags()) - .build()).getBody(); + new UpdateSecretRequest + .Builder(secret.id()) + .withContentType(secret.contentType()) + .withAttributes(secret.attributes()) + .withTags(secret.tags()) + .build()).getBody(); compareSecrets(secret, updatedSecret); // Subsequent operations must use the updated bundle for comparison. @@ -126,37 +140,42 @@ public void crudOperations() throws Exception { { // Update secret using vault and secret name. - secret.attributes().withNotBefore(new DateTime() - .withMonthOfYear(2) - .withDayOfMonth(1) - .withYear(2000)); - Map tags = new HashMap(); - tags.put("rex", "woof"); - secret.withTags(tags) - .withContentType("application/html"); + secret.attributes().withNotBefore(new DateTime() + .withMonthOfYear(2) + .withDayOfMonth(1) + .withYear(2000)); + Map tags = new HashMap(); + tags.put("rex", "woof"); + secret.withTags(tags) + .withContentType("application/html"); // Perform the operation. SecretBundle updatedSecret = keyVaultClient.updateSecret( - new UpdateSecretRequest - .Builder(getVaultUri(), SECRET_NAME) - .withContentType(secret.contentType()) - .withAttributes(secret.attributes()) - .withTags(secret.tags()) - .build()).getBody(); + new UpdateSecretRequest + .Builder(getVaultUri(), SECRET_NAME) + .withVersion(secret.secretIdentifier().version()) + .withContentType(secret.contentType()) + .withAttributes(secret.attributes()) + .withTags(secret.tags()) + .build()).getBody(); compareSecrets(secret, updatedSecret); + validateSecret(updatedSecret, + secret.secretIdentifier().vault(), + secret.secretIdentifier().name(), + null, secret.contentType(), secret.attributes()); } { // Delete secret - SecretBundle deleteBundle = keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME).getBody(); + SecretBundle deleteBundle = keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME).getBody(); compareSecrets(secret, deleteBundle); } { // Expects a secret not found try { - keyVaultClient.getSecret(secretId.baseIdentifier()); + keyVaultClient.getSecret(secretId.baseIdentifier()); } catch (KeyVaultErrorException e) { Assert.assertNotNull(e.getBody().error().code()); Assert.assertEquals("SecretNotFound", e.getBody().error().code()); @@ -165,7 +184,7 @@ public void crudOperations() throws Exception { } - @Test + @Test public void listSecrets() throws Exception { HashSet secrets = new HashSet(); @@ -174,7 +193,7 @@ public void listSecrets() throws Exception { for (;;) { try { SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME + i, SECRET_VALUE).build()).getBody(); + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME + i, SECRET_VALUE).build()).getBody(); SecretIdentifier id = new SecretIdentifier(secret.id()); secrets.add(id.baseIdentifier()); break; @@ -190,7 +209,7 @@ public void listSecrets() throws Exception { } } - PagedList listResult = keyVaultClient.getSecrets(getVaultUri(), PAGELIST_MAX_SECRETS).getBody(); + PagedList listResult = keyVaultClient.listSecrets(getVaultUri(), PAGELIST_MAX_SECRETS).getBody(); Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().getItems().size()); HashSet toDelete = new HashSet(); @@ -204,14 +223,14 @@ public void listSecrets() throws Exception { Assert.assertEquals(0, secrets.size()); for (String secretName : toDelete) { - try{ - keyVaultClient.deleteSecret(getVaultUri(), secretName); - } - catch(KeyVaultErrorException e){ - // Ignore forbidden exception for certificate secrets that cannot be deleted - if(!e.getBody().error().code().equals("Forbidden")) - throw e; - } + try{ + keyVaultClient.deleteSecret(getVaultUri(), secretName); + } + catch(KeyVaultErrorException e){ + // Ignore forbidden exception for certificate secrets that cannot be deleted + if(!e.getBody().error().code().equals("Forbidden")) + throw e; + } } } @@ -224,7 +243,7 @@ public void listSecretVersions() throws Exception { for (;;) { try { SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); secrets.add(secret.id()); break; } catch (KeyVaultErrorException e) { @@ -239,19 +258,12 @@ public void listSecretVersions() throws Exception { } } - PagedList listResult = keyVaultClient.getSecretVersions(getVaultUri(), SECRET_NAME, PAGELIST_MAX_SECRETS).getBody(); + PagedList listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME, PAGELIST_MAX_SECRETS).getBody(); Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().getItems().size()); - listResult = keyVaultClient.getSecretVersions(getVaultUri(), SECRET_NAME).getBody(); - for (;;) { - for (SecretItem item : listResult) { - secrets.remove(item.id()); - } - String nextLink = listResult.nextPageLink(); - if (nextLink == null) { - break; - } - keyVaultClient.getSecretVersionsNext(nextLink).getBody(); + listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME).getBody(); + for (SecretItem item : listResult) { + secrets.remove(item.id()); } Assert.assertEquals(0, secrets.size()); @@ -259,7 +271,7 @@ public void listSecretVersions() throws Exception { keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME); } - private static void validateSecret(SecretBundle secret, String vault, String name, String value, String contentType) throws Exception { + private static void validateSecret(SecretBundle secret, String vault, String name, String value, String contentType, SecretAttributes attributes) throws Exception { String prefix = vault + "/secrets/" + name + "/"; String id = secret.id(); Assert.assertTrue( // @@ -271,17 +283,19 @@ private static void validateSecret(SecretBundle secret, String vault, String nam } Assert.assertNotNull("\"created\" should not be null.", secret.attributes().created()); Assert.assertNotNull("\"updated\" should not be null.", secret.attributes().updated()); + + compareAttributes(attributes, secret.attributes()); } private void compareSecrets(SecretBundle expected, SecretBundle actual) { - Assert.assertEquals(expected.contentType(), actual.contentType()); - Assert.assertEquals(expected.id(), actual.id()); - Assert.assertEquals(expected.value(), actual.value()); - Assert.assertEquals(expected.attributes().enabled(), actual.attributes().enabled()); - Assert.assertEquals(expected.attributes().expires(), actual.attributes().expires()); - Assert.assertEquals(expected.attributes().notBefore(), actual.attributes().notBefore()); - if(expected.tags() != null || actual.tags() != null) - Assert.assertTrue(expected.tags().equals(actual.tags())); - } + Assert.assertEquals(expected.contentType(), actual.contentType()); + Assert.assertEquals(expected.id(), actual.id()); + Assert.assertEquals(expected.value(), actual.value()); + Assert.assertEquals(expected.attributes().enabled(), actual.attributes().enabled()); + Assert.assertEquals(expected.attributes().expires(), actual.attributes().expires()); + Assert.assertEquals(expected.attributes().notBefore(), actual.attributes().notBefore()); + if(expected.tags() != null || actual.tags() != null) + Assert.assertTrue(expected.tags().equals(actual.tags())); + } } From 1a40bdbf1373d04bce4c3e82c8c054a052c4f422 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Mon, 15 Aug 2016 16:35:42 -0700 Subject: [PATCH 22/56] Java Cryptography Test Case update --- .../azure/keyvault/cryptography/RsaKey.java | 19 + .../test/AesCbcBCProviderTest.java | 120 +---- .../test/AesCbcHmacShaBCProviderTest.java | 17 + .../cryptography/test/AesCbcHmacShaTest.java | 59 +-- ...faultProviderTest.java => AesCbcTest.java} | 61 +-- .../test/AesKwBCProviderTest.java | 261 +---------- ...efaultProviderTest.java => AesKwTest.java} | 135 ++---- .../test/RsaKeyBCProviderTest.java | 16 + .../cryptography/test/RsaKeyTest.java | 30 +- .../test/SymmetricKeyBCProviderTest.java | 326 +------------- .../test/SymmetricKeyBaseTest.java | 423 ++++++++++++++++++ .../test/SymmetricKeyDefaultProviderTest.java | 399 +---------------- 12 files changed, 576 insertions(+), 1290 deletions(-) create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaBCProviderTest.java rename azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/{AesCbcDefaultProviderTest.java => AesCbcTest.java} (61%) rename azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/{AesKwDefaultProviderTest.java => AesKwTest.java} (60%) create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyBCProviderTest.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java index d8fe513c31c7b..b56511a99205d 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java @@ -22,6 +22,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; +import java.security.Provider; import java.security.interfaces.RSAPublicKey; import org.apache.commons.lang3.NotImplementedException; @@ -52,6 +53,8 @@ public RsaKey(String kid) throws NoSuchAlgorithmException { public RsaKey(String kid, int keySize) throws NoSuchAlgorithmException { + this(kid, keySize, null); + /* if (Strings.isNullOrWhiteSpace(kid)) { throw new IllegalArgumentException("kid"); } @@ -62,6 +65,22 @@ public RsaKey(String kid, int keySize) throws NoSuchAlgorithmException { _keyPair = generator.generateKeyPair(); _kid = kid; + */ + } + + public RsaKey(String kid, int keySize, Provider provider) throws NoSuchAlgorithmException { + + if (Strings.isNullOrWhiteSpace(kid)) { + throw new IllegalArgumentException("kid"); + } + + final KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", provider); + + generator.initialize(keySize); + + _keyPair = generator.generateKeyPair(); + _kid = kid; + } public RsaKey(String kid, KeyPair keyPair) { diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java index c7d9c96b36702..043b2b54808be 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcBCProviderTest.java @@ -1,132 +1,18 @@ package com.microsoft.azure.keyvault.cryptography.test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.fail; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; import java.security.Provider; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; - -import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; -import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; - -public class AesCbcBCProviderTest { - private Provider _provider = null; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } +public class AesCbcBCProviderTest extends AesCbcTest { @Before public void setUp() throws Exception { try { - _provider = (Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance(); - } catch (ClassNotFoundException ex) { - throw new RuntimeException(ex.getMessage()); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex.getMessage()); - } catch (InstantiationException ex) { + super.setProvider((Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance()); + } catch (Exception ex) { throw new RuntimeException(ex.getMessage()); } } - @After - public void tearDown() throws Exception { - } - - @Test - public void testAes128Cbc() { - // Arrange: These values are taken from Appendix B of the JWE - // specification at - // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B - // Since the values were intended for use with AES128-CBC-HMAC-SHA2 we - // actually take the realCEK from the second half of the CEK data below - // in order - // that the encrypted result will match the ED value from the example. - byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; - byte[] PLAIN = { 76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, 112, 114, 111, 115, 112, 101, 114, 46 }; - byte[] IV = { 3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101 }; - //byte[] AUTH = { 101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52, 83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66, 77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73, 110, 48 }; - byte[] ED = { 40, 57, 83, (byte) 181, 119, 33, (byte) 133, (byte) 148, (byte) 198, (byte) 185, (byte) 243, 24, (byte) 152, (byte) 230, 6, 75, (byte) 129, (byte) 223, 127, 19, (byte) 210, 82, (byte) 183, (byte) 230, (byte) 168, 33, (byte) 215, 104, (byte) 143, 112, 56, 102 }; - //byte[] TAG = { 83, 73, (byte) 191, 98, 104, (byte) 205, (byte) 211, (byte) 128, (byte) 201, (byte) 189, (byte) 199, (byte) 133, 32, 38, (byte) 194, 85 }; - - Aes128Cbc algo = new Aes128Cbc(); - byte[] realCEK = new byte[128 >> 3]; - byte[] encrypted = null; - - // Take the second half of CEK as the AES key - System.arraycopy(CEK, 128 >> 3, realCEK, 0, 128 >> 3); - - ICryptoTransform encryptor = null; - try { - encryptor = algo.CreateEncryptor(realCEK, IV, null, _provider); - } catch (InvalidKeyException e1) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e1) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e1) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e1) { - fail("InvalidAlgorithmParameterException"); - } - - try { - encrypted = encryptor.doFinal(PLAIN); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - ICryptoTransform decryptor = null; - try { - decryptor = algo.CreateDecryptor(realCEK, IV, null, _provider); - } catch (InvalidKeyException e1) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e1) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e1) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e1) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] decrypted = null; - - try { - decrypted = decryptor.doFinal(encrypted); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(PLAIN, decrypted); - assertArrayEquals(ED, encrypted); - } } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaBCProviderTest.java new file mode 100644 index 0000000000000..5c7e07a273474 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaBCProviderTest.java @@ -0,0 +1,17 @@ +package com.microsoft.azure.keyvault.cryptography.test; + +import java.security.Provider; + +import org.junit.Before; + +public class AesCbcHmacShaBCProviderTest extends AesCbcHmacShaTest { + + @Before + public void setUp() throws Exception { + try { + super.setProvider((Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance()); + } catch (Exception ex) { + throw new RuntimeException(ex.getMessage()); + } + } +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java index 211f3116bd0bc..4783152229b1d 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java @@ -3,13 +3,7 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.fail; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; +import java.security.Provider; import org.junit.After; import org.junit.AfterClass; @@ -22,6 +16,8 @@ import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128CbcHmacSha256; public class AesCbcHmacShaTest { + + private Provider _provider = null; @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -33,11 +29,16 @@ public static void tearDownAfterClass() throws Exception { @Before public void setUp() throws Exception { + setProvider(null); } @After public void tearDown() throws Exception { } + + protected void setProvider(Provider provider) { + _provider = null; + } @Test public void testAes128CbcHmacSha256() { @@ -59,15 +60,9 @@ public void testAes128CbcHmacSha256() { byte[] tag = null; try { - transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(CEK, IV, AUTH); - } catch (InvalidKeyException e1) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e1) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e1) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e1) { - fail("InvalidAlgorithmParameterException"); + transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(CEK, IV, AUTH, _provider); + } catch (Exception e) { + fail(e.getMessage()); } try { @@ -77,41 +72,23 @@ public void testAes128CbcHmacSha256() { assertArrayEquals(ED, encrypted); assertArrayEquals(TAG, tag); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } ICryptoTransform decryptor = null; try { - decryptor = algo.CreateDecryptor(CEK, IV, AUTH); - } catch (InvalidKeyException e1) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e1) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e1) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e1) { - fail("InvalidAlgorithmParameterException"); + decryptor = algo.CreateDecryptor(CEK, IV, AUTH, _provider); + } catch (Exception e) { + fail(e.getMessage()); } byte[] decrypted = null; try { decrypted = decryptor.doFinal(encrypted); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java similarity index 61% rename from azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java rename to azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java index 947ef7cddfc74..53286b5471690 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcDefaultProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java @@ -3,13 +3,7 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.fail; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; +import java.security.Provider; import org.junit.After; import org.junit.AfterClass; @@ -20,8 +14,10 @@ import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; -public class AesCbcDefaultProviderTest { +public class AesCbcTest { + private Provider _provider = null; + @BeforeClass public static void setUpBeforeClass() throws Exception { } @@ -32,11 +28,16 @@ public static void tearDownAfterClass() throws Exception { @Before public void setUp() throws Exception { + setProvider(null); } @After public void tearDown() throws Exception { } + + protected void setProvider(Provider provider) { + _provider = provider; + } @Test public void testAes128Cbc() { @@ -63,54 +64,30 @@ public void testAes128Cbc() { ICryptoTransform encryptor = null; try { - encryptor = algo.CreateEncryptor(realCEK, IV, null); - } catch (InvalidKeyException e1) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e1) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e1) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e1) { - fail("InvalidAlgorithmParameterException"); + encryptor = algo.CreateEncryptor(realCEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); } try { encrypted = encryptor.doFinal(PLAIN); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } ICryptoTransform decryptor = null; try { - decryptor = algo.CreateDecryptor(realCEK, IV, null); - } catch (InvalidKeyException e1) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e1) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e1) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e1) { - fail("InvalidAlgorithmParameterException"); + decryptor = algo.CreateDecryptor(realCEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); } byte[] decrypted = null; try { decrypted = decryptor.doFinal(encrypted); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java index e1e7ce50c53f7..480db6f2e8966 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwBCProviderTest.java @@ -18,272 +18,17 @@ package com.microsoft.azure.keyvault.cryptography.test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.fail; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; import java.security.Provider; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; - -import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; -import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw; -import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw128; -import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw192; -import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256; - -public class AesKwBCProviderTest { - - private Provider _provider = null; - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } +public class AesKwBCProviderTest extends AesKwTest { @Before public void setUp() throws Exception { try { - _provider = (Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance(); - } catch (ClassNotFoundException ex) { - throw new RuntimeException(ex.getMessage()); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex.getMessage()); - } catch (InstantiationException ex) { + super.setProvider((Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance()); + } catch (Exception ex) { throw new RuntimeException(ex.getMessage()); } } - - @After - public void tearDown() throws Exception { - } - - @Test - public void KeyVault_AesKw128() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; - - AesKw kw = new AesKw128(); - - ICryptoTransform encryptor = null; - - try { - encryptor = kw.CreateEncryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] encrypted = null; - - try { - encrypted = encryptor.doFinal(CEK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - ICryptoTransform decryptor = null; - - try { - decryptor = kw.CreateDecryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] decrypted = null; - - try { - decrypted = decryptor.doFinal(EK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - - @Test - public void KeyVault_AesKw192() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; - - AesKw kw = new AesKw192(); - - ICryptoTransform encryptor = null; - - try { - encryptor = kw.CreateEncryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] encrypted = null; - - try { - encrypted = encryptor.doFinal(CEK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - ICryptoTransform decryptor = null; - - try { - decryptor = kw.CreateDecryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] decrypted = null; - - try { - decrypted = decryptor.doFinal(EK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - - @Test - public void KeyVault_AesKw256() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; - - AesKw kw = new AesKw256(); - - ICryptoTransform encryptor = null; - - try { - encryptor = kw.CreateEncryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] encrypted = null; - - try { - encrypted = encryptor.doFinal(CEK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - ICryptoTransform decryptor = null; - - try { - decryptor = kw.CreateDecryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); - } - - byte[] decrypted = null; - - try { - decrypted = decryptor.doFinal(EK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java similarity index 60% rename from azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java rename to azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java index a9b4495e9313a..d22e2107ce6ef 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwDefaultProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java @@ -21,15 +21,10 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.fail; -import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Provider; -import javax.crypto.BadPaddingException; import javax.crypto.Cipher; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; - import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -42,7 +37,10 @@ import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw192; import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256; -public class AesKwDefaultProviderTest { +public class AesKwTest { + + // Always null for the default provider + private Provider _provider = null; private static boolean hasUnlimitedCrypto() { try { @@ -68,8 +66,9 @@ public void setUp() throws Exception { public void tearDown() throws Exception { } - // Always null for the default provider - private Provider _provider = null; + protected void setProvider(Provider provider) { + _provider = provider; + } @Test public void KeyVault_AesKw128() { @@ -84,28 +83,16 @@ public void KeyVault_AesKw128() { try { encryptor = kw.CreateEncryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); + } catch (Exception e) { + fail(e.getMessage()); } byte[] encrypted = null; try { encrypted = encryptor.doFinal(CEK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert @@ -115,28 +102,16 @@ public void KeyVault_AesKw128() { try { decryptor = kw.CreateDecryptor(KEK, _provider); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); + } catch (Exception e) { + fail(e.getMessage()); } byte[] decrypted = null; try { decrypted = decryptor.doFinal(EK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert @@ -161,17 +136,13 @@ public void KeyVault_AesKw192() { ICryptoTransform encryptor = null; try { - encryptor = kw.CreateEncryptor(KEK); + encryptor = kw.CreateEncryptor(KEK, _provider); if (!unlimited) fail("Expected InvalidKeyException"); } catch (InvalidKeyException e) { if (unlimited) fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); + } catch (Exception e) { + fail(e.getMessage()); } if (unlimited) { @@ -179,14 +150,8 @@ public void KeyVault_AesKw192() { try { encrypted = encryptor.doFinal(CEK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert @@ -196,16 +161,12 @@ public void KeyVault_AesKw192() { ICryptoTransform decryptor = null; try { - decryptor = kw.CreateDecryptor(KEK); + decryptor = kw.CreateDecryptor(KEK, _provider); if (!unlimited) fail("Expected InvalidKeyException"); } catch (InvalidKeyException e) { if (unlimited) fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); + } catch (Exception e) { + fail(e.getMessage()); } if (unlimited) { @@ -213,14 +174,8 @@ public void KeyVault_AesKw192() { try { decrypted = decryptor.doFinal(EK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert @@ -246,16 +201,12 @@ public void KeyVault_AesKw256() { ICryptoTransform encryptor = null; try { - encryptor = kw.CreateEncryptor(KEK); + encryptor = kw.CreateEncryptor(KEK, _provider); if (!unlimited) fail("Expected InvalidKeyException"); } catch (InvalidKeyException e) { if (unlimited) fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); + } catch (Exception e) { + fail(e.getMessage()); } if (unlimited) { @@ -263,14 +214,8 @@ public void KeyVault_AesKw256() { try { encrypted = encryptor.doFinal(CEK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert @@ -280,17 +225,13 @@ public void KeyVault_AesKw256() { ICryptoTransform decryptor = null; try { - decryptor = kw.CreateDecryptor(KEK); + decryptor = kw.CreateDecryptor(KEK, _provider); if (!unlimited) fail("Expected InvalidKeyException"); } catch (InvalidKeyException e) { if (unlimited) fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } catch (NoSuchPaddingException e) { - fail("NoSuchPaddingException"); - } catch (InvalidAlgorithmParameterException e) { - fail("InvalidAlgorithmParameterException"); + } catch (Exception e) { + fail(e.getMessage()); } if (unlimited) { @@ -298,14 +239,8 @@ public void KeyVault_AesKw256() { try { decrypted = decryptor.doFinal(EK); - } catch (IllegalBlockSizeException e) { - fail("IllegalBlockSizeException"); - } catch (BadPaddingException e) { - fail("BadPaddingException"); - } catch (InvalidKeyException e) { - fail("InvalidKeyException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); + } catch (Exception e) { + fail(e.getMessage()); } // Assert diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyBCProviderTest.java new file mode 100644 index 0000000000000..c9a9c70acaeb3 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyBCProviderTest.java @@ -0,0 +1,16 @@ +package com.microsoft.azure.keyvault.cryptography.test; + +import java.security.Provider; +import org.junit.Before; + +public class RsaKeyBCProviderTest extends RsaKeyTest { + + @Before + public void setUp() throws Exception { + try { + super.setProvider((Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance()); + } catch (Exception ex) { + throw new RuntimeException(ex.getMessage()); + } + } +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java index e41ceaa460ab6..0d9fafb68ebbf 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -5,7 +5,7 @@ import java.math.BigInteger; import java.security.KeyFactory; import java.security.KeyPair; -import java.security.KeyPairGenerator; +import java.security.Provider; import java.security.spec.KeySpec; import java.security.spec.RSAPrivateCrtKeySpec; import java.security.spec.RSAPublicKeySpec; @@ -24,6 +24,8 @@ import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; public class RsaKeyTest { + + private Provider _provider = null; @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -40,6 +42,10 @@ public void setUp() throws Exception { @After public void tearDown() throws Exception { } + + protected void setProvider(Provider provider) { + _provider = provider; + } @Test public void testEncryptDecryptRsa15() throws Exception { @@ -179,24 +185,24 @@ public void testWrapUnwrapDefaultAlgorithm() throws Exception { assertArrayEquals(plaintext, decrypted); } - private static KeyPair getTestKeyMaterial() throws Exception { + private KeyPair getTestKeyMaterial() throws Exception { return getWellKnownKey(); } - private static KeyPair getWellKnownKey() throws Exception { - BigInteger modulus = new BigInteger("27266783713040163753473734334021230592631652450892850648620119914958066181400432364213298181846462385257448168605902438305568194683691563208578540343969522651422088760509452879461613852042845039552547834002168737350264189810815735922734447830725099163869215360401162450008673869707774119785881115044406101346450911054819448375712432746968301739007624952483347278954755460152795801894283389540036131881712321193750961817346255102052653789197325341350920441746054233522546543768770643593655942246891652634114922277138937273034902434321431672058220631825053788262810480543541597284376261438324665363067125951152574540779"); - BigInteger publicExponent = new BigInteger("65537"); + private KeyPair getWellKnownKey() throws Exception { + BigInteger modulus = new BigInteger("27266783713040163753473734334021230592631652450892850648620119914958066181400432364213298181846462385257448168605902438305568194683691563208578540343969522651422088760509452879461613852042845039552547834002168737350264189810815735922734447830725099163869215360401162450008673869707774119785881115044406101346450911054819448375712432746968301739007624952483347278954755460152795801894283389540036131881712321193750961817346255102052653789197325341350920441746054233522546543768770643593655942246891652634114922277138937273034902434321431672058220631825053788262810480543541597284376261438324665363067125951152574540779"); + BigInteger publicExponent = new BigInteger("65537"); BigInteger privateExponent = new BigInteger("10466613941269075477152428927796086150095892102279802916937552172064636326433780566497000814207416485739683286961848843255766652023400959086290344987308562817062506476465756840999981989957456897020361717197805192876094362315496459535960304928171129585813477132331538577519084006595335055487028872410579127692209642938724850603554885478763205394868103298473476811627231543504190652483290944218004086457805431824328448422034887148115990501701345535825110962804471270499590234116100216841170344686381902328362376624405803648588830575558058257742073963036264273582756620469659464278207233345784355220317478103481872995809"); - BigInteger primeP = new BigInteger("175002941104568842715096339107566771592009112128184231961529953978142750732317724951747797764638217287618769007295505214923187971350518217670604044004381362495186864051394404165602744235299100790551775147322153206730562450301874236875459336154569893255570576967036237661594595803204808064127845257496057219227"); - BigInteger primeQ = new BigInteger("155807574095269324897144428622185380283967159190626345335083690114147315509962698765044950001909553861571493035240542031420213144237033208612132704562174772894369053916729901982420535940939821673277140180113593951522522222348910536202664252481405241042414183668723338300649954708432681241621374644926879028977"); - BigInteger primeExponentP = new BigInteger("79745606804504995938838168837578376593737280079895233277372027184693457251170125851946171360348440134236338520742068873132216695552312068793428432338173016914968041076503997528137698610601222912385953171485249299873377130717231063522112968474603281996190849604705284061306758152904594168593526874435238915345"); - BigInteger primeExponentQ = new BigInteger("80619964983821018303966686284189517841976445905569830731617605558094658227540855971763115484608005874540349730961777634427740786642996065386667564038755340092176159839025706183161615488856833433976243963682074011475658804676349317075370362785860401437192843468423594688700132964854367053490737073471709030801"); - BigInteger crtCoefficient = new BigInteger("2157818511040667226980891229484210846757728661751992467240662009652654684725325675037512595031058612950802328971801913498711880111052682274056041470625863586779333188842602381844572406517251106159327934511268610438516820278066686225397795046020275055545005189953702783748235257613991379770525910232674719428"); + BigInteger primeP = new BigInteger("175002941104568842715096339107566771592009112128184231961529953978142750732317724951747797764638217287618769007295505214923187971350518217670604044004381362495186864051394404165602744235299100790551775147322153206730562450301874236875459336154569893255570576967036237661594595803204808064127845257496057219227"); + BigInteger primeQ = new BigInteger("155807574095269324897144428622185380283967159190626345335083690114147315509962698765044950001909553861571493035240542031420213144237033208612132704562174772894369053916729901982420535940939821673277140180113593951522522222348910536202664252481405241042414183668723338300649954708432681241621374644926879028977"); + BigInteger primeExponentP = new BigInteger("79745606804504995938838168837578376593737280079895233277372027184693457251170125851946171360348440134236338520742068873132216695552312068793428432338173016914968041076503997528137698610601222912385953171485249299873377130717231063522112968474603281996190849604705284061306758152904594168593526874435238915345"); + BigInteger primeExponentQ = new BigInteger("80619964983821018303966686284189517841976445905569830731617605558094658227540855971763115484608005874540349730961777634427740786642996065386667564038755340092176159839025706183161615488856833433976243963682074011475658804676349317075370362785860401437192843468423594688700132964854367053490737073471709030801"); + BigInteger crtCoefficient = new BigInteger("2157818511040667226980891229484210846757728661751992467240662009652654684725325675037512595031058612950802328971801913498711880111052682274056041470625863586779333188842602381844572406517251106159327934511268610438516820278066686225397795046020275055545005189953702783748235257613991379770525910232674719428"); - KeySpec publicKeySpec = new RSAPublicKeySpec(modulus, publicExponent); + KeySpec publicKeySpec = new RSAPublicKeySpec(modulus, publicExponent); KeySpec privateKeySpec = new RSAPrivateCrtKeySpec(modulus, publicExponent, privateExponent, primeP, primeQ, primeExponentP, primeExponentQ, crtCoefficient); - KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + KeyFactory keyFactory = _provider == null ? KeyFactory.getInstance("RSA") : KeyFactory.getInstance("RSA", _provider); return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java index ba86f68eeff90..a6a7936c9fa65 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java @@ -18,337 +18,17 @@ package com.microsoft.azure.keyvault.cryptography.test; -import static org.junit.Assert.*; - -import java.io.IOException; -import java.security.NoSuchAlgorithmException; import java.security.Provider; -import java.util.concurrent.ExecutionException; - -import org.apache.commons.lang3.tuple.Pair; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.microsoft.azure.keyvault.cryptography.SymmetricKey; - -public class SymmetricKeyBCProviderTest { - - private Provider _provider = null; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - @AfterClass - public static void tearDownAfterClass() throws Exception { - } +public class SymmetricKeyBCProviderTest extends SymmetricKeyBaseTest { @Before public void setUp() throws Exception { try { - _provider = (Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance(); - } catch (ClassNotFoundException ex) { - throw new RuntimeException(ex.getMessage()); - } catch (IllegalAccessException ex) { + super.setProvider((Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider").newInstance()); + } catch (Exception ex) { throw new RuntimeException(ex.getMessage()); - } catch (InstantiationException ex) { - throw new RuntimeException(ex.getMessage()); - } - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testSymmetricKeyAesKw128() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; - - SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); - - byte[] encrypted = null; - - try { - encrypted = key.wrapKeyAsync(CEK, "A128KW").get().getLeft(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, "A128KW").get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); } } - - @Test - public void testSymmetricKeyAesKw192() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; - - SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); - - byte[] encrypted = null; - - try { - encrypted = key.wrapKeyAsync(CEK, "A192KW").get().getLeft(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, "A192KW").get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyAesKw256() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; - - SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); - - byte[] encrypted = null; - - try { - encrypted = key.wrapKeyAsync(CEK, "A256KW").get().getLeft(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, "A256KW").get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyDefaultAlgorithmAesKw128() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; - - SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); - - byte[] encrypted = null; - String algorithm = null; - - try { - Pair result = key.wrapKeyAsync(CEK, null).get(); - encrypted = result.getLeft(); - algorithm = result.getRight(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertEquals("A128KW", algorithm); - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, algorithm).get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyDefaultAlgorithmAesKw192() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; - - SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); - - byte[] encrypted = null; - String algorithm = null; - - try { - Pair result = key.wrapKeyAsync(CEK, null).get(); - encrypted = result.getLeft(); - algorithm = result.getRight(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertEquals( "A192KW", algorithm); - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, algorithm).get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyDefaultAlgorithmAesKw256() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; - - SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); - - byte[] encrypted = null; - String algorithm = null; - - try { - Pair result = key.wrapKeyAsync(CEK, null).get(); - encrypted = result.getLeft(); - algorithm = result.getRight(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertEquals("A256KW", algorithm); - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, algorithm).get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java new file mode 100644 index 0000000000000..36b6bf464aa16 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java @@ -0,0 +1,423 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import static org.junit.Assert.*; + +import java.io.IOException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; +import java.util.concurrent.ExecutionException; + +import javax.crypto.Cipher; + +import org.apache.commons.lang3.tuple.Pair; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.microsoft.azure.keyvault.cryptography.SymmetricKey; + +public abstract class SymmetricKeyBaseTest { + + private Provider _provider = null; + + private static boolean hasUnlimitedCrypto() { + try { + return Cipher.getMaxAllowedKeyLength("RC5") >= 256; + } catch (NoSuchAlgorithmException e) { + return false; + } + } + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public abstract void setUp() throws Exception; + + @After + public void tearDown() throws Exception { + } + + protected void setProvider(Provider provider) { + _provider = provider; + } + + @Test + public void testSymmetricKeyAesKw128() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; + + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A128KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyAesKw192() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A192KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyAesKw256() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A256KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyDefaultAlgorithmAesKw128() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; + + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + String algorithm = null; + + try { + Pair result = key.wrapKeyAsync(CEK, null).get(); + encrypted = result.getLeft(); + algorithm = result.getRight(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertEquals("A128KW", algorithm); + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, algorithm).get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyDefaultAlgorithmAesKw192() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + String algorithm = null; + + try { + Pair result = key.wrapKeyAsync(CEK, null).get(); + + encrypted = result.getLeft(); + algorithm = result.getRight(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertEquals( "A192KW", algorithm); + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, algorithm).get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyDefaultAlgorithmAesKw256() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + String algorithm = null; + + try { + Pair result = key.wrapKeyAsync(CEK, null).get(); + encrypted = result.getLeft(); + algorithm = result.getRight(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertEquals("A256KW", algorithm); + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, algorithm).get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java index 9365b416988e3..384961ad2e643 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java @@ -18,407 +18,12 @@ package com.microsoft.azure.keyvault.cryptography.test; -import static org.junit.Assert.*; - -import java.io.IOException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.util.concurrent.ExecutionException; - -import javax.crypto.Cipher; - -import org.apache.commons.lang3.tuple.Pair; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.microsoft.azure.keyvault.cryptography.SymmetricKey; -public class SymmetricKeyDefaultProviderTest { - - private static boolean hasUnlimitedCrypto() { - try { - return Cipher.getMaxAllowedKeyLength("RC5") >= 256; - } catch (NoSuchAlgorithmException e) { - return false; - } - } - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } +public class SymmetricKeyDefaultProviderTest extends SymmetricKeyBaseTest { @Before public void setUp() throws Exception { + super.setProvider(null); } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testSymmetricKeyAesKw128() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; - - SymmetricKey key = new SymmetricKey("KEK", KEK); - - byte[] encrypted = null; - - try { - encrypted = key.wrapKeyAsync(CEK, "A128KW").get().getLeft(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, "A128KW").get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyAesKw192() { - - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; - - /* - * This test using the default JCE provider depends on whether unlimited security - * is installed or not. In the unlimited case, the full test should pass but in - * the limited case, it should fail with InvalidKeyException. - */ - boolean unlimited = hasUnlimitedCrypto(); - SymmetricKey key = new SymmetricKey("KEK", KEK); - - byte[] encrypted = null; - - try { - encrypted = key.wrapKeyAsync(CEK, "A192KW").get().getLeft(); - - if (!unlimited) fail("Expected ExecutionException"); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - - // In the limited case, the failure should be InvalidKeyException - // In the unlimited case, this should not fail - if (!unlimited) { - Throwable cause = e.getCause(); - if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); - } else { - fail("ExecutionException"); - } - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - if (unlimited) { - // Assert - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, "A192KW").get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyAesKw256() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; - - /* - * This test using the default JCE provider depends on whether unlimited security - * is installed or not. In the unlimited case, the full test should pass but in - * the limited case, it should fail with InvalidKeyException. - */ - boolean unlimited = hasUnlimitedCrypto(); - SymmetricKey key = new SymmetricKey("KEK", KEK); - - byte[] encrypted = null; - - try { - encrypted = key.wrapKeyAsync(CEK, "A256KW").get().getLeft(); - - if (!unlimited) fail("Expected ExecutionException"); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - // In the limited case, the failure should be InvalidKeyException - // In the unlimited case, this should not fail - if (!unlimited) { - Throwable cause = e.getCause(); - if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); - } else { - fail("ExecutionException"); - } - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - if (unlimited) { - // Assert - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, "A256KW").get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyDefaultAlgorithmAesKw128() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x1F, (byte) 0xA6, (byte) 0x8B, 0x0A, (byte) 0x81, 0x12, (byte) 0xB4, 0x47, (byte) 0xAE, (byte) 0xF3, 0x4B, (byte) 0xD8, (byte) 0xFB, 0x5A, 0x7B, (byte) 0x82, (byte) 0x9D, 0x3E, (byte) 0x86, 0x23, 0x71, (byte) 0xD2, (byte) 0xCF, (byte) 0xE5 }; - - SymmetricKey key = new SymmetricKey("KEK", KEK); - - byte[] encrypted = null; - String algorithm = null; - - try { - Pair result = key.wrapKeyAsync(CEK, null).get(); - encrypted = result.getLeft(); - algorithm = result.getRight(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertEquals("A128KW", algorithm); - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, algorithm).get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyDefaultAlgorithmAesKw192() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; - - /* - * This test using the default JCE provider depends on whether unlimited security - * is installed or not. In the unlimited case, the full test should pass but in - * the limited case, it should fail with InvalidKeyException. - */ - boolean unlimited = hasUnlimitedCrypto(); - SymmetricKey key = new SymmetricKey("KEK", KEK); - - byte[] encrypted = null; - String algorithm = null; - - try { - Pair result = key.wrapKeyAsync(CEK, null).get(); - - encrypted = result.getLeft(); - algorithm = result.getRight(); - - if (!unlimited) fail("Expected ExecutionException"); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - // In the limited case, the failure should be InvalidKeyException - // In the unlimited case, this should not fail - if (!unlimited) { - Throwable cause = e.getCause(); - if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); - } else { - fail("ExecutionException"); - } - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - if (unlimited) { - // Assert - assertEquals( "A192KW", algorithm); - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, algorithm).get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - - @Test - public void testSymmetricKeyDefaultAlgorithmAesKw256() { - // Arrange - byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; - byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; - byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; - - /* - * This test using the default JCE provider depends on whether unlimited security - * is installed or not. In the unlimited case, the full test should pass but in - * the limited case, it should fail with InvalidKeyException. - */ - boolean unlimited = hasUnlimitedCrypto(); - SymmetricKey key = new SymmetricKey("KEK", KEK); - - byte[] encrypted = null; - String algorithm = null; - - try { - Pair result = key.wrapKeyAsync(CEK, null).get(); - encrypted = result.getLeft(); - algorithm = result.getRight(); - - if (!unlimited) fail("Expected ExecutionException"); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - // In the limited case, the failure should be InvalidKeyException - // In the unlimited case, this should not fail - if (!unlimited) { - Throwable cause = e.getCause(); - if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); - } else { - fail("ExecutionException"); - } - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - if (unlimited) { - // Assert - assertEquals("A256KW", algorithm); - assertArrayEquals(EK, encrypted); - - byte[] decrypted = null; - - try { - decrypted = key.unwrapKeyAsync(EK, algorithm).get(); - } catch (InterruptedException e) { - fail("InterrupedException"); - } catch (ExecutionException e) { - fail("ExecutionException"); - } catch (NoSuchAlgorithmException e) { - fail("NoSuchAlgorithmException"); - } - - // Assert - assertArrayEquals(CEK, decrypted); - } - - try { - key.close(); - } catch (IOException e) { - fail("Key could not be closed"); - } - } - } From f8c55838978e545b7f4e6eee5a1ed96549ed2de7 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Fri, 19 Aug 2016 14:11:52 -0700 Subject: [PATCH 23/56] RS256 Signature support. --- .../microsoft/azure/keyvault/core/IKey.java | 2 +- azure-keyvault-cryptography/pom.xml | 10 + .../keyvault/cryptography/Algorithm.java | 2 +- .../cryptography/AlgorithmResolver.java | 30 +- .../azure/keyvault/cryptography/RsaKey.java | 106 ++++-- .../azure/keyvault/cryptography/Strings.java | 20 +- .../cryptography/algorithms/Rs256.java | 126 +++++++ .../cryptography/algorithms/RsaSignature.java | 215 +++++++++++ .../test/Base64UrlDeserializer.java | 43 +++ .../test/Base64UrlSerializer.java | 47 +++ .../cryptography/test/JsonWebKey.java | 346 ++++++++++++++++++ .../cryptography/test/JsonWebKeyType.java | 40 ++ .../cryptography/test/RsaKeyTest.java | 207 ++++------- .../keyvault/extensions/KeyVaultKey.java | 3 +- .../azure/keyvault/extensions/Strings.java | 8 +- 15 files changed, 1020 insertions(+), 185 deletions(-) create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java create mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java index 264024d42b153..6cf69f7002aa9 100755 --- a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java @@ -153,7 +153,7 @@ public interface IKey extends Closeable { * The signature to verify * @param algorithm * The algorithm to use, must be provided - * @return A ListenableFuture containing a boolean result + * @return A ListenableFuture containing the signature and the algorithm used. * @throws NoSuchAlgorithmException the algorithm is not valid */ ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) throws NoSuchAlgorithmException; diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index 17b3766ef8184..5b7688e30a0db 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -59,5 +59,15 @@ azure-keyvault-core ${project.version} + + com.fasterxml.jackson.core + jackson-databind + test + + + commons-codec + commons-codec + test + diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java index 810a6dfa4fb51..bfdcf9e54e790 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java @@ -23,7 +23,7 @@ public abstract class Algorithm { private final String _name; protected Algorithm(String name) { - if (Strings.isNullOrEmpty(name)) { + if (Strings.isNullOrWhiteSpace(name)) { throw new IllegalArgumentException("name"); } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java index 1eacaad75e0c3..c794b02867779 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java @@ -30,6 +30,7 @@ import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw128; import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw192; import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256; +import com.microsoft.azure.keyvault.cryptography.algorithms.Rs256; import com.microsoft.azure.keyvault.cryptography.algorithms.Rsa15; import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; @@ -53,31 +54,38 @@ public class AlgorithmResolver { Default.put(Rsa15.AlgorithmName, new Rsa15()); Default.put(RsaOaep.AlgorithmName, new RsaOaep()); - // Default.put( Rs256.AlgorithmName, new Rs256() ); + Default.put( Rs256.AlgorithmName, new Rs256() ); // Default.put( RsNull.AlgorithmName, new RsNull() ); } private final ConcurrentMap _algorithms = new ConcurrentHashMap(); - /// - /// Returns the implementation for an algorithm name - /// - /// The algorithm name - /// + /** + * Returns the implementation for an algorithm name. + * + * @param algorithmName The algorithm name. + * @return The implementation for the algorithm or null. + */ public Algorithm get(String algorithmName) { return _algorithms.get(algorithmName); } + /** + * Add/Update a named algorithm implementation. + * + * @param algorithmName The algorithm name. + * @param provider The implementation of the algorithm. + */ public void put(String algorithmName, Algorithm provider) { _algorithms.put(algorithmName, provider); } - /// - /// Removes an algorithm from the resolver - /// - /// The algorithm name + /** + * Remove a named algorithm implementation. + * + * @param algorithmName The algorithm name + */ public void remove(String algorithmName) { _algorithms.remove(algorithmName); } - } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java index b56511a99205d..4548a883c17fd 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java @@ -25,13 +25,13 @@ import java.security.Provider; import java.security.interfaces.RSAPublicKey; -import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.microsoft.azure.keyvault.core.IKey; +import com.microsoft.azure.keyvault.cryptography.algorithms.Rs256; import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; import com.microsoft.azure.keyvault.cryptography.Strings; @@ -44,28 +44,16 @@ public static int getDefaultKeySize() { return RsaKey.KeySize2048; } - private final String _kid; - private final KeyPair _keyPair; + private final String _kid; + private final KeyPair _keyPair; + private final Provider _provider; public RsaKey(String kid) throws NoSuchAlgorithmException { this(kid, getDefaultKeySize()); } public RsaKey(String kid, int keySize) throws NoSuchAlgorithmException { - this(kid, keySize, null); - /* - if (Strings.isNullOrWhiteSpace(kid)) { - throw new IllegalArgumentException("kid"); - } - - final KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA"); - - generator.initialize(keySize); - - _keyPair = generator.generateKeyPair(); - _kid = kid; - */ } public RsaKey(String kid, int keySize, Provider provider) throws NoSuchAlgorithmException { @@ -78,12 +66,16 @@ public RsaKey(String kid, int keySize, Provider provider) throws NoSuchAlgorithm generator.initialize(keySize); - _keyPair = generator.generateKeyPair(); - _kid = kid; - + _kid = kid; + _keyPair = generator.generateKeyPair(); + _provider = provider; } public RsaKey(String kid, KeyPair keyPair) { + this(kid, keyPair, null); + } + + public RsaKey(String kid, KeyPair keyPair, Provider provider) { if (Strings.isNullOrWhiteSpace(kid)) { throw new IllegalArgumentException("kid"); @@ -96,9 +88,10 @@ public RsaKey(String kid, KeyPair keyPair) { if (keyPair.getPublic() == null || !(keyPair.getPublic() instanceof RSAPublicKey)) { throw new IllegalArgumentException("keyPair"); } - - _keyPair = keyPair; - _kid = kid; + + _kid = kid; + _keyPair = keyPair; + _provider = provider; } @Override @@ -113,8 +106,7 @@ public String getDefaultKeyWrapAlgorithm() { @Override public String getDefaultSignatureAlgorithm() { - // TODO: Signature Processing - return null; + return Rs256.AlgorithmName; } @Override @@ -146,7 +138,7 @@ public ListenableFuture decryptAsync(final byte[] ciphertext, final byte ListenableFuture result; try { - transform = algo.CreateDecryptor(_keyPair); + transform = algo.CreateDecryptor(_keyPair, _provider); result = Futures.immediateFuture(transform.doFinal(ciphertext)); } catch (Exception e) { result = Futures.immediateFailedFuture(e); @@ -176,7 +168,7 @@ public ListenableFuture> encryptAsync(final byte[ ListenableFuture> result; try { - transform = algo.CreateEncryptor(_keyPair); + transform = algo.CreateEncryptor(_keyPair, _provider); result = Futures.immediateFuture(Triple.of(transform.doFinal(plaintext), (byte[]) null, algorithmName)); } catch (Exception e) { result = Futures.immediateFailedFuture(e); @@ -206,7 +198,7 @@ public ListenableFuture> wrapKeyAsync(final byte[] key, fin ListenableFuture> result; try { - transform = algo.CreateEncryptor(_keyPair); + transform = algo.CreateEncryptor(_keyPair, _provider); result = Futures.immediateFuture(Pair.of(transform.doFinal(key), algorithmName)); } catch (Exception e) { result = Futures.immediateFailedFuture(e); @@ -240,7 +232,7 @@ public ListenableFuture unwrapKeyAsync(final byte[] encryptedKey, final ListenableFuture result; try { - transform = algo.CreateDecryptor(_keyPair); + transform = algo.CreateDecryptor(_keyPair, _provider); result = Futures.immediateFuture(transform.doFinal(encryptedKey)); } catch (Exception e) { result = Futures.immediateFailedFuture(e); @@ -250,13 +242,63 @@ public ListenableFuture unwrapKeyAsync(final byte[] encryptedKey, final } @Override - public ListenableFuture> signAsync(final byte[] digest, final String algorithm) { - return Futures.immediateFailedFuture(new NotImplementedException("signAsync is not currently supported")); + public ListenableFuture> signAsync(final byte[] digest, final String algorithm) throws NoSuchAlgorithmException { + + if (digest == null) { + throw new IllegalArgumentException("encryptedKey "); + } + + // Interpret the requested algorithm + if (Strings.isNullOrWhiteSpace(algorithm)) { + throw new IllegalArgumentException("algorithm"); + } + + // Interpret the requested algorithm + Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithm); + + if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricSignatureAlgorithm)) { + throw new NoSuchAlgorithmException(algorithm); + } + + Rs256 algo = (Rs256)baseAlgorithm; + + Rs256.Rs256Signer signer = algo.createSigner(_keyPair); + + try { + return Futures.immediateFuture(Pair.of(signer.sign(digest), Rs256.AlgorithmName)); + } catch (Exception e) { + return Futures.immediateFailedFuture(e); + } } @Override - public ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) { - return Futures.immediateFailedFuture(new NotImplementedException("verifyAsync is not currently supported")); + public ListenableFuture verifyAsync(final byte[] digest, final byte[] signature, final String algorithm) throws NoSuchAlgorithmException { + + if (digest == null) { + throw new IllegalArgumentException("encryptedKey "); + } + + // Interpret the requested algorithm + if (Strings.isNullOrWhiteSpace(algorithm)) { + throw new IllegalArgumentException("algorithm"); + } + + // Interpret the requested algorithm + Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithm); + + if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricSignatureAlgorithm)) { + throw new NoSuchAlgorithmException(algorithm); + } + + Rs256 algo = (Rs256)baseAlgorithm; + + Rs256.Rs256Verifier signer = algo.createVerifier(_keyPair); + + try { + return Futures.immediateFuture(signer.verify(signature, digest)); + } catch (Exception e) { + return Futures.immediateFailedFuture(e); + } } @Override diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java index c948e8e3453ab..c6cf7244a1532 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java @@ -18,19 +18,29 @@ package com.microsoft.azure.keyvault.cryptography; -import com.microsoft.azure.keyvault.cryptography.Strings; - -public class Strings { - +public final class Strings { + + /** + * Determines whether the parameter string is either null or empty. + * + * @param arg The string to be checked. + * @return true if the string is null or empty. + */ public static boolean isNullOrEmpty(String arg) { - if (arg == null || arg.isEmpty()) { + if (arg == null || arg.length() == 0) { return true; } return false; } + /** + * Determines whether the parameter string is null, empty or whitespace. + * + * @param arg The string to be checked. + * @return true if the string is null, empty or whitespace. + */ public static boolean isNullOrWhiteSpace(String arg) { if (Strings.isNullOrEmpty(arg) || arg.trim().isEmpty()) { diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java new file mode 100644 index 0000000000000..750a02f529ea7 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java @@ -0,0 +1,126 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import java.math.BigInteger; +import java.security.InvalidKeyException; +import java.security.KeyPair; +import java.security.NoSuchAlgorithmException; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import javax.crypto.BadPaddingException; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.NoSuchPaddingException; + +/** + * + */ +public class Rs256 extends RsaSignature { + + static final String RsaNone = "RSA/ECB/PKCS1Padding"; + + public class Rs256Signer { + + private final KeyPair _keyPair; + private final int _emLen; + + private final BigInteger _n; + + Rs256Signer(KeyPair keyPair) { + + _keyPair = keyPair; + _n = ((RSAPublicKey)_keyPair.getPublic()).getModulus(); + + _emLen = getOctetLength( _n.bitLength() ); + } + + public byte[] sign(final byte[] digest) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + // Signing isn't just a case of encrypting the digest, there is much more to do. + // For details of the algorithm, see https://tools.ietf.org/html/rfc3447#section-8.2 + + // Construct the encoded message + byte[] EM = EMSA_PKCS1_V1_5_ENCODE(digest, _emLen, "SHA-256"); + + // Convert to integer message + BigInteger s = OS2IP(EM); + + // RSASP1(s) + s = RSASP1((RSAPrivateKey)_keyPair.getPrivate(), s); + + // Convert to octet sequence + return I2OSP(s, getOctetLength( _n.bitLength() ) ); + } + } + + public class Rs256Verifier { + + private final KeyPair _keyPair; + private final BigInteger _n; + private final int _emLength; + + Rs256Verifier(KeyPair keyPair) { + _keyPair = keyPair; + _n = ((RSAPublicKey)_keyPair.getPublic()).getModulus(); + _emLength = getOctetLength( _n.bitLength() ); + } + + public boolean verify(final byte[] signature, final byte[] digest) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + + if ( signature.length != getOctetLength( _n.bitLength() ) ) { + throw new IllegalBlockSizeException(); + } + + // Convert to integer signature + BigInteger s = OS2IP(signature); + + // Convert integer message + BigInteger m = RSAVP1((RSAPublicKey)_keyPair.getPublic(), s); + + + byte[] EM = I2OSP(m, getOctetLength( _n.bitLength() ) ); + byte[] EM2 = EMSA_PKCS1_V1_5_ENCODE(digest, _emLength, "SHA-256"); + + // TODO: Need constant time compare + if ( EM.length != EM2.length ) + return false; + + for ( int i = 0; i < digest.length; i++ ) { + if ( EM[i] != EM2[i] ) + return false; + } + + return true; + } + } + + public final static String AlgorithmName = "RS256"; + + public Rs256() { + super(AlgorithmName); + } + + public Rs256Signer createSigner(KeyPair keyPair) { + + return new Rs256Signer(keyPair); + } + + public Rs256Verifier createVerifier(KeyPair keyPair) { + return new Rs256Verifier(keyPair); + } +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java new file mode 100644 index 0000000000000..a9ac4d4559cbb --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java @@ -0,0 +1,215 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.algorithms; + +import java.math.BigInteger; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.util.Arrays; + +import com.microsoft.azure.keyvault.cryptography.AsymmetricSignatureAlgorithm; +import com.microsoft.azure.keyvault.cryptography.Strings; + +public abstract class RsaSignature extends AsymmetricSignatureAlgorithm { + + private static final BigInteger twoFiveSix = new BigInteger("256"); + private static final byte[] sha256Prefix = new byte[] { 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, (byte) 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20 }; + + protected RsaSignature(String name) { + super(name); + } + + protected static byte[] toByteArray(BigInteger n) { + byte[] result = n.toByteArray(); + if (result[0] == 0) { + // The leading zero is used to let the number positive. Since RSA + // parameters are always positive, we remove it. + return Arrays.copyOfRange(result, 1, result.length); + } + return result; + } + + protected static BigInteger toBigInteger(byte[] b) { + if (b[0] < 0) { + // RSA parameters are always positive numbers, so if the first byte + // is negative, we need to add a leading zero + // to make the entire BigInteger positive. + byte[] temp = new byte[1 + b.length]; + System.arraycopy(b, 0, temp, 1, b.length); + b = temp; + } + return new BigInteger(b); + } + + protected int getOctetLength(int bits) { + return ( bits % 8 > 0 ) ? bits >> 3 + 1 : bits >> 3; + } + + + /* + * See https://tools.ietf.org/html/rfc3447#section-4.2 + */ + protected BigInteger OS2IP(byte[] x) { + + if ( x == null || x.length == 0 ) { + throw new IllegalArgumentException("x"); + } + + return new BigInteger(1,x); + } + + /* + * See https://tools.ietf.org/html/rfc3447#section-4.1 + */ + protected byte[] I2OSP(BigInteger x, int xLen) { + + if ( x == null ) { + throw new IllegalArgumentException("x"); + } + + if ( xLen <= 0 ) { + throw new IllegalArgumentException("xLen"); + } + + if ( x.compareTo( twoFiveSix.pow(xLen) ) == 1 ) { + throw new IllegalArgumentException("integer too large"); + } + + byte[] bytes = x.toByteArray(); + + if ( bytes.length > xLen ) { + throw new IllegalArgumentException("integer too large"); + } + + byte[] result = new byte[xLen]; + + System.arraycopy(bytes, 0, result, xLen - bytes.length, bytes.length); + + return result; + } + + /* + * See https://tools.ietf.org/html/rfc3447#section-5.2.1 + */ + protected BigInteger RSASP1(RSAPrivateKey K, BigInteger m) { + + if ( K == null ) { + throw new IllegalArgumentException("K"); + } + + if ( m == null ) { + throw new IllegalArgumentException("m"); + } + + BigInteger n = K.getModulus(); + BigInteger d = K.getPrivateExponent(); + + if ( m.compareTo(BigInteger.ONE) == -1 || m.compareTo(n) != -1 ) { + throw new IllegalArgumentException("message representative out of range"); + } + + return m.modPow(d, n); + } + + /* + * See https://tools.ietf.org/html/rfc3447#section-5.2.2 + */ + protected BigInteger RSAVP1(RSAPublicKey K, BigInteger s) { + + if ( K == null ) { + throw new IllegalArgumentException("K"); + } + + if ( s == null ) { + throw new IllegalArgumentException("s"); + } + BigInteger n = K.getModulus(); + BigInteger e = K.getPublicExponent(); + + if ( s.compareTo(BigInteger.ONE) == -1 || s.compareTo(n) != -1 ) { + throw new IllegalArgumentException("message representative out of range"); + } + + return s.modPow(e, n); + } + + /* + * See https://tools.ietf.org/html/rfc3447#section-9.2 + */ + protected byte[] EMSA_PKCS1_V1_5_ENCODE(byte[] m, int emLen, String algorithm) throws NoSuchAlgorithmException { + + // Check m + if ( m == null || m.length == 0 ) { + throw new IllegalArgumentException("m"); + } + + byte[] algorithmPrefix = null; + MessageDigest messageDigest = null; + + // Check algorithm + if ( Strings.isNullOrWhiteSpace(algorithm) ) { + throw new IllegalArgumentException("algorithm"); + } + + // Only supported algorithms + if ( algorithm.equals("SHA-256") ) { + + // Initialize prefix and digest + algorithmPrefix = sha256Prefix; + messageDigest = MessageDigest.getInstance("SHA-256"); + } else { + throw new IllegalArgumentException("algorithm"); + } + + if ( algorithmPrefix == null || messageDigest == null ) { + throw new IllegalArgumentException("initialization with arguments failed"); + } + + // Hash the message + byte[] digest = messageDigest.digest(m); + + // Construct T, the DER encoded DigestInfo structure + byte[] T = new byte[algorithmPrefix.length + digest.length]; + + System.arraycopy(algorithmPrefix, 0, T, 0, algorithmPrefix.length); + System.arraycopy(digest, 0, T, algorithmPrefix.length, digest.length); + + if ( emLen < T.length + 11 ) { + throw new IllegalArgumentException("intended encoded message length too short"); + } + + // Construct PS + byte[] PS = new byte[emLen - T.length - 3]; + + for ( int i = 0; i < PS.length; i++ ) PS[i] = (byte) 0xff; + + // Construct EM + byte[] EM = new byte[PS.length + T.length + 3]; + + EM[0] = 0x00; EM[1] = 0x01; EM[PS.length + 2] = 0x00; + + System.arraycopy(PS, 0, EM, 2, PS.length); + System.arraycopy(T, 0, EM, PS.length + 3, T.length); + + return EM; + } + +} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java new file mode 100644 index 0000000000000..8f54e8cdece21 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java @@ -0,0 +1,43 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import java.io.IOException; + +import org.apache.commons.codec.binary.Base64; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; + +public class Base64UrlDeserializer extends JsonDeserializer { + + static final Base64 _base64 = new Base64(-1, null, true); + + @Override + public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + String text = jp.getText(); + if (text != null) { + return _base64.decode(text); + } + return null; + } + +} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java new file mode 100644 index 0000000000000..3cf15e392863d --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java @@ -0,0 +1,47 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import java.io.IOException; + +import org.apache.commons.codec.binary.Base64; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +public class Base64UrlSerializer extends JsonSerializer { + + static final Base64 _base64 = new Base64(-1, null, true); + + @Override + public void serialize(byte[] value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { + String text; + if (value == null) { + text = null; + } else if (value.length == 0) { + text = ""; + } else { + text = _base64.encodeAsString(value); + } + jgen.writeString(text); + } + +} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java new file mode 100644 index 0000000000000..ec65f0d6fea55 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java @@ -0,0 +1,346 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import java.io.IOException; +import java.math.BigInteger; +import java.security.GeneralSecurityException; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.PrivateKey; +import java.security.Provider; +import java.security.PublicKey; +import java.security.interfaces.RSAPrivateCrtKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.RSAPrivateCrtKeySpec; +import java.security.spec.RSAPrivateKeySpec; +import java.security.spec.RSAPublicKeySpec; +import java.util.Arrays; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY) +public class JsonWebKey { + + private String kid; + + @JsonProperty("kid") + public String getKid() { + return kid; + } + + public void setKid(String kid) { + this.kid = kid; + } + + private String kty; + + @JsonProperty("kty") + public String getKty() { + return kty; + } + + public void setKty(String kty) { + this.kty = kty; + } + + private String[] keyOps; + + @JsonProperty("key_ops") + public String[] getKeyOps() { + return keyOps; + } + + public void setKeyOps(String[] keyOps) { + this.keyOps = keyOps; + } + + private byte[] n; + + @JsonProperty("n") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getN() { + return n; + } + + public void setN(byte[] n) { + this.n = n; + } + + private byte[] e; + + @JsonProperty("e") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getE() { + return e; + } + + public void setE(byte[] e) { + this.e = e; + } + + private byte[] d; + + @JsonProperty("d") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getD() { + return d; + } + + public void setD(byte[] d) { + this.d = d; + } + + private byte[] dp; + + @JsonProperty("dp") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getDP() { + return dp; + } + + public void setDP(byte[] dp) { + this.dp = dp; + } + + private byte[] dq; + + @JsonProperty("dq") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getDQ() { + return dq; + } + + public void setDQ(byte[] dq) { + this.dq = dq; + } + + private byte[] qi; + + @JsonProperty("qi") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getQI() { + return qi; + } + + public void setQI(byte[] qi) { + this.qi = qi; + } + + private byte[] p; + + @JsonProperty("p") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getP() { + return p; + } + + public void setP(byte[] p) { + this.p = p; + } + + private byte[] q; + + @JsonProperty("q") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getQ() { + return q; + } + + public void setQ(byte[] q) { + this.q = q; + } + + private byte[] k; + + @JsonProperty("k") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getk() { + return k; + } + + public void setK(byte[] k) { + this.k = k; + } + + private byte[] t; + + @JsonProperty("key_hsm") + @JsonSerialize(using = Base64UrlSerializer.class) + @JsonDeserialize(using = Base64UrlDeserializer.class) + public byte[] getT() { + return t; + } + + public void setT(byte[] t) { + this.t = t; + } + + @Override + public String toString() { + ObjectMapper mapper = new ObjectMapper(); + try { + return mapper.writeValueAsString(this); + } catch (JsonGenerationException e) { + throw new IllegalStateException(e); + } catch (JsonMappingException e) { + throw new IllegalStateException(e); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + private RSAPublicKeySpec getRSAPublicKeySpec() { + + return new RSAPublicKeySpec(toBigInteger(n), toBigInteger(e)); + } + + private RSAPrivateKeySpec getRSAPrivateKeySpec() { + + return new RSAPrivateCrtKeySpec(toBigInteger(n), toBigInteger(e), toBigInteger(d), toBigInteger(p), toBigInteger(q), toBigInteger(dp), toBigInteger(dq), toBigInteger(qi)); + } + + private PublicKey getRSAPublicKey(Provider provider) { + + try { + RSAPublicKeySpec publicKeySpec = getRSAPublicKeySpec(); + KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider) : KeyFactory.getInstance("RSA"); + + return factory.generatePublic(publicKeySpec); + } catch (GeneralSecurityException e) { + throw new IllegalStateException(e); + } + } + + private PrivateKey getRSAPrivateKey(Provider provider) { + + try { + RSAPrivateKeySpec privateKeySpec = getRSAPrivateKeySpec(); + KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider) : KeyFactory.getInstance("RSA"); + + return factory.generatePrivate(privateKeySpec); + } catch (GeneralSecurityException e) { + throw new IllegalStateException(e); + } + } + + private void checkRSACompatible() { + if (!JsonWebKeyType.RSA.equals(kty) && !JsonWebKeyType.RSAHSM.equals(kty)) { + throw new UnsupportedOperationException("Not an RSA key"); + } + } + + private static byte[] toByteArray(BigInteger n) { + byte[] result = n.toByteArray(); + if (result[0] == 0) { + // The leading zero is used to let the number positive. Since RSA + // parameters are always positive, we remove it. + return Arrays.copyOfRange(result, 1, result.length); + } + return result; + } + + private static BigInteger toBigInteger(byte[] b) { + if (b[0] < 0) { + // RSA parameters are always positive numbers, so if the first byte + // is negative, we need to add a leading zero + // to make the entire BigInteger positive. + byte[] temp = new byte[1 + b.length]; + System.arraycopy(b, 0, temp, 1, b.length); + b = temp; + } + return new BigInteger(b); + } + + public static JsonWebKey fromRSA(KeyPair keyPair) { + + RSAPrivateCrtKey privateKey = (RSAPrivateCrtKey) keyPair.getPrivate(); + JsonWebKey key = null; + + if (privateKey != null) { + + key = new JsonWebKey(); + + key.setKty(JsonWebKeyType.RSA); + + key.setN(toByteArray(privateKey.getModulus())); + key.setE(toByteArray(privateKey.getPublicExponent())); + key.setD(toByteArray(privateKey.getPrivateExponent())); + key.setP(toByteArray(privateKey.getPrimeP())); + key.setQ(toByteArray(privateKey.getPrimeQ())); + key.setDP(toByteArray(privateKey.getPrimeExponentP())); + key.setDQ(toByteArray(privateKey.getPrimeExponentQ())); + key.setQI(toByteArray(privateKey.getCrtCoefficient())); + } else { + + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + + key = new JsonWebKey(); + + key.setKty(JsonWebKeyType.RSA); + + key.setN(toByteArray(publicKey.getModulus())); + key.setE(toByteArray(publicKey.getPublicExponent())); + key.setD(null); + key.setP(null); + key.setQ(null); + key.setDP(null); + key.setDQ(null); + key.setQI(null); + } + + return key; + } + + public KeyPair toRSA() { + return this.toRSA(false); + } + + public KeyPair toRSA(boolean includePrivateParameters) { + + return toRSA(includePrivateParameters, null); + } + + public KeyPair toRSA(boolean includePrivateParameters, Provider provider) { + + // Must be RSA + checkRSACompatible(); + + if (includePrivateParameters) { + return new KeyPair(getRSAPublicKey(provider), getRSAPrivateKey(provider)); + } else { + return new KeyPair(getRSAPublicKey(provider), null); + } + } +} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java new file mode 100644 index 0000000000000..f3b1760652637 --- /dev/null +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java @@ -0,0 +1,40 @@ +/** + * + * Copyright (c) Microsoft and contributors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.microsoft.azure.keyvault.cryptography.test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Supported JsonWebKey key types (kty) + */ +public final class JsonWebKeyType { + + public static final String EC = "EC"; + public static final String RSA = "RSA"; + public static final String RSAHSM = "RSA-HSM"; + public static final String OCT = "oct"; + + public static final List ALL_TYPES = Collections.unmodifiableList(Arrays.asList(new String[] { EC, RSA, RSAHSM, OCT })); + + private JsonWebKeyType() { + // not instantiable + } +} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java index 0d9fafb68ebbf..7c9b29b956bd5 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -2,15 +2,10 @@ import static org.junit.Assert.*; -import java.math.BigInteger; -import java.security.KeyFactory; -import java.security.KeyPair; +import java.security.MessageDigest; import java.security.Provider; -import java.security.spec.KeySpec; -import java.security.spec.RSAPrivateCrtKeySpec; -import java.security.spec.RSAPublicKeySpec; -import java.util.concurrent.Future; +import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; import org.junit.After; @@ -19,12 +14,19 @@ import org.junit.BeforeClass; import org.junit.Test; +import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.cryptography.RsaKey; +import com.microsoft.azure.keyvault.cryptography.algorithms.Rs256; import com.microsoft.azure.keyvault.cryptography.algorithms.Rsa15; import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; public class RsaKeyTest { + // A Content Encryption Key, or Message. This value is kept consistent with the .NET + // unit test cases to enable cross platform testing. + static final byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; + static final String CrossPlatformSignature = "RaNc+8WcWxplS8I7ynJLSoLJKz+dgBvrZhIGH3VFlTTyzu7b9d+lpaV9IKhzCNBsgSysKhgL7EZwVCOTBZ4m6xvKSXqVFXYaBPyBTD7VoKPMYMW6ai5x6xV5XAMaZPfMkff3Deg/RXcc8xQ28FhYuUa8yly01GySY4Hk55anEvb2wBxSy1UGun/0LE1lYH3C3XEgSry4cEkJHDJl1hp+wB4J/noXOqn5ECGU+/4ehBJOyW1gtUH0/gRe8yXnDH0AXepHRyH8iBHLWlKX1r+1/OrMulqOoi82RZzJlTyEz9X+bsQhllqGF6n3hdLS6toH9o7wUtwYNqSx82JuQT6iMg=="; + private Provider _provider = null; @BeforeClass @@ -48,163 +50,110 @@ protected void setProvider(Provider provider) { } @Test - public void testEncryptDecryptRsa15() throws Exception { + public void testRsa15() throws Exception { - KeyPair keyPair = getTestKeyMaterial(); - RsaKey key = new RsaKey("foo", keyPair); - byte[] plaintext = "plaintext".getBytes(); + RsaKey key = getTestRsaKey(); - // Encrypt the plaintext - Triple result = key.encryptAsync(plaintext, null, null, Rsa15.AlgorithmName).get(); - - byte[] ciphertext = result.getLeft(); + // Wrap and Unwrap + Pair wrapped = key.wrapKeyAsync(CEK, Rsa15.AlgorithmName).get(); + byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); - assertEquals(Rsa15.AlgorithmName, result.getRight()); - - // Decrypt the ciphertext - Future decryptResult = key.decryptAsync(ciphertext, null, null, null, result.getRight()); - byte[] decrypted = decryptResult.get(); - - key.close(); - - assertArrayEquals(plaintext, decrypted); - } - - @Test - public void testEncryptDecryptRsaOaep() throws Exception { - - KeyPair keyPair = getTestKeyMaterial(); - RsaKey key = new RsaKey("foo", keyPair); - byte[] plaintext = "plaintext".getBytes(); + // Assert + assertEquals(Rsa15.AlgorithmName, wrapped.getRight()); + assertArrayEquals(CEK, unwrapped); - // Encrypt the plaintext - Triple result = key.encryptAsync(plaintext, null, null, RsaOaep.AlgorithmName).get(); + // Encrypt and Decrypt + Triple encrypted = key.encryptAsync(CEK, null, null, Rsa15.AlgorithmName).get(); + byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); - byte[] ciphertext = result.getLeft(); - - assertEquals(RsaOaep.AlgorithmName, result.getRight()); - - // Decrypt the ciphertext - Future decryptResult = key.decryptAsync(ciphertext, null, null, null, result.getRight()); - byte[] decrypted = decryptResult.get(); + // Assert + assertEquals(Rsa15.AlgorithmName, encrypted.getRight()); + assertArrayEquals(CEK, decrypted); key.close(); - - assertArrayEquals(plaintext, decrypted); } @Test - public void testWrapUnwrapRsa15() throws Exception { + public void testRsaOaep() throws Exception { - KeyPair keyPair = getTestKeyMaterial(); - RsaKey key = new RsaKey("foo", keyPair); - byte[] plaintext = "plaintext".getBytes(); + RsaKey key = getTestRsaKey(); - // Encrypt the plaintext - Pair result = key.wrapKeyAsync(plaintext, Rsa15.AlgorithmName).get(); + // Wrap and Unwrap + Pair wrapped = key.wrapKeyAsync(CEK, RsaOaep.AlgorithmName).get(); + byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); - byte[] ciphertext = result.getLeft(); - - assertEquals(Rsa15.AlgorithmName, result.getRight()); - - // Decrypt the ciphertext - Future decryptResult = key.unwrapKeyAsync(ciphertext, result.getRight()); - byte[] decrypted = decryptResult.get(); - - key.close(); - - assertArrayEquals(plaintext, decrypted); - } + // Assert + assertEquals(RsaOaep.AlgorithmName, wrapped.getRight()); + assertArrayEquals(CEK, unwrapped); - @Test - public void testWrapUnwrapRsaOaep() throws Exception { - - KeyPair keyPair = getTestKeyMaterial(); - RsaKey key = new RsaKey("foo", keyPair); - byte[] plaintext = "plaintext".getBytes(); - - // Encrypt the plaintext - Pair result = key.wrapKeyAsync(plaintext, RsaOaep.AlgorithmName).get(); + // Encrypt and Decrypt + Triple encrypted = key.encryptAsync(CEK, null, null, RsaOaep.AlgorithmName).get(); + byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); - byte[] ciphertext = result.getLeft(); - - assertEquals(RsaOaep.AlgorithmName, result.getRight()); - - // Decrypt the ciphertext - Future decryptResult = key.unwrapKeyAsync(ciphertext, result.getRight()); - byte[] decrypted = decryptResult.get(); + // Assert + assertEquals(RsaOaep.AlgorithmName, encrypted.getRight()); + assertArrayEquals(CEK, decrypted); key.close(); - - assertArrayEquals(plaintext, decrypted); } @Test - public void testEncryptDecryptDefaultAlgorithm() throws Exception { + public void testDefaultAlgorithm() throws Exception { - KeyPair keyPair = getTestKeyMaterial(); - RsaKey key = new RsaKey("foo", keyPair); - byte[] plaintext = "plaintext".getBytes(); + RsaKey key = getTestRsaKey(); - // Encrypt the plaintext - Triple result = key.encryptAsync(plaintext, null, null, null).get(); - - byte[] ciphertext = result.getLeft(); + assertEquals(RsaOaep.AlgorithmName, key.getDefaultEncryptionAlgorithm()); + assertEquals(RsaOaep.AlgorithmName, key.getDefaultKeyWrapAlgorithm()); + assertEquals(Rs256.AlgorithmName, key.getDefaultSignatureAlgorithm()); + + // Wrap and Unwrap + Pair wrapped = key.wrapKeyAsync(CEK, key.getDefaultKeyWrapAlgorithm()).get(); + byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); - assertEquals(RsaOaep.AlgorithmName, result.getRight()); + // Assert + assertEquals(RsaOaep.AlgorithmName, wrapped.getRight()); + assertArrayEquals(CEK, unwrapped); - // Decrypt the ciphertext - Future decryptResult = key.decryptAsync(ciphertext, null, null, null, result.getRight()); - byte[] decrypted = decryptResult.get(); + // Encrypt and Decrypt + Triple encrypted = key.encryptAsync(CEK, null, null, key.getDefaultEncryptionAlgorithm()).get(); + byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); + + // Assert + assertEquals(RsaOaep.AlgorithmName, encrypted.getRight()); + assertArrayEquals(CEK, decrypted); key.close(); - - assertArrayEquals(plaintext, decrypted); } - + @Test - public void testWrapUnwrapDefaultAlgorithm() throws Exception { + public void testSignVerify() throws Exception { + + RsaKey key = getTestRsaKey(); - KeyPair keyPair = getTestKeyMaterial(); - RsaKey key = new RsaKey("foo", keyPair); - byte[] plaintext = "plaintext".getBytes(); + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + byte[] hash = digest.digest(CEK); + + Pair signature = key.signAsync(hash, "RS256").get(); + boolean result = key.verifyAsync(hash, signature.getLeft(), "RS256").get(); - // Encrypt the plaintext - Pair result = key.wrapKeyAsync(plaintext, null).get(); - - byte[] ciphertext = result.getLeft(); + assertTrue(result); - assertEquals(RsaOaep.AlgorithmName, result.getRight()); + // Now prove we can verify the cross platform signature + result = key.verifyAsync(hash, Base64.decodeBase64(CrossPlatformSignature), "RS256").get(); - // Decrypt the ciphertext - Future decryptResult = key.unwrapKeyAsync(ciphertext, result.getRight()); - byte[] decrypted = decryptResult.get(); + assertTrue(result); key.close(); - - assertArrayEquals(plaintext, decrypted); } - - private KeyPair getTestKeyMaterial() throws Exception { - - return getWellKnownKey(); - } - - private KeyPair getWellKnownKey() throws Exception { - BigInteger modulus = new BigInteger("27266783713040163753473734334021230592631652450892850648620119914958066181400432364213298181846462385257448168605902438305568194683691563208578540343969522651422088760509452879461613852042845039552547834002168737350264189810815735922734447830725099163869215360401162450008673869707774119785881115044406101346450911054819448375712432746968301739007624952483347278954755460152795801894283389540036131881712321193750961817346255102052653789197325341350920441746054233522546543768770643593655942246891652634114922277138937273034902434321431672058220631825053788262810480543541597284376261438324665363067125951152574540779"); - BigInteger publicExponent = new BigInteger("65537"); - BigInteger privateExponent = new BigInteger("10466613941269075477152428927796086150095892102279802916937552172064636326433780566497000814207416485739683286961848843255766652023400959086290344987308562817062506476465756840999981989957456897020361717197805192876094362315496459535960304928171129585813477132331538577519084006595335055487028872410579127692209642938724850603554885478763205394868103298473476811627231543504190652483290944218004086457805431824328448422034887148115990501701345535825110962804471270499590234116100216841170344686381902328362376624405803648588830575558058257742073963036264273582756620469659464278207233345784355220317478103481872995809"); - BigInteger primeP = new BigInteger("175002941104568842715096339107566771592009112128184231961529953978142750732317724951747797764638217287618769007295505214923187971350518217670604044004381362495186864051394404165602744235299100790551775147322153206730562450301874236875459336154569893255570576967036237661594595803204808064127845257496057219227"); - BigInteger primeQ = new BigInteger("155807574095269324897144428622185380283967159190626345335083690114147315509962698765044950001909553861571493035240542031420213144237033208612132704562174772894369053916729901982420535940939821673277140180113593951522522222348910536202664252481405241042414183668723338300649954708432681241621374644926879028977"); - BigInteger primeExponentP = new BigInteger("79745606804504995938838168837578376593737280079895233277372027184693457251170125851946171360348440134236338520742068873132216695552312068793428432338173016914968041076503997528137698610601222912385953171485249299873377130717231063522112968474603281996190849604705284061306758152904594168593526874435238915345"); - BigInteger primeExponentQ = new BigInteger("80619964983821018303966686284189517841976445905569830731617605558094658227540855971763115484608005874540349730961777634427740786642996065386667564038755340092176159839025706183161615488856833433976243963682074011475658804676349317075370362785860401437192843468423594688700132964854367053490737073471709030801"); - BigInteger crtCoefficient = new BigInteger("2157818511040667226980891229484210846757728661751992467240662009652654684725325675037512595031058612950802328971801913498711880111052682274056041470625863586779333188842602381844572406517251106159327934511268610438516820278066686225397795046020275055545005189953702783748235257613991379770525910232674719428"); - - KeySpec publicKeySpec = new RSAPublicKeySpec(modulus, publicExponent); - KeySpec privateKeySpec = new RSAPrivateCrtKeySpec(modulus, publicExponent, privateExponent, primeP, primeQ, primeExponentP, primeExponentQ, crtCoefficient); - KeyFactory keyFactory = _provider == null ? KeyFactory.getInstance("RSA") : KeyFactory.getInstance("RSA", _provider); - - return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); + + private RsaKey getTestRsaKey() throws Exception { + String jwkString = "{\"kty\":\"RSA\",\"n\":\"rZ8pnmXkhfmmgNWVVdtNcYy2q0OAcCGIpeFzsN9URqJsiBEiWQfxlUxFTbM4kVWPqjauKt6byvApBGEeMA7Qs8kxwRVP-BD4orXRe9VPgliM92rH0UxQWHmCHUe7G7uUAFPwbiDVhWuFzELxNa6Kljg6Z9DuUKoddmQvlYWj8uSunofCtDi_zzlZKGYTOYJma5IYScHNww1yjLp8-b-Be2UdHbrPkCv6Nuwi6MVIKjPpEeRQgfefRmxDBJQKY3OfydMXZmEwukYXVkUcdIP8XwG2OxnfdRK0oAo0NDebNNVuT89k_3AyZLTr1KbDmx1nnjwa8uB8k-uLtcOC9igbTw\",\"e\":\"AQAB\",\"d\":\"H-z7hy_vVJ9yeZBMtIvt8qpQUK_J51STPwV085otcgud72tPKJXoW2658664ASl9kGwbnLBwb2G3-SEunuGqiNS_PGUB3niob6sFSUMRKsPDsB9HfPoOcCZvwZiWFGRqs6C7vlR1TuJVqRjKJ_ffbf4K51oo6FZPspx7j4AShLAwLUSQ60Ld5QPuxYMYZIMpdVbMVIVHJ26pR4Y18e_0GYmEGnbF5N0HkwqQmfmTiIK5aoGnD3GGgqHeHmWBwh6_WAq90ITLcX_zBeqQUgBSj-Z5v61SroO9Eang36T9mMoYrcPpYwemtAOb4HhQYDj8dCCfbeOcVmvZ9UJKWCX2oQ\",\"dp\":\"HW87UpwPoj3lPI9B9K1hJFeuGgarpakvtHuk1HpZ5hXWFGAJiXoWRV-jvYyjoM2k7RpSxPyuuFFmYHcIxiGFp2ES4HnP0BIhKVa2DyugUxIEcMK53C43Ub4mboJPZTSC3sapKgAmA2ue624sapWmshTPpx9qnUP2Oj3cSMkgMGE\",\"dq\":\"RhwEwb5FYio0GS2tmul8FAYsNH7JDehwI1yUApnTiakhSenFetml4PYyVkKR4csgLZEi3RY6J3R8Tg-36zrZuF7hxhVJn80L5_KETSpfEI3jcrXMVg4SRaMsWLY9Ahxflt2FJgUnHOmWRLmP6_hmaTcxxSACjbyUd_HhwNavD5E\",\"qi\":\"wYPZ4lKIslA1w3FaAzQifnNLABYXXUZ_KAA3a8T8fuxkdE4OP3xIFX7WHhnmBd6uOFiEcGoeq2jNQqDg91rV5661-5muQKcvp4uUsNId5rQw9EZw-kdDcwMtVFTEBfvVuyp83X974xYAHn1Jd8wWohSwrpi1QuH5cQMR5Fm6I1A\",\"p\":\"74Ot7MgxRu4euB31UWnGtrqYPjJmvbjYESS43jfDfo-s62ggV5a39P_YPg6oosgtGHNw0QDxunUOXNu9iriaYPf_imptRk69bKN8Nrl727Y-AaBYdLf1UZuwz8X07FqHAH5ghYpk79djld8QvkUUJLpx6rzcW8BJLTOi46DtzZE\",\"q\":\"uZJu-qenARIt28oj_Jlsk-p_KLnqdczczZfbRDd7XNp6csGLa8R0EyYqUB4xLWELQZsX4tAu9SaAO62tuuEy5wbOAmOVrq2ntoia1mGQSJdoeVq6OqtN300xVnaBc3us0rm8C6-824fEQ1PWXoulXLKcSqBhFT-hQahsYi-kat8\"}"; + ObjectMapper mapper = new ObjectMapper(); + JsonWebKey jwk = null; + + jwk = mapper.readValue(jwkString, JsonWebKey.class); + + return new RsaKey("foo", jwk.toRSA(true, _provider) ); } } diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index 485fa3a0b797f..c33fb8eefbabe 100755 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -29,10 +29,9 @@ import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.cryptography.RsaKey; -import com.microsoft.azure.keyvault.cryptography.Strings; +import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyOperationResult; -import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; import com.microsoft.rest.ServiceResponse; diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java index 3b4d8ad3b1afb..52ef356b78e3b 100755 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/Strings.java @@ -24,13 +24,13 @@ public class Strings { /** - * Verifier if the string is empty or null. + * Determines whether the parameter string is either null or empty. * @param arg the string to verify - * @return true if the string is empty or null and false otherwise + * @return true if the string is empty or null and false otherwise. */ public static boolean isNullOrEmpty(String arg) { - if (arg == null || arg.isEmpty()) { + if (arg == null || arg.length() == 0) { return true; } @@ -38,7 +38,7 @@ public static boolean isNullOrEmpty(String arg) { } /** - * Verifier if the string is empty, contains only whitespace or is null. + * Determines whether the parameter string is null, empty or whitespace. * @param arg the string to verify * @return true if the string is empty, contains only whitespace or is null and false otherwise */ From 83a3fc618804957b33de211556a0c880a65a36fa Mon Sep 17 00:00:00 2001 From: Pooneh Date: Mon, 22 Aug 2016 09:38:56 -0700 Subject: [PATCH 24/56] Adding managed field for certifciates and use base class of attributes in request classes. --- .../azure/keyvault/models/KeyBundle.java | 25 +++++++++++++++++ .../azure/keyvault/models/KeyItem.java | 25 +++++++++++++++++ .../azure/keyvault/models/SecretBundle.java | 25 +++++++++++++++++ .../azure/keyvault/models/SecretItem.java | 25 +++++++++++++++++ .../requests/CreateCertificateRequest.java | 5 ++-- .../keyvault/requests/CreateKeyRequest.java | 5 ++-- .../requests/ImportCertificateRequest.java | 5 ++-- .../keyvault/requests/ImportKeyRequest.java | 5 ++-- .../requests/MergeCertificateRequest.java | 5 ++-- .../keyvault/requests/SetSecretRequest.java | 5 ++-- .../requests/UpdateCertificateRequest.java | 6 ++--- .../keyvault/requests/UpdateKeyRequest.java | 5 ++-- .../requests/UpdateSecretRequest.java | 5 ++-- .../test/CertificateOperationsTest.java | 27 +++++++++++++------ .../keyvault/test/KeyOperationsTest.java | 9 ++++--- .../keyvault/test/SecretOperationsTest.java | 8 ++++-- 16 files changed, 158 insertions(+), 32 deletions(-) diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index 453e5177fab2b..ae4a62b7cbacc 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -38,6 +38,11 @@ public class KeyBundle { */ private Map tags; + /** + * True if the secret's lifetime is managed by key vault. + */ + private Boolean managed; + /** * Get the key value. * @@ -98,6 +103,26 @@ public KeyBundle withTags(Map tags) { return this; } + /** + * Get the managed value. + * + * @return the managed value + */ + public Boolean managed() { + return this.managed; + } + + /** + * Set the managed value. + * + * @param managed the managed value to set + * @return the KeyBundle object itself. + */ + public KeyBundle withManaged(Boolean managed) { + this.managed = managed; + return this; + } + /** * The key identifier. * @return identifier for the key diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index 05584de30f1ac..4dea299b81d8c 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -33,6 +33,11 @@ public class KeyItem { */ private Map tags; + /** + * True if the secret's lifetime is managed by key vault. + */ + private Boolean managed; + /** * Get the kid value. * @@ -93,6 +98,26 @@ public KeyItem withTags(Map tags) { return this; } + /** + * Get the managed value. + * + * @return the managed value + */ + public Boolean managed() { + return this.managed; + } + + /** + * Set the managed value. + * + * @param managed the managed value to set + * @return the KeyItem object itself. + */ + public KeyItem withManaged(Boolean managed) { + this.managed = managed; + return this; + } + /** * The key identifier. * @return The Identifier value diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index c52baf76b82f9..6dea046e03cc5 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -53,6 +53,11 @@ public class SecretBundle { */ private String kid; + /** + * True if the secret's lifetime is managed by key vault. + */ + private Boolean managed; + /** * Get the value value. * @@ -173,6 +178,26 @@ public SecretBundle withKid(String kid) { return this; } + /** + * Get the managed value. + * + * @return the managed value + */ + public Boolean managed() { + return this.managed; + } + + /** + * Set the managed value. + * + * @param managed the managed value to set + * @return the SecretBundle object itself. + */ + public SecretBundle withManaged(Boolean managed) { + this.managed = managed; + return this; + } + /** * the secret identifier. * @return The Identifier value diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index 5359f9cba67ca..db383c7f7f0fb 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -38,6 +38,11 @@ public class SecretItem { */ private String contentType; + /** + * True if the secret's lifetime is managed by key vault. + */ + private Boolean managed; + /** * Get the id value. * @@ -118,6 +123,26 @@ public SecretItem withContentType(String contentType) { return this; } + /** + * Get the managed value. + * + * @return the managed value + */ + public Boolean managed() { + return this.managed; + } + + /** + * Set the managed value. + * + * @param managed the managed value to set + * @return the SecretItem object itself. + */ + public SecretItem withManaged(Boolean managed) { + this.managed = managed; + return this; + } + /** * the secret identifier. * @return The Identifier value diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java index fb9a8e5db704b..84900c5ae2143 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificatePolicy; import com.microsoft.azure.keyvault.models.IssuerReference; @@ -69,8 +70,8 @@ public Builder withPolicy(CertificatePolicy certificatePolicy) { * The attributes of the certificate. * @return the Builder object itself. */ - public Builder withAttributes(CertificateAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (CertificateAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java index 96f416bb9cf36..e197baa16c33b 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.KeyAttributes; /** @@ -84,8 +85,8 @@ public Builder withKeyOperations(List keyOperations) { * the key management attributes value to set. * @return the Builder object itself. */ - public Builder withAttributes(KeyAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (KeyAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java index 56f04bd98a454..431c595ca9709 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificatePolicy; import com.microsoft.azure.keyvault.models.IssuerReference; @@ -89,8 +90,8 @@ public Builder withPolicy(CertificatePolicy policy) { * The attributes of the certificate. * @return the Builder object itself. */ - public Builder withAttributes(CertificateAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (CertificateAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java index 8fb02162ff3da..b644554936253 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; @@ -71,8 +72,8 @@ public Builder withHsm(boolean isHsm) { * the key management attributes value to set * @return the Builder object itself. */ - public Builder withAttributes(KeyAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (KeyAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java index 9ad223c6a4816..1a1569e41d97c 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/MergeCertificateRequest.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; /** @@ -54,8 +55,8 @@ public Builder(String vaultBaseUrl, String certificateName, List x509Cer * The attributes of the certificate. * @return the Builder object itself. */ - public Builder withAttributes(CertificateAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (CertificateAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java index a34c08d296f73..2bfa1cc3c6bc4 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetSecretRequest.java @@ -3,6 +3,7 @@ import java.util.Collections; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.SecretAttributes; /** @@ -66,8 +67,8 @@ public Builder withContentType(String contentType) { * The secret management attributes. * @return the Builder object itself. */ - public Builder withAttributes(SecretAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (SecretAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java index 407b4c1407d27..b1403613b462d 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.Map; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificatePolicy; import com.microsoft.azure.keyvault.models.IssuerReference; @@ -11,7 +12,6 @@ import com.microsoft.azure.keyvault.models.LifetimeAction; import com.microsoft.azure.keyvault.models.SecretProperties; import com.microsoft.azure.keyvault.models.X509CertificateProperties; -import com.microsoft.azure.keyvault.requests.CreateCertificateRequest.Builder; /** * The update certificate request class. @@ -84,8 +84,8 @@ public Builder withPolicy(CertificatePolicy certificatePolicy) { * The attributes of the certificate. * @return the Builder object itself. */ - public Builder withAttributes(CertificateAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (CertificateAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java index d87b8c798c583..bad0b37d43b75 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java @@ -6,6 +6,7 @@ import java.util.Map; import com.microsoft.azure.keyvault.KeyIdentifier; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.KeyAttributes; /** @@ -94,8 +95,8 @@ public Builder withKeyOperations(List keyOperations) { * the key management attributes value to set * @return the Builder object itself. */ - public Builder withAttributes(KeyAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (KeyAttributes) attributes; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java index 732aa8843ae33..e56f9f7713e28 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateSecretRequest.java @@ -4,6 +4,7 @@ import java.util.Map; import com.microsoft.azure.keyvault.SecretIdentifier; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.SecretAttributes; /** @@ -89,8 +90,8 @@ public Builder withContentType(String contentType) { * The secret management attributes. * @return the Builder object itself. */ - public Builder withAttributes(SecretAttributes attributes) { - this.attributes = attributes; + public Builder withAttributes(Attributes attributes) { + this.attributes = (SecretAttributes) attributes; return this; } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index 85839d816a2aa..18a13e9423e9b 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -57,8 +57,10 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.keyvault.CertificateIdentifier; +import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.azure.keyvault.models.AdministratorDetails; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificateBundle; import com.microsoft.azure.keyvault.models.Contact; @@ -66,6 +68,7 @@ import com.microsoft.azure.keyvault.models.IssuerBundle; import com.microsoft.azure.keyvault.models.IssuerCredentials; import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.OrganizationDetails; import com.microsoft.azure.keyvault.models.CertificateItem; @@ -143,8 +146,8 @@ public void createSelfSignedCertificatePkcs12() throws Exception { .withIssuerReference(issuerReference) .withX509CertificateProperties(x509Properties); - CertificateAttributes attribute = (CertificateAttributes) new CertificateAttributes() - .withEnabled(false) + Attributes attribute = new CertificateAttributes() + .withEnabled(true) .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); @@ -177,7 +180,13 @@ public void createSelfSignedCertificatePkcs12() throws Exception { // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + Assert.assertTrue(secret.managed()); + // Retrieve the key backing the certificate + KeyIdentifier keyIdentifier = certificateBundle.keyIdentifier(); + KeyBundle keyBundle = keyVaultClient.getKey(keyIdentifier.baseIdentifier()).getBody(); + Assert.assertTrue(keyBundle.managed()); + // Load the secret into a KeyStore String secretPassword = ""; KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword); @@ -325,7 +334,8 @@ public void createCertificatePkcs12() throws Exception { // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - + Assert.assertTrue(secret.managed()); + // Load the secret into a KeyStore String secretPassword = ""; KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword); @@ -538,7 +548,7 @@ public void importCertificatePkcs12() throws Exception { // Set content type to indicate the certificate is PKCS12 format. SecretProperties secretProperties = new SecretProperties().withContentType(MIME_PKCS12); CertificatePolicy certificatePolicy = new CertificatePolicy().withSecretProperties(secretProperties); - CertificateAttributes attribute = (CertificateAttributes) new CertificateAttributes().withEnabled(true); + Attributes attribute = new CertificateAttributes().withEnabled(true); String vaultUri = getVaultUri(); String certificateName = "importCertPkcs"; @@ -565,7 +575,8 @@ public void importCertificatePkcs12() throws Exception { // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); - + Assert.assertTrue(secret.managed()); + // Load the secret into a KeyStore String secretPassword = ""; KeyStore keyStore = loadSecretToKeyStore(secret, secretPassword); @@ -605,14 +616,13 @@ public void certificateUpdate() throws Exception { .build()).getBody(); - CertificateAttributes attribute = (CertificateAttributes) new CertificateAttributes() - .withEnabled(false) + Attributes attribute = new CertificateAttributes() .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); CertificateBundle updatedCertBundle = keyVaultClient.updateCertificate( new UpdateCertificateRequest .Builder(vaultUri, certificateName) - .withAttributes((CertificateAttributes) attribute.withEnabled(false)) + .withAttributes(attribute.withEnabled(false)) .withTags(sTags) .build()).getBody(); Assert.assertEquals(attribute.enabled(), updatedCertBundle.attributes().enabled()); @@ -1098,6 +1108,7 @@ private void validatePem(CertificateBundle certificateBundle, String subjectName // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + Assert.assertTrue(secret.managed()); String secretValue = secret.value(); // Extract private key from PEM diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index f227d9f5ca3cb..c4fd3b4d6209f 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -47,6 +47,7 @@ import com.microsoft.azure.keyvault.requests.CreateKeyRequest; import com.microsoft.azure.keyvault.requests.ImportKeyRequest; import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; @@ -68,7 +69,7 @@ public void transparentAuthentication() throws Exception { Map tags = new HashMap(); tags.put("foo", "baz"); List keyOps = Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT); - KeyAttributes attribute = (KeyAttributes) new KeyAttributes() + Attributes attribute = new KeyAttributes() .withEnabled(true) .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); @@ -108,7 +109,7 @@ public void importKeyOperation() throws Exception { } private void checkImportOperation(KeyBundle keyBundle, boolean importToHardware) throws Exception { - KeyAttributes attribute = (KeyAttributes) new KeyAttributes() + Attributes attribute = new KeyAttributes() .withEnabled(true) .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); @@ -546,7 +547,7 @@ private static KeyPair getWellKnownKey() throws Exception { return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); } - private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops, KeyAttributes attributes) throws Exception { + private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops, Attributes attributes) throws Exception { String prefix = vault + "/keys/" + keyName + "/"; String kid = bundle.key().kid(); Assert.assertTrue( @@ -562,6 +563,8 @@ private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String Assert.assertNotNull("\"updated\" should not be null.", bundle.attributes().updated()); compareAttributes(attributes, bundle.attributes()); + + Assert.assertTrue(bundle.managed() == null || bundle.managed() == false); } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index 7378e9ebc9bee..1673ded8ff130 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -25,6 +25,7 @@ import org.junit.Assert; import org.junit.Test; +import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.SecretAttributes; import com.microsoft.azure.keyvault.models.SecretBundle; @@ -46,7 +47,7 @@ public void transparentAuthentication() throws Exception { // Create a secret on a vault. { - SecretAttributes attributes = (SecretAttributes) new SecretAttributes() + Attributes attributes = new SecretAttributes() .withEnabled(true) .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); @@ -271,7 +272,7 @@ public void listSecretVersions() throws Exception { keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME); } - private static void validateSecret(SecretBundle secret, String vault, String name, String value, String contentType, SecretAttributes attributes) throws Exception { + private static void validateSecret(SecretBundle secret, String vault, String name, String value, String contentType, Attributes attributes) throws Exception { String prefix = vault + "/secrets/" + name + "/"; String id = secret.id(); Assert.assertTrue( // @@ -285,6 +286,8 @@ private static void validateSecret(SecretBundle secret, String vault, String nam Assert.assertNotNull("\"updated\" should not be null.", secret.attributes().updated()); compareAttributes(attributes, secret.attributes()); + + Assert.assertTrue(secret.managed() == null || secret.managed() == false); } private void compareSecrets(SecretBundle expected, SecretBundle actual) { @@ -296,6 +299,7 @@ private void compareSecrets(SecretBundle expected, SecretBundle actual) { Assert.assertEquals(expected.attributes().notBefore(), actual.attributes().notBefore()); if(expected.tags() != null || actual.tags() != null) Assert.assertTrue(expected.tags().equals(actual.tags())); + } } From 4612ba66b0850f52faec4c53b86f408ba555ba60 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Mon, 22 Aug 2016 13:46:46 -0700 Subject: [PATCH 25/56] Crypto test cases for excess key material support to match .NET --- .../keyvault/cryptography/Algorithm.java | 25 +++ .../cryptography/algorithms/Aes128Cbc.java | 50 +++++ .../cryptography/algorithms/Aes192Cbc.java | 51 +++++ .../cryptography/algorithms/Aes256Cbc.java | 51 +++++ .../cryptography/algorithms/AesKw128.java | 19 +- .../cryptography/algorithms/AesKw192.java | 19 +- .../cryptography/algorithms/AesKw256.java | 19 +- .../cryptography/test/AesCbcTest.java | 185 +++++++++++++++--- .../keyvault/cryptography/test/AesKwTest.java | 178 +++++++++++++++++ .../test/SymmetricKeyBCProviderTest.java | 2 +- .../test/SymmetricKeyDefaultProviderTest.java | 29 --- ...KeyBaseTest.java => SymmetricKeyTest.java} | 173 +++++++++++++++- 12 files changed, 719 insertions(+), 82 deletions(-) delete mode 100755 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java rename azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/{SymmetricKeyBaseTest.java => SymmetricKeyTest.java} (69%) diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java index bfdcf9e54e790..127521c7d4373 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java @@ -33,4 +33,29 @@ protected Algorithm(String name) { public String getName() { return _name; } + + /* + * Takes the first count bytes from the source and + * returns a new array containing those bytes. + * + * @param count The number of bytes to take. + * @param source The source of the bytes. + * @return count bytes from the source as a new array. + */ + public static byte[] Take(int count, byte[] source) + { + if ( source == null ) { + throw new IllegalArgumentException("source"); + } + + if ( count <= 0 || count > source.length ) { + throw new IllegalArgumentException("count"); + } + + byte[] target = new byte[count]; + + System.arraycopy(source, 0, target, 0, count); + + return target; + } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java index 206a463d5b7ef..c0a5630e8df6b 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java @@ -18,12 +18,62 @@ package com.microsoft.azure.keyvault.cryptography.algorithms; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; + public class Aes128Cbc extends AesCbc { public static final String AlgorithmName = "A128CBC"; + + static final int KeySizeInBytes = 128 >> 3; public Aes128Cbc() { super(AlgorithmName); } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java index 2cb0fc22b4d96..96b03caf970e0 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java @@ -18,12 +18,63 @@ package com.microsoft.azure.keyvault.cryptography.algorithms; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; + public class Aes192Cbc extends AesCbc { public static final String AlgorithmName = "A192CBC"; + + static final int KeySizeInBytes = 192 >> 3; public Aes192Cbc() { super(AlgorithmName); } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java index 91fb58e09c932..88abe788ee757 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java @@ -18,12 +18,63 @@ package com.microsoft.azure.keyvault.cryptography.algorithms; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.Provider; + +import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; + public class Aes256Cbc extends AesCbc { public static final String AlgorithmName = "A256CBC"; + + static final int KeySizeInBytes = 256 >> 3; public Aes256Cbc() { super(AlgorithmName); } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + } + + @Override + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + } + + @Override + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + + if (key == null || key.length < KeySizeInBytes) { + throw new InvalidKeyException("key must be at least 128 bits in length"); + } + + return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java index 5d7a15605aea6..2044f10895867 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java @@ -21,6 +21,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; +import java.security.Provider; import javax.crypto.NoSuchPaddingException; @@ -29,37 +30,39 @@ public final class AesKw128 extends AesKw { public static final String AlgorithmName = "A128KW"; + + static final int KeySizeInBytes = 128 >> 3; public AesKw128() { super(AlgorithmName); } @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("key must not be null"); } - if (key.length << 3 != 128) { - throw new IllegalArgumentException("key must be 128 bits long"); + if (key.length < KeySizeInBytes) { + throw new IllegalArgumentException("key must be at least 128 bits long"); } - return super.CreateEncryptor(key, iv); + return super.CreateEncryptor(Take(KeySizeInBytes,key), iv, provider); } @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("key must not be null"); } - if (key.length << 3 != 128) { - throw new IllegalArgumentException("key must be 128 bits long"); + if (key.length < KeySizeInBytes) { + throw new IllegalArgumentException("key must be at least 128 bits long"); } - return super.CreateDecryptor(key, iv); + return super.CreateDecryptor(Take(KeySizeInBytes,key), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java index f20f5ec7ee22c..bb652553ff83e 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java @@ -21,6 +21,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; +import java.security.Provider; import javax.crypto.NoSuchPaddingException; @@ -29,37 +30,39 @@ public final class AesKw192 extends AesKw { public static final String AlgorithmName = "A192KW"; + + static final int KeySizeInBytes = 192 >> 3; public AesKw192() { super(AlgorithmName); } @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("key must not be null"); } - if (key.length << 3 != 192) { - throw new IllegalArgumentException("key must be 192 bits long"); + if (key.length < KeySizeInBytes) { + throw new IllegalArgumentException("key must be at least 192 bits long"); } - return super.CreateEncryptor(key, iv); + return super.CreateEncryptor(Take(KeySizeInBytes,key), iv, provider); } @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("key must not be null"); } - if (key.length << 3 != 192) { - throw new IllegalArgumentException("key must be 192 bits long"); + if (key.length < KeySizeInBytes) { + throw new IllegalArgumentException("key must be at least 192 bits long"); } - return super.CreateDecryptor(key, iv); + return super.CreateDecryptor(Take(KeySizeInBytes,key), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java index c4b23a572c222..b2ed7dd4815f7 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java @@ -21,6 +21,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; +import java.security.Provider; import javax.crypto.NoSuchPaddingException; @@ -29,37 +30,39 @@ public final class AesKw256 extends AesKw { public static final String AlgorithmName = "A256KW"; + + static final int KeySizeInBytes = 256 >> 3; public AesKw256() { super(AlgorithmName); } @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("key must not be null"); } - if (key.length << 3 != 256) { - throw new IllegalArgumentException("key must be 256 bits long"); + if (key.length < KeySizeInBytes) { + throw new IllegalArgumentException("key must be at least 256 bits long"); } - return super.CreateEncryptor(key, iv); + return super.CreateEncryptor(Take(KeySizeInBytes,key), iv, provider); } @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("key must not be null"); } - if (key.length << 3 != 256) { - throw new IllegalArgumentException("key must be 256 bits long"); + if (key.length < KeySizeInBytes) { + throw new IllegalArgumentException("key must be at least 256 bits long"); } - return super.CreateDecryptor(key, iv); + return super.CreateDecryptor(Take(KeySizeInBytes,key), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java index 53286b5471690..6498b9508dff6 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java @@ -11,6 +11,7 @@ import org.junit.BeforeClass; import org.junit.Test; +import com.microsoft.azure.keyvault.cryptography.Algorithm; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; @@ -40,44 +41,130 @@ protected void setProvider(Provider provider) { } @Test - public void testAes128Cbc() { - // Arrange: These values are taken from Appendix B of the JWE - // specification at - // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B - // Since the values were intended for use with AES128-CBC-HMAC-SHA2 we - // actually take the realCEK from the second half of the CEK data below - // in order - // that the encrypted result will match the ED value from the example. - byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; - byte[] PLAIN = { 76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, 112, 114, 111, 115, 112, 101, 114, 46 }; - byte[] IV = { 3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101 }; - //byte[] AUTH = { 101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52, 83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66, 77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73, 110, 48 }; - byte[] ED = { 40, 57, 83, (byte) 181, 119, 33, (byte) 133, (byte) 148, (byte) 198, (byte) 185, (byte) 243, 24, (byte) 152, (byte) 230, 6, 75, (byte) 129, (byte) 223, 127, 19, (byte) 210, 82, (byte) 183, (byte) 230, (byte) 168, 33, (byte) 215, 104, (byte) 143, 112, 56, 102 }; - //byte[] TAG = { 83, 73, (byte) 191, 98, 104, (byte) 205, (byte) 211, (byte) 128, (byte) 201, (byte) 189, (byte) 199, (byte) 133, 32, 38, (byte) 194, 85 }; - - Aes128Cbc algo = new Aes128Cbc(); - byte[] realCEK = new byte[128 >> 3]; - byte[] encrypted = null; - - // Take the second half of CEK as the AES key - System.arraycopy(CEK, 128 >> 3, realCEK, 0, 128 >> 3); + public void testAes128CbcOneBlock() { + // Note that AES128CBC as implemented in this library uses PKCS7 padding mode where the test + // vectors from RFC3602 do not use padding. + byte[] CEK = { 0x06, (byte)0xa9, 0x21, 0x40, 0x36, (byte)0xb8, (byte)0xa1, 0x5b, 0x51, 0x2e, 0x03, (byte)0xd5, 0x34, 0x12, 0x00, 0x06 }; + byte[] PLAIN = "Single block msg".getBytes(); + byte[] IV = { 0x3d, (byte)0xaf, (byte)0xba, 0x42, (byte)0x9d, (byte)0x9e, (byte)0xb4, 0x30, (byte)0xb4, 0x22, (byte)0xda, (byte)0x80, 0x2c, (byte)0x9f, (byte)0xac, 0x41 }; + byte[] ED = { (byte)0xe3, 0x53, 0x77, (byte)0x9c, 0x10, 0x79, (byte)0xae, (byte)0xb8, 0x27, 0x08, (byte)0x94, 0x2d, (byte)0xbe, 0x77, 0x18, 0x1a }; + + Aes128Cbc algo = new Aes128Cbc(); + byte[] encrypted = null; + + ICryptoTransform encryptor = null; + try { + encryptor = algo.CreateEncryptor(CEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + encrypted = encryptor.doFinal(PLAIN); + + // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(16,encrypted),ED); + } catch (Exception e) { + fail(e.getMessage()); + } + + ICryptoTransform decryptor = null; + try { + decryptor = algo.CreateDecryptor(CEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(encrypted); + + // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(16, decrypted), PLAIN); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @Test + public void testAes128CbcTwoBlock() { + // Note that AES128CBC as implemented in this library uses PKCS7 padding mode where the test + // vectors do not use padding. + byte[] CEK = { (byte)0xc2, (byte)0x86, 0x69, 0x6d, (byte)0x88, 0x7c, (byte)0x9a, (byte)0xa0, 0x61, 0x1b, (byte)0xbb, 0x3e, 0x20, 0x25, (byte)0xa4, 0x5a }; + byte[] PLAIN = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; + byte[] IV = { 0x56, 0x2e, 0x17, (byte)0x99, 0x6d, 0x09, 0x3d, 0x28, (byte)0xdd, (byte)0xb3, (byte)0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 }; + byte[] ED = { (byte)0xd2, (byte)0x96, (byte)0xcd, (byte)0x94, (byte)0xc2, (byte)0xcc, (byte)0xcf, (byte)0x8a, 0x3a, (byte)0x86, 0x30, 0x28, (byte)0xb5, (byte)0xe1, (byte)0xdc, 0x0a, 0x75, (byte)0x86, 0x60, 0x2d, 0x25, 0x3c, (byte)0xff, (byte)0xf9, 0x1b, (byte)0x82, 0x66, (byte)0xbe, (byte)0xa6, (byte)0xd6, 0x1a, (byte)0xb1 }; + + Aes128Cbc algo = new Aes128Cbc(); + byte[] encrypted = null; + + ICryptoTransform encryptor = null; + try { + encryptor = algo.CreateEncryptor(CEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + encrypted = encryptor.doFinal(PLAIN); + + // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(32,encrypted),ED); + } catch (Exception e) { + fail(e.getMessage()); + } + + ICryptoTransform decryptor = null; + try { + decryptor = algo.CreateDecryptor(CEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(encrypted); + + // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(32, decrypted), PLAIN); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @Test + public void testAes128CbcOneBlock_ExcessKeyMaterial() { + // Note that AES128CBC as implemented in this library uses PKCS7 padding mode where the test + // vectors from RFC3602 do not use padding. + byte[] CEK = { 0x06, (byte)0xa9, 0x21, 0x40, 0x36, (byte)0xb8, (byte)0xa1, 0x5b, 0x51, 0x2e, 0x03, (byte)0xd5, 0x34, 0x12, 0x00, 0x06, (byte)0xc2, (byte)0x86, 0x69, 0x6d, (byte)0x88, 0x7c, (byte)0x9a, (byte)0xa0, 0x61, 0x1b, (byte)0xbb, 0x3e, 0x20, 0x25, (byte)0xa4, 0x5a }; + byte[] PLAIN = "Single block msg".getBytes(); + byte[] IV = { 0x3d, (byte)0xaf, (byte)0xba, 0x42, (byte)0x9d, (byte)0x9e, (byte)0xb4, 0x30, (byte)0xb4, 0x22, (byte)0xda, (byte)0x80, 0x2c, (byte)0x9f, (byte)0xac, 0x41 }; + byte[] ED = { (byte)0xe3, 0x53, 0x77, (byte)0x9c, 0x10, 0x79, (byte)0xae, (byte)0xb8, 0x27, 0x08, (byte)0x94, 0x2d, (byte)0xbe, 0x77, 0x18, 0x1a }; + + Aes128Cbc algo = new Aes128Cbc(); + byte[] encrypted = null; ICryptoTransform encryptor = null; try { - encryptor = algo.CreateEncryptor(realCEK, IV, null, _provider); + encryptor = algo.CreateEncryptor(CEK, IV, null, _provider); } catch (Exception e) { fail(e.getMessage()); } try { encrypted = encryptor.doFinal(PLAIN); + + // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(16,encrypted),ED); } catch (Exception e) { fail(e.getMessage()); } ICryptoTransform decryptor = null; try { - decryptor = algo.CreateDecryptor(realCEK, IV, null, _provider); + decryptor = algo.CreateDecryptor(CEK, IV, null, _provider); } catch (Exception e) { fail(e.getMessage()); } @@ -86,12 +173,58 @@ public void testAes128Cbc() { try { decrypted = decryptor.doFinal(encrypted); + + // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(16, decrypted), PLAIN); } catch (Exception e) { fail(e.getMessage()); } + } - // Assert - assertArrayEquals(PLAIN, decrypted); - assertArrayEquals(ED, encrypted); + @Test + public void testAes128CbcTwoBlock_ExcessKeyMaterial() { + // Note that AES128CBC as implemented in this library uses PKCS7 padding mode where the test + // vectors do not use padding. + byte[] CEK = { (byte)0xc2, (byte)0x86, 0x69, 0x6d, (byte)0x88, 0x7c, (byte)0x9a, (byte)0xa0, 0x61, 0x1b, (byte)0xbb, 0x3e, 0x20, 0x25, (byte)0xa4, 0x5a, (byte)0xc2, (byte)0x86, 0x69, 0x6d, (byte)0x88, 0x7c, (byte)0x9a, (byte)0xa0, 0x61, 0x1b, (byte)0xbb, 0x3e, 0x20, 0x25, (byte)0xa4, 0x5a }; + byte[] PLAIN = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; + byte[] IV = { 0x56, 0x2e, 0x17, (byte)0x99, 0x6d, 0x09, 0x3d, 0x28, (byte)0xdd, (byte)0xb3, (byte)0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 }; + byte[] ED = { (byte)0xd2, (byte)0x96, (byte)0xcd, (byte)0x94, (byte)0xc2, (byte)0xcc, (byte)0xcf, (byte)0x8a, 0x3a, (byte)0x86, 0x30, 0x28, (byte)0xb5, (byte)0xe1, (byte)0xdc, 0x0a, 0x75, (byte)0x86, 0x60, 0x2d, 0x25, 0x3c, (byte)0xff, (byte)0xf9, 0x1b, (byte)0x82, 0x66, (byte)0xbe, (byte)0xa6, (byte)0xd6, 0x1a, (byte)0xb1 }; + + Aes128Cbc algo = new Aes128Cbc(); + byte[] encrypted = null; + + ICryptoTransform encryptor = null; + try { + encryptor = algo.CreateEncryptor(CEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + encrypted = encryptor.doFinal(PLAIN); + + // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(32,encrypted),ED); + } catch (Exception e) { + fail(e.getMessage()); + } + + ICryptoTransform decryptor = null; + try { + decryptor = algo.CreateDecryptor(CEK, IV, null, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(encrypted); + + // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding + assertArrayEquals(Algorithm.Take(32, decrypted), PLAIN); + } catch (Exception e) { + fail(e.getMessage()); + } } } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java index d22e2107ce6ef..e79e5569fe71c 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesKwTest.java @@ -248,4 +248,182 @@ public void KeyVault_AesKw256() { } } + @Test + public void KeyVault_AesKw128_ExcessKeyMaterial() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte)0x88, (byte)0x99, (byte)0xAA, (byte)0xBB, (byte)0xCC, (byte)0xDD, (byte)0xEE, (byte)0xFF }; + byte[] EK = { 0x1F, (byte)0xA6, (byte)0x8B, 0x0A, (byte)0x81, 0x12, (byte)0xB4, 0x47, (byte)0xAE, (byte)0xF3, 0x4B, (byte)0xD8, (byte)0xFB, 0x5A, 0x7B, (byte)0x82, (byte)0x9D, 0x3E, (byte)0x86, 0x23, 0x71, (byte)0xD2, (byte)0xCF, (byte)0xE5 }; + + AesKw kw = new AesKw128(); + + ICryptoTransform encryptor = null; + + try { + encryptor = kw.CreateEncryptor(KEK, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] encrypted = null; + + try { + encrypted = encryptor.doFinal(CEK); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + + ICryptoTransform decryptor = null; + + try { + decryptor = kw.CreateDecryptor(KEK, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(EK); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + @Test + public void KeyVault_AesKw192_ExcessKeyMaterial() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { (byte) 0x96, 0x77, (byte) 0x8B, 0x25, (byte) 0xAE, 0x6C, (byte) 0xA4, 0x35, (byte) 0xF9, 0x2B, 0x5B, (byte) 0x97, (byte) 0xC0, 0x50, (byte) 0xAE, (byte) 0xD2, 0x46, (byte) 0x8A, (byte) 0xB8, (byte) 0xA1, 0x7A, (byte) 0xD8, 0x4E, 0x5D }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + AesKw kw = new AesKw192(); + + ICryptoTransform encryptor = null; + + try { + encryptor = kw.CreateEncryptor(KEK, _provider); + + if (!unlimited) fail("Expected InvalidKeyException"); + } catch (InvalidKeyException e) { + if (unlimited) fail("InvalidKeyException"); + } catch (Exception e) { + fail(e.getMessage()); + } + + if (unlimited) { + byte[] encrypted = null; + + try { + encrypted = encryptor.doFinal(CEK); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + + ICryptoTransform decryptor = null; + + try { + decryptor = kw.CreateDecryptor(KEK, _provider); + if (!unlimited) fail("Expected InvalidKeyException"); + } catch (InvalidKeyException e) { + if (unlimited) fail("InvalidKeyException"); + } catch (Exception e) { + fail(e.getMessage()); + } + + if (unlimited) { + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(EK); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + } + + @Test + public void KeyVault_AesKw256_ExcessKeyMaterial() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte) 0xE8, (byte) 0xC3, (byte) 0xF9, (byte) 0xCE, 0x0F, 0x5B, (byte) 0xA2, 0x63, (byte) 0xE9, 0x77, 0x79, 0x05, (byte) 0x81, (byte) 0x8A, 0x2A, (byte) 0x93, (byte) 0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte) 0x8A, (byte) 0xE7 }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + AesKw kw = new AesKw256(); + + ICryptoTransform encryptor = null; + + try { + encryptor = kw.CreateEncryptor(KEK, _provider); + if (!unlimited) fail("Expected InvalidKeyException"); + } catch (InvalidKeyException e) { + if (unlimited) fail("InvalidKeyException"); + } catch (Exception e) { + fail(e.getMessage()); + } + + if (unlimited) { + byte[] encrypted = null; + + try { + encrypted = encryptor.doFinal(CEK); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(EK, encrypted); + } + + ICryptoTransform decryptor = null; + + try { + decryptor = kw.CreateDecryptor(KEK, _provider); + + if (!unlimited) fail("Expected InvalidKeyException"); + } catch (InvalidKeyException e) { + if (unlimited) fail("InvalidKeyException"); + } catch (Exception e) { + fail(e.getMessage()); + } + + if (unlimited) { + byte[] decrypted = null; + + try { + decrypted = decryptor.doFinal(EK); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + } + } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java index a6a7936c9fa65..2954df416105f 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBCProviderTest.java @@ -21,7 +21,7 @@ import java.security.Provider; import org.junit.Before; -public class SymmetricKeyBCProviderTest extends SymmetricKeyBaseTest { +public class SymmetricKeyBCProviderTest extends SymmetricKeyTest { @Before public void setUp() throws Exception { diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java deleted file mode 100755 index 384961ad2e643..0000000000000 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyDefaultProviderTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.cryptography.test; - -import org.junit.Before; - -public class SymmetricKeyDefaultProviderTest extends SymmetricKeyBaseTest { - - @Before - public void setUp() throws Exception { - super.setProvider(null); - } -} diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyTest.java similarity index 69% rename from azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java rename to azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyTest.java index 36b6bf464aa16..b6d3194cae058 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyBaseTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/SymmetricKeyTest.java @@ -37,7 +37,7 @@ import com.microsoft.azure.keyvault.cryptography.SymmetricKey; -public abstract class SymmetricKeyBaseTest { +public class SymmetricKeyTest { private Provider _provider = null; @@ -58,7 +58,9 @@ public static void tearDownAfterClass() throws Exception { } @Before - public abstract void setUp() throws Exception; + public void setUp() throws Exception { + setProvider(null); + } @After public void tearDown() throws Exception { @@ -420,4 +422,171 @@ public void testSymmetricKeyDefaultAlgorithmAesKw256() { } } + @Test + public void testSymmetricKeyAesKw128_ExcessKeyMaterial() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte)0x88, (byte)0x99, (byte)0xAA, (byte)0xBB, (byte)0xCC, (byte)0xDD, (byte)0xEE, (byte)0xFF }; + byte[] EK = { 0x1F, (byte)0xA6, (byte)0x8B, 0x0A, (byte)0x81, 0x12, (byte)0xB4, 0x47, (byte)0xAE, (byte)0xF3, 0x4B, (byte)0xD8, (byte)0xFB, 0x5A, 0x7B, (byte)0x82, (byte)0x9D, 0x3E, (byte)0x86, 0x23, 0x71, (byte)0xD2, (byte)0xCF, (byte)0xE5 }; + + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A128KW").get().getLeft(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A128KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyAesKw192_ExcessKeyMaterial() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte)0x88, (byte)0x99, (byte)0xAA, (byte)0xBB, (byte)0xCC, (byte)0xDD, (byte)0xEE, (byte)0xFF }; + byte[] EK = { (byte)0x96, 0x77, (byte)0x8B, 0x25, (byte)0xAE, 0x6C, (byte)0xA4, 0x35, (byte)0xF9, 0x2B, 0x5B, (byte)0x97, (byte)0xC0, 0x50, (byte)0xAE, (byte)0xD2, 0x46, (byte)0x8A, (byte)0xB8, (byte)0xA1, 0x7A, (byte)0xD8, 0x4E, 0x5D }; + + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A192KW").get().getLeft(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A192KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } + + @Test + public void testSymmetricKeyAesKw256_ExcessKeyMaterial() { + // Arrange + byte[] KEK = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + byte[] EK = { 0x64, (byte)0xE8, (byte)0xC3, (byte)0xF9, (byte)0xCE, 0x0F, 0x5B, (byte)0xA2, 0x63, (byte)0xE9, 0x77, 0x79, 0x05, (byte)0x81, (byte)0x8A, 0x2A, (byte)0x93, (byte)0xC8, 0x19, 0x1E, 0x7D, 0x6E, (byte)0x8A, (byte)0xE7 }; + + /* + * This test using the default JCE provider depends on whether unlimited security + * is installed or not. In the unlimited case, the full test should pass but in + * the limited case, it should fail with InvalidKeyException. + */ + boolean unlimited = hasUnlimitedCrypto(); + SymmetricKey key = new SymmetricKey("KEK", KEK, _provider); + + byte[] encrypted = null; + + try { + encrypted = key.wrapKeyAsync(CEK, "A256KW").get().getLeft(); + + if (!unlimited) fail("Expected ExecutionException"); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + // In the limited case, the failure should be InvalidKeyException + // In the unlimited case, this should not fail + if (!unlimited) { + Throwable cause = e.getCause(); + if (cause == null || !(cause instanceof InvalidKeyException)) fail("ExecutionException"); + } else { + fail("ExecutionException"); + } + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + if (unlimited) { + // Assert + assertArrayEquals(EK, encrypted); + + byte[] decrypted = null; + + try { + decrypted = key.unwrapKeyAsync(EK, "A256KW").get(); + } catch (InterruptedException e) { + fail("InterrupedException"); + } catch (ExecutionException e) { + fail("ExecutionException"); + } catch (NoSuchAlgorithmException e) { + fail("NoSuchAlgorithmException"); + } + + // Assert + assertArrayEquals(CEK, decrypted); + } + + try { + key.close(); + } catch (IOException e) { + fail("Key could not be closed"); + } + } } From 87af588e5373dca6945472b6a4071f6cd5c8562e Mon Sep 17 00:00:00 2001 From: Pooneh Date: Tue, 23 Aug 2016 11:25:18 -0700 Subject: [PATCH 26/56] Refactoring JSON web key to KV webkey project --- azure-keyvault-cryptography/pom.xml | 61 ++- .../test/Base64UrlDeserializer.java | 43 --- .../cryptography/test/JsonWebKey.java | 346 ------------------ .../cryptography/test/JsonWebKeyType.java | 40 -- .../cryptography/test/RsaKeyTest.java | 1 + azure-keyvault-extensions/pom.xml | 5 + .../keyvault/extensions/KeyVaultKey.java | 2 +- azure-keyvault-webkey/pom.xml | 104 ++++++ .../webkey/Base64UrlJsonDeserializer.java | 34 ++ .../webkey/Base64UrlJsonSerializer.java | 25 +- .../azure/keyvault/webkey}/JsonWebKey.java | 337 ++++++++--------- .../webkey/JsonWebKeyEncryptionAlgorithm.java | 18 +- .../keyvault/webkey/JsonWebKeyOperation.java | 18 +- .../webkey/JsonWebKeySignatureAlgorithm.java | 18 +- .../azure/keyvault/webkey/JsonWebKeyType.java | 18 +- .../azure/keyvault/webkey/package-info.java | 3 +- azure-keyvault/pom.xml | 5 + .../azure/keyvault/KeyVaultClientImpl.java | 4 +- .../azure/keyvault/models/KeyBundle.java | 1 + .../keyvault/models/KeyImportParameters.java | 1 + .../keyvault/requests/ImportKeyRequest.java | 2 +- .../keyvault/test/AsyncOperationsTest.java | 44 ++- .../keyvault/test/KeyOperationsTest.java | 2 +- 23 files changed, 395 insertions(+), 737 deletions(-) delete mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java delete mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java delete mode 100644 azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java create mode 100644 azure-keyvault-webkey/pom.xml create mode 100644 azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java rename azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java => azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java (50%) rename {azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models => azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey}/JsonWebKey.java (60%) rename {azure-keyvault => azure-keyvault-webkey}/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java (54%) rename {azure-keyvault => azure-keyvault-webkey}/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java (63%) rename {azure-keyvault => azure-keyvault-webkey}/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java (59%) rename {azure-keyvault => azure-keyvault-webkey}/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java (58%) rename {azure-keyvault => azure-keyvault-webkey}/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java (58%) diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index 5b7688e30a0db..b3e1236542df2 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -34,40 +34,35 @@ HEAD - - UTF-8 - - - true - + + UTF-8 + + + true + - - - junit - junit - test - - - org.bouncycastle - bcprov-jdk15on - test - 1.54 - - + + + junit + junit + test + + + org.bouncycastle + bcprov-jdk15on + test + 1.54 + + ${project.groupId} - azure-keyvault-core - ${project.version} - - - com.fasterxml.jackson.core - jackson-databind - test - - - commons-codec - commons-codec - test - - + azure-keyvault-core + ${project.version} + + + ${project.groupId} + azure-keyvault-webkey + ${project.version} + + diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java deleted file mode 100644 index 8f54e8cdece21..0000000000000 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlDeserializer.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.cryptography.test; - -import java.io.IOException; - -import org.apache.commons.codec.binary.Base64; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; - -public class Base64UrlDeserializer extends JsonDeserializer { - - static final Base64 _base64 = new Base64(-1, null, true); - - @Override - public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { - String text = jp.getText(); - if (text != null) { - return _base64.decode(text); - } - return null; - } - -} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java deleted file mode 100644 index ec65f0d6fea55..0000000000000 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKey.java +++ /dev/null @@ -1,346 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.cryptography.test; - -import java.io.IOException; -import java.math.BigInteger; -import java.security.GeneralSecurityException; -import java.security.KeyFactory; -import java.security.KeyPair; -import java.security.PrivateKey; -import java.security.Provider; -import java.security.PublicKey; -import java.security.interfaces.RSAPrivateCrtKey; -import java.security.interfaces.RSAPublicKey; -import java.security.spec.RSAPrivateCrtKeySpec; -import java.security.spec.RSAPrivateKeySpec; -import java.security.spec.RSAPublicKeySpec; -import java.util.Arrays; - -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; - -@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY) -public class JsonWebKey { - - private String kid; - - @JsonProperty("kid") - public String getKid() { - return kid; - } - - public void setKid(String kid) { - this.kid = kid; - } - - private String kty; - - @JsonProperty("kty") - public String getKty() { - return kty; - } - - public void setKty(String kty) { - this.kty = kty; - } - - private String[] keyOps; - - @JsonProperty("key_ops") - public String[] getKeyOps() { - return keyOps; - } - - public void setKeyOps(String[] keyOps) { - this.keyOps = keyOps; - } - - private byte[] n; - - @JsonProperty("n") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getN() { - return n; - } - - public void setN(byte[] n) { - this.n = n; - } - - private byte[] e; - - @JsonProperty("e") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getE() { - return e; - } - - public void setE(byte[] e) { - this.e = e; - } - - private byte[] d; - - @JsonProperty("d") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getD() { - return d; - } - - public void setD(byte[] d) { - this.d = d; - } - - private byte[] dp; - - @JsonProperty("dp") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getDP() { - return dp; - } - - public void setDP(byte[] dp) { - this.dp = dp; - } - - private byte[] dq; - - @JsonProperty("dq") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getDQ() { - return dq; - } - - public void setDQ(byte[] dq) { - this.dq = dq; - } - - private byte[] qi; - - @JsonProperty("qi") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getQI() { - return qi; - } - - public void setQI(byte[] qi) { - this.qi = qi; - } - - private byte[] p; - - @JsonProperty("p") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getP() { - return p; - } - - public void setP(byte[] p) { - this.p = p; - } - - private byte[] q; - - @JsonProperty("q") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getQ() { - return q; - } - - public void setQ(byte[] q) { - this.q = q; - } - - private byte[] k; - - @JsonProperty("k") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getk() { - return k; - } - - public void setK(byte[] k) { - this.k = k; - } - - private byte[] t; - - @JsonProperty("key_hsm") - @JsonSerialize(using = Base64UrlSerializer.class) - @JsonDeserialize(using = Base64UrlDeserializer.class) - public byte[] getT() { - return t; - } - - public void setT(byte[] t) { - this.t = t; - } - - @Override - public String toString() { - ObjectMapper mapper = new ObjectMapper(); - try { - return mapper.writeValueAsString(this); - } catch (JsonGenerationException e) { - throw new IllegalStateException(e); - } catch (JsonMappingException e) { - throw new IllegalStateException(e); - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - - private RSAPublicKeySpec getRSAPublicKeySpec() { - - return new RSAPublicKeySpec(toBigInteger(n), toBigInteger(e)); - } - - private RSAPrivateKeySpec getRSAPrivateKeySpec() { - - return new RSAPrivateCrtKeySpec(toBigInteger(n), toBigInteger(e), toBigInteger(d), toBigInteger(p), toBigInteger(q), toBigInteger(dp), toBigInteger(dq), toBigInteger(qi)); - } - - private PublicKey getRSAPublicKey(Provider provider) { - - try { - RSAPublicKeySpec publicKeySpec = getRSAPublicKeySpec(); - KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider) : KeyFactory.getInstance("RSA"); - - return factory.generatePublic(publicKeySpec); - } catch (GeneralSecurityException e) { - throw new IllegalStateException(e); - } - } - - private PrivateKey getRSAPrivateKey(Provider provider) { - - try { - RSAPrivateKeySpec privateKeySpec = getRSAPrivateKeySpec(); - KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider) : KeyFactory.getInstance("RSA"); - - return factory.generatePrivate(privateKeySpec); - } catch (GeneralSecurityException e) { - throw new IllegalStateException(e); - } - } - - private void checkRSACompatible() { - if (!JsonWebKeyType.RSA.equals(kty) && !JsonWebKeyType.RSAHSM.equals(kty)) { - throw new UnsupportedOperationException("Not an RSA key"); - } - } - - private static byte[] toByteArray(BigInteger n) { - byte[] result = n.toByteArray(); - if (result[0] == 0) { - // The leading zero is used to let the number positive. Since RSA - // parameters are always positive, we remove it. - return Arrays.copyOfRange(result, 1, result.length); - } - return result; - } - - private static BigInteger toBigInteger(byte[] b) { - if (b[0] < 0) { - // RSA parameters are always positive numbers, so if the first byte - // is negative, we need to add a leading zero - // to make the entire BigInteger positive. - byte[] temp = new byte[1 + b.length]; - System.arraycopy(b, 0, temp, 1, b.length); - b = temp; - } - return new BigInteger(b); - } - - public static JsonWebKey fromRSA(KeyPair keyPair) { - - RSAPrivateCrtKey privateKey = (RSAPrivateCrtKey) keyPair.getPrivate(); - JsonWebKey key = null; - - if (privateKey != null) { - - key = new JsonWebKey(); - - key.setKty(JsonWebKeyType.RSA); - - key.setN(toByteArray(privateKey.getModulus())); - key.setE(toByteArray(privateKey.getPublicExponent())); - key.setD(toByteArray(privateKey.getPrivateExponent())); - key.setP(toByteArray(privateKey.getPrimeP())); - key.setQ(toByteArray(privateKey.getPrimeQ())); - key.setDP(toByteArray(privateKey.getPrimeExponentP())); - key.setDQ(toByteArray(privateKey.getPrimeExponentQ())); - key.setQI(toByteArray(privateKey.getCrtCoefficient())); - } else { - - RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); - - key = new JsonWebKey(); - - key.setKty(JsonWebKeyType.RSA); - - key.setN(toByteArray(publicKey.getModulus())); - key.setE(toByteArray(publicKey.getPublicExponent())); - key.setD(null); - key.setP(null); - key.setQ(null); - key.setDP(null); - key.setDQ(null); - key.setQI(null); - } - - return key; - } - - public KeyPair toRSA() { - return this.toRSA(false); - } - - public KeyPair toRSA(boolean includePrivateParameters) { - - return toRSA(includePrivateParameters, null); - } - - public KeyPair toRSA(boolean includePrivateParameters, Provider provider) { - - // Must be RSA - checkRSACompatible(); - - if (includePrivateParameters) { - return new KeyPair(getRSAPublicKey(provider), getRSAPrivateKey(provider)); - } else { - return new KeyPair(getRSAPublicKey(provider), null); - } - } -} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java deleted file mode 100644 index f3b1760652637..0000000000000 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/JsonWebKeyType.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.microsoft.azure.keyvault.cryptography.test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * Supported JsonWebKey key types (kty) - */ -public final class JsonWebKeyType { - - public static final String EC = "EC"; - public static final String RSA = "RSA"; - public static final String RSAHSM = "RSA-HSM"; - public static final String OCT = "oct"; - - public static final List ALL_TYPES = Collections.unmodifiableList(Arrays.asList(new String[] { EC, RSA, RSAHSM, OCT })); - - private JsonWebKeyType() { - // not instantiable - } -} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java index 7c9b29b956bd5..454752d7bac8b 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -19,6 +19,7 @@ import com.microsoft.azure.keyvault.cryptography.algorithms.Rs256; import com.microsoft.azure.keyvault.cryptography.algorithms.Rsa15; import com.microsoft.azure.keyvault.cryptography.algorithms.RsaOaep; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; public class RsaKeyTest { diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 3c9f92ea238a1..36d1dc3668e0a 100755 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -81,6 +81,11 @@ azure-keyvault ${project.version} + + ${project.groupId} + azure-keyvault-webkey + ${project.version} + org.mockito mockito-core diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index c33fb8eefbabe..2ef3291cfca3a 100755 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -29,7 +29,7 @@ import com.microsoft.azure.keyvault.KeyVaultClient; import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.cryptography.RsaKey; -import com.microsoft.azure.keyvault.models.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml new file mode 100644 index 0000000000000..698622c6d1fe0 --- /dev/null +++ b/azure-keyvault-webkey/pom.xml @@ -0,0 +1,104 @@ + + + 4.0.0 + + com.microsoft.azure + azure-parent + 1.0.0-SNAPSHOT + ../pom.xml + + + azure-keyvault-webkey + jar + + Microsoft Azure SDK for Key Vault WebKey + This package contains Microsoft Azure Key Vault WebKey library. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + UTF-8 + + + + + + microsoft + Microsoft + + + + + + + com.fasterxml.jackson.core + jackson-databind + + + commons-codec + commons-codec + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + com.microsoft.schemas._2003._10.serialization; + /** +
* Copyright (c) Microsoft Corporation. All rights reserved. +
* Licensed under the MIT License. See License.txt in the project root for +
* license information. +
*/]]>
+
+
+ +
+
+
diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java new file mode 100644 index 0000000000000..18967a8863809 --- /dev/null +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.keyvault.webkey; + +import java.io.IOException; + +import org.apache.commons.codec.binary.Base64; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; + +/** + * The base64 URL JSON deserializer. + */ +public class Base64UrlJsonDeserializer extends JsonDeserializer { + + static final Base64 _base64 = new Base64(-1, null, true); + + @Override + public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + String text = jp.getText(); + if (text != null) { + return _base64.decode(text); + } + return null; + } + +} \ No newline at end of file diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java similarity index 50% rename from azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java index 3cf15e392863d..3613a1aa79199 100644 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/Base64UrlSerializer.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java @@ -1,22 +1,10 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ -package com.microsoft.azure.keyvault.cryptography.test; +package com.microsoft.azure.keyvault.webkey; import java.io.IOException; @@ -27,7 +15,10 @@ import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; -public class Base64UrlSerializer extends JsonSerializer { +/** + * The base64 URL JSON serializer. + */ +public class Base64UrlJsonSerializer extends JsonSerializer { static final Base64 _base64 = new Base64(-1, null, true); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java similarity index 60% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java index ef267481ebba1..e6670116cf5e4 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/JsonWebKey.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java @@ -1,14 +1,10 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. + * license information. */ -package com.microsoft.azure.keyvault.models; +package com.microsoft.azure.keyvault.webkey; import java.io.IOException; import java.math.BigInteger; @@ -16,6 +12,7 @@ import java.security.KeyFactory; import java.security.KeyPair; import java.security.PrivateKey; +import java.security.Provider; import java.security.PublicKey; import java.security.interfaces.RSAPrivateCrtKey; import java.security.interfaces.RSAPublicKey; @@ -24,18 +21,21 @@ import java.security.spec.RSAPublicKeySpec; import java.util.Arrays; import java.util.List; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; -import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; -import com.microsoft.rest.Base64Url; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; /** * As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18. */ +@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY, setterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY) public class JsonWebKey { + /** * Key Identifier. */ @@ -50,73 +50,72 @@ public class JsonWebKey { /** * The keyOps property. */ - @JsonProperty(value = "key_ops") private List keyOps; /** * RSA modulus. */ - private Base64Url n; + private byte[] n; /** * RSA public exponent. */ - private Base64Url e; + private byte[] e; /** * RSA private exponent. */ - private Base64Url d; + private byte[] d; /** * RSA Private Key Parameter. */ - private Base64Url dp; + private byte[] dp; /** * RSA Private Key Parameter. */ - private Base64Url dq; + private byte[] dq; /** * RSA Private Key Parameter. */ - private Base64Url qi; + private byte[] qi; /** * RSA secret prime. */ - private Base64Url p; + private byte[] p; /** * RSA secret prime, with p < q. */ - private Base64Url q; + private byte[] q; /** * Symmetric key. */ - private Base64Url k; + private byte[] k; /** * HSM Token, used with Bring Your Own Key. */ - @JsonProperty(value = "key_hsm") - private Base64Url t; + private byte[] t; /** - * Get the kid value. + * Key Identifier. * - * @return the kid value + * @return the kid value. */ + @JsonProperty("kid") public String kid() { return this.kid; } /** - * Set the kid value. + * Set the key identifier value. * - * @param kid the kid value to set + * @param kid the key identifier * @return the JsonWebKey object itself. */ public JsonWebKey withKid(String kid) { @@ -125,18 +124,20 @@ public JsonWebKey withKid(String kid) { } /** - * Get the kty value. + * Key type, usually RSA. Possible values include: 'EC', 'RSA', 'RSA-HSM', + * 'oct'. * - * @return the kty value + * @return the key type. */ + @JsonProperty("kty") public String kty() { return this.kty; } /** - * Set the kty value. + * Set the key type value. * - * @param kty the kty value to set + * @param kty the key type * @return the JsonWebKey object itself. */ public JsonWebKey withKty(String kty) { @@ -145,18 +146,19 @@ public JsonWebKey withKty(String kty) { } /** - * Get the keyOps value. + * Get the key operations. * - * @return the keyOps value + * @return the key operations. */ + @JsonProperty("key_ops") public List keyOps() { return this.keyOps; } /** - * Set the keyOps value. + * Set the key operations value. * - * @param keyOps the keyOps value to set + * @param keyOps the key operations value to set * @return the JsonWebKey object itself. */ public JsonWebKey withKeyOps(List keyOps) { @@ -165,279 +167,222 @@ public JsonWebKey withKeyOps(List keyOps) { } /** - * Get the n value. + * Get the RSA modulus value. * - * @return the n value + * @return the RSA modulus value. */ + @JsonProperty("n") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] n() { - if (this.n == null) { - return null; - } - return this.n.getDecodedBytes(); + return this.n; } /** - * Set the n value. + * Set the RSA modulus value. * - * @param n the n value to set + * @param n the RSA modulus value to set * @return the JsonWebKey object itself. */ public JsonWebKey withN(byte[] n) { - if (n == null) { - this.n = null; - } else { - this.n = Base64Url.encode(n); - } + this.n = n; return this; } /** - * Get the e value. - * - * @return the e value + * Get the RSA public exponent value. + * @return the RSA public exponent value. */ + @JsonProperty("e") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] e() { - if (this.e == null) { - return null; - } - return this.e.getDecodedBytes(); + return this.e; } /** - * Set the e value. - * - * @param e the e value to set + * Set the RSA public exponent value. + * + * @param e RSA public exponent value to set * @return the JsonWebKey object itself. */ public JsonWebKey withE(byte[] e) { - if (e == null) { - this.e = null; - } else { - this.e = Base64Url.encode(e); - } + this.e = e; return this; } /** - * Get the d value. - * - * @return the d value + * Get the RSA private exponent value. + * @return the RSA private exponent value. */ + @JsonProperty("d") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] d() { - if (this.d == null) { - return null; - } - return this.d.getDecodedBytes(); + return this.d; } /** - * Set the d value. - * - * @param d the d value to set + * Set RSA private exponent value. + * + * @param d the RSA private exponent value to set. * @return the JsonWebKey object itself. */ public JsonWebKey withD(byte[] d) { - if (d == null) { - this.d = null; - } else { - this.d = Base64Url.encode(d); - } + this.d = d; return this; } /** - * Get the dp value. - * - * @return the dp value + * Get the RSA Private Key Parameter value. + * @return the RSA Private Key Parameter value. */ + @JsonProperty("dp") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] dp() { - if (this.dp == null) { - return null; - } - return this.dp.getDecodedBytes(); + return this.dp; } /** - * Set the dp value. - * - * @param dp the dp value to set + * Set RSA Private Key Parameter value + * @param dp the RSA Private Key Parameter value to set. * @return the JsonWebKey object itself. */ public JsonWebKey withDp(byte[] dp) { - if (dp == null) { - this.dp = null; - } else { - this.dp = Base64Url.encode(dp); - } + this.dp = dp; return this; } /** - * Get the dq value. - * - * @return the dq value + * Get the RSA Private Key Parameter value. + * @return the RSA Private Key Parameter value. */ + @JsonProperty("dq") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] dq() { - if (this.dq == null) { - return null; - } - return this.dq.getDecodedBytes(); + return this.dq; } /** - * Set the dq value. - * - * @param dq the dq value to set + * Set RSA Private Key Parameter value . + * @param dq the RSA Private Key Parameter value to set. * @return the JsonWebKey object itself. */ public JsonWebKey withDq(byte[] dq) { - if (dq == null) { - this.dq = null; - } else { - this.dq = Base64Url.encode(dq); - } + this.dq = dq; return this; } /** - * Get the qi value. - * - * @return the qi value + * Get the RSA Private Key Parameter value. + * @return the RSA Private Key Parameter value. */ + @JsonProperty("qi") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] qi() { - if (this.qi == null) { - return null; - } - return this.qi.getDecodedBytes(); + return this.qi; } /** - * Set the qi value. - * - * @param qi the qi value to set + * Set RSA Private Key Parameter value. + * @param qi the RSA Private Key Parameter value to set. * @return the JsonWebKey object itself. */ public JsonWebKey withQi(byte[] qi) { - if (qi == null) { - this.qi = null; - } else { - this.qi = Base64Url.encode(qi); - } + this.qi = qi; return this; } /** - * Get the p value. - * - * @return the p value + * Get the RSA secret prime value. + * @return the RSA secret prime value. */ + @JsonProperty("p") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] p() { - if (this.p == null) { - return null; - } - return this.p.getDecodedBytes(); + return this.p; } /** - * Set the p value. - * - * @param p the p value to set + * Set the RSA secret prime value. + * @param p the RSA secret prime value. * @return the JsonWebKey object itself. */ public JsonWebKey withP(byte[] p) { - if (p == null) { - this.p = null; - } else { - this.p = Base64Url.encode(p); - } + this.p = p; return this; } /** - * Get the q value. - * - * @return the q value + * Get RSA secret prime, with p < q value. + * @return the RSA secret prime, with p < q value. */ + @JsonProperty("q") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] q() { - if (this.q == null) { - return null; - } - return this.q.getDecodedBytes(); + return this.q; } /** - * Set the q value. - * - * @param q the q value to set + * Set the RSA secret prime, with p < q value. + * @param q the the RSA secret prime, with p < q value to be set. * @return the JsonWebKey object itself. */ public JsonWebKey withQ(byte[] q) { - if (q == null) { - this.q = null; - } else { - this.q = Base64Url.encode(q); - } + this.q = q; return this; } /** - * Get the k value. - * - * @return the k value + * Get Symmetric key value. + * @return the symmetric key value. */ + @JsonProperty("k") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] k() { - if (this.k == null) { - return null; - } - return this.k.getDecodedBytes(); + return this.k; } /** - * Set the k value. - * - * @param k the k value to set + * Set the Symmetric key value. + * @param k the symmetric key value to set. * @return the JsonWebKey object itself. */ public JsonWebKey withK(byte[] k) { - if (k == null) { - this.k = null; - } else { - this.k = Base64Url.encode(k); - } + this.k = k; return this; } /** - * Get the t value. - * - * @return the t value + * Get HSM Token value, used with Bring Your Own Key. + * @return HSM Token, used with Bring Your Own Key. */ + @JsonProperty("key_hsm") + @JsonSerialize(using = Base64UrlJsonSerializer.class) + @JsonDeserialize(using = Base64UrlJsonDeserializer.class) public byte[] t() { - if (this.t == null) { - return null; - } - return this.t.getDecodedBytes(); + return this.t; } /** - * Set the t value. - * - * @param t the t value to set + * Set HSM Token value, used with Bring Your Own Key. + * @param t HSM Token value to set, used with Bring Your Own Key * @return the JsonWebKey object itself. */ public JsonWebKey withT(byte[] t) { - if (t == null) { - this.t = null; - } else { - this.t = Base64Url.encode(t); - } + this.t = t; return this; } @Override public String toString() { - AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); - ObjectMapper mapper = mapperAdapter.getObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { @@ -473,13 +418,14 @@ private RSAPrivateKeySpec getRSAPrivateKeySpec() { /** * Get the RSA public key value. * + * @param provider the Java security provider. * @return the RSA public key value */ - private PublicKey getRSAPublicKey() { + private PublicKey getRSAPublicKey(Provider provider) { try { RSAPublicKeySpec publicKeySpec = getRSAPublicKeySpec(); - KeyFactory factory = KeyFactory.getInstance("RSA"); + KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider) : KeyFactory.getInstance("RSA"); return factory.generatePublic(publicKeySpec); } catch (GeneralSecurityException e) { @@ -490,13 +436,14 @@ private PublicKey getRSAPublicKey() { /** * Get the RSA private key value. * + * @param provider the Java security provider. * @return the RSA private key value */ - private PrivateKey getRSAPrivateKey() { + private PrivateKey getRSAPrivateKey(Provider provider) { try { RSAPrivateKeySpec privateKeySpec = getRSAPrivateKeySpec(); - KeyFactory factory = KeyFactory.getInstance("RSA"); + KeyFactory factory = provider != null ? KeyFactory.getInstance("RSA", provider) : KeyFactory.getInstance("RSA"); return factory.generatePrivate(privateKeySpec); } catch (GeneralSecurityException e) { @@ -590,14 +537,24 @@ public KeyPair toRSA() { * @return RSA key pair */ public KeyPair toRSA(boolean includePrivateParameters) { + return toRSA(includePrivateParameters, null); + } + + /** + * Converts JSON web key to RSA key pair and include the private key if set to true. + * @param provider the Java security provider. + * @param includePrivateParameters true if the RSA key pair should include the private key. False otherwise. + * @return RSA key pair + */ + public KeyPair toRSA(boolean includePrivateParameters, Provider provider) { // Must be RSA checkRSACompatible(); if (includePrivateParameters) { - return new KeyPair(getRSAPublicKey(), getRSAPrivateKey()); + return new KeyPair(getRSAPublicKey(provider), getRSAPrivateKey(provider)); } else { - return new KeyPair(getRSAPublicKey(), null); + return new KeyPair(getRSAPublicKey(provider), null); } } -} +} \ No newline at end of file diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java similarity index 54% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java index 96ee1a2d303e8..8eb412e21e412 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.webkey; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java similarity index 63% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java index 50360fee81496..aeacbc6655ace 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.webkey; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java similarity index 59% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java index fa9737305d268..0dc97946c274b 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.webkey; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java similarity index 58% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java index a04d9b3c40540..c5bdf89410d9e 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.webkey; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java similarity index 58% rename from azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java rename to azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java index 30b69d136c2b7..6768bb5045206 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/package-info.java @@ -3,7 +3,6 @@ // license information. /** - * This package contains the classes for KeyVaultClient. Performs cryptographic - * key operations and vault operations against the Key Vault service. + * This package contains the classes for key vault JSON web key. */ package com.microsoft.azure.keyvault.webkey; diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index a1a3830259410..66e34edb30b3e 100755 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -52,6 +52,11 @@ azure-client-runtime 1.0.0-SNAPSHOT
+ + ${project.groupId} + azure-keyvault-webkey + ${project.version} + diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 8b5c045ede14a..4c9e596423269 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -33,7 +33,6 @@ import com.microsoft.azure.keyvault.models.IssuerAttributes; import com.microsoft.azure.keyvault.models.IssuerBundle; import com.microsoft.azure.keyvault.models.IssuerCredentials; -import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyCreateParameters; @@ -54,6 +53,9 @@ import com.microsoft.azure.keyvault.models.SecretItem; import com.microsoft.azure.keyvault.models.SecretSetParameters; import com.microsoft.azure.keyvault.models.SecretUpdateParameters; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.Base64UrlJsonSerializer; +import com.microsoft.azure.keyvault.webkey.Base64UrlJsonDeserializer; import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index ae4a62b7cbacc..e7ce6cc2b0fb1 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.KeyIdentifier; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java index 0cd6eb0a956e5..457486131b8c7 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java @@ -12,6 +12,7 @@ import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; /** * The key import parameters. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java index b644554936253..91adae60c3ce8 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java @@ -5,8 +5,8 @@ import java.util.Map; import com.microsoft.azure.keyvault.models.Attributes; -import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; /** * The import key request class. diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java index 86410c9ab946f..de8a167ee8eda 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Random; +import java.util.concurrent.ExecutionException; import org.junit.Assert; import org.junit.Test; @@ -39,6 +40,7 @@ import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyItem; import com.microsoft.azure.keyvault.models.KeyOperationResult; +import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyResult; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.models.SecretItem; @@ -115,7 +117,21 @@ public void keyAsync() throws Exception { Assert.assertTrue(verifypResult.value()); keyBundle = keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get().getBody(); - Assert.assertNotNull(keyBundle); + Assert.assertNotNull(keyBundle); + + //Get the unavailable key to throw exception -> it gets stuck + + try { + keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get(); + } catch (ExecutionException ex) { + + Throwable t = ex.getCause(); + if(t instanceof KeyVaultErrorException) + { + Assert.assertEquals("KeyNotFound", ((KeyVaultErrorException) t).getBody().error().code()); + } + else throw ex; + } } @Test @@ -144,6 +160,18 @@ public void secretAsync() throws Exception { secretBundle = keyVaultClient.deleteSecretAsync(vault, secretname, null).get().getBody(); Assert.assertNotNull(secretBundle); + + try { + keyVaultClient.deleteSecretAsync(vault, secretname, null).get(); + } catch (ExecutionException ex) { + + Throwable t = ex.getCause(); + if(t instanceof KeyVaultErrorException) + { + Assert.assertEquals("SecretNotFound", ((KeyVaultErrorException) t).getBody().error().code()); + } + else throw ex; + } } @Test @@ -199,7 +227,19 @@ public void certificateAsync() throws Exception { keyVaultClient.deleteCertificateOperationAsync(vault, certificateName, null).get().getBody(); - keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get().getBody(); + keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get().getBody(); + + try { + keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get(); + } catch (ExecutionException ex) { + + Throwable t = ex.getCause(); + if(t instanceof KeyVaultErrorException) + { + Assert.assertEquals("CertificateNotFound", ((KeyVaultErrorException) t).getBody().error().code()); + } + else throw ex; + } } @Test diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index c4fd3b4d6209f..219b2202eade1 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -48,8 +48,8 @@ import com.microsoft.azure.keyvault.requests.ImportKeyRequest; import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; import com.microsoft.azure.keyvault.models.Attributes; -import com.microsoft.azure.keyvault.models.JsonWebKey; import com.microsoft.azure.keyvault.models.KeyAttributes; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; From 2af489b4d87f5c16f02482f116494e4a4c9d48f5 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Wed, 24 Aug 2016 09:56:30 -0700 Subject: [PATCH 27/56] License, documentation and byte array handling update. --- .../microsoft/azure/keyvault/core/IKey.java | 18 +-- .../keyvault/cryptography/Algorithm.java | 57 ++----- .../cryptography/AlgorithmResolver.java | 18 +-- .../AsymmetricEncryptionAlgorithm.java | 76 +++++++-- .../AsymmetricSignatureAlgorithm.java | 18 +-- .../keyvault/cryptography/ByteExtensions.java | 147 ++++++++++++++++++ .../cryptography/EncryptionAlgorithm.java | 26 ++-- .../IAuthenticatedCryptoTransform.java | 18 +-- .../cryptography/ICryptoTransform.java | 34 ++-- .../cryptography/KeyWrapAlgorithm.java | 133 ++++++++++++++-- .../cryptography/SignatureAlgorithm.java | 18 +-- .../azure/keyvault/cryptography/Strings.java | 18 +-- .../SymmetricEncryptionAlgorithm.java | 99 +++++++++--- .../keyvault/cryptography/SymmetricKey.java | 18 +-- .../cryptography/algorithms/Aes128Cbc.java | 27 +--- .../algorithms/Aes128CbcHmacSha256.java | 18 +-- .../cryptography/algorithms/Aes192Cbc.java | 27 +--- .../algorithms/Aes192CbcHmacSha384.java | 18 +-- .../cryptography/algorithms/Aes256Cbc.java | 27 +--- .../algorithms/Aes256CbcHmacSha512.java | 18 +-- .../cryptography/algorithms/AesCbc.java | 18 +-- .../algorithms/AesCbcHmacSha2.java | 18 +-- .../cryptography/algorithms/AesKw.java | 18 +-- .../cryptography/algorithms/AesKw128.java | 23 +-- .../cryptography/algorithms/AesKw192.java | 23 +-- .../cryptography/algorithms/AesKw256.java | 23 +-- .../cryptography/algorithms/Rsa15.java | 18 +-- .../algorithms/RsaEncryption.java | 18 +-- .../cryptography/algorithms/RsaOaep.java | 18 +-- .../cryptography/algorithms/package-info.java | 9 ++ .../cryptography/algorithms/package.html | 5 - .../keyvault/cryptography/package-info.java | 10 ++ .../azure/keyvault/cryptography/package.html | 5 - .../cryptography/test/AesCbcTest.java | 17 +- .../azure/keyvault/CertificateIdentifier.java | 18 +-- .../CertificateOperationIdentifier.java | 18 +-- .../azure/keyvault/IssuerIdentifier.java | 18 +-- .../azure/keyvault/KeyIdentifier.java | 18 +-- .../azure/keyvault/KeyVaultClient.java | 2 +- .../azure/keyvault/ObjectIdentifier.java | 18 +-- .../azure/keyvault/SecretIdentifier.java | 18 +-- .../authentication/ChallengeCache.java | 18 +-- .../authentication/KeyVaultCredentials.java | 18 +-- .../keyvault/test/AsyncOperationsTest.java | 18 +-- .../test/CertificateOperationsTest.java | 18 +-- .../keyvault/test/KeyOperationsTest.java | 18 +-- .../KeyVaultClientIntegrationTestBase.java | 18 +-- .../keyvault/test/SecretOperationsTest.java | 18 +-- 48 files changed, 610 insertions(+), 682 deletions(-) create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package-info.java delete mode 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package-info.java delete mode 100755 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html diff --git a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java index 6cf69f7002aa9..5eb18bd42677a 100755 --- a/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java +++ b/azure-keyvault-core/src/main/java/com/microsoft/azure/keyvault/core/IKey.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.core; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java index 127521c7d4373..e80ccaf5a76b0 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Algorithm.java @@ -1,27 +1,24 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; +/** + * Abstract base class for all Algorithm objects. + * + */ public abstract class Algorithm { private final String _name; + /** + * Constructor. + * + * @param name The name of the algorithm. + */ protected Algorithm(String name) { if (Strings.isNullOrWhiteSpace(name)) { throw new IllegalArgumentException("name"); @@ -30,32 +27,12 @@ protected Algorithm(String name) { _name = name; } - public String getName() { - return _name; - } - - /* - * Takes the first count bytes from the source and - * returns a new array containing those bytes. + /** + * Gets the name of the algorithm. * - * @param count The number of bytes to take. - * @param source The source of the bytes. - * @return count bytes from the source as a new array. + * @return The name of the algorithm. */ - public static byte[] Take(int count, byte[] source) - { - if ( source == null ) { - throw new IllegalArgumentException("source"); - } - - if ( count <= 0 || count > source.length ) { - throw new IllegalArgumentException("count"); - } - - byte[] target = new byte[count]; - - System.arraycopy(source, 0, target, 0, count); - - return target; + public String getName() { + return _name; } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java index c794b02867779..6804aa055420d 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java index 6a01e0333b0f2..b239a41d8530c 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricEncryptionAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; @@ -25,18 +13,74 @@ import javax.crypto.NoSuchPaddingException; +/** + * Abstract base class for all asymmetric encryption algorithms. + * + */ public abstract class AsymmetricEncryptionAlgorithm extends EncryptionAlgorithm { + /** + * Constructor. + * + * @param name The name of the algorithm. + */ protected AsymmetricEncryptionAlgorithm(String name) { super(name); } + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption that + * uses the specified {@link java.security.KeyPair} and the default {@link java.security.Provider} provider. + * + * @param keyPair + * The key pair to use. + * @return + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + */ public abstract ICryptoTransform CreateEncryptor(KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption that + * uses the specified {@link java.security.KeyPair} and {@link java.security.Provider}. + * + * @param keyPair + * The key pair to use. + * @param provider + * The provider to use. + * @return + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + */ public abstract ICryptoTransform CreateEncryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption that + * uses the specified {@link java.security.KeyPair} and the default {@link java.security.Provider} provider. + * + * @param keyPair + * The key pair to use. + * @return + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + */ public abstract ICryptoTransform CreateDecryptor(KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption that + * uses the specified {@link java.security.KeyPair} and {@link java.security.Provider}. + * + * @param keyPair + * The key pair to use. + * @param provider + * The provider to use. + * @return + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + */ public abstract ICryptoTransform CreateDecryptor(KeyPair keyPair, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException; - } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java index 5232ab646ff4c..ff5e1417ba5c6 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AsymmetricSignatureAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java new file mode 100644 index 0000000000000..c76b4c507de6a --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java @@ -0,0 +1,147 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.keyvault.cryptography; + +public final class ByteExtensions { + + public static boolean sequenceEqualConstantTime( byte[] self, byte[] other ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + if ( other == null ) + throw new IllegalArgumentException( "other" ); + + // Constant time comparison of two byte arrays + long difference = ( self.length & 0xffffffffl ) ^ ( other.length & 0xffffffffl ); + + for ( int i = 0; i < self.length && i < other.length; i++ ) + { + difference |= ( self[i] ^ other[i] ) & 0xffffffffl; + } + + return difference == 0; + } + + public static byte[] or( byte[] self, byte[] other ) + { + return or( self, other, 0 ); + } + + public static byte[] or( byte[] self, byte[] other, int offset ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + if ( other == null ) + throw new IllegalArgumentException( "other" ); + + if ( self.length > other.length - offset ) + throw new IllegalArgumentException( "self and other lengths do not match" ); + + byte[] result = new byte[self.length]; + + for ( int i = 0; i < self.length; i++ ) + { + result[i] = (byte)( self[i] | other[offset + i] ); + } + + return result; + } + + public static byte[] xor( byte[] self, byte[] other ) { + return xor( self, other, 0, false ); + } + + public static byte[] xor( byte[] self, byte[] other, boolean inPlace ) + { + return xor( self, other, 0, inPlace ); + } + + public static byte[] xor( byte[] self, byte[] other, int offset ) { + return xor( self, other, 0, false ); + } + + public static byte[] xor( byte[] self, byte[] other, int offset, boolean inPlace ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + if ( other == null ) + throw new IllegalArgumentException( "other" ); + + if ( self.length > other.length - offset ) + throw new IllegalArgumentException( "self and other lengths do not match" ); + + if ( inPlace ) + { + for ( int i = 0; i < self.length; i++ ) + { + self[i] = (byte)( self[i] ^ other[offset + i] ); + } + + return self; + } + else + { + byte[] result = new byte[self.length]; + + for ( int i = 0; i < self.length; i++ ) + { + result[i] = (byte)( self[i] ^ other[offset + i] ); + } + + return result; + } + } + + public static byte[] take( byte[] self, int count ) + { + return ByteExtensions.take( self, 0, count ); + } + + + /** + * Takes the first count bytes from the source and + * returns a new array containing those bytes. + * + * @param self The source of the bytes. + * @param offset The starting offset. + * @param count The number of bytes to take. + * @return count bytes from the source as a new array. + */ + public static byte[] take( byte[] self, int offset, int count ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + if ( offset < 0 ) + throw new IllegalArgumentException( "offset cannot be < 0" ); + + if ( count <= 0 ) + throw new IllegalArgumentException( "count cannot be <= 0" ); + + if ( offset + count > self.length ) + throw new IllegalArgumentException( "offset + count cannot be > self.Length" ); + + byte[] result = new byte[count]; + + System.arraycopy( self, offset, result, 0, count ); + + return result; + } + + public static void zero( byte[] self ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + for ( int i = 0; i < self.length; i++ ) { + self[i] = 0; + } + } +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java index 527b704d6db20..4d36c332b3beb 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/EncryptionAlgorithm.java @@ -1,25 +1,21 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; +/** + * Abstract base class for all encryption algorithms. + * + */ public abstract class EncryptionAlgorithm extends Algorithm { + /** + * Constructor. + * @param name The name of the algorithm. + */ protected EncryptionAlgorithm(String name) { super(name); } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java index 8145964666abf..113a14404cf4d 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/IAuthenticatedCryptoTransform.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java index 3e1c725b3f8b0..4787a9d11a0f4 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ICryptoTransform.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; @@ -24,7 +12,23 @@ import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; +/** + * Defines the basic operations of cryptographic transformations. + * + */ public interface ICryptoTransform { + /** + * Transforms the specified region of the specified byte array as a single operation. + * + * @param input + * The byte array to be transformed + * @return + * The transformed result. + * @throws IllegalBlockSizeException + * @throws BadPaddingException + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + */ public byte[] doFinal(byte[] input) throws IllegalBlockSizeException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException; } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java index fdc15bc1dad94..e0028d51a5073 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/KeyWrapAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; @@ -25,25 +13,140 @@ import javax.crypto.NoSuchPaddingException; +/** + * Abstract base class for all key wrap algorithms. + * + */ public abstract class KeyWrapAlgorithm extends Algorithm { + /** + * Constructor. + * + * @param name The name of the algorithm. + */ protected KeyWrapAlgorithm(String name) { super(name); } + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption. + * Uses the default AES-KW initialization vector. + * @param key + * The AES key material to be used. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateEncryptor(byte[] key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption that + * uses the specified provider for the Java Security API. Uses the default AES-KW initialization vector. + * + * @param key + * The AES key material to be used. + * @param provider + * The provider to use. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateEncryptor(byte[] key, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption + * using the supplied initialization vector. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption + * using the supplied initialization vector and the specific provider for the Java Security API. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @param provider + * The provider to use. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption. + * Uses the default AES-KW initialization vector. + * @param key + * The AES key material to be used. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateDecryptor(byte[] key) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption that + * uses the specified provider for the Java Security API. Uses the default AES-KW initialization vector. + * + * @param key + * The AES key material to be used. + * @param provider + * The provider to use. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateDecryptor(byte[] key, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption + * using the supplied initialization vector. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption + * using the supplied initialization vector and the specific provider for the Java Security API. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @param provider + * The provider to use. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidKeyException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException; } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java index f0d8f2b953f88..53d7459b91363 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SignatureAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java index c6cf7244a1532..a1ead94749e65 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/Strings.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java index 4834485c31957..7c6e586fc09f8 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; @@ -25,18 +13,91 @@ import javax.crypto.NoSuchPaddingException; +/** + * Abstract base class for all symmetric encryption algorithms. + * + */ public abstract class SymmetricEncryptionAlgorithm extends EncryptionAlgorithm { + /** + * Constructor. + * + * @param name The name of the algorithm. + */ protected SymmetricEncryptionAlgorithm(String name) { super(name); } - public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; - - public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; - + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption + * using the supplied initialization vector and the specific provider for the Java Security API. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @param authenticationData + * The authentication data to be used with authenticating encryption algorithms (optional) + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption + * using the supplied initialization vector and the specific provider for the Java Security API. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @param authenticationData + * The authentication data to be used with authenticating encryption algorithms (optional) + * @param provider + * The provider to use. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidAlgorithmParameterException + */ public abstract ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption + * using the supplied initialization vector and the specific provider for the Java Security API. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @param authenticationData + * The authentication data to be used with authenticating encryption algorithms (optional) + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidAlgorithmParameterException + */ + public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + + /** + * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption + * using the supplied initialization vector and the specific provider for the Java Security API. + * @param key + * The AES key material to be used. + * @param iv + * The initialization vector to be used. + * @param authenticationData + * The authentication data to be used with authenticating encryption algorithms (optional) + * @param provider + * The provider to use. + * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation + * @throws InvalidKeyException + * @throws NoSuchAlgorithmException + * @throws NoSuchPaddingException + * @throws InvalidAlgorithmParameterException + */ + public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java index f9900d592b3de..14e0797b46587 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java index c0a5630e8df6b..14cf40023b7c8 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; @@ -25,6 +13,7 @@ import javax.crypto.NoSuchPaddingException; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public class Aes128Cbc extends AesCbc { @@ -44,7 +33,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); } @Override @@ -54,7 +43,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } @Override @@ -64,7 +53,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); } @Override @@ -74,6 +63,6 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java index eeb40fa3808b4..9e75131a3de84 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java index 96b03caf970e0..4ec8451b47901 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; @@ -25,6 +13,7 @@ import javax.crypto.NoSuchPaddingException; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public class Aes192Cbc extends AesCbc { @@ -44,7 +33,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); } @Override @@ -54,7 +43,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } @Override @@ -64,7 +53,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); } @Override @@ -74,7 +63,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java index 0e0e6758558a8..74f279eff8c72 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java index 88abe788ee757..629b647ec6b92 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; @@ -25,6 +13,7 @@ import javax.crypto.NoSuchPaddingException; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public class Aes256Cbc extends AesCbc { @@ -44,7 +33,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); } @Override @@ -54,7 +43,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcEncryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } @Override @@ -64,7 +53,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, null); + return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); } @Override @@ -74,7 +63,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica throw new InvalidKeyException("key must be at least 128 bits in length"); } - return new AesCbcDecryptor(AesCbc.Take(KeySizeInBytes, key), iv, provider); + return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java index 495bc7bd69468..e038c808fec53 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java index 7c49fba06c6b2..49edaa57a71b5 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java index 882a21284d616..c2ccc2a88ab13 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java index 8f7fa07ae6f12..6bd7dfc28c639 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java index 2044f10895867..3c628688ef236 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; @@ -25,6 +13,7 @@ import javax.crypto.NoSuchPaddingException; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public final class AesKw128 extends AesKw { @@ -48,7 +37,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 128 bits long"); } - return super.CreateEncryptor(Take(KeySizeInBytes,key), iv, provider); + return super.CreateEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } @Override @@ -62,7 +51,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 128 bits long"); } - return super.CreateDecryptor(Take(KeySizeInBytes,key), iv, provider); + return super.CreateDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java index bb652553ff83e..dd24b0011a0c1 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; @@ -25,6 +13,7 @@ import javax.crypto.NoSuchPaddingException; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public final class AesKw192 extends AesKw { @@ -48,7 +37,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 192 bits long"); } - return super.CreateEncryptor(Take(KeySizeInBytes,key), iv, provider); + return super.CreateEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } @Override @@ -62,7 +51,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 192 bits long"); } - return super.CreateDecryptor(Take(KeySizeInBytes,key), iv, provider); + return super.CreateDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java index b2ed7dd4815f7..79398e292adc4 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; @@ -25,6 +13,7 @@ import javax.crypto.NoSuchPaddingException; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public final class AesKw256 extends AesKw { @@ -48,7 +37,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 256 bits long"); } - return super.CreateEncryptor(Take(KeySizeInBytes,key), iv, provider); + return super.CreateEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } @Override @@ -62,7 +51,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 256 bits long"); } - return super.CreateDecryptor(Take(KeySizeInBytes,key), iv, provider); + return super.CreateDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java index 8161095756f88..4770183bb3ab8 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java index dd673f61ab416..83343057aa55a 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaEncryption.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java index 424778e85f261..55b57b6acd633 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package-info.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package-info.java new file mode 100644 index 0000000000000..f3101db3f04c0 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// + +/** + * This package contains cryptographic functions and implementations. + */ +package com.microsoft.azure.keyvault.cryptography.algorithms; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html deleted file mode 100755 index 102a782ab4a86..0000000000000 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - -This package contains the Azure Key Vault Extension Cryptographic algorithm classes. - - diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package-info.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package-info.java new file mode 100644 index 0000000000000..5492e8c677615 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// + +/** + * This package contains cryptographic functions and implementations + * of RSA and symmetric keys that conform with the IKey interface. + */ +package com.microsoft.azure.keyvault.cryptography; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html deleted file mode 100755 index 12edd05fd0bac..0000000000000 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - -This package contains the Azure Key Vault Extension classes. - - diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java index 6498b9508dff6..c35cfcdfc6c24 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java @@ -12,6 +12,7 @@ import org.junit.Test; import com.microsoft.azure.keyvault.cryptography.Algorithm; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; @@ -63,7 +64,7 @@ public void testAes128CbcOneBlock() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(16,encrypted),ED); + assertArrayEquals(ByteExtensions.take(encrypted, 16), ED); } catch (Exception e) { fail(e.getMessage()); } @@ -81,7 +82,7 @@ public void testAes128CbcOneBlock() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(16, decrypted), PLAIN); + assertArrayEquals(ByteExtensions.take(decrypted, 16), PLAIN); } catch (Exception e) { fail(e.getMessage()); } @@ -110,7 +111,7 @@ public void testAes128CbcTwoBlock() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(32,encrypted),ED); + assertArrayEquals(ByteExtensions.take(encrypted, 32), ED); } catch (Exception e) { fail(e.getMessage()); } @@ -128,7 +129,7 @@ public void testAes128CbcTwoBlock() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(32, decrypted), PLAIN); + assertArrayEquals(ByteExtensions.take(decrypted, 32), PLAIN); } catch (Exception e) { fail(e.getMessage()); } @@ -157,7 +158,7 @@ public void testAes128CbcOneBlock_ExcessKeyMaterial() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(16,encrypted),ED); + assertArrayEquals(ByteExtensions.take(encrypted, 16),ED); } catch (Exception e) { fail(e.getMessage()); } @@ -175,7 +176,7 @@ public void testAes128CbcOneBlock_ExcessKeyMaterial() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(16, decrypted), PLAIN); + assertArrayEquals(ByteExtensions.take(decrypted, 16), PLAIN); } catch (Exception e) { fail(e.getMessage()); } @@ -204,7 +205,7 @@ public void testAes128CbcTwoBlock_ExcessKeyMaterial() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(32,encrypted),ED); + assertArrayEquals(ByteExtensions.take(encrypted, 32), ED); } catch (Exception e) { fail(e.getMessage()); } @@ -222,7 +223,7 @@ public void testAes128CbcTwoBlock_ExcessKeyMaterial() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(Algorithm.Take(32, decrypted), PLAIN); + assertArrayEquals(ByteExtensions.take(decrypted, 32), PLAIN); } catch (Exception e) { fail(e.getMessage()); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java index 334ad65b5f3d4..c78460edcfdec 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateIdentifier.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java index e902dad696565..ed88be41ab019 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/CertificateOperationIdentifier.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java index 69b685c50ea40..6d50e9c6c049c 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/IssuerIdentifier.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java index b28d4464449e2..67dcd6f35b83e 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyIdentifier.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 1c1d45cab33d3..2aae9e82f23b3 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -1,7 +1,7 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java index 290a07c94003e..e026b82b7d9ae 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/ObjectIdentifier.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java index 60d3d927bcdee..c2564685eb822 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/SecretIdentifier.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java index 7f0a1fbd287d0..07cd0a8dc49b7 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.authentication; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java index ad1a3e8206271..9c184cb7cea5b 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.authentication; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java index de8a167ee8eda..44eb04f681b56 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.test; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index 18a13e9423e9b..3af77cfca2625 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.test; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 219b2202eade1..54eb89cd3d444 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.test; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java index 2ebb0c791a977..d3deb5fcb23f5 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyVaultClientIntegrationTestBase.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.test; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index 1673ded8ff130..af27ec8973c2f 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.test; From 02404918aa9080a13694c2fc2707826b62383803 Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Wed, 24 Aug 2016 15:22:19 -0700 Subject: [PATCH 28/56] Fix RSA256 signature --- .../cryptography/ISignatureTransform.java | 16 +++ .../azure/keyvault/cryptography/RsaKey.java | 24 ++--- .../cryptography/algorithms/Rs256.java | 102 ++++++------------ .../cryptography/algorithms/RsaSignature.java | 91 ++++++++-------- .../cryptography/test/AesCbcTest.java | 1 - .../cryptography/test/RsaKeyTest.java | 12 ++- 6 files changed, 112 insertions(+), 134 deletions(-) create mode 100644 azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ISignatureTransform.java diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ISignatureTransform.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ISignatureTransform.java new file mode 100644 index 0000000000000..484b1448fb513 --- /dev/null +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ISignatureTransform.java @@ -0,0 +1,16 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ + +package com.microsoft.azure.keyvault.cryptography; + +import java.security.GeneralSecurityException; + +public interface ISignatureTransform { + + public byte[] sign(final byte[] digest) throws GeneralSecurityException; + + public boolean verify(final byte[] digest, final byte[] signature) throws GeneralSecurityException; +} diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java index 4548a883c17fd..4abfcfd8855a6 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java @@ -1,19 +1,7 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography; @@ -262,7 +250,7 @@ public ListenableFuture> signAsync(final byte[] digest, fin Rs256 algo = (Rs256)baseAlgorithm; - Rs256.Rs256Signer signer = algo.createSigner(_keyPair); + ISignatureTransform signer = algo.createSignatureTransform(_keyPair); try { return Futures.immediateFuture(Pair.of(signer.sign(digest), Rs256.AlgorithmName)); @@ -292,10 +280,10 @@ public ListenableFuture verifyAsync(final byte[] digest, final byte[] s Rs256 algo = (Rs256)baseAlgorithm; - Rs256.Rs256Verifier signer = algo.createVerifier(_keyPair); + ISignatureTransform signer = algo.createSignatureTransform(_keyPair); try { - return Futures.immediateFuture(signer.verify(signature, digest)); + return Futures.immediateFuture(signer.verify(digest, signature)); } catch (Exception e) { return Futures.immediateFailedFuture(e); } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java index 750a02f529ea7..54a4fd4572361 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java @@ -1,32 +1,19 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; import java.math.BigInteger; -import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.NoSuchAlgorithmException; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; + +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; +import com.microsoft.azure.keyvault.cryptography.ISignatureTransform; /** * @@ -35,27 +22,31 @@ public class Rs256 extends RsaSignature { static final String RsaNone = "RSA/ECB/PKCS1Padding"; - public class Rs256Signer { - + class Rs256SignatureTransform implements ISignatureTransform { + private final KeyPair _keyPair; private final int _emLen; - private final BigInteger _n; - - Rs256Signer(KeyPair keyPair) { - + Rs256SignatureTransform(KeyPair keyPair) { _keyPair = keyPair; - _n = ((RSAPublicKey)_keyPair.getPublic()).getModulus(); - _emLen = getOctetLength( _n.bitLength() ); + BigInteger modulus = ((RSAPublicKey)_keyPair.getPublic()).getModulus(); + + _emLen = getOctetLength( modulus.bitLength() ); + } - - public byte[] sign(final byte[] digest) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + + @Override + public byte[] sign(byte[] digest) throws NoSuchAlgorithmException { // Signing isn't just a case of encrypting the digest, there is much more to do. // For details of the algorithm, see https://tools.ietf.org/html/rfc3447#section-8.2 + if ( _keyPair.getPrivate() == null ) { + // TODO + } + // Construct the encoded message - byte[] EM = EMSA_PKCS1_V1_5_ENCODE(digest, _emLen, "SHA-256"); + byte[] EM = EMSA_PKCS1_V1_5_ENCODE_HASH(digest, _emLen, "SHA-256"); // Convert to integer message BigInteger s = OS2IP(EM); @@ -64,26 +55,14 @@ public byte[] sign(final byte[] digest) throws InvalidKeyException, NoSuchAlgori s = RSASP1((RSAPrivateKey)_keyPair.getPrivate(), s); // Convert to octet sequence - return I2OSP(s, getOctetLength( _n.bitLength() ) ); + return I2OSP(s, _emLen ); } - } - - public class Rs256Verifier { - - private final KeyPair _keyPair; - private final BigInteger _n; - private final int _emLength; - - Rs256Verifier(KeyPair keyPair) { - _keyPair = keyPair; - _n = ((RSAPublicKey)_keyPair.getPublic()).getModulus(); - _emLength = getOctetLength( _n.bitLength() ); - } - - public boolean verify(final byte[] signature, final byte[] digest) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException { + + @Override + public boolean verify(byte[] digest, byte[] signature) throws NoSuchAlgorithmException { - if ( signature.length != getOctetLength( _n.bitLength() ) ) { - throw new IllegalBlockSizeException(); + if ( signature.length != _emLen ) { + throw new IllegalArgumentException( "invalid signature length"); } // Convert to integer signature @@ -92,21 +71,13 @@ public boolean verify(final byte[] signature, final byte[] digest) throws Invali // Convert integer message BigInteger m = RSAVP1((RSAPublicKey)_keyPair.getPublic(), s); + byte[] EM = I2OSP(m, _emLen ); + byte[] EM2 = EMSA_PKCS1_V1_5_ENCODE_HASH(digest, _emLen, "SHA-256"); - byte[] EM = I2OSP(m, getOctetLength( _n.bitLength() ) ); - byte[] EM2 = EMSA_PKCS1_V1_5_ENCODE(digest, _emLength, "SHA-256"); - - // TODO: Need constant time compare - if ( EM.length != EM2.length ) - return false; - - for ( int i = 0; i < digest.length; i++ ) { - if ( EM[i] != EM2[i] ) - return false; - } - - return true; + // Use constant time compare + return ByteExtensions.sequenceEqualConstantTime(EM, EM2); } + } public final static String AlgorithmName = "RS256"; @@ -115,12 +86,9 @@ public Rs256() { super(AlgorithmName); } - public Rs256Signer createSigner(KeyPair keyPair) { + @Override + public ISignatureTransform createSignatureTransform(KeyPair keyPair) { - return new Rs256Signer(keyPair); - } - - public Rs256Verifier createVerifier(KeyPair keyPair) { - return new Rs256Verifier(keyPair); + return new Rs256SignatureTransform(keyPair); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java index a9ac4d4559cbb..e5248b47bfb52 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java @@ -1,24 +1,13 @@ /** - * - * Copyright (c) Microsoft and contributors. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. */ package com.microsoft.azure.keyvault.cryptography.algorithms; import java.math.BigInteger; +import java.security.KeyPair; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.interfaces.RSAPrivateKey; @@ -26,6 +15,7 @@ import java.util.Arrays; import com.microsoft.azure.keyvault.cryptography.AsymmetricSignatureAlgorithm; +import com.microsoft.azure.keyvault.cryptography.ISignatureTransform; import com.microsoft.azure.keyvault.cryptography.Strings; public abstract class RsaSignature extends AsymmetricSignatureAlgorithm { @@ -37,33 +27,10 @@ protected RsaSignature(String name) { super(name); } - protected static byte[] toByteArray(BigInteger n) { - byte[] result = n.toByteArray(); - if (result[0] == 0) { - // The leading zero is used to let the number positive. Since RSA - // parameters are always positive, we remove it. - return Arrays.copyOfRange(result, 1, result.length); - } - return result; - } - - protected static BigInteger toBigInteger(byte[] b) { - if (b[0] < 0) { - // RSA parameters are always positive numbers, so if the first byte - // is negative, we need to add a leading zero - // to make the entire BigInteger positive. - byte[] temp = new byte[1 + b.length]; - System.arraycopy(b, 0, temp, 1, b.length); - b = temp; - } - return new BigInteger(b); - } - protected int getOctetLength(int bits) { return ( bits % 8 > 0 ) ? bits >> 3 + 1 : bits >> 3; } - /* * See https://tools.ietf.org/html/rfc3447#section-4.2 */ @@ -161,7 +128,6 @@ protected byte[] EMSA_PKCS1_V1_5_ENCODE(byte[] m, int emLen, String algorithm) t throw new IllegalArgumentException("m"); } - byte[] algorithmPrefix = null; MessageDigest messageDigest = null; // Check algorithm @@ -172,25 +138,55 @@ protected byte[] EMSA_PKCS1_V1_5_ENCODE(byte[] m, int emLen, String algorithm) t // Only supported algorithms if ( algorithm.equals("SHA-256") ) { - // Initialize prefix and digest - algorithmPrefix = sha256Prefix; + // Initialize digest messageDigest = MessageDigest.getInstance("SHA-256"); } else { throw new IllegalArgumentException("algorithm"); } - if ( algorithmPrefix == null || messageDigest == null ) { - throw new IllegalArgumentException("initialization with arguments failed"); - } - // Hash the message byte[] digest = messageDigest.digest(m); // Construct T, the DER encoded DigestInfo structure - byte[] T = new byte[algorithmPrefix.length + digest.length]; + return EMSA_PKCS1_V1_5_ENCODE_HASH(digest, emLen, algorithm); + } + + /* + * See https://tools.ietf.org/html/rfc3447#section-9.2 + */ + protected byte[] EMSA_PKCS1_V1_5_ENCODE_HASH(byte[] h, int emLen, String algorithm) throws NoSuchAlgorithmException { + + // Check m + if ( h == null || h.length == 0 ) { + throw new IllegalArgumentException("m"); + } + + byte[] algorithmPrefix = null; + + // Check algorithm + if ( Strings.isNullOrWhiteSpace(algorithm) ) { + throw new IllegalArgumentException("algorithm"); + } + + // Only supported algorithms + if ( algorithm.equals("SHA-256") ) { + + // Initialize prefix and digest + algorithmPrefix = sha256Prefix; + + if ( h.length != 32 ) { + throw new IllegalArgumentException("h is incorrect length for SHA-256"); + } + } else { + throw new IllegalArgumentException("algorithm"); + } + + + // Construct T, the DER encoded DigestInfo structure + byte[] T = new byte[algorithmPrefix.length + h.length]; System.arraycopy(algorithmPrefix, 0, T, 0, algorithmPrefix.length); - System.arraycopy(digest, 0, T, algorithmPrefix.length, digest.length); + System.arraycopy(h, 0, T, algorithmPrefix.length, h.length); if ( emLen < T.length + 11 ) { throw new IllegalArgumentException("intended encoded message length too short"); @@ -212,4 +208,5 @@ protected byte[] EMSA_PKCS1_V1_5_ENCODE(byte[] m, int emLen, String algorithm) t return EM; } + public abstract ISignatureTransform createSignatureTransform(KeyPair keyPair); } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java index c35cfcdfc6c24..351f22a1ce993 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java @@ -11,7 +11,6 @@ import org.junit.BeforeClass; import org.junit.Test; -import com.microsoft.azure.keyvault.cryptography.Algorithm; import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java index 454752d7bac8b..2b181398ae859 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -25,7 +25,8 @@ public class RsaKeyTest { // A Content Encryption Key, or Message. This value is kept consistent with the .NET // unit test cases to enable cross platform testing. - static final byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; + static final byte[] CEK = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte)0x88, (byte)0x99, (byte)0xAA, (byte)0xBB, (byte)0xCC, (byte)0xDD, (byte)0xEE, (byte)0xFF }; + static final String CrossPlatformHash = "qPrtarvzXBKksm5A9v6xnXNtkARcg7n5ox9jjTI+aBE="; static final String CrossPlatformSignature = "RaNc+8WcWxplS8I7ynJLSoLJKz+dgBvrZhIGH3VFlTTyzu7b9d+lpaV9IKhzCNBsgSysKhgL7EZwVCOTBZ4m6xvKSXqVFXYaBPyBTD7VoKPMYMW6ai5x6xV5XAMaZPfMkff3Deg/RXcc8xQ28FhYuUa8yly01GySY4Hk55anEvb2wBxSy1UGun/0LE1lYH3C3XEgSry4cEkJHDJl1hp+wB4J/noXOqn5ECGU+/4ehBJOyW1gtUH0/gRe8yXnDH0AXepHRyH8iBHLWlKX1r+1/OrMulqOoi82RZzJlTyEz9X+bsQhllqGF6n3hdLS6toH9o7wUtwYNqSx82JuQT6iMg=="; private Provider _provider = null; @@ -134,11 +135,20 @@ public void testSignVerify() throws Exception { MessageDigest digest = MessageDigest.getInstance("SHA-256"); byte[] hash = digest.digest(CEK); + byte[] crossPlatformHash = Base64.decodeBase64(CrossPlatformHash); + byte[] crossPlatformSignature = Base64.decodeBase64(CrossPlatformSignature); + + assertNotNull( hash ); + assertEquals( 32, hash.length ); + assertArrayEquals(hash, crossPlatformHash); + Pair signature = key.signAsync(hash, "RS256").get(); boolean result = key.verifyAsync(hash, signature.getLeft(), "RS256").get(); assertTrue(result); + //assertArrayEquals(crossPlatformSignature, signature.getLeft()); + // Now prove we can verify the cross platform signature result = key.verifyAsync(hash, Base64.decodeBase64(CrossPlatformSignature), "RS256").get(); From d47971b7197bd78ee88f68a3567e75cc260e55cb Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Mon, 29 Aug 2016 16:58:23 -0700 Subject: [PATCH 29/56] Minor signature code cleanup --- .../azure/keyvault/cryptography/algorithms/RsaSignature.java | 2 -- .../azure/keyvault/cryptography/test/RsaKeyTest.java | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java index e5248b47bfb52..84d2257ae2175 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaSignature.java @@ -12,8 +12,6 @@ import java.security.NoSuchAlgorithmException; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; -import java.util.Arrays; - import com.microsoft.azure.keyvault.cryptography.AsymmetricSignatureAlgorithm; import com.microsoft.azure.keyvault.cryptography.ISignatureTransform; import com.microsoft.azure.keyvault.cryptography.Strings; diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java index 2b181398ae859..18cf7db616e18 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -138,6 +138,7 @@ public void testSignVerify() throws Exception { byte[] crossPlatformHash = Base64.decodeBase64(CrossPlatformHash); byte[] crossPlatformSignature = Base64.decodeBase64(CrossPlatformSignature); + // Check the hash assertNotNull( hash ); assertEquals( 32, hash.length ); assertArrayEquals(hash, crossPlatformHash); @@ -145,9 +146,9 @@ public void testSignVerify() throws Exception { Pair signature = key.signAsync(hash, "RS256").get(); boolean result = key.verifyAsync(hash, signature.getLeft(), "RS256").get(); + // Check the signature assertTrue(result); - - //assertArrayEquals(crossPlatformSignature, signature.getLeft()); + assertArrayEquals(crossPlatformSignature, signature.getLeft()); // Now prove we can verify the cross platform signature result = key.verifyAsync(hash, Base64.decodeBase64(CrossPlatformSignature), "RS256").get(); From de395a3d25e0c0538502b1f4bae6f1b27f2dcd44 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Fri, 2 Sep 2016 10:59:27 -0700 Subject: [PATCH 30/56] Adapting the observer model for Key Vault wrapped client, fixed build becaue incompatibility with runtime and instead of using constant string for JWK algorithms use static class representations --- .../keyvault/extensions/KeyVaultKey.java | 10 +- .../KeyVaultKeyResolverBCProviderTest.java | 3 +- ...eyVaultKeyResolverDefaultProviderTest.java | 3 +- .../azure/keyvault/webkey/JsonWebKey.java | 14 +- .../webkey/JsonWebKeyEncryptionAlgorithm.java | 62 +- .../keyvault/webkey/JsonWebKeyOperation.java | 94 +- .../webkey/JsonWebKeySignatureAlgorithm.java | 79 +- .../azure/keyvault/webkey/JsonWebKeyType.java | 79 +- .../azure/keyvault/KeyVaultClient.java | 83 +- .../azure/keyvault/KeyVaultClientImpl.java | 4982 ++++++++--------- .../models/CertificateIssuerItem.java | 2 +- .../CertificateIssuerSetParameters.java | 2 +- .../CertificateIssuerUpdateParameters.java | 5 +- .../CertificateOperationUpdateParameter.java | 2 +- .../azure/keyvault/models/IssuerBundle.java | 2 +- .../keyvault/models/IssuerReference.java | 3 +- .../azure/keyvault/models/KeyBundle.java | 5 +- .../keyvault/models/KeyCreateParameters.java | 17 +- .../azure/keyvault/models/KeyItem.java | 5 +- .../models/KeyOperationsParameters.java | 7 +- .../azure/keyvault/models/KeyProperties.java | 2 +- .../keyvault/models/KeySignParameters.java | 7 +- .../keyvault/models/KeyUpdateParameters.java | 7 +- .../keyvault/models/KeyVerifyParameters.java | 7 +- .../azure/keyvault/models/SecretBundle.java | 9 +- .../azure/keyvault/models/SecretItem.java | 5 +- .../models/X509CertificateProperties.java | 4 +- .../keyvault/requests/CreateKeyRequest.java | 25 +- .../keyvault/requests/ImportKeyRequest.java | 3 +- .../keyvault/requests/UpdateKeyRequest.java | 11 +- .../keyvault/test/AsyncOperationsTest.java | 11 +- .../test/CertificateOperationsTest.java | 12 +- .../keyvault/test/KeyOperationsTest.java | 66 +- .../keyvault/test/SecretOperationsTest.java | 15 +- 34 files changed, 2768 insertions(+), 2875 deletions(-) diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index 2ef3291cfca3a..f4afd66b74aaa 100755 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -30,6 +30,8 @@ import com.microsoft.azure.keyvault.core.IKey; import com.microsoft.azure.keyvault.cryptography.RsaKey; import com.microsoft.azure.keyvault.webkey.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; @@ -96,7 +98,7 @@ protected KeyVaultKey(KeyVaultClient client, KeyBundle keyBundle) { if (key.kty().equals(JsonWebKeyType.RSA)) { // The private key is not available for KeyVault keys implementation = new RsaKey(key.kid(), key.toRSA(false)); - } else if (key.kty().equals(JsonWebKeyType.RSAHSM)) { + } else if (key.kty().equals(JsonWebKeyType.RSA_HSM)) { // The private key is not available for KeyVault keys implementation = new RsaKey(key.kid(), key.toRSA(false)); } @@ -169,7 +171,7 @@ public ListenableFuture decryptAsync(byte[] ciphertext, byte[] iv, byte[ ListenableFuture> futureCall = client.decryptAsync( implementation.getKid(), - algorithm, + new JsonWebKeyEncryptionAlgorithm(algorithm), ciphertext, null); return Futures.transform(futureCall, new DecryptResultTransform()); @@ -207,7 +209,7 @@ public ListenableFuture unwrapKeyAsync(byte[] ciphertext, String algorit ListenableFuture> futureCall = client.unwrapKeyAsync( implementation.getKid(), - algorithm, + new JsonWebKeyEncryptionAlgorithm(algorithm), ciphertext, null); return Futures.transform(futureCall, new DecryptResultTransform()); @@ -227,7 +229,7 @@ public ListenableFuture> signAsync(byte[] digest, String al ListenableFuture> futureCall = client.signAsync( implementation.getKid(), - algorithm, + new JsonWebKeySignatureAlgorithm(algorithm), digest, null); return Futures.transform(futureCall, new SignResultTransform(algorithm)); diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java index 58948e52d9bb2..f7f16bb09ca29 100755 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java @@ -38,6 +38,7 @@ import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.requests.CreateKeyRequest; import com.microsoft.azure.keyvault.requests.SetSecretRequest; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; import com.microsoft.rest.ServiceResponse; public class KeyVaultKeyResolverBCProviderTest extends KeyVaultClientIntegrationTestBase { @@ -79,7 +80,7 @@ public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, Exec { try { // Create a key on a vault. - CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); + CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build(); ServiceResponse response = keyVaultClient.createKey(request); KeyBundle bundle = response != null ? response.getBody() : null; diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java index e6932d917cda1..63708e2b6a085 100755 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java @@ -22,6 +22,7 @@ import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.requests.CreateKeyRequest; import com.microsoft.azure.keyvault.requests.SetSecretRequest; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; // //Copyright © Microsoft Corporation, All Rights Reserved @@ -79,7 +80,7 @@ public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, Exec { try { // Create a key on a vault. - CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build(); + CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build(); KeyBundle keyBundle = keyVaultClient.createKey(request).getBody(); try diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java index e6670116cf5e4..868cab9204858 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java @@ -45,12 +45,12 @@ public class JsonWebKey { * Key type, usually RSA. Possible values include: 'EC', 'RSA', 'RSA-HSM', * 'oct'. */ - private String kty; + private JsonWebKeyType kty; /** * The keyOps property. */ - private List keyOps; + private List keyOps; /** * RSA modulus. @@ -130,7 +130,7 @@ public JsonWebKey withKid(String kid) { * @return the key type. */ @JsonProperty("kty") - public String kty() { + public JsonWebKeyType kty() { return this.kty; } @@ -140,7 +140,7 @@ public String kty() { * @param kty the key type * @return the JsonWebKey object itself. */ - public JsonWebKey withKty(String kty) { + public JsonWebKey withKty(JsonWebKeyType kty) { this.kty = kty; return this; } @@ -151,7 +151,7 @@ public JsonWebKey withKty(String kty) { * @return the key operations. */ @JsonProperty("key_ops") - public List keyOps() { + public List keyOps() { return this.keyOps; } @@ -161,7 +161,7 @@ public List keyOps() { * @param keyOps the key operations value to set * @return the JsonWebKey object itself. */ - public JsonWebKey withKeyOps(List keyOps) { + public JsonWebKey withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } @@ -455,7 +455,7 @@ private PrivateKey getRSAPrivateKey(Provider provider) { * Verifies if the key is an RSA key. */ private void checkRSACompatible() { - if (!JsonWebKeyType.RSA.equals(kty()) && !JsonWebKeyType.RSAHSM.equals(kty())) { + if (!JsonWebKeyType.RSA.equals(kty()) && !JsonWebKeyType.RSA_HSM.equals(kty())) { throw new UnsupportedOperationException("Not an RSA key"); } } diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java index 8eb412e21e412..67e5e99dd08c2 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyEncryptionAlgorithm.java @@ -1,7 +1,7 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. + * license information. */ package com.microsoft.azure.keyvault.webkey; @@ -10,30 +10,58 @@ import java.util.Collections; import java.util.List; +import com.fasterxml.jackson.annotation.JsonValue; + /** - * Supported JsonWebKey Algorithms. + * Defines values for JsonWebKeyEncryptionAlgorithm. */ public final class JsonWebKeyEncryptionAlgorithm { + /** Static value RSA-OAEP for JsonWebKeyEncryptionAlgorithm. */ + public static final JsonWebKeyEncryptionAlgorithm RSA_OAEP = new JsonWebKeyEncryptionAlgorithm("RSA-OAEP"); - /** - * The 'RSA-OAEP' algorithm. - */ - public static final String RSAOAEP = "RSA-OAEP"; - - /** - * The 'RSA1_5' algorithm. - */ - public static final String RSA15 = "RSA1_5"; + /** Static value RSA1_5 for JsonWebKeyEncryptionAlgorithm. */ + public static final JsonWebKeyEncryptionAlgorithm RSA1_5 = new JsonWebKeyEncryptionAlgorithm("RSA1_5"); + + private String value; /** - * All the JWK encryption algorithms. + * Creates a custom value for JsonWebKeyEncryptionAlgorithm. + * @param value the custom value */ - public static final List ALL_ALGORITHMS = - Collections.unmodifiableList( - Arrays.asList(new String[] {RSA15, RSAOAEP})); + public JsonWebKeyEncryptionAlgorithm(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } - private JsonWebKeyEncryptionAlgorithm() { - // not instantiable + @Override + public int hashCode() { + return value.hashCode(); } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JsonWebKeyEncryptionAlgorithm)) { + return false; + } + if (obj == this) { + return true; + } + JsonWebKeyEncryptionAlgorithm rhs = (JsonWebKeyEncryptionAlgorithm) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } + + /** + * All the JWK encryption algorithms. + */ + public static final List ALL_ALGORITHMS = + Collections.unmodifiableList(Arrays.asList(RSA_OAEP, RSA1_5)); } diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java index aeacbc6655ace..9dbb9d30fce67 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyOperation.java @@ -1,7 +1,7 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. + * license information. */ package com.microsoft.azure.keyvault.webkey; @@ -10,50 +10,70 @@ import java.util.Collections; import java.util.List; +import com.fasterxml.jackson.annotation.JsonValue; + /** - * Supported JsonWebKey operations. + * Defines values for JsonWebKeyOperation. */ public final class JsonWebKeyOperation { + /** Static value encrypt for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation ENCRYPT = new JsonWebKeyOperation("encrypt"); - /** - * Encrypt operation. - */ - public static final String ENCRYPT = "encrypt"; - - /** - * Decrypt operation. - */ - public static final String DECRYPT = "decrypt"; - - /** - * Sign operation. - */ - public static final String SIGN = "sign"; - - /** - * Verify operation. - */ - public static final String VERIFY = "verify"; - - /** - * WrapKey operation. - */ - public static final String WRAP = "wrapKey"; - - /** - * UnwrapKey operation. - */ - public static final String UNWRAP = "unwrapKey"; + /** Static value decrypt for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation DECRYPT = new JsonWebKeyOperation("decrypt"); + + /** Static value sign for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation SIGN = new JsonWebKeyOperation("sign"); + + /** Static value verify for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation VERIFY = new JsonWebKeyOperation("verify"); + + /** Static value wrapKey for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation WRAP_KEY = new JsonWebKeyOperation("wrapKey"); + + /** Static value unwrapKey for JsonWebKeyOperation. */ + public static final JsonWebKeyOperation UNWRAP_KEY = new JsonWebKeyOperation("unwrapKey"); + + private String value; /** - * All JWK operations. + * Creates a custom value for JsonWebKeyOperation. + * @param value the custom value */ - public static final List ALL_OPERATIONS = - Collections.unmodifiableList( - Arrays.asList(new String[] {ENCRYPT, DECRYPT, SIGN, VERIFY, WRAP, UNWRAP })); + public JsonWebKeyOperation(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } - private JsonWebKeyOperation() { - // not instantiable + @Override + public int hashCode() { + return value.hashCode(); } + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JsonWebKeyOperation)) { + return false; + } + if (obj == this) { + return true; + } + JsonWebKeyOperation rhs = (JsonWebKeyOperation) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } + + /** + * All the JWK operations. + */ + public static final List ALL_OPERATIONS = + Collections.unmodifiableList(Arrays.asList(ENCRYPT, DECRYPT, SIGN, VERIFY, WRAP_KEY, UNWRAP_KEY)); } diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java index 0dc97946c274b..5e532c10cd297 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeySignatureAlgorithm.java @@ -1,7 +1,7 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. + * license information. */ package com.microsoft.azure.keyvault.webkey; @@ -10,39 +10,64 @@ import java.util.Collections; import java.util.List; +import com.fasterxml.jackson.annotation.JsonValue; + /** - * Supported JsonWebKey Algorithms. + * Defines values for JsonWebKeySignatureAlgorithm. */ public final class JsonWebKeySignatureAlgorithm { + /** Static value RS256 for JsonWebKeySignatureAlgorithm. */ + public static final JsonWebKeySignatureAlgorithm RS256 = new JsonWebKeySignatureAlgorithm("RS256"); - /** - * The 'RS256' algorithm. - */ - public static final String RS256 = "RS256"; - - /** - * The 'RS384' algorithm. - */ - public static final String RS384 = "RS384"; - - /** - * The 'RS512' algorithm. - */ - public static final String RS512 = "RS512"; - - /** - * The 'RSNULL' algorithm. - */ - public static final String RSNULL = "RSNULL"; + /** Static value RS384 for JsonWebKeySignatureAlgorithm. */ + public static final JsonWebKeySignatureAlgorithm RS384 = new JsonWebKeySignatureAlgorithm("RS384"); + + /** Static value RS512 for JsonWebKeySignatureAlgorithm. */ + public static final JsonWebKeySignatureAlgorithm RS512 = new JsonWebKeySignatureAlgorithm("RS512"); + + /** Static value RSNULL for JsonWebKeySignatureAlgorithm. */ + public static final JsonWebKeySignatureAlgorithm RSNULL = new JsonWebKeySignatureAlgorithm("RSNULL"); + + private String value; /** - * All JWK algorithms. + * Creates a custom value for JsonWebKeySignatureAlgorithm. + * @param value the custom value */ - public static final List ALL_ALGORITHMS = - Collections.unmodifiableList( - Arrays.asList(new String[] {RS256, RS384, RS512, RSNULL})); + public JsonWebKeySignatureAlgorithm(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } - private JsonWebKeySignatureAlgorithm() { - // not instantiable + @Override + public int hashCode() { + return value.hashCode(); } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JsonWebKeySignatureAlgorithm)) { + return false; + } + if (obj == this) { + return true; + } + JsonWebKeySignatureAlgorithm rhs = (JsonWebKeySignatureAlgorithm) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } + + /** + * All the JWK signature algorithms. + */ + public static final List ALL_ALGORITHMS = + Collections.unmodifiableList(Arrays.asList(RS256, RS384, RS512, RSNULL)); } diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java index c5bdf89410d9e..8a7c9dbffbc8e 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKeyType.java @@ -1,7 +1,7 @@ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for - * license information. + * license information. */ package com.microsoft.azure.keyvault.webkey; @@ -10,39 +10,64 @@ import java.util.Collections; import java.util.List; +import com.fasterxml.jackson.annotation.JsonValue; + /** - * Supported JsonWebKey key types (kty). + * Defines values for JsonWebKeyType. */ public final class JsonWebKeyType { + /** Static value EC for JsonWebKeyType. */ + public static final JsonWebKeyType EC = new JsonWebKeyType("EC"); - /** - * The Elliptic Curve 'EC' key type. - */ - public static final String EC = "EC"; - - /** - * The 'RSA' key type. - */ - public static final String RSA = "RSA"; - - /** - * The 'RSA-HSM' key type. - */ - public static final String RSAHSM = "RSA-HSM"; - - /** - * The Octet 'oct' key type. - */ - public static final String OCT = "oct"; + /** Static value RSA for JsonWebKeyType. */ + public static final JsonWebKeyType RSA = new JsonWebKeyType("RSA"); + + /** Static value RSA-HSM for JsonWebKeyType. */ + public static final JsonWebKeyType RSA_HSM = new JsonWebKeyType("RSA-HSM"); + + /** Static value oct for JsonWebKeyType. */ + public static final JsonWebKeyType OCT = new JsonWebKeyType("oct"); + + private String value; /** - * All JWK key types. + * Creates a custom value for JsonWebKeyType. + * @param value the custom value */ - public static final List ALL_TYPES = - Collections.unmodifiableList( - Arrays.asList(new String[] {EC, RSA, RSAHSM, OCT})); + public JsonWebKeyType(String value) { + this.value = value; + } + + @JsonValue + @Override + public String toString() { + return value; + } - private JsonWebKeyType() { - // not instantiable + @Override + public int hashCode() { + return value.hashCode(); } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof JsonWebKeyType)) { + return false; + } + if (obj == this) { + return true; + } + JsonWebKeyType rhs = (JsonWebKeyType) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } + + /** + * All the JWK key types. + */ + public static final List ALL_TYPES = + Collections.unmodifiableList(Arrays.asList(EC, RSA, RSA_HSM, OCT)); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 2aae9e82f23b3..0dbb76b43010b 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -41,11 +41,12 @@ import com.microsoft.azure.keyvault.requests.UpdateCertificateRequest; import com.microsoft.azure.keyvault.requests.UpdateKeyRequest; import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; import com.microsoft.azure.RestClient; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.ServiceResponseCallback; import com.microsoft.rest.credentials.ServiceClientCredentials; import okhttp3.ResponseBody; @@ -56,6 +57,8 @@ import retrofit2.http.Headers; import retrofit2.http.Path; import retrofit2.http.Query; +import rx.Observable; +import rx.functions.Func1; /** * Initializes a new instance of the KeyVaultClient class. @@ -179,7 +182,7 @@ private void initializeService() { interface KeyVaultClientService { @Headers({"Content-Type: application/json; charset=utf-8", "Accept: application/pkcs10"}) @GET("certificates/{certificate-name}/pending") - Call getPendingCertificateSigningRequest(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getPendingCertificateSigningRequest(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); } /** @@ -585,7 +588,7 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse encrypt(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse encrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -600,7 +603,7 @@ public ServiceResponse encrypt(String keyIdentifier, String * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall encryptAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall encryptAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encryptAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -616,7 +619,7 @@ public ServiceCall encryptAsync(String keyIdentifier, String * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse decrypt(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse decrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -631,7 +634,7 @@ public ServiceResponse decrypt(String keyIdentifier, String * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall decryptAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall decryptAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decryptAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -647,7 +650,7 @@ public ServiceCall decryptAsync(String keyIdentifier, String * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse sign(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse sign(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.sign(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -662,7 +665,7 @@ public ServiceResponse sign(String keyIdentifier, String alg * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall signAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall signAsync(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.signAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -679,7 +682,7 @@ public ServiceCall signAsync(String keyIdentifier, String al * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse verify(String keyIdentifier, String algorithm, byte[] digest, byte[] signature) + public ServiceResponse verify(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verify(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature); @@ -695,7 +698,7 @@ public ServiceResponse verify(String keyIdentifier, String algo * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall verifyAsync(String keyIdentifier, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { + public ServiceCall verifyAsync(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verifyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature, serviceCallback); } @@ -711,7 +714,7 @@ public ServiceCall verifyAsync(String keyIdentifier, String alg * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse wrapKey(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse wrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -726,7 +729,7 @@ public ServiceResponse wrapKey(String keyIdentifier, String * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall wrapKeyAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall wrapKeyAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -742,7 +745,7 @@ public ServiceCall wrapKeyAsync(String keyIdentifier, String * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse unwrapKey(String keyIdentifier, String algorithm, byte[] value) + public ServiceResponse unwrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -757,7 +760,7 @@ public ServiceResponse unwrapKey(String keyIdentifier, Strin * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ - public ServiceCall unwrapKeyAsync(String keyIdentifier, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall unwrapKeyAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -1857,19 +1860,7 @@ public ServiceCall mergeCertificateAsync(MergeCertificateRequ */ public ServiceResponse getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - Response response = call.execute(); - return new ServiceResponse(response.body().string(), response); + return getPendingCertificateSigningRequestAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -1881,6 +1872,17 @@ public ServiceResponse getPendingCertificateSigningRequest(String vaultB * @return the {@link ServiceCall} object */ public ServiceCall getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getPendingCertificateSigningRequestAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Gets the pending certificate signing request response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the String object + */ + private Observable> getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1891,24 +1893,17 @@ public ServiceCall getPendingCertificateSigningRequestAsync(String vault throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - if (serviceCallback != null) { - serviceCallback.success(new ServiceResponse(response.body().string(), response)); - } - serviceCall.success(new ServiceResponse(response.body().string(), response)); - } catch (IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getPendingCertificateSigningRequest(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = new ServiceResponse(response.body().string(), response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 4c9e596423269..156945410742d 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -13,6 +13,7 @@ import com.google.common.base.Joiner; import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceCall; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.AzureServiceResponseBuilder; import com.microsoft.azure.keyvault.models.BackupKeyResult; @@ -54,6 +55,10 @@ import com.microsoft.azure.keyvault.models.SecretSetParameters; import com.microsoft.azure.keyvault.models.SecretUpdateParameters; import com.microsoft.azure.keyvault.webkey.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; import com.microsoft.azure.keyvault.webkey.Base64UrlJsonSerializer; import com.microsoft.azure.keyvault.webkey.Base64UrlJsonDeserializer; import com.microsoft.azure.ListOperationCallback; @@ -61,16 +66,15 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.RestClient; import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestException; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; -import com.microsoft.rest.ServiceResponseCallback; import com.microsoft.rest.Validator; import java.io.IOException; import java.util.List; import java.util.Map; import okhttp3.ResponseBody; -import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.GET; import retrofit2.http.Header; @@ -83,6 +87,8 @@ import retrofit2.http.Query; import retrofit2.http.Url; import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; /** * Initializes a new instance of the KeyVaultClientImpl class. @@ -246,199 +252,199 @@ private void initializeService() { interface KeyVaultClientService { @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/create") - Call createKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> createKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("keys/{key-name}") - Call importKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> importKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "keys/{key-name}", method = "DELETE", hasBody = true) - Call deleteKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("keys/{key-name}/{key-version}") - Call updateKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys/{key-name}/{key-version}") - Call getKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys/{key-name}/versions") - Call getKeyVersions(@Path("key-name") String keyName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getKeyVersions(@Path("key-name") String keyName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("keys") - Call getKeys(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getKeys(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/backup") - Call backupKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> backupKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/restore") - Call restoreKey(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyRestoreParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> restoreKey(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyRestoreParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/encrypt") - Call encrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> encrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/decrypt") - Call decrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> decrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/sign") - Call sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeySignParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeySignParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/verify") - Call verify(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyVerifyParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> verify(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyVerifyParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/wrapkey") - Call wrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> wrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("keys/{key-name}/{key-version}/unwrapkey") - Call unwrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> unwrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("secrets/{secret-name}") - Call setSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretSetParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> setSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretSetParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "secrets/{secret-name}", method = "DELETE", hasBody = true) - Call deleteSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("secrets/{secret-name}/{secret-version}") - Call updateSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets/{secret-name}/{secret-version}") - Call getSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets") - Call getSecrets(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getSecrets(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("secrets/{secret-name}/versions") - Call getSecretVersions(@Path("secret-name") String secretName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getSecretVersions(@Path("secret-name") String secretName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates") - Call getCertificates(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificates(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/{certificate-name}", method = "DELETE", hasBody = true) - Call deleteCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/contacts") - Call setCertificateContacts(@Body Contacts contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> setCertificateContacts(@Body Contacts contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/contacts") - Call getCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/contacts", method = "DELETE", hasBody = true) - Call deleteCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers") - Call getCertificateIssuers(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateIssuers(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PUT("certificates/issuers/{issuer-name}") - Call setCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerSetParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> setCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerSetParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/issuers/{issuer-name}") - Call updateCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerUpdateParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerUpdateParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/issuers/{issuer-name}") - Call getCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/issuers/{issuer-name}", method = "DELETE", hasBody = true) - Call deleteCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/create") - Call createCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> createCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/import") - Call importCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> importCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/versions") - Call getCertificateVersions(@Path("certificate-name") String certificateName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateVersions(@Path("certificate-name") String certificateName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/policy") - Call getCertificatePolicy(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificatePolicy(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/policy") - Call updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicy certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicy certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/{certificate-version}") - Call updateCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/{certificate-version}") - Call getCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @PATCH("certificates/{certificate-name}/pending") - Call updateCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateOperationUpdateParameter certificateOperation, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> updateCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateOperationUpdateParameter certificateOperation, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET("certificates/{certificate-name}/pending") - Call getCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> getCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @HTTP(path = "certificates/{certificate-name}/pending", method = "DELETE", hasBody = true) - Call deleteCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> deleteCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @POST("certificates/{certificate-name}/pending/merge") - Call mergeCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateMergeParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + Observable> mergeCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateMergeParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getKeyVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getKeyVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getKeysNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getKeysNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getSecretsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getSecretsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getSecretVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getSecretVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getCertificatesNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getCertificatesNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getCertificateIssuersNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getCertificateIssuersNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @Headers("Content-Type: application/json; charset=utf-8") @GET - Call getCertificateVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getCertificateVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); } @@ -447,38 +453,14 @@ interface KeyVaultClientService { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (kty == null) { - throw new IllegalArgumentException("Parameter kty is required and cannot be null."); - } - final Integer keySize = null; - final List keyOps = null; - final KeyAttributes keyAttributes = null; - final Map tags = null; - KeyCreateParameters parameters = new KeyCreateParameters(); - parameters.withKty(kty); - parameters.withKeySize(null); - parameters.withKeyOps(null); - parameters.withKeyAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return createKeyDelegate(call.execute()); + public ServiceResponse createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createKeyAsync(vaultBaseUrl, keyName, kty).toBlocking().single(); } /** @@ -486,11 +468,23 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, final ServiceCallback serviceCallback) { + return ServiceCall.create(createKeyAsync(vaultBaseUrl, keyName, kty), serviceCallback); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @return the observable to the KeyBundle object */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, final ServiceCallback serviceCallback) { + public Observable> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -504,7 +498,7 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName throw new IllegalArgumentException("Parameter kty is required and cannot be null."); } final Integer keySize = null; - final List keyOps = null; + final List keyOps = null; final KeyAttributes keyAttributes = null; final Map tags = null; KeyCreateParameters parameters = new KeyCreateParameters(); @@ -514,26 +508,18 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = createKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -541,9 +527,9 @@ public void onResponse(Call call, Response response) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param keySize The key size in bytes. e.g. 1024 or 2048. - * @param keyOps the List<String> value + * @param keyOps the List<JsonWebKeyOperation> value * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @throws KeyVaultErrorException exception thrown from REST call @@ -551,31 +537,8 @@ public void onResponse(Call call, Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (kty == null) { - throw new IllegalArgumentException("Parameter kty is required and cannot be null."); - } - Validator.validate(keyOps); - Validator.validate(keyAttributes); - Validator.validate(tags); - KeyCreateParameters parameters = new KeyCreateParameters(); - parameters.withKty(kty); - parameters.withKeySize(keySize); - parameters.withKeyOps(keyOps); - parameters.withKeyAttributes(keyAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return createKeyDelegate(call.execute()); + public ServiceResponse createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createKeyAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).toBlocking().single(); } /** @@ -583,15 +546,31 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param keySize The key size in bytes. e.g. 1024 or 2048. - * @param keyOps the List<String> value + * @param keyOps the List<JsonWebKeyOperation> value * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(createKeyAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags), serviceCallback); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param keySize The key size in bytes. e.g. 1024 or 2048. + * @param keyOps the List<JsonWebKeyOperation> value + * @param keyAttributes the KeyAttributes value + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, String kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + public Observable> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -614,26 +593,18 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = createKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.createKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse createKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -655,30 +626,7 @@ private ServiceResponse createKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (key == null) { - throw new IllegalArgumentException("Parameter key is required and cannot be null."); - } - Validator.validate(key); - final Boolean hsm = null; - final KeyAttributes keyAttributes = null; - final Map tags = null; - KeyImportParameters parameters = new KeyImportParameters(); - parameters.withHsm(null); - parameters.withKey(key); - parameters.withKeyAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return importKeyDelegate(call.execute()); + return importKeyAsync(vaultBaseUrl, keyName, key).toBlocking().single(); } /** @@ -688,9 +636,21 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param key The Json web key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, final ServiceCallback serviceCallback) { + return ServiceCall.create(importKeyAsync(vaultBaseUrl, keyName, key), serviceCallback); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @return the observable to the KeyBundle object + */ + public Observable> importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -713,26 +673,18 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = importKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = importKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -750,29 +702,7 @@ public void onResponse(Call call, Response response) * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (key == null) { - throw new IllegalArgumentException("Parameter key is required and cannot be null."); - } - Validator.validate(key); - Validator.validate(keyAttributes); - Validator.validate(tags); - KeyImportParameters parameters = new KeyImportParameters(); - parameters.withHsm(hsm); - parameters.withKey(key); - parameters.withKeyAttributes(keyAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return importKeyDelegate(call.execute()); + return importKeyAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).toBlocking().single(); } /** @@ -785,9 +715,24 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @param keyAttributes The key management attributes * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(importKeyAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags), serviceCallback); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @param hsm Whether to import as a hardware key (HSM) or software key + * @param keyAttributes The key management attributes + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object + */ + public Observable> importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -800,7 +745,6 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName if (key == null) { throw new IllegalArgumentException("Parameter key is required and cannot be null."); } - Validator.validate(key); Validator.validate(keyAttributes); Validator.validate(tags); KeyImportParameters parameters = new KeyImportParameters(); @@ -809,26 +753,18 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = importKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.importKey(keyName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = importKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse importKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -849,18 +785,7 @@ private ServiceResponse importKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteKeyDelegate(call.execute()); + return deleteKeyAsync(vaultBaseUrl, keyName).toBlocking().single(); } /** @@ -869,9 +794,20 @@ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteKeyAsync(vaultBaseUrl, keyName), serviceCallback); + } + + /** + * Deletes the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the KeyBundle object + */ + public Observable> deleteKeyAsync(String vaultBaseUrl, String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -882,26 +818,18 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.deleteKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -923,28 +851,7 @@ private ServiceResponse deleteKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final List keyOps = null; - final KeyAttributes keyAttributes = null; - final Map tags = null; - KeyUpdateParameters parameters = new KeyUpdateParameters(); - parameters.withKeyOps(null); - parameters.withKeyAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateKeyDelegate(call.execute()); + return updateKeyAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single(); } /** @@ -954,9 +861,21 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @param keyName The name of the key * @param keyVersion The version of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateKeyAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @return the observable to the KeyBundle object + */ + public Observable> updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -969,7 +888,7 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - final List keyOps = null; + final List keyOps = null; final KeyAttributes keyAttributes = null; final Map tags = null; KeyUpdateParameters parameters = new KeyUpdateParameters(); @@ -977,26 +896,18 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -1013,29 +924,8 @@ public void onResponse(Call call, Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(keyOps); - Validator.validate(keyAttributes); - Validator.validate(tags); - KeyUpdateParameters parameters = new KeyUpdateParameters(); - parameters.withKeyOps(keyOps); - parameters.withKeyAttributes(keyAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateKeyDelegate(call.execute()); + public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateKeyAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).toBlocking().single(); } /** @@ -1048,9 +938,24 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @param keyAttributes the KeyAttributes value * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateKeyAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags), serviceCallback); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. + * @param keyAttributes the KeyAttributes value + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object */ - public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + public Observable> updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1071,26 +976,18 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName parameters.withKeyAttributes(keyAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1112,21 +1009,7 @@ private ServiceResponse updateKeyDelegate(Response resp * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getKeyDelegate(call.execute()); + return getKeyAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single(); } /** @@ -1136,9 +1019,21 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyName, St * @param keyName The name of the key * @param keyVersion The version of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(getKeyAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @return the observable to the KeyBundle object + */ + public Observable> getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1152,26 +1047,18 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.getKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1192,26 +1079,14 @@ private ServiceResponse getKeyDelegate(Response respons * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeyVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getKeyVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1220,9 +1095,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName) { + return getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1234,32 +1146,18 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeyVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeyVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -1274,25 +1172,14 @@ public void onResponse(Call call, Response response) * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeyVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getKeyVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1302,9 +1189,48 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * @param keyName The name of the key * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param maxresults Maximum number of results to return. + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { + return getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified key. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param keyName The name of the key + ServiceResponse> * @param maxresults Maximum number of results to return. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1315,32 +1241,18 @@ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeyVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getKeyVersions(keyName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeyVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getKeyVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1360,23 +1272,14 @@ private ServiceResponse> getKeyVersionsDelegate(Response> getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeysDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getKeysNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1384,9 +1287,44 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeysSinglePageAsync(vaultBaseUrl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeysAsync(final String vaultBaseUrl) { + return getKeysSinglePageAsync(vaultBaseUrl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeysNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeysSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1395,32 +1333,18 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeysDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeysDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -1434,22 +1358,14 @@ public void onResponse(Call call, Response response) * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getKeysDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getKeysNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1458,9 +1374,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorException * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeysSinglePageAsync(vaultBaseUrl, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeysAsync(final String vaultBaseUrl, final Integer maxresults) { + return getKeysSinglePageAsync(vaultBaseUrl, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeysNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List keys in the specified vault. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param maxresults Maximum number of results to return. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeysSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1468,32 +1421,18 @@ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeysDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getKeys(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeysDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getKeysDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1514,18 +1453,7 @@ private ServiceResponse> getKeysDelegate(Response backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return backupKeyDelegate(call.execute()); + return backupKeyAsync(vaultBaseUrl, keyName).toBlocking().single(); } /** @@ -1534,9 +1462,20 @@ public ServiceResponse backupKey(String vaultBaseUrl, String ke * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { + return ServiceCall.create(backupKeyAsync(vaultBaseUrl, keyName), serviceCallback); + } + + /** + * Requests that a backup of the specified key be downloaded to the client. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the BackupKeyResult object + */ + public Observable> backupKeyAsync(String vaultBaseUrl, String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1547,26 +1486,18 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String k throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = backupKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.backupKey(keyName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = backupKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse backupKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1587,20 +1518,7 @@ private ServiceResponse backupKeyDelegate(Response restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (keyBundleBackup == null) { - throw new IllegalArgumentException("Parameter keyBundleBackup is required and cannot be null."); - } - KeyRestoreParameters parameters = new KeyRestoreParameters(); - parameters.withKeyBundleBackup(keyBundleBackup); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return restoreKeyDelegate(call.execute()); + return restoreKeyAsync(vaultBaseUrl, keyBundleBackup).toBlocking().single(); } /** @@ -1609,9 +1527,20 @@ public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBund * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyBundleBackup the backup blob associated with a key bundle * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { + return ServiceCall.create(restoreKeyAsync(vaultBaseUrl, keyBundleBackup), serviceCallback); + } + + /** + * Restores the backup key in to a vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyBundleBackup the backup blob associated with a key bundle + * @return the observable to the KeyBundle object + */ + public Observable> restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1624,26 +1553,18 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun KeyRestoreParameters parameters = new KeyRestoreParameters(); parameters.withKeyBundleBackup(keyBundleBackup); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = restoreKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.restoreKey(this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = restoreKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse restoreKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1666,31 +1587,8 @@ private ServiceResponse restoreKeyDelegate(Response res * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse encrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return encryptDelegate(call.execute()); + public ServiceResponse encrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return encryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); } /** @@ -1702,9 +1600,23 @@ public ServiceResponse encrypt(String vaultBaseUrl, String k * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(encryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object */ - public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public Observable> encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1727,26 +1639,18 @@ public ServiceCall encryptAsync(String vaultBaseUrl, String parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = encryptDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.encrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = encryptDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse encryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1769,31 +1673,8 @@ private ServiceResponse encryptDelegate(Response decrypt(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return decryptDelegate(call.execute()); + public ServiceResponse decrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return decryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); } /** @@ -1805,9 +1686,23 @@ public ServiceResponse decrypt(String vaultBaseUrl, String k * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(decryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Decrypts a single block of encrypted data. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object */ - public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public Observable> decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1830,26 +1725,18 @@ public ServiceCall decryptAsync(String vaultBaseUrl, String parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = decryptDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.decrypt(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = decryptDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse decryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1872,7 +1759,36 @@ private ServiceResponse decryptDelegate(Response sign(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public ServiceResponse sign(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return signAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + } + + /** + * Creates a signature from a digest using the specified key in the vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param value the Base64Url value + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(signAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Creates a signature from a digest using the specified key in the vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1895,64 +1811,18 @@ public ServiceResponse sign(String vaultBaseUrl, String keyN parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return signDelegate(call.execute()); - } - - /** - * Creates a signature from a digest using the specified key in the vault. - * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' - * @param value the Base64Url value - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object - */ - public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeySignParameters parameters = new KeySignParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = signDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); - } - } - }); - return serviceCall; + return service.sign(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = signDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); } private ServiceResponse signDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -1976,35 +1846,8 @@ private ServiceResponse signDelegate(Response * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse verify(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (digest == null) { - throw new IllegalArgumentException("Parameter digest is required and cannot be null."); - } - if (signature == null) { - throw new IllegalArgumentException("Parameter signature is required and cannot be null."); - } - KeyVerifyParameters parameters = new KeyVerifyParameters(); - parameters.withAlgorithm(algorithm); - parameters.withDigest(digest); - parameters.withSignature(signature); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return verifyDelegate(call.execute()); + public ServiceResponse verify(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return verifyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).toBlocking().single(); } /** @@ -2017,9 +1860,24 @@ public ServiceResponse verify(String vaultBaseUrl, String keyNa * @param digest The digest used for signing * @param signature The signature to be verified * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ - public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { + public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { + return ServiceCall.create(verifyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature), serviceCallback); + } + + /** + * Verifies a signature using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param digest The digest used for signing + * @param signature The signature to be verified + * @return the observable to the KeyVerifyResult object + */ + public Observable> verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2046,26 +1904,18 @@ public ServiceCall verifyAsync(String vaultBaseUrl, String keyN parameters.withDigest(digest); parameters.withSignature(signature); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = verifyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.verify(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = verifyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse verifyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2088,31 +1938,8 @@ private ServiceResponse verifyDelegate(Response r * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse wrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return wrapKeyDelegate(call.execute()); + public ServiceResponse wrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return wrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); } /** @@ -2124,9 +1951,23 @@ public ServiceResponse wrapKey(String vaultBaseUrl, String k * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(wrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Wraps a symmetric key using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object */ - public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public Observable> wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2149,26 +1990,18 @@ public ServiceCall wrapKeyAsync(String vaultBaseUrl, String parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = wrapKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.wrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = wrapKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse wrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2191,31 +2024,8 @@ private ServiceResponse wrapKeyDelegate(Response unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (keyName == null) { - throw new IllegalArgumentException("Parameter keyName is required and cannot be null."); - } - if (keyVersion == null) { - throw new IllegalArgumentException("Parameter keyVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (algorithm == null) { - throw new IllegalArgumentException("Parameter algorithm is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - KeyOperationsParameters parameters = new KeyOperationsParameters(); - parameters.withAlgorithm(algorithm); - parameters.withValue(value); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return unwrapKeyDelegate(call.execute()); + public ServiceResponse unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return unwrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); } /** @@ -2227,9 +2037,23 @@ public ServiceResponse unwrapKey(String vaultBaseUrl, String * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ - public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, String algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceCall.create(unwrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2252,26 +2076,18 @@ public ServiceCall unwrapKeyAsync(String vaultBaseUrl, Strin parameters.withAlgorithm(algorithm); parameters.withValue(value); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = unwrapKeyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.unwrapKey(keyName, keyVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = unwrapKeyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse unwrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2293,29 +2109,7 @@ private ServiceResponse unwrapKeyDelegate(Response setSecret(String vaultBaseUrl, String secretName, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - final Map tags = null; - final String contentType = null; - final SecretAttributes secretAttributes = null; - SecretSetParameters parameters = new SecretSetParameters(); - parameters.withValue(value); - parameters.withTags(null); - parameters.withContentType(null); - parameters.withSecretAttributes(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return setSecretDelegate(call.execute()); + return setSecretAsync(vaultBaseUrl, secretName, value).toBlocking().single(); } /** @@ -2325,9 +2119,21 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @param secretName The name of the secret in the given vault * @param value The value of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) { + return ServiceCall.create(setSecretAsync(vaultBaseUrl, secretName, value), serviceCallback); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @return the observable to the SecretBundle object + */ + public Observable> setSecretAsync(String vaultBaseUrl, String secretName, String value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2349,26 +2155,18 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secr parameters.withContentType(null); parameters.withSecretAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -2386,28 +2184,7 @@ public void onResponse(Call call, Response response) * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (value == null) { - throw new IllegalArgumentException("Parameter value is required and cannot be null."); - } - Validator.validate(tags); - Validator.validate(secretAttributes); - SecretSetParameters parameters = new SecretSetParameters(); - parameters.withValue(value); - parameters.withTags(tags); - parameters.withContentType(contentType); - parameters.withSecretAttributes(secretAttributes); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return setSecretDelegate(call.execute()); + return setSecretAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).toBlocking().single(); } /** @@ -2420,9 +2197,24 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @param contentType Type of the secret value such as a password * @param secretAttributes The secret management attributes * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes, final ServiceCallback serviceCallback) { + return ServiceCall.create(setSecretAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes), serviceCallback); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @param tags Application-specific metadata in the form of key-value pairs + * @param contentType Type of the secret value such as a password + * @param secretAttributes The secret management attributes + * @return the observable to the SecretBundle object + */ + public Observable> setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2443,26 +2235,18 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secr parameters.withContentType(contentType); parameters.withSecretAttributes(secretAttributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.setSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse setSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2483,18 +2267,7 @@ private ServiceResponse setSecretDelegate(Response r * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteSecretDelegate(call.execute()); + return deleteSecretAsync(vaultBaseUrl, secretName).toBlocking().single(); } /** @@ -2503,9 +2276,20 @@ public ServiceResponse deleteSecret(String vaultBaseUrl, String se * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteSecretAsync(vaultBaseUrl, secretName), serviceCallback); + } + + /** + * Deletes a secret from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the observable to the SecretBundle object + */ + public Observable> deleteSecretAsync(String vaultBaseUrl, String secretName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2516,26 +2300,18 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String s throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.deleteSecret(secretName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2557,28 +2333,7 @@ private ServiceResponse deleteSecretDelegate(Response updateSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (secretVersion == null) { - throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final String contentType = null; - final SecretAttributes secretAttributes = null; - final Map tags = null; - SecretUpdateParameters parameters = new SecretUpdateParameters(); - parameters.withContentType(null); - parameters.withSecretAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateSecretDelegate(call.execute()); + return updateSecretAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single(); } /** @@ -2588,9 +2343,21 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateSecretAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @return the observable to the SecretBundle object + */ + public Observable> updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2611,26 +2378,18 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String s parameters.withSecretAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -2648,27 +2407,7 @@ public void onResponse(Call call, Response response) * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (secretVersion == null) { - throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(secretAttributes); - Validator.validate(tags); - SecretUpdateParameters parameters = new SecretUpdateParameters(); - parameters.withContentType(contentType); - parameters.withSecretAttributes(secretAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateSecretDelegate(call.execute()); + return updateSecretAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).toBlocking().single(); } /** @@ -2681,9 +2420,24 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @param secretAttributes The secret management attributes * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateSecretAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags), serviceCallback); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @param contentType Type of the secret value such as a password + * @param secretAttributes The secret management attributes + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the SecretBundle object + */ + public Observable> updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2703,26 +2457,18 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String s parameters.withSecretAttributes(secretAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2744,21 +2490,7 @@ private ServiceResponse updateSecretDelegate(Response getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (secretVersion == null) { - throw new IllegalArgumentException("Parameter secretVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getSecretDelegate(call.execute()); + return getSecretAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single(); } /** @@ -2768,9 +2500,21 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(getSecretAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + } + + /** + * Gets a secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @return the observable to the SecretBundle object + */ + public Observable> getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2784,26 +2528,18 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getSecretDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getSecret(secretName, secretVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getSecretDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2823,23 +2559,14 @@ private ServiceResponse getSecretDelegate(Response r * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getSecretsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -2847,9 +2574,44 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretsSinglePageAsync(vaultBaseUrl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretsAsync(final String vaultBaseUrl) { + return getSecretsSinglePageAsync(vaultBaseUrl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretsSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2858,32 +2620,18 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -2897,22 +2645,14 @@ public void onResponse(Call call, Response response) * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getSecretsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -2921,9 +2661,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of secrets to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretsSinglePageAsync(vaultBaseUrl, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of secrets to return. + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults) { + return getSecretsSinglePageAsync(vaultBaseUrl, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List secrets in the specified vault. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param maxresults Maximum number of secrets to return. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretsSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2931,32 +2708,18 @@ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getSecrets(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getSecretsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -2977,26 +2740,14 @@ private ServiceResponse> getSecretsDelegate(Response> getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getSecretVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -3005,9 +2756,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName) { + return getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3019,32 +2807,18 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -3059,25 +2833,35 @@ public void onResponse(Call call, Response response) * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (secretName == null) { - throw new IllegalArgumentException("Parameter secretName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getSecretVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getSecretVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param maxresults Maximum number of results to return. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); } /** @@ -3086,10 +2870,28 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorExcept * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param maxresults Maximum number of results to return. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { + return getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified secret. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param secretName The name of the secret in the given vault + ServiceResponse> * @param maxresults Maximum number of results to return. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { + public Observable>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3100,32 +2902,18 @@ public ServiceCall> getSecretVersionsAsync(final String vaultBa throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getSecretVersions(secretName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getSecretVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3145,23 +2933,14 @@ private ServiceResponse> getSecretVersionsDelegate(Response * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificatesDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificatesNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -3169,9 +2948,44 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificatesSinglePageAsync(vaultBaseUrl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificatesAsync(final String vaultBaseUrl) { + return getCertificatesSinglePageAsync(vaultBaseUrl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificatesSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3180,32 +2994,18 @@ public ServiceCall> getCertificatesAsync(final String vaul } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificatesDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificatesDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -3219,22 +3019,14 @@ public void onResponse(Call call, Response response) * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificatesDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificatesNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -3243,9 +3035,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificatesSinglePageAsync(vaultBaseUrl, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults) { + return getCertificatesSinglePageAsync(vaultBaseUrl, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificates in the specified vault. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param maxresults Maximum number of results to return. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificatesSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3253,32 +3082,18 @@ public ServiceCall> getCertificatesAsync(final String vaul throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificatesDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getCertificates(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificatesDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificatesDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3299,18 +3114,7 @@ private ServiceResponse> getCertificatesDelegate(Respo * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteCertificateDelegate(call.execute()); + return deleteCertificateAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -3319,9 +3123,20 @@ public ServiceResponse deleteCertificate(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteCertificateAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Deletes a certificate from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @return the observable to the CertificateBundle object + */ + public Observable> deleteCertificateAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3332,26 +3147,18 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.deleteCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3372,19 +3179,7 @@ private ServiceResponse deleteCertificateDelegate(Response setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (contacts == null) { - throw new IllegalArgumentException("Parameter contacts is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(contacts); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return setCertificateContactsDelegate(call.execute()); + return setCertificateContactsAsync(vaultBaseUrl, contacts).toBlocking().single(); } /** @@ -3393,9 +3188,20 @@ public ServiceResponse setCertificateContacts(String vaultBaseUrl, Con * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param contacts The contacts for the vault certificates. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { + return ServiceCall.create(setCertificateContactsAsync(vaultBaseUrl, contacts), serviceCallback); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param contacts The contacts for the vault certificates. + * @return the observable to the Contacts object + */ + public Observable> setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3407,26 +3213,18 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Co } Validator.validate(contacts); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setCertificateContactsDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.setCertificateContacts(contacts, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setCertificateContactsDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse setCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3446,15 +3244,7 @@ private ServiceResponse setCertificateContactsDelegate(Response getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificateContactsDelegate(call.execute()); + return getCertificateContactsAsync(vaultBaseUrl).toBlocking().single(); } /** @@ -3462,9 +3252,19 @@ public ServiceResponse getCertificateContacts(String vaultBaseUrl) thr * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificateContactsAsync(vaultBaseUrl), serviceCallback); + } + + /** + * Gets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the Contacts object + */ + public Observable> getCertificateContactsAsync(String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3472,26 +3272,18 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, fi throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificateContactsDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.getCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificateContactsDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3511,15 +3303,7 @@ private ServiceResponse getCertificateContactsDelegate(Response deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteCertificateContactsDelegate(call.execute()); + return deleteCertificateContactsAsync(vaultBaseUrl).toBlocking().single(); } /** @@ -3527,9 +3311,19 @@ public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteCertificateContactsAsync(vaultBaseUrl), serviceCallback); + } + + /** + * Deletes the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the Contacts object + */ + public Observable> deleteCertificateContactsAsync(String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3537,26 +3331,18 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteCertificateContactsDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.deleteCertificateContacts(this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteCertificateContactsDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3576,23 +3362,14 @@ private ServiceResponse deleteCertificateContactsDelegate(Response> getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificateIssuersNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -3600,9 +3377,44 @@ public Page nextPage(String nextPageLink) throws KeyVault * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateIssuersSinglePageAsync(vaultBaseUrl), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the List<CertificateIssuerItem> object + */ + public Observable>> getCertificateIssuersAsync(final String vaultBaseUrl) { + return getCertificateIssuersSinglePageAsync(vaultBaseUrl) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3611,32 +3423,18 @@ public ServiceCall> getCertificateIssuersAsync(final } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateIssuersDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateIssuersDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -3650,22 +3448,14 @@ public void onResponse(Call call, Response response) * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateIssuersDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificateIssuersNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -3674,9 +3464,46 @@ public Page nextPage(String nextPageLink) throws KeyVault * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return. + * @return the observable to the List<CertificateIssuerItem> object + */ + public Observable>> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults) { + return getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param maxresults Maximum number of results to return. + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3684,32 +3511,18 @@ public ServiceCall> getCertificateIssuersAsync(final throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateIssuersDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } + return service.getCertificateIssuers(maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateIssuersDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificateIssuersDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3724,36 +3537,14 @@ private ServiceResponse> getCertificateIssuersDe * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. + * @param provider The issuer provider. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (provider == null) { - throw new IllegalArgumentException("Parameter provider is required and cannot be null."); - } - final IssuerCredentials credentials = null; - final OrganizationDetails organizationDetails = null; - final IssuerAttributes attributes = null; - CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); - parameter.withProvider(provider); - parameter.withCredentials(null); - parameter.withOrganizationDetails(null); - parameter.withAttributes(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - return setCertificateIssuerDelegate(call.execute()); + return setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider).toBlocking().single(); } /** @@ -3761,11 +3552,23 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. + * @param provider The issuer provider. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { + return ServiceCall.create(setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider), serviceCallback); + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The issuer provider. + * @return the observable to the IssuerBundle object + */ + public Observable> setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3787,26 +3590,18 @@ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, parameter.withOrganizationDetails(null); parameter.withAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -3814,7 +3609,7 @@ public void onResponse(Call call, Response response) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. + * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. * @param organizationDetails Details of the organization as provided to the issuer. * @param attributes Attributes of the issuer object. @@ -3823,30 +3618,8 @@ public void onResponse(Call call, Response response) * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (provider == null) { - throw new IllegalArgumentException("Parameter provider is required and cannot be null."); - } - Validator.validate(credentials); - Validator.validate(organizationDetails); - Validator.validate(attributes); - CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); - parameter.withProvider(provider); - parameter.withCredentials(credentials); - parameter.withOrganizationDetails(organizationDetails); - parameter.withAttributes(attributes); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - return setCertificateIssuerDelegate(call.execute()); + public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single(); } /** @@ -3854,14 +3627,29 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. + * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. * @param organizationDetails Details of the organization as provided to the issuer. * @param attributes Attributes of the issuer object. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { + return ServiceCall.create(setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The issuer provider. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @return the observable to the IssuerBundle object + */ + public Observable> setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3883,26 +3671,18 @@ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, parameter.withOrganizationDetails(organizationDetails); parameter.withAttributes(attributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = setCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = setCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse setCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -3917,36 +3697,13 @@ private ServiceResponse setCertificateIssuerDelegate(Response updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (provider == null) { - throw new IllegalArgumentException("Parameter provider is required and cannot be null."); - } - final IssuerCredentials credentials = null; - final OrganizationDetails organizationDetails = null; - final IssuerAttributes attributes = null; - CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); - parameter.withProvider(provider); - parameter.withCredentials(null); - parameter.withOrganizationDetails(null); - parameter.withAttributes(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - return updateCertificateIssuerDelegate(call.execute()); + public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); } /** @@ -3954,11 +3711,21 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object + */ + public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object */ - public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { + public Observable> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3968,38 +3735,28 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUr if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - if (provider == null) { - throw new IllegalArgumentException("Parameter provider is required and cannot be null."); - } + final String provider = null; final IssuerCredentials credentials = null; final OrganizationDetails organizationDetails = null; final IssuerAttributes attributes = null; CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); - parameter.withProvider(provider); + parameter.withProvider(null); parameter.withCredentials(null); parameter.withOrganizationDetails(null); parameter.withAttributes(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -4007,7 +3764,7 @@ public void onResponse(Call call, Response response) * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. + * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. * @param organizationDetails Details of the organization as provided to the issuer. * @param attributes Attributes of the issuer object. @@ -4017,29 +3774,7 @@ public void onResponse(Call call, Response response) * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (provider == null) { - throw new IllegalArgumentException("Parameter provider is required and cannot be null."); - } - Validator.validate(credentials); - Validator.validate(organizationDetails); - Validator.validate(attributes); - CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); - parameter.withProvider(provider); - parameter.withCredentials(credentials); - parameter.withOrganizationDetails(organizationDetails); - parameter.withAttributes(attributes); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - return updateCertificateIssuerDelegate(call.execute()); + return updateCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single(); } /** @@ -4047,14 +3782,29 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @param provider The name of the issuer. + * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. * @param organizationDetails Details of the organization as provided to the issuer. * @param attributes Attributes of the issuer object. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The issuer provider. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @return the observable to the IssuerBundle object + */ + public Observable> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4064,9 +3814,6 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUr if (this.apiVersion() == null) { throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } - if (provider == null) { - throw new IllegalArgumentException("Parameter provider is required and cannot be null."); - } Validator.validate(credentials); Validator.validate(organizationDetails); Validator.validate(attributes); @@ -4076,26 +3823,18 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUr parameter.withOrganizationDetails(organizationDetails); parameter.withAttributes(attributes); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4116,18 +3855,7 @@ private ServiceResponse updateCertificateIssuerDelegate(Response getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificateIssuerDelegate(call.execute()); + return getCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); } /** @@ -4136,9 +3864,20 @@ public ServiceResponse getCertificateIssuer(String vaultBaseUrl, S * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Gets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object + */ + public Observable> getCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4149,26 +3888,18 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.getCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4189,18 +3920,7 @@ private ServiceResponse getCertificateIssuerDelegate(Response deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (issuerName == null) { - throw new IllegalArgumentException("Parameter issuerName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteCertificateIssuerDelegate(call.execute()); + return deleteCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); } /** @@ -4209,9 +3929,20 @@ public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Deletes the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object + */ + public Observable> deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4222,26 +3953,18 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUr throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteCertificateIssuerDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.deleteCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteCertificateIssuerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4262,25 +3985,7 @@ private ServiceResponse deleteCertificateIssuerDelegate(Response createCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final CertificatePolicy certificatePolicy = null; - final CertificateAttributes certificateAttributes = null; - final Map tags = null; - CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.withCertificatePolicy(null); - parameters.withCertificateAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return createCertificateDelegate(call.execute()); + return createCertificateAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -4289,9 +3994,20 @@ public ServiceResponse createCertificate(String vaultBaseU * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(createCertificateAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable> createCertificateAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4309,26 +4025,18 @@ public ServiceCall createCertificateAsync(String vaultBase parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = createCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -4345,25 +4053,7 @@ public void onResponse(Call call, Response response) * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(certificatePolicy); - Validator.validate(certificateAttributes); - Validator.validate(tags); - CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.withCertificatePolicy(certificatePolicy); - parameters.withCertificateAttributes(certificateAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return createCertificateDelegate(call.execute()); + return createCertificateAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).toBlocking().single(); } /** @@ -4375,9 +4065,23 @@ public ServiceResponse createCertificate(String vaultBaseU * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(createCertificateAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags), serviceCallback); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateOperation object + */ + public Observable> createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4395,26 +4099,18 @@ public ServiceCall createCertificateAsync(String vaultBase parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = createCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.createCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse createCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4436,31 +4132,7 @@ private ServiceResponse createCertificateDelegate(Response * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (base64EncodedCertificate == null) { - throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); - } - final String password = null; - final CertificatePolicy certificatePolicy = null; - final CertificateAttributes certificateAttributes = null; - final Map tags = null; - CertificateImportParameters parameters = new CertificateImportParameters(); - parameters.withBase64EncodedCertificate(base64EncodedCertificate); - parameters.withPassword(null); - parameters.withCertificatePolicy(null); - parameters.withCertificateAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return importCertificateDelegate(call.execute()); + return importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).toBlocking().single(); } /** @@ -4470,9 +4142,21 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) { + return ServiceCall.create(importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate), serviceCallback); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. + * @return the observable to the CertificateBundle object + */ + public Observable> importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4496,26 +4180,18 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = importCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = importCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -4534,30 +4210,24 @@ public void onResponse(Call call, Response response) * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (base64EncodedCertificate == null) { - throw new IllegalArgumentException("Parameter base64EncodedCertificate is required and cannot be null."); - } - Validator.validate(certificatePolicy); - Validator.validate(certificateAttributes); - Validator.validate(tags); - CertificateImportParameters parameters = new CertificateImportParameters(); - parameters.withBase64EncodedCertificate(base64EncodedCertificate); - parameters.withPassword(password); - parameters.withCertificatePolicy(certificatePolicy); - parameters.withCertificateAttributes(certificateAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return importCertificateDelegate(call.execute()); + return importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).toBlocking().single(); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags), serviceCallback); } /** @@ -4570,10 +4240,9 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param certificatePolicy The management policy for the certificate * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the observable to the CertificateBundle object */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + public Observable> importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4596,26 +4265,18 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = importCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.importCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = importCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse importCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4636,26 +4297,14 @@ private ServiceResponse importCertificateDelegate(Response> getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final Integer maxresults = null; - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificateVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -4664,9 +4313,46 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName) { + return getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4678,32 +4364,18 @@ public ServiceCall> getCertificateVersionsAsync(final Stri } final Integer maxresults = null; String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -4718,25 +4390,14 @@ public void onResponse(Call call, Response response) * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - ServiceResponse> response = getCertificateVersionsDelegate(call.execute()); - PagedList result = new PagedList(response.getBody()) { + ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { @Override - public Page nextPage(String nextPageLink) throws KeyVaultErrorException, IOException { - return getCertificateVersionsNext(nextPageLink).getBody(); + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse<>(result, response.getResponse()); + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -4746,9 +4407,48 @@ public Page nextPage(String nextPageLink) throws KeyVaultErrorE * @param certificateName The name of the certificate * @param maxresults Maximum number of results to return. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param maxresults Maximum number of results to return. + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { + return getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of a certificate. + * + ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param certificateName The name of the certificate + ServiceResponse> * @param maxresults Maximum number of results to return. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4759,32 +4459,18 @@ public ServiceCall> getCertificateVersionsAsync(final Stri throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall> serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateVersionsDelegate(response); - if (serviceCallback != null) { - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); - } - } - serviceCall.success(new ServiceResponse<>(result.getBody().getItems(), response)); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificateVersions(certificateName, maxresults, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateVersionsDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificateVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4805,18 +4491,7 @@ private ServiceResponse> getCertificateVersionsDelegat * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificatePolicyDelegate(call.execute()); + return getCertificatePolicyAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -4825,9 +4500,20 @@ public ServiceResponse getCertificatePolicy(String vaultBaseU * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificatePolicyAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Gets the policy for a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @return the observable to the CertificatePolicy object + */ + public Observable> getCertificatePolicyAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4838,26 +4524,18 @@ public ServiceCall getCertificatePolicyAsync(String vaultBase throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificatePolicyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.getCertificatePolicy(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificatePolicyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4879,22 +4557,7 @@ private ServiceResponse getCertificatePolicyDelegate(Response * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificatePolicy == null) { - throw new IllegalArgumentException("Parameter certificatePolicy is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(certificatePolicy); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return updateCertificatePolicyDelegate(call.execute()); + return updateCertificatePolicyAsync(vaultBaseUrl, certificateName, certificatePolicy).toBlocking().single(); } /** @@ -4904,9 +4567,21 @@ public ServiceResponse updateCertificatePolicy(String vaultBa * @param certificateName The name of the certificate in the given vault. * @param certificatePolicy The policy for the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificatePolicyAsync(vaultBaseUrl, certificateName, certificatePolicy), serviceCallback); + } + + /** + * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @param certificatePolicy The policy for the certificate. + * @return the observable to the CertificatePolicy object + */ + public Observable> updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4921,26 +4596,18 @@ public ServiceCall updateCertificatePolicyAsync(String vaultB } Validator.validate(certificatePolicy); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificatePolicyDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateCertificatePolicy(certificateName, certificatePolicy, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificatePolicyDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -4962,28 +4629,7 @@ private ServiceResponse updateCertificatePolicyDelegate(Respo * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificateVersion == null) { - throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - final CertificatePolicy certificatePolicy = null; - final CertificateAttributes certificateAttributes = null; - final Map tags = null; - CertificateUpdateParameters parameters = new CertificateUpdateParameters(); - parameters.withCertificatePolicy(null); - parameters.withCertificateAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateCertificateDelegate(call.execute()); + return updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single(); } /** @@ -4993,9 +4639,21 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @return the observable to the CertificateBundle object + */ + public Observable> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5016,26 +4674,18 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -5053,28 +4703,7 @@ public void onResponse(Call call, Response response) * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificateVersion == null) { - throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - Validator.validate(certificatePolicy); - Validator.validate(certificateAttributes); - Validator.validate(tags); - CertificateUpdateParameters parameters = new CertificateUpdateParameters(); - parameters.withCertificatePolicy(certificatePolicy); - parameters.withCertificateAttributes(certificateAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return updateCertificateDelegate(call.execute()); + return updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags).toBlocking().single(); } /** @@ -5087,9 +4716,24 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags), serviceCallback); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5110,26 +4754,18 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.updateCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5151,21 +4787,7 @@ private ServiceResponse updateCertificateDelegate(Response getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (certificateVersion == null) { - throw new IllegalArgumentException("Parameter certificateVersion is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificateDelegate(call.execute()); + return getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single(); } /** @@ -5175,9 +4797,21 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + } + + /** + * Gets a Certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @return the observable to the CertificateBundle object + */ + public Observable> getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5191,26 +4825,18 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.getCertificate(certificateName, certificateVersion, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5232,20 +4858,7 @@ private ServiceResponse getCertificateDelegate(Response updateCertificateOperation(String vaultBaseUrl, String certificateName, boolean cancellationRequested) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - CertificateOperationUpdateParameter certificateOperation = new CertificateOperationUpdateParameter(); - certificateOperation.withCancellationRequested(cancellationRequested); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), certificateOperation, parameterizedHost, this.userAgent()); - return updateCertificateOperationDelegate(call.execute()); + return updateCertificateOperationAsync(vaultBaseUrl, certificateName, cancellationRequested).toBlocking().single(); } /** @@ -5255,9 +4868,21 @@ public ServiceResponse updateCertificateOperation(String v * @param certificateName The name of the certificate * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateCertificateOperationAsync(vaultBaseUrl, certificateName, cancellationRequested), serviceCallback); + } + + /** + * Updates a certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. + * @return the observable to the CertificateOperation object + */ + public Observable> updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5270,26 +4895,18 @@ public ServiceCall updateCertificateOperationAsync(String CertificateOperationUpdateParameter certificateOperation = new CertificateOperationUpdateParameter(); certificateOperation.withCancellationRequested(cancellationRequested); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.updateCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), certificateOperation, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = updateCertificateOperationDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.updateCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), certificateOperation, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateCertificateOperationDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse updateCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5310,18 +4927,7 @@ private ServiceResponse updateCertificateOperationDelegate * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return getCertificateOperationDelegate(call.execute()); + return getCertificateOperationAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -5330,9 +4936,20 @@ public ServiceResponse getCertificateOperation(String vaul * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getCertificateOperationAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Gets the certificate operation response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable> getCertificateOperationAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5343,26 +4960,18 @@ public ServiceCall getCertificateOperationAsync(String vau throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = getCertificateOperationDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); - } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); + return service.getCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getCertificateOperationDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse getCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5383,18 +4992,7 @@ private ServiceResponse getCertificateOperationDelegate(Re * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - return deleteCertificateOperationDelegate(call.execute()); + return deleteCertificateOperationAsync(vaultBaseUrl, certificateName).toBlocking().single(); } /** @@ -5403,9 +5001,20 @@ public ServiceResponse deleteCertificateOperation(String v * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteCertificateOperationAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Deletes the certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable> deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5416,26 +5025,18 @@ public ServiceCall deleteCertificateOperationAsync(String throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); } String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = deleteCertificateOperationDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.deleteCertificateOperation(certificateName, this.apiVersion(), this.acceptLanguage(), parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteCertificateOperationDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse deleteCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5457,28 +5058,7 @@ private ServiceResponse deleteCertificateOperationDelegate * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (x509Certificates == null) { - throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); - } - Validator.validate(x509Certificates); - final CertificateAttributes certificateAttributes = null; - final Map tags = null; - CertificateMergeParameters parameters = new CertificateMergeParameters(); - parameters.withX509Certificates(x509Certificates); - parameters.withCertificateAttributes(null); - parameters.withTags(null); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return mergeCertificateDelegate(call.execute()); + return mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates).toBlocking().single(); } /** @@ -5488,9 +5068,21 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @param certificateName The name of the certificate * @param x509Certificates The certificate or the certificate chain to merge * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) { + return ServiceCall.create(mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates), serviceCallback); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificate chain to merge + * @return the observable to the CertificateBundle object + */ + public Observable> mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5511,26 +5103,18 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, parameters.withCertificateAttributes(null); parameters.withTags(null); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = mergeCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = mergeCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } /** @@ -5547,28 +5131,7 @@ public void onResponse(Call call, Response response) * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. */ public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (vaultBaseUrl == null) { - throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); - } - if (certificateName == null) { - throw new IllegalArgumentException("Parameter certificateName is required and cannot be null."); - } - if (this.apiVersion() == null) { - throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null."); - } - if (x509Certificates == null) { - throw new IllegalArgumentException("Parameter x509Certificates is required and cannot be null."); - } - Validator.validate(x509Certificates); - Validator.validate(certificateAttributes); - Validator.validate(tags); - CertificateMergeParameters parameters = new CertificateMergeParameters(); - parameters.withX509Certificates(x509Certificates); - parameters.withCertificateAttributes(certificateAttributes); - parameters.withTags(tags); - String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - return mergeCertificateDelegate(call.execute()); + return mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).toBlocking().single(); } /** @@ -5580,9 +5143,23 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @param certificateAttributes The attributes of the certificate (optional) * @param tags Application-specific metadata in the form of key-value pairs * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceCall.create(mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags), serviceCallback); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificate chain to merge + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable> mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5603,26 +5180,18 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, parameters.withCertificateAttributes(certificateAttributes); parameters.withTags(tags); String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl); - Call call = service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()); - final ServiceCall serviceCall = new ServiceCall<>(call); - call.enqueue(new ServiceResponseCallback(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse clientResponse = mergeCertificateDelegate(response); - if (serviceCallback != null) { - serviceCallback.success(clientResponse); + return service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = mergeCertificateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); } - serviceCall.success(clientResponse); - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse mergeCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5641,12 +5210,15 @@ private ServiceResponse mergeCertificateDelegate(Response> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getKeyVersionsNextDelegate(call.execute()); + public ServiceResponse> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5655,35 +5227,59 @@ public ServiceResponse> getKeyVersionsNext(final String nextPa * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeyVersionsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified key. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeyVersionsNextAsync(final String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeyVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified key. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeyVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeyVersionsNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeyVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeyVersionsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getKeyVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5702,12 +5298,15 @@ private ServiceResponse> getKeyVersionsNextDelegate(Response> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getKeysNextDelegate(call.execute()); + public ServiceResponse> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getKeysNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5716,35 +5315,59 @@ public ServiceResponse> getKeysNext(final String nextPageLink) * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getKeysNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getKeysNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List keys in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<KeyItem> object + */ + public Observable>> getKeysNextAsync(final String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getKeysNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List keys in the specified vault. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getKeysNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getKeysNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getKeysNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getKeysNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getKeysNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5763,12 +5386,15 @@ private ServiceResponse> getKeysNextDelegate(Response> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getSecretsNextDelegate(call.execute()); + public ServiceResponse> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5777,35 +5403,59 @@ public ServiceResponse> getSecretsNext(final String nextPag * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List secrets in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretsNextAsync(final String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List secrets in the specified vault. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretsNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getSecretsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5824,12 +5474,15 @@ private ServiceResponse> getSecretsNextDelegate(Response> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getSecretVersionsNextDelegate(call.execute()); + public ServiceResponse> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5838,35 +5491,59 @@ public ServiceResponse> getSecretVersionsNext(final String * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getSecretVersionsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of the specified secret. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<SecretItem> object + */ + public Observable>> getSecretVersionsNextAsync(final String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getSecretVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of the specified secret. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getSecretVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getSecretVersionsNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getSecretVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getSecretVersionsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getSecretVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5885,12 +5562,15 @@ private ServiceResponse> getSecretVersionsNextDelegate(Resp * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getCertificatesNextDelegate(call.execute()); + public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5899,35 +5579,59 @@ public ServiceResponse> getCertificatesNext(final Stri * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificatesNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificates in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificatesNextAsync(final String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificatesNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificates in the specified vault. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificatesNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificatesNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificatesNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificatesNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificatesNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -5946,12 +5650,15 @@ private ServiceResponse> getCertificatesNextDelegate(R * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getCertificateIssuersNextDelegate(call.execute()); + public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5960,35 +5667,59 @@ public ServiceResponse> getCertificateIssuersNex * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateIssuersNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List certificate issuers for the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<CertificateIssuerItem> object + */ + public Observable>> getCertificateIssuersNextAsync(final String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateIssuersNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateIssuersNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateIssuersNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateIssuersNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateIssuersNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificateIssuersNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { @@ -6007,12 +5738,15 @@ private ServiceResponse> getCertificateIssuersNe * @throws IllegalArgumentException exception thrown from invalid parameters * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ - public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { - if (nextPageLink == null) { - throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); - } - Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - return getCertificateVersionsNextDelegate(call.execute()); + public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + ServiceResponse> response = getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); + PagedList pagedList = new PagedList(response.getBody()) { + @Override + public Page nextPage(String nextPageLink) throws RestException, IOException { + return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + } + }; + return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -6021,35 +5755,59 @@ public ServiceResponse> getCertificateVersionsNext(fin * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link Call} object + * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { + return AzureServiceCall.create( + getCertificateVersionsNextSinglePageAsync(nextPageLink), + new Func1>>>() { + @Override + public Observable>> call(String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }, + serviceCallback); + } + + /** + * List the versions of a certificate. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the List<CertificateItem> object + */ + public Observable>> getCertificateVersionsNextAsync(final String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink) + .concatMap(new Func1>, Observable>>>() { + @Override + public Observable>> call(ServiceResponse> page) { + String nextPageLink = page.getBody().getNextPageLink(); + return getCertificateVersionsNextSinglePageAsync(nextPageLink); + } + }); + } + + /** + * List the versions of a certificate. + * + ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + */ + public Observable>> getCertificateVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - Call call = service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()); - serviceCall.newCall(call); - call.enqueue(new ServiceResponseCallback>(serviceCall, serviceCallback) { - @Override - public void onResponse(Call call, Response response) { - try { - ServiceResponse> result = getCertificateVersionsNextDelegate(response); - serviceCallback.load(result.getBody().getItems()); - if (result.getBody().getNextPageLink() != null - && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) { - getCertificateVersionsNextAsync(result.getBody().getNextPageLink(), serviceCall, serviceCallback); - } else { - serviceCallback.success(new ServiceResponse<>(serviceCallback.get(), result.getResponse())); + return service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = getCertificateVersionsNextDelegate(response); + return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + } catch (Throwable t) { + return Observable.error(t); } - } catch (KeyVaultErrorException | IOException exception) { - if (serviceCallback != null) { - serviceCallback.failure(exception); - } - serviceCall.failure(exception); } - } - }); - return serviceCall; + }); } private ServiceResponse> getCertificateVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java index f90e86cd39fdb..2edac49304f93 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java @@ -21,7 +21,7 @@ public class CertificateIssuerItem { private String id; /** - * The name of the issuer. + * The issuer provider. */ private String provider; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java index f9daf44e44fda..df352850dff30 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java @@ -17,7 +17,7 @@ */ public class CertificateIssuerSetParameters { /** - * The name of the issuer. + * The issuer provider. */ @JsonProperty(required = true) private String provider; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java index 7af311457b0ea..05d62b4ec54d9 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java @@ -13,13 +13,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The certificate issuer set parameters. + * The certificate issuer update parameters. */ public class CertificateIssuerUpdateParameters { /** - * The name of the issuer. + * The issuer provider. */ - @JsonProperty(required = true) private String provider; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java index dd7c42a5f4ac0..b2cd7b05f1189 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * A certificate operation is returned in case of async requests. + * The certificate operation update parameters. */ public class CertificateOperationUpdateParameter { /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java index e30c98684da69..59b4d7f2afca1 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -30,7 +30,7 @@ public class IssuerBundle { private String id; /** - * The name of the issuer. + * The issuer provider. */ private String provider; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java index 6f971897b7dbb..c2aa1dbe1f77e 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java @@ -16,7 +16,8 @@ */ public class IssuerReference { /** - * Name of the referenced issuer object. + * Name of the referenced issuer object or reserved names e.g. 'Self', + * 'Unknown'. */ private String name; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index e7ce6cc2b0fb1..07fff30be2e88 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -19,6 +19,7 @@ import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.webkey.JsonWebKey; import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; +import com.fasterxml.jackson.annotation.JsonProperty; /** * A KeyBundle consisting of a WebKey plus its Attributes. @@ -40,8 +41,10 @@ public class KeyBundle { private Map tags; /** - * True if the secret's lifetime is managed by key vault. + * True if the key's lifetime is managed by key vault i.e. if this is a + * key backing a certificate, then managed will be true. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private Boolean managed; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java index a799ee36fb6e7..9d61d685cee94 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java @@ -13,6 +13,8 @@ import java.util.List; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; /** * The key create parameters. @@ -20,10 +22,11 @@ public class KeyCreateParameters { /** * The type of key to create. Valid key types, see JsonWebKeyType. - * Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'. + * Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, + * Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'. */ @JsonProperty(required = true) - private String kty; + private JsonWebKeyType kty; /** * The key size in bytes. e.g. 1024 or 2048. @@ -35,7 +38,7 @@ public class KeyCreateParameters { * The keyOps property. */ @JsonProperty(value = "key_ops") - private List keyOps; + private List keyOps; /** * The keyAttributes property. @@ -53,7 +56,7 @@ public class KeyCreateParameters { * * @return the kty value */ - public String kty() { + public JsonWebKeyType kty() { return this.kty; } @@ -63,7 +66,7 @@ public String kty() { * @param kty the kty value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters withKty(String kty) { + public KeyCreateParameters withKty(JsonWebKeyType kty) { this.kty = kty; return this; } @@ -93,7 +96,7 @@ public KeyCreateParameters withKeySize(Integer keySize) { * * @return the keyOps value */ - public List keyOps() { + public List keyOps() { return this.keyOps; } @@ -103,7 +106,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the KeyCreateParameters object itself. */ - public KeyCreateParameters withKeyOps(List keyOps) { + public KeyCreateParameters withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index 4dea299b81d8c..57f669af5a4b7 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -13,6 +13,7 @@ import java.util.Map; import com.microsoft.azure.keyvault.KeyIdentifier; +import com.fasterxml.jackson.annotation.JsonProperty; /** * The key item containing key metadata. @@ -34,8 +35,10 @@ public class KeyItem { private Map tags; /** - * True if the secret's lifetime is managed by key vault. + * True if the key's lifetime is managed by key vault i.e. if this is a + * key backing a certificate, then managed will be true. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private Boolean managed; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java index 228a944624152..d65ddea14591e 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java @@ -10,6 +10,7 @@ package com.microsoft.azure.keyvault.models; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; @@ -21,7 +22,7 @@ public class KeyOperationsParameters { * algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5'. */ @JsonProperty(value = "alg", required = true) - private String algorithm; + private JsonWebKeyEncryptionAlgorithm algorithm; /** * The value property. @@ -34,7 +35,7 @@ public class KeyOperationsParameters { * * @return the algorithm value */ - public String algorithm() { + public JsonWebKeyEncryptionAlgorithm algorithm() { return this.algorithm; } @@ -44,7 +45,7 @@ public String algorithm() { * @param algorithm the algorithm value to set * @return the KeyOperationsParameters object itself. */ - public KeyOperationsParameters withAlgorithm(String algorithm) { + public KeyOperationsParameters withAlgorithm(JsonWebKeyEncryptionAlgorithm algorithm) { this.algorithm = algorithm; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java index 999ed545fd0be..a82bbe119d6b7 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java @@ -28,7 +28,7 @@ public class KeyProperties { private String keyType; /** - * The key size in bytes. e.g. 1024 or 2048. + * The key size in bytes. e.g. 2048. */ @JsonProperty(value = "key_size") private Integer keySize; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java index 1af4965c7b756..838b54f7a964a 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java @@ -10,6 +10,7 @@ package com.microsoft.azure.keyvault.models; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; @@ -23,7 +24,7 @@ public class KeySignParameters { * values include: 'RS256', 'RS384', 'RS512', 'RSNULL'. */ @JsonProperty(value = "alg", required = true) - private String algorithm; + private JsonWebKeySignatureAlgorithm algorithm; /** * The value property. @@ -36,7 +37,7 @@ public class KeySignParameters { * * @return the algorithm value */ - public String algorithm() { + public JsonWebKeySignatureAlgorithm algorithm() { return this.algorithm; } @@ -46,7 +47,7 @@ public String algorithm() { * @param algorithm the algorithm value to set * @return the KeySignParameters object itself. */ - public KeySignParameters withAlgorithm(String algorithm) { + public KeySignParameters withAlgorithm(JsonWebKeySignatureAlgorithm algorithm) { this.algorithm = algorithm; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java index 33c51dc4d697b..043fbe2d44fd3 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Map; import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; /** * The key update parameters. @@ -23,7 +24,7 @@ public class KeyUpdateParameters { * operations, see JsonWebKeyOperation. */ @JsonProperty(value = "key_ops") - private List keyOps; + private List keyOps; /** * The keyAttributes property. @@ -41,7 +42,7 @@ public class KeyUpdateParameters { * * @return the keyOps value */ - public List keyOps() { + public List keyOps() { return this.keyOps; } @@ -51,7 +52,7 @@ public List keyOps() { * @param keyOps the keyOps value to set * @return the KeyUpdateParameters object itself. */ - public KeyUpdateParameters withKeyOps(List keyOps) { + public KeyUpdateParameters withKeyOps(List keyOps) { this.keyOps = keyOps; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java index 1f370f7494ed7..96fd4cb07f947 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java @@ -10,6 +10,7 @@ package com.microsoft.azure.keyvault.models; +import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; @@ -23,7 +24,7 @@ public class KeyVerifyParameters { * include: 'RS256', 'RS384', 'RS512', 'RSNULL'. */ @JsonProperty(value = "alg", required = true) - private String algorithm; + private JsonWebKeySignatureAlgorithm algorithm; /** * The digest used for signing. @@ -42,7 +43,7 @@ public class KeyVerifyParameters { * * @return the algorithm value */ - public String algorithm() { + public JsonWebKeySignatureAlgorithm algorithm() { return this.algorithm; } @@ -52,7 +53,7 @@ public String algorithm() { * @param algorithm the algorithm value to set * @return the KeyVerifyParameters object itself. */ - public KeyVerifyParameters withAlgorithm(String algorithm) { + public KeyVerifyParameters withAlgorithm(JsonWebKeySignatureAlgorithm algorithm) { this.algorithm = algorithm; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index 6dea046e03cc5..2035765e09b95 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -13,6 +13,7 @@ import java.io.IOException; import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -49,13 +50,17 @@ public class SecretBundle { private Map tags; /** - * The key id for certificate. + * If this is a secret backing a KV certificate, then this field specifies + * the corresponding key backing the KV certificate. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String kid; /** - * True if the secret's lifetime is managed by key vault. + * True if the secret's lifetime is managed by key vault i.e. if this is a + * secret backing a certificate, then managed will be true. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private Boolean managed; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index db383c7f7f0fb..9c4c31e91d44a 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -13,6 +13,7 @@ import java.util.Map; import com.microsoft.azure.keyvault.SecretIdentifier; +import com.fasterxml.jackson.annotation.JsonProperty; /** * The secret item containing secret metadata. @@ -39,8 +40,10 @@ public class SecretItem { private String contentType; /** - * True if the secret's lifetime is managed by key vault. + * True if the secret's lifetime is managed by key vault i.e. if this is a + * key backing a certificate, then managed will be true. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private Boolean managed; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java index ae9267dba24d6..34b1889e212ee 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java @@ -23,7 +23,7 @@ public class X509CertificateProperties { private String subject; /** - * The enhaunced key usage. + * The enhanced key usage. */ private List ekus; @@ -40,7 +40,7 @@ public class X509CertificateProperties { private List keyUsage; /** - * The subject alternate names. + * The duration that the ceritifcate is valid in months. */ @JsonProperty(value = "validity_months") private Integer validityInMonths; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java index e197baa16c33b..8aee1468265fb 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateKeyRequest.java @@ -7,6 +7,8 @@ import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.KeyAttributes; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; /** * The create key request class. @@ -15,9 +17,9 @@ public final class CreateKeyRequest { private final String vaultBaseUrl; private final String keyName; - private final String keyType; + private final JsonWebKeyType keyType; private final Integer keySize; - private final List keyOperations; + private final List keyOperations; private final KeyAttributes keyAttributes; private final Map tags; @@ -29,11 +31,11 @@ public static class Builder { // Required parameters private final String vaultBaseUrl; private final String keyName; - private final String keyType; + private final JsonWebKeyType keyType; // Optional parameters private Integer keySize; - private List keyOperations; + private List keyOperations; private KeyAttributes attributes; private Map tags; @@ -45,10 +47,11 @@ public static class Builder { * @param keyName * The name of the key in the given vault * @param keyType - * The type of key to create. Possible values include: 'EC', - * 'RSA', 'RSA-HSM', 'oct' + * The type of key to create. Valid key types, see JsonWebKeyType. + * Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. + * Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' */ - public Builder(String vaultBaseUrl, String keyName, String keyType) { + public Builder(String vaultBaseUrl, String keyName, JsonWebKeyType keyType) { this.vaultBaseUrl = vaultBaseUrl; this.keyName = keyName; this.keyType = keyType; @@ -73,7 +76,7 @@ public Builder withKeySize(Integer size) { * the key operation list. * @return the Builder object itself. */ - public Builder withKeyOperations(List keyOperations) { + public Builder withKeyOperations(List keyOperations) { this.keyOperations = keyOperations; return this; } @@ -120,7 +123,7 @@ private CreateKeyRequest(Builder builder) { keySize = builder.keySize; if (builder.keyOperations != null) { - keyOperations = new ArrayList(builder.keyOperations); + keyOperations = new ArrayList(builder.keyOperations); } else { keyOperations = null; } @@ -156,7 +159,7 @@ public String keyName() { /** * @return the key type */ - public String keyType() { + public JsonWebKeyType keyType() { return keyType; } @@ -170,7 +173,7 @@ public Integer keySize() { /** * @return the key operations */ - public List keyOperations() { + public List keyOperations() { return keyOperations; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java index 91adae60c3ce8..908881d78bb92 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportKeyRequest.java @@ -7,6 +7,7 @@ import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.KeyAttributes; import com.microsoft.azure.keyvault.webkey.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; /** * The import key request class. @@ -110,7 +111,7 @@ private ImportKeyRequest(Builder builder) { .withD(builder.key.d()).withP(builder.key.p()).withQ(builder.key.q()).withDp(builder.key.dp()) .withDq(builder.key.dq()).withQi(builder.key.qi()).withK(builder.key.k()).withT(builder.key.t()); if (builder.key.keyOps() != null) { - key.withKeyOps(new ArrayList(builder.key.keyOps())); + key.withKeyOps(new ArrayList(builder.key.keyOps())); } } else { key = null; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java index bad0b37d43b75..6d62c41fc166f 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateKeyRequest.java @@ -8,6 +8,7 @@ import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.KeyAttributes; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; /** * The key update request class. @@ -17,7 +18,7 @@ public final class UpdateKeyRequest { private final String vaultBaseUrl; private final String keyName; private final String keyVersion; - private final List keyOperations; + private final List keyOperations; private final KeyAttributes keyAttributes; private final Map tags; @@ -32,7 +33,7 @@ public static class Builder { // Optional parameters private String keyVersion; - private List keyOperations; + private List keyOperations; private KeyAttributes attributes; private Map tags; @@ -83,7 +84,7 @@ public Builder withVersion(String keyVersion) { * the key operation list * @return the Builder object itself. */ - public Builder withKeyOperations(List keyOperations) { + public Builder withKeyOperations(List keyOperations) { this.keyOperations = keyOperations; return this; } @@ -129,7 +130,7 @@ private UpdateKeyRequest(Builder builder) { keyVersion = builder.keyVersion == null ? "" : builder.keyVersion; if (builder.keyOperations != null) { - keyOperations = new ArrayList(builder.keyOperations); + keyOperations = new ArrayList(builder.keyOperations); } else { keyOperations = null; } @@ -172,7 +173,7 @@ public String keyVersion() { /** * @return the key operations */ - public List keyOperations() { + public List keyOperations() { return keyOperations; } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java index 44eb04f681b56..3fcd6787ce999 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -46,6 +46,7 @@ import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; public class AsyncOperationsTest extends KeyVaultClientIntegrationTestBase { @@ -56,7 +57,7 @@ public void keyAsync() throws Exception { String vault = getVaultUri(); String keyname = "mykey"; - CreateKeyRequest createKeyRequest = new CreateKeyRequest.Builder(vault, keyname, "RSA").build(); + CreateKeyRequest createKeyRequest = new CreateKeyRequest.Builder(vault, keyname, JsonWebKeyType.RSA).build(); KeyBundle keyBundle = keyVaultClient.createKeyAsync(createKeyRequest, null).get().getBody(); Assert.assertNotNull(keyBundle); @@ -81,16 +82,16 @@ public void keyAsync() throws Exception { KeyBundle restoreResult = keyVaultClient.restoreKeyAsync(vault, backupResult.value(), null).get().getBody(); Assert.assertNotNull(restoreResult); - KeyOperationResult encryptResult = keyVaultClient.encryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, new byte[100], null).get().getBody(); + KeyOperationResult encryptResult = keyVaultClient.encryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, new byte[100], null).get().getBody(); Assert.assertNotNull(encryptResult); - KeyOperationResult decryptResult = keyVaultClient.decryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, encryptResult.result(), null).get().getBody(); + KeyOperationResult decryptResult = keyVaultClient.decryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, encryptResult.result(), null).get().getBody(); Assert.assertNotNull(decryptResult); - KeyOperationResult wrapResult = keyVaultClient.wrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, new byte[100], null).get().getBody(); + KeyOperationResult wrapResult = keyVaultClient.wrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, new byte[100], null).get().getBody(); Assert.assertNotNull(wrapResult); - KeyOperationResult unwrapResult = keyVaultClient.unwrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, wrapResult.result(), null).get().getBody(); + KeyOperationResult unwrapResult = keyVaultClient.unwrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, wrapResult.result(), null).get().getBody(); Assert.assertNotNull(unwrapResult); byte[] plainText = new byte[100]; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index 3af77cfca2625..c3dfd810293e3 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -677,9 +677,11 @@ public void listCertificates() throws Exception { HashSet toDelete = new HashSet(); for (CertificateItem item : listResult) { - CertificateIdentifier id = new CertificateIdentifier(item.id()); - toDelete.add(id.name()); - certificates.remove(item.id()); + if(item != null) { + CertificateIdentifier id = new CertificateIdentifier(item.id()); + toDelete.add(id.name()); + certificates.remove(item.id()); + } } Assert.assertEquals(0, certificates.size()); @@ -736,7 +738,9 @@ public void listCertificateVersions() throws Exception { listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName).getBody(); for (CertificateItem item : listResult) { - certificates.remove(item.id()); + if(item != null) { + certificates.remove(item.id()); + } } Assert.assertEquals(0, certificates.size()); diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 54eb89cd3d444..92de113eb9f98 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -56,28 +56,28 @@ public void transparentAuthentication() throws Exception { { Map tags = new HashMap(); tags.put("foo", "baz"); - List keyOps = Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT); + List keyOps = Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT); Attributes attribute = new KeyAttributes() .withEnabled(true) .withExpires(new DateTime().withYear(2050).withMonthOfYear(1)) .withNotBefore(new DateTime().withYear(2000).withMonthOfYear(1)); KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest - .Builder(getVaultUri(), KEY_NAME, "RSA") + .Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA) .withAttributes(attribute) .withKeyOperations(keyOps) .withKeySize(2048) .withTags(tags) .build()).getBody(); - validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, "RSA", keyOps, attribute); + validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, keyOps, attribute); } // Create a key on a different vault. Key Vault Data Plane returns 401, // which must be transparently handled by KeyVaultCredentials. { - KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, "RSA", null, null); + KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); } } @@ -114,7 +114,7 @@ private void checkImportOperation(KeyBundle keyBundle, boolean importToHardware) .withTags(tags) .build()).getBody(); - validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? "RSA-HSM" : "RSA", importedJwk.keyOps(), attribute); + validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? JsonWebKeyType.RSA_HSM : JsonWebKeyType.RSA, importedJwk.keyOps(), attribute); checkEncryptDecryptSequence(importedJwk, importResultBundle); } @@ -127,7 +127,7 @@ private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle impor // Encrypt in the service. { - KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); } @@ -152,7 +152,7 @@ private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle impor // Decrypt in the service. { - KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA15, cipherText).getBody(); + KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA1_5, cipherText).getBody(); byte[] beforeEncrypt = plainText; byte[] afterDecrypt = result.result(); @@ -166,8 +166,8 @@ public void crudOperations() throws Exception { KeyBundle createdBundle; { // Create key - createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); - validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null, null); + createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); } // Key identifier. @@ -211,7 +211,7 @@ public void crudOperations() throws Exception { .withMonthOfYear(2) .withDayOfMonth(1) .withYear(2050)); - List key_ops = Arrays.asList("encrypt", "decrypt"); + List key_ops = Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT); Map tags = new HashMap(); tags.put("foo", "baz"); createdBundle.key().withKeyOps(key_ops); @@ -240,7 +240,7 @@ public void crudOperations() throws Exception { .withMonthOfYear(2) .withDayOfMonth(1) .withYear(2000)); - List key_ops = Arrays.asList("sign", "verify"); + List key_ops = Arrays.asList(JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY); createdBundle.key().withKeyOps(key_ops); Map tags = new HashMap(); tags.put("foo", "baz"); @@ -284,9 +284,9 @@ public void backupRestore() throws Exception { // Creates a key { createdBundle = keyVaultClient.createKey( - new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA") + new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA) .build()).getBody(); - validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, "RSA", null, null); + validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); } // Creates a backup of key. @@ -316,7 +316,7 @@ public void listKeys() throws Exception { int failureCount = 0; for (;;) { try { - KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, "RSA").build()).getBody(); + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, JsonWebKeyType.RSA).build()).getBody(); KeyIdentifier kid = new KeyIdentifier(createdBundle.key().kid()); keys.add(kid.baseIdentifier()); break; @@ -338,9 +338,11 @@ public void listKeys() throws Exception { HashSet toDelete = new HashSet(); for (KeyItem item : listResult) { - KeyIdentifier id = new KeyIdentifier(item.kid()); - toDelete.add(id.name()); - keys.remove(item.kid()); + if(item != null) { + KeyIdentifier id = new KeyIdentifier(item.kid()); + toDelete.add(id.name()); + keys.remove(item.kid()); + } } Assert.assertEquals(0, keys.size()); @@ -365,7 +367,7 @@ public void listKeyVersions() throws Exception { int failureCount = 0; for (;;) { try { - KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, "RSA").build()).getBody(); + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); keys.add(createdBundle.key().kid()); break; } catch (KeyVaultErrorException e) { @@ -386,7 +388,9 @@ public void listKeyVersions() throws Exception { listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME).getBody(); for (KeyItem item : listResult) { - keys.remove(item.kid()); + if(item != null) { + keys.remove(item.kid()); + } } Assert.assertEquals(0, keys.size()); @@ -409,19 +413,19 @@ public void encryptDecryptOperations() throws Exception { // encrypt and decrypt using kid WO version { - result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } // encrypt and decrypt using full kid { - result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } } @@ -441,19 +445,19 @@ public void wrapUnwrapOperations() throws Exception { // wrap and unwrap using kid WO version { - result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } // wrap and unwrap using full kid { - result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); cipherText = result.result(); - result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSAOAEP, cipherText).getBody(); + result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); Assert.assertArrayEquals(plainText, result.result()); } } @@ -501,7 +505,7 @@ private static JsonWebKey importTestKey() throws Exception { JsonWebKey key = JsonWebKey.fromRSA(getTestKeyMaterial()); key.withKty(JsonWebKeyType.RSA); - key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT, JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY, JsonWebKeyOperation.WRAP, JsonWebKeyOperation.UNWRAP)); + key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, JsonWebKeyOperation.DECRYPT, JsonWebKeyOperation.SIGN, JsonWebKeyOperation.VERIFY, JsonWebKeyOperation.WRAP_KEY, JsonWebKeyOperation.UNWRAP_KEY)); keyBundle = keyVaultClient.importKey( new ImportKeyRequest @@ -509,7 +513,7 @@ private static JsonWebKey importTestKey() throws Exception { .withHsm(false) .build()).getBody(); - validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, "RSA", null, null); + validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); return keyBundle.key(); } @@ -535,7 +539,7 @@ private static KeyPair getWellKnownKey() throws Exception { return new KeyPair(keyFactory.generatePublic(publicKeySpec), keyFactory.generatePrivate(privateKeySpec)); } - private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, String kty, List key_ops, Attributes attributes) throws Exception { + private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String keyName, JsonWebKeyType kty, List key_ops, Attributes attributes) throws Exception { String prefix = vault + "/keys/" + keyName + "/"; String kid = bundle.key().kid(); Assert.assertTrue( diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index af27ec8973c2f..ed6282decdf41 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -174,8 +174,7 @@ public void crudOperations() throws Exception { } @Test - public void listSecrets() throws Exception { - + public void listSecrets() throws Exception { HashSet secrets = new HashSet(); for (int i = 0; i < MAX_SECRETS; ++i) { int failureCount = 0; @@ -204,9 +203,11 @@ public void listSecrets() throws Exception { HashSet toDelete = new HashSet(); for (SecretItem item : listResult) { - SecretIdentifier id = new SecretIdentifier(item.id()); - toDelete.add(id.name()); - secrets.remove(item.id()); + if(item != null) { + SecretIdentifier id = new SecretIdentifier(item.id()); + toDelete.add(id.name()); + secrets.remove(item.id()); + } } Assert.assertEquals(0, secrets.size()); @@ -252,7 +253,9 @@ public void listSecretVersions() throws Exception { listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME).getBody(); for (SecretItem item : listResult) { - secrets.remove(item.id()); + if(item != null) { + secrets.remove(item.id()); + } } Assert.assertEquals(0, secrets.size()); From 7125cbd54f6479b449fb8747ddd39674284b8d64 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Fri, 2 Sep 2016 11:47:41 -0700 Subject: [PATCH 31/56] fix styling errors and addressed feedback. --- .../webkey/Base64UrlJsonDeserializer.java | 4 ++-- .../webkey/Base64UrlJsonSerializer.java | 4 ++-- .../azure/keyvault/webkey/JsonWebKey.java | 2 +- .../azure/keyvault/KeyVaultClient.java | 1 - .../azure/keyvault/KeyVaultClientImpl.java | 2 -- .../authentication/ChallengeCache.java | 5 +--- .../models/KeyVaultErrorException.java | 7 +++--- .../requests/SetCertificateIssuerRequest.java | 6 ++--- .../UpdateCertificateIssuerRequest.java | 23 ++++++++++++++----- .../keyvault/test/AsyncOperationsTest.java | 2 +- .../test/CertificateOperationsTest.java | 3 ++- 11 files changed, 32 insertions(+), 27 deletions(-) diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java index 18967a8863809..9418b15a96736 100644 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonDeserializer.java @@ -20,13 +20,13 @@ */ public class Base64UrlJsonDeserializer extends JsonDeserializer { - static final Base64 _base64 = new Base64(-1, null, true); + static final Base64 BASE64 = new Base64(-1, null, true); @Override public byte[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { String text = jp.getText(); if (text != null) { - return _base64.decode(text); + return BASE64.decode(text); } return null; } diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java index 3613a1aa79199..eac3d33e26c7b 100644 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/Base64UrlJsonSerializer.java @@ -20,7 +20,7 @@ */ public class Base64UrlJsonSerializer extends JsonSerializer { - static final Base64 _base64 = new Base64(-1, null, true); + static final Base64 BASE64 = new Base64(-1, null, true); @Override public void serialize(byte[] value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { @@ -30,7 +30,7 @@ public void serialize(byte[] value, JsonGenerator jgen, SerializerProvider provi } else if (value.length == 0) { text = ""; } else { - text = _base64.encodeAsString(value); + text = BASE64.encodeAsString(value); } jgen.writeString(text); } diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java index 868cab9204858..5d6dc8fe8b355 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java @@ -245,7 +245,7 @@ public byte[] dp() { } /** - * Set RSA Private Key Parameter value + * Set RSA Private Key Parameter value. * @param dp the RSA Private Key Parameter value to set. * @return the JsonWebKey object itself. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 0dbb76b43010b..95a998e02c63b 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -50,7 +50,6 @@ import com.microsoft.rest.credentials.ServiceClientCredentials; import okhttp3.ResponseBody; -import retrofit2.Call; import retrofit2.Response; import retrofit2.http.GET; import retrofit2.http.Header; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 156945410742d..ddeb203106bf6 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -59,8 +59,6 @@ import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; -import com.microsoft.azure.keyvault.webkey.Base64UrlJsonSerializer; -import com.microsoft.azure.keyvault.webkey.Base64UrlJsonDeserializer; import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java index 07cd0a8dc49b7..a0700600afffe 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/ChallengeCache.java @@ -10,13 +10,10 @@ import java.util.Locale; import java.util.Map; -import com.microsoft.rest.credentials.ServiceClientCredentials; - import okhttp3.HttpUrl; /** - * An implementation of {@link ServiceClientCredentials} that supports automatic bearer token refresh. - * + * Handles caching of the challenge. */ class ChallengeCache { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java index 43b6a45e162db..796e35e8da3c6 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java @@ -31,14 +31,13 @@ public class KeyVaultErrorException extends RestException { public KeyVaultErrorException() { } @Override - public String getMessage() - { - if(body != null && body.error() != null + public String getMessage() { + if (body != null && body.error() != null && body.error().message() != null && !body.error().message().isEmpty()) { return body.error().message(); } - return getMessage(); + return super.getMessage(); } /** * Initializes a new instance of the KeyVaultErrorException class. diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java index 23201a4a26f4a..7d582e2f5bde6 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/SetCertificateIssuerRequest.java @@ -77,7 +77,7 @@ public Builder withOrganizationDetails(OrganizationDetails organizationDetails) /** * Set issuer attributes. * - * @param organizationDetails + * @param attributes * The issuer attributes. * @return the Builder object itself. */ @@ -100,14 +100,14 @@ private SetCertificateIssuerRequest(Builder builder) { vaultBaseUrl = builder.vaultBaseUrl; issuerName = builder.issuerName; provider = builder.provider; - if(builder.organizationDetails != null) { + if (builder.organizationDetails != null) { organizationDetails = new OrganizationDetails() .withId(builder.organizationDetails.id()) .withAdminDetails(new ArrayList(builder.organizationDetails.adminDetails())); } else { organizationDetails = null; } - if(builder.credentials != null) { + if (builder.credentials != null) { credentials = new IssuerCredentials() .withAccountId(builder.credentials.accountId()) .withPassword(builder.credentials.password()); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java index 37d1048673aea..d743f86cabe6c 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateIssuerRequest.java @@ -26,9 +26,9 @@ public static class Builder { // Required parameters private final String vaultBaseUrl; private final String issuerName; - private final String provider; // Optional parameters + private String provider; private IssuerCredentials credentials; private OrganizationDetails organizationDetails; private IssuerAttributes attributes; @@ -42,12 +42,23 @@ public static class Builder { * @param issuerName * The name of the issuer in the given vault. */ - public Builder(String vaultBaseUrl, String issuerName, String provider) { + public Builder(String vaultBaseUrl, String issuerName) { this.vaultBaseUrl = vaultBaseUrl; this.issuerName = issuerName; - this.provider = provider; } + /** + * Set issuer credentials. + * + * @param provider + * The issuer provider. + * @return the Builder object itself. + */ + public Builder withProvider(String provider) { + this.provider = provider; + return this; + } + /** * Set issuer credentials. * @@ -75,7 +86,7 @@ public Builder withOrganizationDetails(OrganizationDetails organizationDetails) /** * Set issuer attributes. * - * @param organizationDetails + * @param attributes * The issuer attributes. * @return the Builder object itself. */ @@ -98,14 +109,14 @@ private UpdateCertificateIssuerRequest(Builder builder) { vaultBaseUrl = builder.vaultBaseUrl; issuerName = builder.issuerName; provider = builder.provider; - if(builder.organizationDetails != null) { + if (builder.organizationDetails != null) { organizationDetails = new OrganizationDetails() .withId(builder.organizationDetails.id()) .withAdminDetails(new ArrayList(builder.organizationDetails.adminDetails())); } else { organizationDetails = null; } - if(builder.credentials != null) { + if (builder.credentials != null) { credentials = new IssuerCredentials() .withAccountId(builder.credentials.accountId()) .withPassword(builder.credentials.password()); diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java index 3fcd6787ce999..c2277e5bf2c5d 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -241,7 +241,7 @@ public void issuerAsync() throws Exception { IssuerBundle certificateIssuer = keyVaultClient.setCertificateIssuerAsync(setCertificateIssuerRequest, null).get().getBody(); Assert.assertNotNull(certificateIssuer); - UpdateCertificateIssuerRequest updateCertificateIssuerRequest = new UpdateCertificateIssuerRequest.Builder(vault, issuerName, "SslAdmin").build(); + UpdateCertificateIssuerRequest updateCertificateIssuerRequest = new UpdateCertificateIssuerRequest.Builder(vault, issuerName).withProvider("SslAdmin").build(); certificateIssuer = keyVaultClient.updateCertificateIssuerAsync(updateCertificateIssuerRequest, null).get().getBody(); Assert.assertNotNull(certificateIssuer); diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index c3dfd810293e3..8e4b7c7dced0f 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -798,7 +798,8 @@ public void issuerCrudOperations() throws Exception { retrievedCertificateIssuer.withCredentials(updatedCredentials); IssuerBundle updatedCertificateIssuer = keyVaultClient.updateCertificateIssuer( new UpdateCertificateIssuerRequest - .Builder(getVaultUri(), certificateIssuerName, ISSUER_TEST) + .Builder(getVaultUri(), certificateIssuerName) + .withProvider(ISSUER_TEST) .withCredentials(updatedCredentials) .withOrganizationDetails(retrievedCertificateIssuer.organizationDetails()) .withAttributes(retrievedCertificateIssuer.attributes()) From c335c05b03d168f91330c6dfe6995508a68e3d03 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Fri, 9 Sep 2016 10:20:01 -0700 Subject: [PATCH 32/56] Remove .getBody for ListanableFuture to accomodate the recent breaking change --- .../keyvault/extensions/KeyVaultKey.java | 19 +++-- .../extensions/KeyVaultKeyResolver.java | 15 ++-- .../keyvault/test/AsyncOperationsTest.java | 78 +++++++++---------- 3 files changed, 54 insertions(+), 58 deletions(-) diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java index f4afd66b74aaa..d3bf97abc148b 100755 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKey.java @@ -35,7 +35,6 @@ import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyOperationResult; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; -import com.microsoft.rest.ServiceResponse; /** * The key vault key that performs cryptography operations. @@ -45,22 +44,22 @@ public class KeyVaultKey implements IKey { /** * Transforms the result of decrypt operation to byte array. */ - class DecryptResultTransform implements Function, byte[]> { + class DecryptResultTransform implements Function { DecryptResultTransform() { super(); } @Override - public byte[] apply(ServiceResponse result) { - return result.getBody().result(); + public byte[] apply(KeyOperationResult result) { + return result.result(); } } /** * Transforms the result of sign operation to byte array and algorithm pair. */ - class SignResultTransform implements Function, Pair> { + class SignResultTransform implements Function> { private final String algorithm; @@ -70,9 +69,9 @@ class SignResultTransform implements Function apply(ServiceResponse input) { + public Pair apply(KeyOperationResult input) { - return Pair.of(input.getBody().result(), algorithm); + return Pair.of(input.result(), algorithm); } } @@ -168,7 +167,7 @@ public ListenableFuture decryptAsync(byte[] ciphertext, byte[] iv, byte[ } // Never local - ListenableFuture> futureCall = + ListenableFuture futureCall = client.decryptAsync( implementation.getKid(), new JsonWebKeyEncryptionAlgorithm(algorithm), @@ -206,7 +205,7 @@ public ListenableFuture unwrapKeyAsync(byte[] ciphertext, String algorit } // Never local - ListenableFuture> futureCall = + ListenableFuture futureCall = client.unwrapKeyAsync( implementation.getKid(), new JsonWebKeyEncryptionAlgorithm(algorithm), @@ -226,7 +225,7 @@ public ListenableFuture> signAsync(byte[] digest, String al } // Never local - ListenableFuture> futureCall = + ListenableFuture futureCall = client.signAsync( implementation.getKid(), new JsonWebKeySignatureAlgorithm(algorithm), diff --git a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java index 92f66ddba0c50..7f8e778ef0681 100755 --- a/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java +++ b/azure-keyvault-extensions/src/main/java/com/microsoft/azure/keyvault/extensions/KeyVaultKeyResolver.java @@ -32,7 +32,6 @@ import com.microsoft.azure.keyvault.cryptography.SymmetricKey; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.SecretBundle; -import com.microsoft.rest.ServiceResponse; /** * The key resolver class that handles resolving key id to type {@link IKey} @@ -45,16 +44,15 @@ public class KeyVaultKeyResolver implements IKeyResolver { /** * Transforms {@link KeyBundle} to {@link IKey}. */ - class FutureKeyFromKey implements Function, IKey> { + class FutureKeyFromKey implements Function { protected FutureKeyFromKey() { super(); } @Override - public IKey apply(ServiceResponse keyBundleResponse) { + public IKey apply(KeyBundle keyBundle) { - KeyBundle keyBundle = keyBundleResponse.getBody(); if (keyBundle != null) { return new KeyVaultKey(client, keyBundle); } @@ -66,16 +64,15 @@ public IKey apply(ServiceResponse keyBundleResponse) { /** * Transforms {@link SecretBundle} to {@link IKey}. */ - class FutureKeyFromSecret implements Function, IKey> { + class FutureKeyFromSecret implements Function { protected FutureKeyFromSecret() { super(); } @Override - public IKey apply(ServiceResponse secretBundleResponse) { + public IKey apply(SecretBundle secretBundle) { - SecretBundle secretBundle = secretBundleResponse.getBody(); if (secretBundle != null && secretBundle.contentType().equalsIgnoreCase("application/octet-stream")) { byte[] keyBytes = BASE64.decode(secretBundle.value()); @@ -112,13 +109,13 @@ public KeyVaultKeyResolver(KeyVaultClient client, Provider provider) { private ListenableFuture resolveKeyFromSecretAsync(String kid) { - ListenableFuture> futureCall = client.getSecretAsync(kid, null); + ListenableFuture futureCall = client.getSecretAsync(kid, null); return Futures.transform(futureCall, new FutureKeyFromSecret()); } private ListenableFuture resolveKeyFromKeyAsync(String kid) { - ListenableFuture> futureCall = client.getKeyAsync(kid, null); + ListenableFuture futureCall = client.getKeyAsync(kid, null); return Futures.transform(futureCall, new FutureKeyFromKey()); } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java index c2277e5bf2c5d..878603707842f 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -58,40 +58,40 @@ public void keyAsync() throws Exception { String keyname = "mykey"; CreateKeyRequest createKeyRequest = new CreateKeyRequest.Builder(vault, keyname, JsonWebKeyType.RSA).build(); - KeyBundle keyBundle = keyVaultClient.createKeyAsync(createKeyRequest, null).get().getBody(); + KeyBundle keyBundle = keyVaultClient.createKeyAsync(createKeyRequest, null).get(); Assert.assertNotNull(keyBundle); UpdateKeyRequest updateKeyRequest = new UpdateKeyRequest.Builder(keyBundle.key().kid()).build(); - keyBundle = keyVaultClient.updateKeyAsync(updateKeyRequest, null).get().getBody(); + keyBundle = keyVaultClient.updateKeyAsync(updateKeyRequest, null).get(); Assert.assertNotNull(keyBundle); - keyBundle = keyVaultClient.getKeyAsync(keyBundle.key().kid(), null).get().getBody(); + keyBundle = keyVaultClient.getKeyAsync(keyBundle.key().kid(), null).get(); Assert.assertNotNull(keyBundle); - List keyItems = keyVaultClient.listKeysAsync(vault, 2, null).get().getBody(); + List keyItems = keyVaultClient.listKeysAsync(vault, 2, null).get(); Assert.assertNotNull(keyItems); - List keyVersionItems = keyVaultClient.listKeyVersionsAsync(getVaultUri(), keyname, 2, null).get().getBody(); + List keyVersionItems = keyVaultClient.listKeyVersionsAsync(getVaultUri(), keyname, 2, null).get(); Assert.assertNotNull(keyVersionItems); - BackupKeyResult backupResult = keyVaultClient.backupKeyAsync(vault, keyname, null).get().getBody(); + BackupKeyResult backupResult = keyVaultClient.backupKeyAsync(vault, keyname, null).get(); Assert.assertNotNull(backupResult); keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get(); - KeyBundle restoreResult = keyVaultClient.restoreKeyAsync(vault, backupResult.value(), null).get().getBody(); + KeyBundle restoreResult = keyVaultClient.restoreKeyAsync(vault, backupResult.value(), null).get(); Assert.assertNotNull(restoreResult); - KeyOperationResult encryptResult = keyVaultClient.encryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, new byte[100], null).get().getBody(); + KeyOperationResult encryptResult = keyVaultClient.encryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, new byte[100], null).get(); Assert.assertNotNull(encryptResult); - KeyOperationResult decryptResult = keyVaultClient.decryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, encryptResult.result(), null).get().getBody(); + KeyOperationResult decryptResult = keyVaultClient.decryptAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, encryptResult.result(), null).get(); Assert.assertNotNull(decryptResult); - KeyOperationResult wrapResult = keyVaultClient.wrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, new byte[100], null).get().getBody(); + KeyOperationResult wrapResult = keyVaultClient.wrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, new byte[100], null).get(); Assert.assertNotNull(wrapResult); - KeyOperationResult unwrapResult = keyVaultClient.unwrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, wrapResult.result(), null).get().getBody(); + KeyOperationResult unwrapResult = keyVaultClient.unwrapKeyAsync(keyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, wrapResult.result(), null).get(); Assert.assertNotNull(unwrapResult); byte[] plainText = new byte[100]; @@ -99,13 +99,13 @@ public void keyAsync() throws Exception { MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(plainText); byte[] digest = md.digest(); - KeyOperationResult signResult = keyVaultClient.signAsync(keyBundle.key().kid(), JsonWebKeySignatureAlgorithm.RS256, digest, null).get().getBody(); + KeyOperationResult signResult = keyVaultClient.signAsync(keyBundle.key().kid(), JsonWebKeySignatureAlgorithm.RS256, digest, null).get(); Assert.assertNotNull(signResult); - KeyVerifyResult verifypResult = keyVaultClient.verifyAsync(keyBundle.key().kid(), JsonWebKeySignatureAlgorithm.RS256, digest, signResult.result(), null).get().getBody(); + KeyVerifyResult verifypResult = keyVaultClient.verifyAsync(keyBundle.key().kid(), JsonWebKeySignatureAlgorithm.RS256, digest, signResult.result(), null).get(); Assert.assertTrue(verifypResult.value()); - keyBundle = keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get().getBody(); + keyBundle = keyVaultClient.deleteKeyAsync(keyBundle.keyIdentifier().vault(), keyBundle.keyIdentifier().name(), null).get(); Assert.assertNotNull(keyBundle); //Get the unavailable key to throw exception -> it gets stuck @@ -131,23 +131,23 @@ public void secretAsync() throws Exception { String password = "password"; SetSecretRequest setSecretRequest = new SetSecretRequest.Builder(vault, secretname, password).build(); - SecretBundle secretBundle = keyVaultClient.setSecretAsync(setSecretRequest, null).get().getBody(); + SecretBundle secretBundle = keyVaultClient.setSecretAsync(setSecretRequest, null).get(); Assert.assertNotNull(secretBundle); UpdateSecretRequest updateSecretRequest = new UpdateSecretRequest.Builder(secretBundle.id()).build(); - secretBundle = keyVaultClient.updateSecretAsync(updateSecretRequest, null).get().getBody(); + secretBundle = keyVaultClient.updateSecretAsync(updateSecretRequest, null).get(); Assert.assertNotNull(secretBundle); - secretBundle = keyVaultClient.getSecretAsync(secretBundle.id(), null).get().getBody(); + secretBundle = keyVaultClient.getSecretAsync(secretBundle.id(), null).get(); Assert.assertNotNull(secretBundle); - List secretItems = keyVaultClient.listSecretsAsync(vault, 2, null).get().getBody(); + List secretItems = keyVaultClient.listSecretsAsync(vault, 2, null).get(); Assert.assertNotNull(secretItems); - List secretVersionItems = keyVaultClient.listSecretVersionsAsync(vault, secretname, 2, null).get().getBody(); + List secretVersionItems = keyVaultClient.listSecretVersionsAsync(vault, secretname, 2, null).get(); Assert.assertNotNull(secretVersionItems); - secretBundle = keyVaultClient.deleteSecretAsync(vault, secretname, null).get().getBody(); + secretBundle = keyVaultClient.deleteSecretAsync(vault, secretname, null).get(); Assert.assertNotNull(secretBundle); try { @@ -179,44 +179,44 @@ public void certificateAsync() throws Exception { .withSubject("CN=SelfSignedJavaPkcs12") .withValidityInMonths(12))) .build(); - CertificateOperation certificateOperation = keyVaultClient.createCertificateAsync(createCertificateRequest, null).get().getBody(); + CertificateOperation certificateOperation = keyVaultClient.createCertificateAsync(createCertificateRequest, null).get(); Assert.assertNotNull(certificateOperation); UpdateCertificateOperationRequest updateCertificateOperationRequest = new UpdateCertificateOperationRequest.Builder(vault, certificateName, false).build(); - certificateOperation = keyVaultClient.updateCertificateOperationAsync(updateCertificateOperationRequest, null).get().getBody(); + certificateOperation = keyVaultClient.updateCertificateOperationAsync(updateCertificateOperationRequest, null).get(); Assert.assertNotNull(certificateOperation); Map tags = new HashMap(); tags.put("tag1", "foo"); UpdateCertificateRequest updateCertificateRequest = new UpdateCertificateRequest.Builder(vault, certificateName).withTags(tags).build(); - CertificateBundle certificateBundle = keyVaultClient.updateCertificateAsync(updateCertificateRequest, null).get().getBody(); + CertificateBundle certificateBundle = keyVaultClient.updateCertificateAsync(updateCertificateRequest, null).get(); Assert.assertNotNull(certificateBundle); UpdateCertificatePolicyRequest updateCertificatePolicyRequest = new UpdateCertificatePolicyRequest.Builder(vault, certificateName).build(); - CertificatePolicy certificatePolicy = keyVaultClient.updateCertificatePolicyAsync(updateCertificatePolicyRequest, null).get().getBody(); + CertificatePolicy certificatePolicy = keyVaultClient.updateCertificatePolicyAsync(updateCertificatePolicyRequest, null).get(); Assert.assertNotNull(certificatePolicy); - certificatePolicy = keyVaultClient.getCertificatePolicyAsync(vault, certificateName, null).get().getBody(); + certificatePolicy = keyVaultClient.getCertificatePolicyAsync(vault, certificateName, null).get(); Assert.assertNotNull(certificatePolicy); - certificateOperation = keyVaultClient.getCertificateOperationAsync(vault, certificateName, null).get().getBody(); + certificateOperation = keyVaultClient.getCertificateOperationAsync(vault, certificateName, null).get(); Assert.assertNotNull(certificateOperation); - certificateBundle = keyVaultClient.getCertificateAsync(vault, certificateName, null).get().getBody(); + certificateBundle = keyVaultClient.getCertificateAsync(vault, certificateName, null).get(); Assert.assertNotNull(certificateBundle); - String cert = keyVaultClient.getPendingCertificateSigningRequestAsync(vault, certificateName, null).get().getBody(); + String cert = keyVaultClient.getPendingCertificateSigningRequestAsync(vault, certificateName, null).get(); Assert.assertTrue(!cert.isEmpty()); - List certificateItem = keyVaultClient.listCertificatesAsync(vault, null).get().getBody(); + List certificateItem = keyVaultClient.listCertificatesAsync(vault, null).get(); Assert.assertNotNull(certificateItem); - List certificateVersionItem = keyVaultClient.listCertificateVersionsAsync(vault, certificateName, null).get().getBody(); + List certificateVersionItem = keyVaultClient.listCertificateVersionsAsync(vault, certificateName, null).get(); Assert.assertNotNull(certificateVersionItem); - keyVaultClient.deleteCertificateOperationAsync(vault, certificateName, null).get().getBody(); - keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get().getBody(); + keyVaultClient.deleteCertificateOperationAsync(vault, certificateName, null).get(); + keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get(); try { keyVaultClient.deleteCertificateAsync(vault, certificateName, null).get(); @@ -238,20 +238,20 @@ public void issuerAsync() throws Exception { String issuerName = "myIssuer"; SetCertificateIssuerRequest setCertificateIssuerRequest = new SetCertificateIssuerRequest.Builder(vault, issuerName, "Test").build(); - IssuerBundle certificateIssuer = keyVaultClient.setCertificateIssuerAsync(setCertificateIssuerRequest, null).get().getBody(); + IssuerBundle certificateIssuer = keyVaultClient.setCertificateIssuerAsync(setCertificateIssuerRequest, null).get(); Assert.assertNotNull(certificateIssuer); UpdateCertificateIssuerRequest updateCertificateIssuerRequest = new UpdateCertificateIssuerRequest.Builder(vault, issuerName).withProvider("SslAdmin").build(); - certificateIssuer = keyVaultClient.updateCertificateIssuerAsync(updateCertificateIssuerRequest, null).get().getBody(); + certificateIssuer = keyVaultClient.updateCertificateIssuerAsync(updateCertificateIssuerRequest, null).get(); Assert.assertNotNull(certificateIssuer); - certificateIssuer = keyVaultClient.getCertificateIssuerAsync(vault, issuerName, null).get().getBody(); + certificateIssuer = keyVaultClient.getCertificateIssuerAsync(vault, issuerName, null).get(); Assert.assertNotNull(certificateIssuer); - List issuers = keyVaultClient.listCertificateIssuersAsync(vault, null).get().getBody(); + List issuers = keyVaultClient.listCertificateIssuersAsync(vault, null).get(); Assert.assertNotNull(issuers); - keyVaultClient.deleteCertificateIssuerAsync(vault, issuerName, null).get().getBody(); + keyVaultClient.deleteCertificateIssuerAsync(vault, issuerName, null).get(); } @@ -260,10 +260,10 @@ public void certificateContactsAsync() throws Exception { String vault = getVaultUri(); - Contacts contacts = keyVaultClient.setCertificateContactsAsync(vault, new Contacts(), null).get().getBody(); + Contacts contacts = keyVaultClient.setCertificateContactsAsync(vault, new Contacts(), null).get(); Assert.assertNotNull(contacts); - contacts = keyVaultClient.getCertificateContactsAsync(vault, null).get().getBody(); + contacts = keyVaultClient.getCertificateContactsAsync(vault, null).get(); Assert.assertNotNull(contacts); keyVaultClient.deleteCertificateContactsAsync(vault, null).get(); From db09121f0b9bba5dfb4bcfe09a15c7e462c431a5 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Mon, 12 Sep 2016 10:30:25 -0700 Subject: [PATCH 33/56] key vault cryptography refactoring. Removing additional methods from ByteExtension and using Arrays extension methods where applicable. Changed static final names to all caps. --- .../cryptography/AlgorithmResolver.java | 26 ++--- .../keyvault/cryptography/ByteExtensions.java | 95 ++----------------- .../azure/keyvault/cryptography/RsaKey.java | 8 +- .../keyvault/cryptography/SymmetricKey.java | 20 ++-- .../cryptography/algorithms/Aes128Cbc.java | 57 +---------- .../algorithms/Aes128CbcHmacSha256.java | 4 +- .../cryptography/algorithms/Aes192Cbc.java | 58 +---------- .../algorithms/Aes192CbcHmacSha384.java | 4 +- .../cryptography/algorithms/Aes256Cbc.java | 58 +---------- .../algorithms/Aes256CbcHmacSha512.java | 4 +- .../cryptography/algorithms/AesCbc.java | 33 +++++-- .../algorithms/AesCbcHmacSha2.java | 6 +- .../cryptography/algorithms/AesKw128.java | 10 +- .../cryptography/algorithms/AesKw192.java | 10 +- .../cryptography/algorithms/AesKw256.java | 10 +- .../cryptography/algorithms/Rs256.java | 26 ++++- .../cryptography/algorithms/Rsa15.java | 4 +- .../cryptography/algorithms/RsaOaep.java | 4 +- .../cryptography/test/AesCbcTest.java | 18 ++-- .../cryptography/test/RsaKeyTest.java | 26 ++--- 20 files changed, 144 insertions(+), 337 deletions(-) diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java index 6804aa055420d..60930c8d1e3a7 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/AlgorithmResolver.java @@ -27,23 +27,23 @@ public class AlgorithmResolver { public static final AlgorithmResolver Default = new AlgorithmResolver(); static { - Default.put(Aes128CbcHmacSha256.AlgorithmName, new Aes128CbcHmacSha256()); - Default.put(Aes192CbcHmacSha384.AlgorithmName, new Aes192CbcHmacSha384()); - Default.put(Aes256CbcHmacSha512.AlgorithmName, new Aes256CbcHmacSha512()); + Default.put(Aes128CbcHmacSha256.ALGORITHM_NAME, new Aes128CbcHmacSha256()); + Default.put(Aes192CbcHmacSha384.ALGORITHM_NAME, new Aes192CbcHmacSha384()); + Default.put(Aes256CbcHmacSha512.ALGORITHM_NAME, new Aes256CbcHmacSha512()); - Default.put(Aes128Cbc.AlgorithmName, new Aes128Cbc()); - Default.put(Aes192Cbc.AlgorithmName, new Aes192Cbc()); - Default.put(Aes256Cbc.AlgorithmName, new Aes256Cbc()); + Default.put(Aes128Cbc.ALGORITHM_NAME, new Aes128Cbc()); + Default.put(Aes192Cbc.ALGORITHM_NAME, new Aes192Cbc()); + Default.put(Aes256Cbc.ALGORITHM_NAME, new Aes256Cbc()); - Default.put(AesKw128.AlgorithmName, new AesKw128()); - Default.put(AesKw192.AlgorithmName, new AesKw192()); - Default.put(AesKw256.AlgorithmName, new AesKw256()); + Default.put(AesKw128.ALGORITHM_NAME, new AesKw128()); + Default.put(AesKw192.ALGORITHM_NAME, new AesKw192()); + Default.put(AesKw256.ALGORITHM_NAME, new AesKw256()); - Default.put(Rsa15.AlgorithmName, new Rsa15()); - Default.put(RsaOaep.AlgorithmName, new RsaOaep()); + Default.put(Rsa15.ALGORITHM_NAME, new Rsa15()); + Default.put(RsaOaep.ALGORITHM_NAME, new RsaOaep()); - Default.put( Rs256.AlgorithmName, new Rs256() ); - // Default.put( RsNull.AlgorithmName, new RsNull() ); + Default.put( Rs256.ALGORITHM_NAME, new Rs256() ); + // Default.put( RsNull.ALGORITHM_NAME, new RsNull() ); } private final ConcurrentMap _algorithms = new ConcurrentHashMap(); diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java index c76b4c507de6a..2c8af1810d836 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java @@ -6,26 +6,9 @@ package com.microsoft.azure.keyvault.cryptography; -public final class ByteExtensions { - - public static boolean sequenceEqualConstantTime( byte[] self, byte[] other ) - { - if ( self == null ) - throw new IllegalArgumentException( "self" ); +import java.util.Arrays; - if ( other == null ) - throw new IllegalArgumentException( "other" ); - - // Constant time comparison of two byte arrays - long difference = ( self.length & 0xffffffffl ) ^ ( other.length & 0xffffffffl ); - - for ( int i = 0; i < self.length && i < other.length; i++ ) - { - difference |= ( self[i] ^ other[i] ) & 0xffffffffl; - } - - return difference == 0; - } +public final class ByteExtensions { public static byte[] or( byte[] self, byte[] other ) { @@ -54,19 +37,10 @@ public static byte[] or( byte[] self, byte[] other, int offset ) } public static byte[] xor( byte[] self, byte[] other ) { - return xor( self, other, 0, false ); - } - - public static byte[] xor( byte[] self, byte[] other, boolean inPlace ) - { - return xor( self, other, 0, inPlace ); - } - - public static byte[] xor( byte[] self, byte[] other, int offset ) { - return xor( self, other, 0, false ); + return xor( self, other, 0 ); } - public static byte[] xor( byte[] self, byte[] other, int offset, boolean inPlace ) + static byte[] xor( byte[] self, byte[] other, int offset ) { if ( self == null ) throw new IllegalArgumentException( "self" ); @@ -77,71 +51,20 @@ public static byte[] xor( byte[] self, byte[] other, int offset, boolean inPlace if ( self.length > other.length - offset ) throw new IllegalArgumentException( "self and other lengths do not match" ); - if ( inPlace ) - { - for ( int i = 0; i < self.length; i++ ) - { - self[i] = (byte)( self[i] ^ other[offset + i] ); - } + byte[] result = new byte[self.length]; - return self; - } - else + for ( int i = 0; i < self.length; i++ ) { - byte[] result = new byte[self.length]; - - for ( int i = 0; i < self.length; i++ ) - { - result[i] = (byte)( self[i] ^ other[offset + i] ); - } - - return result; + result[i] = (byte)( self[i] ^ other[offset + i] ); } - } - - public static byte[] take( byte[] self, int count ) - { - return ByteExtensions.take( self, 0, count ); - } - - - /** - * Takes the first count bytes from the source and - * returns a new array containing those bytes. - * - * @param self The source of the bytes. - * @param offset The starting offset. - * @param count The number of bytes to take. - * @return count bytes from the source as a new array. - */ - public static byte[] take( byte[] self, int offset, int count ) - { - if ( self == null ) - throw new IllegalArgumentException( "self" ); - - if ( offset < 0 ) - throw new IllegalArgumentException( "offset cannot be < 0" ); - - if ( count <= 0 ) - throw new IllegalArgumentException( "count cannot be <= 0" ); - - if ( offset + count > self.length ) - throw new IllegalArgumentException( "offset + count cannot be > self.Length" ); - - byte[] result = new byte[count]; - - System.arraycopy( self, offset, result, 0, count ); return result; } public static void zero( byte[] self ) { - if ( self == null ) - throw new IllegalArgumentException( "self" ); - - for ( int i = 0; i < self.length; i++ ) { - self[i] = 0; + if ( self != null ) { + Arrays.fill(self, (byte)0); } } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java index 4abfcfd8855a6..c8807fc29c49f 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/RsaKey.java @@ -84,17 +84,17 @@ public RsaKey(String kid, KeyPair keyPair, Provider provider) { @Override public String getDefaultEncryptionAlgorithm() { - return RsaOaep.AlgorithmName; + return RsaOaep.ALGORITHM_NAME; } @Override public String getDefaultKeyWrapAlgorithm() { - return RsaOaep.AlgorithmName; + return RsaOaep.ALGORITHM_NAME; } @Override public String getDefaultSignatureAlgorithm() { - return Rs256.AlgorithmName; + return Rs256.ALGORITHM_NAME; } @Override @@ -253,7 +253,7 @@ public ListenableFuture> signAsync(final byte[] digest, fin ISignatureTransform signer = algo.createSignatureTransform(_keyPair); try { - return Futures.immediateFuture(Pair.of(signer.sign(digest), Rs256.AlgorithmName)); + return Futures.immediateFuture(Pair.of(signer.sign(digest), Rs256.ALGORITHM_NAME)); } catch (Exception e) { return Futures.immediateFailedFuture(e); } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java index 14e0797b46587..a5e333f092f3b 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java @@ -66,19 +66,19 @@ public String getDefaultEncryptionAlgorithm() { switch (_key.length) { case KeySize128: - return Aes128Cbc.AlgorithmName; + return Aes128Cbc.ALGORITHM_NAME; case KeySize192: - return Aes192Cbc.AlgorithmName; + return Aes192Cbc.ALGORITHM_NAME; case KeySize256: - return Aes128CbcHmacSha256.AlgorithmName; + return Aes128CbcHmacSha256.ALGORITHM_NAME; case KeySize384: - return Aes192CbcHmacSha384.AlgorithmName; + return Aes192CbcHmacSha384.ALGORITHM_NAME; case KeySize512: - return Aes256CbcHmacSha512.AlgorithmName; + return Aes256CbcHmacSha512.ALGORITHM_NAME; } return null; @@ -89,21 +89,21 @@ public String getDefaultKeyWrapAlgorithm() { switch (_key.length) { case KeySize128: - return AesKw128.AlgorithmName; + return AesKw128.ALGORITHM_NAME; case KeySize192: - return AesKw192.AlgorithmName; + return AesKw192.ALGORITHM_NAME; case KeySize256: - return AesKw256.AlgorithmName; + return AesKw256.ALGORITHM_NAME; case KeySize384: // Default to longest allowed key length for wrap - return AesKw256.AlgorithmName; + return AesKw256.ALGORITHM_NAME; case KeySize512: // Default to longest allowed key length for wrap - return AesKw256.AlgorithmName; + return AesKw256.ALGORITHM_NAME; } return null; diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java index 14cf40023b7c8..89a10584294dd 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128Cbc.java @@ -6,63 +6,12 @@ package com.microsoft.azure.keyvault.cryptography.algorithms; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.Provider; - -import javax.crypto.NoSuchPaddingException; - -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; -import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; - public class Aes128Cbc extends AesCbc { - public static final String AlgorithmName = "A128CBC"; - - static final int KeySizeInBytes = 128 >> 3; + private static final int KEY_SIZE = 128; + public static final String ALGORITHM_NAME = "A128CBC"; public Aes128Cbc() { - super(AlgorithmName); - } - - @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); - } - - @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); - } - - @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); - } - - @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + super(ALGORITHM_NAME, KEY_SIZE); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java index 9e75131a3de84..f473aee20d11b 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes128CbcHmacSha256.java @@ -8,9 +8,9 @@ public class Aes128CbcHmacSha256 extends AesCbcHmacSha2 { - public static final String AlgorithmName = "A128CBC-HS256"; + public static final String ALGORITHM_NAME = "A128CBC-HS256"; public Aes128CbcHmacSha256() { - super(AlgorithmName); + super(ALGORITHM_NAME); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java index 4ec8451b47901..fe6f3ff8f1f16 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192Cbc.java @@ -6,64 +6,12 @@ package com.microsoft.azure.keyvault.cryptography.algorithms; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.Provider; - -import javax.crypto.NoSuchPaddingException; - -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; -import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; - public class Aes192Cbc extends AesCbc { - public static final String AlgorithmName = "A192CBC"; - - static final int KeySizeInBytes = 192 >> 3; + private static final int KEY_SIZE = 192; + public static final String ALGORITHM_NAME = "A192CBC"; public Aes192Cbc() { - super(AlgorithmName); - } - - @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); - } - - @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + super(ALGORITHM_NAME, KEY_SIZE); } - - @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); - } - - @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); - } - } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java index 74f279eff8c72..ecfc65f49ff69 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes192CbcHmacSha384.java @@ -8,9 +8,9 @@ public class Aes192CbcHmacSha384 extends AesCbcHmacSha2 { - public static final String AlgorithmName = "A192CBC-HS384"; + public static final String ALGORITHM_NAME = "A192CBC-HS384"; public Aes192CbcHmacSha384() { - super(AlgorithmName); + super(ALGORITHM_NAME); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java index 629b647ec6b92..f198b9012b54c 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256Cbc.java @@ -6,64 +6,12 @@ package com.microsoft.azure.keyvault.cryptography.algorithms; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.security.Provider; - -import javax.crypto.NoSuchPaddingException; - -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; -import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; - public class Aes256Cbc extends AesCbc { - public static final String AlgorithmName = "A256CBC"; - - static final int KeySizeInBytes = 256 >> 3; + private static final int KEY_SIZE = 256; + public static final String ALGORITHM_NAME = "A256CBC"; public Aes256Cbc() { - super(AlgorithmName); - } - - @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); - } - - @Override - public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + super(ALGORITHM_NAME, KEY_SIZE); } - - @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, null); - } - - @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - if (key == null || key.length < KeySizeInBytes) { - throw new InvalidKeyException("key must be at least 128 bits in length"); - } - - return new AesCbcDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); - } - } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java index e038c808fec53..61c1aead84b77 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Aes256CbcHmacSha512.java @@ -8,9 +8,9 @@ public class Aes256CbcHmacSha512 extends AesCbcHmacSha2 { - public static final String AlgorithmName = "A256CBC-HS512"; + public static final String ALGORITHM_NAME = "A256CBC-HS512"; public Aes256CbcHmacSha512() { - super(AlgorithmName); + super(ALGORITHM_NAME); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java index 49edaa57a71b5..d2f891cc13094 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java @@ -10,6 +10,7 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Provider; +import java.util.Arrays; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -23,6 +24,8 @@ public abstract class AesCbc extends SymmetricEncryptionAlgorithm { + final int keySizeInBytes; + final int keySize; static class AesCbcDecryptor implements ICryptoTransform { private final Cipher _cipher; @@ -67,31 +70,49 @@ public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPad } } - protected AesCbc(String name) { + protected AesCbc(String name, int size) { super(name); + keySize = size; + keySizeInBytes = size >> 3; } @Override public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - - return new AesCbcEncryptor(key, iv, null); + + if (key == null || key.length < keySizeInBytes) { + throw new InvalidKeyException("key must be at least " + keySize + " bits in length"); + } + + return new AesCbcEncryptor(Arrays.copyOfRange(key, 0, keySizeInBytes), iv, null); } @Override public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - return new AesCbcEncryptor(key, iv, provider); + if (key == null || key.length < keySizeInBytes) { + throw new InvalidKeyException("key must be at least " + keySize + " bits in length"); + } + + return new AesCbcEncryptor(Arrays.copyOfRange(key, 0, keySizeInBytes), iv, provider); } @Override public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - return new AesCbcDecryptor(key, iv, null); + if (key == null || key.length < keySizeInBytes) { + throw new InvalidKeyException("key must be at least " + keySize + " bits in length"); + } + + return new AesCbcDecryptor(Arrays.copyOfRange(key, 0, keySizeInBytes), iv, null); } @Override public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - return new AesCbcDecryptor(key, iv, provider); + if (key == null || key.length < keySizeInBytes) { + throw new InvalidKeyException("key must be at least " + keySize + " bits in length"); + } + + return new AesCbcDecryptor(Arrays.copyOfRange(key, 0, keySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java index c2ccc2a88ab13..0372401e5a039 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java @@ -212,7 +212,7 @@ private static Triple GetAlgorithmParameters(String algorit byte[] hmac_key; Mac hmac; - if (algorithm.equalsIgnoreCase(Aes128CbcHmacSha256.AlgorithmName)) { + if (algorithm.equalsIgnoreCase(Aes128CbcHmacSha256.ALGORITHM_NAME)) { if ((key.length << 3) < 256) { throw new IllegalArgumentException(String.format("%s key length in bits %d < 256", algorithm, key.length << 3)); } @@ -227,7 +227,7 @@ private static Triple GetAlgorithmParameters(String algorit hmac = Mac.getInstance("HmacSHA256"); hmac.init(new SecretKeySpec(hmac_key, "HmacSHA256")); - } else if (algorithm.equalsIgnoreCase(Aes192CbcHmacSha384.AlgorithmName)) { + } else if (algorithm.equalsIgnoreCase(Aes192CbcHmacSha384.ALGORITHM_NAME)) { if ((key.length << 3) < 384) { throw new IllegalArgumentException(String.format("%s key length in bits %d < 384", algorithm, key.length << 3)); @@ -242,7 +242,7 @@ private static Triple GetAlgorithmParameters(String algorit hmac = Mac.getInstance("HmacSHA384"); hmac.init(new SecretKeySpec(hmac_key, "HmacSHA384")); - } else if (algorithm.equalsIgnoreCase(Aes256CbcHmacSha512.AlgorithmName)) { + } else if (algorithm.equalsIgnoreCase(Aes256CbcHmacSha512.ALGORITHM_NAME)) { if ((key.length << 3) < 512) { throw new IllegalArgumentException(String.format("%s key length in bits %d < 512", algorithm, key.length << 3)); diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java index 3c628688ef236..d5696f5998f3f 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw128.java @@ -10,20 +10,20 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Provider; +import java.util.Arrays; import javax.crypto.NoSuchPaddingException; -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public final class AesKw128 extends AesKw { - public static final String AlgorithmName = "A128KW"; + public static final String ALGORITHM_NAME = "A128KW"; static final int KeySizeInBytes = 128 >> 3; public AesKw128() { - super(AlgorithmName); + super(ALGORITHM_NAME); } @Override @@ -37,7 +37,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 128 bits long"); } - return super.CreateEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + return super.CreateEncryptor(Arrays.copyOfRange(key, 0, KeySizeInBytes), iv, provider); } @Override @@ -51,7 +51,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 128 bits long"); } - return super.CreateDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + return super.CreateDecryptor(Arrays.copyOfRange(key, 0, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java index dd24b0011a0c1..43225d8e080dd 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw192.java @@ -10,20 +10,20 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Provider; +import java.util.Arrays; import javax.crypto.NoSuchPaddingException; -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public final class AesKw192 extends AesKw { - public static final String AlgorithmName = "A192KW"; + public static final String ALGORITHM_NAME = "A192KW"; static final int KeySizeInBytes = 192 >> 3; public AesKw192() { - super(AlgorithmName); + super(ALGORITHM_NAME); } @Override @@ -37,7 +37,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 192 bits long"); } - return super.CreateEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + return super.CreateEncryptor(Arrays.copyOfRange(key, 0, KeySizeInBytes), iv, provider); } @Override @@ -51,7 +51,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 192 bits long"); } - return super.CreateDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + return super.CreateDecryptor(Arrays.copyOfRange(key, 0, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java index 79398e292adc4..b2b514713c96f 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesKw256.java @@ -10,20 +10,20 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.Provider; +import java.util.Arrays; import javax.crypto.NoSuchPaddingException; -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; public final class AesKw256 extends AesKw { - public static final String AlgorithmName = "A256KW"; + public static final String ALGORITHM_NAME = "A256KW"; static final int KeySizeInBytes = 256 >> 3; public AesKw256() { - super(AlgorithmName); + super(ALGORITHM_NAME); } @Override @@ -37,7 +37,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 256 bits long"); } - return super.CreateEncryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + return super.CreateEncryptor(Arrays.copyOfRange(key, 0, KeySizeInBytes), iv, provider); } @Override @@ -51,7 +51,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, Provider provider throw new IllegalArgumentException("key must be at least 256 bits long"); } - return super.CreateDecryptor(ByteExtensions.take(key, KeySizeInBytes), iv, provider); + return super.CreateDecryptor(Arrays.copyOfRange(key, 0, KeySizeInBytes), iv, provider); } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java index 54a4fd4572361..eddafecac6b28 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java @@ -12,7 +12,6 @@ import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ISignatureTransform; /** @@ -75,15 +74,15 @@ public boolean verify(byte[] digest, byte[] signature) throws NoSuchAlgorithmExc byte[] EM2 = EMSA_PKCS1_V1_5_ENCODE_HASH(digest, _emLen, "SHA-256"); // Use constant time compare - return ByteExtensions.sequenceEqualConstantTime(EM, EM2); + return sequenceEqualConstantTime(EM, EM2); } } - public final static String AlgorithmName = "RS256"; + public final static String ALGORITHM_NAME = "RS256"; public Rs256() { - super(AlgorithmName); + super(ALGORITHM_NAME); } @Override @@ -91,4 +90,23 @@ public ISignatureTransform createSignatureTransform(KeyPair keyPair) { return new Rs256SignatureTransform(keyPair); } + + private boolean sequenceEqualConstantTime( byte[] self, byte[] other ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + if ( other == null ) + throw new IllegalArgumentException( "other" ); + + // Constant time comparison of two byte arrays + long difference = ( self.length & 0xffffffffl ) ^ ( other.length & 0xffffffffl ); + + for ( int i = 0; i < self.length && i < other.length; i++ ) + { + difference |= ( self[i] ^ other[i] ) & 0xffffffffl; + } + + return difference == 0; + } } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java index 4770183bb3ab8..18ea8d28514fd 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rsa15.java @@ -72,10 +72,10 @@ public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPad final static String RSA15 = "RSA/ECB/PKCS1Padding"; - public final static String AlgorithmName = "RSA1_5"; + public final static String ALGORITHM_NAME = "RSA1_5"; public Rsa15() { - super(AlgorithmName); + super(ALGORITHM_NAME); } @Override diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java index 55b57b6acd633..38c3e4131231b 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/RsaOaep.java @@ -72,10 +72,10 @@ public byte[] doFinal(byte[] plaintext) throws IllegalBlockSizeException, BadPad final static String RSAOAEP = "RSA/ECB/OAEPWithSHA1AndMGF1Padding"; - public final static String AlgorithmName = "RSA-OAEP"; + public final static String ALGORITHM_NAME = "RSA-OAEP"; public RsaOaep() { - super(AlgorithmName); + super(ALGORITHM_NAME); } @Override diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java index 351f22a1ce993..b9bbf4a65e1e9 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.fail; import java.security.Provider; +import java.util.Arrays; import org.junit.After; import org.junit.AfterClass; @@ -11,7 +12,6 @@ import org.junit.BeforeClass; import org.junit.Test; -import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128Cbc; @@ -63,7 +63,7 @@ public void testAes128CbcOneBlock() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(encrypted, 16), ED); + assertArrayEquals(Arrays.copyOfRange(encrypted, 0, 16), ED); } catch (Exception e) { fail(e.getMessage()); } @@ -81,7 +81,7 @@ public void testAes128CbcOneBlock() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(decrypted, 16), PLAIN); + assertArrayEquals(Arrays.copyOfRange(decrypted, 0, 16), PLAIN); } catch (Exception e) { fail(e.getMessage()); } @@ -110,7 +110,7 @@ public void testAes128CbcTwoBlock() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(encrypted, 32), ED); + assertArrayEquals(Arrays.copyOfRange(encrypted, 0, 32), ED); } catch (Exception e) { fail(e.getMessage()); } @@ -128,7 +128,7 @@ public void testAes128CbcTwoBlock() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(decrypted, 32), PLAIN); + assertArrayEquals(Arrays.copyOfRange(decrypted, 0, 32), PLAIN); } catch (Exception e) { fail(e.getMessage()); } @@ -157,7 +157,7 @@ public void testAes128CbcOneBlock_ExcessKeyMaterial() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(encrypted, 16),ED); + assertArrayEquals(Arrays.copyOfRange(encrypted, 0, 16),ED); } catch (Exception e) { fail(e.getMessage()); } @@ -175,7 +175,7 @@ public void testAes128CbcOneBlock_ExcessKeyMaterial() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 16 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(decrypted, 16), PLAIN); + assertArrayEquals(Arrays.copyOfRange(decrypted, 0, 16), PLAIN); } catch (Exception e) { fail(e.getMessage()); } @@ -204,7 +204,7 @@ public void testAes128CbcTwoBlock_ExcessKeyMaterial() { encrypted = encryptor.doFinal(PLAIN); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(encrypted, 32), ED); + assertArrayEquals(Arrays.copyOfRange(encrypted, 0, 32), ED); } catch (Exception e) { fail(e.getMessage()); } @@ -222,7 +222,7 @@ public void testAes128CbcTwoBlock_ExcessKeyMaterial() { decrypted = decryptor.doFinal(encrypted); // Assert: we only compare the first 32 bytes as this library uses PKCS7 padding - assertArrayEquals(ByteExtensions.take(decrypted, 32), PLAIN); + assertArrayEquals(Arrays.copyOfRange(decrypted, 0, 32), PLAIN); } catch (Exception e) { fail(e.getMessage()); } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java index 18cf7db616e18..799827bd349c5 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/RsaKeyTest.java @@ -57,19 +57,19 @@ public void testRsa15() throws Exception { RsaKey key = getTestRsaKey(); // Wrap and Unwrap - Pair wrapped = key.wrapKeyAsync(CEK, Rsa15.AlgorithmName).get(); + Pair wrapped = key.wrapKeyAsync(CEK, Rsa15.ALGORITHM_NAME).get(); byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); // Assert - assertEquals(Rsa15.AlgorithmName, wrapped.getRight()); + assertEquals(Rsa15.ALGORITHM_NAME, wrapped.getRight()); assertArrayEquals(CEK, unwrapped); // Encrypt and Decrypt - Triple encrypted = key.encryptAsync(CEK, null, null, Rsa15.AlgorithmName).get(); + Triple encrypted = key.encryptAsync(CEK, null, null, Rsa15.ALGORITHM_NAME).get(); byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); // Assert - assertEquals(Rsa15.AlgorithmName, encrypted.getRight()); + assertEquals(Rsa15.ALGORITHM_NAME, encrypted.getRight()); assertArrayEquals(CEK, decrypted); key.close(); @@ -81,19 +81,19 @@ public void testRsaOaep() throws Exception { RsaKey key = getTestRsaKey(); // Wrap and Unwrap - Pair wrapped = key.wrapKeyAsync(CEK, RsaOaep.AlgorithmName).get(); + Pair wrapped = key.wrapKeyAsync(CEK, RsaOaep.ALGORITHM_NAME).get(); byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); // Assert - assertEquals(RsaOaep.AlgorithmName, wrapped.getRight()); + assertEquals(RsaOaep.ALGORITHM_NAME, wrapped.getRight()); assertArrayEquals(CEK, unwrapped); // Encrypt and Decrypt - Triple encrypted = key.encryptAsync(CEK, null, null, RsaOaep.AlgorithmName).get(); + Triple encrypted = key.encryptAsync(CEK, null, null, RsaOaep.ALGORITHM_NAME).get(); byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); // Assert - assertEquals(RsaOaep.AlgorithmName, encrypted.getRight()); + assertEquals(RsaOaep.ALGORITHM_NAME, encrypted.getRight()); assertArrayEquals(CEK, decrypted); key.close(); @@ -104,16 +104,16 @@ public void testDefaultAlgorithm() throws Exception { RsaKey key = getTestRsaKey(); - assertEquals(RsaOaep.AlgorithmName, key.getDefaultEncryptionAlgorithm()); - assertEquals(RsaOaep.AlgorithmName, key.getDefaultKeyWrapAlgorithm()); - assertEquals(Rs256.AlgorithmName, key.getDefaultSignatureAlgorithm()); + assertEquals(RsaOaep.ALGORITHM_NAME, key.getDefaultEncryptionAlgorithm()); + assertEquals(RsaOaep.ALGORITHM_NAME, key.getDefaultKeyWrapAlgorithm()); + assertEquals(Rs256.ALGORITHM_NAME, key.getDefaultSignatureAlgorithm()); // Wrap and Unwrap Pair wrapped = key.wrapKeyAsync(CEK, key.getDefaultKeyWrapAlgorithm()).get(); byte[] unwrapped = key.unwrapKeyAsync(wrapped.getLeft(), wrapped.getRight()).get(); // Assert - assertEquals(RsaOaep.AlgorithmName, wrapped.getRight()); + assertEquals(RsaOaep.ALGORITHM_NAME, wrapped.getRight()); assertArrayEquals(CEK, unwrapped); // Encrypt and Decrypt @@ -121,7 +121,7 @@ public void testDefaultAlgorithm() throws Exception { byte[] decrypted = key.decryptAsync(encrypted.getLeft(), null, null, null, encrypted.getRight()).get(); // Assert - assertEquals(RsaOaep.AlgorithmName, encrypted.getRight()); + assertEquals(RsaOaep.ALGORITHM_NAME, encrypted.getRight()); assertArrayEquals(CEK, decrypted); key.close(); From 28ed4e8c99a06c6a911b15991928bcbca5c24cd5 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Tue, 13 Sep 2016 22:34:23 -0700 Subject: [PATCH 34/56] Removing the ServiceResponse<> off return type and remove with*() for readonly objects. --- .../KeyVaultKeyResolverBCProviderTest.java | 10 +- ...eyVaultKeyResolverDefaultProviderTest.java | 8 +- .../azure/keyvault/KeyVaultClient.java | 258 +- .../azure/keyvault/KeyVaultClientImpl.java | 2066 +++++++++++++---- .../azure/keyvault/models/KeyBundle.java | 11 - .../azure/keyvault/models/KeyItem.java | 11 - .../azure/keyvault/models/SecretBundle.java | 22 - .../azure/keyvault/models/SecretItem.java | 11 - .../test/CertificateOperationsTest.java | 86 +- .../keyvault/test/KeyOperationsTest.java | 70 +- .../keyvault/test/SecretOperationsTest.java | 30 +- 11 files changed, 1864 insertions(+), 719 deletions(-) diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java index f7f16bb09ca29..813b4c3ee5ad6 100755 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverBCProviderTest.java @@ -39,7 +39,6 @@ import com.microsoft.azure.keyvault.requests.CreateKeyRequest; import com.microsoft.azure.keyvault.requests.SetSecretRequest; import com.microsoft.azure.keyvault.webkey.JsonWebKeyType; -import com.microsoft.rest.ServiceResponse; public class KeyVaultKeyResolverBCProviderTest extends KeyVaultClientIntegrationTestBase { @@ -81,8 +80,7 @@ public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, Exec try { // Create a key on a vault. CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build(); - ServiceResponse response = keyVaultClient.createKey(request); - KeyBundle bundle = response != null ? response.getBody() : null; + KeyBundle bundle = keyVaultClient.createKey(request); if ( bundle != null ) { @@ -126,7 +124,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret128Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ); if ( secretBundle != null ) { @@ -186,7 +184,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret192Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ); if ( secretBundle != null ) { @@ -246,7 +244,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret256Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ); if ( secretBundle != null ) { diff --git a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java index 63708e2b6a085..62777c9b26103 100755 --- a/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java +++ b/azure-keyvault-extensions/src/test/java/com/microsoft/azure/keyvault/extensions/test/KeyVaultKeyResolverDefaultProviderTest.java @@ -81,7 +81,7 @@ public void KeyVault_KeyVaultKeyResolver_Key() throws InterruptedException, Exec try { // Create a key on a vault. CreateKeyRequest request = new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build(); - KeyBundle keyBundle = keyVaultClient.createKey(request).getBody(); + KeyBundle keyBundle = keyVaultClient.createKey(request); try { @@ -116,7 +116,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret128Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret(request).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret(request); if ( secretBundle != null ) { @@ -176,7 +176,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret192Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ); if ( secretBundle != null ) { @@ -249,7 +249,7 @@ public void KeyVault_KeyVaultKeyResolver_Secret256Base64() throws InterruptedExc try { SetSecretRequest request = new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, _base64.encodeAsString(keyBytes)).withContentType("application/octet-stream").build(); - SecretBundle secretBundle = keyVaultClient.setSecret( request ).getBody(); + SecretBundle secretBundle = keyVaultClient.setSecret( request ); if ( secretBundle != null ) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 95a998e02c63b..c49e98428ee1c 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -192,9 +192,9 @@ interface KeyVaultClientService { * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse createKey(CreateKeyRequest createKeyRequest) + public KeyBundle createKey(CreateKeyRequest createKeyRequest) throws KeyVaultErrorException, IllegalArgumentException, IOException { return innerKeyVaultClient.createKey( createKeyRequest.vaultBaseUrl(), @@ -234,9 +234,9 @@ public ServiceCall createKeyAsync(CreateKeyRequest createKeyRequest, * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse importKey(ImportKeyRequest importKeyRequest) + public KeyBundle importKey(ImportKeyRequest importKeyRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.importKey( importKeyRequest.vaultBaseUrl(), @@ -274,9 +274,9 @@ public ServiceCall importKeyAsync(ImportKeyRequest importKeyRequest, * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) + public KeyBundle deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteKey(vaultBaseUrl, keyName); } @@ -301,9 +301,9 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse updateKey(UpdateKeyRequest updateKeyRequest) + public KeyBundle updateKey(UpdateKeyRequest updateKeyRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateKey( updateKeyRequest.vaultBaseUrl(), @@ -340,9 +340,9 @@ public ServiceCall updateKeyAsync(UpdateKeyRequest updateKeyRequest, * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse getKey(String keyIdentifier) + public KeyBundle getKey(String keyIdentifier) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.getKey(id.vault, id.name, id.version == null ? "" : id.version); @@ -368,9 +368,9 @@ public ServiceCall getKeyAsync(String keyIdentifier, final ServiceCal * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse getKey(String vaultBaseUrl, String keyName) + public KeyBundle getKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, ""); } @@ -396,9 +396,9 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, f * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) + public KeyBundle getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, keyVersion); } @@ -424,9 +424,9 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> if successful. */ - public ServiceResponse> listKeyVersions(final String vaultBaseUrl, final String keyName) + public PagedList listKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName); } @@ -447,13 +447,13 @@ public ServiceCall> listKeyVersionsAsync(final String vaultBaseUrl * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> if successful. */ - public ServiceResponse> listKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) + public PagedList listKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName, maxresults); } @@ -463,7 +463,7 @@ public ServiceResponse> listKeyVersions(final String vaultBas * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -478,9 +478,9 @@ public ServiceCall> listKeyVersionsAsync(final String vaultBaseUrl * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> if successful. */ - public ServiceResponse> listKeys(final String vaultBaseUrl) + public PagedList listKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeys(vaultBaseUrl); } @@ -499,13 +499,13 @@ public ServiceCall> listKeysAsync(final String vaultBaseUrl, final * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> if successful. */ - public ServiceResponse> listKeys(final String vaultBaseUrl, final Integer maxresults) + public PagedList listKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getKeys(vaultBaseUrl, maxresults); } @@ -514,7 +514,7 @@ public ServiceResponse> listKeys(final String vaultBaseUrl, f * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -530,9 +530,9 @@ public ServiceCall> listKeysAsync(final String vaultBaseUrl, final * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the BackupKeyResult object wrapped in {@link ServiceResponse} if successful. + * @return the BackupKeyResult if successful. */ - public ServiceResponse backupKey(String vaultBaseUrl, String keyName) + public BackupKeyResult backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.backupKey(vaultBaseUrl, keyName); } @@ -557,9 +557,9 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String k * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle if successful. */ - public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) + public KeyBundle restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.restoreKey(vaultBaseUrl, keyBundleBackup); } @@ -585,9 +585,9 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult if successful. */ - public ServiceResponse encrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) + public KeyOperationResult encrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -616,9 +616,9 @@ public ServiceCall encryptAsync(String keyIdentifier, JsonWe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult if successful. */ - public ServiceResponse decrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) + public KeyOperationResult decrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -647,9 +647,9 @@ public ServiceCall decryptAsync(String keyIdentifier, JsonWe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult if successful. */ - public ServiceResponse sign(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value) + public KeyOperationResult sign(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.sign(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -679,9 +679,9 @@ public ServiceCall signAsync(String keyIdentifier, JsonWebKe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyVerifyResult if successful. */ - public ServiceResponse verify(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) + public KeyVerifyResult verify(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verify(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature); @@ -711,9 +711,9 @@ public ServiceCall verifyAsync(String keyIdentifier, JsonWebKey * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult if successful. */ - public ServiceResponse wrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) + public KeyOperationResult wrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -742,9 +742,9 @@ public ServiceCall wrapKeyAsync(String keyIdentifier, JsonWe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult if successful. */ - public ServiceResponse unwrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) + public KeyOperationResult unwrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); @@ -772,9 +772,9 @@ public ServiceCall unwrapKeyAsync(String keyIdentifier, Json * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle if successful. */ - public ServiceResponse setSecret(SetSecretRequest setSecretRequest) + public SecretBundle setSecret(SetSecretRequest setSecretRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setSecret( setSecretRequest.vaultBaseUrl(), @@ -812,9 +812,9 @@ public ServiceCall setSecretAsync(SetSecretRequest setSecretReques * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle if successful. */ - public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) + public SecretBundle deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteSecret(vaultBaseUrl, secretName); } @@ -839,9 +839,9 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String s * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle if successful. */ - public ServiceResponse updateSecret(UpdateSecretRequest updateSecretRequest) + public SecretBundle updateSecret(UpdateSecretRequest updateSecretRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateSecret( updateSecretRequest.vaultBaseUrl(), @@ -878,9 +878,9 @@ public ServiceCall updateSecretAsync(UpdateSecretRequest updateSec * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle if successful. */ - public ServiceResponse getSecret(String secretIdentifier) + public SecretBundle getSecret(String secretIdentifier) throws KeyVaultErrorException, IOException, IllegalArgumentException { SecretIdentifier id = new SecretIdentifier(secretIdentifier); return innerKeyVaultClient.getSecret(id.vault, id.name, id.version == null ? "" : id.version); @@ -906,9 +906,9 @@ public ServiceCall getSecretAsync(String secretIdentifier, final S * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle if successful. */ - public ServiceResponse getSecret(String vaultBaseUrl, String secretName) + public SecretBundle getSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, ""); } @@ -934,9 +934,9 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle if successful. */ - public ServiceResponse getSecret(String vaultBaseUrl, String secretName, String secretVersion) + public SecretBundle getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, secretVersion == null ? "" : secretVersion); } @@ -961,9 +961,9 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> if successful. */ - public ServiceResponse> listSecrets(final String vaultBaseUrl) + public PagedList listSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecrets(vaultBaseUrl); } @@ -982,13 +982,13 @@ public ServiceCall> listSecretsAsync(final String vaultBaseUrl, * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of secrets to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> if successful. */ - public ServiceResponse> listSecrets(final String vaultBaseUrl, final Integer maxresults) + public PagedList listSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecrets(vaultBaseUrl, maxresults); } @@ -997,7 +997,7 @@ public ServiceResponse> listSecrets(final String vaultBase * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of secrets to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1013,9 +1013,9 @@ public ServiceCall> listSecretsAsync(final String vaultBaseUrl, * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> if successful. */ - public ServiceResponse> listSecretVersions(final String vaultBaseUrl, final String secretName) + public PagedList listSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName); } @@ -1036,13 +1036,13 @@ public ServiceCall> listSecretVersionsAsync(final String vaultB * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> if successful. */ - public ServiceResponse> listSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) + public PagedList listSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName, maxresults); } @@ -1052,7 +1052,7 @@ public ServiceResponse> listSecretVersions(final String va * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1067,9 +1067,9 @@ public ServiceCall> listSecretVersionsAsync(final String vaultB * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> if successful. */ - public ServiceResponse> listCertificates(final String vaultBaseUrl) + public PagedList listCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificates(vaultBaseUrl); } @@ -1088,13 +1088,13 @@ public ServiceCall> listCertificatesAsync(final String vau * List certificates in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> if successful. */ - public ServiceResponse> listCertificates(final String vaultBaseUrl, final Integer maxresults) + public PagedList listCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificates(vaultBaseUrl, maxresults); } @@ -1103,7 +1103,7 @@ public ServiceResponse> listCertificates(final String * List certificates in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1119,9 +1119,9 @@ public ServiceCall> listCertificatesAsync(final String vau * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) + public CertificateBundle deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificate(vaultBaseUrl, certificateName); } @@ -1146,9 +1146,9 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the Contacts object wrapped in {@link ServiceResponse} if successful. + * @return the Contacts if successful. */ - public ServiceResponse setCertificateContacts(String vaultBaseUrl, Contacts contacts) + public Contacts setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setCertificateContacts(vaultBaseUrl, contacts); } @@ -1172,9 +1172,9 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Co * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the Contacts object wrapped in {@link ServiceResponse} if successful. + * @return the Contacts if successful. */ - public ServiceResponse getCertificateContacts(String vaultBaseUrl) + public Contacts getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateContacts(vaultBaseUrl); } @@ -1197,9 +1197,9 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, fi * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the Contacts object wrapped in {@link ServiceResponse} if successful. + * @return the Contacts if successful. */ - public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) + public Contacts deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificateContacts(vaultBaseUrl); } @@ -1222,9 +1222,9 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateIssuerItem> if successful. */ - public ServiceResponse> listCertificateIssuers(final String vaultBaseUrl) + public PagedList listCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl); } @@ -1243,13 +1243,13 @@ public ServiceCall> listCertificateIssuersAsync(fina * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateIssuerItem> if successful. */ - public ServiceResponse> listCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) + public PagedList listCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl, maxresults); } @@ -1258,7 +1258,7 @@ public ServiceResponse> listCertificateIssuers( * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1274,9 +1274,9 @@ public ServiceCall> listCertificateIssuersAsync(fina * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle if successful. */ - public ServiceResponse setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest) + public IssuerBundle setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.setCertificateIssuer( setCertificateIssuerRequest.vaultBaseUrl(), @@ -1314,9 +1314,9 @@ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerR * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle if successful. */ - public ServiceResponse updateCertificateIssuer(UpdateCertificateIssuerRequest updateCertificateIssuerRequest) + public IssuerBundle updateCertificateIssuer(UpdateCertificateIssuerRequest updateCertificateIssuerRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificateIssuer( updateCertificateIssuerRequest.vaultBaseUrl(), @@ -1355,9 +1355,9 @@ public ServiceCall updateCertificateIssuerAsync(UpdateCertificateI * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle if successful. */ - public ServiceResponse getCertificateIssuer(String vaultBaseUrl, String issuerName) + public IssuerBundle getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateIssuer(vaultBaseUrl, issuerName); } @@ -1382,9 +1382,9 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle if successful. */ - public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl, String issuerName) + public IssuerBundle deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificateIssuer(vaultBaseUrl, issuerName); } @@ -1409,9 +1409,9 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUr * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation if successful. */ - public ServiceResponse createCertificate(CreateCertificateRequest createCertificateRequest) + public CertificateOperation createCertificate(CreateCertificateRequest createCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.createCertificate( createCertificateRequest.vaultBaseUrl(), @@ -1447,9 +1447,9 @@ public ServiceCall createCertificateAsync(CreateCertificat * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse importCertificate(ImportCertificateRequest importCertificateRequest) + public CertificateBundle importCertificate(ImportCertificateRequest importCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.importCertificate( importCertificateRequest.vaultBaseUrl(), @@ -1489,9 +1489,9 @@ public ServiceCall importCertificateAsync(ImportCertificateRe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> if successful. */ - public ServiceResponse> listCertificateVersions(final String vaultBaseUrl, final String certificateName) + public PagedList listCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName); } @@ -1512,13 +1512,13 @@ public ServiceCall> listCertificateVersionsAsync(final Str * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> if successful. */ - public ServiceResponse> listCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) + public PagedList listCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName, maxresults); } @@ -1528,7 +1528,7 @@ public ServiceResponse> listCertificateVersions(final * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1544,9 +1544,9 @@ public ServiceCall> listCertificateVersionsAsync(final Str * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. + * @return the CertificatePolicy if successful. */ - public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) + public CertificatePolicy getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificatePolicy(vaultBaseUrl, certificateName); } @@ -1571,9 +1571,9 @@ public ServiceCall getCertificatePolicyAsync(String vaultBase * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. + * @return the CertificatePolicy if successful. */ - public ServiceResponse updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest) + public CertificatePolicy updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificatePolicy( updateCertificatePolicyRequest.vaultBaseUrl(), @@ -1605,9 +1605,9 @@ public ServiceCall updateCertificatePolicyAsync(UpdateCertifi * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse updateCertificate(UpdateCertificateRequest updateCertificateRequest) + public CertificateBundle updateCertificate(UpdateCertificateRequest updateCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificate( updateCertificateRequest.vaultBaseUrl(), @@ -1644,9 +1644,9 @@ public ServiceCall updateCertificateAsync(UpdateCertificateRe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse getCertificate(String certificateIdentifier) + public CertificateBundle getCertificate(String certificateIdentifier) throws KeyVaultErrorException, IOException, IllegalArgumentException { CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); return innerKeyVaultClient.getCertificate(id.vault, id.name, id.version == null ? "" : id.version); @@ -1672,9 +1672,9 @@ public ServiceCall getCertificateAsync(String certificateIden * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName) + public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, ""); } @@ -1700,9 +1700,9 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) + public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, certificateVersion); } @@ -1728,9 +1728,9 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation if successful. */ - public ServiceResponse updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest) + public CertificateOperation updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.updateCertificateOperation( updateCertificateOperationRequest.vaultBaseUrl(), @@ -1762,9 +1762,9 @@ public ServiceCall updateCertificateOperationAsync(UpdateC * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation if successful. */ - public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) + public CertificateOperation getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.getCertificateOperation(vaultBaseUrl, certificateName); } @@ -1789,9 +1789,9 @@ public ServiceCall getCertificateOperationAsync(String vau * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation if successful. */ - public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) + public CertificateOperation deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.deleteCertificateOperation(vaultBaseUrl, certificateName); } @@ -1816,9 +1816,9 @@ public ServiceCall deleteCertificateOperationAsync(String * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle if successful. */ - public ServiceResponse mergeCertificate(MergeCertificateRequest mergeCertificateRequest) + public CertificateBundle mergeCertificate(MergeCertificateRequest mergeCertificateRequest) throws KeyVaultErrorException, IOException, IllegalArgumentException { return innerKeyVaultClient.mergeCertificate( mergeCertificateRequest.vaultBaseUrl(), @@ -1855,11 +1855,11 @@ public ServiceCall mergeCertificateAsync(MergeCertificateRequ * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the String object wrapped in {@link ServiceResponse} if successful. + * @return the String if successful. */ - public ServiceResponse getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) + public String getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getPendingCertificateSigningRequestAsync(vaultBaseUrl, certificateName).toBlocking().single(); + return getPendingCertificateSigningRequestWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); } /** @@ -1871,7 +1871,7 @@ public ServiceResponse getPendingCertificateSigningRequest(String vaultB * @return the {@link ServiceCall} object */ public ServiceCall getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getPendingCertificateSigningRequestAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.create(getPendingCertificateSigningRequestWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** @@ -1881,7 +1881,7 @@ public ServiceCall getPendingCertificateSigningRequestAsync(String vault * @param certificateName The name of the certificate * @return the observable to the String object */ - private Observable> getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName) { + private Observable> getPendingCertificateSigningRequestWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index ddeb203106bf6..bfafedeedfcc8 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -455,10 +455,10 @@ interface KeyVaultClientService { * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createKeyAsync(vaultBaseUrl, keyName, kty).toBlocking().single(); + public KeyBundle createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty).toBlocking().single().getBody(); } /** @@ -471,7 +471,7 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * @return the {@link ServiceCall} object */ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, final ServiceCallback serviceCallback) { - return ServiceCall.create(createKeyAsync(vaultBaseUrl, keyName, kty), serviceCallback); + return ServiceCall.create(createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty), serviceCallback); } /** @@ -482,7 +482,24 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @return the observable to the KeyBundle object */ - public Observable> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { + public Observable createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { + return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @return the observable to the KeyBundle object + */ + public Observable> createKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -533,10 +550,10 @@ public Observable> call(Response respon * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createKeyAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).toBlocking().single(); + public KeyBundle createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).toBlocking().single().getBody(); } /** @@ -553,7 +570,7 @@ public ServiceResponse createKey(String vaultBaseUrl, String keyName, * @return the {@link ServiceCall} object */ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(createKeyAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags), serviceCallback); + return ServiceCall.create(createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags), serviceCallback); } /** @@ -568,7 +585,28 @@ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the KeyBundle object */ - public Observable> createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { + public Observable createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { + return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Creates a new, named, key in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param keySize The key size in bytes. e.g. 1024 or 2048. + * @param keyOps the List<JsonWebKeyOperation> value + * @param keyAttributes the KeyAttributes value + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object + */ + public Observable> createKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -621,10 +659,10 @@ private ServiceResponse createKeyDelegate(Response resp * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importKeyAsync(vaultBaseUrl, keyName, key).toBlocking().single(); + public KeyBundle importKey(String vaultBaseUrl, String keyName, JsonWebKey key) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key).toBlocking().single().getBody(); } /** @@ -637,7 +675,7 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, final ServiceCallback serviceCallback) { - return ServiceCall.create(importKeyAsync(vaultBaseUrl, keyName, key), serviceCallback); + return ServiceCall.create(importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key), serviceCallback); } /** @@ -648,7 +686,24 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName * @param key The Json web key * @return the observable to the KeyBundle object */ - public Observable> importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key) { + public Observable importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key) { + return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @return the observable to the KeyBundle object + */ + public Observable> importKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKey key) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -697,10 +752,10 @@ public Observable> call(Response respon * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse importKey(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importKeyAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).toBlocking().single(); + public KeyBundle importKey(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).toBlocking().single().getBody(); } /** @@ -716,7 +771,7 @@ public ServiceResponse importKey(String vaultBaseUrl, String keyName, * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(importKeyAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags), serviceCallback); + return ServiceCall.create(importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags), serviceCallback); } /** @@ -730,7 +785,27 @@ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the KeyBundle object */ - public Observable> importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { + public Observable importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { + return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Imports a key into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param key The Json web key + * @param hsm Whether to import as a hardware key (HSM) or software key + * @param keyAttributes The key management attributes + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object + */ + public Observable> importKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -780,10 +855,10 @@ private ServiceResponse importKeyDelegate(Response resp * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteKeyAsync(vaultBaseUrl, keyName).toBlocking().single(); + public KeyBundle deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName).toBlocking().single().getBody(); } /** @@ -795,7 +870,23 @@ public ServiceResponse deleteKey(String vaultBaseUrl, String keyName) * @return the {@link ServiceCall} object */ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteKeyAsync(vaultBaseUrl, keyName), serviceCallback); + return ServiceCall.create(deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback); + } + + /** + * Deletes the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the KeyBundle object + */ + public Observable deleteKeyAsync(String vaultBaseUrl, String keyName) { + return deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -805,7 +896,7 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName * @param keyName The name of the key * @return the observable to the KeyBundle object */ - public Observable> deleteKeyAsync(String vaultBaseUrl, String keyName) { + public Observable> deleteKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -846,10 +937,10 @@ private ServiceResponse deleteKeyDelegate(Response resp * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateKeyAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single(); + public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single().getBody(); } /** @@ -862,7 +953,7 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @return the {@link ServiceCall} object */ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateKeyAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + return ServiceCall.create(updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); } /** @@ -873,7 +964,24 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName * @param keyVersion The version of the key * @return the observable to the KeyBundle object */ - public Observable> updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { + public Observable updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { + return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @return the observable to the KeyBundle object + */ + public Observable> updateKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -920,10 +1028,10 @@ public Observable> call(Response respon * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateKeyAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).toBlocking().single(); + public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).toBlocking().single().getBody(); } /** @@ -939,7 +1047,27 @@ public ServiceResponse updateKey(String vaultBaseUrl, String keyName, * @return the {@link ServiceCall} object */ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateKeyAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags), serviceCallback); + return ServiceCall.create(updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags), serviceCallback); + } + + /** + * Updates the Key Attributes associated with the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. + * @param keyAttributes the KeyAttributes value + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the KeyBundle object + */ + public Observable updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { + return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -953,7 +1081,7 @@ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the KeyBundle object */ - public Observable> updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { + public Observable> updateKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1004,10 +1132,10 @@ private ServiceResponse updateKeyDelegate(Response resp * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyBundle object wrapped in {@link ServiceResponse} if successful. + * @return the KeyBundle object if successful. */ - public ServiceResponse getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getKeyAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single(); + public KeyBundle getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single().getBody(); } /** @@ -1020,7 +1148,24 @@ public ServiceResponse getKey(String vaultBaseUrl, String keyName, St * @return the {@link ServiceCall} object */ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(getKeyAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + return ServiceCall.create(getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + } + + /** + * Retrieves the public portion of a key plus its attributes. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @return the observable to the KeyBundle object + */ + public Observable getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { + return getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -1031,7 +1176,7 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S * @param keyVersion The version of the key * @return the observable to the KeyBundle object */ - public Observable> getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { + public Observable> getKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1074,17 +1219,16 @@ private ServiceResponse getKeyDelegate(Response respons * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> object if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1112,15 +1256,35 @@ public Observable>> call(String nextPageLink) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @return the observable to the List<KeyItem> object + * @return the observable to the PagedList<KeyItem> object */ - public Observable>> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName) { + public Observable> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName) { + return getKeyVersionsWithServiceResponseAsync(vaultBaseUrl, keyName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the PagedList<KeyItem> object + */ + public Observable>> getKeyVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String keyName) { return getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getKeyVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getKeyVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -1130,7 +1294,7 @@ public Observable>> call(ServiceResponse>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName) { if (vaultBaseUrl == null) { @@ -1163,21 +1327,20 @@ public Observable>> call(Response re * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> object if successful. */ - public ServiceResponse> getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1185,7 +1348,7 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcep * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1206,16 +1369,37 @@ public Observable>> call(String nextPageLink) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @param maxresults Maximum number of results to return. - * @return the observable to the List<KeyItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<KeyItem> object */ - public Observable>> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { + public Observable> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { + return getKeyVersionsWithServiceResponseAsync(vaultBaseUrl, keyName, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<KeyItem> object + */ + public Observable>> getKeyVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { return getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getKeyVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getKeyVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -1225,8 +1409,8 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net ServiceResponse> * @param keyName The name of the key - ServiceResponse> * @param maxresults Maximum number of results to return. - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -1267,17 +1451,16 @@ private ServiceResponse> getKeyVersionsDelegate(Response> getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -1303,15 +1486,34 @@ public Observable>> call(String nextPageLink) { * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the List<KeyItem> object + * @return the observable to the PagedList<KeyItem> object */ - public Observable>> getKeysAsync(final String vaultBaseUrl) { + public Observable> getKeysAsync(final String vaultBaseUrl) { + return getKeysWithServiceResponseAsync(vaultBaseUrl) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the PagedList<KeyItem> object + */ + public Observable>> getKeysWithServiceResponseAsync(final String vaultBaseUrl) { return getKeysSinglePageAsync(vaultBaseUrl) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getKeysNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getKeysNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -1320,7 +1522,7 @@ public Observable>> call(ServiceResponse>> getKeysSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { @@ -1349,28 +1551,27 @@ public Observable>> call(Response re * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> object if successful. */ - public ServiceResponse> getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -1390,16 +1591,36 @@ public Observable>> call(String nextPageLink) { * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. - * @return the observable to the List<KeyItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<KeyItem> object + */ + public Observable> getKeysAsync(final String vaultBaseUrl, final Integer maxresults) { + return getKeysWithServiceResponseAsync(vaultBaseUrl, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List keys in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<KeyItem> object */ - public Observable>> getKeysAsync(final String vaultBaseUrl, final Integer maxresults) { + public Observable>> getKeysWithServiceResponseAsync(final String vaultBaseUrl, final Integer maxresults) { return getKeysSinglePageAsync(vaultBaseUrl, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getKeysNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getKeysNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -1408,8 +1629,8 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - ServiceResponse> * @param maxresults Maximum number of results to return. - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getKeysSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -1448,10 +1669,10 @@ private ServiceResponse> getKeysDelegate(Response backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return backupKeyAsync(vaultBaseUrl, keyName).toBlocking().single(); + public BackupKeyResult backupKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return backupKeyWithServiceResponseAsync(vaultBaseUrl, keyName).toBlocking().single().getBody(); } /** @@ -1463,7 +1684,7 @@ public ServiceResponse backupKey(String vaultBaseUrl, String ke * @return the {@link ServiceCall} object */ public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return ServiceCall.create(backupKeyAsync(vaultBaseUrl, keyName), serviceCallback); + return ServiceCall.create(backupKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback); } /** @@ -1473,7 +1694,23 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String k * @param keyName The name of the key * @return the observable to the BackupKeyResult object */ - public Observable> backupKeyAsync(String vaultBaseUrl, String keyName) { + public Observable backupKeyAsync(String vaultBaseUrl, String keyName) { + return backupKeyWithServiceResponseAsync(vaultBaseUrl, keyName).map(new Func1, BackupKeyResult>() { + @Override + public BackupKeyResult call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Requests that a backup of the specified key be downloaded to the client. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @return the observable to the BackupKeyResult object + */ + public Observable> backupKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1513,10 +1750,10 @@ private ServiceResponse backupKeyDelegate(Response restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return restoreKeyAsync(vaultBaseUrl, keyBundleBackup).toBlocking().single(); + public KeyBundle restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup).toBlocking().single().getBody(); } /** @@ -1528,7 +1765,7 @@ public ServiceResponse restoreKey(String vaultBaseUrl, byte[] keyBund * @return the {@link ServiceCall} object */ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { - return ServiceCall.create(restoreKeyAsync(vaultBaseUrl, keyBundleBackup), serviceCallback); + return ServiceCall.create(restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup), serviceCallback); } /** @@ -1538,7 +1775,23 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun * @param keyBundleBackup the backup blob associated with a key bundle * @return the observable to the KeyBundle object */ - public Observable> restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup) { + public Observable restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup) { + return restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup).map(new Func1, KeyBundle>() { + @Override + public KeyBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Restores the backup key in to a vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyBundleBackup the backup blob associated with a key bundle + * @return the observable to the KeyBundle object + */ + public Observable> restoreKeyWithServiceResponseAsync(String vaultBaseUrl, byte[] keyBundleBackup) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1583,10 +1836,10 @@ private ServiceResponse restoreKeyDelegate(Response res * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult object if successful. */ - public ServiceResponse encrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return encryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public KeyOperationResult encrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); } /** @@ -1601,7 +1854,26 @@ public ServiceResponse encrypt(String vaultBaseUrl, String k * @return the {@link ServiceCall} object */ public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(encryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.create(encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + } + + /** + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + return encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { + @Override + public KeyOperationResult call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -1614,7 +1886,7 @@ public ServiceCall encryptAsync(String vaultBaseUrl, String * @param value the Base64Url value * @return the observable to the KeyOperationResult object */ - public Observable> encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + public Observable> encryptWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1669,10 +1941,10 @@ private ServiceResponse encryptDelegate(Response decrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return decryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public KeyOperationResult decrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return decryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); } /** @@ -1687,7 +1959,7 @@ public ServiceResponse decrypt(String vaultBaseUrl, String k * @return the {@link ServiceCall} object */ public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(decryptAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.create(decryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -1700,7 +1972,26 @@ public ServiceCall decryptAsync(String vaultBaseUrl, String * @param value the Base64Url value * @return the observable to the KeyOperationResult object */ - public Observable> decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + public Observable decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + return decryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { + @Override + public KeyOperationResult call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Decrypts a single block of encrypted data. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> decryptWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1755,10 +2046,10 @@ private ServiceResponse decryptDelegate(Response sign(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return signAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public KeyOperationResult sign(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); } /** @@ -1773,7 +2064,7 @@ public ServiceResponse sign(String vaultBaseUrl, String keyN * @return the {@link ServiceCall} object */ public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(signAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.create(signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -1786,7 +2077,26 @@ public ServiceCall signAsync(String vaultBaseUrl, String key * @param value the Base64Url value * @return the observable to the KeyOperationResult object */ - public Observable> signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { + public Observable signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { + return signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { + @Override + public KeyOperationResult call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Creates a signature from a digest using the specified key in the vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> signWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1842,10 +2152,10 @@ private ServiceResponse signDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyVerifyResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyVerifyResult object if successful. */ - public ServiceResponse verify(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return verifyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).toBlocking().single(); + public KeyVerifyResult verify(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).toBlocking().single().getBody(); } /** @@ -1861,7 +2171,27 @@ public ServiceResponse verify(String vaultBaseUrl, String keyNa * @return the {@link ServiceCall} object */ public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { - return ServiceCall.create(verifyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature), serviceCallback); + return ServiceCall.create(verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature), serviceCallback); + } + + /** + * Verifies a signature using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' + * @param digest The digest used for signing + * @param signature The signature to be verified + * @return the observable to the KeyVerifyResult object + */ + public Observable verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { + return verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).map(new Func1, KeyVerifyResult>() { + @Override + public KeyVerifyResult call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -1875,7 +2205,7 @@ public ServiceCall verifyAsync(String vaultBaseUrl, String keyN * @param signature The signature to be verified * @return the observable to the KeyVerifyResult object */ - public Observable> verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { + public Observable> verifyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -1934,10 +2264,10 @@ private ServiceResponse verifyDelegate(Response r * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the KeyOperationResult object wrapped in {@link ServiceResponse} if successful. + * @return the KeyOperationResult object if successful. */ - public ServiceResponse wrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return wrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public KeyOperationResult wrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); } /** @@ -1952,7 +2282,7 @@ public ServiceResponse wrapKey(String vaultBaseUrl, String k * @return the {@link ServiceCall} object */ public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(wrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.create(wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -1965,7 +2295,26 @@ public ServiceCall wrapKeyAsync(String vaultBaseUrl, String * @param value the Base64Url value * @return the observable to the KeyOperationResult object */ - public Observable> wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + public Observable wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + return wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { + @Override + public KeyOperationResult call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Wraps a symmetric key using the specified key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> wrapKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2020,10 +2369,10 @@ private ServiceResponse wrapKeyDelegate(Response unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return unwrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single(); + public KeyOperationResult unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); } /** @@ -2038,7 +2387,7 @@ public ServiceResponse unwrapKey(String vaultBaseUrl, String * @return the {@link ServiceCall} object */ public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(unwrapKeyAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.create(unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -2051,7 +2400,26 @@ public ServiceCall unwrapKeyAsync(String vaultBaseUrl, Strin * @param value the Base64Url value * @return the observable to the KeyOperationResult object */ - public Observable> unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + public Observable unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + return unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { + @Override + public KeyOperationResult call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param keyName The name of the key + * @param keyVersion The version of the key + * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' + * @param value the Base64Url value + * @return the observable to the KeyOperationResult object + */ + public Observable> unwrapKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2104,10 +2472,10 @@ private ServiceResponse unwrapKeyDelegate(Response setSecret(String vaultBaseUrl, String secretName, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setSecretAsync(vaultBaseUrl, secretName, value).toBlocking().single(); + public SecretBundle setSecret(String vaultBaseUrl, String secretName, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value).toBlocking().single().getBody(); } /** @@ -2120,7 +2488,7 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) { - return ServiceCall.create(setSecretAsync(vaultBaseUrl, secretName, value), serviceCallback); + return ServiceCall.create(setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value), serviceCallback); } /** @@ -2131,7 +2499,24 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secr * @param value The value of the secret * @return the observable to the SecretBundle object */ - public Observable> setSecretAsync(String vaultBaseUrl, String secretName, String value) { + public Observable setSecretAsync(String vaultBaseUrl, String secretName, String value) { + return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value).map(new Func1, SecretBundle>() { + @Override + public SecretBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @return the observable to the SecretBundle object + */ + public Observable> setSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String value) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2179,10 +2564,10 @@ public Observable> call(Response res * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle object if successful. */ - public ServiceResponse setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setSecretAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).toBlocking().single(); + public SecretBundle setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).toBlocking().single().getBody(); } /** @@ -2198,7 +2583,27 @@ public ServiceResponse setSecret(String vaultBaseUrl, String secre * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes, final ServiceCallback serviceCallback) { - return ServiceCall.create(setSecretAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes), serviceCallback); + return ServiceCall.create(setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes), serviceCallback); + } + + /** + * Sets a secret in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param value The value of the secret + * @param tags Application-specific metadata in the form of key-value pairs + * @param contentType Type of the secret value such as a password + * @param secretAttributes The secret management attributes + * @return the observable to the SecretBundle object + */ + public Observable setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { + return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).map(new Func1, SecretBundle>() { + @Override + public SecretBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -2212,7 +2617,7 @@ public ServiceCall setSecretAsync(String vaultBaseUrl, String secr * @param secretAttributes The secret management attributes * @return the observable to the SecretBundle object */ - public Observable> setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { + public Observable> setSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2262,10 +2667,10 @@ private ServiceResponse setSecretDelegate(Response r * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle object if successful. */ - public ServiceResponse deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteSecretAsync(vaultBaseUrl, secretName).toBlocking().single(); + public SecretBundle deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName).toBlocking().single().getBody(); } /** @@ -2277,7 +2682,23 @@ public ServiceResponse deleteSecret(String vaultBaseUrl, String se * @return the {@link ServiceCall} object */ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteSecretAsync(vaultBaseUrl, secretName), serviceCallback); + return ServiceCall.create(deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName), serviceCallback); + } + + /** + * Deletes a secret from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the observable to the SecretBundle object + */ + public Observable deleteSecretAsync(String vaultBaseUrl, String secretName) { + return deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName).map(new Func1, SecretBundle>() { + @Override + public SecretBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -2287,7 +2708,7 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String s * @param secretName The name of the secret in the given vault * @return the observable to the SecretBundle object */ - public Observable> deleteSecretAsync(String vaultBaseUrl, String secretName) { + public Observable> deleteSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2328,10 +2749,10 @@ private ServiceResponse deleteSecretDelegate(Response updateSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateSecretAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single(); + public SecretBundle updateSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single().getBody(); } /** @@ -2344,7 +2765,7 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateSecretAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + return ServiceCall.create(updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); } /** @@ -2355,7 +2776,24 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String s * @param secretVersion The version of the secret * @return the observable to the SecretBundle object */ - public Observable> updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { + public Observable updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { + return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).map(new Func1, SecretBundle>() { + @Override + public SecretBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @return the observable to the SecretBundle object + */ + public Observable> updateSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String secretVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2402,10 +2840,10 @@ public Observable> call(Response res * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the SecretBundle object wrapped in {@link ServiceResponse} if successful. + * @return the SecretBundle object if successful. */ - public ServiceResponse updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateSecretAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).toBlocking().single(); + public SecretBundle updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).toBlocking().single().getBody(); } /** @@ -2421,7 +2859,27 @@ public ServiceResponse updateSecret(String vaultBaseUrl, String se * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateSecretAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags), serviceCallback); + return ServiceCall.create(updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags), serviceCallback); + } + + /** + * Updates the attributes associated with the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @param contentType Type of the secret value such as a password + * @param secretAttributes The secret management attributes + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the SecretBundle object + */ + public Observable updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { + return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).map(new Func1, SecretBundle>() { + @Override + public SecretBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -2435,7 +2893,7 @@ public ServiceCall updateSecretAsync(String vaultBaseUrl, String s * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the SecretBundle object */ - public Observable> updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { + public Observable> updateSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2485,10 +2943,23 @@ private ServiceResponse updateSecretDelegate(Response getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getSecretAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single(); + public SecretBundle getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single().getBody(); + } + + /** + * Gets a secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param secretVersion The version of the secret + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { + return ServiceCall.create(getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); } /** @@ -2497,11 +2968,15 @@ public ServiceResponse getSecret(String vaultBaseUrl, String secre * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the observable to the SecretBundle object */ - public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(getSecretAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + public Observable getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { + return getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).map(new Func1, SecretBundle>() { + @Override + public SecretBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -2512,7 +2987,7 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * @param secretVersion The version of the secret * @return the observable to the SecretBundle object */ - public Observable> getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { + public Observable> getSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String secretVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -2554,17 +3029,16 @@ private ServiceResponse getSecretDelegate(Response r * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> object if successful. */ - public ServiceResponse> getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -2590,15 +3064,34 @@ public Observable>> call(String nextPageLink) { * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the List<SecretItem> object + * @return the observable to the PagedList<SecretItem> object + */ + public Observable> getSecretsAsync(final String vaultBaseUrl) { + return getSecretsWithServiceResponseAsync(vaultBaseUrl) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the PagedList<SecretItem> object */ - public Observable>> getSecretsAsync(final String vaultBaseUrl) { + public Observable>> getSecretsWithServiceResponseAsync(final String vaultBaseUrl) { return getSecretsSinglePageAsync(vaultBaseUrl) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getSecretsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getSecretsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -2607,7 +3100,7 @@ public Observable>> call(ServiceResponse>> getSecretsSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { @@ -2636,28 +3129,27 @@ public Observable>> call(Response * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of secrets to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> object if successful. */ - public ServiceResponse> getSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of secrets to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -2677,16 +3169,36 @@ public Observable>> call(String nextPageLink) { * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of secrets to return. - * @return the observable to the List<SecretItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<SecretItem> object + */ + public Observable> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults) { + return getSecretsWithServiceResponseAsync(vaultBaseUrl, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List secrets in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<SecretItem> object */ - public Observable>> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults) { + public Observable>> getSecretsWithServiceResponseAsync(final String vaultBaseUrl, final Integer maxresults) { return getSecretsSinglePageAsync(vaultBaseUrl, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getSecretsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getSecretsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -2695,8 +3207,8 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - ServiceResponse> * @param maxresults Maximum number of secrets to return. - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getSecretsSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -2735,17 +3247,16 @@ private ServiceResponse> getSecretsDelegate(Response> getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -2773,15 +3284,35 @@ public Observable>> call(String nextPageLink) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @return the observable to the List<SecretItem> object + * @return the observable to the PagedList<SecretItem> object + */ + public Observable> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName) { + return getSecretVersionsWithServiceResponseAsync(vaultBaseUrl, secretName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @return the observable to the PagedList<SecretItem> object */ - public Observable>> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName) { + public Observable>> getSecretVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String secretName) { return getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getSecretVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getSecretVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -2791,7 +3322,7 @@ public Observable>> call(ServiceResponse>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName) { if (vaultBaseUrl == null) { @@ -2824,21 +3355,20 @@ public Observable>> call(Response * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> object if successful. */ - public ServiceResponse> getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -2846,7 +3376,7 @@ public Page nextPage(String nextPageLink) throws RestException, IOEx * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -2867,16 +3397,37 @@ public Observable>> call(String nextPageLink) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @param maxresults Maximum number of results to return. - * @return the observable to the List<SecretItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<SecretItem> object + */ + public Observable> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { + return getSecretVersionsWithServiceResponseAsync(vaultBaseUrl, secretName, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of the specified secret. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param secretName The name of the secret in the given vault + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<SecretItem> object */ - public Observable>> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { + public Observable>> getSecretVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { return getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getSecretVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getSecretVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -2886,8 +3437,8 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net ServiceResponse> * @param secretName The name of the secret in the given vault - ServiceResponse> * @param maxresults Maximum number of results to return. - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -2928,17 +3479,16 @@ private ServiceResponse> getSecretVersionsDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> object if successful. */ - public ServiceResponse> getCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -2964,15 +3514,34 @@ public Observable>> call(String nextPageLi * List certificates in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the List<CertificateItem> object + * @return the observable to the PagedList<CertificateItem> object + */ + public Observable> getCertificatesAsync(final String vaultBaseUrl) { + return getCertificatesWithServiceResponseAsync(vaultBaseUrl) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the PagedList<CertificateItem> object */ - public Observable>> getCertificatesAsync(final String vaultBaseUrl) { + public Observable>> getCertificatesWithServiceResponseAsync(final String vaultBaseUrl) { return getCertificatesSinglePageAsync(vaultBaseUrl) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificatesNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificatesNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -2981,7 +3550,7 @@ public Observable>> call(ServiceResponse

>> getCertificatesSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { @@ -3010,28 +3579,27 @@ public Observable>> call(Response> getCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** * List certificates in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -3051,16 +3619,36 @@ public Observable>> call(String nextPageLi * List certificates in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. - * @return the observable to the List<CertificateItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<CertificateItem> object + */ + public Observable> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults) { + return getCertificatesWithServiceResponseAsync(vaultBaseUrl, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List certificates in the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<CertificateItem> object */ - public Observable>> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults) { + public Observable>> getCertificatesWithServiceResponseAsync(final String vaultBaseUrl, final Integer maxresults) { return getCertificatesSinglePageAsync(vaultBaseUrl, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificatesNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificatesNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -3069,8 +3657,8 @@ public Observable>> call(ServiceResponse

> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - ServiceResponse> * @param maxresults Maximum number of results to return. - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificatesSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -3109,10 +3697,10 @@ private ServiceResponse> getCertificatesDelegate(Respo * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object if successful. */ - public ServiceResponse deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateAsync(vaultBaseUrl, certificateName).toBlocking().single(); + public CertificateBundle deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); } /** @@ -3124,7 +3712,7 @@ public ServiceResponse deleteCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.create(deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** @@ -3134,7 +3722,23 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl * @param certificateName The name of the certificate in the given vault * @return the observable to the CertificateBundle object */ - public Observable> deleteCertificateAsync(String vaultBaseUrl, String certificateName) { + public Observable deleteCertificateAsync(String vaultBaseUrl, String certificateName) { + return deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes a certificate from the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @return the observable to the CertificateBundle object + */ + public Observable> deleteCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3174,10 +3778,10 @@ private ServiceResponse deleteCertificateDelegate(Response setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setCertificateContactsAsync(vaultBaseUrl, contacts).toBlocking().single(); + public Contacts setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts).toBlocking().single().getBody(); } /** @@ -3189,7 +3793,23 @@ public ServiceResponse setCertificateContacts(String vaultBaseUrl, Con * @return the {@link ServiceCall} object */ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { - return ServiceCall.create(setCertificateContactsAsync(vaultBaseUrl, contacts), serviceCallback); + return ServiceCall.create(setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts), serviceCallback); + } + + /** + * Sets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param contacts The contacts for the vault certificates. + * @return the observable to the Contacts object + */ + public Observable setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts) { + return setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts).map(new Func1, Contacts>() { + @Override + public Contacts call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3199,7 +3819,7 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Co * @param contacts The contacts for the vault certificates. * @return the observable to the Contacts object */ - public Observable> setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts) { + public Observable> setCertificateContactsWithServiceResponseAsync(String vaultBaseUrl, Contacts contacts) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3239,10 +3859,10 @@ private ServiceResponse setCertificateContactsDelegate(Response getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateContactsAsync(vaultBaseUrl).toBlocking().single(); + public Contacts getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getCertificateContactsWithServiceResponseAsync(vaultBaseUrl).toBlocking().single().getBody(); } /** @@ -3253,7 +3873,22 @@ public ServiceResponse getCertificateContacts(String vaultBaseUrl) thr * @return the {@link ServiceCall} object */ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateContactsAsync(vaultBaseUrl), serviceCallback); + return ServiceCall.create(getCertificateContactsWithServiceResponseAsync(vaultBaseUrl), serviceCallback); + } + + /** + * Gets the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the Contacts object + */ + public Observable getCertificateContactsAsync(String vaultBaseUrl) { + return getCertificateContactsWithServiceResponseAsync(vaultBaseUrl).map(new Func1, Contacts>() { + @Override + public Contacts call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3262,7 +3897,7 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, fi * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @return the observable to the Contacts object */ - public Observable> getCertificateContactsAsync(String vaultBaseUrl) { + public Observable> getCertificateContactsWithServiceResponseAsync(String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3298,10 +3933,10 @@ private ServiceResponse getCertificateContactsDelegate(Response deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateContactsAsync(vaultBaseUrl).toBlocking().single(); + public Contacts deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl).toBlocking().single().getBody(); } /** @@ -3312,7 +3947,7 @@ public ServiceResponse deleteCertificateContacts(String vaultBaseUrl) * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateContactsAsync(vaultBaseUrl), serviceCallback); + return ServiceCall.create(deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl), serviceCallback); } /** @@ -3321,7 +3956,22 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @return the observable to the Contacts object */ - public Observable> deleteCertificateContactsAsync(String vaultBaseUrl) { + public Observable deleteCertificateContactsAsync(String vaultBaseUrl) { + return deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl).map(new Func1, Contacts>() { + @Override + public Contacts call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes the certificate contacts for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the Contacts object + */ + public Observable> deleteCertificateContactsWithServiceResponseAsync(String vaultBaseUrl) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3357,17 +4007,16 @@ private ServiceResponse deleteCertificateContactsDelegate(Response> getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -3393,15 +4042,34 @@ public Observable>> call(String next * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the observable to the List<CertificateIssuerItem> object + * @return the observable to the PagedList<CertificateIssuerItem> object + */ + public Observable> getCertificateIssuersAsync(final String vaultBaseUrl) { + return getCertificateIssuersWithServiceResponseAsync(vaultBaseUrl) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @return the observable to the PagedList<CertificateIssuerItem> object */ - public Observable>> getCertificateIssuersAsync(final String vaultBaseUrl) { + public Observable>> getCertificateIssuersWithServiceResponseAsync(final String vaultBaseUrl) { return getCertificateIssuersSinglePageAsync(vaultBaseUrl) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateIssuersNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificateIssuersNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -3410,7 +4078,7 @@ public Observable>> call(ServiceResp * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl) { if (vaultBaseUrl == null) { @@ -3439,28 +4107,27 @@ public Observable>> call(Response> getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -3480,16 +4147,36 @@ public Observable>> call(String next * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param maxresults Maximum number of results to return. - * @return the observable to the List<CertificateIssuerItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<CertificateIssuerItem> object + */ + public Observable> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults) { + return getCertificateIssuersWithServiceResponseAsync(vaultBaseUrl, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<CertificateIssuerItem> object */ - public Observable>> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults) { + public Observable>> getCertificateIssuersWithServiceResponseAsync(final String vaultBaseUrl, final Integer maxresults) { return getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateIssuersNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificateIssuersNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -3498,8 +4185,8 @@ public Observable>> call(ServiceResp * List certificate issuers for the specified vault. * ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - ServiceResponse> * @param maxresults Maximum number of results to return. - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -3539,10 +4226,10 @@ private ServiceResponse> getCertificateIssuersDe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle object if successful. */ - public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider).toBlocking().single(); + public IssuerBundle setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider).toBlocking().single().getBody(); } /** @@ -3555,7 +4242,24 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { - return ServiceCall.create(setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider), serviceCallback); + return ServiceCall.create(setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider), serviceCallback); + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The issuer provider. + * @return the observable to the IssuerBundle object + */ + public Observable setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider) { + return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider).map(new Func1, IssuerBundle>() { + @Override + public IssuerBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3566,7 +4270,7 @@ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, * @param provider The issuer provider. * @return the observable to the IssuerBundle object */ - public Observable> setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider) { + public Observable> setCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName, String provider) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3614,10 +4318,10 @@ public Observable> call(Response res * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle object if successful. */ - public ServiceResponse setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single(); + public IssuerBundle setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single().getBody(); } /** @@ -3633,7 +4337,27 @@ public ServiceResponse setCertificateIssuer(String vaultBaseUrl, S * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { - return ServiceCall.create(setCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + return ServiceCall.create(setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + } + + /** + * Sets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The issuer provider. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @return the observable to the IssuerBundle object + */ + public Observable setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { + return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).map(new Func1, IssuerBundle>() { + @Override + public IssuerBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3647,7 +4371,7 @@ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, * @param attributes Attributes of the issuer object. * @return the observable to the IssuerBundle object */ - public Observable> setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { + public Observable> setCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3698,10 +4422,10 @@ private ServiceResponse setCertificateIssuerDelegate(Response updateCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); + public IssuerBundle updateCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).toBlocking().single().getBody(); } /** @@ -3713,7 +4437,23 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + return ServiceCall.create(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object + */ + public Observable updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { + return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1, IssuerBundle>() { + @Override + public IssuerBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3723,7 +4463,7 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUr * @param issuerName The name of the issuer. * @return the observable to the IssuerBundle object */ - public Observable> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { + public Observable> updateCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3769,10 +4509,10 @@ public Observable> call(Response res * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the IssuerBundle object wrapped in {@link ServiceResponse} if successful. + * @return the IssuerBundle object if successful. */ - public ServiceResponse updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single(); + public IssuerBundle updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single().getBody(); } /** @@ -3788,7 +4528,27 @@ public ServiceResponse updateCertificateIssuer(String vaultBaseUrl * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateIssuerAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + return ServiceCall.create(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + } + + /** + * Updates the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @param provider The issuer provider. + * @param credentials The credentials to be used for the issuer. + * @param organizationDetails Details of the organization as provided to the issuer. + * @param attributes Attributes of the issuer object. + * @return the observable to the IssuerBundle object + */ + public Observable updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { + return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).map(new Func1, IssuerBundle>() { + @Override + public IssuerBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3802,7 +4562,7 @@ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUr * @param attributes Attributes of the issuer object. * @return the observable to the IssuerBundle object */ - public Observable> updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { + public Observable> updateCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3850,10 +4610,10 @@ private ServiceResponse updateCertificateIssuerDelegate(Response getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); + public IssuerBundle getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).toBlocking().single().getBody(); } /** @@ -3865,7 +4625,23 @@ public ServiceResponse getCertificateIssuer(String vaultBaseUrl, S * @return the {@link ServiceCall} object */ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + return ServiceCall.create(getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Gets the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object + */ + public Observable getCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { + return getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1, IssuerBundle>() { + @Override + public IssuerBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3875,7 +4651,7 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, * @param issuerName The name of the issuer. * @return the observable to the IssuerBundle object */ - public Observable> getCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { + public Observable> getCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3915,10 +4691,10 @@ private ServiceResponse getCertificateIssuerDelegate(Response deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateIssuerAsync(vaultBaseUrl, issuerName).toBlocking().single(); + public IssuerBundle deleteCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).toBlocking().single().getBody(); } /** @@ -3930,7 +4706,23 @@ public ServiceResponse deleteCertificateIssuer(String vaultBaseUrl * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateIssuerAsync(vaultBaseUrl, issuerName), serviceCallback); + return ServiceCall.create(deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); + } + + /** + * Deletes the specified certificate issuer. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param issuerName The name of the issuer. + * @return the observable to the IssuerBundle object + */ + public Observable deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { + return deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1, IssuerBundle>() { + @Override + public IssuerBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -3940,7 +4732,7 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUr * @param issuerName The name of the issuer. * @return the observable to the IssuerBundle object */ - public Observable> deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { + public Observable> deleteCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -3980,10 +4772,10 @@ private ServiceResponse deleteCertificateIssuerDelegate(Response createCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createCertificateAsync(vaultBaseUrl, certificateName).toBlocking().single(); + public CertificateOperation createCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); } /** @@ -3995,7 +4787,23 @@ public ServiceResponse createCertificate(String vaultBaseU * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(createCertificateAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.create(createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable createCertificateAsync(String vaultBaseUrl, String certificateName) { + return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificateOperation>() { + @Override + public CertificateOperation call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4005,7 +4813,7 @@ public ServiceCall createCertificateAsync(String vaultBase * @param certificateName The name of the certificate * @return the observable to the CertificateOperation object */ - public Observable> createCertificateAsync(String vaultBaseUrl, String certificateName) { + public Observable> createCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4048,10 +4856,10 @@ public Observable> call(Response createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createCertificateAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).toBlocking().single(); + public CertificateOperation createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).toBlocking().single().getBody(); } /** @@ -4066,7 +4874,26 @@ public ServiceResponse createCertificate(String vaultBaseU * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(createCertificateAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags), serviceCallback); + return ServiceCall.create(createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags), serviceCallback); + } + + /** + * Creates a new certificate version. If this is the first version, the certificate resource is created. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateOperation object + */ + public Observable createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).map(new Func1, CertificateOperation>() { + @Override + public CertificateOperation call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4079,7 +4906,7 @@ public ServiceCall createCertificateAsync(String vaultBase * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the CertificateOperation object */ - public Observable> createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + public Observable> createCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4127,10 +4954,23 @@ private ServiceResponse createCertificateDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object if successful. + */ + public CertificateBundle importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).toBlocking().single().getBody(); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object */ - public ServiceResponse importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).toBlocking().single(); + public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) { + return ServiceCall.create(importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate), serviceCallback); } /** @@ -4139,11 +4979,15 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. - * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the observable to the CertificateBundle object */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) { - return ServiceCall.create(importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate), serviceCallback); + public Observable importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { + return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4154,7 +4998,7 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @return the observable to the CertificateBundle object */ - public Observable> importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { + public Observable> importCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4205,10 +5049,10 @@ public Observable> call(Response importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).toBlocking().single(); + public CertificateBundle importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).toBlocking().single().getBody(); } /** @@ -4225,7 +5069,28 @@ public ServiceResponse importCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(importCertificateAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags), serviceCallback); + return ServiceCall.create(importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags), serviceCallback); + } + + /** + * Imports a certificate into the specified vault. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4240,7 +5105,7 @@ public ServiceCall importCertificateAsync(String vaultBaseUrl * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the CertificateBundle object */ - public Observable> importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + public Observable> importCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4292,17 +5157,16 @@ private ServiceResponse importCertificateDelegate(Response> getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -4330,15 +5194,35 @@ public Observable>> call(String nextPageLi * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @return the observable to the List<CertificateItem> object + * @return the observable to the PagedList<CertificateItem> object + */ + public Observable> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName) { + return getCertificateVersionsWithServiceResponseAsync(vaultBaseUrl, certificateName) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the PagedList<CertificateItem> object */ - public Observable>> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName) { + public Observable>> getCertificateVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String certificateName) { return getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificateVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -4348,7 +5232,7 @@ public Observable>> call(ServiceResponse

>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName) { if (vaultBaseUrl == null) { @@ -4381,21 +5265,20 @@ public Observable>> call(Response> getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -4403,7 +5286,7 @@ public Page nextPage(String nextPageLink) throws RestException, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param maxresults Maximum number of results to return. + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ @@ -4424,16 +5307,37 @@ public Observable>> call(String nextPageLi * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @param maxresults Maximum number of results to return. - * @return the observable to the List<CertificateItem> object + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<CertificateItem> object + */ + public Observable> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { + return getCertificateVersionsWithServiceResponseAsync(vaultBaseUrl, certificateName, maxresults) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the observable to the PagedList<CertificateItem> object */ - public Observable>> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { + public Observable>> getCertificateVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { return getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificateVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -4443,8 +5347,8 @@ public Observable>> call(ServiceResponse

> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net ServiceResponse> * @param certificateName The name of the certificate - ServiceResponse> * @param maxresults Maximum number of results to return. - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. + * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { if (vaultBaseUrl == null) { @@ -4486,10 +5390,10 @@ private ServiceResponse> getCertificateVersionsDelegat * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. + * @return the CertificatePolicy object if successful. */ - public ServiceResponse getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificatePolicyAsync(vaultBaseUrl, certificateName).toBlocking().single(); + public CertificatePolicy getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); } /** @@ -4501,7 +5405,23 @@ public ServiceResponse getCertificatePolicy(String vaultBaseU * @return the {@link ServiceCall} object */ public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificatePolicyAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.create(getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Gets the policy for a certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @return the observable to the CertificatePolicy object + */ + public Observable getCertificatePolicyAsync(String vaultBaseUrl, String certificateName) { + return getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificatePolicy>() { + @Override + public CertificatePolicy call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4511,7 +5431,7 @@ public ServiceCall getCertificatePolicyAsync(String vaultBase * @param certificateName The name of the certificate in the given vault. * @return the observable to the CertificatePolicy object */ - public Observable> getCertificatePolicyAsync(String vaultBaseUrl, String certificateName) { + public Observable> getCertificatePolicyWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4552,10 +5472,10 @@ private ServiceResponse getCertificatePolicyDelegate(Response * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificatePolicy object wrapped in {@link ServiceResponse} if successful. + * @return the CertificatePolicy object if successful. */ - public ServiceResponse updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificatePolicyAsync(vaultBaseUrl, certificateName, certificatePolicy).toBlocking().single(); + public CertificatePolicy updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy).toBlocking().single().getBody(); } /** @@ -4568,7 +5488,24 @@ public ServiceResponse updateCertificatePolicy(String vaultBa * @return the {@link ServiceCall} object */ public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificatePolicyAsync(vaultBaseUrl, certificateName, certificatePolicy), serviceCallback); + return ServiceCall.create(updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy), serviceCallback); + } + + /** + * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault. + * @param certificatePolicy The policy for the certificate. + * @return the observable to the CertificatePolicy object + */ + public Observable updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) { + return updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy).map(new Func1, CertificatePolicy>() { + @Override + public CertificatePolicy call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4579,7 +5516,7 @@ public ServiceCall updateCertificatePolicyAsync(String vaultB * @param certificatePolicy The policy for the certificate. * @return the observable to the CertificatePolicy object */ - public Observable> updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) { + public Observable> updateCertificatePolicyWithServiceResponseAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4624,10 +5561,10 @@ private ServiceResponse updateCertificatePolicyDelegate(Respo * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object if successful. */ - public ServiceResponse updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single(); + public CertificateBundle updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single().getBody(); } /** @@ -4640,7 +5577,24 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + return ServiceCall.create(updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @return the observable to the CertificateBundle object + */ + public Observable updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { + return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4651,7 +5605,7 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl * @param certificateVersion The version of the certificate * @return the observable to the CertificateBundle object */ - public Observable> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { + public Observable> updateCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4698,10 +5652,10 @@ public Observable> call(Response updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags).toBlocking().single(); + public CertificateBundle updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags).toBlocking().single().getBody(); } /** @@ -4717,7 +5671,27 @@ public ServiceResponse updateCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags), serviceCallback); + return ServiceCall.create(updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags), serviceCallback); + } + + /** + * Updates the attributes associated with the specified certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @param certificatePolicy The management policy for the certificate + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4731,7 +5705,7 @@ public ServiceCall updateCertificateAsync(String vaultBaseUrl * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the CertificateBundle object */ - public Observable> updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + public Observable> updateCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4782,10 +5756,10 @@ private ServiceResponse updateCertificateDelegate(Response getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single(); + public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single().getBody(); } /** @@ -4798,7 +5772,24 @@ public ServiceResponse getCertificate(String vaultBaseUrl, St * @return the {@link ServiceCall} object */ public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + return ServiceCall.create(getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + } + + /** + * Gets a Certificate. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate in the given vault + * @param certificateVersion The version of the certificate + * @return the observable to the CertificateBundle object + */ + public Observable getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { + return getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4809,7 +5800,7 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S * @param certificateVersion The version of the certificate * @return the observable to the CertificateBundle object */ - public Observable> getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { + public Observable> getCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4853,10 +5844,10 @@ private ServiceResponse getCertificateDelegate(Response updateCertificateOperation(String vaultBaseUrl, String certificateName, boolean cancellationRequested) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateOperationAsync(vaultBaseUrl, certificateName, cancellationRequested).toBlocking().single(); + public CertificateOperation updateCertificateOperation(String vaultBaseUrl, String certificateName, boolean cancellationRequested) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return updateCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName, cancellationRequested).toBlocking().single().getBody(); } /** @@ -4869,7 +5860,7 @@ public ServiceResponse updateCertificateOperation(String v * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateOperationAsync(vaultBaseUrl, certificateName, cancellationRequested), serviceCallback); + return ServiceCall.create(updateCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName, cancellationRequested), serviceCallback); } /** @@ -4880,7 +5871,24 @@ public ServiceCall updateCertificateOperationAsync(String * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. * @return the observable to the CertificateOperation object */ - public Observable> updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested) { + public Observable updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested) { + return updateCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName, cancellationRequested).map(new Func1, CertificateOperation>() { + @Override + public CertificateOperation call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Updates a certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. + * @return the observable to the CertificateOperation object + */ + public Observable> updateCertificateOperationWithServiceResponseAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4922,10 +5930,10 @@ private ServiceResponse updateCertificateOperationDelegate * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation object if successful. */ - public ServiceResponse getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateOperationAsync(vaultBaseUrl, certificateName).toBlocking().single(); + public CertificateOperation getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); } /** @@ -4937,7 +5945,23 @@ public ServiceResponse getCertificateOperation(String vaul * @return the {@link ServiceCall} object */ public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateOperationAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.create(getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Gets the certificate operation response. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable getCertificateOperationAsync(String vaultBaseUrl, String certificateName) { + return getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificateOperation>() { + @Override + public CertificateOperation call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -4947,7 +5971,7 @@ public ServiceCall getCertificateOperationAsync(String vau * @param certificateName The name of the certificate * @return the observable to the CertificateOperation object */ - public Observable> getCertificateOperationAsync(String vaultBaseUrl, String certificateName) { + public Observable> getCertificateOperationWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -4987,10 +6011,10 @@ private ServiceResponse getCertificateOperationDelegate(Re * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateOperation object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateOperation object if successful. */ - public ServiceResponse deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateOperationAsync(vaultBaseUrl, certificateName).toBlocking().single(); + public CertificateOperation deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); } /** @@ -5002,7 +6026,23 @@ public ServiceResponse deleteCertificateOperation(String v * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateOperationAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.create(deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + } + + /** + * Deletes the certificate operation. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @return the observable to the CertificateOperation object + */ + public Observable deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName) { + return deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificateOperation>() { + @Override + public CertificateOperation call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -5012,7 +6052,7 @@ public ServiceCall deleteCertificateOperationAsync(String * @param certificateName The name of the certificate * @return the observable to the CertificateOperation object */ - public Observable> deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName) { + public Observable> deleteCertificateOperationWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5053,10 +6093,10 @@ private ServiceResponse deleteCertificateOperationDelegate * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the CertificateBundle object wrapped in {@link ServiceResponse} if successful. + * @return the CertificateBundle object if successful. */ - public ServiceResponse mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates).toBlocking().single(); + public CertificateBundle mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates).toBlocking().single().getBody(); } /** @@ -5069,7 +6109,24 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) { - return ServiceCall.create(mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates), serviceCallback); + return ServiceCall.create(mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates), serviceCallback); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificate chain to merge + * @return the observable to the CertificateBundle object + */ + public Observable mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates) { + return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -5080,7 +6137,7 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, * @param x509Certificates The certificate or the certificate chain to merge * @return the observable to the CertificateBundle object */ - public Observable> mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates) { + public Observable> mergeCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, List x509Certificates) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5126,10 +6183,10 @@ public Observable> call(Response mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).toBlocking().single(); + public CertificateBundle mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { + return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).toBlocking().single().getBody(); } /** @@ -5144,7 +6201,26 @@ public ServiceResponse mergeCertificate(String vaultBaseUrl, * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(mergeCertificateAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags), serviceCallback); + return ServiceCall.create(mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags), serviceCallback); + } + + /** + * Merges a certificate or a certificate chain with a key pair existing on the server. + * + * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param certificateName The name of the certificate + * @param x509Certificates The certificate or the certificate chain to merge + * @param certificateAttributes The attributes of the certificate (optional) + * @param tags Application-specific metadata in the form of key-value pairs + * @return the observable to the CertificateBundle object + */ + public Observable mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { + return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).map(new Func1, CertificateBundle>() { + @Override + public CertificateBundle call(ServiceResponse response) { + return response.getBody(); + } + }); } /** @@ -5157,7 +6233,7 @@ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, * @param tags Application-specific metadata in the form of key-value pairs * @return the observable to the CertificateBundle object */ - public Observable> mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { + public Observable> mergeCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { if (vaultBaseUrl == null) { throw new IllegalArgumentException("Parameter vaultBaseUrl is required and cannot be null."); } @@ -5206,17 +6282,16 @@ private ServiceResponse mergeCertificateDelegate(Response> getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5243,15 +6318,34 @@ public Observable>> call(String nextPageLink) { * List the versions of the specified key. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<KeyItem> object + * @return the observable to the PagedList<KeyItem> object + */ + public Observable> getKeyVersionsNextAsync(final String nextPageLink) { + return getKeyVersionsNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of the specified key. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<KeyItem> object */ - public Observable>> getKeyVersionsNextAsync(final String nextPageLink) { + public Observable>> getKeyVersionsNextWithServiceResponseAsync(final String nextPageLink) { return getKeyVersionsNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getKeyVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getKeyVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5260,7 +6354,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getKeyVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { @@ -5294,17 +6388,16 @@ private ServiceResponse> getKeyVersionsNextDelegate(Response> getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getKeysNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5331,15 +6424,34 @@ public Observable>> call(String nextPageLink) { * List keys in the specified vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<KeyItem> object + * @return the observable to the PagedList<KeyItem> object + */ + public Observable> getKeysNextAsync(final String nextPageLink) { + return getKeysNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List keys in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<KeyItem> object */ - public Observable>> getKeysNextAsync(final String nextPageLink) { + public Observable>> getKeysNextWithServiceResponseAsync(final String nextPageLink) { return getKeysNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getKeysNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getKeysNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5348,7 +6460,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<KeyItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getKeysNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { @@ -5382,17 +6494,16 @@ private ServiceResponse> getKeysNextDelegate(Response> getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5419,15 +6530,34 @@ public Observable>> call(String nextPageLink) { * List secrets in the specified vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<SecretItem> object + * @return the observable to the PagedList<SecretItem> object + */ + public Observable> getSecretsNextAsync(final String nextPageLink) { + return getSecretsNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List secrets in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<SecretItem> object */ - public Observable>> getSecretsNextAsync(final String nextPageLink) { + public Observable>> getSecretsNextWithServiceResponseAsync(final String nextPageLink) { return getSecretsNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getSecretsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getSecretsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5436,7 +6566,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getSecretsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { @@ -5470,17 +6600,16 @@ private ServiceResponse> getSecretsNextDelegate(Response> getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5507,15 +6636,34 @@ public Observable>> call(String nextPageLink) { * List the versions of the specified secret. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<SecretItem> object + * @return the observable to the PagedList<SecretItem> object */ - public Observable>> getSecretVersionsNextAsync(final String nextPageLink) { + public Observable> getSecretVersionsNextAsync(final String nextPageLink) { + return getSecretVersionsNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of the specified secret. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<SecretItem> object + */ + public Observable>> getSecretVersionsNextWithServiceResponseAsync(final String nextPageLink) { return getSecretVersionsNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getSecretVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getSecretVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5524,7 +6672,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<SecretItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getSecretVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { @@ -5558,17 +6706,16 @@ private ServiceResponse> getSecretVersionsNextDelegate(Resp * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> object if successful. */ - public ServiceResponse> getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5595,15 +6742,34 @@ public Observable>> call(String nextPageLi * List certificates in the specified vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<CertificateItem> object + * @return the observable to the PagedList<CertificateItem> object + */ + public Observable> getCertificatesNextAsync(final String nextPageLink) { + return getCertificatesNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List certificates in the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<CertificateItem> object */ - public Observable>> getCertificatesNextAsync(final String nextPageLink) { + public Observable>> getCertificatesNextWithServiceResponseAsync(final String nextPageLink) { return getCertificatesNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificatesNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificatesNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5612,7 +6778,7 @@ public Observable>> call(ServiceResponse

> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificatesNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { @@ -5646,17 +6812,16 @@ private ServiceResponse> getCertificatesNextDelegate(R * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateIssuerItem> object if successful. */ - public ServiceResponse> getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5683,15 +6848,34 @@ public Observable>> call(String next * List certificate issuers for the specified vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<CertificateIssuerItem> object + * @return the observable to the PagedList<CertificateIssuerItem> object + */ + public Observable> getCertificateIssuersNextAsync(final String nextPageLink) { + return getCertificateIssuersNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List certificate issuers for the specified vault. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<CertificateIssuerItem> object */ - public Observable>> getCertificateIssuersNextAsync(final String nextPageLink) { + public Observable>> getCertificateIssuersNextWithServiceResponseAsync(final String nextPageLink) { return getCertificateIssuersNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateIssuersNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificateIssuersNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5700,7 +6884,7 @@ public Observable>> call(ServiceResp * List certificate issuers for the specified vault. * ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateIssuersNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { @@ -5734,17 +6918,16 @@ private ServiceResponse> getCertificateIssuersNe * @throws KeyVaultErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> object if successful. */ - public ServiceResponse> getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { ServiceResponse> response = getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); - PagedList pagedList = new PagedList(response.getBody()) { + return new PagedList(response.getBody()) { @Override public Page nextPage(String nextPageLink) throws RestException, IOException { return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); } }; - return new ServiceResponse>(pagedList, response.getResponse()); } /** @@ -5771,15 +6954,34 @@ public Observable>> call(String nextPageLi * List the versions of a certificate. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the observable to the List<CertificateItem> object + * @return the observable to the PagedList<CertificateItem> object + */ + public Observable> getCertificateVersionsNextAsync(final String nextPageLink) { + return getCertificateVersionsNextWithServiceResponseAsync(nextPageLink) + .map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * List the versions of a certificate. + * + * @param nextPageLink The NextLink from the previous successful call to List operation. + * @return the observable to the PagedList<CertificateItem> object */ - public Observable>> getCertificateVersionsNextAsync(final String nextPageLink) { + public Observable>> getCertificateVersionsNextWithServiceResponseAsync(final String nextPageLink) { return getCertificateVersionsNextSinglePageAsync(nextPageLink) .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { String nextPageLink = page.getBody().getNextPageLink(); - return getCertificateVersionsNextSinglePageAsync(nextPageLink); + if (nextPageLink == null) { + return Observable.just(page); + } + return Observable.just(page).concatWith(getCertificateVersionsNextWithServiceResponseAsync(nextPageLink)); } }); } @@ -5788,7 +6990,7 @@ public Observable>> call(ServiceResponse

> * @param nextPageLink The NextLink from the previous successful call to List operation. - * @return the List<CertificateItem> object wrapped in {@link ServiceResponse} if successful. + * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateVersionsNextSinglePageAsync(final String nextPageLink) { if (nextPageLink == null) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index 07fff30be2e88..e8353e0708742 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -116,17 +116,6 @@ public Boolean managed() { return this.managed; } - /** - * Set the managed value. - * - * @param managed the managed value to set - * @return the KeyBundle object itself. - */ - public KeyBundle withManaged(Boolean managed) { - this.managed = managed; - return this; - } - /** * The key identifier. * @return identifier for the key diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index 57f669af5a4b7..f54b847cd02f7 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -110,17 +110,6 @@ public Boolean managed() { return this.managed; } - /** - * Set the managed value. - * - * @param managed the managed value to set - * @return the KeyItem object itself. - */ - public KeyItem withManaged(Boolean managed) { - this.managed = managed; - return this; - } - /** * The key identifier. * @return The Identifier value diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index 2035765e09b95..f5648ae67eb13 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -172,17 +172,6 @@ public String kid() { return this.kid; } - /** - * Set the kid value. - * - * @param kid the kid value to set - * @return the SecretBundle object itself. - */ - public SecretBundle withKid(String kid) { - this.kid = kid; - return this; - } - /** * Get the managed value. * @@ -192,17 +181,6 @@ public Boolean managed() { return this.managed; } - /** - * Set the managed value. - * - * @param managed the managed value to set - * @return the SecretBundle object itself. - */ - public SecretBundle withManaged(Boolean managed) { - this.managed = managed; - return this; - } - /** * the secret identifier. * @return The Identifier value diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index 9c4c31e91d44a..00bd3528dc4a0 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -135,17 +135,6 @@ public Boolean managed() { return this.managed; } - /** - * Set the managed value. - * - * @param managed the managed value to set - * @return the SecretItem object itself. - */ - public SecretItem withManaged(Boolean managed) { - this.managed = managed; - return this; - } - /** * the secret identifier. * @return The Identifier value diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index 8e4b7c7dced0f..833f167d399ff 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -150,7 +150,7 @@ public void createSelfSignedCertificatePkcs12() throws Exception { .withTags(sTags) .build(); - CertificateOperation certificateOperation = keyVaultClient.createCertificate(createCertificateRequest).getBody(); + CertificateOperation certificateOperation = keyVaultClient.createCertificate(createCertificateRequest); Assert.assertNotNull(certificateOperation); Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); @@ -167,12 +167,12 @@ public void createSelfSignedCertificatePkcs12() throws Exception { // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()); Assert.assertTrue(secret.managed()); // Retrieve the key backing the certificate KeyIdentifier keyIdentifier = certificateBundle.keyIdentifier(); - KeyBundle keyBundle = keyVaultClient.getKey(keyIdentifier.baseIdentifier()).getBody(); + KeyBundle keyBundle = keyVaultClient.getKey(keyIdentifier.baseIdentifier()); Assert.assertTrue(keyBundle.managed()); // Load the secret into a KeyStore @@ -182,7 +182,7 @@ public void createSelfSignedCertificatePkcs12() throws Exception { // Validate the certificate and key in the KeyStore validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword); - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName); Assert.assertNotNull(deletedCertificateBundle); try { keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); @@ -224,7 +224,7 @@ public void createSelfSignedCertificatePem() throws Exception { new CreateCertificateRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); Assert.assertNotNull(certificateOperation); Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); @@ -234,7 +234,7 @@ public void createSelfSignedCertificatePem() throws Exception { validatePem(certificateBundle, subjectName); - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName); Assert.assertNotNull(deletedCertificateBundle); try { @@ -277,7 +277,7 @@ public void createCertificatePkcs12() throws Exception { .Builder(getVaultUri(),certificateIssuerName, ISSUER_TEST) .withCredentials(credentials) .withOrganizationDetails(organizationDetails) - .build()).getBody(); + .build()); validateCertificateIssuer(createdCertificateIssuer, certificateIssuerName); @@ -305,7 +305,7 @@ public void createCertificatePkcs12() throws Exception { new CreateCertificateRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); Assert.assertNotNull(certificateOperation); Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); @@ -321,7 +321,7 @@ public void createCertificatePkcs12() throws Exception { // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()); Assert.assertTrue(secret.managed()); // Load the secret into a KeyStore @@ -331,7 +331,7 @@ public void createCertificatePkcs12() throws Exception { // Validate the certificate and key in the KeyStore validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword); - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName); Assert.assertNotNull(deletedCertificateBundle); try { @@ -374,7 +374,7 @@ public void createCertificatePem() throws Exception { .Builder(getVaultUri(), certificateIssuerName, ISSUER_TEST) .withCredentials(credentials) .withOrganizationDetails(organizationDetails) - .build()).getBody(); + .build()); validateCertificateIssuer(createdCertificateIssuer, certificateIssuerName); // Set content type to indicate the certificate is PEM format. @@ -401,7 +401,7 @@ public void createCertificatePem() throws Exception { new CreateCertificateRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); Assert.assertNotNull(certificateOperation); Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); @@ -411,7 +411,7 @@ public void createCertificatePem() throws Exception { validatePem(certificateBundle, subjectName); - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName); Assert.assertNotNull(deletedCertificateBundle); try { @@ -458,16 +458,16 @@ public void createCsr() throws InterruptedException, ExecutionException, KeyVaul new CreateCertificateRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); Assert.assertNotNull(certificateOperation); Assert.assertTrue(certificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)); Assert.assertNotNull(certificateOperation.csr()); - String csr = keyVaultClient.getPendingCertificateSigningRequest(vaultUri, certificateName).getBody(); + String csr = keyVaultClient.getPendingCertificateSigningRequest(vaultUri, certificateName); Assert.assertNotNull(csr); - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName); Assert.assertNotNull(deletedCertificateBundle); try { @@ -511,18 +511,18 @@ public void certificateAsyncRequestCancellation() throws KeyVaultErrorException, new CreateCertificateRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); CertificateOperation cancelledCertificateOperation = keyVaultClient.updateCertificateOperation( new UpdateCertificateOperationRequest .Builder(vaultUri, certificateName, true) - .build()).getBody(); + .build()); Assert.assertNotNull(cancelledCertificateOperation); Assert.assertTrue(cancelledCertificateOperation.cancellationRequested()); - keyVaultClient.deleteCertificateOperation(getVaultUri(), certificateName).getBody(); - keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + keyVaultClient.deleteCertificateOperation(getVaultUri(), certificateName); + keyVaultClient.deleteCertificate(getVaultUri(), certificateName); } /** @@ -547,7 +547,7 @@ public void importCertificatePkcs12() throws Exception { .withPolicy(certificatePolicy) .withAttributes(attribute) .withTags(sTags) - .build()).getBody(); + .build()); // Validate the certificate bundle created validateCertificateBundle(certificateBundle, certificatePolicy); @@ -562,7 +562,7 @@ public void importCertificatePkcs12() throws Exception { // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()); Assert.assertTrue(secret.managed()); // Load the secret into a KeyStore @@ -572,7 +572,7 @@ public void importCertificatePkcs12() throws Exception { // Validate the certificate and key in the KeyStore validateCertificateKeyInKeyStore(keyStore, x509Certificate, secretPassword); - CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName).getBody(); + CertificateBundle deletedCertificateBundle = keyVaultClient.deleteCertificate(getVaultUri(), certificateName); try { keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); @@ -601,7 +601,7 @@ public void certificateUpdate() throws Exception { .Builder(vaultUri, certificateName, certificateContent) .withPassword(certificatePassword) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); Attributes attribute = new CertificateAttributes() @@ -612,7 +612,7 @@ public void certificateUpdate() throws Exception { .Builder(vaultUri, certificateName) .withAttributes(attribute.withEnabled(false)) .withTags(sTags) - .build()).getBody(); + .build()); Assert.assertEquals(attribute.enabled(), updatedCertBundle.attributes().enabled()); Assert.assertEquals(sTags.toString(), updatedCertBundle.tags().toString()); @@ -621,10 +621,10 @@ public void certificateUpdate() throws Exception { new UpdateCertificatePolicyRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicyUpdate) - .build()).getBody(); + .build()); Assert.assertEquals(certificatePolicyUpdate.issuerReference().name(), updatedCertificatePolicy.issuerReference().name()); - CertificatePolicy policy = keyVaultClient.getCertificatePolicy(vaultUri, certificateName).getBody(); + CertificatePolicy policy = keyVaultClient.getCertificatePolicy(vaultUri, certificateName); Assert.assertEquals(certificatePolicyUpdate.issuerReference().name(), policy.issuerReference().name()); keyVaultClient.deleteCertificate(getVaultUri(), certificateName); @@ -655,7 +655,7 @@ public void listCertificates() throws Exception { .Builder(getVaultUri(), certificateName + i, certificateContent) .withPassword(certificatePassword) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); CertificateIdentifier id = certificateBundle.certificateIdentifier(); certificates.add(id.baseIdentifier()); break; @@ -671,7 +671,7 @@ public void listCertificates() throws Exception { } } - PagedList listResult = keyVaultClient.listCertificates(getVaultUri(), PAGELIST_MAX_CERTS).getBody(); + PagedList listResult = keyVaultClient.listCertificates(getVaultUri(), PAGELIST_MAX_CERTS); Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); HashSet toDelete = new HashSet(); @@ -716,7 +716,7 @@ public void listCertificateVersions() throws Exception { .Builder(getVaultUri(), certificateName, certificateContent) .withPassword(certificatePassword) .withPolicy(certificatePolicy) - .build()).getBody(); + .build()); CertificateIdentifier id = certificateBundle.certificateIdentifier(); certificates.add(id.identifier()); break; @@ -732,10 +732,10 @@ public void listCertificateVersions() throws Exception { } } - PagedList listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName, PAGELIST_MAX_CERTS).getBody(); + PagedList listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName, PAGELIST_MAX_CERTS); Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); - listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName).getBody(); + listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName); for (CertificateItem item : listResult) { if(item != null) { @@ -781,13 +781,13 @@ public void issuerCrudOperations() throws Exception { .Builder(getVaultUri(), "issuer1", certificateIssuer.provider()) .withCredentials(certificateIssuer.credentials()) .withOrganizationDetails(certificateIssuer.organizationDetails()) - .build()).getBody(); + .build()); validateCertificateIssuer(certificateIssuer, createdCertificateIssuer); String certificateIssuerName = createdCertificateIssuer.issuerIdentifier().name(); IssuerBundle retrievedCertificateIssuer = keyVaultClient.getCertificateIssuer(getVaultUri(), - certificateIssuerName).getBody(); + certificateIssuerName); validateCertificateIssuer(certificateIssuer, retrievedCertificateIssuer); @@ -803,13 +803,13 @@ public void issuerCrudOperations() throws Exception { .withCredentials(updatedCredentials) .withOrganizationDetails(retrievedCertificateIssuer.organizationDetails()) .withAttributes(retrievedCertificateIssuer.attributes()) - .build()).getBody(); + .build()); validateCertificateIssuer(retrievedCertificateIssuer, updatedCertificateIssuer); Assert.assertNotNull(updatedCertificateIssuer.organizationDetails()); - IssuerBundle deletedCertificateIssuer = keyVaultClient.deleteCertificateIssuer(getVaultUri(), certificateIssuerName).getBody(); + IssuerBundle deletedCertificateIssuer = keyVaultClient.deleteCertificateIssuer(getVaultUri(), certificateIssuerName); validateCertificateIssuer(updatedCertificateIssuer, deletedCertificateIssuer); @@ -844,7 +844,7 @@ public void contactsCrudOperations() throws Exception { Contacts certificateContacts = new Contacts(); certificateContacts.withContactList(contacts); - Contacts createdCertificateContacts = keyVaultClient.setCertificateContacts(getVaultUri(), certificateContacts).getBody(); + Contacts createdCertificateContacts = keyVaultClient.setCertificateContacts(getVaultUri(), certificateContacts); Assert.assertNotNull(createdCertificateContacts); Assert.assertNotNull(createdCertificateContacts.contactList()); Assert.assertTrue(createdCertificateContacts.contactList().size() == 2); @@ -857,20 +857,20 @@ public void contactsCrudOperations() throws Exception { Assert.assertTrue(createContacts[1].phone().equalsIgnoreCase("8888888888")); // Get - Contacts retrievedCertificateContacts = keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); + Contacts retrievedCertificateContacts = keyVaultClient.getCertificateContacts(getVaultUri()); Assert.assertNotNull(retrievedCertificateContacts); Assert.assertNotNull(retrievedCertificateContacts.contactList()); Assert.assertTrue(retrievedCertificateContacts.contactList().size() == 2); // Delete - Contacts deletedCertificateContacts = keyVaultClient.deleteCertificateContacts(getVaultUri()).getBody(); + Contacts deletedCertificateContacts = keyVaultClient.deleteCertificateContacts(getVaultUri()); Assert.assertNotNull(deletedCertificateContacts); Assert.assertNotNull(deletedCertificateContacts.contactList()); Assert.assertTrue(deletedCertificateContacts.contactList().size() == 2); // Get after delete try { - keyVaultClient.getCertificateContacts(getVaultUri()).getBody(); + keyVaultClient.getCertificateContacts(getVaultUri()); } catch (KeyVaultErrorException e) { Assert.assertNotNull(e.getBody().error()); Assert.assertEquals("ContactsNotFound", e.getBody().error().code()); @@ -890,7 +890,7 @@ private static CertificateBundle pollOnCertificateOperation(CertificateOperation while (pendingPollCount < 21) { String certificateName = certificateOperation.certificateOperationIdentifier().name(); CertificateOperation pendingCertificateOperation = keyVaultClient - .getCertificateOperation(getVaultUri(), certificateName).getBody(); + .getCertificateOperation(getVaultUri(), certificateName); if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_IN_PROGRESS)) { Thread.sleep(10000); pendingPollCount += 1; @@ -898,7 +898,7 @@ private static CertificateBundle pollOnCertificateOperation(CertificateOperation } if (pendingCertificateOperation.status().equalsIgnoreCase(STATUS_COMPLETED)) { - return keyVaultClient.getCertificate(pendingCertificateOperation.target()).getBody(); + return keyVaultClient.getCertificate(pendingCertificateOperation.target()); } throw new Exception(String.format( @@ -1100,7 +1100,7 @@ private void validatePem(CertificateBundle certificateBundle, String subjectName // Retrieve the secret backing the certificate SecretIdentifier secretIdentifier = certificateBundle.secretIdentifier(); - SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()).getBody(); + SecretBundle secret = keyVaultClient.getSecret(secretIdentifier.baseIdentifier()); Assert.assertTrue(secret.managed()); String secretValue = secret.value(); diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 92de113eb9f98..863b2f8a4166a 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -68,7 +68,7 @@ public void transparentAuthentication() throws Exception { .withKeyOperations(keyOps) .withKeySize(2048) .withTags(tags) - .build()).getBody(); + .build()); validateRsaKeyBundle(bundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, keyOps, attribute); } @@ -76,7 +76,7 @@ public void transparentAuthentication() throws Exception { // Create a key on a different vault. Key Vault Data Plane returns 401, // which must be transparently handled by KeyVaultCredentials. { - KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + KeyBundle bundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()); validateRsaKeyBundle(bundle, getSecondaryVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); } @@ -112,7 +112,7 @@ private void checkImportOperation(KeyBundle keyBundle, boolean importToHardware) .withHsm(importToHardware) .withAttributes(attribute) .withTags(tags) - .build()).getBody(); + .build()); validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? JsonWebKeyType.RSA_HSM : JsonWebKeyType.RSA, importedJwk.keyOps(), attribute); checkEncryptDecryptSequence(importedJwk, importResultBundle); @@ -127,7 +127,7 @@ private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle impor // Encrypt in the service. { - KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + KeyOperationResult result = keyVaultClient.encrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText); cipherText = result.result(); } @@ -152,7 +152,7 @@ private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle impor // Decrypt in the service. { - KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA1_5, cipherText).getBody(); + KeyOperationResult result = keyVaultClient.decrypt(importedKeyBundle.key().kid(), JsonWebKeyEncryptionAlgorithm.RSA1_5, cipherText); byte[] beforeEncrypt = plainText; byte[] afterDecrypt = result.result(); @@ -166,7 +166,7 @@ public void crudOperations() throws Exception { KeyBundle createdBundle; { // Create key - createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()); validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); } @@ -175,31 +175,31 @@ public void crudOperations() throws Exception { { // Get key using kid WO version - KeyBundle readBundle = keyVaultClient.getKey(keyId.baseIdentifier()).getBody(); + KeyBundle readBundle = keyVaultClient.getKey(keyId.baseIdentifier()); compareKeyBundles(createdBundle, readBundle); } { // Get key using full kid as defined in the bundle - KeyBundle readBundle = keyVaultClient.getKey(createdBundle.key().kid()).getBody(); + KeyBundle readBundle = keyVaultClient.getKey(createdBundle.key().kid()); compareKeyBundles(createdBundle, readBundle); } { // Get key using vault and key name. - KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME).getBody(); + KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME); compareKeyBundles(createdBundle, readBundle); } { // Get key using vault, key name and version. - KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME, keyId.version()).getBody(); + KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME, keyId.version()); compareKeyBundles(createdBundle, readBundle); } { // Get key using vault, key name and a null version. - KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME).getBody(); + KeyBundle readBundle = keyVaultClient.getKey(getVaultUri(), KEY_NAME); compareKeyBundles(createdBundle, readBundle); } @@ -224,7 +224,7 @@ public void crudOperations() throws Exception { .withKeyOperations(key_ops) .withAttributes(createdBundle.attributes()) .withTags(createdBundle.tags()) - .build()).getBody(); + .build()); compareKeyBundles(createdBundle, updatedBundle); @@ -253,14 +253,14 @@ public void crudOperations() throws Exception { .withKeyOperations(key_ops) .withAttributes(createdBundle.attributes()) .withTags(createdBundle.tags()) - .build()).getBody(); + .build()); compareKeyBundles(createdBundle, updatedBundle); } { // Delete key - KeyBundle deleteBundle = keyVaultClient.deleteKey(getVaultUri(), KEY_NAME).getBody(); + KeyBundle deleteBundle = keyVaultClient.deleteKey(getVaultUri(), KEY_NAME); compareKeyBundles(createdBundle, deleteBundle); } @@ -285,14 +285,14 @@ public void backupRestore() throws Exception { { createdBundle = keyVaultClient.createKey( new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA) - .build()).getBody(); + .build()); validateRsaKeyBundle(createdBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); } // Creates a backup of key. byte[] keyBackup; { - keyBackup = keyVaultClient.backupKey(getVaultUri(), KEY_NAME).getBody().value(); + keyBackup = keyVaultClient.backupKey(getVaultUri(), KEY_NAME).value(); } // Deletes the key. @@ -302,7 +302,7 @@ public void backupRestore() throws Exception { // Restores the key. { - KeyBundle restoredBundle = keyVaultClient.restoreKey(getVaultUri(), keyBackup).getBody(); + KeyBundle restoredBundle = keyVaultClient.restoreKey(getVaultUri(), keyBackup); compareKeyBundles(createdBundle, restoredBundle); } @@ -316,7 +316,7 @@ public void listKeys() throws Exception { int failureCount = 0; for (;;) { try { - KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, JsonWebKeyType.RSA).build()).getBody(); + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME + i, JsonWebKeyType.RSA).build()); KeyIdentifier kid = new KeyIdentifier(createdBundle.key().kid()); keys.add(kid.baseIdentifier()); break; @@ -332,7 +332,7 @@ public void listKeys() throws Exception { } } - PagedList listResult = keyVaultClient.listKeys(getVaultUri(), PAGELIST_MAX_KEYS).getBody(); + PagedList listResult = keyVaultClient.listKeys(getVaultUri(), PAGELIST_MAX_KEYS); Assert.assertTrue(PAGELIST_MAX_KEYS >= listResult.currentPage().getItems().size()); HashSet toDelete = new HashSet(); @@ -367,7 +367,7 @@ public void listKeyVersions() throws Exception { int failureCount = 0; for (;;) { try { - KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()).getBody(); + KeyBundle createdBundle = keyVaultClient.createKey(new CreateKeyRequest.Builder(getVaultUri(), KEY_NAME, JsonWebKeyType.RSA).build()); keys.add(createdBundle.key().kid()); break; } catch (KeyVaultErrorException e) { @@ -382,10 +382,10 @@ public void listKeyVersions() throws Exception { } } - PagedList listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME, MAX_KEYS).getBody(); + PagedList listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME, MAX_KEYS); //TODO bug: Assert.assertTrue(PAGELIST_MAX_KEYS >= listResult.currentPage().getItems().size()); - listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME).getBody(); + listResult = keyVaultClient.listKeyVersions(getVaultUri(), KEY_NAME); for (KeyItem item : listResult) { if(item != null) { @@ -413,19 +413,19 @@ public void encryptDecryptOperations() throws Exception { // encrypt and decrypt using kid WO version { - result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + result = keyVaultClient.encrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText); cipherText = result.result(); - result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); + result = keyVaultClient.decrypt(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText); Assert.assertArrayEquals(plainText, result.result()); } // encrypt and decrypt using full kid { - result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + result = keyVaultClient.encrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText); cipherText = result.result(); - result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); + result = keyVaultClient.decrypt(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText); Assert.assertArrayEquals(plainText, result.result()); } } @@ -445,19 +445,19 @@ public void wrapUnwrapOperations() throws Exception { // wrap and unwrap using kid WO version { - result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText); cipherText = result.result(); - result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); + result = keyVaultClient.unwrapKey(keyId.baseIdentifier(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText); Assert.assertArrayEquals(plainText, result.result()); } // wrap and unwrap using full kid { - result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText).getBody(); + result = keyVaultClient.wrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, plainText); cipherText = result.result(); - result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText).getBody(); + result = keyVaultClient.unwrapKey(testKey.kid(), JsonWebKeyEncryptionAlgorithm.RSA_OAEP, cipherText); Assert.assertArrayEquals(plainText, result.result()); } } @@ -481,19 +481,19 @@ public void signVerifyOperations() throws Exception { // Using kid WO version { - result = keyVaultClient.sign(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest).getBody(); + result = keyVaultClient.sign(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest); signature = result.result(); - verifyResult = keyVaultClient.verify(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest, signature).getBody(); + verifyResult = keyVaultClient.verify(keyId.baseIdentifier(), JsonWebKeySignatureAlgorithm.RS256, digest, signature); Assert.assertEquals(new Boolean(true), verifyResult.value()); } // Using full kid { - result = keyVaultClient.sign(testKey.kid(), JsonWebKeySignatureAlgorithm.RS256, digest).getBody(); + result = keyVaultClient.sign(testKey.kid(), JsonWebKeySignatureAlgorithm.RS256, digest); signature = result.result(); - verifyResult = keyVaultClient.verify(testKey.kid(), JsonWebKeySignatureAlgorithm.RS256, digest, signature).getBody(); + verifyResult = keyVaultClient.verify(testKey.kid(), JsonWebKeySignatureAlgorithm.RS256, digest, signature); Assert.assertEquals(new Boolean(true), verifyResult.value()); } @@ -511,7 +511,7 @@ private static JsonWebKey importTestKey() throws Exception { new ImportKeyRequest .Builder(getVaultUri(), KEY_NAME, key) .withHsm(false) - .build()).getBody(); + .build()); validateRsaKeyBundle(keyBundle, getVaultUri(), KEY_NAME, JsonWebKeyType.RSA, null, null); diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index ed6282decdf41..08e6cd13de44e 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -49,7 +49,7 @@ public void transparentAuthentication() throws Exception { .withAttributes(attributes) .withContentType(contentType) .withTags(tags) - .build()).getBody(); + .build()); validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, contentType, attributes); } @@ -57,7 +57,7 @@ public void transparentAuthentication() throws Exception { // 401, which must be transparently handled by KeyVaultCredentials. { SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + new SetSecretRequest.Builder(getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE).build()); validateSecret(secret, getSecondaryVaultUri(), SECRET_NAME, SECRET_VALUE, null, null); } @@ -70,7 +70,7 @@ public void crudOperations() throws Exception { { // Create secret secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()); validateSecret(secret, getVaultUri(), SECRET_NAME, SECRET_VALUE, null, null); } @@ -79,25 +79,25 @@ public void crudOperations() throws Exception { { // Get secret using kid WO version - SecretBundle readBundle = keyVaultClient.getSecret(secretId.baseIdentifier()).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(secretId.baseIdentifier()); compareSecrets(secret, readBundle); } { // Get secret using full kid as defined in the bundle - SecretBundle readBundle = keyVaultClient.getSecret(secret.id()).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(secret.id()); compareSecrets(secret, readBundle); } { // Get secret using vault and secret name. - SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME); compareSecrets(secret, readBundle); } { // Get secret using vault, secret name and version. - SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME, secretId.version()).getBody(); + SecretBundle readBundle = keyVaultClient.getSecret(getVaultUri(), SECRET_NAME, secretId.version()); compareSecrets(secret, readBundle); } @@ -119,7 +119,7 @@ public void crudOperations() throws Exception { .withContentType(secret.contentType()) .withAttributes(secret.attributes()) .withTags(secret.tags()) - .build()).getBody(); + .build()); compareSecrets(secret, updatedSecret); // Subsequent operations must use the updated bundle for comparison. @@ -146,7 +146,7 @@ public void crudOperations() throws Exception { .withContentType(secret.contentType()) .withAttributes(secret.attributes()) .withTags(secret.tags()) - .build()).getBody(); + .build()); compareSecrets(secret, updatedSecret); validateSecret(updatedSecret, @@ -157,7 +157,7 @@ public void crudOperations() throws Exception { { // Delete secret - SecretBundle deleteBundle = keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME).getBody(); + SecretBundle deleteBundle = keyVaultClient.deleteSecret(getVaultUri(), SECRET_NAME); compareSecrets(secret, deleteBundle); } @@ -181,7 +181,7 @@ public void listSecrets() throws Exception { for (;;) { try { SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME + i, SECRET_VALUE).build()).getBody(); + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME + i, SECRET_VALUE).build()); SecretIdentifier id = new SecretIdentifier(secret.id()); secrets.add(id.baseIdentifier()); break; @@ -197,7 +197,7 @@ public void listSecrets() throws Exception { } } - PagedList listResult = keyVaultClient.listSecrets(getVaultUri(), PAGELIST_MAX_SECRETS).getBody(); + PagedList listResult = keyVaultClient.listSecrets(getVaultUri(), PAGELIST_MAX_SECRETS); Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().getItems().size()); HashSet toDelete = new HashSet(); @@ -233,7 +233,7 @@ public void listSecretVersions() throws Exception { for (;;) { try { SecretBundle secret = keyVaultClient.setSecret( - new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()).getBody(); + new SetSecretRequest.Builder(getVaultUri(), SECRET_NAME, SECRET_VALUE).build()); secrets.add(secret.id()); break; } catch (KeyVaultErrorException e) { @@ -248,10 +248,10 @@ public void listSecretVersions() throws Exception { } } - PagedList listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME, PAGELIST_MAX_SECRETS).getBody(); + PagedList listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME, PAGELIST_MAX_SECRETS); Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().getItems().size()); - listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME).getBody(); + listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME); for (SecretItem item : listResult) { if(item != null) { secrets.remove(item.id()); From 1f90d9368c6eebb57e3647703f814c934e15b586 Mon Sep 17 00:00:00 2001 From: alvadb Date: Mon, 19 Sep 2016 17:01:11 -0700 Subject: [PATCH 35/56] Update additional pom.xml for annotation build break --- azure-keyvault/pom.xml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index 66e34edb30b3e..fa61aa7c7f5ea 100755 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -70,6 +70,11 @@ 1.0.0-SNAPSHOT test + + com.microsoft.azure + api-annotations + 0.0.1-SNAPSHOT + @@ -114,6 +119,24 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.0 + + + + com.microsoft.azure.management.apigeneration.LangDefinitionProcessor + + true + true + + true + true + + + + From c9889371982506d1792e5b6b5ffd3a5ed13e8ba7 Mon Sep 17 00:00:00 2001 From: alvadb Date: Mon, 19 Sep 2016 17:20:43 -0700 Subject: [PATCH 36/56] Additional pom.xml updates for build break fix. --- azure-keyvault-core/pom.xml | 23 +++++++++++++++++++++++ azure-keyvault-cryptography/pom.xml | 27 +++++++++++++++++++++++++++ azure-keyvault-extensions/pom.xml | 23 +++++++++++++++++++++++ azure-keyvault-webkey/pom.xml | 23 +++++++++++++++++++++++ 4 files changed, 96 insertions(+) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index 32a541dce7d91..c9c06e52dfd5f 100755 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -97,6 +97,24 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.0 + + + + com.microsoft.azure.management.apigeneration.LangDefinitionProcessor + + true + true + + true + true + + + + @@ -110,5 +128,10 @@ guava 18.0 + + com.microsoft.azure + api-annotations + 0.0.1-SNAPSHOT + diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index b3e1236542df2..54b8b9c347d02 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -64,5 +64,32 @@ azure-keyvault-webkey ${project.version} + + com.microsoft.azure + api-annotations + 0.0.1-SNAPSHOT + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.0 + + + + com.microsoft.azure.management.apigeneration.LangDefinitionProcessor + + true + true + + true + true + + + + + diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 36d1dc3668e0a..d333e5eeabd81 100755 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -103,6 +103,11 @@ guava 18.0 + + com.microsoft.azure + api-annotations + 0.0.1-SNAPSHOT + @@ -147,6 +152,24 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.0 + + + + com.microsoft.azure.management.apigeneration.LangDefinitionProcessor + + true + true + + true + true + + + + diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml index 698622c6d1fe0..905f5eb09bf78 100644 --- a/azure-keyvault-webkey/pom.xml +++ b/azure-keyvault-webkey/pom.xml @@ -55,6 +55,11 @@ commons-codec commons-codec + + com.microsoft.azure + api-annotations + 0.0.1-SNAPSHOT + @@ -99,6 +104,24 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.0 + + + + com.microsoft.azure.management.apigeneration.LangDefinitionProcessor + + true + true + + true + true + + + + From 1c27b8ee7737ea28c2585437ffd06cb589c2ff1a Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Mon, 19 Sep 2016 13:15:34 -0700 Subject: [PATCH 37/56] Update AesCbcHmac test vectors and add more tests from RFC7518 --- .../cryptography/test/AesCbcHmacShaTest.java | 205 ++++++++++++++++-- 1 file changed, 187 insertions(+), 18 deletions(-) diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java index 4783152229b1d..5bd3cacf3813d 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java @@ -12,8 +12,9 @@ import org.junit.Test; import com.microsoft.azure.keyvault.cryptography.IAuthenticatedCryptoTransform; -import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.algorithms.Aes128CbcHmacSha256; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes192CbcHmacSha384; +import com.microsoft.azure.keyvault.cryptography.algorithms.Aes256CbcHmacSha512; public class AesCbcHmacShaTest { @@ -42,15 +43,32 @@ protected void setProvider(Provider provider) { @Test public void testAes128CbcHmacSha256() { - // Arrange: These values are taken from Appendix B of the JWE - // specification at + // Arrange: These values are taken from Appendix B of the JWE specification at // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B - byte[] CEK = { 4, (byte) 211, 31, (byte) 197, 84, (byte) 157, (byte) 252, (byte) 254, 11, 100, (byte) 157, (byte) 250, 63, (byte) 170, 106, (byte) 206, 107, 124, (byte) 212, 45, 111, 107, 9, (byte) 219, (byte) 200, (byte) 177, 0, (byte) 240, (byte) 143, (byte) 156, 44, (byte) 207 }; - byte[] PLAIN = { 76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, 112, 114, 111, 115, 112, 101, 114, 46 }; - byte[] IV = { 3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101 }; - byte[] AUTH = { 101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 66, 77, 84, 73, 52, 83, 49, 99, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, 74, 66, 77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, 50, 73, 110, 48 }; - byte[] ED = { 40, 57, 83, (byte) 181, 119, 33, (byte) 133, (byte) 148, (byte) 198, (byte) 185, (byte) 243, 24, (byte) 152, (byte) 230, 6, 75, (byte) 129, (byte) 223, 127, 19, (byte) 210, 82, (byte) 183, (byte) 230, (byte) 168, 33, (byte) 215, 104, (byte) 143, 112, 56, 102 }; - byte[] TAG = { 83, 73, (byte) 191, 98, 104, (byte) 205, (byte) 211, (byte) 128, (byte) 201, (byte) 189, (byte) 199, (byte) 133, 32, 38, (byte) 194, 85 }; + byte[] K = { (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, (byte)0x06, (byte)0x07, (byte)0x08, (byte)0x09, (byte)0x0a, (byte)0x0b, (byte)0x0c, (byte)0x0d, (byte)0x0e, (byte)0x0f, + (byte)0x10, (byte)0x11, (byte)0x12, (byte)0x13, (byte)0x14, (byte)0x15, (byte)0x16, (byte)0x17, (byte)0x18, (byte)0x19, (byte)0x1a, (byte)0x1b, (byte)0x1c, (byte)0x1d, (byte)0x1e, (byte)0x1f }; + byte[] P = { (byte)0x41, (byte)0x20, (byte)0x63, (byte)0x69, (byte)0x70, (byte)0x68, (byte)0x65, (byte)0x72, (byte)0x20, (byte)0x73, (byte)0x79, (byte)0x73, (byte)0x74, (byte)0x65, (byte)0x6d, (byte)0x20, + (byte)0x6d, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x20, (byte)0x6e, (byte)0x6f, (byte)0x74, (byte)0x20, (byte)0x62, (byte)0x65, (byte)0x20, (byte)0x72, (byte)0x65, (byte)0x71, (byte)0x75, + (byte)0x69, (byte)0x72, (byte)0x65, (byte)0x64, (byte)0x20, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x62, (byte)0x65, (byte)0x20, (byte)0x73, (byte)0x65, (byte)0x63, (byte)0x72, (byte)0x65, + (byte)0x74, (byte)0x2c, (byte)0x20, (byte)0x61, (byte)0x6e, (byte)0x64, (byte)0x20, (byte)0x69, (byte)0x74, (byte)0x20, (byte)0x6d, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x20, (byte)0x62, + (byte)0x65, (byte)0x20, (byte)0x61, (byte)0x62, (byte)0x6c, (byte)0x65, (byte)0x20, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x66, (byte)0x61, (byte)0x6c, (byte)0x6c, (byte)0x20, (byte)0x69, + (byte)0x6e, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x68, (byte)0x61, (byte)0x6e, (byte)0x64, (byte)0x73, (byte)0x20, (byte)0x6f, (byte)0x66, + (byte)0x20, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x65, (byte)0x6e, (byte)0x65, (byte)0x6d, (byte)0x79, (byte)0x20, (byte)0x77, (byte)0x69, (byte)0x74, (byte)0x68, (byte)0x6f, + (byte)0x75, (byte)0x74, (byte)0x20, (byte)0x69, (byte)0x6e, (byte)0x63, (byte)0x6f, (byte)0x6e, (byte)0x76, (byte)0x65, (byte)0x6e, (byte)0x69, (byte)0x65, (byte)0x6e, (byte)0x63, (byte)0x65 }; + byte[] IV = { (byte)0x1a, (byte)0xf3, (byte)0x8c, (byte)0x2d, (byte)0xc2, (byte)0xb9, (byte)0x6f, (byte)0xfd, (byte)0xd8, (byte)0x66, (byte)0x94, (byte)0x09, (byte)0x23, (byte)0x41, (byte)0xbc, (byte)0x04 }; + byte[] A = { (byte)0x54, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x73, (byte)0x65, (byte)0x63, (byte)0x6f, (byte)0x6e, (byte)0x64, (byte)0x20, (byte)0x70, (byte)0x72, (byte)0x69, (byte)0x6e, (byte)0x63, + (byte)0x69, (byte)0x70, (byte)0x6c, (byte)0x65, (byte)0x20, (byte)0x6f, (byte)0x66, (byte)0x20, (byte)0x41, (byte)0x75, (byte)0x67, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x65, (byte)0x20, + (byte)0x4b, (byte)0x65, (byte)0x72, (byte)0x63, (byte)0x6b, (byte)0x68, (byte)0x6f, (byte)0x66, (byte)0x66, (byte)0x73 }; + byte[] E = { (byte)0xc8, (byte)0x0e, (byte)0xdf, (byte)0xa3, (byte)0x2d, (byte)0xdf, (byte)0x39, (byte)0xd5, (byte)0xef, (byte)0x00, (byte)0xc0, (byte)0xb4, (byte)0x68, (byte)0x83, (byte)0x42, (byte)0x79, + (byte)0xa2, (byte)0xe4, (byte)0x6a, (byte)0x1b, (byte)0x80, (byte)0x49, (byte)0xf7, (byte)0x92, (byte)0xf7, (byte)0x6b, (byte)0xfe, (byte)0x54, (byte)0xb9, (byte)0x03, (byte)0xa9, (byte)0xc9, + (byte)0xa9, (byte)0x4a, (byte)0xc9, (byte)0xb4, (byte)0x7a, (byte)0xd2, (byte)0x65, (byte)0x5c, (byte)0x5f, (byte)0x10, (byte)0xf9, (byte)0xae, (byte)0xf7, (byte)0x14, (byte)0x27, (byte)0xe2, + (byte)0xfc, (byte)0x6f, (byte)0x9b, (byte)0x3f, (byte)0x39, (byte)0x9a, (byte)0x22, (byte)0x14, (byte)0x89, (byte)0xf1, (byte)0x63, (byte)0x62, (byte)0xc7, (byte)0x03, (byte)0x23, (byte)0x36, + (byte)0x09, (byte)0xd4, (byte)0x5a, (byte)0xc6, (byte)0x98, (byte)0x64, (byte)0xe3, (byte)0x32, (byte)0x1c, (byte)0xf8, (byte)0x29, (byte)0x35, (byte)0xac, (byte)0x40, (byte)0x96, (byte)0xc8, + (byte)0x6e, (byte)0x13, (byte)0x33, (byte)0x14, (byte)0xc5, (byte)0x40, (byte)0x19, (byte)0xe8, (byte)0xca, (byte)0x79, (byte)0x80, (byte)0xdf, (byte)0xa4, (byte)0xb9, (byte)0xcf, (byte)0x1b, + (byte)0x38, (byte)0x4c, (byte)0x48, (byte)0x6f, (byte)0x3a, (byte)0x54, (byte)0xc5, (byte)0x10, (byte)0x78, (byte)0x15, (byte)0x8e, (byte)0xe5, (byte)0xd7, (byte)0x9d, (byte)0xe5, (byte)0x9f, + (byte)0xbd, (byte)0x34, (byte)0xd8, (byte)0x48, (byte)0xb3, (byte)0xd6, (byte)0x95, (byte)0x50, (byte)0xa6, (byte)0x76, (byte)0x46, (byte)0x34, (byte)0x44, (byte)0x27, (byte)0xad, (byte)0xe5, + (byte)0x4b, (byte)0x88, (byte)0x51, (byte)0xff, (byte)0xb5, (byte)0x98, (byte)0xf7, (byte)0xf8, (byte)0x00, (byte)0x74, (byte)0xb9, (byte)0x47, (byte)0x3c, (byte)0x82, (byte)0xe2, (byte)0xdb }; + byte[] T = { (byte)0x65, (byte)0x2c, (byte)0x3f, (byte)0xa3, (byte)0x6b, (byte)0x0a, (byte)0x7c, (byte)0x5b, (byte)0x32, (byte)0x19, (byte)0xfa, (byte)0xb3, (byte)0xa3, (byte)0x0b, (byte)0xc1, (byte)0xc4 }; Aes128CbcHmacSha256 algo = new Aes128CbcHmacSha256(); @@ -60,25 +78,24 @@ public void testAes128CbcHmacSha256() { byte[] tag = null; try { - transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(CEK, IV, AUTH, _provider); + transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(K, IV, A, _provider); } catch (Exception e) { fail(e.getMessage()); } try { - encrypted = transform.doFinal(PLAIN); - tag = transform.getTag(); + encrypted = transform.doFinal(P); + tag = transform.getTag(); - assertArrayEquals(ED, encrypted); - assertArrayEquals(TAG, tag); + assertArrayEquals(E, encrypted); + assertArrayEquals(T, tag); } catch (Exception e) { fail(e.getMessage()); } - ICryptoTransform decryptor = null; try { - decryptor = algo.CreateDecryptor(CEK, IV, AUTH, _provider); + transform = (IAuthenticatedCryptoTransform)algo.CreateDecryptor(K, IV, A, _provider); } catch (Exception e) { fail(e.getMessage()); } @@ -86,13 +103,165 @@ public void testAes128CbcHmacSha256() { byte[] decrypted = null; try { - decrypted = decryptor.doFinal(encrypted); + decrypted = transform.doFinal(encrypted); + tag = transform.getTag(); } catch (Exception e) { fail(e.getMessage()); } // Assert - assertArrayEquals(PLAIN, decrypted); + assertArrayEquals(P, decrypted); + assertArrayEquals(T, tag); } + + @Test + public void testAes192CbcHmacSha384() { + // Arrange: These values are taken from Appendix B of the JWE specification at + // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B + byte[] K = { (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, (byte)0x06, (byte)0x07, (byte)0x08, (byte)0x09, (byte)0x0a, (byte)0x0b, (byte)0x0c, (byte)0x0d, (byte)0x0e, (byte)0x0f, + (byte)0x10, (byte)0x11, (byte)0x12, (byte)0x13, (byte)0x14, (byte)0x15, (byte)0x16, (byte)0x17, (byte)0x18, (byte)0x19, (byte)0x1a, (byte)0x1b, (byte)0x1c, (byte)0x1d, (byte)0x1e, (byte)0x1f, + (byte)0x20, (byte)0x21, (byte)0x22, (byte)0x23, (byte)0x24, (byte)0x25, (byte)0x26, (byte)0x27, (byte)0x28, (byte)0x29, (byte)0x2a, (byte)0x2b, (byte)0x2c, (byte)0x2d, (byte)0x2e, (byte)0x2f }; + byte[] P = { (byte)0x41, (byte)0x20, (byte)0x63, (byte)0x69, (byte)0x70, (byte)0x68, (byte)0x65, (byte)0x72, (byte)0x20, (byte)0x73, (byte)0x79, (byte)0x73, (byte)0x74, (byte)0x65, (byte)0x6d, (byte)0x20, + (byte)0x6d, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x20, (byte)0x6e, (byte)0x6f, (byte)0x74, (byte)0x20, (byte)0x62, (byte)0x65, (byte)0x20, (byte)0x72, (byte)0x65, (byte)0x71, (byte)0x75, + (byte)0x69, (byte)0x72, (byte)0x65, (byte)0x64, (byte)0x20, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x62, (byte)0x65, (byte)0x20, (byte)0x73, (byte)0x65, (byte)0x63, (byte)0x72, (byte)0x65, + (byte)0x74, (byte)0x2c, (byte)0x20, (byte)0x61, (byte)0x6e, (byte)0x64, (byte)0x20, (byte)0x69, (byte)0x74, (byte)0x20, (byte)0x6d, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x20, (byte)0x62, + (byte)0x65, (byte)0x20, (byte)0x61, (byte)0x62, (byte)0x6c, (byte)0x65, (byte)0x20, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x66, (byte)0x61, (byte)0x6c, (byte)0x6c, (byte)0x20, (byte)0x69, + (byte)0x6e, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x68, (byte)0x61, (byte)0x6e, (byte)0x64, (byte)0x73, (byte)0x20, (byte)0x6f, (byte)0x66, + (byte)0x20, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x65, (byte)0x6e, (byte)0x65, (byte)0x6d, (byte)0x79, (byte)0x20, (byte)0x77, (byte)0x69, (byte)0x74, (byte)0x68, (byte)0x6f, + (byte)0x75, (byte)0x74, (byte)0x20, (byte)0x69, (byte)0x6e, (byte)0x63, (byte)0x6f, (byte)0x6e, (byte)0x76, (byte)0x65, (byte)0x6e, (byte)0x69, (byte)0x65, (byte)0x6e, (byte)0x63, (byte)0x65 }; + byte[] IV = { (byte)0x1a, (byte)0xf3, (byte)0x8c, (byte)0x2d, (byte)0xc2, (byte)0xb9, (byte)0x6f, (byte)0xfd, (byte)0xd8, (byte)0x66, (byte)0x94, (byte)0x09, (byte)0x23, (byte)0x41, (byte)0xbc, (byte)0x04 }; + byte[] A = { (byte)0x54, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x73, (byte)0x65, (byte)0x63, (byte)0x6f, (byte)0x6e, (byte)0x64, (byte)0x20, (byte)0x70, (byte)0x72, (byte)0x69, (byte)0x6e, (byte)0x63, + (byte)0x69, (byte)0x70, (byte)0x6c, (byte)0x65, (byte)0x20, (byte)0x6f, (byte)0x66, (byte)0x20, (byte)0x41, (byte)0x75, (byte)0x67, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x65, (byte)0x20, + (byte)0x4b, (byte)0x65, (byte)0x72, (byte)0x63, (byte)0x6b, (byte)0x68, (byte)0x6f, (byte)0x66, (byte)0x66, (byte)0x73 }; + byte[] E = { (byte)0xea, (byte)0x65, (byte)0xda, (byte)0x6b, (byte)0x59, (byte)0xe6, (byte)0x1e, (byte)0xdb, (byte)0x41, (byte)0x9b, (byte)0xe6, (byte)0x2d, (byte)0x19, (byte)0x71, (byte)0x2a, (byte)0xe5, + (byte)0xd3, (byte)0x03, (byte)0xee, (byte)0xb5, (byte)0x00, (byte)0x52, (byte)0xd0, (byte)0xdf, (byte)0xd6, (byte)0x69, (byte)0x7f, (byte)0x77, (byte)0x22, (byte)0x4c, (byte)0x8e, (byte)0xdb, + (byte)0x00, (byte)0x0d, (byte)0x27, (byte)0x9b, (byte)0xdc, (byte)0x14, (byte)0xc1, (byte)0x07, (byte)0x26, (byte)0x54, (byte)0xbd, (byte)0x30, (byte)0x94, (byte)0x42, (byte)0x30, (byte)0xc6, + (byte)0x57, (byte)0xbe, (byte)0xd4, (byte)0xca, (byte)0x0c, (byte)0x9f, (byte)0x4a, (byte)0x84, (byte)0x66, (byte)0xf2, (byte)0x2b, (byte)0x22, (byte)0x6d, (byte)0x17, (byte)0x46, (byte)0x21, + (byte)0x4b, (byte)0xf8, (byte)0xcf, (byte)0xc2, (byte)0x40, (byte)0x0a, (byte)0xdd, (byte)0x9f, (byte)0x51, (byte)0x26, (byte)0xe4, (byte)0x79, (byte)0x66, (byte)0x3f, (byte)0xc9, (byte)0x0b, + (byte)0x3b, (byte)0xed, (byte)0x78, (byte)0x7a, (byte)0x2f, (byte)0x0f, (byte)0xfc, (byte)0xbf, (byte)0x39, (byte)0x04, (byte)0xbe, (byte)0x2a, (byte)0x64, (byte)0x1d, (byte)0x5c, (byte)0x21, + (byte)0x05, (byte)0xbf, (byte)0xe5, (byte)0x91, (byte)0xba, (byte)0xe2, (byte)0x3b, (byte)0x1d, (byte)0x74, (byte)0x49, (byte)0xe5, (byte)0x32, (byte)0xee, (byte)0xf6, (byte)0x0a, (byte)0x9a, + (byte)0xc8, (byte)0xbb, (byte)0x6c, (byte)0x6b, (byte)0x01, (byte)0xd3, (byte)0x5d, (byte)0x49, (byte)0x78, (byte)0x7b, (byte)0xcd, (byte)0x57, (byte)0xef, (byte)0x48, (byte)0x49, (byte)0x27, + (byte)0xf2, (byte)0x80, (byte)0xad, (byte)0xc9, (byte)0x1a, (byte)0xc0, (byte)0xc4, (byte)0xe7, (byte)0x9c, (byte)0x7b, (byte)0x11, (byte)0xef, (byte)0xc6, (byte)0x00, (byte)0x54, (byte)0xe3 }; + byte[] T = { (byte)0x84, (byte)0x90, (byte)0xac, (byte)0x0e, (byte)0x58, (byte)0x94, (byte)0x9b, (byte)0xfe, (byte)0x51, (byte)0x87, (byte)0x5d, (byte)0x73, (byte)0x3f, (byte)0x93, (byte)0xac, (byte)0x20, + (byte)0x75, (byte)0x16, (byte)0x80, (byte)0x39, (byte)0xcc, (byte)0xc7, (byte)0x33, (byte)0xd7 }; + + Aes192CbcHmacSha384 algo = new Aes192CbcHmacSha384(); + + IAuthenticatedCryptoTransform transform = null; + + byte[] encrypted = null; + byte[] tag = null; + + try { + transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(K, IV, A, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + encrypted = transform.doFinal(P); + tag = transform.getTag(); + + assertArrayEquals(E, encrypted); + assertArrayEquals(T, tag); + + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + transform = (IAuthenticatedCryptoTransform)algo.CreateDecryptor(K, IV, A, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] decrypted = null; + + try { + decrypted = transform.doFinal(encrypted); + tag = transform.getTag(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(P, decrypted); + assertArrayEquals(T, tag); + } + @Test + public void testAes256CbcHmacSha512() { + // Arrange: These values are taken from Appendix B of the JWE specification at + // https://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-40#appendix-B + byte[] K = { (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, (byte)0x06, (byte)0x07, (byte)0x08, (byte)0x09, (byte)0x0a, (byte)0x0b, (byte)0x0c, (byte)0x0d, (byte)0x0e, (byte)0x0f, + (byte)0x10, (byte)0x11, (byte)0x12, (byte)0x13, (byte)0x14, (byte)0x15, (byte)0x16, (byte)0x17, (byte)0x18, (byte)0x19, (byte)0x1a, (byte)0x1b, (byte)0x1c, (byte)0x1d, (byte)0x1e, (byte)0x1f, + (byte)0x20, (byte)0x21, (byte)0x22, (byte)0x23, (byte)0x24, (byte)0x25, (byte)0x26, (byte)0x27, (byte)0x28, (byte)0x29, (byte)0x2a, (byte)0x2b, (byte)0x2c, (byte)0x2d, (byte)0x2e, (byte)0x2f, + (byte)0x30, (byte)0x31, (byte)0x32, (byte)0x33, (byte)0x34, (byte)0x35, (byte)0x36, (byte)0x37, (byte)0x38, (byte)0x39, (byte)0x3a, (byte)0x3b, (byte)0x3c, (byte)0x3d, (byte)0x3e, (byte)0x3f }; + byte[] P = { (byte)0x41, (byte)0x20, (byte)0x63, (byte)0x69, (byte)0x70, (byte)0x68, (byte)0x65, (byte)0x72, (byte)0x20, (byte)0x73, (byte)0x79, (byte)0x73, (byte)0x74, (byte)0x65, (byte)0x6d, (byte)0x20, + (byte)0x6d, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x20, (byte)0x6e, (byte)0x6f, (byte)0x74, (byte)0x20, (byte)0x62, (byte)0x65, (byte)0x20, (byte)0x72, (byte)0x65, (byte)0x71, (byte)0x75, + (byte)0x69, (byte)0x72, (byte)0x65, (byte)0x64, (byte)0x20, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x62, (byte)0x65, (byte)0x20, (byte)0x73, (byte)0x65, (byte)0x63, (byte)0x72, (byte)0x65, + (byte)0x74, (byte)0x2c, (byte)0x20, (byte)0x61, (byte)0x6e, (byte)0x64, (byte)0x20, (byte)0x69, (byte)0x74, (byte)0x20, (byte)0x6d, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x20, (byte)0x62, + (byte)0x65, (byte)0x20, (byte)0x61, (byte)0x62, (byte)0x6c, (byte)0x65, (byte)0x20, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x66, (byte)0x61, (byte)0x6c, (byte)0x6c, (byte)0x20, (byte)0x69, + (byte)0x6e, (byte)0x74, (byte)0x6f, (byte)0x20, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x68, (byte)0x61, (byte)0x6e, (byte)0x64, (byte)0x73, (byte)0x20, (byte)0x6f, (byte)0x66, + (byte)0x20, (byte)0x74, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x65, (byte)0x6e, (byte)0x65, (byte)0x6d, (byte)0x79, (byte)0x20, (byte)0x77, (byte)0x69, (byte)0x74, (byte)0x68, (byte)0x6f, + (byte)0x75, (byte)0x74, (byte)0x20, (byte)0x69, (byte)0x6e, (byte)0x63, (byte)0x6f, (byte)0x6e, (byte)0x76, (byte)0x65, (byte)0x6e, (byte)0x69, (byte)0x65, (byte)0x6e, (byte)0x63, (byte)0x65 }; + byte[] IV = { (byte)0x1a, (byte)0xf3, (byte)0x8c, (byte)0x2d, (byte)0xc2, (byte)0xb9, (byte)0x6f, (byte)0xfd, (byte)0xd8, (byte)0x66, (byte)0x94, (byte)0x09, (byte)0x23, (byte)0x41, (byte)0xbc, (byte)0x04 }; + byte[] A = { (byte)0x54, (byte)0x68, (byte)0x65, (byte)0x20, (byte)0x73, (byte)0x65, (byte)0x63, (byte)0x6f, (byte)0x6e, (byte)0x64, (byte)0x20, (byte)0x70, (byte)0x72, (byte)0x69, (byte)0x6e, (byte)0x63, + (byte)0x69, (byte)0x70, (byte)0x6c, (byte)0x65, (byte)0x20, (byte)0x6f, (byte)0x66, (byte)0x20, (byte)0x41, (byte)0x75, (byte)0x67, (byte)0x75, (byte)0x73, (byte)0x74, (byte)0x65, (byte)0x20, + (byte)0x4b, (byte)0x65, (byte)0x72, (byte)0x63, (byte)0x6b, (byte)0x68, (byte)0x6f, (byte)0x66, (byte)0x66, (byte)0x73 }; + byte[] E = { (byte)0x4a, (byte)0xff, (byte)0xaa, (byte)0xad, (byte)0xb7, (byte)0x8c, (byte)0x31, (byte)0xc5, (byte)0xda, (byte)0x4b, (byte)0x1b, (byte)0x59, (byte)0x0d, (byte)0x10, (byte)0xff, (byte)0xbd, + (byte)0x3d, (byte)0xd8, (byte)0xd5, (byte)0xd3, (byte)0x02, (byte)0x42, (byte)0x35, (byte)0x26, (byte)0x91, (byte)0x2d, (byte)0xa0, (byte)0x37, (byte)0xec, (byte)0xbc, (byte)0xc7, (byte)0xbd, + (byte)0x82, (byte)0x2c, (byte)0x30, (byte)0x1d, (byte)0xd6, (byte)0x7c, (byte)0x37, (byte)0x3b, (byte)0xcc, (byte)0xb5, (byte)0x84, (byte)0xad, (byte)0x3e, (byte)0x92, (byte)0x79, (byte)0xc2, + (byte)0xe6, (byte)0xd1, (byte)0x2a, (byte)0x13, (byte)0x74, (byte)0xb7, (byte)0x7f, (byte)0x07, (byte)0x75, (byte)0x53, (byte)0xdf, (byte)0x82, (byte)0x94, (byte)0x10, (byte)0x44, (byte)0x6b, + (byte)0x36, (byte)0xeb, (byte)0xd9, (byte)0x70, (byte)0x66, (byte)0x29, (byte)0x6a, (byte)0xe6, (byte)0x42, (byte)0x7e, (byte)0xa7, (byte)0x5c, (byte)0x2e, (byte)0x08, (byte)0x46, (byte)0xa1, + (byte)0x1a, (byte)0x09, (byte)0xcc, (byte)0xf5, (byte)0x37, (byte)0x0d, (byte)0xc8, (byte)0x0b, (byte)0xfe, (byte)0xcb, (byte)0xad, (byte)0x28, (byte)0xc7, (byte)0x3f, (byte)0x09, (byte)0xb3, + (byte)0xa3, (byte)0xb7, (byte)0x5e, (byte)0x66, (byte)0x2a, (byte)0x25, (byte)0x94, (byte)0x41, (byte)0x0a, (byte)0xe4, (byte)0x96, (byte)0xb2, (byte)0xe2, (byte)0xe6, (byte)0x60, (byte)0x9e, + (byte)0x31, (byte)0xe6, (byte)0xe0, (byte)0x2c, (byte)0xc8, (byte)0x37, (byte)0xf0, (byte)0x53, (byte)0xd2, (byte)0x1f, (byte)0x37, (byte)0xff, (byte)0x4f, (byte)0x51, (byte)0x95, (byte)0x0b, + (byte)0xbe, (byte)0x26, (byte)0x38, (byte)0xd0, (byte)0x9d, (byte)0xd7, (byte)0xa4, (byte)0x93, (byte)0x09, (byte)0x30, (byte)0x80, (byte)0x6d, (byte)0x07, (byte)0x03, (byte)0xb1, (byte)0xf6 }; + byte[] T = { (byte)0x4d, (byte)0xd3, (byte)0xb4, (byte)0xc0, (byte)0x88, (byte)0xa7, (byte)0xf4, (byte)0x5c, (byte)0x21, (byte)0x68, (byte)0x39, (byte)0x64, (byte)0x5b, (byte)0x20, (byte)0x12, (byte)0xbf, + (byte)0x2e, (byte)0x62, (byte)0x69, (byte)0xa8, (byte)0xc5, (byte)0x6a, (byte)0x81, (byte)0x6d, (byte)0xbc, (byte)0x1b, (byte)0x26, (byte)0x77, (byte)0x61, (byte)0x95, (byte)0x5b, (byte)0xc5 }; + + Aes256CbcHmacSha512 algo = new Aes256CbcHmacSha512(); + + IAuthenticatedCryptoTransform transform = null; + + byte[] encrypted = null; + byte[] tag = null; + + try { + transform = (IAuthenticatedCryptoTransform) algo.CreateEncryptor(K, IV, A, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + encrypted = transform.doFinal(P); + tag = transform.getTag(); + + assertArrayEquals(E, encrypted); + assertArrayEquals(T, tag); + + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + transform = (IAuthenticatedCryptoTransform)algo.CreateDecryptor(K, IV, A, _provider); + } catch (Exception e) { + fail(e.getMessage()); + } + + byte[] decrypted = null; + + try { + decrypted = transform.doFinal(encrypted); + tag = transform.getTag(); + } catch (Exception e) { + fail(e.getMessage()); + } + + // Assert + assertArrayEquals(P, decrypted); + assertArrayEquals(T, tag); + } } From 76421272dbd5b929d3e01699ca3f50b4ee8f055c Mon Sep 17 00:00:00 2001 From: alvadb Date: Thu, 22 Sep 2016 10:55:21 -0700 Subject: [PATCH 38/56] Removed annotation dependency from keyvault libs Removed annotation dependency from keyvault libs --- azure-keyvault-core/pom.xml | 24 ------------------------ azure-keyvault-cryptography/pom.xml | 27 --------------------------- azure-keyvault-extensions/pom.xml | 24 ------------------------ azure-keyvault-webkey/pom.xml | 24 ------------------------ azure-keyvault/pom.xml | 24 ------------------------ 5 files changed, 123 deletions(-) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index c9c06e52dfd5f..871785c62cdd4 100755 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -96,25 +96,6 @@
*/]]> - - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - - - com.microsoft.azure.management.apigeneration.LangDefinitionProcessor - - true - true - - true - true - - - - @@ -128,10 +109,5 @@ guava 18.0 - - com.microsoft.azure - api-annotations - 0.0.1-SNAPSHOT - diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index 54b8b9c347d02..b3e1236542df2 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -64,32 +64,5 @@ azure-keyvault-webkey ${project.version} - - com.microsoft.azure - api-annotations - 0.0.1-SNAPSHOT - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - - - com.microsoft.azure.management.apigeneration.LangDefinitionProcessor - - true - true - - true - true - - - - - diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index d333e5eeabd81..25cbfdf05c497 100755 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -103,11 +103,6 @@ guava 18.0 - - com.microsoft.azure - api-annotations - 0.0.1-SNAPSHOT - @@ -151,25 +146,6 @@
*/]]> - - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - - - com.microsoft.azure.management.apigeneration.LangDefinitionProcessor - - true - true - - true - true - - - -
diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml index 905f5eb09bf78..680dcbf3ae124 100644 --- a/azure-keyvault-webkey/pom.xml +++ b/azure-keyvault-webkey/pom.xml @@ -55,11 +55,6 @@ commons-codec commons-codec - - com.microsoft.azure - api-annotations - 0.0.1-SNAPSHOT - @@ -103,25 +98,6 @@
*/]]> - - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - - - com.microsoft.azure.management.apigeneration.LangDefinitionProcessor - - true - true - - true - true - - - -
diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index fa61aa7c7f5ea..9284ae5e29a10 100755 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -70,11 +70,6 @@ 1.0.0-SNAPSHOT test - - com.microsoft.azure - api-annotations - 0.0.1-SNAPSHOT - @@ -118,25 +113,6 @@
*/]]> - - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - - - com.microsoft.azure.management.apigeneration.LangDefinitionProcessor - - true - true - - true - true - - - -
From bd5555e27084109dd61fa9ac1791a166e75a63e4 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Wed, 14 Sep 2016 23:56:11 -0700 Subject: [PATCH 39/56] Adding more functionalities to JsonWebKey: AES key conversions, verify, equals, clear memory and tests. --- azure-keyvault-webkey/pom.xml | 13 + .../azure/keyvault/webkey/JsonWebKey.java | 261 +++++++++++++++++- .../webkey/test/AesValidationTests.java | 92 ++++++ .../webkey/test/ClearMemoryTests.java | 56 ++++ .../webkey/test/RsaHsmValidationTests.java | 45 +++ .../webkey/test/RsaValidationTests.java | 126 +++++++++ 6 files changed, 589 insertions(+), 4 deletions(-) create mode 100644 azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/AesValidationTests.java create mode 100644 azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/ClearMemoryTests.java create mode 100644 azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/RsaHsmValidationTests.java create mode 100644 azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/RsaValidationTests.java diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml index 680dcbf3ae124..de73c52ff25a4 100644 --- a/azure-keyvault-webkey/pom.xml +++ b/azure-keyvault-webkey/pom.xml @@ -55,6 +55,19 @@ commons-codec commons-codec + + + + junit + junit + test + + + com.google.guava + guava + 18.0 + test + diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java index 5d6dc8fe8b355..7ffce489d19e6 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java @@ -20,15 +20,22 @@ import java.security.spec.RSAPrivateKeySpec; import java.security.spec.RSAPublicKeySpec; import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; + +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.base.Objects; /** * As of http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18. @@ -401,7 +408,7 @@ public String toString() { */ private RSAPublicKeySpec getRSAPublicKeySpec() { - return new RSAPublicKeySpec(toBigInteger(n()), toBigInteger(e())); + return new RSAPublicKeySpec(toBigInteger(n), toBigInteger(e)); } /** @@ -411,8 +418,8 @@ private RSAPublicKeySpec getRSAPublicKeySpec() { */ private RSAPrivateKeySpec getRSAPrivateKeySpec() { - return new RSAPrivateCrtKeySpec(toBigInteger(n()), toBigInteger(e()), toBigInteger(d()), toBigInteger(p()), - toBigInteger(q()), toBigInteger(dp()), toBigInteger(dq()), toBigInteger(qi())); + return new RSAPrivateCrtKeySpec(toBigInteger(n), toBigInteger(e), toBigInteger(d), toBigInteger(p), + toBigInteger(q), toBigInteger(dp), toBigInteger(dq), toBigInteger(qi)); } /** @@ -455,7 +462,7 @@ private PrivateKey getRSAPrivateKey(Provider provider) { * Verifies if the key is an RSA key. */ private void checkRSACompatible() { - if (!JsonWebKeyType.RSA.equals(kty()) && !JsonWebKeyType.RSA_HSM.equals(kty())) { + if (!JsonWebKeyType.RSA.equals(kty) && !JsonWebKeyType.RSA_HSM.equals(kty)) { throw new UnsupportedOperationException("Not an RSA key"); } } @@ -557,4 +564,250 @@ public KeyPair toRSA(boolean includePrivateParameters, Provider provider) { return new KeyPair(getRSAPublicKey(provider), null); } } + + /** + * Converts AES key to JSON web key. + * @param secretKey AES key + * @return the JSON web key, converted from AES key. + */ + public static JsonWebKey fromAes(SecretKey secretKey) { + if(secretKey == null) { + return null; + } + + return new JsonWebKey() + .withK(secretKey.getEncoded()) + .withKty(JsonWebKeyType.OCT); + } + + /** + * Converts JSON web key to AES key. + * @return AES key + */ + public SecretKey toAes() { + if(k == null) { + return null; + } + + SecretKey secretKey = new SecretKeySpec(k, "AES"); + return secretKey; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof JsonWebKey) { + return this.equals((JsonWebKey) obj); + } + return super.equals(obj); + } + + /** + * Indicates whether some other {@link JsonWebKey} is "equal to" this one. + * @param jwk the other {@link JsonWebKey} to compare with. + * @return true if this {@link JsonWebKey} is the same as the jwk argument; false otherwise. + */ + public boolean equals(JsonWebKey jwk) { + if (jwk == null) { + return false; + } + + if(!Objects.equal(kid, jwk.kid)) { + return false; + } + + if (!Objects.equal(kty, jwk.kty)) { + return false; + } + + if (!Objects.equal(keyOps, jwk.keyOps)) { + return false; + } + + if (!Arrays.equals(k, jwk.k)) { + return false; + } + + // Public parameters + if (!Arrays.equals(n, jwk.n)) { + return false; + } + if (!Arrays.equals(e, jwk.e)) { + return false; + } + + // Private parameters + if (!Arrays.equals(d, jwk.d)) { + return false; + } + if (!Arrays.equals(dp, jwk.dp)) { + return false; + } + if (!Arrays.equals(dq, jwk.dq)) { + return false; + } + if (!Arrays.equals(qi, jwk.qi)) { + return false; + } + if (!Arrays.equals(p, jwk.p)) { + return false; + } + if (!Arrays.equals(q, jwk.q)) { + return false; + } + + // HSM token + if (!Arrays.equals(t, jwk.t)) { + return false; + } + + return true; + } + + /** + * Verifies whether the {@link JsonWebKey} has private key. + * @return true if the {@link JsonWebKey} has private key; false otherwise. + */ + public boolean hasPrivateKey() { + + if(JsonWebKeyType.OCT.equals(kty)) { + return k != null; + } + + else if(JsonWebKeyType.RSA.equals(kty) || JsonWebKeyType.RSA_HSM.equals(kty)) { + return (d != null && dp != null && dq != null && qi != null && p != null && q != null); + } + + return false; + } + + /** + * Verifies whether the {@link JsonWebKey} is valid. + * @return true if the {@link JsonWebKey} is valid; false otherwise. + */ + @JsonIgnore + public boolean isValid() { + if(kty == null) { + return false; + } + + if(keyOps != null) { + final Set set = new HashSet(JsonWebKeyOperation.ALL_OPERATIONS); + for(int i = 0; i < keyOps.size(); i++) { + if(!set.contains(keyOps.get(i))) + return false; + } + } + + if(JsonWebKeyType.OCT.equals(kty)) { + return isValidOctet(); + } + + else if(JsonWebKeyType.RSA.equals(kty)) { + return isValidRsa(); + } + + else if(JsonWebKeyType.RSA_HSM.equals(kty)) { + return isValidRsaHsm(); + } + return false; + } + + private boolean isValidOctet() { + if (k != null) { + return true; + } + return false; + } + + private boolean isValidRsa() { + if (n == null || e == null) { + return false; + } + + return hasPrivateKey() + || (d == null && dp == null && dq == null && qi == null && p == null && q == null); + } + + private boolean isValidRsaHsm() { + // MAY have public key parameters + if ((n == null && e != null) || (n != null && e == null)) { + return false; + } + + // no private key + if(hasPrivateKey()) { + return false; + } + + // MUST have ( T || ( N && E ) ) + boolean tokenParameters = t != null; + boolean publicParameters = (n != null && e != null); + + if (tokenParameters && publicParameters) { + return false; + } + + return (tokenParameters || publicParameters); + } + + /** + * Clear key materials. + */ + public void clearMemory() { + zeroArray(k); + zeroArray(n); + zeroArray(e); + zeroArray(d); + zeroArray(dp); + zeroArray(dq); + zeroArray(qi); + zeroArray(p); + zeroArray(q); + zeroArray(t); + k = n = e = d = dp = dq = qi = p = q = t = null; + } + + private static void zeroArray(byte[] bytes) { + if(bytes != null) { + Arrays.fill(bytes, (byte) 0); + } + } + + @Override + public int hashCode() { + int hashCode = 48313; // setting it to a random prime number + if(kid != null) { + hashCode += kid.hashCode(); + } + + if(JsonWebKeyType.OCT.equals(kty)) { + hashCode += hashCode(k); + } + + else if(JsonWebKeyType.RSA.equals(kty)) { + hashCode += hashCode(n); + } + + else if(JsonWebKeyType.RSA_HSM.equals(kty)) { + hashCode += hashCode(t); + } + + return hashCode; + } + + private static int hashCode(byte[] obj) { + int hashCode = 0; + + if(obj == null || obj.length == 0) { + return 0; + } + + for(int i = 0; i < obj.length; i += 1) { + hashCode = (hashCode << 3) | (hashCode >> 29) ^ obj [i]; + } + return hashCode; + } } \ No newline at end of file diff --git a/azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/AesValidationTests.java b/azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/AesValidationTests.java new file mode 100644 index 0000000000000..3d1ed2b07c77d --- /dev/null +++ b/azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/AesValidationTests.java @@ -0,0 +1,92 @@ +package com.microsoft.azure.keyvault.webkey.test; + +import java.util.Arrays; +import java.util.Random; + +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; + +import org.junit.Assert; +import org.junit.Test; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; + +public class AesValidationTests { + private static final String TRANSFORMATION = "AES"; + + @Test + public void aesKeyValidation() throws Exception { + KeyGenerator keyGen = KeyGenerator.getInstance(TRANSFORMATION); + keyGen.init(256); + + SecretKey skey = keyGen.generateKey(); + JsonWebKey key = serializeDeserialize(skey); + Assert.assertTrue(key.hasPrivateKey()); + Assert.assertTrue(key.isValid()); + + SecretKey secretKey = key.toAes(); + encryptDecrypt(secretKey); + + // Compare equal JSON web keys + JsonWebKey sameKey = JsonWebKey.fromAes(skey); + Assert.assertEquals(key, key); + Assert.assertEquals(key, sameKey); + Assert.assertEquals(key.hashCode(), sameKey.hashCode()); + } + + @Test + public void invalidKeyOps() throws Exception { + JsonWebKey key = getAes(); + key.withKeyOps(Arrays.asList(JsonWebKeyOperation.ENCRYPT, new JsonWebKeyOperation("foo"))); + Assert.assertFalse(key.isValid()); + } + + @Test + public void octHashCode() throws Exception { + JsonWebKey key = getAes(); + + // Compare hash codes for unequal JWK that would not map to the same hash + Assert.assertNotEquals(key.hashCode(), new JsonWebKey().withK(key.k()).hashCode()); + Assert.assertNotEquals(key.hashCode(), new JsonWebKey().withKty(key.kty()).hashCode()); + + // Compare hash codes for unequal JWK that would map to the same hash + Assert.assertEquals(key.hashCode(), new JsonWebKey().withK(key.k()).withKty(key.kty()).hashCode()); + } + + private static JsonWebKey getAes() throws Exception { + KeyGenerator keyGen = KeyGenerator.getInstance(TRANSFORMATION); + keyGen.init(256); + + SecretKey skey = keyGen.generateKey(); + return JsonWebKey.fromAes(skey); + } + + private static JsonWebKey serializeDeserialize(SecretKey skey) throws Exception { + JsonWebKey webKey = JsonWebKey.fromAes(skey); + String serializedKey = webKey.toString(); + ObjectMapper mapper = new ObjectMapper(); + return mapper.readValue(serializedKey, JsonWebKey.class); + } + + private static void encryptDecrypt(SecretKey key) throws Exception { + byte[] plaintext = new byte[10]; + new Random().nextBytes(plaintext); + byte[] cipherText = encrypt(key, plaintext); + Assert.assertArrayEquals(decrypt(key, cipherText), plaintext); + } + + private static byte[] encrypt(SecretKey key, byte[] plaintext) throws Exception { + Cipher cipher = Cipher.getInstance(TRANSFORMATION); + cipher.init(Cipher.ENCRYPT_MODE, key); + return cipher.doFinal(plaintext); + } + + private static byte[] decrypt(SecretKey key, byte[] ciphertext) throws Exception { + Cipher cipher = Cipher.getInstance(TRANSFORMATION); + cipher.init(Cipher.DECRYPT_MODE, key); + return cipher.doFinal(ciphertext); + } +} diff --git a/azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/ClearMemoryTests.java b/azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/ClearMemoryTests.java new file mode 100644 index 0000000000000..f28801584059a --- /dev/null +++ b/azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/ClearMemoryTests.java @@ -0,0 +1,56 @@ +package com.microsoft.azure.keyvault.webkey.test; + +import java.util.Random; + +import org.junit.Assert; +import org.junit.Test; + +import com.microsoft.azure.keyvault.webkey.JsonWebKey; + +public class ClearMemoryTests { + + @Test + public void clearMemory() + { + JsonWebKey key = new JsonWebKey() + .withD(getRandomByte()) + .withDp(getRandomByte()) + .withDq(getRandomByte()) + .withE(getRandomByte()) + .withK(getRandomByte()) + .withN(getRandomByte()) + .withP(getRandomByte()) + .withQ(getRandomByte()) + .withQi(getRandomByte()) + .withT(getRandomByte()); + key.clearMemory(); + Assert.assertNull(key.d()); + Assert.assertNull(key.dp()); + Assert.assertNull(key.dq()); + Assert.assertNull(key.e()); + Assert.assertNull(key.k()); + Assert.assertNull(key.n()); + Assert.assertNull(key.p()); + Assert.assertNull(key.q()); + Assert.assertNull(key.qi()); + Assert.assertNull(key.t()); + + // Compare it with a newly created JsonWebKey with no properties set. + JsonWebKey key2 = new JsonWebKey(); + Assert.assertTrue(key2.equals(key)); + } + + @Test + public void clearNullMemory() + { + JsonWebKey key = new JsonWebKey(); + key.clearMemory(); + } + + private static byte[] getRandomByte() { + byte[] bytes = new byte[10]; + new Random().nextBytes(bytes); + return bytes; + } + +} diff --git a/azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/RsaHsmValidationTests.java b/azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/RsaHsmValidationTests.java new file mode 100644 index 0000000000000..816db50104ae4 --- /dev/null +++ b/azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/RsaHsmValidationTests.java @@ -0,0 +1,45 @@ +package com.microsoft.azure.keyvault.webkey.test; + +import org.junit.Assert; +import org.junit.Test; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; + +public class RsaHsmValidationTests { + + String keyWithoutT = "{\"kid\":\"key_id\",\"kty\":\"RSA-HSM\",\"key_ops\":[\"encrypt\",\"decrypt\"],\"n\":\"1_6ZtP288hEkKML-L6nFyZh1PD1rmAgwbbwjEvTSDK_008BYWhjp_6ULy9BhWtRIytNkPkm9gzaBTrCpp-vyDXPGa836Htp-w8u5JmxoUZchJh576m3m-8ZYWTmZSAp5SpruyKAmLSxPJHEWPXQntnmuTMjb9HBT9Ltrwc0ZDk-jsMLYunDJrNmrRUxQgb0zQ_Tl5fJjj8j-0KVx2RXtbfWFvf5fRdBYyP3m0aUpoopQPwtXszD2LcSKMJ_TnmnvMWr8MOA5aRlBaGdBk7zBgRafvDPam3Q2AvFA9mfcAVncpfZ3JFm73VARw6MofXtRqOHtZ7y4oNbY95xXwU2r6w\",\"e\":\"AQAB\"}"; + String keyWithT = "{\"kid\":\"key_id\",\"kty\":\"RSA-HSM\",\"key_ops\":[\"encrypt\",\"decrypt\"],\"key_hsm\":\"T-TOKEN\"}"; + + @Test + public void rsaHsmValidation() throws Exception { + ObjectMapper mapper = new ObjectMapper(); + JsonWebKey keyNoT = mapper.readValue(keyWithoutT, JsonWebKey.class); + JsonWebKey keyT = mapper.readValue(keyWithT, JsonWebKey.class); + + Assert.assertTrue(keyNoT.isValid()); + Assert.assertFalse(keyNoT.hasPrivateKey()); + + Assert.assertTrue(keyT.isValid()); + Assert.assertFalse(keyT.hasPrivateKey()); + } + + @Test + public void rsaHsmHashCode() throws Exception { + ObjectMapper mapper = new ObjectMapper(); + JsonWebKey keyNoT = mapper.readValue(keyWithoutT, JsonWebKey.class); + JsonWebKey keyT = mapper.readValue(keyWithT, JsonWebKey.class); + + Assert.assertNotEquals(keyT.hashCode(), keyNoT.hashCode()); + + // Compare hash codes for unequal JWK that would not map to the same hash + Assert.assertNotEquals(keyT.hashCode(), new JsonWebKey().withKid(keyT.kid()).withT(keyT.t()).hashCode()); + Assert.assertNotEquals(keyT.hashCode(), new JsonWebKey().withKid(keyT.kid()).withKty(keyT.kty()).hashCode()); + Assert.assertNotEquals(keyNoT.hashCode(), new JsonWebKey().hashCode()); + + // Compare hash codes for unequal JWK that would map to the same hash + Assert.assertEquals(keyT.hashCode(), + new JsonWebKey().withKid(keyT.kid()).withKty(keyT.kty()).withT(keyT.t()).hashCode()); + Assert.assertEquals(keyNoT.hashCode(), new JsonWebKey().withKid(keyT.kid()).hashCode()); + } +} diff --git a/azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/RsaValidationTests.java b/azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/RsaValidationTests.java new file mode 100644 index 0000000000000..cb5bcb3de2282 --- /dev/null +++ b/azure-keyvault-webkey/src/test/java/com/microsoft/azure/keyvault/webkey/test/RsaValidationTests.java @@ -0,0 +1,126 @@ +package com.microsoft.azure.keyvault.webkey.test; + +import java.security.KeyPair; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.util.ArrayList; +import java.util.Map; +import java.util.Random; + +import javax.crypto.Cipher; + +import org.junit.Assert; +import org.junit.Test; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.ImmutableMap; +import com.microsoft.azure.keyvault.webkey.JsonWebKey; +import com.microsoft.azure.keyvault.webkey.JsonWebKeyOperation; + +public class RsaValidationTests { + + private static final String TRANSFORMATION = "RSA/ECB/PKCS1Padding"; + + @Test + public void rsaPublicKeyValidation() throws Exception { + for(String keyStr : keys.values()) + { + ObjectMapper mapper = new ObjectMapper(); + JsonWebKey key = mapper.readValue(keyStr, JsonWebKey.class); + Assert.assertTrue(key.hasPrivateKey()); + Assert.assertTrue(key.isValid()); + + KeyPair keyPair = key.toRSA(); + validateRsaKey(keyPair, key); + Assert.assertNull(keyPair.getPrivate()); + + // Compare equal JSON web keys + JsonWebKey sameKey = mapper.readValue(keyStr, JsonWebKey.class); + Assert.assertEquals(key, key); + Assert.assertEquals(key, sameKey); + Assert.assertEquals(key.hashCode(), sameKey.hashCode()); + } + } + + @Test + public void rsaPrivateKeyValidation() throws Exception { + for(String keyStr : keys.values()) + { + ObjectMapper mapper = new ObjectMapper(); + JsonWebKey key = mapper.readValue(keyStr, JsonWebKey.class); + + KeyPair keyPairWithPrivate = key.toRSA(true); + validateRsaKey(keyPairWithPrivate, key); + encryptDecrypt(keyPairWithPrivate.getPublic(), keyPairWithPrivate.getPrivate()); + } + } + + @Test + public void rsaHashCode() throws Exception { + + String keyStr = (String) keys.values().toArray()[0]; + ObjectMapper mapper = new ObjectMapper(); + JsonWebKey key = mapper.readValue(keyStr, JsonWebKey.class); + + // Compare hash codes for unequal JWK that would not map to the same hash + Assert.assertNotEquals(key.hashCode(), new JsonWebKey().withKid(key.kid()).withN(key.n()).hashCode()); + Assert.assertNotEquals(key.hashCode(), new JsonWebKey().withKid(key.kid()).withKty(key.kty()).hashCode()); + Assert.assertNotEquals(key.hashCode(), new JsonWebKey().withKid(key.kid()).withT(key.t()).hashCode()); + + // Compare hash codes for unequal JWK that would map to the same hash + Assert.assertEquals(key.hashCode(), + new JsonWebKey().withN(key.n()).withKty(key.kty()).withKid(key.kid()).hashCode()); + } + + private static void encryptDecrypt(PublicKey publicKey, PrivateKey privateKey) throws Exception { + byte[] plaintext = new byte[10]; + new Random().nextBytes(plaintext); + byte[] cipherText = encrypt(publicKey, plaintext); + if(privateKey != null) { + Assert.assertArrayEquals(decrypt(privateKey, cipherText), plaintext); + } + } + + private static byte[] encrypt(PublicKey key, byte[] plaintext) throws Exception { + Cipher cipher = Cipher.getInstance(TRANSFORMATION); + cipher.init(Cipher.ENCRYPT_MODE, key); + return cipher.doFinal(plaintext); + } + + private static byte[] decrypt(PrivateKey key, byte[] ciphertext) throws Exception { + Cipher cipher = Cipher.getInstance(TRANSFORMATION); + cipher.init(Cipher.DECRYPT_MODE, key); + return cipher.doFinal(ciphertext); + } + + private static void validateRsaKey(KeyPair keyPair, JsonWebKey key) throws Exception { + JsonWebKey jsonWebKey = JsonWebKey.fromRSA(keyPair); + boolean includePrivateKey = keyPair.getPrivate() != null; + KeyPair keyPair2 = jsonWebKey.toRSA(includePrivateKey); + + Assert.assertTrue(includePrivateKey == jsonWebKey.hasPrivateKey()); + + PublicKey publicKey = keyPair2.getPublic(); + PrivateKey privateKey = keyPair2.getPrivate(); + + if(includePrivateKey) { + Assert.assertNotNull(privateKey); + + // set the missing properties to compare the keys + jsonWebKey.withKeyOps(new ArrayList(key.keyOps())); + jsonWebKey.withKid(new String(key.kid())); + Assert.assertEquals(jsonWebKey, key); + Assert.assertEquals(key.hashCode(), jsonWebKey.hashCode()); + } + + encryptDecrypt(publicKey, privateKey); + } + + Map keys = ImmutableMap.builder() + .put(512, "{\"kty\":\"RSA\",\"n\":\"uOXIpiH9L0h_byTuP3fcMvKbfS85eTKvxW2skw4oIU2TM3ceFvlDwDK4gKHl4qE4z18bz0qrv9ElstOrT96piQ\",\"e\":\"AQAB\",\"d\":\"And2KMA5uQ1r9MwuvZCODi0D2lcFvz7oBbenyxqmuhTYfdGcuGE9FZg5V6ZcNwBK_eYGZqSwL1Gh2EmzG6AxwQ\",\"dp\":\"CEh8kzQnCRK97NKQeV_wGgWsLYlmgis7Cms85_DIqwE\",\"dq\":\"TAi0G0iE5pvMpiEN2y189hjSRSqE6Unc1lXaE3hcnWE\",\"qi\":\"2HhNqW3QBv1R_iEpu44KVMQs0DdnY5oWp1lH6hgPhXU\",\"p\":\"5BblSoMJmO5Afa-urQFzFpBfACt1175NMUs4tHUYEkE\",\"q\":\"z4Xdf_FU-51wTkW5mFJ6QoDK-GrkMXSdct9hdW26NUk\",\"key_ops\":[\"wrapKey\",\"unwrapKey\",\"encrypt\",\"decrypt\",\"sign\",\"verify\"],\"kid\":\"key_id\"}") + .put(1024, "{\"kty\":\"RSA\",\"n\":\"zicSNMeAUYwp6V6UQlJ8gW04o6O4ZJBIefsLnV6-to1YkzgDu6vDBWb83DcDgB2x63W-ZVK23F4dcJcULu1VM-jX83Sfg0b_ZrugiiXCnZ4iidLNcY5QOS1dSHjfI1eWH6QdLPSIE3sHk-BILrIXqoyIJH-LFxzMu--4bDlej2M\",\"e\":\"AQAB\",\"d\":\"A4h7F2YT6bhG2TXcJ9OiFQj6LFPLmG2gnSnGssiQHDDWXWLB-mvT-9O4CBr2ETJxFvsw0cVV8CqGXQrTaodGxOuCGNmYoczodvlhUBJyMBxAI2or5eZUF9jRiECvigoxNVWKsqWxypvq_X1pMfQbh9ot7F6KOJAEg6wlLTc-fIE\",\"dp\":\"v2JbDaZfi3OCCLMtNMjOxfNsBOPb1IqerGux4IR17fLIzG6JlcyaR4uasILdjE4VufqnppZ6FIlFCZUiyIP0GQ\",\"dq\":\"m6NTbNOxN2qnont_qttyqg6WvOA6zWK55-ZnX8hShmlv0ySgtw1PfOWso3wpRMHAujTOfUSeI14DgOLHLNkKtQ\",\"qi\":\"HOcBZfyxW1dSnghCvdTuKL3jLSww6k_v0jhYET32gyKe8od7uxP7w0dXZ8al4zQ3xGxrip9y7jJi0pjG-Z4uGw\",\"p\":\"6dlyTUBrwxLyLbr0X3yqmNu3VrHSt2zbW8jueZFWXPELlbuQ6EKrHoR39BM8MSjFN5PfZbsBhcqNBkqhitj6xw\",\"q\":\"4a4DOrnZt4423myMKmhgDINvIdNmLCHG0aE8UWcSPKO6RFhzHX46NJSoOuk9gvccMKEXOpcJC6P8b8ypN-OKhQ\",\"key_ops\":[\"wrapKey\",\"unwrapKey\",\"encrypt\",\"decrypt\",\"sign\",\"verify\"],\"kid\":\"key_id\"}") + .put(2048, "{\"kty\":\"RSA\",\"n\":\"rZ8pnmXkhfmmgNWVVdtNcYy2q0OAcCGIpeFzsN9URqJsiBEiWQfxlUxFTbM4kVWPqjauKt6byvApBGEeMA7Qs8kxwRVP-BD4orXRe9VPgliM92rH0UxQWHmCHUe7G7uUAFPwbiDVhWuFzELxNa6Kljg6Z9DuUKoddmQvlYWj8uSunofCtDi_zzlZKGYTOYJma5IYScHNww1yjLp8-b-Be2UdHbrPkCv6Nuwi6MVIKjPpEeRQgfefRmxDBJQKY3OfydMXZmEwukYXVkUcdIP8XwG2OxnfdRK0oAo0NDebNNVuT89k_3AyZLTr1KbDmx1nnjwa8uB8k-uLtcOC9igbTw\",\"e\":\"AQAB\",\"d\":\"H-z7hy_vVJ9yeZBMtIvt8qpQUK_J51STPwV085otcgud72tPKJXoW2658664ASl9kGwbnLBwb2G3-SEunuGqiNS_PGUB3niob6sFSUMRKsPDsB9HfPoOcCZvwZiWFGRqs6C7vlR1TuJVqRjKJ_ffbf4K51oo6FZPspx7j4AShLAwLUSQ60Ld5QPuxYMYZIMpdVbMVIVHJ26pR4Y18e_0GYmEGnbF5N0HkwqQmfmTiIK5aoGnD3GGgqHeHmWBwh6_WAq90ITLcX_zBeqQUgBSj-Z5v61SroO9Eang36T9mMoYrcPpYwemtAOb4HhQYDj8dCCfbeOcVmvZ9UJKWCX2oQ\",\"dp\":\"HW87UpwPoj3lPI9B9K1hJFeuGgarpakvtHuk1HpZ5hXWFGAJiXoWRV-jvYyjoM2k7RpSxPyuuFFmYHcIxiGFp2ES4HnP0BIhKVa2DyugUxIEcMK53C43Ub4mboJPZTSC3sapKgAmA2ue624sapWmshTPpx9qnUP2Oj3cSMkgMGE\",\"dq\":\"RhwEwb5FYio0GS2tmul8FAYsNH7JDehwI1yUApnTiakhSenFetml4PYyVkKR4csgLZEi3RY6J3R8Tg-36zrZuF7hxhVJn80L5_KETSpfEI3jcrXMVg4SRaMsWLY9Ahxflt2FJgUnHOmWRLmP6_hmaTcxxSACjbyUd_HhwNavD5E\",\"qi\":\"wYPZ4lKIslA1w3FaAzQifnNLABYXXUZ_KAA3a8T8fuxkdE4OP3xIFX7WHhnmBd6uOFiEcGoeq2jNQqDg91rV5661-5muQKcvp4uUsNId5rQw9EZw-kdDcwMtVFTEBfvVuyp83X974xYAHn1Jd8wWohSwrpi1QuH5cQMR5Fm6I1A\",\"p\":\"74Ot7MgxRu4euB31UWnGtrqYPjJmvbjYESS43jfDfo-s62ggV5a39P_YPg6oosgtGHNw0QDxunUOXNu9iriaYPf_imptRk69bKN8Nrl727Y-AaBYdLf1UZuwz8X07FqHAH5ghYpk79djld8QvkUUJLpx6rzcW8BJLTOi46DtzZE\",\"q\":\"uZJu-qenARIt28oj_Jlsk-p_KLnqdczczZfbRDd7XNp6csGLa8R0EyYqUB4xLWELQZsX4tAu9SaAO62tuuEy5wbOAmOVrq2ntoia1mGQSJdoeVq6OqtN300xVnaBc3us0rm8C6-824fEQ1PWXoulXLKcSqBhFT-hQahsYi-kat8\",\"key_ops\":[\"wrapKey\",\"unwrapKey\",\"encrypt\",\"decrypt\",\"sign\",\"verify\"],\"kid\":\"key_id\"}") + .put(3072, "{\"kty\":\"RSA\",\"n\":\"03u6K67VN18OzIRZdvCC8F9iOVojF-0kk03JQ7rfwumQMqgxLYOmLkrqLcyJV69XYt32LeEesuwuz_zJbQo9gg4T1pnKJSb-l5xoH1rfnihdc9PyMAH___d_zv3Zg9vdusg668eO1oqS5DtAe517suzwhcMIyCsFNx4aBxCDiPlEwzYISwMQHylt-4d6mbFsqJoGK14WqxTOyv0mLoeeDPs9gmQulGbyjYdZJgqjeRBMuHpXgjs_eMwHuqYmWr-jmbRMzBJpKoAgAJkDxkJzJ7wdf4Bq9HrutVspXqw9ZWh4ImIq65Rm5Mx3JDlUNdlYB0jMyDHpuwAZfr8shACty2d5bvlMnk7aYKngCbX2ZSm6BFInA4mz1eey9Iz8uxnfyEjwaYJCFRDy44P_8aymW4tsLoLYgWnF9NodxcLVbhJjBqsipYiUbvW6PUUB4SVtql4yI3EEcZsFFVAVOnms1sXGXK8vm9V9KU1RSWqF268jMD8s-QHg3a1WmooX6sw5\",\"e\":\"AQAB\",\"d\":\"WKU3m6DcmamcK-jcEUluMTBiHTUlmZ1a4-3Ki7vUmEBLo5gxiOjyatwW_dyKwzjpkbUFQCTpN8ldM-w7SBvvPUkGUsFC5MDMHaO_V0lBi2tTBL6V-T6VXmcRaSOpnaY28liErhkHS_Fo8gbOGCKiW5UKmp7uWu0BciGJemWXJP6LLqJC5qJhixZUFgcrQioHKELrjBkTumFt7tMewokxHDLhjPrONYFTcTSHDzWNYS0OY5NQg_OuvsUTBk8nq4lA2GSQqXyM-B2gbwG6pLSwccwu0x3Fd8qurxg6TSGQAjh69Iyb9ZwiHMsx3XLV95Jmqc0rcEbCzLZUBxX3daGjshw3Yd3pzEXqM8Mz-58p835VPhSMlZB_yvtP72o2QiKybhq1ob5Ygt7hqlqe08K5StN2rzJJoFkwivhfC3_KDX7XSLEK9PzqPaTOkkJu7y7tJgi6aC6Fq-X3fgeLy20LsBKV_SF4Zd323IZ713iGJFJo0f4mDUXfQmU3wrILk40L\",\"dp\":\"V5SlApD1a0ng5XrzEmOV2EVKVLcS7Z2j1WYLVa4BMxSsi8zJal_v8nllEN8ylDTWKCZt6Dg3fcHtOWKYGe7e2fBMwSsKcjPI2aFVHjI18ZMbC1m6eHWK81zlTQ-ZhgiRMXQvsRCX6Qt8PPvqfV4j-YILYfgJbQ_DRYEfJzq9JCQjFwGUiSoZvOBl9jQMM1u4NmOnvodwf8Jk4Oi1DC65U-CjOC7D07eDPNv74Pog6h6x3u7Z9S-ITvP1NX4h0_ot\",\"dq\":\"rg2IrHzp59w8nZbtd4NDk_stRB8xT6T2pxpH3LhNhEbLrmy0sF4Xemm8frlgRWeEn9dUV2nzveorEJF57bZ3cclEqBGtD72y_IRPZTPgDcYhc9l4xKJkJJuA3yWcQ6eHZHjLAZHi9PszYvFiUx1veHU2S_f7aGKjO14n05wb9r-YUmIKt7AVwK94HksflvNIREa867E2OL1lIJiX3azkyMgTnSHvi0bwgdIGp6uPdDwVW_qvvUmlFinDWflgq58\",\"qi\":\"Dw0f0UwU2KN98stNeuk2UVtG-GyKjCxSSYocGBlShsXzxeLn2faLSkkqhUVicW4o2PmedPDpxanDW2Gl7osamaPb25CodPS3JJxeHWrJ6hGBfKqvJnysZ-0zL8wVzwuNLc3VL-jlCudFfGK03MBapA9h3qjAFFhHZRgLH8y64MimARfh2gLldZ0FgNF9zB4yxmVzvpOng4XRJGzSBKdf9QbuL60Tia2rWR7QU2GtbrXlp4KiNZspZuzmBLZPaa82\",\"p\":\"3lnk-l3lG3ahUzPzhInjwTJEDRrAt0YMhpLmO444TNs0MD__RxRQO8EAhLGCuKaNJmKOg-D5-Fup34KBAcFKw1vCh06PNxoIbHmcY1KwrlA3M_47pK74sK532429sM2N0JH9ti4QjtcD85__THeS6I5g8x8xdSH6sm6ubOiUWUQ96fN10pDv-9D7PuoHGEGlndvsRE0GwWmBIjCnIbxXN4kQsE5YXbrY_WTdPXxwTb8F6Cqc2WXIuhZLlSqd8NjD\",\"q\":\"83zNQcd3dTEpO-j6e7hHeKYghVBhIViD6bXDzD3IX--maTnllGMD-xxHNzOURwl_VzwWo1Al_QQSKDMeEnNDXhSU50qbdhdyVDyRXQuR2Fb9hN5SACX-SiPgfs-2buJVZh8JD-VFSI7ou6eMQ9h-uIGnhoxH3vCs7dJgy-mHGPsvqTypaIo3LHGfM21z8h0yqgyYwaanv5UllaustjvRFId_2oWqNtrn6q410s9W5-6Q6xqkrW2m_lUffu7ViRdT\",\"key_ops\":[\"wrapKey\",\"unwrapKey\",\"encrypt\",\"decrypt\",\"sign\",\"verify\"],\"kid\":\"key_id\"}") + .put(4096, "{\"kty\":\"RSA\",\"n\":\"mmpRerSZYY4Xx_s89Qn3NMAmJOW0TXtddwjdTedA2CITP_BQW9Q6K7ZEKcAk5W8KwfvAYEIDkWN0iKtoSiBmTJxgCqpDI2MO1D_JJXFP6Tovbtgj1FJ8Ai90w04wmxoCdS9mFC2tE51qUWO7frJpTGrZqVAB8UMH031c3pUPzWedGRvKwj7J-Awtg_IoByaK-qoyRlwfqm8WpHjg6R6Fn1aJY3Fp62l1F3XGayUgqoJmg0_YzYxKpz9WDqIJo15sbyQEpTG6kRybD8T5O8908JU2d3KPp7GOKDNpai5wdaK50QyvaU3BtvKI35IaK367FSVPEZPEoAGgUBCoLXx8N16XHVgjspSMV6NnjBEoehr4xU3nw4cZ-09yZSXJv5FGKmg4pkJGCHQwUfA3XlWNZSPYIgBByyjpMe6gJt_RDBhkkYGVddkwn4HPlMIk3Gi9wzMLuVcLNVeq5k4Us3YsaXdSPI6LSfoosu7mi8qm2JMYlFzbB9_FaxJWqgHlTRSiXX0XNuHPMJoBHtKwh_7VXxiosim8EvszF_Is1ttF77l5lC198slQ5zsZ2XM90Ln9UV04kAyI1jEegDiW37uVSikt-VKyVKSZg5lgmp16CevLnqD2g_YD6fJMmbU4QmeVELhZeQc7Z_XGH7lM1bSeiAJ0dKlDKDURnA0h2LQfquM\",\"e\":\"AQAB\",\"d\":\"D_CvEz5WzGihW9Y7p1qtV5deWKtoaXc1YXcGIWdLR68nfY-OkWw0dRQOWqD92LwVyDX3g02ilfzw_WAfFp0xnPGnmHJAbAQVy83_MwuiIYQNfCEj0bnnbfJS2LaBngFEBQTXl3hU8ulqcuxwtoDZuIxvMQ3pUBaIqvRjWeGEDW2Hch1vA45ScHYRXMWVYZJBAToAkUgr8f7LFOoa4vXGUCSGxOqNnJejrBWkXfsp3BrfVOmGipwo42BOae71lRUc7HwzXo-Q9YSWcpJK3Y8U60umoRNacQfgkkB8aVGnRP1_YRfbeRYQdpT4PDFrh4Hq83aJKwSuD4vGGNMfXqgIdSWhREajFDN653gDIIrt1BPh-snE9HIr0QWJmGQTlKTFfXMEoHx6mxJgUmzZSdQ9BkfCYyInpevh2piUrdpoAEEBapYyTmEHetutMm6cpPd4EK7-yHf3f1k1Rx-HIkiN-pLPiy6x6sRS-272pRNJUjEyRr7QIxgv2rVmQpFd3HZIsmTA9e5HnEH88pbwzqckWeA8nCpe6vr9uJ5MkIMaZq1Exw2bL8TjezbQdRvFm6eO25ECBE_YRuTm72hWfkn1Aocz5_RrSvW6gjwXpgTB6ScNyDrrmo9Kz8DQA7uvRvwhS48fceGGqEt_02qtj_FY1e8Q-XLVsPz-oafqbrTPI0E\",\"dp\":\"D9PGN8qEoUjBFIDKfuilcKwpU25pLnGsgnlzXxORZYB2T1y_DzHVXoSFkcOcFfn2L-AWFSUQmFlt37ULSoSTi2J5KzeydzXfkz4CauzqyEEyv1Uu_FBM6ZDb14ZkYoS8B_vWx7ow99fopwwObs5LH9vtGmiAJczVTNuwUQd_8uRXsWdoy2Ku8XLmNBaxvpXjzbs3ooKIw450PWB1qk455OrQ0k2dqrbY5VlOjgBEk317yCamGbPy2AgC4EnXnAZ0qJ5gN-mJNbjBCjkS0MImMWphJCrXkKMxl1OURKW_ujb7B5EGXcTmJuFxu8uE6_SxDrhmbCfdrwnfVdQXIGyGsw\",\"dq\":\"xEmqiGWKIuuyMX3wElvw2E_qJfuJ58lyAqQOYrM8ROsk4iaV9yc9G57pHsLRdiCYYrYDoisi96LdJ6kScAcS8j5TAuAdHq2riI0MOd-lZr6I4S_3pnjO3SuHYmCoFagnpIo7QM9-l2ZguDrfCjs7PtQZqMWSg-ncHYrHDsbynhe9GPdes01u4XZ3Y2xoYBDJX2iCXVNKJBUeYwlLd01p4eE1O_UkI8GdxQDMOr0ifOjWa9HtmY13Q8yvWoDtA4UX9Ec83mB3F2RWi4b-0C1pxSifCzeo4VZ0uOZ_aR4ZKfx7npWseE6F-Ue2vPx3qnfZQAkXaqJPsR15ZU0ZtJqAEQ\",\"qi\":\"fzpgNvwBpXBjLkqVkKnGD20kTR1lnMfXKJHk_iGE3UY7FVRSGXiUWpRWo-Gh0Lq8jJVXddX3looqv-v_9uKHja2JkHToWSkJajRznFHvz1pMfs7d3Nr4puumuNxJC1rgktnOIK4eikNxxHJ5Rs6TeQOwWxRbmywMiEeUQAwVvgaaF91g8FmNUE4C2BCpav-1fKkr_ydo1j4AgcSaCcKuywPBvp2Fznf4UcND_1vyZVKhSBbqbu6ql8vb9zEo3E8AKsrn9REji0BnA5kHk1Ps7GiQcMSCdazwBq1kw3DYD5Mt4CuyOdg6Btg-MVDXLLS0Dw0VEvcPhi7ypUlpl0RWcQ\",\"p\":\"uFaIjld13k5EkpQtTJ6zw9Zq5QJwaVBu1RiyXTdji8ysU6rxk07HAsUt049BuKqFv2jdKVDsdL25WkIao93hstdl8Kl_7XQX491_1np1hW-NvapNUYo5UUn-SeT4zseoIu8n-GarEAI00U8Xj2M4pewd82zlCQHTCXZiwbWGF2XMfPqvpYhFtEoMyJUf8z6qCvcZgp-neJJNbLgesspHke8--GwYN-QjrUynkmUGZ14BQdnLsmNLeaWY7A92sLSOFYVK8XnXSzOUld2P5JCgTenS5Na5UpuaY1K8od8rci3TE23Gtma5VhqBiPOFgPXmlkpkBe1uRn84iV5avYQfdw\",\"q\":\"1nHaNzR3mE6cyzPqsqNxT_FDDzMXHCmxW8cO_9GzmFBW6MhNArPEIV9BFAo-NRjDKMYKPin67MlyiLCMN-TWTayeNeuvw_WYwKfI_t9xuyf1nsW-TsNoK4n2d0kwoB5OEH9pAtQKv9rSZl4WULePldJBF4lPBhQb0lmRu-HB_SRskZe8CdDcm-gjwLhoP76gstWN5PNzgrPTpxBC6tHdWD-ZbkzIGWzCjxNHAnJkUAEsy3FVllCtO4pMVXz3zupaVzmDlUQ34weWXqkA-C7QgUPNoCD_M7PTNJKQpnTwlgk1Jvn8v4FDrpmYvv5l8B9swMPtlIi9xADuuEg8gO5i9Q\",\"key_ops\":[\"wrapKey\",\"unwrapKey\",\"encrypt\",\"decrypt\",\"sign\",\"verify\"],\"kid\":\"key_id\"}") + .build(); +} From 8740e2c5b8deed992adc01ca440ea16e577dd713 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Fri, 23 Sep 2016 14:07:08 -0700 Subject: [PATCH 40/56] Change IssuerReference to IssuerParameters and adding CertificateType. --- azure-keyvault-webkey/pom.xml | 11 ++- .../azure/keyvault/webkey/JsonWebKey.java | 64 ++++++++--------- .../azure/keyvault/KeyVaultClientImpl.java | 1 + .../authentication/KeyVaultCredentials.java | 4 +- .../keyvault/models/CertificateOperation.java | 20 +++--- .../keyvault/models/CertificatePolicy.java | 20 +++--- .../keyvault/models/IssuerParameters.java | 71 +++++++++++++++++++ .../keyvault/models/IssuerReference.java | 44 ------------ .../models/KeyVaultErrorException.java | 10 --- .../requests/CreateCertificateRequest.java | 6 +- .../requests/ImportCertificateRequest.java | 6 +- .../UpdateCertificatePolicyRequest.java | 6 +- .../requests/UpdateCertificateRequest.java | 6 +- .../keyvault/test/AsyncOperationsTest.java | 4 +- .../test/CertificateOperationsTest.java | 46 ++++++------ .../keyvault/test/KeyOperationsTest.java | 2 + .../keyvault/test/SecretOperationsTest.java | 12 ++++ 17 files changed, 182 insertions(+), 151 deletions(-) create mode 100644 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerParameters.java delete mode 100755 azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml index de73c52ff25a4..31aca33de3b28 100644 --- a/azure-keyvault-webkey/pom.xml +++ b/azure-keyvault-webkey/pom.xml @@ -55,6 +55,11 @@ commons-codec commons-codec + + com.google.guava + guava + 18.0 + @@ -62,12 +67,6 @@ junit test - - com.google.guava - guava - 18.0 - test - diff --git a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java index 7ffce489d19e6..4e6ad1fd67d92 100755 --- a/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java +++ b/azure-keyvault-webkey/src/main/java/com/microsoft/azure/keyvault/webkey/JsonWebKey.java @@ -571,7 +571,7 @@ public KeyPair toRSA(boolean includePrivateParameters, Provider provider) { * @return the JSON web key, converted from AES key. */ public static JsonWebKey fromAes(SecretKey secretKey) { - if(secretKey == null) { + if (secretKey == null) { return null; } @@ -585,7 +585,7 @@ public static JsonWebKey fromAes(SecretKey secretKey) { * @return AES key */ public SecretKey toAes() { - if(k == null) { + if (k == null) { return null; } @@ -614,7 +614,7 @@ public boolean equals(JsonWebKey jwk) { return false; } - if(!Objects.equal(kid, jwk.kid)) { + if (!Objects.equal(kid, jwk.kid)) { return false; } @@ -672,11 +672,11 @@ public boolean equals(JsonWebKey jwk) { */ public boolean hasPrivateKey() { - if(JsonWebKeyType.OCT.equals(kty)) { + if (JsonWebKeyType.OCT.equals(kty)) { return k != null; } - else if(JsonWebKeyType.RSA.equals(kty) || JsonWebKeyType.RSA_HSM.equals(kty)) { + else if (JsonWebKeyType.RSA.equals(kty) || JsonWebKeyType.RSA_HSM.equals(kty)) { return (d != null && dp != null && dq != null && qi != null && p != null && q != null); } @@ -689,27 +689,28 @@ else if(JsonWebKeyType.RSA.equals(kty) || JsonWebKeyType.RSA_HSM.equals(kty)) { */ @JsonIgnore public boolean isValid() { - if(kty == null) { + if (kty == null) { return false; } - if(keyOps != null) { + if (keyOps != null) { final Set set = new HashSet(JsonWebKeyOperation.ALL_OPERATIONS); - for(int i = 0; i < keyOps.size(); i++) { - if(!set.contains(keyOps.get(i))) + for (int i = 0; i < keyOps.size(); i++) { + if (!set.contains(keyOps.get(i))) { return false; + } } } - if(JsonWebKeyType.OCT.equals(kty)) { + if (JsonWebKeyType.OCT.equals(kty)) { return isValidOctet(); } - else if(JsonWebKeyType.RSA.equals(kty)) { + else if (JsonWebKeyType.RSA.equals(kty)) { return isValidRsa(); } - else if(JsonWebKeyType.RSA_HSM.equals(kty)) { + else if (JsonWebKeyType.RSA_HSM.equals(kty)) { return isValidRsaHsm(); } return false; @@ -738,7 +739,7 @@ private boolean isValidRsaHsm() { } // no private key - if(hasPrivateKey()) { + if (hasPrivateKey()) { return false; } @@ -757,21 +758,20 @@ private boolean isValidRsaHsm() { * Clear key materials. */ public void clearMemory() { - zeroArray(k); - zeroArray(n); - zeroArray(e); - zeroArray(d); - zeroArray(dp); - zeroArray(dq); - zeroArray(qi); - zeroArray(p); - zeroArray(q); - zeroArray(t); - k = n = e = d = dp = dq = qi = p = q = t = null; + zeroArray(k); k = null; + zeroArray(n); n = null; + zeroArray(e); e = null; + zeroArray(d); d = null; + zeroArray(dp); dp = null; + zeroArray(dq); dq = null; + zeroArray(qi); qi = null; + zeroArray(p); p = null; + zeroArray(q); q = null; + zeroArray(t); t = null; } private static void zeroArray(byte[] bytes) { - if(bytes != null) { + if (bytes != null) { Arrays.fill(bytes, (byte) 0); } } @@ -779,19 +779,19 @@ private static void zeroArray(byte[] bytes) { @Override public int hashCode() { int hashCode = 48313; // setting it to a random prime number - if(kid != null) { + if (kid != null) { hashCode += kid.hashCode(); } - if(JsonWebKeyType.OCT.equals(kty)) { + if (JsonWebKeyType.OCT.equals(kty)) { hashCode += hashCode(k); } - else if(JsonWebKeyType.RSA.equals(kty)) { + else if (JsonWebKeyType.RSA.equals(kty)) { hashCode += hashCode(n); } - else if(JsonWebKeyType.RSA_HSM.equals(kty)) { + else if (JsonWebKeyType.RSA_HSM.equals(kty)) { hashCode += hashCode(t); } @@ -801,12 +801,12 @@ else if(JsonWebKeyType.RSA_HSM.equals(kty)) { private static int hashCode(byte[] obj) { int hashCode = 0; - if(obj == null || obj.length == 0) { + if (obj == null || obj.length == 0) { return 0; } - for(int i = 0; i < obj.length; i += 1) { - hashCode = (hashCode << 3) | (hashCode >> 29) ^ obj [i]; + for (int i = 0; i < obj.length; i++) { + hashCode = (hashCode << 3) | (hashCode >> 29) ^ obj[i]; } return hashCode; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index bfafedeedfcc8..854e41f4a06c9 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -818,6 +818,7 @@ public Observable> importKeyWithServiceResponseAsync( if (key == null) { throw new IllegalArgumentException("Parameter key is required and cannot be null."); } + Validator.validate(key); Validator.validate(keyAttributes); Validator.validate(tags); KeyImportParameters parameters = new KeyImportParameters(); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java index 9c184cb7cea5b..b10d3a6c287b8 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/authentication/KeyVaultCredentials.java @@ -122,7 +122,7 @@ private String getAuthenticationCredentials(Map challengeMap) { * the authentication challenge name. * @return a challenge map. */ - private Map extractChallenge(String authenticateHeader, String authChallengePrefix) { + private static Map extractChallenge(String authenticateHeader, String authChallengePrefix) { if (!isValidChallenge(authenticateHeader, authChallengePrefix)) { return null; } @@ -147,7 +147,7 @@ private Map extractChallenge(String authenticateHeader, String a * the authentication challenge name. * @return */ - private boolean isValidChallenge(String authenticateHeader, String authChallengePrefix) { + private static boolean isValidChallenge(String authenticateHeader, String authChallengePrefix) { if (authenticateHeader != null && !authenticateHeader.isEmpty() && authenticateHeader.toLowerCase().startsWith(authChallengePrefix.toLowerCase())) { return true; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java index 02fd132ae9754..1cf79183ef3d5 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java @@ -30,10 +30,10 @@ public class CertificateOperation { private String id; /** - * Reference to the issuer of the X509 component of a certificate. + * Parameters for the issuer of the X509 component of a certificate. */ @JsonProperty(value = "issuer") - private IssuerReference issuerReference; + private IssuerParameters issuerParameters; /** * The Certificate Signing Request (CSR) that is being used in the @@ -84,22 +84,22 @@ public String id() { } /** - * Get the issuerReference value. + * Get the issuerParameters value. * - * @return the issuerReference value + * @return the issuerParameters value */ - public IssuerReference issuerReference() { - return this.issuerReference; + public IssuerParameters issuerParameters() { + return this.issuerParameters; } /** - * Set the issuerReference value. + * Set the issuerParameters value. * - * @param issuerReference the issuerReference value to set + * @param issuerParameters the issuerParameters value to set * @return the CertificateOperation object itself. */ - public CertificateOperation withIssuerReference(IssuerReference issuerReference) { - this.issuerReference = issuerReference; + public CertificateOperation withIssuerParameters(IssuerParameters issuerParameters) { + this.issuerParameters = issuerParameters; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java index 6243eb4a805e4..7fa34dc9aa7b2 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java @@ -49,10 +49,10 @@ public class CertificatePolicy { private List lifetimeActions; /** - * Reference to the issuer of the X509 component of a certificate. + * Parameters for the issuer of the X509 component of a certificate. */ @JsonProperty(value = "issuer") - private IssuerReference issuerReference; + private IssuerParameters issuerParameters; /** * The certificate attributes. @@ -149,22 +149,22 @@ public CertificatePolicy withLifetimeActions(List lifetimeAction } /** - * Get the issuerReference value. + * Get the issuerParameters value. * - * @return the issuerReference value + * @return the issuerParameters value */ - public IssuerReference issuerReference() { - return this.issuerReference; + public IssuerParameters issuerParameters() { + return this.issuerParameters; } /** - * Set the issuerReference value. + * Set the issuerParameters value. * - * @param issuerReference the issuerReference value to set + * @param issuerParameters the issuerParameters value to set * @return the CertificatePolicy object itself. */ - public CertificatePolicy withIssuerReference(IssuerReference issuerReference) { - this.issuerReference = issuerReference; + public CertificatePolicy withIssuerParameters(IssuerParameters issuerParameters) { + this.issuerParameters = issuerParameters; return this; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerParameters.java new file mode 100644 index 0000000000000..826f3692c34c4 --- /dev/null +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerParameters.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package com.microsoft.azure.keyvault.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Parameters for the issuer of the X509 component of a certificate. + */ +public class IssuerParameters { + /** + * Name of the referenced issuer object or reserved names e.g. 'Self', + * 'Unknown'. + */ + private String name; + + /** + * Type of certificate to be requested from the issuer provider. + */ + @JsonProperty(value = "cty") + private String certificateType; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the IssuerParameters object itself. + */ + public IssuerParameters withName(String name) { + this.name = name; + return this; + } + + /** + * Get the certificateType value. + * + * @return the certificateType value + */ + public String certificateType() { + return this.certificateType; + } + + /** + * Set the certificateType value. + * + * @param certificateType the certificateType value to set + * @return the IssuerParameters object itself. + */ + public IssuerParameters withCertificateType(String certificateType) { + this.certificateType = certificateType; + return this; + } + +} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java deleted file mode 100755 index c2aa1dbe1f77e..0000000000000 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerReference.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 - * Changes may cause incorrect behavior and will be lost if the code is - * regenerated. - */ - -package com.microsoft.azure.keyvault.models; - - -/** - * Reference to the issuer of the X509 component of a certificate. - */ -public class IssuerReference { - /** - * Name of the referenced issuer object or reserved names e.g. 'Self', - * 'Unknown'. - */ - private String name; - - /** - * Get the name value. - * - * @return the name value - */ - public String name() { - return this.name; - } - - /** - * Set the name value. - * - * @param name the name value to set - * @return the IssuerReference object itself. - */ - public IssuerReference withName(String name) { - this.name = name; - return this; - } - -} diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java index 796e35e8da3c6..bdcfc617fc14c 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java @@ -29,16 +29,6 @@ public class KeyVaultErrorException extends RestException { * Initializes a new instance of the KeyVaultErrorException class. */ public KeyVaultErrorException() { } - - @Override - public String getMessage() { - if (body != null && body.error() != null - && body.error().message() != null - && !body.error().message().isEmpty()) { - return body.error().message(); - } - return super.getMessage(); - } /** * Initializes a new instance of the KeyVaultErrorException class. * diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java index 84900c5ae2143..6237eed6ce75d 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/CreateCertificateRequest.java @@ -7,7 +7,7 @@ import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificatePolicy; -import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.IssuerParameters; import com.microsoft.azure.keyvault.models.KeyProperties; import com.microsoft.azure.keyvault.models.LifetimeAction; import com.microsoft.azure.keyvault.models.SecretProperties; @@ -118,9 +118,9 @@ private CreateCertificateRequest(Builder builder) { .withExpires(builder.policy.attributes().expires()) .withNotBefore(builder.policy.attributes().notBefore())); } - if (builder.policy.issuerReference() != null) { + if (builder.policy.issuerParameters() != null) { certificatePolicy - .withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); + .withIssuerParameters(new IssuerParameters().withName(builder.policy.issuerParameters().name())); } if (builder.policy.x509CertificateProperties() != null) { certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java index 431c595ca9709..715ffa5d245a6 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/ImportCertificateRequest.java @@ -7,7 +7,7 @@ import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificatePolicy; -import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.IssuerParameters; import com.microsoft.azure.keyvault.models.KeyProperties; import com.microsoft.azure.keyvault.models.LifetimeAction; import com.microsoft.azure.keyvault.models.SecretProperties; @@ -141,9 +141,9 @@ private ImportCertificateRequest(Builder builder) { .withExpires(builder.policy.attributes().expires()) .withNotBefore(builder.policy.attributes().notBefore())); } - if (builder.policy.issuerReference() != null) { + if (builder.policy.issuerParameters() != null) { certificatePolicy - .withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); + .withIssuerParameters(new IssuerParameters().withName(builder.policy.issuerParameters().name())); } if (builder.policy.x509CertificateProperties() != null) { certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java index ea155328ece75..eb783686250a0 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificatePolicyRequest.java @@ -4,7 +4,7 @@ import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificatePolicy; -import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.IssuerParameters; import com.microsoft.azure.keyvault.models.KeyProperties; import com.microsoft.azure.keyvault.models.LifetimeAction; import com.microsoft.azure.keyvault.models.SecretProperties; @@ -78,9 +78,9 @@ private UpdateCertificatePolicyRequest(Builder builder) { .withExpires(builder.policy.attributes().expires()) .withNotBefore(builder.policy.attributes().notBefore())); } - if (builder.policy.issuerReference() != null) { + if (builder.policy.issuerParameters() != null) { certificatePolicy - .withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); + .withIssuerParameters(new IssuerParameters().withName(builder.policy.issuerParameters().name())); } if (builder.policy.x509CertificateProperties() != null) { certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java index b1403613b462d..556fecdc57e5d 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/requests/UpdateCertificateRequest.java @@ -7,7 +7,7 @@ import com.microsoft.azure.keyvault.models.Attributes; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificatePolicy; -import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.IssuerParameters; import com.microsoft.azure.keyvault.models.KeyProperties; import com.microsoft.azure.keyvault.models.LifetimeAction; import com.microsoft.azure.keyvault.models.SecretProperties; @@ -139,9 +139,9 @@ private UpdateCertificateRequest(Builder builder) { .withExpires(builder.policy.attributes().expires()) .withNotBefore(builder.policy.attributes().notBefore())); } - if (builder.policy.issuerReference() != null) { + if (builder.policy.issuerParameters() != null) { certificatePolicy - .withIssuerReference(new IssuerReference().withName(builder.policy.issuerReference().name())); + .withIssuerParameters(new IssuerParameters().withName(builder.policy.issuerParameters().name())); } if (builder.policy.x509CertificateProperties() != null) { certificatePolicy.withX509CertificateProperties(new X509CertificateProperties() diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java index 878603707842f..70a221d188afa 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -24,7 +24,7 @@ import com.microsoft.azure.keyvault.models.CertificatePolicy; import com.microsoft.azure.keyvault.models.Contacts; import com.microsoft.azure.keyvault.models.IssuerBundle; -import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.IssuerParameters; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyItem; import com.microsoft.azure.keyvault.models.KeyOperationResult; @@ -174,7 +174,7 @@ public void certificateAsync() throws Exception { .Builder(vault, certificateName) .withPolicy(new CertificatePolicy() .withSecretProperties(new SecretProperties().withContentType("application/x-pkcs12")) - .withIssuerReference(new IssuerReference().withName("Self")) + .withIssuerParameters(new IssuerParameters().withName("Self")) .withX509CertificateProperties(new X509CertificateProperties() .withSubject("CN=SelfSignedJavaPkcs12") .withValidityInMonths(12))) diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index 833f167d399ff..e752f02f22cec 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -55,7 +55,7 @@ import com.microsoft.azure.keyvault.models.Contacts; import com.microsoft.azure.keyvault.models.IssuerBundle; import com.microsoft.azure.keyvault.models.IssuerCredentials; -import com.microsoft.azure.keyvault.models.IssuerReference; +import com.microsoft.azure.keyvault.models.IssuerParameters; import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.OrganizationDetails; @@ -126,12 +126,12 @@ public void createSelfSignedCertificatePkcs12() throws Exception { .withValidityInMonths(12); // Set issuer to "Self" - IssuerReference issuerReference = new IssuerReference() + IssuerParameters issuerParameters = new IssuerParameters() .withName(ISSUER_SELF); CertificatePolicy certificatePolicy = new CertificatePolicy() .withSecretProperties(secretProperties) - .withIssuerReference(issuerReference) + .withIssuerParameters(issuerParameters) .withX509CertificateProperties(x509Properties); Attributes attribute = new CertificateAttributes() @@ -210,12 +210,12 @@ public void createSelfSignedCertificatePem() throws Exception { .withValidityInMonths(12); // Set issuer to "Self" - IssuerReference issuerReference = new IssuerReference() + IssuerParameters issuerParameters = new IssuerParameters() .withName(ISSUER_SELF); CertificatePolicy certificatePolicy = new CertificatePolicy() .withSecretProperties(secretProperties) - .withIssuerReference(issuerReference) + .withIssuerParameters(issuerParameters) .withX509CertificateProperties(x509Properties); String vaultUri = getVaultUri(); @@ -291,12 +291,12 @@ public void createCertificatePkcs12() throws Exception { .withValidityInMonths(12); // Set issuer reference to the created issuer - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(createdCertificateIssuer.issuerIdentifier().name()); + IssuerParameters issuerParameters = new IssuerParameters(); + issuerParameters.withName(createdCertificateIssuer.issuerIdentifier().name()); CertificatePolicy certificatePolicy = new CertificatePolicy() .withSecretProperties(secretProperties) - .withIssuerReference(issuerReference) + .withIssuerParameters(issuerParameters) .withX509CertificateProperties(x509Properties); String vaultUri = getVaultUri(); @@ -387,12 +387,12 @@ public void createCertificatePem() throws Exception { x509Properties.withValidityInMonths(12); // Set issuer reference to the created issuer - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(createdCertificateIssuer.issuerIdentifier().name()); + IssuerParameters issuerParameters = new IssuerParameters(); + issuerParameters.withName(createdCertificateIssuer.issuerIdentifier().name()); CertificatePolicy certificatePolicy = new CertificatePolicy() .withSecretProperties(secretProperties) - .withIssuerReference(issuerReference) + .withIssuerParameters(issuerParameters) .withX509CertificateProperties(x509Properties); String vaultUri = getVaultUri(); @@ -444,12 +444,12 @@ public void createCsr() throws InterruptedException, ExecutionException, KeyVaul x509Properties.withValidityInMonths(12); // Set issuer to "Unknown" - IssuerReference issuerReference = new IssuerReference(); - issuerReference.withName(ISSUER_UNKNOWN); + IssuerParameters issuerParameters = new IssuerParameters(); + issuerParameters.withName(ISSUER_UNKNOWN); CertificatePolicy certificatePolicy = new CertificatePolicy() .withSecretProperties(secretProperties) - .withIssuerReference(issuerReference) + .withIssuerParameters(issuerParameters) .withX509CertificateProperties(x509Properties); String vaultUri = getVaultUri(); @@ -497,12 +497,12 @@ public void certificateAsyncRequestCancellation() throws KeyVaultErrorException, .withValidityInMonths(12); // Set issuer to "Self" - IssuerReference issuerReference = new IssuerReference() + IssuerParameters issuerParameters = new IssuerParameters() .withName(ISSUER_SELF); CertificatePolicy certificatePolicy = new CertificatePolicy() .withSecretProperties(secretProperties) - .withIssuerReference(issuerReference) + .withIssuerParameters(issuerParameters) .withX509CertificateProperties(x509Properties); String vaultUri = getVaultUri(); @@ -616,16 +616,16 @@ public void certificateUpdate() throws Exception { Assert.assertEquals(attribute.enabled(), updatedCertBundle.attributes().enabled()); Assert.assertEquals(sTags.toString(), updatedCertBundle.tags().toString()); - CertificatePolicy certificatePolicyUpdate = certificatePolicy.withIssuerReference(new IssuerReference().withName(ISSUER_SELF)); + CertificatePolicy certificatePolicyUpdate = certificatePolicy.withIssuerParameters(new IssuerParameters().withName(ISSUER_SELF)); CertificatePolicy updatedCertificatePolicy = keyVaultClient.updateCertificatePolicy( new UpdateCertificatePolicyRequest .Builder(vaultUri, certificateName) .withPolicy(certificatePolicyUpdate) .build()); - Assert.assertEquals(certificatePolicyUpdate.issuerReference().name(), updatedCertificatePolicy.issuerReference().name()); + Assert.assertEquals(certificatePolicyUpdate.issuerParameters().name(), updatedCertificatePolicy.issuerParameters().name()); CertificatePolicy policy = keyVaultClient.getCertificatePolicy(vaultUri, certificateName); - Assert.assertEquals(certificatePolicyUpdate.issuerReference().name(), policy.issuerReference().name()); + Assert.assertEquals(certificatePolicyUpdate.issuerParameters().name(), policy.issuerParameters().name()); keyVaultClient.deleteCertificate(getVaultUri(), certificateName); } @@ -1022,10 +1022,10 @@ private void validateCertificateBundle(CertificateBundle certificateBundle, Cert if (certificatePolicy != null) { Assert.assertNotNull(certificateBundle.policy()); - Assert.assertNotNull(certificateBundle.policy().issuerReference()); - Assert.assertNotNull(certificateBundle.policy().issuerReference().name()); - if(certificatePolicy.issuerReference() != null) { - Assert.assertTrue(certificateBundle.policy().issuerReference().name().equalsIgnoreCase(certificatePolicy.issuerReference().name())); + Assert.assertNotNull(certificateBundle.policy().issuerParameters()); + Assert.assertNotNull(certificateBundle.policy().issuerParameters().name()); + if(certificatePolicy.issuerParameters() != null) { + Assert.assertTrue(certificateBundle.policy().issuerParameters().name().equalsIgnoreCase(certificatePolicy.issuerParameters().name())); } } } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 863b2f8a4166a..452b6eae13bcf 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -116,6 +116,7 @@ private void checkImportOperation(KeyBundle keyBundle, boolean importToHardware) validateRsaKeyBundle(importResultBundle, getVaultUri(), KEY_NAME, importToHardware ? JsonWebKeyType.RSA_HSM : JsonWebKeyType.RSA, importedJwk.keyOps(), attribute); checkEncryptDecryptSequence(importedJwk, importResultBundle); + Assert.assertTrue(importResultBundle.key().isValid()); } private void checkEncryptDecryptSequence(JsonWebKey importedKey, KeyBundle importedKeyBundle) throws Exception { @@ -557,6 +558,7 @@ private static void validateRsaKeyBundle(KeyBundle bundle, String vault, String compareAttributes(attributes, bundle.attributes()); Assert.assertTrue(bundle.managed() == null || bundle.managed() == false); + Assert.assertTrue(bundle.key().isValid()); } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index 08e6cd13de44e..4f556a0fd8882 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -14,14 +14,17 @@ import org.junit.Test; import com.microsoft.azure.keyvault.models.Attributes; +import com.microsoft.azure.keyvault.models.KeyVaultError; import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.SecretAttributes; import com.microsoft.azure.keyvault.models.SecretBundle; +import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.PagedList; import com.microsoft.azure.keyvault.SecretIdentifier; import com.microsoft.azure.keyvault.models.SecretItem; import com.microsoft.azure.keyvault.requests.SetSecretRequest; import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; +import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; public class SecretOperationsTest extends KeyVaultClientIntegrationTestBase { @@ -63,6 +66,15 @@ public void transparentAuthentication() throws Exception { } + @Test + public void deserializeWithExtraFieldTest() throws Exception { + AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); + ObjectMapper mapper = mapperAdapter.getObjectMapper(); + KeyVaultError error = mapper.readValue("{\"error\":{\"code\":\"SecretNotFound\",\"message\":\"Secret not found: javaSecret\",\"noneexisting\":true}}", KeyVaultError.class); + Assert.assertEquals(error.error().message(), "Secret not found: javaSecret"); + Assert.assertEquals(error.error().code(), "SecretNotFound"); + } + @Test public void crudOperations() throws Exception { From 20cb23b617a43d3328a8f8a08cb814eb075180d3 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Wed, 28 Sep 2016 18:19:03 -0700 Subject: [PATCH 41/56] Remove runtimes from SDK --- azure-keyvault-extensions/pom.xml | 2 -- azure-keyvault/pom.xml | 2 -- 2 files changed, 4 deletions(-) diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 25cbfdf05c497..749578fd292d5 100755 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -49,7 +49,6 @@ com.microsoft.azure azure-client-runtime - 1.0.0-SNAPSHOT commons-codec @@ -95,7 +94,6 @@ com.microsoft.azure azure-client-authentication - 1.0.0-beta2 test diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index 9284ae5e29a10..96e1e04904f84 100755 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -50,7 +50,6 @@ com.microsoft.azure azure-client-runtime - 1.0.0-SNAPSHOT ${project.groupId} @@ -67,7 +66,6 @@ com.microsoft.azure azure-client-authentication - 1.0.0-SNAPSHOT test From 2819ac38f33aa9a3c6083259c872ee56762b46d2 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Thu, 29 Sep 2016 09:48:25 -0700 Subject: [PATCH 42/56] [release] Bump up version to 1.0.0-beta3 --- azure-keyvault-core/pom.xml | 2 +- azure-keyvault-cryptography/pom.xml | 6 +++--- azure-keyvault-extensions/pom.xml | 18 +++++++++--------- azure-keyvault-webkey/pom.xml | 2 +- azure-keyvault/pom.xml | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index 871785c62cdd4..2b9ea14672bf6 100755 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -17,7 +17,7 @@ com.microsoft.azure azure-parent - 1.0.0-SNAPSHOT + 1.0.0-beta3 ../pom.xml diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index b3e1236542df2..fdaa8f150f1de 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -9,7 +9,7 @@ com.microsoft.azure azure-parent - 1.0.0-SNAPSHOT + 1.0.0-beta3 ../pom.xml @@ -57,12 +57,12 @@ ${project.groupId} azure-keyvault-core - ${project.version} + 1.0.0-beta3 ${project.groupId} azure-keyvault-webkey - ${project.version} + 1.0.0-beta3 diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 749578fd292d5..10ae305c9f986 100755 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-SNAPSHOT + 1.0.0-beta3 ../pom.xml @@ -66,24 +66,24 @@ 1.54 - ${project.groupId} + com.microsoft.azure azure-keyvault-core - ${project.version} + 1.0.0-beta3 - ${project.groupId} + com.microsoft.azure azure-keyvault-cryptography - ${project.version} + 1.0.0-beta3 - ${project.groupId} + com.microsoft.azure azure-keyvault - ${project.version} + 1.0.0-beta3 - ${project.groupId} + com.microsoft.azure azure-keyvault-webkey - ${project.version} + 1.0.0-beta3 org.mockito diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml index 31aca33de3b28..4faeb0a35b708 100644 --- a/azure-keyvault-webkey/pom.xml +++ b/azure-keyvault-webkey/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-SNAPSHOT + 1.0.0-beta3 ../pom.xml diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index 96e1e04904f84..13070c5ff545a 100755 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-SNAPSHOT + 1.0.0-beta3 ../pom.xml @@ -54,7 +54,7 @@ ${project.groupId} azure-keyvault-webkey - ${project.version} + 1.0.0-beta3 From deea0b4b4a8628b0933b409f0e3d1ffb779b364d Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Wed, 28 Sep 2016 14:48:54 -0700 Subject: [PATCH 43/56] [release] Prepare for next development iteration (1.0.0-beta4-SNAPSHOT) --- azure-keyvault-core/pom.xml | 2 +- azure-keyvault-cryptography/pom.xml | 10 +++++----- azure-keyvault-extensions/pom.xml | 10 +++++----- azure-keyvault-webkey/pom.xml | 2 +- azure-keyvault/pom.xml | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index 2b9ea14672bf6..fb5949b5c4a04 100755 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -17,7 +17,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT ../pom.xml diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index fdaa8f150f1de..bef7eb3a98bae 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -9,7 +9,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT ../pom.xml @@ -55,14 +55,14 @@ 1.54 - ${project.groupId} + com.microsoft.azure azure-keyvault-core - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT - ${project.groupId} + com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 10ae305c9f986..8bae456f11270 100755 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT ../pom.xml @@ -68,22 +68,22 @@ com.microsoft.azure azure-keyvault-core - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT com.microsoft.azure azure-keyvault-cryptography - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT com.microsoft.azure azure-keyvault - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT org.mockito diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml index 4faeb0a35b708..d01f1a2937b2e 100644 --- a/azure-keyvault-webkey/pom.xml +++ b/azure-keyvault-webkey/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT ../pom.xml diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index 13070c5ff545a..ed8b9e264351a 100755 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT ../pom.xml @@ -52,9 +52,9 @@ azure-client-runtime - ${project.groupId} + com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT From 168aaacfaf9456dab300067c4a9a708d1b8aa68e Mon Sep 17 00:00:00 2001 From: Hervey Wilson Date: Thu, 6 Oct 2016 10:47:48 -0700 Subject: [PATCH 44/56] Cryptography package updates --- .../keyvault/cryptography/ByteExtensions.java | 30 ++++ .../SymmetricEncryptionAlgorithm.java | 24 ++-- .../keyvault/cryptography/SymmetricKey.java | 131 ++++++++++++------ .../cryptography/algorithms/AesCbc.java | 4 +- .../algorithms/AesCbcHmacSha2.java | 60 ++++---- .../cryptography/algorithms/Rs256.java | 22 +-- .../cryptography/test/AesCbcHmacShaTest.java | 6 +- .../cryptography/test/AesCbcTest.java | 8 +- 8 files changed, 178 insertions(+), 107 deletions(-) diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java index 2c8af1810d836..07aee9a689490 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/ByteExtensions.java @@ -67,4 +67,34 @@ public static void zero( byte[] self ) Arrays.fill(self, (byte)0); } } + + /** + * Compares two byte arrays in constant time. + * + * @param self + * The first byte array to compare + * @param other + * The second byte array to compare + * @return + * True if the two byte arrays are equal. + */ + public static boolean sequenceEqualConstantTime( byte[] self, byte[] other ) + { + if ( self == null ) + throw new IllegalArgumentException( "self" ); + + if ( other == null ) + throw new IllegalArgumentException( "other" ); + + // Constant time comparison of two byte arrays + long difference = ( self.length & 0xffffffffl ) ^ ( other.length & 0xffffffffl ); + + for ( int i = 0; i < self.length && i < other.length; i++ ) + { + difference |= ( self[i] ^ other[i] ) & 0xffffffffl; + } + + return difference == 0; + } + } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java index 7c6e586fc09f8..b582ced734928 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricEncryptionAlgorithm.java @@ -32,11 +32,11 @@ protected SymmetricEncryptionAlgorithm(String name) { * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption * using the supplied initialization vector and the specific provider for the Java Security API. * @param key - * The AES key material to be used. + * The key material to be used. * @param iv * The initialization vector to be used. * @param authenticationData - * The authentication data to be used with authenticating encryption algorithms (optional) + * The authentication data to be used with authenticating encryption algorithms (ignored for non-authenticating algorithms) * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation * @throws InvalidKeyException * @throws NoSuchAlgorithmException @@ -49,11 +49,11 @@ protected SymmetricEncryptionAlgorithm(String name) { * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for encryption * using the supplied initialization vector and the specific provider for the Java Security API. * @param key - * The AES key material to be used. + * The key material to be used. * @param iv * The initialization vector to be used. * @param authenticationData - * The authentication data to be used with authenticating encryption algorithms (optional) + * The authentication data to be used with authenticating encryption algorithms (ignored for non-authenticating algorithms) * @param provider * The provider to use. * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation @@ -68,28 +68,32 @@ protected SymmetricEncryptionAlgorithm(String name) { * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption * using the supplied initialization vector and the specific provider for the Java Security API. * @param key - * The AES key material to be used. + * The key material to be used. * @param iv * The initialization vector to be used. * @param authenticationData - * The authentication data to be used with authenticating encryption algorithms (optional) + * The authentication data to be used with authenticating encryption algorithms (ignored for non-authenticating algorithms) + * @param authenticationTag + * The authentication tag to verify when using authenticating encryption algorithms (ignored for non-authenticating algorithms) * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation * @throws InvalidKeyException * @throws NoSuchAlgorithmException * @throws NoSuchPaddingException * @throws InvalidAlgorithmParameterException */ - public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, byte[] authenticationTag) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; /** * Creates a {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation for decryption * using the supplied initialization vector and the specific provider for the Java Security API. * @param key - * The AES key material to be used. + * The key material to be used. * @param iv * The initialization vector to be used. * @param authenticationData - * The authentication data to be used with authenticating encryption algorithms (optional) + * The authentication data to be used with authenticating encryption algorithms (ignored for non-authenticating algorithms) + * @param authenticationTag + * The authentication tag to verify when using authenticating encryption algorithms (ignored for non-authenticating algorithms) * @param provider * The provider to use. * @return A {@link com.microsoft.azure.keyvault.cryptography.ICryptoTransform} implementation @@ -98,6 +102,6 @@ protected SymmetricEncryptionAlgorithm(String name) { * @throws NoSuchPaddingException * @throws InvalidAlgorithmParameterException */ - public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; + public abstract ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, byte[] authenticationTag, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException; } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java index a5e333f092f3b..c401d77251a88 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/SymmetricKey.java @@ -9,6 +9,9 @@ import java.io.IOException; import java.security.NoSuchAlgorithmException; import java.security.Provider; +import java.security.SecureRandom; +import java.util.UUID; + import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; @@ -26,38 +29,121 @@ import com.microsoft.azure.keyvault.cryptography.algorithms.AesKw256; import com.microsoft.azure.keyvault.cryptography.Strings; +/** + * A simple symmetric key implementation + * + */ public class SymmetricKey implements IKey { + + private static final SecureRandom Rng = new SecureRandom(); public static final int KeySize128 = 128 >> 3; public static final int KeySize192 = 192 >> 3; public static final int KeySize256 = 256 >> 3; public static final int KeySize384 = 384 >> 3; public static final int KeySize512 = 512 >> 3; + + public static final int DefaultKeySize = KeySize256; private final String _kid; private final byte[] _key; private final Provider _provider; + + /** + * Creates a SymmetricKey with a random key identifier and + * a random key with DefaultKeySize bits. + */ + public SymmetricKey() { + this(UUID.randomUUID().toString()); + } + + /** + * Creates a SymmetricKey with the specified key identifier and + * a random key with DefaultKeySize bits. + * @param kid + * The key identifier to use. + */ + public SymmetricKey(String kid) { + this(kid, DefaultKeySize); + } + + /** + * Creates a SymmetricKey with the specified key identifier and + * a random key with the specified size. + * @param kid + * The key identifier to use. + * @param keySizeInBytes + * The key size to use in bytes. + */ + public SymmetricKey(String kid, int keySizeInBytes ) { + this(kid, keySizeInBytes, null); + } + + /** + * Creates a SymmetricKey with the specified key identifier and + * a random key with the specified size that uses the specified provider. + * @param kid + * The key identifier to use. + * @param keySizeInBytes + * The key size to use in bytes. + * @param provider + * The provider to use (optional, null for default) + */ + public SymmetricKey(String kid, int keySizeInBytes, Provider provider) { + + if ( Strings.isNullOrWhiteSpace(kid) ) { + throw new IllegalArgumentException("kid"); + } + + if ( keySizeInBytes != KeySize128 && keySizeInBytes != KeySize192 && keySizeInBytes != KeySize256 && keySizeInBytes != KeySize384 && keySizeInBytes != KeySize512 ) { + throw new IllegalArgumentException("The key material must be 128, 192, 256, 384 or 512 bits of data"); + } + + _kid = kid; + _key = new byte[keySizeInBytes]; + _provider = provider; + + // Generate a random key + Rng.nextBytes(_key); + } + /** + * Creates a SymmetricKey with the specified key identifier and key material. + * @param kid + * The key identifier to use. + * @param keyBytes + * The key material to use. + */ public SymmetricKey(String kid, byte[] keyBytes) { this(kid, keyBytes, null); } + /** + * Creates a SymmetricKey with the specified key identifier and key material + * that uses the specified Provider. + * @param kid + * The key identifier to use. + * @param keyBytes + * The key material to use. + * @param provider + * The Provider to use (optional, null for default) + */ public SymmetricKey(String kid, byte[] keyBytes, Provider provider) { - if (Strings.isNullOrWhiteSpace(kid)) { + if ( Strings.isNullOrWhiteSpace(kid) ) { throw new IllegalArgumentException("kid"); } - if (keyBytes == null) { + if ( keyBytes == null ) { throw new IllegalArgumentException("keyBytes"); } - if (keyBytes.length != KeySize128 && keyBytes.length != KeySize192 && keyBytes.length != KeySize256 && keyBytes.length != KeySize384 && keyBytes.length != KeySize512) { + if ( keyBytes.length != KeySize128 && keyBytes.length != KeySize192 && keyBytes.length != KeySize256 && keyBytes.length != KeySize384 && keyBytes.length != KeySize512 ) { throw new IllegalArgumentException("The key material must be 128, 192, 256, 384 or 512 bits of data"); } - _kid = kid; - _key = keyBytes; + _kid = kid; + _key = keyBytes; _provider = provider; } @@ -148,7 +234,7 @@ public ListenableFuture decryptAsync(final byte[] ciphertext, final byte ICryptoTransform transform = null; try { - transform = algo.CreateDecryptor(_key, iv, authenticationData, _provider ); + transform = algo.CreateDecryptor(_key, iv, authenticationData, authenticationTag, _provider ); } catch (Exception e) { return Futures.immediateFailedFuture(e); } @@ -161,19 +247,6 @@ public ListenableFuture decryptAsync(final byte[] ciphertext, final byte return Futures.immediateFailedFuture(e); } - if (transform instanceof IAuthenticatedCryptoTransform) { - - IAuthenticatedCryptoTransform authenticatedTransform = (IAuthenticatedCryptoTransform) transform; - - if (authenticationData == null || authenticationTag == null) { - throw new IllegalArgumentException("AuthenticatingCryptoTransform requires authenticationData and authenticationTag"); - } - - if (!sequenceEqualConstantTime(authenticationTag, authenticatedTransform.getTag())) { - throw new IllegalArgumentException("Data is not authentic"); - } - } - return Futures.immediateFuture(result); } @@ -313,24 +386,4 @@ public ListenableFuture verifyAsync(final byte[] digest, final byte[] s @Override public void close() throws IOException { } - - public static boolean sequenceEqualConstantTime(byte[] self, byte[] other) { - if (self == null) { - throw new IllegalArgumentException("self"); - } - - if (other == null) { - throw new IllegalArgumentException("other"); - } - - // Constant time comparison of two byte arrays - long difference = (self.length & 0xffffffffl) ^ (other.length & 0xffffffffl); - - for (int i = 0; i < self.length && i < other.length; i++) { - difference |= (self[i] & 0xffffffffl) ^ (other[i] & 0xffffffffl); - } - - return difference == 0; - } - } diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java index d2f891cc13094..f2b9d28f67e32 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbc.java @@ -97,7 +97,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica } @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, byte[] authenticationTag) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null || key.length < keySizeInBytes) { throw new InvalidKeyException("key must be at least " + keySize + " bits in length"); @@ -107,7 +107,7 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica } @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, byte[] authenticationTag, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null || key.length < keySizeInBytes) { throw new InvalidKeyException("key must be at least " + keySize + " bits in length"); diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java index 0372401e5a039..9ab0a3cd2f1e3 100755 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/AesCbcHmacSha2.java @@ -20,6 +20,7 @@ import org.apache.commons.lang3.tuple.Triple; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.IAuthenticatedCryptoTransform; import com.microsoft.azure.keyvault.cryptography.ICryptoTransform; import com.microsoft.azure.keyvault.cryptography.SymmetricEncryptionAlgorithm; @@ -35,22 +36,26 @@ static class AesCbcHmacSha2Decryptor implements IAuthenticatedCryptoTransform { byte[] _tag; - AesCbcHmacSha2Decryptor(String name, byte[] key, byte[] iv, byte[] associatedData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + AesCbcHmacSha2Decryptor(String name, byte[] key, byte[] iv, byte[] authenticationData, byte[] authenticationTag, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + // Split the key to get the AES key, the HMAC key and the HMAC // object Triple parameters = GetAlgorithmParameters(name, key); // Save the MAC provider and key - _hmac = parameters.getRight(); + _hmac = parameters.getRight(); _hmac_key = parameters.getMiddle(); // Create the AES provider - _inner = new AesCbc.AesCbcDecryptor(parameters.getLeft(), iv, provider); + _inner = new AesCbc.AesCbcDecryptor(parameters.getLeft(), iv, provider); - _aad_length = toBigEndian(associatedData.length * 8); + _aad_length = toBigEndian(authenticationData.length * 8); + + // Save the tag + _tag = authenticationTag; // Prime the hash. - _hmac.update(associatedData); + _hmac.update(authenticationData); _hmac.update(iv); } @@ -59,18 +64,6 @@ public byte[] getTag() { return _tag; } - // public int TransformBlock( byte[] inputBuffer, int inputOffset, int - // inputCount, byte[] outputBuffer, int outputOffset ) - // { - // // Add the cipher text to the running hash - // _hmac.TransformBlock( inputBuffer, inputOffset, inputCount, - // inputBuffer, inputOffset ); - // - // // Decrypt the cipher text - // return _inner.TransformBlock( inputBuffer, inputOffset, inputCount, - // outputBuffer, outputOffset ); - // } - @Override public byte[] doFinal(byte[] input) throws IllegalBlockSizeException, BadPaddingException, InvalidKeyException, NoSuchAlgorithmException { @@ -80,9 +73,14 @@ public byte[] doFinal(byte[] input) throws IllegalBlockSizeException, BadPadding // Add the associated_data_length bytes to the hash byte[] hash = _hmac.doFinal(_aad_length); - // Compute the tag - _tag = new byte[_hmac_key.length]; - System.arraycopy(hash, 0, _tag, 0, _hmac_key.length); + // Compute the new tag + byte[] tag = new byte[_hmac_key.length]; + System.arraycopy(hash, 0, tag, 0, _hmac_key.length); + + // Check the tag before performing the final decrypt + if ( !ByteExtensions.sequenceEqualConstantTime(_tag, tag) ) { + throw new IllegalArgumentException("Data is not authentic"); + } return _inner.doFinal(input); } @@ -97,7 +95,7 @@ static class AesCbcHmacSha2Encryptor implements IAuthenticatedCryptoTransform { byte[] _tag; - AesCbcHmacSha2Encryptor(String name, byte[] key, byte[] iv, byte[] associatedData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + AesCbcHmacSha2Encryptor(String name, byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { // Split the key to get the AES key, the HMAC key and the HMAC // object Triple parameters = GetAlgorithmParameters(name, key); @@ -109,10 +107,10 @@ static class AesCbcHmacSha2Encryptor implements IAuthenticatedCryptoTransform { // Create the AES encryptor _inner = new AesCbc.AesCbcEncryptor(parameters.getLeft(), iv, provider); - _aad_length = toBigEndian(associatedData.length * 8); + _aad_length = toBigEndian(authenticationData.length * 8); // Prime the hash. - _hmac.update(associatedData); + _hmac.update(authenticationData); _hmac.update(iv); } @@ -160,12 +158,12 @@ protected AesCbcHmacSha2(String name) { } @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { - return CreateDecryptor(key, iv, authenticationData, null); + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, byte[] authenticationTag) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + return CreateDecryptor(key, iv, authenticationData, authenticationTag, null); } @Override - public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { + public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authenticationData, byte[] authenticationTag, Provider provider) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException { if (key == null) { throw new IllegalArgumentException("No key material"); } @@ -175,11 +173,15 @@ public ICryptoTransform CreateDecryptor(byte[] key, byte[] iv, byte[] authentica } if (authenticationData == null) { - throw new IllegalArgumentException("No associated data"); + throw new IllegalArgumentException("No authentication data"); + } + + if (authenticationTag == null) { + throw new IllegalArgumentException("No authentication tag"); } // Create the Decryptor - return new AesCbcHmacSha2Decryptor(getName(), key, iv, authenticationData, provider); + return new AesCbcHmacSha2Decryptor(getName(), key, iv, authenticationData, authenticationTag, provider); } @Override @@ -199,7 +201,7 @@ public ICryptoTransform CreateEncryptor(byte[] key, byte[] iv, byte[] authentica } if (authenticationData == null) { - throw new IllegalArgumentException("No associated data"); + throw new IllegalArgumentException("No authentication data"); } // Create the Encryptor diff --git a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java index eddafecac6b28..e443398bf0402 100644 --- a/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java +++ b/azure-keyvault-cryptography/src/main/java/com/microsoft/azure/keyvault/cryptography/algorithms/Rs256.java @@ -12,6 +12,7 @@ import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; +import com.microsoft.azure.keyvault.cryptography.ByteExtensions; import com.microsoft.azure.keyvault.cryptography.ISignatureTransform; /** @@ -74,7 +75,7 @@ public boolean verify(byte[] digest, byte[] signature) throws NoSuchAlgorithmExc byte[] EM2 = EMSA_PKCS1_V1_5_ENCODE_HASH(digest, _emLen, "SHA-256"); // Use constant time compare - return sequenceEqualConstantTime(EM, EM2); + return ByteExtensions.sequenceEqualConstantTime(EM, EM2); } } @@ -90,23 +91,4 @@ public ISignatureTransform createSignatureTransform(KeyPair keyPair) { return new Rs256SignatureTransform(keyPair); } - - private boolean sequenceEqualConstantTime( byte[] self, byte[] other ) - { - if ( self == null ) - throw new IllegalArgumentException( "self" ); - - if ( other == null ) - throw new IllegalArgumentException( "other" ); - - // Constant time comparison of two byte arrays - long difference = ( self.length & 0xffffffffl ) ^ ( other.length & 0xffffffffl ); - - for ( int i = 0; i < self.length && i < other.length; i++ ) - { - difference |= ( self[i] ^ other[i] ) & 0xffffffffl; - } - - return difference == 0; - } } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java index 5bd3cacf3813d..ef588b4830e9c 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcHmacShaTest.java @@ -95,7 +95,7 @@ public void testAes128CbcHmacSha256() { } try { - transform = (IAuthenticatedCryptoTransform)algo.CreateDecryptor(K, IV, A, _provider); + transform = (IAuthenticatedCryptoTransform)algo.CreateDecryptor(K, IV, A, T, _provider); } catch (Exception e) { fail(e.getMessage()); } @@ -171,7 +171,7 @@ public void testAes192CbcHmacSha384() { } try { - transform = (IAuthenticatedCryptoTransform)algo.CreateDecryptor(K, IV, A, _provider); + transform = (IAuthenticatedCryptoTransform)algo.CreateDecryptor(K, IV, A, T, _provider); } catch (Exception e) { fail(e.getMessage()); } @@ -246,7 +246,7 @@ public void testAes256CbcHmacSha512() { } try { - transform = (IAuthenticatedCryptoTransform)algo.CreateDecryptor(K, IV, A, _provider); + transform = (IAuthenticatedCryptoTransform)algo.CreateDecryptor(K, IV, A, T, _provider); } catch (Exception e) { fail(e.getMessage()); } diff --git a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java index b9bbf4a65e1e9..7b41487ef9888 100755 --- a/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java +++ b/azure-keyvault-cryptography/src/test/java/com/microsoft/azure/keyvault/cryptography/test/AesCbcTest.java @@ -70,7 +70,7 @@ public void testAes128CbcOneBlock() { ICryptoTransform decryptor = null; try { - decryptor = algo.CreateDecryptor(CEK, IV, null, _provider); + decryptor = algo.CreateDecryptor(CEK, IV, null, null, _provider); } catch (Exception e) { fail(e.getMessage()); } @@ -117,7 +117,7 @@ public void testAes128CbcTwoBlock() { ICryptoTransform decryptor = null; try { - decryptor = algo.CreateDecryptor(CEK, IV, null, _provider); + decryptor = algo.CreateDecryptor(CEK, IV, null, null, _provider); } catch (Exception e) { fail(e.getMessage()); } @@ -164,7 +164,7 @@ public void testAes128CbcOneBlock_ExcessKeyMaterial() { ICryptoTransform decryptor = null; try { - decryptor = algo.CreateDecryptor(CEK, IV, null, _provider); + decryptor = algo.CreateDecryptor(CEK, IV, null, null, _provider); } catch (Exception e) { fail(e.getMessage()); } @@ -211,7 +211,7 @@ public void testAes128CbcTwoBlock_ExcessKeyMaterial() { ICryptoTransform decryptor = null; try { - decryptor = algo.CreateDecryptor(CEK, IV, null, _provider); + decryptor = algo.CreateDecryptor(CEK, IV, null, null, _provider); } catch (Exception e) { fail(e.getMessage()); } From a6571f7a3926211ef5117d117541fb171de924bc Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Thu, 10 Nov 2016 11:04:36 -0800 Subject: [PATCH 45/56] Keyvault cryptography beta3.1 release --- azure-keyvault-cryptography/pom.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index bef7eb3a98bae..0caacc1f2bfe1 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -9,12 +9,13 @@ com.microsoft.azure azure-parent - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta3 ../pom.xml azure-keyvault-cryptography jar + 1.0.0-beta3.1 Microsoft Azure SDK for Key Vault Cryptography This package contains Microsoft Azure SDK for Key Vault Cryptography. @@ -57,12 +58,12 @@ com.microsoft.azure azure-keyvault-core - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta3 com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta3 From 32f2d487231fcda5a3a7a50bf15949ff3876d1ac Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Thu, 10 Nov 2016 11:06:04 -0800 Subject: [PATCH 46/56] Prepare for next iteration of development --- azure-keyvault-cryptography/pom.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index 0caacc1f2bfe1..bef7eb3a98bae 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -9,13 +9,12 @@ com.microsoft.azure azure-parent - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT ../pom.xml azure-keyvault-cryptography jar - 1.0.0-beta3.1 Microsoft Azure SDK for Key Vault Cryptography This package contains Microsoft Azure SDK for Key Vault Cryptography. @@ -58,12 +57,12 @@ com.microsoft.azure azure-keyvault-core - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta3 + 1.0.0-beta4-SNAPSHOT From 56210531856466e53a9cf83cf22615003a4549ee Mon Sep 17 00:00:00 2001 From: Pooneh Date: Thu, 10 Nov 2016 10:28:03 -0800 Subject: [PATCH 47/56] Updating the api-version and adding innererror --- .../azure/keyvault/KeyVaultClientImpl.java | 4 +-- .../azure/keyvault/models/Error.java | 15 +++++++++++ .../keyvault/test/SecretOperationsTest.java | 26 +++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index 854e41f4a06c9..d9b1bbac60a5d 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -219,7 +219,7 @@ private KeyVaultClientImpl(String baseUrl, ServiceClientCredentials credentials) } protected void initialize() { - this.apiVersion = "2015-06-01"; + this.apiVersion = "2016-10-01"; this.acceptLanguage = "en-US"; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; @@ -236,7 +236,7 @@ protected void initialize() { public String userAgent() { return String.format("Azure-SDK-For-Java/%s (%s)", getClass().getPackage().getImplementationVersion(), - "KeyVaultClient, 2015-06-01"); + "KeyVaultClient, 2016-10-01"); } private void initializeService() { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java index 4d231d644f92a..8826781c7e929 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java @@ -28,6 +28,12 @@ public class Error { @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String message; + /** + * The innerError property. + */ + @JsonProperty(value = "innererror", access = JsonProperty.Access.WRITE_ONLY) + private Error innerError; + /** * Get the code value. * @@ -46,4 +52,13 @@ public String message() { return this.message; } + /** + * Get the innerError value. + * + * @return the innerError value + */ + public Error innerError() { + return this.innerError; + } + } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index 4f556a0fd8882..d975af90a3966 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -75,6 +75,32 @@ public void deserializeWithExtraFieldTest() throws Exception { Assert.assertEquals(error.error().code(), "SecretNotFound"); } + @Test + // verifies the inner error on disabled secret + public void disabledSecretGet() throws Exception { + + String secretName = "disabledsecret"; + SecretBundle secret = keyVaultClient.setSecret( + new SetSecretRequest + .Builder(getVaultUri(), secretName, SECRET_VALUE) + .withAttributes(new SecretAttributes().withEnabled(false)) + .build()); + try { + keyVaultClient.getSecret(secret.id()); + Assert.fail("Should throw exception for disabled secret."); + } + catch (KeyVaultErrorException e) { + Assert.assertEquals(e.getBody().error().code(), "Forbidden"); + Assert.assertNotNull(e.getBody().error().message()); + Assert.assertNotNull(e.getBody().error().innerError()); + Assert.assertEquals(e.getBody().error().innerError().code(), "SecretDisabled"); + } + catch (Exception e) { + Assert.fail("Should throw KeyVaultErrorException for disabled secret."); + } + keyVaultClient.deleteSecret(getVaultUri(), secretName); + } + @Test public void crudOperations() throws Exception { From 27ecb0db6f0cb5f4b0b005333c7b3f74f48d256c Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Tue, 27 Dec 2016 03:00:16 -0800 Subject: [PATCH 48/56] [release] Prepare for beta5 development iteration --- azure-keyvault-core/pom.xml | 2 +- azure-keyvault-cryptography/pom.xml | 6 +++--- azure-keyvault-extensions/pom.xml | 10 +++++----- azure-keyvault-webkey/pom.xml | 2 +- azure-keyvault/pom.xml | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index fb5949b5c4a04..b9719b08a0f75 100755 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -17,7 +17,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta5-SNAPSHOT ../pom.xml diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index bef7eb3a98bae..8501c81ed9f35 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -9,7 +9,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta5-SNAPSHOT ../pom.xml @@ -57,12 +57,12 @@ com.microsoft.azure azure-keyvault-core - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta5-SNAPSHOT com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta5-SNAPSHOT diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 8bae456f11270..e084c960a6936 100755 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta5-SNAPSHOT ../pom.xml @@ -68,22 +68,22 @@ com.microsoft.azure azure-keyvault-core - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta5-SNAPSHOT com.microsoft.azure azure-keyvault-cryptography - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta5-SNAPSHOT com.microsoft.azure azure-keyvault - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta5-SNAPSHOT com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta5-SNAPSHOT org.mockito diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml index d01f1a2937b2e..a4fc4d77b6fbb 100644 --- a/azure-keyvault-webkey/pom.xml +++ b/azure-keyvault-webkey/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta5-SNAPSHOT ../pom.xml diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index ed8b9e264351a..0e0934848c5ec 100755 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta5-SNAPSHOT ../pom.xml @@ -54,7 +54,7 @@ com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta4-SNAPSHOT + 1.0.0-beta5-SNAPSHOT From 0e03b6a4fbf88627236dbc0c70370dd20d3ff7ec Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Sat, 7 Jan 2017 01:04:51 -0800 Subject: [PATCH 49/56] [release] Prepare for beta4.1 release --- azure-keyvault-core/pom.xml | 2 +- azure-keyvault-cryptography/pom.xml | 6 +++--- azure-keyvault-extensions/pom.xml | 10 +++++----- azure-keyvault-webkey/pom.xml | 2 +- azure-keyvault/pom.xml | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index b9719b08a0f75..2b9ea14672bf6 100755 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -17,7 +17,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta3 ../pom.xml diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index 8501c81ed9f35..820b878447138 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -9,7 +9,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta3 ../pom.xml @@ -57,12 +57,12 @@ com.microsoft.azure azure-keyvault-core - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta3 com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta3 diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index e084c960a6936..10ae305c9f986 100755 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta3 ../pom.xml @@ -68,22 +68,22 @@ com.microsoft.azure azure-keyvault-core - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta3 com.microsoft.azure azure-keyvault-cryptography - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta3 com.microsoft.azure azure-keyvault - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta3 com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta3 org.mockito diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml index a4fc4d77b6fbb..4faeb0a35b708 100644 --- a/azure-keyvault-webkey/pom.xml +++ b/azure-keyvault-webkey/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta3 ../pom.xml diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index 0e0934848c5ec..7a0a82e83678e 100755 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta3 ../pom.xml @@ -54,7 +54,7 @@ com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta3 From 78a51c762bcde9ad671a10ee944363e6f4ee6df6 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Sat, 7 Jan 2017 01:09:12 -0800 Subject: [PATCH 50/56] [release] Change versions back to development iteration --- azure-keyvault-core/pom.xml | 2 +- azure-keyvault-cryptography/pom.xml | 6 +++--- azure-keyvault-extensions/pom.xml | 10 +++++----- azure-keyvault-webkey/pom.xml | 2 +- azure-keyvault/pom.xml | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index 2b9ea14672bf6..b9719b08a0f75 100755 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -17,7 +17,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta3 + 1.0.0-beta5-SNAPSHOT ../pom.xml diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index 820b878447138..8501c81ed9f35 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -9,7 +9,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta3 + 1.0.0-beta5-SNAPSHOT ../pom.xml @@ -57,12 +57,12 @@ com.microsoft.azure azure-keyvault-core - 1.0.0-beta3 + 1.0.0-beta5-SNAPSHOT com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta3 + 1.0.0-beta5-SNAPSHOT diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 10ae305c9f986..e084c960a6936 100755 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta3 + 1.0.0-beta5-SNAPSHOT ../pom.xml @@ -68,22 +68,22 @@ com.microsoft.azure azure-keyvault-core - 1.0.0-beta3 + 1.0.0-beta5-SNAPSHOT com.microsoft.azure azure-keyvault-cryptography - 1.0.0-beta3 + 1.0.0-beta5-SNAPSHOT com.microsoft.azure azure-keyvault - 1.0.0-beta3 + 1.0.0-beta5-SNAPSHOT com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta3 + 1.0.0-beta5-SNAPSHOT org.mockito diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml index 4faeb0a35b708..a4fc4d77b6fbb 100644 --- a/azure-keyvault-webkey/pom.xml +++ b/azure-keyvault-webkey/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta3 + 1.0.0-beta5-SNAPSHOT ../pom.xml diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index 7a0a82e83678e..0e0934848c5ec 100755 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta3 + 1.0.0-beta5-SNAPSHOT ../pom.xml @@ -54,7 +54,7 @@ com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta3 + 1.0.0-beta5-SNAPSHOT From ddadd3d73bd355da68a1c68659b5941672bb799b Mon Sep 17 00:00:00 2001 From: anuchan Date: Mon, 6 Feb 2017 18:50:26 -0800 Subject: [PATCH 51/56] [release] Prepare for beta6 development iteration --- azure-keyvault-core/pom.xml | 2 +- azure-keyvault-cryptography/pom.xml | 6 +++--- azure-keyvault-extensions/pom.xml | 10 +++++----- azure-keyvault-webkey/pom.xml | 2 +- azure-keyvault/pom.xml | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index b9719b08a0f75..0ebe257f46952 100755 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -17,7 +17,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT ../pom.xml diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index 8501c81ed9f35..2b541491227de 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -9,7 +9,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT ../pom.xml @@ -57,12 +57,12 @@ com.microsoft.azure azure-keyvault-core - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index e084c960a6936..2761eef2ef9f1 100755 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT ../pom.xml @@ -68,22 +68,22 @@ com.microsoft.azure azure-keyvault-core - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT com.microsoft.azure azure-keyvault-cryptography - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT com.microsoft.azure azure-keyvault - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT org.mockito diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml index a4fc4d77b6fbb..e1b26fd426a20 100644 --- a/azure-keyvault-webkey/pom.xml +++ b/azure-keyvault-webkey/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT ../pom.xml diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index 0e0934848c5ec..c9e4c8ed95351 100755 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure azure-parent - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT ../pom.xml @@ -54,7 +54,7 @@ com.microsoft.azure azure-keyvault-webkey - 1.0.0-beta5-SNAPSHOT + 1.0.0-beta6-SNAPSHOT From c574b95a0486977c1a8225d374d9ee9eee7cbd91 Mon Sep 17 00:00:00 2001 From: Pooneh Date: Sun, 5 Feb 2017 18:38:03 -0800 Subject: [PATCH 52/56] Updating Key Vault Java SDK to use the latest Runtime Client. --- azure-keyvault-core/pom.xml | 15 +- .../azure/keyvault/KeyVaultClient.java | 502 +-- .../azure/keyvault/KeyVaultClientImpl.java | 2804 ++++++++--------- .../azure/keyvault/models/Action.java | 2 +- .../azure/keyvault/models/ActionType.java | 2 +- .../keyvault/models/AdministratorDetails.java | 3 +- .../azure/keyvault/models/Attributes.java | 7 +- .../keyvault/models/BackupKeyResult.java | 6 +- .../models/CertificateAttributes.java | 2 +- .../keyvault/models/CertificateBundle.java | 22 +- .../models/CertificateCreateParameters.java | 5 +- .../models/CertificateImportParameters.java | 5 +- .../models/CertificateIssuerItem.java | 5 +- .../CertificateIssuerSetParameters.java | 6 +- .../CertificateIssuerUpdateParameters.java | 5 +- .../keyvault/models/CertificateItem.java | 12 +- .../models/CertificateMergeParameters.java | 5 +- .../keyvault/models/CertificateOperation.java | 16 +- .../CertificateOperationUpdateParameter.java | 2 +- .../keyvault/models/CertificatePolicy.java | 5 +- .../models/CertificateUpdateParameters.java | 5 +- .../azure/keyvault/models/Contact.java | 4 +- .../azure/keyvault/models/Contacts.java | 4 +- .../azure/keyvault/models/Error.java | 6 +- .../keyvault/models/IssuerAttributes.java | 9 +- .../azure/keyvault/models/IssuerBundle.java | 11 +- .../keyvault/models/IssuerCredentials.java | 2 +- .../keyvault/models/IssuerParameters.java | 7 +- .../azure/keyvault/models/KeyAttributes.java | 4 +- .../azure/keyvault/models/KeyBundle.java | 20 +- .../keyvault/models/KeyCreateParameters.java | 11 +- .../keyvault/models/KeyImportParameters.java | 7 +- .../azure/keyvault/models/KeyItem.java | 16 +- .../keyvault/models/KeyOperationResult.java | 6 +- .../models/KeyOperationsParameters.java | 6 +- .../azure/keyvault/models/KeyProperties.java | 5 +- .../keyvault/models/KeyRestoreParameters.java | 6 +- .../keyvault/models/KeySignParameters.java | 6 +- .../keyvault/models/KeyUpdateParameters.java | 5 +- .../azure/keyvault/models/KeyUsageType.java | 2 +- .../azure/keyvault/models/KeyVaultError.java | 6 +- .../models/KeyVaultErrorException.java | 73 +- .../keyvault/models/KeyVerifyParameters.java | 8 +- .../keyvault/models/KeyVerifyResult.java | 6 +- .../azure/keyvault/models/LifetimeAction.java | 9 +- .../keyvault/models/OrganizationDetails.java | 3 +- .../azure/keyvault/models/PageImpl.java | 6 +- ...endingCertificateSigningRequestResult.java | 4 +- .../keyvault/models/SecretAttributes.java | 2 +- .../azure/keyvault/models/SecretBundle.java | 21 +- .../azure/keyvault/models/SecretItem.java | 17 +- .../keyvault/models/SecretProperties.java | 4 +- .../keyvault/models/SecretSetParameters.java | 8 +- .../models/SecretUpdateParameters.java | 6 +- .../models/SubjectAlternativeNames.java | 4 +- .../azure/keyvault/models/Trigger.java | 4 +- .../models/X509CertificateProperties.java | 6 +- .../azure/keyvault/models/package-info.java | 4 +- .../azure/keyvault/package-info.java | 4 +- .../keyvault/test/AsyncOperationsTest.java | 6 +- .../test/CertificateOperationsTest.java | 40 +- .../keyvault/test/KeyOperationsTest.java | 12 +- .../keyvault/test/SecretOperationsTest.java | 28 +- 63 files changed, 1751 insertions(+), 2103 deletions(-) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index 0ebe257f46952..9cd682f935a51 100755 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -1,16 +1,7 @@ 4.0.0 diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index c49e98428ee1c..3098de2322dc2 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -10,6 +10,7 @@ import java.util.List; import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureClient; import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.PagedList; @@ -43,14 +44,17 @@ import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; -import com.microsoft.azure.RestClient; +import com.microsoft.rest.RestClient; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.protocol.SerializerAdapter; +import okhttp3.OkHttpClient; import okhttp3.ResponseBody; import retrofit2.Response; +import retrofit2.Retrofit; import retrofit2.http.GET; import retrofit2.http.Header; import retrofit2.http.Headers; @@ -128,7 +132,7 @@ public void withLongRunningOperationRetryTimeout(int longRunningOperationRetryTi * * @return the generateClientRequestId value. */ - public boolean getGenerateClientRequestId() { + public boolean generateClientRequestId() { return innerKeyVaultClient.generateClientRequestId(); } @@ -141,6 +145,34 @@ public void withGenerateClientRequestId(boolean generateClientRequestId) { innerKeyVaultClient.withGenerateClientRequestId(generateClientRequestId); } + /** + * @return the {@link RestClient} instance. + */ + public RestClient restClient() { + return innerKeyVaultClient.restClient(); + } + + /** + * @return the Retrofit instance. + */ + public Retrofit retrofit() { + return innerKeyVaultClient.retrofit(); + } + + /** + * @return the HTTP client. + */ + public OkHttpClient httpClient() { + return innerKeyVaultClient.httpClient(); + } + + /** + * @return the adapter to a Jackson {@link com.fasterxml.jackson.databind.ObjectMapper}. + */ + public SerializerAdapter serializerAdapter() { + return innerKeyVaultClient.serializerAdapter(); + } + /** * Initializes an instance of KeyVaultClient client. * @@ -179,23 +211,18 @@ private void initializeService() { * used by Retrofit to perform actually REST calls. */ interface KeyVaultClientService { - @Headers({"Content-Type: application/json; charset=utf-8", "Accept: application/pkcs10"}) + @Headers({ "Content-Type: application/json; charset=utf-8", "Accept: application/pkcs10", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getPendingCertificateSigningRequest" }) @GET("certificates/{certificate-name}/pending") Observable> getPendingCertificateSigningRequest(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); } /** - * Creates a new, named, key in the specified vault. + * Creates a new key, stores it, then returns key parameters and attributes to the client. The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: Requires the keys/create permission. * * @param createKeyRequest the grouped properties for creating a key request - * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle if successful. */ - public KeyBundle createKey(CreateKeyRequest createKeyRequest) - throws KeyVaultErrorException, IllegalArgumentException, IOException { + public KeyBundle createKey(CreateKeyRequest createKeyRequest) { return innerKeyVaultClient.createKey( createKeyRequest.vaultBaseUrl(), createKeyRequest.keyName(), @@ -207,7 +234,7 @@ public KeyBundle createKey(CreateKeyRequest createKeyRequest) } /** - * Creates a new, named, key in the specified vault. + * Creates a new key, stores it, then returns key parameters and attributes to the client. The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: Requires the keys/create permission. * * @param createKeyRequest the grouped properties for creating a key request * @@ -227,17 +254,13 @@ public ServiceCall createKeyAsync(CreateKeyRequest createKeyRequest, } /** - * Imports a key into the specified vault. + * Imports an externally created key, stores it, and returns key parameters and attributes to the client. The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: requires the keys/import permission. * * @param importKeyRequest the grouped properties for importing a key request * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle if successful. */ - public KeyBundle importKey(ImportKeyRequest importKeyRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyBundle importKey(ImportKeyRequest importKeyRequest) { return innerKeyVaultClient.importKey( importKeyRequest.vaultBaseUrl(), importKeyRequest.keyName(), @@ -248,7 +271,7 @@ public KeyBundle importKey(ImportKeyRequest importKeyRequest) } /** - * Imports a key into the specified vault. + * Imports an externally created key, stores it, and returns key parameters and attributes to the client. The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: requires the keys/import permission. * * @param importKeyRequest the grouped properties for importing a key request * @@ -267,22 +290,18 @@ public ServiceCall importKeyAsync(ImportKeyRequest importKeyRequest, } /** - * Deletes the specified key. + * Deletes a key of any type from storage in Azure Key Vault. The delete key operation cannot be used to remove individual versions of a key. This operation removes the cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. Authorization: Requires the keys/delete permission. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle if successful. */ - public KeyBundle deleteKey(String vaultBaseUrl, String keyName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyBundle deleteKey(String vaultBaseUrl, String keyName) { return innerKeyVaultClient.deleteKey(vaultBaseUrl, keyName); } /** - * Deletes the specified key. + * Deletes a key of any type from storage in Azure Key Vault. The delete key operation cannot be used to remove individual versions of a key. This operation removes the cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. Authorization: Requires the keys/delete permission. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key @@ -294,17 +313,13 @@ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName } /** - * Updates the Key Attributes associated with the specified key. + * The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault. The cryptographic material of a key itself cannot be changed. In order to perform this operation, the key must already exist in the Key Vault. Authorization: requires the keys/update permission. * * @param updateKeyRequest the grouped properties for updating a key request * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle if successful. */ - public KeyBundle updateKey(UpdateKeyRequest updateKeyRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyBundle updateKey(UpdateKeyRequest updateKeyRequest) { return innerKeyVaultClient.updateKey( updateKeyRequest.vaultBaseUrl(), updateKeyRequest.keyName(), @@ -315,7 +330,7 @@ public KeyBundle updateKey(UpdateKeyRequest updateKeyRequest) } /** - * Updates the Key Attributes associated with the specified key. + * The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault. The cryptographic material of a key itself cannot be changed. In order to perform this operation, the key must already exist in the Key Vault. Authorization: requires the keys/update permission. * * @param updateKeyRequest the grouped properties for updating a key request * @@ -334,22 +349,19 @@ public ServiceCall updateKeyAsync(UpdateKeyRequest updateKeyRequest, } /** - * Retrieves the public portion of a key plus its attributes. + * Gets the public part of a stored key. The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. Authorization: Requires the keys/get permission. * * @param keyIdentifier The full key identifier - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the KeyBundle if successful. */ - public KeyBundle getKey(String keyIdentifier) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyBundle getKey(String keyIdentifier) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.getKey(id.vault, id.name, id.version == null ? "" : id.version); } /** - * Retrieves the public portion of a key plus its attributes. + * Gets the public part of a stored key. The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. Authorization: Requires the keys/get permission. * * @param keyIdentifier The full key identifier * @param serviceCallback the async ServiceCallback to handle successful and failed responses. @@ -361,22 +373,18 @@ public ServiceCall getKeyAsync(String keyIdentifier, final ServiceCal } /** - * Retrieves the public portion of a key plus its attributes. + * Gets the public part of a stored key. The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. Authorization: Requires the keys/get permission. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle if successful. */ - public KeyBundle getKey(String vaultBaseUrl, String keyName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyBundle getKey(String vaultBaseUrl, String keyName) { return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, ""); } /** - * Retrieves the public portion of a key plus its attributes. + * Gets the public part of a stored key. The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. Authorization: Requires the keys/get permission. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key @@ -388,23 +396,20 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, f } /** - * Retrieves the public portion of a key plus its attributes. + *Gets the public part of a stored key. The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. Authorization: Requires the keys/get permission. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param keyVersion The version of the key - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the KeyBundle if successful. */ - public KeyBundle getKey(String vaultBaseUrl, String keyName, String keyVersion) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyBundle getKey(String vaultBaseUrl, String keyName, String keyVersion) { return innerKeyVaultClient.getKey(vaultBaseUrl, keyName, keyVersion); } /** - * Retrieves the public portion of a key plus its attributes. + * Gets the public part of a stored key. The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. Authorization: Requires the keys/get permission. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key @@ -417,22 +422,19 @@ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, S } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<KeyItem> if successful. */ - public PagedList listKeyVersions(final String vaultBaseUrl, final String keyName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listKeyVersions(final String vaultBaseUrl, final String keyName) { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName); } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key @@ -443,23 +445,20 @@ public ServiceCall> listKeyVersionsAsync(final String vaultBaseUrl return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, serviceCallback); } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<KeyItem> if successful. */ - public PagedList listKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) { return innerKeyVaultClient.getKeyVersions(vaultBaseUrl, keyName, maxresults); } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key @@ -475,13 +474,10 @@ public ServiceCall> listKeyVersionsAsync(final String vaultBaseUrl * List keys in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<KeyItem> if successful. */ - public PagedList listKeys(final String vaultBaseUrl) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listKeys(final String vaultBaseUrl) { return innerKeyVaultClient.getKeys(vaultBaseUrl); } @@ -500,13 +496,10 @@ public ServiceCall> listKeysAsync(final String vaultBaseUrl, final * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<KeyItem> if successful. */ - public PagedList listKeys(final String vaultBaseUrl, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listKeys(final String vaultBaseUrl, final Integer maxresults) { return innerKeyVaultClient.getKeys(vaultBaseUrl, maxresults); } @@ -527,13 +520,10 @@ public ServiceCall> listKeysAsync(final String vaultBaseUrl, final * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the BackupKeyResult if successful. */ - public BackupKeyResult backupKey(String vaultBaseUrl, String keyName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public BackupKeyResult backupKey(String vaultBaseUrl, String keyName) { return innerKeyVaultClient.backupKey(vaultBaseUrl, keyName); } @@ -554,13 +544,10 @@ public ServiceCall backupKeyAsync(String vaultBaseUrl, String k * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyBundleBackup the backup blob associated with a key bundle - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the KeyBundle if successful. */ - public KeyBundle restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyBundle restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) { return innerKeyVaultClient.restoreKey(vaultBaseUrl, keyBundleBackup); } @@ -577,24 +564,21 @@ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBun } /** - * Encrypts a single block of data. The amount of data that may be encrypted is determined. + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault. * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier * @param value the content to be encrypted - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the KeyOperationResult if successful. */ - public KeyOperationResult encrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyOperationResult encrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); } /** - * Encrypts a single block of data. The amount of data that may be encrypted is determined. + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault. * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier @@ -613,13 +597,10 @@ public ServiceCall encryptAsync(String keyIdentifier, JsonWe * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier * @param value the content to be decrypted - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the KeyOperationResult if successful. */ - public KeyOperationResult decrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyOperationResult decrypt(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decrypt(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); } @@ -639,24 +620,21 @@ public ServiceCall decryptAsync(String keyIdentifier, JsonWe } /** - * Creates a signature from a digest using the specified key in the vault. + * Creates a signature from a digest using the specified key. * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier * @param value the content to be signed - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the KeyOperationResult if successful. */ - public KeyOperationResult sign(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyOperationResult sign(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.sign(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); } /** - * Creates a signature from a digest using the specified key in the vault. + * Creates a signature from a digest using the specified key. * * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier @@ -676,13 +654,10 @@ public ServiceCall signAsync(String keyIdentifier, JsonWebKe * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. * @param digest The digest used for signing * @param signature The signature to be verified - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the KeyVerifyResult if successful. */ - public KeyVerifyResult verify(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyVerifyResult verify(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verify(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature); } @@ -708,13 +683,10 @@ public ServiceCall verifyAsync(String keyIdentifier, JsonWebKey * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier * @param value the key to be wrapped - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the KeyOperationResult if successful. */ - public KeyOperationResult wrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyOperationResult wrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); } @@ -739,13 +711,10 @@ public ServiceCall wrapKeyAsync(String keyIdentifier, JsonWe * @param keyIdentifier The full key identifier * @param algorithm algorithm identifier * @param value the key to be unwrapped - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the KeyOperationResult if successful. */ - public KeyOperationResult unwrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public KeyOperationResult unwrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKey(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value); } @@ -769,13 +738,9 @@ public ServiceCall unwrapKeyAsync(String keyIdentifier, Json * * @param setSecretRequest the grouped properties for setting a secret request * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle if successful. */ - public SecretBundle setSecret(SetSecretRequest setSecretRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public SecretBundle setSecret(SetSecretRequest setSecretRequest) { return innerKeyVaultClient.setSecret( setSecretRequest.vaultBaseUrl(), setSecretRequest.secretName(), @@ -809,13 +774,10 @@ public ServiceCall setSecretAsync(SetSecretRequest setSecretReques * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the SecretBundle if successful. */ - public SecretBundle deleteSecret(String vaultBaseUrl, String secretName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public SecretBundle deleteSecret(String vaultBaseUrl, String secretName) { return innerKeyVaultClient.deleteSecret(vaultBaseUrl, secretName); } @@ -832,17 +794,13 @@ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String s } /** - * Updates the attributes associated with the specified secret. + * Updates the attributes associated with a specified secret in a given key vault. * * @param updateSecretRequest the grouped properties for updating a secret request * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the SecretBundle if successful. */ - public SecretBundle updateSecret(UpdateSecretRequest updateSecretRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public SecretBundle updateSecret(UpdateSecretRequest updateSecretRequest) { return innerKeyVaultClient.updateSecret( updateSecretRequest.vaultBaseUrl(), updateSecretRequest.secretName(), @@ -853,7 +811,7 @@ public SecretBundle updateSecret(UpdateSecretRequest updateSecretRequest) } /** - * Updates the attributes associated with the specified secret. + * Updates the attributes associated with a specified secret in a given key vault. * * @param updateSecretRequest the grouped properties for updating a secret request * @@ -872,22 +830,19 @@ public ServiceCall updateSecretAsync(UpdateSecretRequest updateSec } /** - * Gets a secret. + * Get a specified secret from a given key vault. * * @param secretIdentifier The URL for the secret. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the SecretBundle if successful. */ - public SecretBundle getSecret(String secretIdentifier) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public SecretBundle getSecret(String secretIdentifier) { SecretIdentifier id = new SecretIdentifier(secretIdentifier); return innerKeyVaultClient.getSecret(id.vault, id.name, id.version == null ? "" : id.version); } /** - * Gets a secret. + * Get a specified secret from a given key vault. * * @param secretIdentifier The URL for the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. @@ -899,22 +854,19 @@ public ServiceCall getSecretAsync(String secretIdentifier, final S } /** - * Gets a secret. + * Get a specified secret from a given key vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the SecretBundle if successful. */ - public SecretBundle getSecret(String vaultBaseUrl, String secretName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public SecretBundle getSecret(String vaultBaseUrl, String secretName) { return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, ""); } /** - * Gets a secret. + * Get a specified secret from a given key vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault @@ -926,23 +878,20 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr } /** - * Gets a secret. + * Get a specified secret from a given key vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the SecretBundle if successful. */ - public SecretBundle getSecret(String vaultBaseUrl, String secretName, String secretVersion) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public SecretBundle getSecret(String vaultBaseUrl, String secretName, String secretVersion) { return innerKeyVaultClient.getSecret(vaultBaseUrl, secretName, secretVersion == null ? "" : secretVersion); } /** - * Gets a secret. + * Get a specified secret from a given key vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault @@ -958,13 +907,10 @@ public ServiceCall getSecretAsync(String vaultBaseUrl, String secr * List secrets in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<SecretItem> if successful. */ - public PagedList listSecrets(final String vaultBaseUrl) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listSecrets(final String vaultBaseUrl) { return innerKeyVaultClient.getSecrets(vaultBaseUrl); } @@ -983,13 +929,10 @@ public ServiceCall> listSecretsAsync(final String vaultBaseUrl, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<SecretItem> if successful. */ - public PagedList listSecrets(final String vaultBaseUrl, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listSecrets(final String vaultBaseUrl, final Integer maxresults) { return innerKeyVaultClient.getSecrets(vaultBaseUrl, maxresults); } @@ -1010,13 +953,10 @@ public ServiceCall> listSecretsAsync(final String vaultBaseUrl, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<SecretItem> if successful. */ - public PagedList listSecretVersions(final String vaultBaseUrl, final String secretName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listSecretVersions(final String vaultBaseUrl, final String secretName) { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName); } @@ -1037,13 +977,10 @@ public ServiceCall> listSecretVersionsAsync(final String vaultB * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<SecretItem> if successful. */ - public PagedList listSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) { return innerKeyVaultClient.getSecretVersions(vaultBaseUrl, secretName, maxresults); } @@ -1064,13 +1001,10 @@ public ServiceCall> listSecretVersionsAsync(final String vaultB * List certificates in the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<CertificateItem> if successful. */ - public PagedList listCertificates(final String vaultBaseUrl) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listCertificates(final String vaultBaseUrl) { return innerKeyVaultClient.getCertificates(vaultBaseUrl); } @@ -1089,13 +1023,10 @@ public ServiceCall> listCertificatesAsync(final String vau * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<CertificateItem> if successful. */ - public PagedList listCertificates(final String vaultBaseUrl, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listCertificates(final String vaultBaseUrl, final Integer maxresults) { return innerKeyVaultClient.getCertificates(vaultBaseUrl, maxresults); } @@ -1116,13 +1047,10 @@ public ServiceCall> listCertificatesAsync(final String vau * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the CertificateBundle if successful. */ - public CertificateBundle deleteCertificate(String vaultBaseUrl, String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificateBundle deleteCertificate(String vaultBaseUrl, String certificateName) { return innerKeyVaultClient.deleteCertificate(vaultBaseUrl, certificateName); } @@ -1143,13 +1071,10 @@ public ServiceCall deleteCertificateAsync(String vaultBaseUrl * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param contacts The contacts for the vault certificates. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the Contacts if successful. */ - public Contacts setCertificateContacts(String vaultBaseUrl, Contacts contacts) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public Contacts setCertificateContacts(String vaultBaseUrl, Contacts contacts) { return innerKeyVaultClient.setCertificateContacts(vaultBaseUrl, contacts); } @@ -1169,13 +1094,10 @@ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Co * Gets the certificate contacts for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the Contacts if successful. */ - public Contacts getCertificateContacts(String vaultBaseUrl) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public Contacts getCertificateContacts(String vaultBaseUrl) { return innerKeyVaultClient.getCertificateContacts(vaultBaseUrl); } @@ -1194,13 +1116,10 @@ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, fi * Deletes the certificate contacts for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the Contacts if successful. */ - public Contacts deleteCertificateContacts(String vaultBaseUrl) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public Contacts deleteCertificateContacts(String vaultBaseUrl) { return innerKeyVaultClient.deleteCertificateContacts(vaultBaseUrl); } @@ -1219,13 +1138,10 @@ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, * List certificate issuers for the specified vault. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<CertificateIssuerItem> if successful. */ - public PagedList listCertificateIssuers(final String vaultBaseUrl) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listCertificateIssuers(final String vaultBaseUrl) { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl); } @@ -1244,13 +1160,10 @@ public ServiceCall> listCertificateIssuersAsync(fina * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<CertificateIssuerItem> if successful. */ - public PagedList listCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) { return innerKeyVaultClient.getCertificateIssuers(vaultBaseUrl, maxresults); } @@ -1271,13 +1184,9 @@ public ServiceCall> listCertificateIssuersAsync(fina * * @param setCertificateIssuerRequest the grouped properties for setting a certificate issuer request * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle if successful. */ - public IssuerBundle setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public IssuerBundle setCertificateIssuer(SetCertificateIssuerRequest setCertificateIssuerRequest) { return innerKeyVaultClient.setCertificateIssuer( setCertificateIssuerRequest.vaultBaseUrl(), setCertificateIssuerRequest.issuerName(), @@ -1311,13 +1220,9 @@ public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerR * * @param updateCertificateIssuerRequest the grouped properties for updating a certificate issuer request * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle if successful. */ - public IssuerBundle updateCertificateIssuer(UpdateCertificateIssuerRequest updateCertificateIssuerRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public IssuerBundle updateCertificateIssuer(UpdateCertificateIssuerRequest updateCertificateIssuerRequest) { return innerKeyVaultClient.updateCertificateIssuer( updateCertificateIssuerRequest.vaultBaseUrl(), updateCertificateIssuerRequest.issuerName(), @@ -1352,13 +1257,10 @@ public ServiceCall updateCertificateIssuerAsync(UpdateCertificateI * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the IssuerBundle if successful. */ - public IssuerBundle getCertificateIssuer(String vaultBaseUrl, String issuerName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public IssuerBundle getCertificateIssuer(String vaultBaseUrl, String issuerName) { return innerKeyVaultClient.getCertificateIssuer(vaultBaseUrl, issuerName); } @@ -1379,13 +1281,10 @@ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the IssuerBundle if successful. */ - public IssuerBundle deleteCertificateIssuer(String vaultBaseUrl, String issuerName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public IssuerBundle deleteCertificateIssuer(String vaultBaseUrl, String issuerName) { return innerKeyVaultClient.deleteCertificateIssuer(vaultBaseUrl, issuerName); } @@ -1406,13 +1305,9 @@ public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUr * * @param createCertificateRequest the grouped properties for creating a certificate request * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOperation if successful. */ - public CertificateOperation createCertificate(CreateCertificateRequest createCertificateRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificateOperation createCertificate(CreateCertificateRequest createCertificateRequest) { return innerKeyVaultClient.createCertificate( createCertificateRequest.vaultBaseUrl(), createCertificateRequest.certificateName(), @@ -1444,13 +1339,9 @@ public ServiceCall createCertificateAsync(CreateCertificat * * @param importCertificateRequest the grouped properties for importing a certificate request * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle if successful. */ - public CertificateBundle importCertificate(ImportCertificateRequest importCertificateRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificateBundle importCertificate(ImportCertificateRequest importCertificateRequest) { return innerKeyVaultClient.importCertificate( importCertificateRequest.vaultBaseUrl(), importCertificateRequest.certificateName(), @@ -1486,13 +1377,10 @@ public ServiceCall importCertificateAsync(ImportCertificateRe * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<CertificateItem> if successful. */ - public PagedList listCertificateVersions(final String vaultBaseUrl, final String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listCertificateVersions(final String vaultBaseUrl, final String certificateName) { return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName); } @@ -1513,13 +1401,10 @@ public ServiceCall> listCertificateVersionsAsync(final Str * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the PagedList<CertificateItem> if successful. */ - public PagedList listCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList listCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { return innerKeyVaultClient.getCertificateVersions(vaultBaseUrl, certificateName, maxresults); } @@ -1541,13 +1426,10 @@ public ServiceCall> listCertificateVersionsAsync(final Str * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the CertificatePolicy if successful. */ - public CertificatePolicy getCertificatePolicy(String vaultBaseUrl, String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificatePolicy getCertificatePolicy(String vaultBaseUrl, String certificateName) { return innerKeyVaultClient.getCertificatePolicy(vaultBaseUrl, certificateName); } @@ -1568,13 +1450,9 @@ public ServiceCall getCertificatePolicyAsync(String vaultBase * * @param updateCertificatePolicyRequest the grouped properties for updating a certificate policy request * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificatePolicy if successful. */ - public CertificatePolicy updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificatePolicy updateCertificatePolicy(UpdateCertificatePolicyRequest updateCertificatePolicyRequest) { return innerKeyVaultClient.updateCertificatePolicy( updateCertificatePolicyRequest.vaultBaseUrl(), updateCertificatePolicyRequest.certificateName(), @@ -1602,13 +1480,9 @@ public ServiceCall updateCertificatePolicyAsync(UpdateCertifi * * @param updateCertificateRequest the grouped properties for updating a certificate request * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle if successful. */ - public CertificateBundle updateCertificate(UpdateCertificateRequest updateCertificateRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificateBundle updateCertificate(UpdateCertificateRequest updateCertificateRequest) { return innerKeyVaultClient.updateCertificate( updateCertificateRequest.vaultBaseUrl(), updateCertificateRequest.certificateName(), @@ -1638,22 +1512,19 @@ public ServiceCall updateCertificateAsync(UpdateCertificateRe } /** - * Gets a Certificate. + * Gets information about a specified certificate. * * @param certificateIdentifier The certificate identifier - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the CertificateBundle if successful. */ - public CertificateBundle getCertificate(String certificateIdentifier) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificateBundle getCertificate(String certificateIdentifier) { CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); return innerKeyVaultClient.getCertificate(id.vault, id.name, id.version == null ? "" : id.version); } /** - * Gets a Certificate. + * Gets information about a specified certificate. * * @param certificateIdentifier The certificate identifier * @param serviceCallback the async ServiceCallback to handle successful and failed responses. @@ -1665,22 +1536,19 @@ public ServiceCall getCertificateAsync(String certificateIden } /** - * Gets a Certificate. + * Gets information about a specified certificate. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the CertificateBundle if successful. */ - public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName) { return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, ""); } /** - * Gets a Certificate. + * Gets information about a specified certificate. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault @@ -1692,23 +1560,20 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S } /** - * Gets a Certificate. + * Gets information about a specified certificate. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the CertificateBundle if successful. */ - public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) { return innerKeyVaultClient.getCertificate(vaultBaseUrl, certificateName, certificateVersion); } /** - * Gets a Certificate. + * Gets information about a specified certificate. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault @@ -1725,13 +1590,9 @@ public ServiceCall getCertificateAsync(String vaultBaseUrl, S * * @param updateCertificateOperationRequest the grouped properties for updating a certificate operation request * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateOperation if successful. */ - public CertificateOperation updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificateOperation updateCertificateOperation(UpdateCertificateOperationRequest updateCertificateOperationRequest) { return innerKeyVaultClient.updateCertificateOperation( updateCertificateOperationRequest.vaultBaseUrl(), updateCertificateOperationRequest.certificateName(), @@ -1755,22 +1616,19 @@ public ServiceCall updateCertificateOperationAsync(UpdateC } /** - * Gets the certificate operation response. + * Gets the operation associated with a specified certificate. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the CertificateOperation if successful. */ - public CertificateOperation getCertificateOperation(String vaultBaseUrl, String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificateOperation getCertificateOperation(String vaultBaseUrl, String certificateName) { return innerKeyVaultClient.getCertificateOperation(vaultBaseUrl, certificateName); } /** - * Gets the certificate operation response. + * Gets the operation associated with a specified certificate. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate @@ -1782,22 +1640,19 @@ public ServiceCall getCertificateOperationAsync(String vau } /** - * Deletes the certificate operation. + * Deletes the operation for a specified certificate. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the CertificateOperation if successful. */ - public CertificateOperation deleteCertificateOperation(String vaultBaseUrl, String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificateOperation deleteCertificateOperation(String vaultBaseUrl, String certificateName) { return innerKeyVaultClient.deleteCertificateOperation(vaultBaseUrl, certificateName); } /** - * Deletes the certificate operation. + * Deletes the operation for a specified certificate. * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate @@ -1813,13 +1668,9 @@ public ServiceCall deleteCertificateOperationAsync(String * * @param mergeCertificateRequest the grouped properties for merging a certificate request * - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle if successful. */ - public CertificateBundle mergeCertificate(MergeCertificateRequest mergeCertificateRequest) - throws KeyVaultErrorException, IOException, IllegalArgumentException { + public CertificateBundle mergeCertificate(MergeCertificateRequest mergeCertificateRequest) { return innerKeyVaultClient.mergeCertificate( mergeCertificateRequest.vaultBaseUrl(), mergeCertificateRequest.certificateName(), @@ -1852,14 +1703,11 @@ public ServiceCall mergeCertificateAsync(MergeCertificateRequ * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * * @return the String if successful. */ - public String getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) - throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getPendingCertificateSigningRequestWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); + public String getPendingCertificateSigningRequest(String vaultBaseUrl, String certificateName) { + return getPendingCertificateSigningRequestWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().body(); } /** @@ -1871,7 +1719,7 @@ public String getPendingCertificateSigningRequest(String vaultBaseUrl, String ce * @return the {@link ServiceCall} object */ public ServiceCall getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getPendingCertificateSigningRequestWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.fromResponse(getPendingCertificateSigningRequestWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** @@ -1897,7 +1745,7 @@ private Observable> getPendingCertificateSigningRequestW @Override public Observable> call(Response response) { try { - ServiceResponse clientResponse = new ServiceResponse(response.body().string(), response); + ServiceResponse clientResponse = new ServiceResponse(response.body().string(), response); return Observable.just(clientResponse); } catch (Throwable t) { return Observable.error(t); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index d9b1bbac60a5d..a9ac3d905dbc9 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -15,7 +15,6 @@ import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceCall; import com.microsoft.azure.AzureServiceClient; -import com.microsoft.azure.AzureServiceResponseBuilder; import com.microsoft.azure.keyvault.models.BackupKeyResult; import com.microsoft.azure.keyvault.models.CertificateAttributes; import com.microsoft.azure.keyvault.models.CertificateBundle; @@ -62,9 +61,8 @@ import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.Page; import com.microsoft.azure.PagedList; -import com.microsoft.azure.RestClient; import com.microsoft.rest.credentials.ServiceClientCredentials; -import com.microsoft.rest.RestException; +import com.microsoft.rest.RestClient; import com.microsoft.rest.ServiceCall; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -105,11 +103,11 @@ public AzureClient getAzureClient() { return this.azureClient; } - /** Client Api Version. */ + /** Client API version. */ private String apiVersion; /** - * Gets Client Api Version. + * Gets Client API version. * * @return the apiVersion value. */ @@ -191,7 +189,7 @@ public KeyVaultClientImpl withGenerateClientRequestId(boolean generateClientRequ * * @param credentials the management credentials for Azure */ - KeyVaultClientImpl(ServiceClientCredentials credentials) { + public KeyVaultClientImpl(ServiceClientCredentials credentials) { this("https://{vaultBaseUrl}", credentials); } @@ -202,10 +200,8 @@ public KeyVaultClientImpl withGenerateClientRequestId(boolean generateClientRequ * @param credentials the management credentials for Azure */ private KeyVaultClientImpl(String baseUrl, ServiceClientCredentials credentials) { - this(new RestClient.Builder() - .withBaseUrl(baseUrl) - .withCredentials(credentials) - .build()); + super(baseUrl, credentials); + initialize(); } /** @@ -213,7 +209,7 @@ private KeyVaultClientImpl(String baseUrl, ServiceClientCredentials credentials) * * @param restClient the REST client to connect to Azure. */ - KeyVaultClientImpl(RestClient restClient) { + public KeyVaultClientImpl(RestClient restClient) { super(restClient); initialize(); } @@ -248,255 +244,252 @@ private void initializeService() { * used by Retrofit to perform actually REST calls. */ interface KeyVaultClientService { - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient createKey" }) @POST("keys/{key-name}/create") Observable> createKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient importKey" }) @PUT("keys/{key-name}") Observable> importKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient deleteKey" }) @HTTP(path = "keys/{key-name}", method = "DELETE", hasBody = true) Observable> deleteKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient updateKey" }) @PATCH("keys/{key-name}/{key-version}") Observable> updateKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getKey" }) @GET("keys/{key-name}/{key-version}") Observable> getKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getKeyVersions" }) @GET("keys/{key-name}/versions") Observable> getKeyVersions(@Path("key-name") String keyName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getKeys" }) @GET("keys") Observable> getKeys(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient backupKey" }) @POST("keys/{key-name}/backup") Observable> backupKey(@Path("key-name") String keyName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient restoreKey" }) @POST("keys/restore") Observable> restoreKey(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyRestoreParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient encrypt" }) @POST("keys/{key-name}/{key-version}/encrypt") Observable> encrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient decrypt" }) @POST("keys/{key-name}/{key-version}/decrypt") Observable> decrypt(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient sign" }) @POST("keys/{key-name}/{key-version}/sign") Observable> sign(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeySignParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient verify" }) @POST("keys/{key-name}/{key-version}/verify") Observable> verify(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyVerifyParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient wrapKey" }) @POST("keys/{key-name}/{key-version}/wrapkey") Observable> wrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient unwrapKey" }) @POST("keys/{key-name}/{key-version}/unwrapkey") Observable> unwrapKey(@Path("key-name") String keyName, @Path("key-version") String keyVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body KeyOperationsParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient setSecret" }) @PUT("secrets/{secret-name}") Observable> setSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretSetParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient deleteSecret" }) @HTTP(path = "secrets/{secret-name}", method = "DELETE", hasBody = true) Observable> deleteSecret(@Path("secret-name") String secretName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient updateSecret" }) @PATCH("secrets/{secret-name}/{secret-version}") Observable> updateSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body SecretUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getSecret" }) @GET("secrets/{secret-name}/{secret-version}") Observable> getSecret(@Path("secret-name") String secretName, @Path("secret-version") String secretVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getSecrets" }) @GET("secrets") Observable> getSecrets(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getSecretVersions" }) @GET("secrets/{secret-name}/versions") Observable> getSecretVersions(@Path("secret-name") String secretName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getCertificates" }) @GET("certificates") Observable> getCertificates(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient deleteCertificate" }) @HTTP(path = "certificates/{certificate-name}", method = "DELETE", hasBody = true) Observable> deleteCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient setCertificateContacts" }) @PUT("certificates/contacts") Observable> setCertificateContacts(@Body Contacts contacts, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getCertificateContacts" }) @GET("certificates/contacts") Observable> getCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient deleteCertificateContacts" }) @HTTP(path = "certificates/contacts", method = "DELETE", hasBody = true) Observable> deleteCertificateContacts(@Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getCertificateIssuers" }) @GET("certificates/issuers") Observable> getCertificateIssuers(@Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient setCertificateIssuer" }) @PUT("certificates/issuers/{issuer-name}") Observable> setCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerSetParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient updateCertificateIssuer" }) @PATCH("certificates/issuers/{issuer-name}") Observable> updateCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateIssuerUpdateParameters parameter, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getCertificateIssuer" }) @GET("certificates/issuers/{issuer-name}") Observable> getCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient deleteCertificateIssuer" }) @HTTP(path = "certificates/issuers/{issuer-name}", method = "DELETE", hasBody = true) Observable> deleteCertificateIssuer(@Path("issuer-name") String issuerName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient createCertificate" }) @POST("certificates/{certificate-name}/create") Observable> createCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateCreateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient importCertificate" }) @POST("certificates/{certificate-name}/import") Observable> importCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateImportParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getCertificateVersions" }) @GET("certificates/{certificate-name}/versions") Observable> getCertificateVersions(@Path("certificate-name") String certificateName, @Query("maxresults") Integer maxresults, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getCertificatePolicy" }) @GET("certificates/{certificate-name}/policy") Observable> getCertificatePolicy(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient updateCertificatePolicy" }) @PATCH("certificates/{certificate-name}/policy") Observable> updateCertificatePolicy(@Path("certificate-name") String certificateName, @Body CertificatePolicy certificatePolicy, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient updateCertificate" }) @PATCH("certificates/{certificate-name}/{certificate-version}") Observable> updateCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateUpdateParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getCertificate" }) @GET("certificates/{certificate-name}/{certificate-version}") Observable> getCertificate(@Path("certificate-name") String certificateName, @Path("certificate-version") String certificateVersion, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient updateCertificateOperation" }) @PATCH("certificates/{certificate-name}/pending") Observable> updateCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateOperationUpdateParameter certificateOperation, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getCertificateOperation" }) @GET("certificates/{certificate-name}/pending") Observable> getCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient deleteCertificateOperation" }) @HTTP(path = "certificates/{certificate-name}/pending", method = "DELETE", hasBody = true) Observable> deleteCertificateOperation(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient mergeCertificate" }) @POST("certificates/{certificate-name}/pending/merge") Observable> mergeCertificate(@Path("certificate-name") String certificateName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body CertificateMergeParameters parameters, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getKeyVersionsNext" }) @GET - Observable> getKeyVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getKeyVersionsNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getKeysNext" }) @GET - Observable> getKeysNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getKeysNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getSecretsNext" }) @GET - Observable> getSecretsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getSecretsNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getSecretVersionsNext" }) @GET - Observable> getSecretVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getSecretVersionsNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getCertificatesNext" }) @GET - Observable> getCertificatesNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getCertificatesNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getCertificateIssuersNext" }) @GET - Observable> getCertificateIssuersNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getCertificateIssuersNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - @Headers("Content-Type: application/json; charset=utf-8") + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.keyvault.KeyVaultClient getCertificateVersionsNext" }) @GET - Observable> getCertificateVersionsNext(@Url String nextPageLink, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + Observable> getCertificateVersionsNext(@Url String nextUrl, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); } /** - * Creates a new, named, key in the specified vault. + * Creates a new key, stores it, then returns key parameters and attributes to the client. The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: Requires the keys/create permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name for the new key. The system will generate the version name for the new key. + * @param kty The type of key to create. For valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @return the KeyBundle object if successful. */ - public KeyBundle createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty).toBlocking().single().getBody(); + public KeyBundle createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { + return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty).toBlocking().single().body(); } /** - * Creates a new, named, key in the specified vault. + * Creates a new key, stores it, then returns key parameters and attributes to the client. The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: Requires the keys/create permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name for the new key. The system will generate the version name for the new key. + * @param kty The type of key to create. For valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, final ServiceCallback serviceCallback) { - return ServiceCall.create(createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty), serviceCallback); + return ServiceCall.fromResponse(createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty), serviceCallback); } /** - * Creates a new, named, key in the specified vault. + * Creates a new key, stores it, then returns key parameters and attributes to the client. The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: Requires the keys/create permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name for the new key. The system will generate the version name for the new key. + * @param kty The type of key to create. For valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @return the observable to the KeyBundle object */ public Observable createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty).map(new Func1, KeyBundle>() { @Override public KeyBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Creates a new, named, key in the specified vault. + * Creates a new key, stores it, then returns key parameters and attributes to the client. The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: Requires the keys/create permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name for the new key. The system will generate the version name for the new key. + * @param kty The type of key to create. For valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @return the observable to the KeyBundle object */ public Observable> createKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty) { @@ -538,72 +531,69 @@ public Observable> call(Response respon } /** - * Creates a new, named, key in the specified vault. + * Creates a new key, stores it, then returns key parameters and attributes to the client. The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: Requires the keys/create permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' - * @param keySize The key size in bytes. e.g. 1024 or 2048. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name for the new key. The system will generate the version name for the new key. + * @param kty The type of key to create. For valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param keySize The key size in bytes. For example, 1024 or 2048. * @param keyOps the List<JsonWebKeyOperation> value * @param keyAttributes the KeyAttributes value - * @param tags Application-specific metadata in the form of key-value pairs - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param tags Application specific metadata in the form of key-value pairs. * @return the KeyBundle object if successful. */ - public KeyBundle createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).toBlocking().single().getBody(); + public KeyBundle createKey(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { + return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).toBlocking().single().body(); } /** - * Creates a new, named, key in the specified vault. + * Creates a new key, stores it, then returns key parameters and attributes to the client. The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: Requires the keys/create permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' - * @param keySize The key size in bytes. e.g. 1024 or 2048. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name for the new key. The system will generate the version name for the new key. + * @param kty The type of key to create. For valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param keySize The key size in bytes. For example, 1024 or 2048. * @param keyOps the List<JsonWebKeyOperation> value * @param keyAttributes the KeyAttributes value - * @param tags Application-specific metadata in the form of key-value pairs + * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags), serviceCallback); + return ServiceCall.fromResponse(createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags), serviceCallback); } /** - * Creates a new, named, key in the specified vault. + * Creates a new key, stores it, then returns key parameters and attributes to the client. The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: Requires the keys/create permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' - * @param keySize The key size in bytes. e.g. 1024 or 2048. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name for the new key. The system will generate the version name for the new key. + * @param kty The type of key to create. For valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param keySize The key size in bytes. For example, 1024 or 2048. * @param keyOps the List<JsonWebKeyOperation> value * @param keyAttributes the KeyAttributes value - * @param tags Application-specific metadata in the form of key-value pairs + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the KeyBundle object */ public Observable createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { return createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags).map(new Func1, KeyBundle>() { @Override public KeyBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Creates a new, named, key in the specified vault. + * Creates a new key, stores it, then returns key parameters and attributes to the client. The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: Requires the keys/create permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param kty The type of key to create. Valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' - * @param keySize The key size in bytes. e.g. 1024 or 2048. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name for the new key. The system will generate the version name for the new key. + * @param kty The type of key to create. For valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' + * @param keySize The key size in bytes. For example, 1024 or 2048. * @param keyOps the List<JsonWebKeyOperation> value * @param keyAttributes the KeyAttributes value - * @param tags Application-specific metadata in the form of key-value pairs + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the KeyBundle object */ public Observable> createKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags) { @@ -644,45 +634,42 @@ public Observable> call(Response respon } private ServiceResponse createKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Imports a key into the specified vault. + * Imports an externally created key, stores it, and returns key parameters and attributes to the client. The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: requires the keys/import permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName Name for the imported key. * @param key The Json web key - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyBundle object if successful. */ - public KeyBundle importKey(String vaultBaseUrl, String keyName, JsonWebKey key) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key).toBlocking().single().getBody(); + public KeyBundle importKey(String vaultBaseUrl, String keyName, JsonWebKey key) { + return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key).toBlocking().single().body(); } /** - * Imports a key into the specified vault. + * Imports an externally created key, stores it, and returns key parameters and attributes to the client. The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: requires the keys/import permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName Name for the imported key. * @param key The Json web key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, final ServiceCallback serviceCallback) { - return ServiceCall.create(importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key), serviceCallback); + return ServiceCall.fromResponse(importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key), serviceCallback); } /** - * Imports a key into the specified vault. + * Imports an externally created key, stores it, and returns key parameters and attributes to the client. The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: requires the keys/import permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName Name for the imported key. * @param key The Json web key * @return the observable to the KeyBundle object */ @@ -690,16 +677,16 @@ public Observable importKeyAsync(String vaultBaseUrl, String keyName, return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key).map(new Func1, KeyBundle>() { @Override public KeyBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Imports a key into the specified vault. + * Imports an externally created key, stores it, and returns key parameters and attributes to the client. The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: requires the keys/import permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName Name for the imported key. * @param key The Json web key * @return the observable to the KeyBundle object */ @@ -741,68 +728,65 @@ public Observable> call(Response respon } /** - * Imports a key into the specified vault. + * Imports an externally created key, stores it, and returns key parameters and attributes to the client. The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: requires the keys/import permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName Name for the imported key. * @param key The Json web key - * @param hsm Whether to import as a hardware key (HSM) or software key - * @param keyAttributes The key management attributes - * @param tags Application-specific metadata in the form of key-value pairs - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param hsm Whether to import as a hardware key (HSM) or software key. + * @param keyAttributes The key management attributes. + * @param tags Application specific metadata in the form of key-value pairs. * @return the KeyBundle object if successful. */ - public KeyBundle importKey(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).toBlocking().single().getBody(); + public KeyBundle importKey(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { + return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).toBlocking().single().body(); } /** - * Imports a key into the specified vault. + * Imports an externally created key, stores it, and returns key parameters and attributes to the client. The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: requires the keys/import permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName Name for the imported key. * @param key The Json web key - * @param hsm Whether to import as a hardware key (HSM) or software key - * @param keyAttributes The key management attributes - * @param tags Application-specific metadata in the form of key-value pairs + * @param hsm Whether to import as a hardware key (HSM) or software key. + * @param keyAttributes The key management attributes. + * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags), serviceCallback); + return ServiceCall.fromResponse(importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags), serviceCallback); } /** - * Imports a key into the specified vault. + * Imports an externally created key, stores it, and returns key parameters and attributes to the client. The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: requires the keys/import permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName Name for the imported key. * @param key The Json web key - * @param hsm Whether to import as a hardware key (HSM) or software key - * @param keyAttributes The key management attributes - * @param tags Application-specific metadata in the form of key-value pairs + * @param hsm Whether to import as a hardware key (HSM) or software key. + * @param keyAttributes The key management attributes. + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the KeyBundle object */ public Observable importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { return importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags).map(new Func1, KeyBundle>() { @Override public KeyBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Imports a key into the specified vault. + * Imports an externally created key, stores it, and returns key parameters and attributes to the client. The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates a new version of the key. Authorization: requires the keys/import permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName Name for the imported key. * @param key The Json web key - * @param hsm Whether to import as a hardware key (HSM) or software key - * @param keyAttributes The key management attributes - * @param tags Application-specific metadata in the form of key-value pairs + * @param hsm Whether to import as a hardware key (HSM) or software key. + * @param keyAttributes The key management attributes. + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the KeyBundle object */ public Observable> importKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags) { @@ -842,59 +826,56 @@ public Observable> call(Response respon } private ServiceResponse importKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Deletes the specified key. + * Deletes a key of any type from storage in Azure Key Vault. The delete key operation cannot be used to remove individual versions of a key. This operation removes the cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. Authorization: Requires the keys/delete permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key to delete. * @return the KeyBundle object if successful. */ - public KeyBundle deleteKey(String vaultBaseUrl, String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName).toBlocking().single().getBody(); + public KeyBundle deleteKey(String vaultBaseUrl, String keyName) { + return deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName).toBlocking().single().body(); } /** - * Deletes the specified key. + * Deletes a key of any type from storage in Azure Key Vault. The delete key operation cannot be used to remove individual versions of a key. This operation removes the cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. Authorization: Requires the keys/delete permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key to delete. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback); + return ServiceCall.fromResponse(deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback); } /** - * Deletes the specified key. + * Deletes a key of any type from storage in Azure Key Vault. The delete key operation cannot be used to remove individual versions of a key. This operation removes the cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. Authorization: Requires the keys/delete permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key to delete. * @return the observable to the KeyBundle object */ public Observable deleteKeyAsync(String vaultBaseUrl, String keyName) { return deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName).map(new Func1, KeyBundle>() { @Override public KeyBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Deletes the specified key. + * Deletes a key of any type from storage in Azure Key Vault. The delete key operation cannot be used to remove individual versions of a key. This operation removes the cryptographic material associated with the key, which means the key is not usable for Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. Authorization: Requires the keys/delete permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key to delete. * @return the observable to the KeyBundle object */ public Observable> deleteKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName) { @@ -923,63 +904,60 @@ public Observable> call(Response respon } private ServiceResponse deleteKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Updates the Key Attributes associated with the specified key. + * The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault. The cryptographic material of a key itself cannot be changed. In order to perform this operation, the key must already exist in the Key Vault. Authorization: requires the keys/update permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of key to update. + * @param keyVersion The version of the key to update. * @return the KeyBundle object if successful. */ - public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single().getBody(); + public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersion) { + return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single().body(); } /** - * Updates the Key Attributes associated with the specified key. + * The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault. The cryptographic material of a key itself cannot be changed. In order to perform this operation, the key must already exist in the Key Vault. Authorization: requires the keys/update permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of key to update. + * @param keyVersion The version of the key to update. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + return ServiceCall.fromResponse(updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); } /** - * Updates the Key Attributes associated with the specified key. + * The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault. The cryptographic material of a key itself cannot be changed. In order to perform this operation, the key must already exist in the Key Vault. Authorization: requires the keys/update permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of key to update. + * @param keyVersion The version of the key to update. * @return the observable to the KeyBundle object */ public Observable updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).map(new Func1, KeyBundle>() { @Override public KeyBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Updates the Key Attributes associated with the specified key. + * The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault. The cryptographic material of a key itself cannot be changed. In order to perform this operation, the key must already exist in the Key Vault. Authorization: requires the keys/update permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of key to update. + * @param keyVersion The version of the key to update. * @return the observable to the KeyBundle object */ public Observable> updateKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion) { @@ -1018,68 +996,65 @@ public Observable> call(Response respon } /** - * Updates the Key Attributes associated with the specified key. + * The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault. The cryptographic material of a key itself cannot be changed. In order to perform this operation, the key must already exist in the Key Vault. Authorization: requires the keys/update permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of key to update. + * @param keyVersion The version of the key to update. * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. * @param keyAttributes the KeyAttributes value - * @param tags Application-specific metadata in the form of key-value pairs - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param tags Application specific metadata in the form of key-value pairs. * @return the KeyBundle object if successful. */ - public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).toBlocking().single().getBody(); + public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { + return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).toBlocking().single().body(); } /** - * Updates the Key Attributes associated with the specified key. + * The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault. The cryptographic material of a key itself cannot be changed. In order to perform this operation, the key must already exist in the Key Vault. Authorization: requires the keys/update permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of key to update. + * @param keyVersion The version of the key to update. * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. * @param keyAttributes the KeyAttributes value - * @param tags Application-specific metadata in the form of key-value pairs + * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags), serviceCallback); + return ServiceCall.fromResponse(updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags), serviceCallback); } /** - * Updates the Key Attributes associated with the specified key. + * The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault. The cryptographic material of a key itself cannot be changed. In order to perform this operation, the key must already exist in the Key Vault. Authorization: requires the keys/update permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of key to update. + * @param keyVersion The version of the key to update. * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. * @param keyAttributes the KeyAttributes value - * @param tags Application-specific metadata in the form of key-value pairs + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the KeyBundle object */ public Observable updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { return updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags).map(new Func1, KeyBundle>() { @Override public KeyBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Updates the Key Attributes associated with the specified key. + * The update key operation changes specified attributes of a stored key and can be applied to any key type and key version stored in Azure Key Vault. The cryptographic material of a key itself cannot be changed. In order to perform this operation, the key must already exist in the Key Vault. Authorization: requires the keys/update permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of key to update. + * @param keyVersion The version of the key to update. * @param keyOps Json web key operations. For more information on possible key operations, see JsonWebKeyOperation. * @param keyAttributes the KeyAttributes value - * @param tags Application-specific metadata in the form of key-value pairs + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the KeyBundle object */ public Observable> updateKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags) { @@ -1118,63 +1093,60 @@ public Observable> call(Response respon } private ServiceResponse updateKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Retrieves the public portion of a key plus its attributes. + * Gets the public part of a stored key. The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. Authorization: Requires the keys/get permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key to get. + * @param keyVersion Adding the version parameter retrieves a specific version of a key. * @return the KeyBundle object if successful. */ - public KeyBundle getKey(String vaultBaseUrl, String keyName, String keyVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single().getBody(); + public KeyBundle getKey(String vaultBaseUrl, String keyName, String keyVersion) { + return getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).toBlocking().single().body(); } /** - * Retrieves the public portion of a key plus its attributes. + * Gets the public part of a stored key. The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. Authorization: Requires the keys/get permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key to get. + * @param keyVersion Adding the version parameter retrieves a specific version of a key. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + return ServiceCall.fromResponse(getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); } /** - * Retrieves the public portion of a key plus its attributes. + * Gets the public part of a stored key. The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. Authorization: Requires the keys/get permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key to get. + * @param keyVersion Adding the version parameter retrieves a specific version of a key. * @return the observable to the KeyBundle object */ public Observable getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion) { return getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion).map(new Func1, KeyBundle>() { @Override public KeyBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Retrieves the public portion of a key plus its attributes. + * Gets the public part of a stored key. The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. Authorization: Requires the keys/get permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key to get. + * @param keyVersion Adding the version parameter retrieves a specific version of a key. * @return the observable to the KeyBundle object */ public Observable> getKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion) { @@ -1206,42 +1178,39 @@ public Observable> call(Response respon } private ServiceResponse getKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. * @return the PagedList<KeyItem> object if successful. */ - public PagedList getKeyVersions(final String vaultBaseUrl, final String keyName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeyVersions(final String vaultBaseUrl, final String keyName) { ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName), new Func1>>>() { @Override @@ -1253,10 +1222,10 @@ public Observable>> call(String nextPageLink) { } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. * @return the observable to the PagedList<KeyItem> object */ public Observable> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName) { @@ -1264,16 +1233,16 @@ public Observable> getKeyVersionsAsync(final String vaultBaseUrl, .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. * @return the observable to the PagedList<KeyItem> object */ public Observable>> getKeyVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String keyName) { @@ -1281,7 +1250,7 @@ public Observable>> getKeyVersionsWithServiceRespo .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -1291,10 +1260,10 @@ public Observable>> call(ServiceResponse>> getKeyVersionsSinglePageAsync(final String vaultBaseUrl, final String keyName) { @@ -1315,7 +1284,7 @@ public Observable>> getKeyVersionsSinglePageAsync( public Observable>> call(Response response) { try { ServiceResponse> result = getKeyVersionsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -1324,37 +1293,34 @@ public Observable>> call(Response re } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<KeyItem> object if successful. */ - public PagedList getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeyVersions(final String vaultBaseUrl, final String keyName, final Integer maxresults) { ServiceResponse> response = getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults), new Func1>>>() { @Override @@ -1366,10 +1332,10 @@ public Observable>> call(String nextPageLink) { } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<KeyItem> object */ @@ -1378,16 +1344,16 @@ public Observable> getKeyVersionsAsync(final String vaultBaseUrl, .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<KeyItem> object */ @@ -1396,7 +1362,7 @@ public Observable>> getKeyVersionsWithServiceRespo .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -1406,10 +1372,10 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - ServiceResponse> * @param keyName The name of the key + ServiceResponse> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + ServiceResponse> * @param keyName The name of the key. ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ @@ -1430,7 +1396,7 @@ public Observable>> getKeyVersionsSinglePageAsync( public Observable>> call(Response response) { try { ServiceResponse> result = getKeyVersionsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -1439,7 +1405,7 @@ public Observable>> call(Response re } private ServiceResponse> getKeyVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -1448,18 +1414,15 @@ private ServiceResponse> getKeyVersionsDelegate(Response getKeys(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeys(final String vaultBaseUrl) { ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } @@ -1467,12 +1430,12 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcep /** * List keys in the specified vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getKeysSinglePageAsync(vaultBaseUrl), new Func1>>>() { @Override @@ -1486,7 +1449,7 @@ public Observable>> call(String nextPageLink) { /** * List keys in the specified vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the observable to the PagedList<KeyItem> object */ public Observable> getKeysAsync(final String vaultBaseUrl) { @@ -1494,7 +1457,7 @@ public Observable> getKeysAsync(final String vaultBaseUrl) { .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } @@ -1502,7 +1465,7 @@ public Page call(ServiceResponse> response) { /** * List keys in the specified vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the observable to the PagedList<KeyItem> object */ public Observable>> getKeysWithServiceResponseAsync(final String vaultBaseUrl) { @@ -1510,7 +1473,7 @@ public Observable>> getKeysWithServiceResponseAsyn .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -1522,7 +1485,7 @@ public Observable>> call(ServiceResponse>> getKeysSinglePageAsync(final String vaultBaseUrl) { @@ -1540,7 +1503,7 @@ public Observable>> getKeysSinglePageAsync(final S public Observable>> call(Response response) { try { ServiceResponse> result = getKeysDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -1551,19 +1514,16 @@ public Observable>> call(Response re /** * List keys in the specified vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<KeyItem> object if successful. */ - public PagedList getKeys(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeys(final String vaultBaseUrl, final Integer maxresults) { ServiceResponse> response = getKeysSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } @@ -1571,13 +1531,13 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcep /** * List keys in the specified vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getKeysSinglePageAsync(vaultBaseUrl, maxresults), new Func1>>>() { @Override @@ -1591,7 +1551,7 @@ public Observable>> call(String nextPageLink) { /** * List keys in the specified vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<KeyItem> object */ @@ -1600,7 +1560,7 @@ public Observable> getKeysAsync(final String vaultBaseUrl, final I .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } @@ -1608,7 +1568,7 @@ public Page call(ServiceResponse> response) { /** * List keys in the specified vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<KeyItem> object */ @@ -1617,7 +1577,7 @@ public Observable>> getKeysWithServiceResponseAsyn .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -1629,7 +1589,7 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. */ @@ -1647,7 +1607,7 @@ public Observable>> getKeysSinglePageAsync(final S public Observable>> call(Response response) { try { ServiceResponse> result = getKeysDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -1656,7 +1616,7 @@ public Observable>> call(Response re } private ServiceResponse> getKeysDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -1665,41 +1625,38 @@ private ServiceResponse> getKeysDelegate(Response backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return ServiceCall.create(backupKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback); + return ServiceCall.fromResponse(backupKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback); } /** * Requests that a backup of the specified key be downloaded to the client. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. * @return the observable to the BackupKeyResult object */ public Observable backupKeyAsync(String vaultBaseUrl, String keyName) { return backupKeyWithServiceResponseAsync(vaultBaseUrl, keyName).map(new Func1, BackupKeyResult>() { @Override public BackupKeyResult call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } @@ -1707,8 +1664,8 @@ public BackupKeyResult call(ServiceResponse response) { /** * Requests that a backup of the specified key be downloaded to the client. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. * @return the observable to the BackupKeyResult object */ public Observable> backupKeyWithServiceResponseAsync(String vaultBaseUrl, String keyName) { @@ -1737,59 +1694,56 @@ public Observable> call(Response } private ServiceResponse backupKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Restores the backup key in to a vault. + * Restores a backed up key to a vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyBundleBackup the backup blob associated with a key bundle - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyBundleBackup The backup blob associated with a key bundle. * @return the KeyBundle object if successful. */ - public KeyBundle restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup).toBlocking().single().getBody(); + public KeyBundle restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) { + return restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup).toBlocking().single().body(); } /** - * Restores the backup key in to a vault. + * Restores a backed up key to a vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyBundleBackup the backup blob associated with a key bundle + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyBundleBackup The backup blob associated with a key bundle. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { - return ServiceCall.create(restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup), serviceCallback); + return ServiceCall.fromResponse(restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup), serviceCallback); } /** - * Restores the backup key in to a vault. + * Restores a backed up key to a vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyBundleBackup the backup blob associated with a key bundle + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyBundleBackup The backup blob associated with a key bundle. * @return the observable to the KeyBundle object */ public Observable restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup) { return restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup).map(new Func1, KeyBundle>() { @Override public KeyBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Restores the backup key in to a vault. + * Restores a backed up key to a vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyBundleBackup the backup blob associated with a key bundle + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyBundleBackup The backup blob associated with a key bundle. * @return the observable to the KeyBundle object */ public Observable> restoreKeyWithServiceResponseAsync(String vaultBaseUrl, byte[] keyBundleBackup) { @@ -1820,50 +1774,47 @@ public Observable> call(Response respon } private ServiceResponse restoreKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object if successful. */ - public KeyOperationResult encrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); + public KeyOperationResult encrypt(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + return encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().body(); } /** - * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.fromResponse(encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** - * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @return the observable to the KeyOperationResult object @@ -1872,17 +1823,17 @@ public Observable encryptAsync(String vaultBaseUrl, String k return encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { @Override public KeyOperationResult call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. + * Encrypts an arbitrary sequence of bytes using an encryption key that is stored in a key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @return the observable to the KeyOperationResult object @@ -1925,7 +1876,7 @@ public Observable> call(Response encryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -1934,41 +1885,38 @@ private ServiceResponse encryptDelegate(Response decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(decryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.fromResponse(decryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** * Decrypts a single block of encrypted data. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @return the observable to the KeyOperationResult object @@ -1977,7 +1925,7 @@ public Observable decryptAsync(String vaultBaseUrl, String k return decryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { @Override public KeyOperationResult call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } @@ -1985,9 +1933,9 @@ public KeyOperationResult call(ServiceResponse response) { /** * Decrypts a single block of encrypted data. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @return the observable to the KeyOperationResult object @@ -2030,50 +1978,47 @@ public Observable> call(Response decryptDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Creates a signature from a digest using the specified key in the vault. + * Creates a signature from a digest using the specified key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param value the Base64Url value - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object if successful. */ - public KeyOperationResult sign(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); + public KeyOperationResult sign(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value) { + return signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().body(); } /** - * Creates a signature from a digest using the specified key in the vault. + * Creates a signature from a digest using the specified key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.fromResponse(signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** - * Creates a signature from a digest using the specified key in the vault. + * Creates a signature from a digest using the specified key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param value the Base64Url value * @return the observable to the KeyOperationResult object @@ -2082,17 +2027,17 @@ public Observable signAsync(String vaultBaseUrl, String keyN return signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { @Override public KeyOperationResult call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Creates a signature from a digest using the specified key in the vault. + * Creates a signature from a digest using the specified key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param value the Base64Url value * @return the observable to the KeyOperationResult object @@ -2135,75 +2080,72 @@ public Observable> call(Response signDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Verifies a signature using the specified key. + * Verifies a signature using a specified key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' - * @param digest The digest used for signing - * @param signature The signature to be verified - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param digest The digest used for signing. + * @param signature The signature to be verified. * @return the KeyVerifyResult object if successful. */ - public KeyVerifyResult verify(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).toBlocking().single().getBody(); + public KeyVerifyResult verify(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { + return verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).toBlocking().single().body(); } /** - * Verifies a signature using the specified key. + * Verifies a signature using a specified key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' - * @param digest The digest used for signing - * @param signature The signature to be verified + * @param digest The digest used for signing. + * @param signature The signature to be verified. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { - return ServiceCall.create(verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature), serviceCallback); + return ServiceCall.fromResponse(verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature), serviceCallback); } /** - * Verifies a signature using the specified key. + * Verifies a signature using a specified key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' - * @param digest The digest used for signing - * @param signature The signature to be verified + * @param digest The digest used for signing. + * @param signature The signature to be verified. * @return the observable to the KeyVerifyResult object */ public Observable verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { return verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature).map(new Func1, KeyVerifyResult>() { @Override public KeyVerifyResult call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Verifies a signature using the specified key. + * Verifies a signature using a specified key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm The signing/verification algorithm. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' - * @param digest The digest used for signing - * @param signature The signature to be verified + * @param digest The digest used for signing. + * @param signature The signature to be verified. * @return the observable to the KeyVerifyResult object */ public Observable> verifyWithServiceResponseAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature) { @@ -2248,50 +2190,47 @@ public Observable> call(Response } private ServiceResponse verifyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Wraps a symmetric key using the specified key. + * Wraps a symmetric key using a specified key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object if successful. */ - public KeyOperationResult wrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); + public KeyOperationResult wrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + return wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().body(); } /** - * Wraps a symmetric key using the specified key. + * Wraps a symmetric key using a specified key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.fromResponse(wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** - * Wraps a symmetric key using the specified key. + * Wraps a symmetric key using a specified key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @return the observable to the KeyOperationResult object @@ -2300,17 +2239,17 @@ public Observable wrapKeyAsync(String vaultBaseUrl, String k return wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { @Override public KeyOperationResult call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Wraps a symmetric key using the specified key. + * Wraps a symmetric key using a specified key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @return the observable to the KeyOperationResult object @@ -2353,50 +2292,47 @@ public Observable> call(Response wrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * Unwraps a symmetric key using the specified key that was initially used for wrapping that key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the KeyOperationResult object if successful. */ - public KeyOperationResult unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().getBody(); + public KeyOperationResult unwrapKey(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value) { + return unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).toBlocking().single().body(); } /** - * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * Unwraps a symmetric key using the specified key that was initially used for wrapping that key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.create(unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + return ServiceCall.fromResponse(unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** - * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * Unwraps a symmetric key using the specified key that was initially used for wrapping that key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @return the observable to the KeyOperationResult object @@ -2405,17 +2341,17 @@ public Observable unwrapKeyAsync(String vaultBaseUrl, String return unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value).map(new Func1, KeyOperationResult>() { @Override public KeyOperationResult call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Unwraps a symmetric key using the specified key in the vault that has initially been used for wrapping the key. + * Unwraps a symmetric key using the specified key that was initially used for wrapping that key. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param keyName The name of the key - * @param keyVersion The version of the key + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param keyName The name of the key. + * @param keyVersion The version of the key. * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @return the observable to the KeyOperationResult object @@ -2458,63 +2394,60 @@ public Observable> call(Response unwrapKeyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Sets a secret in the specified vault. + * Sets a secret in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param value The value of the secret - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param value The value of the secret. * @return the SecretBundle object if successful. */ - public SecretBundle setSecret(String vaultBaseUrl, String secretName, String value) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value).toBlocking().single().getBody(); + public SecretBundle setSecret(String vaultBaseUrl, String secretName, String value) { + return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value).toBlocking().single().body(); } /** - * Sets a secret in the specified vault. + * Sets a secret in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param value The value of the secret + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param value The value of the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) { - return ServiceCall.create(setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value), serviceCallback); + return ServiceCall.fromResponse(setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value), serviceCallback); } /** - * Sets a secret in the specified vault. + * Sets a secret in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param value The value of the secret + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param value The value of the secret. * @return the observable to the SecretBundle object */ public Observable setSecretAsync(String vaultBaseUrl, String secretName, String value) { return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value).map(new Func1, SecretBundle>() { @Override public SecretBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Sets a secret in the specified vault. + * Sets a secret in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param value The value of the secret + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param value The value of the secret. * @return the observable to the SecretBundle object */ public Observable> setSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String value) { @@ -2554,68 +2487,65 @@ public Observable> call(Response res } /** - * Sets a secret in the specified vault. + * Sets a secret in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param value The value of the secret - * @param tags Application-specific metadata in the form of key-value pairs - * @param contentType Type of the secret value such as a password - * @param secretAttributes The secret management attributes - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param value The value of the secret. + * @param tags Application specific metadata in the form of key-value pairs. + * @param contentType Type of the secret value such as a password. + * @param secretAttributes The secret management attributes. * @return the SecretBundle object if successful. */ - public SecretBundle setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).toBlocking().single().getBody(); + public SecretBundle setSecret(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { + return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).toBlocking().single().body(); } /** - * Sets a secret in the specified vault. + * Sets a secret in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param value The value of the secret - * @param tags Application-specific metadata in the form of key-value pairs - * @param contentType Type of the secret value such as a password - * @param secretAttributes The secret management attributes + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param value The value of the secret. + * @param tags Application specific metadata in the form of key-value pairs. + * @param contentType Type of the secret value such as a password. + * @param secretAttributes The secret management attributes. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes, final ServiceCallback serviceCallback) { - return ServiceCall.create(setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes), serviceCallback); + return ServiceCall.fromResponse(setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes), serviceCallback); } /** - * Sets a secret in the specified vault. + * Sets a secret in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param value The value of the secret - * @param tags Application-specific metadata in the form of key-value pairs - * @param contentType Type of the secret value such as a password - * @param secretAttributes The secret management attributes + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param value The value of the secret. + * @param tags Application specific metadata in the form of key-value pairs. + * @param contentType Type of the secret value such as a password. + * @param secretAttributes The secret management attributes. * @return the observable to the SecretBundle object */ public Observable setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { return setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes).map(new Func1, SecretBundle>() { @Override public SecretBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Sets a secret in the specified vault. + * Sets a secret in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param value The value of the secret - * @param tags Application-specific metadata in the form of key-value pairs - * @param contentType Type of the secret value such as a password - * @param secretAttributes The secret management attributes + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param value The value of the secret. + * @param tags Application specific metadata in the form of key-value pairs. + * @param contentType Type of the secret value such as a password. + * @param secretAttributes The secret management attributes. * @return the observable to the SecretBundle object */ public Observable> setSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes) { @@ -2654,59 +2584,56 @@ public Observable> call(Response res } private ServiceResponse setSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Deletes a secret from the specified vault. + * Deletes a secret from a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. * @return the SecretBundle object if successful. */ - public SecretBundle deleteSecret(String vaultBaseUrl, String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName).toBlocking().single().getBody(); + public SecretBundle deleteSecret(String vaultBaseUrl, String secretName) { + return deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName).toBlocking().single().body(); } /** - * Deletes a secret from the specified vault. + * Deletes a secret from a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName), serviceCallback); + return ServiceCall.fromResponse(deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName), serviceCallback); } /** - * Deletes a secret from the specified vault. + * Deletes a secret from a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. * @return the observable to the SecretBundle object */ public Observable deleteSecretAsync(String vaultBaseUrl, String secretName) { return deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName).map(new Func1, SecretBundle>() { @Override public SecretBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Deletes a secret from the specified vault. + * Deletes a secret from a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. * @return the observable to the SecretBundle object */ public Observable> deleteSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName) { @@ -2735,63 +2662,60 @@ public Observable> call(Response res } private ServiceResponse deleteSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Updates the attributes associated with the specified secret. + * Updates the attributes associated with a specified secret in a given key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. * @return the SecretBundle object if successful. */ - public SecretBundle updateSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single().getBody(); + public SecretBundle updateSecret(String vaultBaseUrl, String secretName, String secretVersion) { + return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single().body(); } /** - * Updates the attributes associated with the specified secret. + * Updates the attributes associated with a specified secret in a given key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + return ServiceCall.fromResponse(updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); } /** - * Updates the attributes associated with the specified secret. + * Updates the attributes associated with a specified secret in a given key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. * @return the observable to the SecretBundle object */ public Observable updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).map(new Func1, SecretBundle>() { @Override public SecretBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Updates the attributes associated with the specified secret. + * Updates the attributes associated with a specified secret in a given key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. * @return the observable to the SecretBundle object */ public Observable> updateSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String secretVersion) { @@ -2830,68 +2754,65 @@ public Observable> call(Response res } /** - * Updates the attributes associated with the specified secret. + * Updates the attributes associated with a specified secret in a given key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret - * @param contentType Type of the secret value such as a password - * @param secretAttributes The secret management attributes - * @param tags Application-specific metadata in the form of key-value pairs - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. + * @param contentType Type of the secret value such as a password. + * @param secretAttributes The secret management attributes. + * @param tags Application specific metadata in the form of key-value pairs. * @return the SecretBundle object if successful. */ - public SecretBundle updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).toBlocking().single().getBody(); + public SecretBundle updateSecret(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { + return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).toBlocking().single().body(); } /** - * Updates the attributes associated with the specified secret. + * Updates the attributes associated with a specified secret in a given key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret - * @param contentType Type of the secret value such as a password - * @param secretAttributes The secret management attributes - * @param tags Application-specific metadata in the form of key-value pairs + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. + * @param contentType Type of the secret value such as a password. + * @param secretAttributes The secret management attributes. + * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags), serviceCallback); + return ServiceCall.fromResponse(updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags), serviceCallback); } /** - * Updates the attributes associated with the specified secret. + * Updates the attributes associated with a specified secret in a given key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret - * @param contentType Type of the secret value such as a password - * @param secretAttributes The secret management attributes - * @param tags Application-specific metadata in the form of key-value pairs + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. + * @param contentType Type of the secret value such as a password. + * @param secretAttributes The secret management attributes. + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the SecretBundle object */ public Observable updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { return updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags).map(new Func1, SecretBundle>() { @Override public SecretBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Updates the attributes associated with the specified secret. + * Updates the attributes associated with a specified secret in a given key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret - * @param contentType Type of the secret value such as a password - * @param secretAttributes The secret management attributes - * @param tags Application-specific metadata in the form of key-value pairs + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. + * @param contentType Type of the secret value such as a password. + * @param secretAttributes The secret management attributes. + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the SecretBundle object */ public Observable> updateSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags) { @@ -2929,63 +2850,60 @@ public Observable> call(Response res } private ServiceResponse updateSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Gets a secret. + * Get a specified secret from a given key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. * @return the SecretBundle object if successful. */ - public SecretBundle getSecret(String vaultBaseUrl, String secretName, String secretVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single().getBody(); + public SecretBundle getSecret(String vaultBaseUrl, String secretName, String secretVersion) { + return getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).toBlocking().single().body(); } /** - * Gets a secret. + * Get a specified secret from a given key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + return ServiceCall.fromResponse(getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); } /** - * Gets a secret. + * Get a specified secret from a given key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. * @return the observable to the SecretBundle object */ public Observable getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion) { return getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion).map(new Func1, SecretBundle>() { @Override public SecretBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Gets a secret. + * Get a specified secret from a given key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault - * @param secretVersion The version of the secret + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. + * @param secretVersion The version of the secret. * @return the observable to the SecretBundle object */ public Observable> getSecretWithServiceResponseAsync(String vaultBaseUrl, String secretName, String secretVersion) { @@ -3017,40 +2935,37 @@ public Observable> call(Response res } private ServiceResponse getSecretDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * List secrets in the specified vault. + * List secrets in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the PagedList<SecretItem> object if successful. */ - public PagedList getSecrets(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecrets(final String vaultBaseUrl) { ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** - * List secrets in the specified vault. + * List secrets in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getSecretsSinglePageAsync(vaultBaseUrl), new Func1>>>() { @Override @@ -3062,9 +2977,9 @@ public Observable>> call(String nextPageLink) { } /** - * List secrets in the specified vault. + * List secrets in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the observable to the PagedList<SecretItem> object */ public Observable> getSecretsAsync(final String vaultBaseUrl) { @@ -3072,15 +2987,15 @@ public Observable> getSecretsAsync(final String vaultBaseUrl) { .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } /** - * List secrets in the specified vault. + * List secrets in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the observable to the PagedList<SecretItem> object */ public Observable>> getSecretsWithServiceResponseAsync(final String vaultBaseUrl) { @@ -3088,7 +3003,7 @@ public Observable>> getSecretsWithServiceRespon .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -3098,9 +3013,9 @@ public Observable>> call(ServiceResponse>> getSecretsSinglePageAsync(final String vaultBaseUrl) { @@ -3118,7 +3033,7 @@ public Observable>> getSecretsSinglePageAsync(f public Observable>> call(Response response) { try { ServiceResponse> result = getSecretsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -3127,35 +3042,32 @@ public Observable>> call(Response } /** - * List secrets in the specified vault. + * List secrets in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SecretItem> object if successful. */ - public PagedList getSecrets(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecrets(final String vaultBaseUrl, final Integer maxresults) { ServiceResponse> response = getSecretsSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** - * List secrets in the specified vault. + * List secrets in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getSecretsSinglePageAsync(vaultBaseUrl, maxresults), new Func1>>>() { @Override @@ -3167,9 +3079,9 @@ public Observable>> call(String nextPageLink) { } /** - * List secrets in the specified vault. + * List secrets in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<SecretItem> object */ @@ -3178,15 +3090,15 @@ public Observable> getSecretsAsync(final String vaultBaseUrl, f .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } /** - * List secrets in the specified vault. + * List secrets in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<SecretItem> object */ @@ -3195,7 +3107,7 @@ public Observable>> getSecretsWithServiceRespon .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -3205,9 +3117,9 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ @@ -3225,7 +3137,7 @@ public Observable>> getSecretsSinglePageAsync(f public Observable>> call(Response response) { try { ServiceResponse> result = getSecretsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -3234,7 +3146,7 @@ public Observable>> call(Response } private ServiceResponse> getSecretsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -3243,19 +3155,16 @@ private ServiceResponse> getSecretsDelegate(Response getSecretVersions(final String vaultBaseUrl, final String secretName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecretVersions(final String vaultBaseUrl, final String secretName) { ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } @@ -3263,13 +3172,13 @@ public Page nextPage(String nextPageLink) throws RestException, IOEx /** * List the versions of the specified secret. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName), new Func1>>>() { @Override @@ -3283,8 +3192,8 @@ public Observable>> call(String nextPageLink) { /** * List the versions of the specified secret. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. * @return the observable to the PagedList<SecretItem> object */ public Observable> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName) { @@ -3292,7 +3201,7 @@ public Observable> getSecretVersionsAsync(final String vaultBas .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } @@ -3300,8 +3209,8 @@ public Page call(ServiceResponse> response) { /** * List the versions of the specified secret. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. * @return the observable to the PagedList<SecretItem> object */ public Observable>> getSecretVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String secretName) { @@ -3309,7 +3218,7 @@ public Observable>> getSecretVersionsWithServic .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -3321,8 +3230,8 @@ public Observable>> call(ServiceResponse>> getSecretVersionsSinglePageAsync(final String vaultBaseUrl, final String secretName) { @@ -3343,7 +3252,7 @@ public Observable>> getSecretVersionsSinglePage public Observable>> call(Response response) { try { ServiceResponse> result = getSecretVersionsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -3354,20 +3263,17 @@ public Observable>> call(Response /** * List the versions of the specified secret. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SecretItem> object if successful. */ - public PagedList getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecretVersions(final String vaultBaseUrl, final String secretName, final Integer maxresults) { ServiceResponse> response = getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } @@ -3375,14 +3281,14 @@ public Page nextPage(String nextPageLink) throws RestException, IOEx /** * List the versions of the specified secret. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults), new Func1>>>() { @Override @@ -3396,8 +3302,8 @@ public Observable>> call(String nextPageLink) { /** * List the versions of the specified secret. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<SecretItem> object */ @@ -3406,7 +3312,7 @@ public Observable> getSecretVersionsAsync(final String vaultBas .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } @@ -3414,8 +3320,8 @@ public Page call(ServiceResponse> response) { /** * List the versions of the specified secret. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param secretName The name of the secret in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param secretName The name of the secret. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<SecretItem> object */ @@ -3424,7 +3330,7 @@ public Observable>> getSecretVersionsWithServic .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -3436,8 +3342,8 @@ public Observable>> call(ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - ServiceResponse> * @param secretName The name of the secret in the given vault + ServiceResponse> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + ServiceResponse> * @param secretName The name of the secret. ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. */ @@ -3458,7 +3364,7 @@ public Observable>> getSecretVersionsSinglePage public Observable>> call(Response response) { try { ServiceResponse> result = getSecretVersionsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -3467,40 +3373,37 @@ public Observable>> call(Response } private ServiceResponse> getSecretVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * List certificates in the specified vault. + * List certificates in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the PagedList<CertificateItem> object if successful. */ - public PagedList getCertificates(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificates(final String vaultBaseUrl) { ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** - * List certificates in the specified vault. + * List certificates in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getCertificatesSinglePageAsync(vaultBaseUrl), new Func1>>>() { @Override @@ -3512,9 +3415,9 @@ public Observable>> call(String nextPageLi } /** - * List certificates in the specified vault. + * List certificates in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the observable to the PagedList<CertificateItem> object */ public Observable> getCertificatesAsync(final String vaultBaseUrl) { @@ -3522,15 +3425,15 @@ public Observable> getCertificatesAsync(final String vault .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } /** - * List certificates in the specified vault. + * List certificates in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the observable to the PagedList<CertificateItem> object */ public Observable>> getCertificatesWithServiceResponseAsync(final String vaultBaseUrl) { @@ -3538,7 +3441,7 @@ public Observable>> getCertificatesWithSer .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -3548,9 +3451,9 @@ public Observable>> call(ServiceResponse

>> getCertificatesSinglePageAsync(final String vaultBaseUrl) { @@ -3568,7 +3471,7 @@ public Observable>> getCertificatesSingleP public Observable>> call(Response response) { try { ServiceResponse> result = getCertificatesDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -3577,35 +3480,32 @@ public Observable>> call(Response getCertificates(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificates(final String vaultBaseUrl, final Integer maxresults) { ServiceResponse> response = getCertificatesSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** - * List certificates in the specified vault. + * List certificates in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getCertificatesSinglePageAsync(vaultBaseUrl, maxresults), new Func1>>>() { @Override @@ -3617,9 +3517,9 @@ public Observable>> call(String nextPageLi } /** - * List certificates in the specified vault. + * List certificates in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<CertificateItem> object */ @@ -3628,15 +3528,15 @@ public Observable> getCertificatesAsync(final String vault .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } /** - * List certificates in the specified vault. + * List certificates in a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<CertificateItem> object */ @@ -3645,7 +3545,7 @@ public Observable>> getCertificatesWithSer .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -3655,9 +3555,9 @@ public Observable>> call(ServiceResponse

> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ @@ -3675,7 +3575,7 @@ public Observable>> getCertificatesSingleP public Observable>> call(Response response) { try { ServiceResponse> result = getCertificatesDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -3684,59 +3584,56 @@ public Observable>> call(Response> getCertificatesDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Deletes a certificate from the specified vault. + * Deletes a certificate from a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the CertificateBundle object if successful. */ - public CertificateBundle deleteCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); + public CertificateBundle deleteCertificate(String vaultBaseUrl, String certificateName) { + return deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().body(); } /** - * Deletes a certificate from the specified vault. + * Deletes a certificate from a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.fromResponse(deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** - * Deletes a certificate from the specified vault. + * Deletes a certificate from a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the observable to the CertificateBundle object */ public Observable deleteCertificateAsync(String vaultBaseUrl, String certificateName) { return deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificateBundle>() { @Override public CertificateBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Deletes a certificate from the specified vault. + * Deletes a certificate from a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the observable to the CertificateBundle object */ public Observable> deleteCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { @@ -3765,59 +3662,56 @@ public Observable> call(Response deleteCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Sets the certificate contacts for the specified vault. + * Sets the certificate contacts for the specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param contacts The contacts for the vault certificates. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param contacts The contacts for the key vault certificate. * @return the Contacts object if successful. */ - public Contacts setCertificateContacts(String vaultBaseUrl, Contacts contacts) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts).toBlocking().single().getBody(); + public Contacts setCertificateContacts(String vaultBaseUrl, Contacts contacts) { + return setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts).toBlocking().single().body(); } /** - * Sets the certificate contacts for the specified vault. + * Sets the certificate contacts for the specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param contacts The contacts for the vault certificates. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param contacts The contacts for the key vault certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { - return ServiceCall.create(setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts), serviceCallback); + return ServiceCall.fromResponse(setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts), serviceCallback); } /** - * Sets the certificate contacts for the specified vault. + * Sets the certificate contacts for the specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param contacts The contacts for the vault certificates. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param contacts The contacts for the key vault certificate. * @return the observable to the Contacts object */ public Observable setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts) { return setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts).map(new Func1, Contacts>() { @Override public Contacts call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Sets the certificate contacts for the specified vault. + * Sets the certificate contacts for the specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param contacts The contacts for the vault certificates. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param contacts The contacts for the key vault certificate. * @return the observable to the Contacts object */ public Observable> setCertificateContactsWithServiceResponseAsync(String vaultBaseUrl, Contacts contacts) { @@ -3847,55 +3741,52 @@ public Observable> call(Response respons } private ServiceResponse setCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Gets the certificate contacts for the specified vault. + * Lists the certificate contacts for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the Contacts object if successful. */ - public Contacts getCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateContactsWithServiceResponseAsync(vaultBaseUrl).toBlocking().single().getBody(); + public Contacts getCertificateContacts(String vaultBaseUrl) { + return getCertificateContactsWithServiceResponseAsync(vaultBaseUrl).toBlocking().single().body(); } /** - * Gets the certificate contacts for the specified vault. + * Lists the certificate contacts for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateContactsWithServiceResponseAsync(vaultBaseUrl), serviceCallback); + return ServiceCall.fromResponse(getCertificateContactsWithServiceResponseAsync(vaultBaseUrl), serviceCallback); } /** - * Gets the certificate contacts for the specified vault. + * Lists the certificate contacts for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the observable to the Contacts object */ public Observable getCertificateContactsAsync(String vaultBaseUrl) { return getCertificateContactsWithServiceResponseAsync(vaultBaseUrl).map(new Func1, Contacts>() { @Override public Contacts call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Gets the certificate contacts for the specified vault. + * Lists the certificate contacts for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the observable to the Contacts object */ public Observable> getCertificateContactsWithServiceResponseAsync(String vaultBaseUrl) { @@ -3921,55 +3812,52 @@ public Observable> call(Response respons } private ServiceResponse getCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Deletes the certificate contacts for the specified vault. + * Deletes the certificate contacts for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the Contacts object if successful. */ - public Contacts deleteCertificateContacts(String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl).toBlocking().single().getBody(); + public Contacts deleteCertificateContacts(String vaultBaseUrl) { + return deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl).toBlocking().single().body(); } /** - * Deletes the certificate contacts for the specified vault. + * Deletes the certificate contacts for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl), serviceCallback); + return ServiceCall.fromResponse(deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl), serviceCallback); } /** - * Deletes the certificate contacts for the specified vault. + * Deletes the certificate contacts for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the observable to the Contacts object */ public Observable deleteCertificateContactsAsync(String vaultBaseUrl) { return deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl).map(new Func1, Contacts>() { @Override public Contacts call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Deletes the certificate contacts for the specified vault. + * Deletes the certificate contacts for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the observable to the Contacts object */ public Observable> deleteCertificateContactsWithServiceResponseAsync(String vaultBaseUrl) { @@ -3995,40 +3883,37 @@ public Observable> call(Response respons } private ServiceResponse deleteCertificateContactsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the PagedList<CertificateIssuerItem> object if successful. */ - public PagedList getCertificateIssuers(final String vaultBaseUrl) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateIssuers(final String vaultBaseUrl) { ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getCertificateIssuersSinglePageAsync(vaultBaseUrl), new Func1>>>() { @Override @@ -4040,9 +3925,9 @@ public Observable>> call(String next } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the observable to the PagedList<CertificateIssuerItem> object */ public Observable> getCertificateIssuersAsync(final String vaultBaseUrl) { @@ -4050,15 +3935,15 @@ public Observable> getCertificateIssuersAsync(final .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the observable to the PagedList<CertificateIssuerItem> object */ public Observable>> getCertificateIssuersWithServiceResponseAsync(final String vaultBaseUrl) { @@ -4066,7 +3951,7 @@ public Observable>> getCertificateIs .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -4076,9 +3961,9 @@ public Observable>> call(ServiceResp } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @return the PagedList<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ public Observable>> getCertificateIssuersSinglePageAsync(final String vaultBaseUrl) { @@ -4096,7 +3981,7 @@ public Observable>> getCertificateIs public Observable>> call(Response response) { try { ServiceResponse> result = getCertificateIssuersDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -4105,35 +3990,32 @@ public Observable>> call(Response getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateIssuers(final String vaultBaseUrl, final Integer maxresults) { ServiceResponse> response = getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults), new Func1>>>() { @Override @@ -4145,9 +4027,9 @@ public Observable>> call(String next } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<CertificateIssuerItem> object */ @@ -4156,15 +4038,15 @@ public Observable> getCertificateIssuersAsync(final .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<CertificateIssuerItem> object */ @@ -4173,7 +4055,7 @@ public Observable>> getCertificateIs .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -4183,9 +4065,9 @@ public Observable>> call(ServiceResp } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * - ServiceResponse> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + ServiceResponse> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the PagedList<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. */ @@ -4203,7 +4085,7 @@ public Observable>> getCertificateIs public Observable>> call(Response response) { try { ServiceResponse> result = getCertificateIssuersDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -4212,7 +4094,7 @@ public Observable>> call(Response> getCertificateIssuersDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -4221,35 +4103,32 @@ private ServiceResponse> getCertificateIssuersDe /** * Sets the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param provider The issuer provider. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object if successful. */ - public IssuerBundle setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider).toBlocking().single().getBody(); + public IssuerBundle setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider) { + return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider).toBlocking().single().body(); } /** * Sets the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param provider The issuer provider. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { - return ServiceCall.create(setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider), serviceCallback); + return ServiceCall.fromResponse(setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider), serviceCallback); } /** * Sets the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param provider The issuer provider. * @return the observable to the IssuerBundle object @@ -4258,7 +4137,7 @@ public Observable setCertificateIssuerAsync(String vaultBaseUrl, S return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider).map(new Func1, IssuerBundle>() { @Override public IssuerBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } @@ -4266,7 +4145,7 @@ public IssuerBundle call(ServiceResponse response) { /** * Sets the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param provider The issuer provider. * @return the observable to the IssuerBundle object @@ -4310,25 +4189,22 @@ public Observable> call(Response res /** * Sets the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. * @param organizationDetails Details of the organization as provided to the issuer. * @param attributes Attributes of the issuer object. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object if successful. */ - public IssuerBundle setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single().getBody(); + public IssuerBundle setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { + return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single().body(); } /** * Sets the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. @@ -4338,13 +4214,13 @@ public IssuerBundle setCertificateIssuer(String vaultBaseUrl, String issuerName, * @return the {@link ServiceCall} object */ public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { - return ServiceCall.create(setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + return ServiceCall.fromResponse(setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); } /** * Sets the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. @@ -4356,7 +4232,7 @@ public Observable setCertificateIssuerAsync(String vaultBaseUrl, S return setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).map(new Func1, IssuerBundle>() { @Override public IssuerBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } @@ -4364,7 +4240,7 @@ public IssuerBundle call(ServiceResponse response) { /** * Sets the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. @@ -4409,7 +4285,7 @@ public Observable> call(Response res } private ServiceResponse setCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -4418,33 +4294,30 @@ private ServiceResponse setCertificateIssuerDelegate(Response updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); + return ServiceCall.fromResponse(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); } /** * Updates the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @return the observable to the IssuerBundle object */ @@ -4452,7 +4325,7 @@ public Observable updateCertificateIssuerAsync(String vaultBaseUrl return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1, IssuerBundle>() { @Override public IssuerBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } @@ -4460,7 +4333,7 @@ public IssuerBundle call(ServiceResponse response) { /** * Updates the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @return the observable to the IssuerBundle object */ @@ -4501,25 +4374,22 @@ public Observable> call(Response res /** * Updates the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. * @param organizationDetails Details of the organization as provided to the issuer. * @param attributes Attributes of the issuer object. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object if successful. */ - public IssuerBundle updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single().getBody(); + public IssuerBundle updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { + return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).toBlocking().single().body(); } /** * Updates the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. @@ -4529,13 +4399,13 @@ public IssuerBundle updateCertificateIssuer(String vaultBaseUrl, String issuerNa * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + return ServiceCall.fromResponse(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); } /** * Updates the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. @@ -4547,7 +4417,7 @@ public Observable updateCertificateIssuerAsync(String vaultBaseUrl return updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes).map(new Func1, IssuerBundle>() { @Override public IssuerBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } @@ -4555,7 +4425,7 @@ public IssuerBundle call(ServiceResponse response) { /** * Updates the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param provider The issuer provider. * @param credentials The credentials to be used for the issuer. @@ -4597,42 +4467,39 @@ public Observable> call(Response res } private ServiceResponse updateCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Gets the specified certificate issuer. + * Lists the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the IssuerBundle object if successful. */ - public IssuerBundle getCertificateIssuer(String vaultBaseUrl, String issuerName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).toBlocking().single().getBody(); + public IssuerBundle getCertificateIssuer(String vaultBaseUrl, String issuerName) { + return getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).toBlocking().single().body(); } /** - * Gets the specified certificate issuer. + * Lists the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); + return ServiceCall.fromResponse(getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); } /** - * Gets the specified certificate issuer. + * Lists the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @return the observable to the IssuerBundle object */ @@ -4640,15 +4507,15 @@ public Observable getCertificateIssuerAsync(String vaultBaseUrl, S return getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1, IssuerBundle>() { @Override public IssuerBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Gets the specified certificate issuer. + * Lists the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @return the observable to the IssuerBundle object */ @@ -4678,7 +4545,7 @@ public Observable> call(Response res } private ServiceResponse getCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -4687,33 +4554,30 @@ private ServiceResponse getCertificateIssuerDelegate(Response deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); + return ServiceCall.fromResponse(deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); } /** * Deletes the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @return the observable to the IssuerBundle object */ @@ -4721,7 +4585,7 @@ public Observable deleteCertificateIssuerAsync(String vaultBaseUrl return deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName).map(new Func1, IssuerBundle>() { @Override public IssuerBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } @@ -4729,7 +4593,7 @@ public IssuerBundle call(ServiceResponse response) { /** * Deletes the specified certificate issuer. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @return the observable to the IssuerBundle object */ @@ -4759,59 +4623,56 @@ public Observable> call(Response res } private ServiceResponse deleteCertificateIssuerDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Creates a new certificate version. If this is the first version, the certificate resource is created. + * Creates a new certificate. If this is the first version, the certificate resource is created. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the CertificateOperation object if successful. */ - public CertificateOperation createCertificate(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); + public CertificateOperation createCertificate(String vaultBaseUrl, String certificateName) { + return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().body(); } /** - * Creates a new certificate version. If this is the first version, the certificate resource is created. + * Creates a new certificate. If this is the first version, the certificate resource is created. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.fromResponse(createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** - * Creates a new certificate version. If this is the first version, the certificate resource is created. + * Creates a new certificate. If this is the first version, the certificate resource is created. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the observable to the CertificateOperation object */ public Observable createCertificateAsync(String vaultBaseUrl, String certificateName) { return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificateOperation>() { @Override public CertificateOperation call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Creates a new certificate version. If this is the first version, the certificate resource is created. + * Creates a new certificate. If this is the first version, the certificate resource is created. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the observable to the CertificateOperation object */ public Observable> createCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { @@ -4847,64 +4708,61 @@ public Observable> call(Response tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).toBlocking().single().getBody(); + public CertificateOperation createCertificate(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).toBlocking().single().body(); } /** - * Creates a new certificate version. If this is the first version, the certificate resource is created. + * Creates a new certificate. If this is the first version, the certificate resource is created. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param certificatePolicy The management policy for the certificate - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. + * @param certificatePolicy The management policy for the certificate. + * @param certificateAttributes The attributes of the certificate (optional). + * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags), serviceCallback); + return ServiceCall.fromResponse(createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags), serviceCallback); } /** - * Creates a new certificate version. If this is the first version, the certificate resource is created. + * Creates a new certificate. If this is the first version, the certificate resource is created. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param certificatePolicy The management policy for the certificate - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. + * @param certificatePolicy The management policy for the certificate. + * @param certificateAttributes The attributes of the certificate (optional). + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the CertificateOperation object */ public Observable createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { return createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags).map(new Func1, CertificateOperation>() { @Override public CertificateOperation call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Creates a new certificate version. If this is the first version, the certificate resource is created. + * Creates a new certificate. If this is the first version, the certificate resource is created. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param certificatePolicy The management policy for the certificate - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. + * @param certificatePolicy The management policy for the certificate. + * @param certificateAttributes The attributes of the certificate (optional). + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the CertificateOperation object */ public Observable> createCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { @@ -4940,45 +4798,42 @@ public Observable> call(Response createCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(202, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Imports a certificate into the specified vault. + * Imports a certificate into a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificateBundle object if successful. */ - public CertificateBundle importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).toBlocking().single().getBody(); + public CertificateBundle importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) { + return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).toBlocking().single().body(); } /** - * Imports a certificate into the specified vault. + * Imports a certificate into a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) { - return ServiceCall.create(importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate), serviceCallback); + return ServiceCall.fromResponse(importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate), serviceCallback); } /** - * Imports a certificate into the specified vault. + * Imports a certificate into a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @return the observable to the CertificateBundle object */ @@ -4986,16 +4841,16 @@ public Observable importCertificateAsync(String vaultBaseUrl, return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate).map(new Func1, CertificateBundle>() { @Override public CertificateBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Imports a certificate into the specified vault. + * Imports a certificate into a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @return the observable to the CertificateBundle object */ @@ -5038,72 +4893,69 @@ public Observable> call(Response tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).toBlocking().single().getBody(); + public CertificateBundle importCertificate(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).toBlocking().single().body(); } /** - * Imports a certificate into the specified vault. + * Imports a certificate into a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption - * @param certificatePolicy The management policy for the certificate - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption. + * @param certificatePolicy The management policy for the certificate. + * @param certificateAttributes The attributes of the certificate (optional). + * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags), serviceCallback); + return ServiceCall.fromResponse(importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags), serviceCallback); } /** - * Imports a certificate into the specified vault. + * Imports a certificate into a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption - * @param certificatePolicy The management policy for the certificate - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption. + * @param certificatePolicy The management policy for the certificate. + * @param certificateAttributes The attributes of the certificate (optional). + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the CertificateBundle object */ public Observable importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { return importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags).map(new Func1, CertificateBundle>() { @Override public CertificateBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Imports a certificate into the specified vault. + * Imports a certificate into a specified key vault. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption - * @param certificatePolicy The management policy for the certificate - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs + * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption. + * @param certificatePolicy The management policy for the certificate. + * @param certificateAttributes The attributes of the certificate (optional). + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the CertificateBundle object */ public Observable> importCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { @@ -5144,7 +4996,7 @@ public Observable> call(Response importCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -5153,19 +5005,16 @@ private ServiceResponse importCertificateDelegate(Response getCertificateVersions(final String vaultBaseUrl, final String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateVersions(final String vaultBaseUrl, final String certificateName) { ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } @@ -5173,13 +5022,13 @@ public Page nextPage(String nextPageLink) throws RestException, /** * List the versions of a certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName), new Func1>>>() { @Override @@ -5193,8 +5042,8 @@ public Observable>> call(String nextPageLi /** * List the versions of a certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the observable to the PagedList<CertificateItem> object */ public Observable> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName) { @@ -5202,7 +5051,7 @@ public Observable> getCertificateVersionsAsync(final Strin .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } @@ -5210,8 +5059,8 @@ public Page call(ServiceResponse> respons /** * List the versions of a certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the observable to the PagedList<CertificateItem> object */ public Observable>> getCertificateVersionsWithServiceResponseAsync(final String vaultBaseUrl, final String certificateName) { @@ -5219,7 +5068,7 @@ public Observable>> getCertificateVersions .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -5231,8 +5080,8 @@ public Observable>> call(ServiceResponse

>> getCertificateVersionsSinglePageAsync(final String vaultBaseUrl, final String certificateName) { @@ -5253,7 +5102,7 @@ public Observable>> getCertificateVersions public Observable>> call(Response response) { try { ServiceResponse> result = getCertificateVersionsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -5264,20 +5113,17 @@ public Observable>> call(Response getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateVersions(final String vaultBaseUrl, final String certificateName, final Integer maxresults) { ServiceResponse> response = getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } @@ -5285,14 +5131,14 @@ public Page nextPage(String nextPageLink) throws RestException, /** * List the versions of a certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults), new Func1>>>() { @Override @@ -5306,8 +5152,8 @@ public Observable>> call(String nextPageLi /** * List the versions of a certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<CertificateItem> object */ @@ -5316,7 +5162,7 @@ public Observable> getCertificateVersionsAsync(final Strin .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } @@ -5324,8 +5170,8 @@ public Page call(ServiceResponse> respons /** * List the versions of a certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the observable to the PagedList<CertificateItem> object */ @@ -5334,7 +5180,7 @@ public Observable>> getCertificateVersions .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -5346,8 +5192,8 @@ public Observable>> call(ServiceResponse

> * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - ServiceResponse> * @param certificateName The name of the certificate + ServiceResponse> * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + ServiceResponse> * @param certificateName The name of the certificate. ServiceResponse> * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. */ @@ -5368,7 +5214,7 @@ public Observable>> getCertificateVersions public Observable>> call(Response response) { try { ServiceResponse> result = getCertificateVersionsDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -5377,59 +5223,56 @@ public Observable>> call(Response> getCertificateVersionsDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Gets the policy for a certificate. + * Lists the policy for a certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in a given key vault. * @return the CertificatePolicy object if successful. */ - public CertificatePolicy getCertificatePolicy(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); + public CertificatePolicy getCertificatePolicy(String vaultBaseUrl, String certificateName) { + return getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().body(); } /** - * Gets the policy for a certificate. + * Lists the policy for a certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in a given key vault. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.fromResponse(getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** - * Gets the policy for a certificate. + * Lists the policy for a certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in a given key vault. * @return the observable to the CertificatePolicy object */ public Observable getCertificatePolicyAsync(String vaultBaseUrl, String certificateName) { return getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificatePolicy>() { @Override public CertificatePolicy call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Gets the policy for a certificate. + * Lists the policy for a certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault. + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in a given key vault. * @return the observable to the CertificatePolicy object */ public Observable> getCertificatePolicyWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { @@ -5458,44 +5301,41 @@ public Observable> call(Response getCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * Updates the policy for a certificate. Set specified members in the certificate policy. Leave others as null. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param certificateName The name of the certificate in the given vault. * @param certificatePolicy The policy for the certificate. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the CertificatePolicy object if successful. */ - public CertificatePolicy updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy).toBlocking().single().getBody(); + public CertificatePolicy updateCertificatePolicy(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy) { + return updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy).toBlocking().single().body(); } /** - * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * Updates the policy for a certificate. Set specified members in the certificate policy. Leave others as null. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param certificateName The name of the certificate in the given vault. * @param certificatePolicy The policy for the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy), serviceCallback); + return ServiceCall.fromResponse(updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy), serviceCallback); } /** - * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * Updates the policy for a certificate. Set specified members in the certificate policy. Leave others as null. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param certificateName The name of the certificate in the given vault. * @param certificatePolicy The policy for the certificate. * @return the observable to the CertificatePolicy object @@ -5504,15 +5344,15 @@ public Observable updateCertificatePolicyAsync(String vaultBa return updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy).map(new Func1, CertificatePolicy>() { @Override public CertificatePolicy call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Updates the policy for a certificate. Set appropriate members in the certificatePolicy that must be updated. Leave others as null. + * Updates the policy for a certificate. Set specified members in the certificate policy. Leave others as null. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param certificateName The name of the certificate in the given vault. * @param certificatePolicy The policy for the certificate. * @return the observable to the CertificatePolicy object @@ -5547,63 +5387,60 @@ public Observable> call(Response updateCertificatePolicyDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Updates the attributes associated with the specified certificate. + * Updates the specified attributes associated with the given certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in the given key vault. + * @param certificateVersion The version of the certificate. * @return the CertificateBundle object if successful. */ - public CertificateBundle updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single().getBody(); + public CertificateBundle updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) { + return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single().body(); } /** - * Updates the attributes associated with the specified certificate. + * Updates the specified attributes associated with the given certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in the given key vault. + * @param certificateVersion The version of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + return ServiceCall.fromResponse(updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); } /** - * Updates the attributes associated with the specified certificate. + * Updates the specified attributes associated with the given certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in the given key vault. + * @param certificateVersion The version of the certificate. * @return the observable to the CertificateBundle object */ public Observable updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).map(new Func1, CertificateBundle>() { @Override public CertificateBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Updates the attributes associated with the specified certificate. + * Updates the specified attributes associated with the given certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in the given key vault. + * @param certificateVersion The version of the certificate. * @return the observable to the CertificateBundle object */ public Observable> updateCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { @@ -5642,68 +5479,65 @@ public Observable> call(Response tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags).toBlocking().single().getBody(); + public CertificateBundle updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { + return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags).toBlocking().single().body(); } /** - * Updates the attributes associated with the specified certificate. + * Updates the specified attributes associated with the given certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate - * @param certificatePolicy The management policy for the certificate - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in the given key vault. + * @param certificateVersion The version of the certificate. + * @param certificatePolicy The management policy for the certificate. + * @param certificateAttributes The attributes of the certificate (optional). + * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags), serviceCallback); + return ServiceCall.fromResponse(updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags), serviceCallback); } /** - * Updates the attributes associated with the specified certificate. + * Updates the specified attributes associated with the given certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate - * @param certificatePolicy The management policy for the certificate - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in the given key vault. + * @param certificateVersion The version of the certificate. + * @param certificatePolicy The management policy for the certificate. + * @param certificateAttributes The attributes of the certificate (optional). + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the CertificateBundle object */ public Observable updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { return updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags).map(new Func1, CertificateBundle>() { @Override public CertificateBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Updates the attributes associated with the specified certificate. + * Updates the specified attributes associated with the given certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate - * @param certificatePolicy The management policy for the certificate - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in the given key vault. + * @param certificateVersion The version of the certificate. + * @param certificatePolicy The management policy for the certificate. + * @param certificateAttributes The attributes of the certificate (optional). + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the CertificateBundle object */ public Observable> updateCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { @@ -5742,63 +5576,60 @@ public Observable> call(Response updateCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Gets a Certificate. + * Gets information about a specified certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in the given vault. + * @param certificateVersion The version of the certificate. * @return the CertificateBundle object if successful. */ - public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single().getBody(); + public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) { + return getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).toBlocking().single().body(); } /** - * Gets a Certificate. + * Gets information about a specified certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in the given vault. + * @param certificateVersion The version of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + return ServiceCall.fromResponse(getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); } /** - * Gets a Certificate. + * Gets information about a specified certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in the given vault. + * @param certificateVersion The version of the certificate. * @return the observable to the CertificateBundle object */ public Observable getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { return getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion).map(new Func1, CertificateBundle>() { @Override public CertificateBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Gets a Certificate. + * Gets information about a specified certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate in the given vault - * @param certificateVersion The version of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate in the given vault. + * @param certificateVersion The version of the certificate. * @return the observable to the CertificateBundle object */ public Observable> getCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String certificateVersion) { @@ -5830,7 +5661,7 @@ public Observable> call(Response getCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -5839,36 +5670,33 @@ private ServiceResponse getCertificateDelegate(Response updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested, final ServiceCallback serviceCallback) { - return ServiceCall.create(updateCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName, cancellationRequested), serviceCallback); + return ServiceCall.fromResponse(updateCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName, cancellationRequested), serviceCallback); } /** * Updates a certificate operation. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. * @return the observable to the CertificateOperation object */ @@ -5876,7 +5704,7 @@ public Observable updateCertificateOperationAsync(String v return updateCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName, cancellationRequested).map(new Func1, CertificateOperation>() { @Override public CertificateOperation call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } @@ -5884,8 +5712,8 @@ public CertificateOperation call(ServiceResponse response) /** * Updates a certificate operation. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. * @return the observable to the CertificateOperation object */ @@ -5917,59 +5745,56 @@ public Observable> call(Response updateCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Gets the certificate operation response. + * Gets the operation associated with a specified certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the CertificateOperation object if successful. */ - public CertificateOperation getCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); + public CertificateOperation getCertificateOperation(String vaultBaseUrl, String certificateName) { + return getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().body(); } /** - * Gets the certificate operation response. + * Gets the operation associated with a specified certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.fromResponse(getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** - * Gets the certificate operation response. + * Gets the operation associated with a specified certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the observable to the CertificateOperation object */ public Observable getCertificateOperationAsync(String vaultBaseUrl, String certificateName) { return getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificateOperation>() { @Override public CertificateOperation call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Gets the certificate operation response. + * Gets the operation associated with a specified certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the observable to the CertificateOperation object */ public Observable> getCertificateOperationWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { @@ -5998,59 +5823,56 @@ public Observable> call(Response getCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * Deletes the certificate operation. + * Deletes the operation for a specified certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the CertificateOperation object if successful. */ - public CertificateOperation deleteCertificateOperation(String vaultBaseUrl, String certificateName) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().getBody(); + public CertificateOperation deleteCertificateOperation(String vaultBaseUrl, String certificateName) { + return deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).toBlocking().single().body(); } /** - * Deletes the certificate operation. + * Deletes the operation for a specified certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.create(deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + return ServiceCall.fromResponse(deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** - * Deletes the certificate operation. + * Deletes the operation for a specified certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the observable to the CertificateOperation object */ public Observable deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName) { return deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName).map(new Func1, CertificateOperation>() { @Override public CertificateOperation call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } /** - * Deletes the certificate operation. + * Deletes the operation for a specified certificate. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. * @return the observable to the CertificateOperation object */ public Observable> deleteCertificateOperationWithServiceResponseAsync(String vaultBaseUrl, String certificateName) { @@ -6079,7 +5901,7 @@ public Observable> call(Response deleteCertificateOperationDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(200, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -6088,44 +5910,41 @@ private ServiceResponse deleteCertificateOperationDelegate /** * Merges a certificate or a certificate chain with a key pair existing on the server. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificate chain to merge - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. + * @param x509Certificates The certificate or the certificate chain to merge. * @return the CertificateBundle object if successful. */ - public CertificateBundle mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates).toBlocking().single().getBody(); + public CertificateBundle mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates) { + return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates).toBlocking().single().body(); } /** * Merges a certificate or a certificate chain with a key pair existing on the server. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificate chain to merge + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. + * @param x509Certificates The certificate or the certificate chain to merge. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) { - return ServiceCall.create(mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates), serviceCallback); + return ServiceCall.fromResponse(mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates), serviceCallback); } /** * Merges a certificate or a certificate chain with a key pair existing on the server. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificate chain to merge + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. + * @param x509Certificates The certificate or the certificate chain to merge. * @return the observable to the CertificateBundle object */ public Observable mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates) { return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates).map(new Func1, CertificateBundle>() { @Override public CertificateBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } @@ -6133,9 +5952,9 @@ public CertificateBundle call(ServiceResponse response) { /** * Merges a certificate or a certificate chain with a key pair existing on the server. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificate chain to merge + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. + * @param x509Certificates The certificate or the certificate chain to merge. * @return the observable to the CertificateBundle object */ public Observable> mergeCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, List x509Certificates) { @@ -6176,50 +5995,47 @@ public Observable> call(Response x509Certificates, CertificateAttributes certificateAttributes, Map tags) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).toBlocking().single().getBody(); + public CertificateBundle mergeCertificate(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { + return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).toBlocking().single().body(); } /** * Merges a certificate or a certificate chain with a key pair existing on the server. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificate chain to merge - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. + * @param x509Certificates The certificate or the certificate chain to merge. + * @param certificateAttributes The attributes of the certificate (optional). + * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link ServiceCall} object */ public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.create(mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags), serviceCallback); + return ServiceCall.fromResponse(mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags), serviceCallback); } /** * Merges a certificate or a certificate chain with a key pair existing on the server. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificate chain to merge - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. + * @param x509Certificates The certificate or the certificate chain to merge. + * @param certificateAttributes The attributes of the certificate (optional). + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the CertificateBundle object */ public Observable mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { return mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags).map(new Func1, CertificateBundle>() { @Override public CertificateBundle call(ServiceResponse response) { - return response.getBody(); + return response.body(); } }); } @@ -6227,11 +6043,11 @@ public CertificateBundle call(ServiceResponse response) { /** * Merges a certificate or a certificate chain with a key pair existing on the server. * - * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net - * @param certificateName The name of the certificate - * @param x509Certificates The certificate or the certificate chain to merge - * @param certificateAttributes The attributes of the certificate (optional) - * @param tags Application-specific metadata in the form of key-value pairs + * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. + * @param certificateName The name of the certificate. + * @param x509Certificates The certificate or the certificate chain to merge. + * @param certificateAttributes The attributes of the certificate (optional). + * @param tags Application specific metadata in the form of key-value pairs. * @return the observable to the CertificateBundle object */ public Observable> mergeCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { @@ -6270,33 +6086,30 @@ public Observable> call(Response mergeCertificateDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder(this.mapperAdapter()) + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) .register(201, new TypeToken() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<KeyItem> object if successful. */ - public PagedList getKeyVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeyVersionsNext(final String nextPageLink) { ServiceResponse> response = getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getKeyVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls @@ -6304,7 +6117,7 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcep * @return the {@link ServiceCall} object */ public ServiceCall> getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getKeyVersionsNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6316,7 +6129,7 @@ public Observable>> call(String nextPageLink) { } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the observable to the PagedList<KeyItem> object @@ -6326,13 +6139,13 @@ public Observable> getKeyVersionsNextAsync(final String nextPageLi .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } /** - * List the versions of the specified key. + * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the observable to the PagedList<KeyItem> object @@ -6342,7 +6155,7 @@ public Observable>> getKeyVersionsNextWithServiceR .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -6352,7 +6165,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<KeyItem> object wrapped in {@link ServiceResponse} if successful. @@ -6361,13 +6174,14 @@ public Observable>> getKeyVersionsNextSinglePageAs if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getKeyVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + String nextUrl = String.format("%s", nextPageLink); + return service.getKeyVersionsNext(nextUrl, this.acceptLanguage(), this.userAgent()) .flatMap(new Func1, Observable>>>() { @Override public Observable>> call(Response response) { try { ServiceResponse> result = getKeyVersionsNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -6376,7 +6190,7 @@ public Observable>> call(Response re } private ServiceResponse> getKeyVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -6386,17 +6200,14 @@ private ServiceResponse> getKeyVersionsNextDelegate(Response getKeysNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getKeysNext(final String nextPageLink) { ServiceResponse> response = getKeysNextSinglePageAsync(nextPageLink).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getKeysNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } @@ -6410,7 +6221,7 @@ public Page nextPage(String nextPageLink) throws RestException, IOExcep * @return the {@link ServiceCall} object */ public ServiceCall> getKeysNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getKeysNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6432,7 +6243,7 @@ public Observable> getKeysNextAsync(final String nextPageLink) { .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } @@ -6448,7 +6259,7 @@ public Observable>> getKeysNextWithServiceResponse .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -6467,13 +6278,14 @@ public Observable>> getKeysNextSinglePageAsync(fin if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getKeysNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + String nextUrl = String.format("%s", nextPageLink); + return service.getKeysNext(nextUrl, this.acceptLanguage(), this.userAgent()) .flatMap(new Func1, Observable>>>() { @Override public Observable>> call(Response response) { try { ServiceResponse> result = getKeysNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -6482,33 +6294,30 @@ public Observable>> call(Response re } private ServiceResponse> getKeysNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * List secrets in the specified vault. + * List secrets in a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<SecretItem> object if successful. */ - public PagedList getSecretsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecretsNext(final String nextPageLink) { ServiceResponse> response = getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getSecretsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** - * List secrets in the specified vault. + * List secrets in a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls @@ -6516,7 +6325,7 @@ public Page nextPage(String nextPageLink) throws RestException, IOEx * @return the {@link ServiceCall} object */ public ServiceCall> getSecretsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getSecretsNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6528,7 +6337,7 @@ public Observable>> call(String nextPageLink) { } /** - * List secrets in the specified vault. + * List secrets in a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the observable to the PagedList<SecretItem> object @@ -6538,13 +6347,13 @@ public Observable> getSecretsNextAsync(final String nextPageLin .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } /** - * List secrets in the specified vault. + * List secrets in a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the observable to the PagedList<SecretItem> object @@ -6554,7 +6363,7 @@ public Observable>> getSecretsNextWithServiceRe .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -6564,7 +6373,7 @@ public Observable>> call(ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<SecretItem> object wrapped in {@link ServiceResponse} if successful. @@ -6573,13 +6382,14 @@ public Observable>> getSecretsNextSinglePageAsy if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getSecretsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + String nextUrl = String.format("%s", nextPageLink); + return service.getSecretsNext(nextUrl, this.acceptLanguage(), this.userAgent()) .flatMap(new Func1, Observable>>>() { @Override public Observable>> call(Response response) { try { ServiceResponse> result = getSecretsNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -6588,7 +6398,7 @@ public Observable>> call(Response } private ServiceResponse> getSecretsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -6598,17 +6408,14 @@ private ServiceResponse> getSecretsNextDelegate(Response getSecretVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getSecretVersionsNext(final String nextPageLink) { ServiceResponse> response = getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getSecretVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } @@ -6622,7 +6429,7 @@ public Page nextPage(String nextPageLink) throws RestException, IOEx * @return the {@link ServiceCall} object */ public ServiceCall> getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getSecretVersionsNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6644,7 +6451,7 @@ public Observable> getSecretVersionsNextAsync(final String next .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } @@ -6660,7 +6467,7 @@ public Observable>> getSecretVersionsNextWithSe .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -6679,13 +6486,14 @@ public Observable>> getSecretVersionsNextSingle if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getSecretVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + String nextUrl = String.format("%s", nextPageLink); + return service.getSecretVersionsNext(nextUrl, this.acceptLanguage(), this.userAgent()) .flatMap(new Func1, Observable>>>() { @Override public Observable>> call(Response response) { try { ServiceResponse> result = getSecretVersionsNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -6694,33 +6502,30 @@ public Observable>> call(Response } private ServiceResponse> getSecretVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * List certificates in the specified vault. + * List certificates in a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CertificateItem> object if successful. */ - public PagedList getCertificatesNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificatesNext(final String nextPageLink) { ServiceResponse> response = getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getCertificatesNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** - * List certificates in the specified vault. + * List certificates in a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls @@ -6728,7 +6533,7 @@ public Page nextPage(String nextPageLink) throws RestException, * @return the {@link ServiceCall} object */ public ServiceCall> getCertificatesNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getCertificatesNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6740,7 +6545,7 @@ public Observable>> call(String nextPageLi } /** - * List certificates in the specified vault. + * List certificates in a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the observable to the PagedList<CertificateItem> object @@ -6750,13 +6555,13 @@ public Observable> getCertificatesNextAsync(final String n .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } /** - * List certificates in the specified vault. + * List certificates in a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the observable to the PagedList<CertificateItem> object @@ -6766,7 +6571,7 @@ public Observable>> getCertificatesNextWit .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -6776,7 +6581,7 @@ public Observable>> call(ServiceResponse

> * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<CertificateItem> object wrapped in {@link ServiceResponse} if successful. @@ -6785,13 +6590,14 @@ public Observable>> getCertificatesNextSin if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getCertificatesNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + String nextUrl = String.format("%s", nextPageLink); + return service.getCertificatesNext(nextUrl, this.acceptLanguage(), this.userAgent()) .flatMap(new Func1, Observable>>>() { @Override public Observable>> call(Response response) { try { ServiceResponse> result = getCertificatesNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -6800,33 +6606,30 @@ public Observable>> call(Response> getCertificatesNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CertificateIssuerItem> object if successful. */ - public PagedList getCertificateIssuersNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateIssuersNext(final String nextPageLink) { ServiceResponse> response = getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getCertificateIssuersNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @param serviceCall the ServiceCall object tracking the Retrofit calls @@ -6834,7 +6637,7 @@ public Page nextPage(String nextPageLink) throws RestExce * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getCertificateIssuersNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6846,7 +6649,7 @@ public Observable>> call(String next } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the observable to the PagedList<CertificateIssuerItem> object @@ -6856,13 +6659,13 @@ public Observable> getCertificateIssuersNextAsync(fi .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the observable to the PagedList<CertificateIssuerItem> object @@ -6872,7 +6675,7 @@ public Observable>> getCertificateIs .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -6882,7 +6685,7 @@ public Observable>> call(ServiceResp } /** - * List certificate issuers for the specified vault. + * List certificate issuers for a specified key vault. * ServiceResponse> * @param nextPageLink The NextLink from the previous successful call to List operation. * @return the PagedList<CertificateIssuerItem> object wrapped in {@link ServiceResponse} if successful. @@ -6891,13 +6694,14 @@ public Observable>> getCertificateIs if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getCertificateIssuersNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + String nextUrl = String.format("%s", nextPageLink); + return service.getCertificateIssuersNext(nextUrl, this.acceptLanguage(), this.userAgent()) .flatMap(new Func1, Observable>>>() { @Override public Observable>> call(Response response) { try { ServiceResponse> result = getCertificateIssuersNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -6906,7 +6710,7 @@ public Observable>> call(Response> getCertificateIssuersNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); @@ -6916,17 +6720,14 @@ private ServiceResponse> getCertificateIssuersNe * List the versions of a certificate. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @throws KeyVaultErrorException exception thrown from REST call - * @throws IOException exception thrown from serialization/deserialization - * @throws IllegalArgumentException exception thrown from invalid parameters * @return the PagedList<CertificateItem> object if successful. */ - public PagedList getCertificateVersionsNext(final String nextPageLink) throws KeyVaultErrorException, IOException, IllegalArgumentException { + public PagedList getCertificateVersionsNext(final String nextPageLink) { ServiceResponse> response = getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single(); - return new PagedList(response.getBody()) { + return new PagedList(response.body()) { @Override - public Page nextPage(String nextPageLink) throws RestException, IOException { - return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().getBody(); + public Page nextPage(String nextPageLink) { + return getCertificateVersionsNextSinglePageAsync(nextPageLink).toBlocking().single().body(); } }; } @@ -6940,7 +6741,7 @@ public Page nextPage(String nextPageLink) throws RestException, * @return the {@link ServiceCall} object */ public ServiceCall> getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.create( + return AzureServiceCall.fromPageResponse( getCertificateVersionsNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6962,7 +6763,7 @@ public Observable> getCertificateVersionsNextAsync(final S .map(new Func1>, Page>() { @Override public Page call(ServiceResponse> response) { - return response.getBody(); + return response.body(); } }); } @@ -6978,7 +6779,7 @@ public Observable>> getCertificateVersions .concatMap(new Func1>, Observable>>>() { @Override public Observable>> call(ServiceResponse> page) { - String nextPageLink = page.getBody().getNextPageLink(); + String nextPageLink = page.body().nextPageLink(); if (nextPageLink == null) { return Observable.just(page); } @@ -6997,13 +6798,14 @@ public Observable>> getCertificateVersions if (nextPageLink == null) { throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null."); } - return service.getCertificateVersionsNext(nextPageLink, this.acceptLanguage(), this.userAgent()) + String nextUrl = String.format("%s", nextPageLink); + return service.getCertificateVersionsNext(nextUrl, this.acceptLanguage(), this.userAgent()) .flatMap(new Func1, Observable>>>() { @Override public Observable>> call(Response response) { try { ServiceResponse> result = getCertificateVersionsNextDelegate(response); - return Observable.just(new ServiceResponse>(result.getBody(), result.getResponse())); + return Observable.just(new ServiceResponse>(result.body(), result.response())); } catch (Throwable t) { return Observable.error(t); } @@ -7012,7 +6814,7 @@ public Observable>> call(Response> getCertificateVersionsNextDelegate(Response response) throws KeyVaultErrorException, IOException, IllegalArgumentException { - return new AzureServiceResponseBuilder, KeyVaultErrorException>(this.mapperAdapter()) + return this.restClient().responseBuilderFactory()., KeyVaultErrorException>newInstance(this.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) .registerError(KeyVaultErrorException.class) .build(response); diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java index b87d376d8bdde..1f70881a0e845 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Action.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java index 3bd73fd386216..9ec938c16e3f2 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/ActionType.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java index 580ac6b5d62f2..0e60e9cf8e320 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/AdministratorDetails.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -37,6 +37,7 @@ public class AdministratorDetails { /** * Phone number. */ + @JsonProperty(value = "phone") private String phone; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java index ed187ccd0cab0..d4028e2176d0a 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Attributes.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -21,6 +21,7 @@ public class Attributes { /** * Determines whether the object is enabled. */ + @JsonProperty(value = "enabled") private Boolean enabled; /** @@ -38,13 +39,13 @@ public class Attributes { /** * Creation time in UTC. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "created", access = JsonProperty.Access.WRITE_ONLY) private Long created; /** * Last updated time in UTC. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "updated", access = JsonProperty.Access.WRITE_ONLY) private Long updated; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java index b5a6a72351240..9efe5dba72250 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/BackupKeyResult.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -20,7 +20,7 @@ public class BackupKeyResult { /** * The backup blob containing the backed up key. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "value", access = JsonProperty.Access.WRITE_ONLY) private Base64Url value; /** @@ -32,7 +32,7 @@ public byte[] value() { if (this.value == null) { return null; } - return this.value.getDecodedBytes(); + return this.value.decodedBytes(); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java index d821e2490bc60..96dcea18189d4 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateAttributes.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java index 44417b1eea285..524885a86230a 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateBundle.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -13,7 +13,6 @@ import com.microsoft.azure.keyvault.CertificateIdentifier; import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.SecretIdentifier; -import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; import com.microsoft.rest.Base64Url; import java.io.IOException; @@ -30,19 +29,19 @@ public class CertificateBundle { /** * The certificate id. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) private String id; /** * The key id. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "kid", access = JsonProperty.Access.WRITE_ONLY) private String kid; /** * The secret id. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "sid", access = JsonProperty.Access.WRITE_ONLY) private String sid; /** @@ -54,27 +53,31 @@ public class CertificateBundle { /** * The management policy. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "policy", access = JsonProperty.Access.WRITE_ONLY) private CertificatePolicy policy; /** * CER contents of x509 certificate. */ + @JsonProperty(value = "cer") private byte[] cer; /** * The content type of the secret. */ + @JsonProperty(value = "contentType") private String contentType; /** * The certificate attributes. */ + @JsonProperty(value = "attributes") private CertificateAttributes attributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** @@ -113,7 +116,7 @@ public byte[] x509Thumbprint() { if (this.x509Thumbprint == null) { return null; } - return this.x509Thumbprint.getDecodedBytes(); + return this.x509Thumbprint.decodedBytes(); } /** @@ -240,8 +243,7 @@ public KeyIdentifier keyIdentifier() { @Override public String toString() { - AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); - ObjectMapper mapper = mapperAdapter.getObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java index 9de3d7a36bebb..313ea1007b89e 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateCreateParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -30,8 +30,9 @@ public class CertificateCreateParameters { private CertificateAttributes certificateAttributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java index 6cd918a00cb14..a85509ce874e2 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateImportParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -44,8 +44,9 @@ public class CertificateImportParameters { private CertificateAttributes certificateAttributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java index 2edac49304f93..58fd49c03affb 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerItem.java @@ -3,13 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ package com.microsoft.azure.keyvault.models; +import com.fasterxml.jackson.annotation.JsonProperty; /** * The certificate issuer item containing certificate issuer metadata. @@ -18,11 +19,13 @@ public class CertificateIssuerItem { /** * Certificate Identifier. */ + @JsonProperty(value = "id") private String id; /** * The issuer provider. */ + @JsonProperty(value = "provider") private String provider; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java index df352850dff30..629ae3db29243 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerSetParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -19,12 +19,13 @@ public class CertificateIssuerSetParameters { /** * The issuer provider. */ - @JsonProperty(required = true) + @JsonProperty(value = "provider", required = true) private String provider; /** * The credentials to be used for the issuer. */ + @JsonProperty(value = "credentials") private IssuerCredentials credentials; /** @@ -36,6 +37,7 @@ public class CertificateIssuerSetParameters { /** * Attributes of the issuer object. */ + @JsonProperty(value = "attributes") private IssuerAttributes attributes; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java index 05d62b4ec54d9..799634b153cdb 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateIssuerUpdateParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -19,11 +19,13 @@ public class CertificateIssuerUpdateParameters { /** * The issuer provider. */ + @JsonProperty(value = "provider") private String provider; /** * The credentials to be used for the issuer. */ + @JsonProperty(value = "credentials") private IssuerCredentials credentials; /** @@ -35,6 +37,7 @@ public class CertificateIssuerUpdateParameters { /** * Attributes of the issuer object. */ + @JsonProperty(value = "attributes") private IssuerAttributes attributes; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java index cf13fa529bb36..e190bc8b024b7 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateItem.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -11,7 +11,6 @@ package com.microsoft.azure.keyvault.models; import java.util.Map; - import com.microsoft.azure.keyvault.CertificateIdentifier; import com.microsoft.rest.Base64Url; import com.fasterxml.jackson.annotation.JsonProperty; @@ -21,18 +20,21 @@ */ public class CertificateItem { /** - * Certificate Identifier. + * Certificate identifier. */ + @JsonProperty(value = "id") private String id; /** * The certificate management attributes. */ + @JsonProperty(value = "attributes") private CertificateAttributes attributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** @@ -110,7 +112,7 @@ public byte[] x509Thumbprint() { if (this.x509Thumbprint == null) { return null; } - return this.x509Thumbprint.getDecodedBytes(); + return this.x509Thumbprint.decodedBytes(); } /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java index 46454283ded8f..61a6948046d0f 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateMergeParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -31,8 +31,9 @@ public class CertificateMergeParameters { private CertificateAttributes certificateAttributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java index 1cf79183ef3d5..862d5d2ad848d 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperation.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -17,16 +17,15 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.CertificateOperationIdentifier; -import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** - * A certificate operation is returned in case of async requests. + * A certificate operation is returned in case of asynchronous requests. */ public class CertificateOperation { /** * The certificate id. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) private String id; /** @@ -36,9 +35,10 @@ public class CertificateOperation { private IssuerParameters issuerParameters; /** - * The Certificate Signing Request (CSR) that is being used in the + * The certificate signing request (CSR) that is being used in the * certificate operation. */ + @JsonProperty(value = "csr") private byte[] csr; /** @@ -50,6 +50,7 @@ public class CertificateOperation { /** * Status of the certificate operation. */ + @JsonProperty(value = "status") private String status; /** @@ -61,11 +62,13 @@ public class CertificateOperation { /** * Error encountered, if any, during the certificate operation. */ + @JsonProperty(value = "error") private Error error; /** * Location which contains the result of the certificate operation. */ + @JsonProperty(value = "target") private String target; /** @@ -256,8 +259,7 @@ public CertificateOperationIdentifier certificateOperationIdentifier() { @Override public String toString() { - AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); - ObjectMapper mapper = mapperAdapter.getObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java index b2cd7b05f1189..4179f67fe606d 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateOperationUpdateParameter.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java index 7fa34dc9aa7b2..1f43ad5bbfa75 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificatePolicy.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -20,7 +20,7 @@ public class CertificatePolicy { /** * The certificate id. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) private String id; /** @@ -57,6 +57,7 @@ public class CertificatePolicy { /** * The certificate attributes. */ + @JsonProperty(value = "attributes") private CertificateAttributes attributes; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java index e3e899ff572c6..af9bbe3f566dd 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/CertificateUpdateParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -30,8 +30,9 @@ public class CertificateUpdateParameters { private CertificateAttributes certificateAttributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java index 7fe0c7baeb017..dd7111eb6f2d6 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contact.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -25,11 +25,13 @@ public class Contact { /** * Name. */ + @JsonProperty(value = "name") private String name; /** * Phone number. */ + @JsonProperty(value = "phone") private String phone; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java index 8d0d542cbeb2b..166f0392f293a 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Contacts.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -20,7 +20,7 @@ public class Contacts { /** * Identifier for the contacts collection. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) private String id; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java index 8826781c7e929..103ad6182c75f 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Error.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -19,13 +19,13 @@ public class Error { /** * The error code. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "code", access = JsonProperty.Access.WRITE_ONLY) private String code; /** * The error message. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "message", access = JsonProperty.Access.WRITE_ONLY) private String message; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java index 592e36229ecc7..7c1b9c47b271d 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerAttributes.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -15,24 +15,25 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * The attributes of an issuer managed by the KeyVault service. + * The attributes of an issuer managed by the Key Vault service. */ public class IssuerAttributes { /** * Determines whether the issuer is enabled. */ + @JsonProperty(value = "enabled") private Boolean enabled; /** * Creation time in UTC. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "created", access = JsonProperty.Access.WRITE_ONLY) private Long created; /** * Last updated time in UTC. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "updated", access = JsonProperty.Access.WRITE_ONLY) private Long updated; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java index 59b4d7f2afca1..89d8500663b05 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerBundle.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -17,7 +17,6 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.IssuerIdentifier; -import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** * The issuer for Key Vault certificate. @@ -26,17 +25,19 @@ public class IssuerBundle { /** * Identifier for the issuer object. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) private String id; /** * The issuer provider. */ + @JsonProperty(value = "provider") private String provider; /** * The credentials to be used for the issuer. */ + @JsonProperty(value = "credentials") private IssuerCredentials credentials; /** @@ -48,6 +49,7 @@ public class IssuerBundle { /** * Attributes of the issuer object. */ + @JsonProperty(value = "attributes") private IssuerAttributes attributes; /** @@ -152,8 +154,7 @@ public IssuerIdentifier issuerIdentifier() { @Override public String toString() { - AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); - ObjectMapper mapper = mapperAdapter.getObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java index 23ef3eced7f05..165d1e1534f6f 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerCredentials.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerParameters.java index 826f3692c34c4..fe8f6a857c07b 100644 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/IssuerParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -17,9 +17,10 @@ */ public class IssuerParameters { /** - * Name of the referenced issuer object or reserved names e.g. 'Self', - * 'Unknown'. + * Name of the referenced issuer object or reserved names; for example, + * 'Self' or 'Unknown'. */ + @JsonProperty(value = "name") private String name; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java index 25c37fede46de..59910d461f84f 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyAttributes.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -12,7 +12,7 @@ /** - * The attributes of a key managed by the KeyVault service. + * The attributes of a key managed by the key vault service. */ public class KeyAttributes extends Attributes { } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java index e8353e0708742..cfe5f0399e88d 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyBundle.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -18,33 +18,35 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.KeyIdentifier; import com.microsoft.azure.keyvault.webkey.JsonWebKey; -import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; import com.fasterxml.jackson.annotation.JsonProperty; /** - * A KeyBundle consisting of a WebKey plus its Attributes. + * A KeyBundle consisting of a WebKey plus its attributes. */ public class KeyBundle { /** * The Json web key. */ + @JsonProperty(value = "key") private JsonWebKey key; /** * The key management attributes. */ + @JsonProperty(value = "attributes") private KeyAttributes attributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** - * True if the key's lifetime is managed by key vault i.e. if this is a - * key backing a certificate, then managed will be true. + * True if the key's lifetime is managed by key vault. If this is a key + * backing a certificate, then managed will be true. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "managed", access = JsonProperty.Access.WRITE_ONLY) private Boolean managed; /** @@ -127,10 +129,8 @@ public KeyIdentifier keyIdentifier() { return new KeyIdentifier(key().kid()); } - @Override public String toString() { - AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); - ObjectMapper mapper = mapperAdapter.getObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java index 9d61d685cee94..bb4e6c187a501 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyCreateParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -21,15 +21,15 @@ */ public class KeyCreateParameters { /** - * The type of key to create. Valid key types, see JsonWebKeyType. + * The type of key to create. For valid key types, see JsonWebKeyType. * Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, * Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct'. */ - @JsonProperty(required = true) + @JsonProperty(value = "kty", required = true) private JsonWebKeyType kty; /** - * The key size in bytes. e.g. 1024 or 2048. + * The key size in bytes. For example, 1024 or 2048. */ @JsonProperty(value = "key_size") private Integer keySize; @@ -47,8 +47,9 @@ public class KeyCreateParameters { private KeyAttributes keyAttributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java index 457486131b8c7..7c3ec66c01862 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyImportParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -27,7 +27,7 @@ public class KeyImportParameters { /** * The Json web key. */ - @JsonProperty(required = true) + @JsonProperty(value = "key", required = true) private JsonWebKey key; /** @@ -37,8 +37,9 @@ public class KeyImportParameters { private KeyAttributes keyAttributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java index f54b847cd02f7..8e0fc7d37f6ba 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyItem.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -11,7 +11,6 @@ package com.microsoft.azure.keyvault.models; import java.util.Map; - import com.microsoft.azure.keyvault.KeyIdentifier; import com.fasterxml.jackson.annotation.JsonProperty; @@ -20,25 +19,28 @@ */ public class KeyItem { /** - * Key Identifier. + * Key identifier. */ + @JsonProperty(value = "kid") private String kid; /** * The key management attributes. */ + @JsonProperty(value = "attributes") private KeyAttributes attributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** - * True if the key's lifetime is managed by key vault i.e. if this is a - * key backing a certificate, then managed will be true. + * True if the key's lifetime is managed by key vault. If this is a key + * backing a certificate, then managed will be true. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "managed", access = JsonProperty.Access.WRITE_ONLY) private Boolean managed; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java index 229b85ec52d70..9c935bb5414c6 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationResult.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -20,7 +20,7 @@ public class KeyOperationResult { /** * Key identifier. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "kid", access = JsonProperty.Access.WRITE_ONLY) private String kid; /** @@ -47,7 +47,7 @@ public byte[] result() { if (this.result == null) { return null; } - return this.result.getDecodedBytes(); + return this.result.decodedBytes(); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java index d65ddea14591e..5a893ce790e09 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyOperationsParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -27,7 +27,7 @@ public class KeyOperationsParameters { /** * The value property. */ - @JsonProperty(required = true) + @JsonProperty(value = "value", required = true) private Base64Url value; /** @@ -59,7 +59,7 @@ public byte[] value() { if (this.value == null) { return null; } - return this.value.getDecodedBytes(); + return this.value.decodedBytes(); } /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java index a82bbe119d6b7..61f339b62ba82 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyProperties.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -19,6 +19,7 @@ public class KeyProperties { /** * Indicates if the private key can be exported. */ + @JsonProperty(value = "exportable") private Boolean exportable; /** @@ -28,7 +29,7 @@ public class KeyProperties { private String keyType; /** - * The key size in bytes. e.g. 2048. + * The key size in bytes. For example; 1024 or 2048. */ @JsonProperty(value = "key_size") private Integer keySize; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java index 2d32495d4074e..3ecc2181ae2b7 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyRestoreParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -18,7 +18,7 @@ */ public class KeyRestoreParameters { /** - * the backup blob associated with a key bundle. + * The backup blob associated with a key bundle. */ @JsonProperty(value = "value", required = true) private Base64Url keyBundleBackup; @@ -32,7 +32,7 @@ public byte[] keyBundleBackup() { if (this.keyBundleBackup == null) { return null; } - return this.keyBundleBackup.getDecodedBytes(); + return this.keyBundleBackup.decodedBytes(); } /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java index 838b54f7a964a..50e87a32383b2 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeySignParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -29,7 +29,7 @@ public class KeySignParameters { /** * The value property. */ - @JsonProperty(required = true) + @JsonProperty(value = "value", required = true) private Base64Url value; /** @@ -61,7 +61,7 @@ public byte[] value() { if (this.value == null) { return null; } - return this.value.getDecodedBytes(); + return this.value.decodedBytes(); } /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java index 043fbe2d44fd3..4cdd6afd1f894 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUpdateParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -33,8 +33,9 @@ public class KeyUpdateParameters { private KeyAttributes keyAttributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java index 7b4b390b1cb65..bce9c9609dd0e 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyUsageType.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java index aa2a6f81d1c74..4d36aeafe0e08 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultError.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -13,13 +13,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * the key vault error exception. + * The key vault error exception. */ public class KeyVaultError { /** * The error property. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "error", access = JsonProperty.Access.WRITE_ONLY) private Error error; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java index bdcfc617fc14c..1fa9ca3344015 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVaultErrorException.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -11,79 +11,36 @@ package com.microsoft.azure.keyvault.models; import com.microsoft.rest.RestException; +import okhttp3.ResponseBody; import retrofit2.Response; /** * Exception thrown for an invalid response with KeyVaultError information. */ public class KeyVaultErrorException extends RestException { - /** - * Information about the associated HTTP response. - */ - private Response response; - /** - * The actual response body. - */ - private KeyVaultError body; - /** - * Initializes a new instance of the KeyVaultErrorException class. - */ - public KeyVaultErrorException() { } /** * Initializes a new instance of the KeyVaultErrorException class. * - * @param message The exception message. - */ - public KeyVaultErrorException(final String message) { - super(message); - } - /** - * Initializes a new instance of the KeyVaultErrorException class. - * - * @param message the exception message - * @param cause exception that caused this exception to occur + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response */ - public KeyVaultErrorException(final String message, final Throwable cause) { - super(message, cause); + public KeyVaultErrorException(final String message, final Response response) { + super(message, response); } + /** * Initializes a new instance of the KeyVaultErrorException class. * - * @param cause exception that caused this exception to occur - */ - public KeyVaultErrorException(final Throwable cause) { - super(cause); - } - /** - * Gets information about the associated HTTP response. - * - * @return the HTTP response - */ - public Response getResponse() { - return response; - } - /** - * Gets the HTTP response body. - * - * @return the response body - */ - public KeyVaultError getBody() { - return body; - } - /** - * Sets the HTTP response. - * + * @param message the exception message or the response content if a message is not available * @param response the HTTP response + * @param body the deserialized response body */ - public void setResponse(Response response) { - this.response = response; + public KeyVaultErrorException(final String message, final Response response, final KeyVaultError body) { + super(message, response, body); } - /** - * Sets the HTTP response body. - * - * @param body the response body - */ - public void setBody(KeyVaultError body) { - this.body = body; + + @Override + public KeyVaultError body() { + return (KeyVaultError) super.body(); } } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java index 96fd4cb07f947..5c0d50d968200 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -29,7 +29,7 @@ public class KeyVerifyParameters { /** * The digest used for signing. */ - @JsonProperty(required = true) + @JsonProperty(value = "digest", required = true) private Base64Url digest; /** @@ -67,7 +67,7 @@ public byte[] digest() { if (this.digest == null) { return null; } - return this.digest.getDecodedBytes(); + return this.digest.decodedBytes(); } /** @@ -94,7 +94,7 @@ public byte[] signature() { if (this.signature == null) { return null; } - return this.signature.getDecodedBytes(); + return this.signature.decodedBytes(); } /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java index 2295ece7edb6a..bd62f37bfb67d 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/KeyVerifyResult.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -17,9 +17,9 @@ */ public class KeyVerifyResult { /** - * true if the signature is verified, false otherwise. + * True if the signature is verified, otherwise false. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "value", access = JsonProperty.Access.WRITE_ONLY) private Boolean value; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java index 9f2f520dfaf7a..8af57a3fc9271 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/LifetimeAction.java @@ -3,27 +3,30 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ package com.microsoft.azure.keyvault.models; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Action and its trigger that will be performed by Key Vault over the - * lifetime of a certificate. + * Action and its trigger that will be performed by Key Vault over the lifetime + * of a certificate. */ public class LifetimeAction { /** * The condition that will execute the action. */ + @JsonProperty(value = "trigger") private Trigger trigger; /** * The action that will be executed. */ + @JsonProperty(value = "action") private Action action; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java index 44e80f582186f..14c49454359b2 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/OrganizationDetails.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -20,6 +20,7 @@ public class OrganizationDetails { /** * Id of the organization. */ + @JsonProperty(value = "id") private String id; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java index ba40e0b446269..ebfecbb4e6fa4 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PageImpl.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -39,7 +39,7 @@ public class PageImpl implements Page { * @return the link to the next page. */ @Override - public String getNextPageLink() { + public String nextPageLink() { return this.nextPageLink; } @@ -49,7 +49,7 @@ public String getNextPageLink() { * @return the list of items in {@link List}. */ @Override - public List getItems() { + public List items() { return items; } diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java index 51b5fc32aee52..9067674bcda98 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/PendingCertificateSigningRequestResult.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -19,7 +19,7 @@ public class PendingCertificateSigningRequestResult { /** * The pending certificate signing request as Base64 encoded string. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "value", access = JsonProperty.Access.WRITE_ONLY) private String value; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java index e6cdbe4d40db0..59b8463d65f5f 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretAttributes.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java index f5648ae67eb13..0743b08e0182e 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretBundle.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -18,49 +18,53 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.microsoft.azure.keyvault.SecretIdentifier; -import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; /** - * A Secret consisting of a value, id and its attributes. + * A secret consisting of a value, id and its attributes. */ public class SecretBundle { /** * The secret value. */ + @JsonProperty(value = "value") private String value; /** * The secret id. */ + @JsonProperty(value = "id") private String id; /** * The content type of the secret. */ + @JsonProperty(value = "contentType") private String contentType; /** * The secret management attributes. */ + @JsonProperty(value = "attributes") private SecretAttributes attributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** * If this is a secret backing a KV certificate, then this field specifies * the corresponding key backing the KV certificate. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "kid", access = JsonProperty.Access.WRITE_ONLY) private String kid; /** - * True if the secret's lifetime is managed by key vault i.e. if this is a + * True if the secret's lifetime is managed by key vault. If this is a * secret backing a certificate, then managed will be true. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "managed", access = JsonProperty.Access.WRITE_ONLY) private Boolean managed; /** @@ -194,8 +198,7 @@ public SecretIdentifier secretIdentifier() { @Override public String toString() { - AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); - ObjectMapper mapper = mapperAdapter.getObjectMapper(); + ObjectMapper mapper = new ObjectMapper(); try { return mapper.writeValueAsString(this); } catch (JsonGenerationException e) { diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java index 00bd3528dc4a0..f73fd1dbefe02 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretItem.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -11,7 +11,6 @@ package com.microsoft.azure.keyvault.models; import java.util.Map; - import com.microsoft.azure.keyvault.SecretIdentifier; import com.fasterxml.jackson.annotation.JsonProperty; @@ -20,30 +19,34 @@ */ public class SecretItem { /** - * Secret Identifier. + * Secret identifier. */ + @JsonProperty(value = "id") private String id; /** * The secret management attributes. */ + @JsonProperty(value = "attributes") private SecretAttributes attributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** * Type of the secret value such as a password. */ + @JsonProperty(value = "contentType") private String contentType; /** - * True if the secret's lifetime is managed by key vault i.e. if this is a - * key backing a certificate, then managed will be true. + * True if the secret's lifetime is managed by key vault. If this is a key + * backing a certificate, then managed will be true. */ - @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "managed", access = JsonProperty.Access.WRITE_ONLY) private Boolean managed; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java index daa4ec324e4cc..f5b4bbc5db3d6 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretProperties.java @@ -3,13 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ package com.microsoft.azure.keyvault.models; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Properties of the key backing a certificate. @@ -18,6 +19,7 @@ public class SecretProperties { /** * The media type (MIME type). */ + @JsonProperty(value = "contentType") private String contentType; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java index c6aa346335c08..af9172c65939c 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretSetParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -20,17 +20,19 @@ public class SecretSetParameters { /** * The value of the secret. */ - @JsonProperty(required = true) + @JsonProperty(value = "value", required = true) private String value; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** * Type of the secret value such as a password. */ + @JsonProperty(value = "contentType") private String contentType; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java index ac9361fffbe73..a3f831f985c61 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SecretUpdateParameters.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -20,6 +20,7 @@ public class SecretUpdateParameters { /** * Type of the secret value such as a password. */ + @JsonProperty(value = "contentType") private String contentType; /** @@ -29,8 +30,9 @@ public class SecretUpdateParameters { private SecretAttributes secretAttributes; /** - * Application-specific metadata in the form of key-value pairs. + * Application specific metadata in the form of key-value pairs. */ + @JsonProperty(value = "tags") private Map tags; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java index 317cc22925354..ec4787470953f 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/SubjectAlternativeNames.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -20,6 +20,7 @@ public class SubjectAlternativeNames { /** * Email addresses. */ + @JsonProperty(value = "emails") private List emails; /** @@ -31,6 +32,7 @@ public class SubjectAlternativeNames { /** * User principal names. */ + @JsonProperty(value = "upns") private List upns; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java index 52fa1a031dd3a..dc06dd4e24af5 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/Trigger.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -17,7 +17,7 @@ */ public class Trigger { /** - * Percentage of lifetime as which to trigger. Value should be between 1 + * Percentage of lifetime at which to trigger. Value should be between 1 * and 99. */ @JsonProperty(value = "lifetime_percentage") diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java index 34b1889e212ee..59fa52ef70632 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/X509CertificateProperties.java @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for * license information. * - * Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 + * Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ @@ -18,13 +18,15 @@ */ public class X509CertificateProperties { /** - * The subject name. Should be a valid X509 Distinguished Name. + * The subject name. Should be a valid X509 distinguished Name. */ + @JsonProperty(value = "subject") private String subject; /** * The enhanced key usage. */ + @JsonProperty(value = "ekus") private List ekus; /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java index 79c10e9f21e65..584cd6850e6c8 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/models/package-info.java @@ -2,12 +2,12 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. /** * This package contains the models classes for KeyVaultClient. - * Performs cryptographic key operations and vault operations against the Key Vault service. + * The key vault client performs cryptographic key operations and vault operations against the Key Vault service. */ package com.microsoft.azure.keyvault.models; diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java index ec9b976c5096b..f08140f306f95 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/package-info.java @@ -2,12 +2,12 @@ // Licensed under the MIT License. See License.txt in the project root for // license information. // -// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 +// Code generated by Microsoft (R) AutoRest Code Generator 1.0.0.0 // Changes may cause incorrect behavior and will be lost if the code is // regenerated. /** * This package contains the classes for KeyVaultClient. - * Performs cryptographic key operations and vault operations against the Key Vault service. + * The key vault client performs cryptographic key operations and vault operations against the Key Vault service. */ package com.microsoft.azure.keyvault; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java index 70a221d188afa..d4c47bfe7b83f 100644 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/AsyncOperationsTest.java @@ -117,7 +117,7 @@ public void keyAsync() throws Exception { Throwable t = ex.getCause(); if(t instanceof KeyVaultErrorException) { - Assert.assertEquals("KeyNotFound", ((KeyVaultErrorException) t).getBody().error().code()); + Assert.assertEquals("KeyNotFound", ((KeyVaultErrorException) t).body().error().code()); } else throw ex; } @@ -157,7 +157,7 @@ public void secretAsync() throws Exception { Throwable t = ex.getCause(); if(t instanceof KeyVaultErrorException) { - Assert.assertEquals("SecretNotFound", ((KeyVaultErrorException) t).getBody().error().code()); + Assert.assertEquals("SecretNotFound", ((KeyVaultErrorException) t).body().error().code()); } else throw ex; } @@ -225,7 +225,7 @@ public void certificateAsync() throws Exception { Throwable t = ex.getCause(); if(t instanceof KeyVaultErrorException) { - Assert.assertEquals("CertificateNotFound", ((KeyVaultErrorException) t).getBody().error().code()); + Assert.assertEquals("CertificateNotFound", ((KeyVaultErrorException) t).body().error().code()); } else throw ex; } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java index e752f02f22cec..f186fe4bf73f2 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/CertificateOperationsTest.java @@ -187,8 +187,8 @@ public void createSelfSignedCertificatePkcs12() throws Exception { try { keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + Assert.assertNotNull(e.body().error()); + Assert.assertEquals("CertificateNotFound", e.body().error().code()); } } @@ -240,8 +240,8 @@ public void createSelfSignedCertificatePem() throws Exception { try { keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + Assert.assertNotNull(e.body().error()); + Assert.assertEquals("CertificateNotFound", e.body().error().code()); } } @@ -337,8 +337,8 @@ public void createCertificatePkcs12() throws Exception { try { keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + Assert.assertNotNull(e.body().error()); + Assert.assertEquals("CertificateNotFound", e.body().error().code()); } } @@ -418,8 +418,8 @@ public void createCertificatePem() throws Exception { keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); } catch(KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + Assert.assertNotNull(e.body().error()); + Assert.assertEquals("CertificateNotFound", e.body().error().code()); } } @@ -473,8 +473,8 @@ public void createCsr() throws InterruptedException, ExecutionException, KeyVaul try { keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + Assert.assertNotNull(e.body().error()); + Assert.assertEquals("CertificateNotFound", e.body().error().code()); } } @@ -577,8 +577,8 @@ public void importCertificatePkcs12() throws Exception { try { keyVaultClient.getCertificate(deletedCertificateBundle.certificateIdentifier().baseIdentifier()); } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateNotFound", e.getBody().error().code()); + Assert.assertNotNull(e.body().error()); + Assert.assertEquals("CertificateNotFound", e.body().error().code()); } } @@ -661,7 +661,7 @@ public void listCertificates() throws Exception { break; } catch (KeyVaultErrorException e) { ++failureCount; - if (e.getBody().error().code().equals("Throttled")) { + if (e.body().error().code().equals("Throttled")) { System.out.println("Waiting to avoid throttling"); Thread.sleep(failureCount * 1500); continue; @@ -672,7 +672,7 @@ public void listCertificates() throws Exception { } PagedList listResult = keyVaultClient.listCertificates(getVaultUri(), PAGELIST_MAX_CERTS); - Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); + Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().items().size()); HashSet toDelete = new HashSet(); @@ -722,7 +722,7 @@ public void listCertificateVersions() throws Exception { break; } catch (KeyVaultErrorException e) { ++failureCount; - if (e.getBody().error().code().equals("Throttled")) { + if (e.body().error().code().equals("Throttled")) { System.out.println("Waiting to avoid throttling"); Thread.sleep(failureCount * 1500); continue; @@ -733,7 +733,7 @@ public void listCertificateVersions() throws Exception { } PagedList listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName, PAGELIST_MAX_CERTS); - Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().getItems().size()); + Assert.assertTrue(PAGELIST_MAX_CERTS >= listResult.currentPage().items().size()); listResult = keyVaultClient.listCertificateVersions(getVaultUri(), certificateName); @@ -816,8 +816,8 @@ public void issuerCrudOperations() throws Exception { try { keyVaultClient.getCertificateIssuer(getVaultUri(), certificateIssuerName); } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("CertificateIssuerNotFound", e.getBody().error().code()); + Assert.assertNotNull(e.body().error()); + Assert.assertEquals("CertificateIssuerNotFound", e.body().error().code()); } } @@ -872,8 +872,8 @@ public void contactsCrudOperations() throws Exception { try { keyVaultClient.getCertificateContacts(getVaultUri()); } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("ContactsNotFound", e.getBody().error().code()); + Assert.assertNotNull(e.body().error()); + Assert.assertEquals("ContactsNotFound", e.body().error().code()); } } diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java index 452b6eae13bcf..e2613dfb99b4b 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/KeyOperationsTest.java @@ -270,8 +270,8 @@ public void crudOperations() throws Exception { try { keyVaultClient.getKey(keyId.baseIdentifier()); } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error()); - Assert.assertEquals("KeyNotFound", e.getBody().error().code()); + Assert.assertNotNull(e.body().error()); + Assert.assertEquals("KeyNotFound", e.body().error().code()); } } @@ -323,7 +323,7 @@ public void listKeys() throws Exception { break; } catch (KeyVaultErrorException e) { ++failureCount; - if (e.getBody().error().code().equals("Throttled")) { + if (e.body().error().code().equals("Throttled")) { System.out.println("Waiting to avoid throttling"); Thread.sleep(failureCount * 1500); continue; @@ -334,7 +334,7 @@ public void listKeys() throws Exception { } PagedList listResult = keyVaultClient.listKeys(getVaultUri(), PAGELIST_MAX_KEYS); - Assert.assertTrue(PAGELIST_MAX_KEYS >= listResult.currentPage().getItems().size()); + Assert.assertTrue(PAGELIST_MAX_KEYS >= listResult.currentPage().items().size()); HashSet toDelete = new HashSet(); @@ -354,7 +354,7 @@ public void listKeys() throws Exception { } catch(KeyVaultErrorException e){ // Ignore forbidden exception for certificate keys that cannot be deleted - if(!e.getBody().error().code().equals("Forbidden")) + if(!e.body().error().code().equals("Forbidden")) throw e; } } @@ -373,7 +373,7 @@ public void listKeyVersions() throws Exception { break; } catch (KeyVaultErrorException e) { ++failureCount; - if (e.getBody().error().code().equals("Throttled")) { + if (e.body().error().code().equals("Throttled")) { System.out.println("Waiting to avoid throttling"); Thread.sleep(failureCount * 1500); continue; diff --git a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java index d975af90a3966..4ac85a20ba773 100755 --- a/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java +++ b/azure-keyvault/src/test/java/com/microsoft/azure/keyvault/test/SecretOperationsTest.java @@ -24,7 +24,6 @@ import com.microsoft.azure.keyvault.models.SecretItem; import com.microsoft.azure.keyvault.requests.SetSecretRequest; import com.microsoft.azure.keyvault.requests.UpdateSecretRequest; -import com.microsoft.azure.serializer.AzureJacksonMapperAdapter; public class SecretOperationsTest extends KeyVaultClientIntegrationTestBase { @@ -68,9 +67,8 @@ public void transparentAuthentication() throws Exception { @Test public void deserializeWithExtraFieldTest() throws Exception { - AzureJacksonMapperAdapter mapperAdapter = new AzureJacksonMapperAdapter(); - ObjectMapper mapper = mapperAdapter.getObjectMapper(); - KeyVaultError error = mapper.readValue("{\"error\":{\"code\":\"SecretNotFound\",\"message\":\"Secret not found: javaSecret\",\"noneexisting\":true}}", KeyVaultError.class); + String content = "{\"error\":{\"code\":\"SecretNotFound\",\"message\":\"Secret not found: javaSecret\",\"noneexisting\":true}}"; + KeyVaultError error = keyVaultClient.serializerAdapter().deserialize(content, KeyVaultError.class); Assert.assertEquals(error.error().message(), "Secret not found: javaSecret"); Assert.assertEquals(error.error().code(), "SecretNotFound"); } @@ -90,10 +88,10 @@ public void disabledSecretGet() throws Exception { Assert.fail("Should throw exception for disabled secret."); } catch (KeyVaultErrorException e) { - Assert.assertEquals(e.getBody().error().code(), "Forbidden"); - Assert.assertNotNull(e.getBody().error().message()); - Assert.assertNotNull(e.getBody().error().innerError()); - Assert.assertEquals(e.getBody().error().innerError().code(), "SecretDisabled"); + Assert.assertEquals(e.body().error().code(), "Forbidden"); + Assert.assertNotNull(e.body().error().message()); + Assert.assertNotNull(e.body().error().innerError()); + Assert.assertEquals(e.body().error().innerError().code(), "SecretDisabled"); } catch (Exception e) { Assert.fail("Should throw KeyVaultErrorException for disabled secret."); @@ -204,8 +202,8 @@ public void crudOperations() throws Exception { try { keyVaultClient.getSecret(secretId.baseIdentifier()); } catch (KeyVaultErrorException e) { - Assert.assertNotNull(e.getBody().error().code()); - Assert.assertEquals("SecretNotFound", e.getBody().error().code()); + Assert.assertNotNull(e.body().error().code()); + Assert.assertEquals("SecretNotFound", e.body().error().code()); } } @@ -225,7 +223,7 @@ public void listSecrets() throws Exception { break; } catch (KeyVaultErrorException e) { ++failureCount; - if (e.getBody().error().code().equals("Throttled")) { + if (e.body().error().code().equals("Throttled")) { System.out.println("Waiting to avoid throttling"); Thread.sleep(failureCount * 1500); continue; @@ -236,7 +234,7 @@ public void listSecrets() throws Exception { } PagedList listResult = keyVaultClient.listSecrets(getVaultUri(), PAGELIST_MAX_SECRETS); - Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().getItems().size()); + Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().items().size()); HashSet toDelete = new HashSet(); @@ -256,7 +254,7 @@ public void listSecrets() throws Exception { } catch(KeyVaultErrorException e){ // Ignore forbidden exception for certificate secrets that cannot be deleted - if(!e.getBody().error().code().equals("Forbidden")) + if(!e.body().error().code().equals("Forbidden")) throw e; } } @@ -276,7 +274,7 @@ public void listSecretVersions() throws Exception { break; } catch (KeyVaultErrorException e) { ++failureCount; - if (e.getBody().error().code().equals("Throttled")) { + if (e.body().error().code().equals("Throttled")) { System.out.println("Throttled!"); Thread.sleep(failureCount * 1500); continue; @@ -287,7 +285,7 @@ public void listSecretVersions() throws Exception { } PagedList listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME, PAGELIST_MAX_SECRETS); - Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().getItems().size()); + Assert.assertTrue(PAGELIST_MAX_SECRETS >= listResult.currentPage().items().size()); listResult = keyVaultClient.listSecretVersions(getVaultUri(), SECRET_NAME); for (SecretItem item : listResult) { From 4adc1ac09d193f58a8b45f1efc53835c7d966180 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Tue, 14 Feb 2017 01:14:27 -0800 Subject: [PATCH 53/56] [#1322] Upgrade guava to 20.0 --- azure-keyvault-core/pom.xml | 2 +- azure-keyvault-extensions/pom.xml | 2 +- azure-keyvault-webkey/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index 9cd682f935a51..71a25c5008440 100755 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -98,7 +98,7 @@ com.google.guava guava - 18.0 + 20.0 diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index 2761eef2ef9f1..fdd10a9b7f2af 100755 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -99,7 +99,7 @@ com.google.guava guava - 18.0 + 20.0 diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml index e1b26fd426a20..e058fbabf99df 100644 --- a/azure-keyvault-webkey/pom.xml +++ b/azure-keyvault-webkey/pom.xml @@ -58,7 +58,7 @@ com.google.guava guava - 18.0 + 20.0 From bb27d8a077826c5aa368e000d47f94e093edea74 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Wed, 15 Feb 2017 01:36:44 -0800 Subject: [PATCH 54/56] Rename ServiceCall to ServiceFuture --- .../azure/keyvault/KeyVaultClient.java | 231 +++++----- .../azure/keyvault/KeyVaultClientImpl.java | 420 +++++++++--------- 2 files changed, 324 insertions(+), 327 deletions(-) diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java index 3098de2322dc2..0d6f8c287997d 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClient.java @@ -6,11 +6,9 @@ package com.microsoft.azure.keyvault; -import java.io.IOException; import java.util.List; import com.google.common.base.Joiner; -import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureClient; import com.microsoft.azure.ListOperationCallback; import com.microsoft.azure.PagedList; @@ -25,7 +23,6 @@ import com.microsoft.azure.keyvault.models.KeyBundle; import com.microsoft.azure.keyvault.models.KeyItem; import com.microsoft.azure.keyvault.models.KeyOperationResult; -import com.microsoft.azure.keyvault.models.KeyVaultErrorException; import com.microsoft.azure.keyvault.models.KeyVerifyResult; import com.microsoft.azure.keyvault.models.SecretBundle; import com.microsoft.azure.keyvault.models.SecretItem; @@ -45,7 +42,7 @@ import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; import com.microsoft.azure.keyvault.webkey.JsonWebKeySignatureAlgorithm; import com.microsoft.rest.RestClient; -import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceFuture; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.credentials.ServiceClientCredentials; @@ -239,9 +236,9 @@ public KeyBundle createKey(CreateKeyRequest createKeyRequest) { * @param createKeyRequest the grouped properties for creating a key request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall createKeyAsync(CreateKeyRequest createKeyRequest, ServiceCallback serviceCallback) { + public ServiceFuture createKeyAsync(CreateKeyRequest createKeyRequest, ServiceCallback serviceCallback) { return innerKeyVaultClient.createKeyAsync( createKeyRequest.vaultBaseUrl(), createKeyRequest.keyName(), @@ -276,9 +273,9 @@ public KeyBundle importKey(ImportKeyRequest importKeyRequest) { * @param importKeyRequest the grouped properties for importing a key request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall importKeyAsync(ImportKeyRequest importKeyRequest, final ServiceCallback serviceCallback) { + public ServiceFuture importKeyAsync(ImportKeyRequest importKeyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.importKeyAsync( importKeyRequest.vaultBaseUrl(), importKeyRequest.keyName(), @@ -306,9 +303,9 @@ public KeyBundle deleteKey(String vaultBaseUrl, String keyName) { * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { + public ServiceFuture deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteKeyAsync(vaultBaseUrl, keyName, serviceCallback); } @@ -335,9 +332,9 @@ public KeyBundle updateKey(UpdateKeyRequest updateKeyRequest) { * @param updateKeyRequest the grouped properties for updating a key request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateKeyAsync(UpdateKeyRequest updateKeyRequest, final ServiceCallback serviceCallback) { + public ServiceFuture updateKeyAsync(UpdateKeyRequest updateKeyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateKeyAsync( updateKeyRequest.vaultBaseUrl(), updateKeyRequest.keyName(), @@ -365,9 +362,9 @@ public KeyBundle getKey(String keyIdentifier) { * * @param keyIdentifier The full key identifier * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getKeyAsync(String keyIdentifier, final ServiceCallback serviceCallback) { + public ServiceFuture getKeyAsync(String keyIdentifier, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.getKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); } @@ -389,9 +386,9 @@ public KeyBundle getKey(String vaultBaseUrl, String keyName) { * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { + public ServiceFuture getKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getKeyAsync(vaultBaseUrl, keyName, "", serviceCallback); } @@ -415,9 +412,9 @@ public KeyBundle getKey(String vaultBaseUrl, String keyName, String keyVersion) * @param keyName The name of the key * @param keyVersion The version of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { + public ServiceFuture getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getKeyAsync(vaultBaseUrl, keyName, keyVersion, serviceCallback); } @@ -439,9 +436,9 @@ public PagedList listKeyVersions(final String vaultBaseUrl, final Strin * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { + public ServiceFuture> listKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, serviceCallback); } /** @@ -464,9 +461,9 @@ public PagedList listKeyVersions(final String vaultBaseUrl, final Strin * @param keyName The name of the key * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceFuture> listKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeyVersionsAsync(vaultBaseUrl, keyName, maxresults, serviceCallback); } @@ -486,9 +483,9 @@ public PagedList listKeys(final String vaultBaseUrl) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + public ServiceFuture> listKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, serviceCallback); } /** @@ -509,9 +506,9 @@ public PagedList listKeys(final String vaultBaseUrl, final Integer maxr * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceFuture> listKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getKeysAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -533,9 +530,9 @@ public BackupKeyResult backupKey(String vaultBaseUrl, String keyName) { * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyName The name of the key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { + public ServiceFuture backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.backupKeyAsync(vaultBaseUrl, keyName, serviceCallback); } @@ -557,9 +554,9 @@ public KeyBundle restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) { * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param keyBundleBackup the backup blob associated with a key bundle * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { + public ServiceFuture restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { return innerKeyVaultClient.restoreKeyAsync(vaultBaseUrl, keyBundleBackup, serviceCallback); } @@ -584,9 +581,9 @@ public KeyOperationResult encrypt(String keyIdentifier, JsonWebKeyEncryptionAlgo * @param algorithm algorithm identifier * @param value the content to be encrypted * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall encryptAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceFuture encryptAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.encryptAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -612,9 +609,9 @@ public KeyOperationResult decrypt(String keyIdentifier, JsonWebKeyEncryptionAlgo * @param algorithm algorithm identifier * @param value the content to be decrypted * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall decryptAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceFuture decryptAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.decryptAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -640,9 +637,9 @@ public KeyOperationResult sign(String keyIdentifier, JsonWebKeySignatureAlgorith * @param algorithm algorithm identifier * @param value the content to be signed * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall signAsync(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceFuture signAsync(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.signAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -670,9 +667,9 @@ public KeyVerifyResult verify(String keyIdentifier, JsonWebKeySignatureAlgorithm * @param digest The digest used for signing * @param signature The signature to be verified * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall verifyAsync(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { + public ServiceFuture verifyAsync(String keyIdentifier, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.verifyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, digest, signature, serviceCallback); } @@ -698,9 +695,9 @@ public KeyOperationResult wrapKey(String keyIdentifier, JsonWebKeyEncryptionAlgo * @param algorithm algorithm identifier * @param value the key to be wrapped * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall wrapKeyAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceFuture wrapKeyAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.wrapKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -726,9 +723,9 @@ public KeyOperationResult unwrapKey(String keyIdentifier, JsonWebKeyEncryptionAl * @param algorithm algorithm identifier * @param value the key to be unwrapped * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall unwrapKeyAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + public ServiceFuture unwrapKeyAsync(String keyIdentifier, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { KeyIdentifier id = new KeyIdentifier(keyIdentifier); return innerKeyVaultClient.unwrapKeyAsync(id.vault, id.name, id.version == null ? "" : id.version, algorithm, value, serviceCallback); } @@ -756,9 +753,9 @@ public SecretBundle setSecret(SetSecretRequest setSecretRequest) { * @param setSecretRequest the grouped properties for setting a secret request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall setSecretAsync(SetSecretRequest setSecretRequest, final ServiceCallback serviceCallback) { + public ServiceFuture setSecretAsync(SetSecretRequest setSecretRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.setSecretAsync( setSecretRequest.vaultBaseUrl(), setSecretRequest.secretName(), @@ -787,9 +784,9 @@ public SecretBundle deleteSecret(String vaultBaseUrl, String secretName) { * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { + public ServiceFuture deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteSecretAsync(vaultBaseUrl, secretName, serviceCallback); } @@ -816,9 +813,9 @@ public SecretBundle updateSecret(UpdateSecretRequest updateSecretRequest) { * @param updateSecretRequest the grouped properties for updating a secret request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateSecretAsync(UpdateSecretRequest updateSecretRequest, final ServiceCallback serviceCallback) { + public ServiceFuture updateSecretAsync(UpdateSecretRequest updateSecretRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateSecretAsync( updateSecretRequest.vaultBaseUrl(), updateSecretRequest.secretName(), @@ -846,9 +843,9 @@ public SecretBundle getSecret(String secretIdentifier) { * * @param secretIdentifier The URL for the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getSecretAsync(String secretIdentifier, final ServiceCallback serviceCallback) { + public ServiceFuture getSecretAsync(String secretIdentifier, final ServiceCallback serviceCallback) { SecretIdentifier id = new SecretIdentifier(secretIdentifier); return innerKeyVaultClient.getSecretAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); } @@ -871,9 +868,9 @@ public SecretBundle getSecret(String vaultBaseUrl, String secretName) { * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { + public ServiceFuture getSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getSecretAsync(vaultBaseUrl, secretName, "", serviceCallback); } @@ -897,9 +894,9 @@ public SecretBundle getSecret(String vaultBaseUrl, String secretName, String sec * @param secretName The name of the secret in the given vault * @param secretVersion The version of the secret * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { + public ServiceFuture getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getSecretAsync(vaultBaseUrl, secretName, secretVersion == null ? "" : secretVersion, serviceCallback); } @@ -919,9 +916,9 @@ public PagedList listSecrets(final String vaultBaseUrl) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + public ServiceFuture> listSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, serviceCallback); } /** @@ -942,9 +939,9 @@ public PagedList listSecrets(final String vaultBaseUrl, final Intege * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceFuture> listSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretsAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -966,9 +963,9 @@ public PagedList listSecretVersions(final String vaultBaseUrl, final * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param secretName The name of the secret in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { + public ServiceFuture> listSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, serviceCallback); } /** @@ -991,9 +988,9 @@ public PagedList listSecretVersions(final String vaultBaseUrl, final * @param secretName The name of the secret in the given vault * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceFuture> listSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getSecretVersionsAsync(vaultBaseUrl, secretName, maxresults, serviceCallback); } @@ -1013,9 +1010,9 @@ public PagedList listCertificates(final String vaultBaseUrl) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + public ServiceFuture> listCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, serviceCallback); } /** @@ -1036,9 +1033,9 @@ public PagedList listCertificates(final String vaultBaseUrl, fi * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceFuture> listCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificatesAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -1060,9 +1057,9 @@ public CertificateBundle deleteCertificate(String vaultBaseUrl, String certifica * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + public ServiceFuture deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteCertificateAsync(vaultBaseUrl, certificateName, serviceCallback); } @@ -1084,9 +1081,9 @@ public Contacts setCertificateContacts(String vaultBaseUrl, Contacts contacts) { * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param contacts The contacts for the vault certificates. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { + public ServiceFuture setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { return innerKeyVaultClient.setCertificateContactsAsync(vaultBaseUrl, contacts, serviceCallback); } @@ -1106,9 +1103,9 @@ public Contacts getCertificateContacts(String vaultBaseUrl) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { + public ServiceFuture getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificateContactsAsync(vaultBaseUrl, serviceCallback); } @@ -1128,9 +1125,9 @@ public Contacts deleteCertificateContacts(String vaultBaseUrl) { * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { + public ServiceFuture deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteCertificateContactsAsync(vaultBaseUrl, serviceCallback); } @@ -1150,9 +1147,9 @@ public PagedList listCertificateIssuers(final String vaul * * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + public ServiceFuture> listCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, serviceCallback); } /** @@ -1173,9 +1170,9 @@ public PagedList listCertificateIssuers(final String vaul * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceFuture> listCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateIssuersAsync(vaultBaseUrl, maxresults, serviceCallback); } @@ -1202,9 +1199,9 @@ public IssuerBundle setCertificateIssuer(SetCertificateIssuerRequest setCertific * @param setCertificateIssuerRequest the grouped properties for setting a certificate issuer request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall setCertificateIssuerAsync(SetCertificateIssuerRequest setCertificateIssuerRequest, final ServiceCallback serviceCallback) { + public ServiceFuture setCertificateIssuerAsync(SetCertificateIssuerRequest setCertificateIssuerRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.setCertificateIssuerAsync( setCertificateIssuerRequest.vaultBaseUrl(), setCertificateIssuerRequest.issuerName(), @@ -1239,9 +1236,9 @@ public IssuerBundle updateCertificateIssuer(UpdateCertificateIssuerRequest updat * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @throws IllegalArgumentException thrown if callback is null - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateCertificateIssuerAsync(UpdateCertificateIssuerRequest updateCertificateIssuerRequest, final ServiceCallback serviceCallback) { + public ServiceFuture updateCertificateIssuerAsync(UpdateCertificateIssuerRequest updateCertificateIssuerRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateIssuerAsync( updateCertificateIssuerRequest.vaultBaseUrl(), updateCertificateIssuerRequest.issuerName(), @@ -1270,9 +1267,9 @@ public IssuerBundle getCertificateIssuer(String vaultBaseUrl, String issuerName) * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + public ServiceFuture getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); } @@ -1294,9 +1291,9 @@ public IssuerBundle deleteCertificateIssuer(String vaultBaseUrl, String issuerNa * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + public ServiceFuture deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteCertificateIssuerAsync(vaultBaseUrl, issuerName, serviceCallback); } @@ -1322,9 +1319,9 @@ public CertificateOperation createCertificate(CreateCertificateRequest createCer * @param createCertificateRequest the grouped properties for creating a certificate request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall createCertificateAsync(CreateCertificateRequest createCertificateRequest, final ServiceCallback serviceCallback) { + public ServiceFuture createCertificateAsync(CreateCertificateRequest createCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.createCertificateAsync( createCertificateRequest.vaultBaseUrl(), createCertificateRequest.certificateName(), @@ -1358,9 +1355,9 @@ public CertificateBundle importCertificate(ImportCertificateRequest importCertif * @param importCertificateRequest the grouped properties for importing a certificate request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall importCertificateAsync(ImportCertificateRequest importCertificateRequest, final ServiceCallback serviceCallback) { + public ServiceFuture importCertificateAsync(ImportCertificateRequest importCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.importCertificateAsync( importCertificateRequest.vaultBaseUrl(), importCertificateRequest.certificateName(), @@ -1390,9 +1387,9 @@ public PagedList listCertificateVersions(final String vaultBase * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { + public ServiceFuture> listCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, serviceCallback); } /** @@ -1415,9 +1412,9 @@ public PagedList listCertificateVersions(final String vaultBase * @param certificateName The name of the certificate * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> listCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { + public ServiceFuture> listCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { return innerKeyVaultClient.getCertificateVersionsAsync(vaultBaseUrl, certificateName, maxresults, serviceCallback); } @@ -1439,9 +1436,9 @@ public CertificatePolicy getCertificatePolicy(String vaultBaseUrl, String certif * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + public ServiceFuture getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificatePolicyAsync(vaultBaseUrl, certificateName, serviceCallback); } @@ -1465,9 +1462,9 @@ public CertificatePolicy updateCertificatePolicy(UpdateCertificatePolicyRequest * @param updateCertificatePolicyRequest the grouped properties for updating a certificate policy request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateCertificatePolicyAsync(UpdateCertificatePolicyRequest updateCertificatePolicyRequest, final ServiceCallback serviceCallback) { + public ServiceFuture updateCertificatePolicyAsync(UpdateCertificatePolicyRequest updateCertificatePolicyRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificatePolicyAsync( updateCertificatePolicyRequest.vaultBaseUrl(), updateCertificatePolicyRequest.certificateName(), @@ -1498,9 +1495,9 @@ public CertificateBundle updateCertificate(UpdateCertificateRequest updateCertif * @param updateCertificateRequest the grouped properties for updating a certificate request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateCertificateAsync(UpdateCertificateRequest updateCertificateRequest, final ServiceCallback serviceCallback) { + public ServiceFuture updateCertificateAsync(UpdateCertificateRequest updateCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateAsync( updateCertificateRequest.vaultBaseUrl(), updateCertificateRequest.certificateName(), @@ -1528,9 +1525,9 @@ public CertificateBundle getCertificate(String certificateIdentifier) { * * @param certificateIdentifier The certificate identifier * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getCertificateAsync(String certificateIdentifier, final ServiceCallback serviceCallback) { + public ServiceFuture getCertificateAsync(String certificateIdentifier, final ServiceCallback serviceCallback) { CertificateIdentifier id = new CertificateIdentifier(certificateIdentifier); return innerKeyVaultClient.getCertificateAsync(id.vault, id.name, id.version == null ? "" : id.version, serviceCallback); } @@ -1553,9 +1550,9 @@ public CertificateBundle getCertificate(String vaultBaseUrl, String certificateN * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate in the given vault * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + public ServiceFuture getCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificateAsync(vaultBaseUrl, certificateName, "", serviceCallback); } @@ -1579,9 +1576,9 @@ public CertificateBundle getCertificate(String vaultBaseUrl, String certificateN * @param certificateName The name of the certificate in the given vault * @param certificateVersion The version of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { + public ServiceFuture getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificateAsync(vaultBaseUrl, certificateName, certificateVersion, serviceCallback); } @@ -1605,9 +1602,9 @@ public CertificateOperation updateCertificateOperation(UpdateCertificateOperatio * @param updateCertificateOperationRequest the grouped properties for updating a certificate operation request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateCertificateOperationAsync(UpdateCertificateOperationRequest updateCertificateOperationRequest, final ServiceCallback serviceCallback) { + public ServiceFuture updateCertificateOperationAsync(UpdateCertificateOperationRequest updateCertificateOperationRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.updateCertificateOperationAsync( updateCertificateOperationRequest.vaultBaseUrl(), updateCertificateOperationRequest.certificateName(), @@ -1633,9 +1630,9 @@ public CertificateOperation getCertificateOperation(String vaultBaseUrl, String * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + public ServiceFuture getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.getCertificateOperationAsync(vaultBaseUrl, certificateName, serviceCallback); } @@ -1657,9 +1654,9 @@ public CertificateOperation deleteCertificateOperation(String vaultBaseUrl, Stri * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + public ServiceFuture deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { return innerKeyVaultClient.deleteCertificateOperationAsync(vaultBaseUrl, certificateName, serviceCallback); } @@ -1685,9 +1682,9 @@ public CertificateBundle mergeCertificate(MergeCertificateRequest mergeCertifica * @param mergeCertificateRequest the grouped properties for merging a certificate request * * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall mergeCertificateAsync(MergeCertificateRequest mergeCertificateRequest, final ServiceCallback serviceCallback) { + public ServiceFuture mergeCertificateAsync(MergeCertificateRequest mergeCertificateRequest, final ServiceCallback serviceCallback) { return innerKeyVaultClient.mergeCertificateAsync( mergeCertificateRequest.vaultBaseUrl(), mergeCertificateRequest.certificateName(), @@ -1716,10 +1713,10 @@ public String getPendingCertificateSigningRequest(String vaultBaseUrl, String ce * @param vaultBaseUrl The vault name, e.g. https://myvault.vault.azure.net * @param certificateName The name of the certificate * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(getPendingCertificateSigningRequestWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + public ServiceFuture getPendingCertificateSigningRequestAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getPendingCertificateSigningRequestWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** diff --git a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java index a9ac3d905dbc9..e2d082710b890 100755 --- a/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java +++ b/azure-keyvault/src/main/java/com/microsoft/azure/keyvault/KeyVaultClientImpl.java @@ -13,7 +13,7 @@ import com.google.common.base.Joiner; import com.google.common.reflect.TypeToken; import com.microsoft.azure.AzureClient; -import com.microsoft.azure.AzureServiceCall; +import com.microsoft.azure.AzureServiceFuture; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.keyvault.models.BackupKeyResult; import com.microsoft.azure.keyvault.models.CertificateAttributes; @@ -63,7 +63,7 @@ import com.microsoft.azure.PagedList; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.RestClient; -import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceFuture; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.Validator; @@ -461,10 +461,10 @@ public KeyBundle createKey(String vaultBaseUrl, String keyName, JsonWebKeyType k * @param keyName The name for the new key. The system will generate the version name for the new key. * @param kty The type of key to create. For valid key types, see JsonWebKeyType. Supported JsonWebKey key types (kty) for Elliptic Curve, RSA, HSM, Octet. Possible values include: 'EC', 'RSA', 'RSA-HSM', 'oct' * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty), serviceCallback); + public ServiceFuture createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty), serviceCallback); } /** @@ -557,10 +557,10 @@ public KeyBundle createKey(String vaultBaseUrl, String keyName, JsonWebKeyType k * @param keyAttributes the KeyAttributes value * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags), serviceCallback); + public ServiceFuture createKeyAsync(String vaultBaseUrl, String keyName, JsonWebKeyType kty, Integer keySize, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createKeyWithServiceResponseAsync(vaultBaseUrl, keyName, kty, keySize, keyOps, keyAttributes, tags), serviceCallback); } /** @@ -659,10 +659,10 @@ public KeyBundle importKey(String vaultBaseUrl, String keyName, JsonWebKey key) * @param keyName Name for the imported key. * @param key The Json web key * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key), serviceCallback); + public ServiceFuture importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key), serviceCallback); } /** @@ -752,10 +752,10 @@ public KeyBundle importKey(String vaultBaseUrl, String keyName, JsonWebKey key, * @param keyAttributes The key management attributes. * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags), serviceCallback); + public ServiceFuture importKeyAsync(String vaultBaseUrl, String keyName, JsonWebKey key, Boolean hsm, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(importKeyWithServiceResponseAsync(vaultBaseUrl, keyName, key, hsm, keyAttributes, tags), serviceCallback); } /** @@ -849,10 +849,10 @@ public KeyBundle deleteKey(String vaultBaseUrl, String keyName) { * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param keyName The name of the key to delete. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback); + public ServiceFuture deleteKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback); } /** @@ -929,10 +929,10 @@ public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersio * @param keyName The name of key to update. * @param keyVersion The version of the key to update. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + public ServiceFuture updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); } /** @@ -1020,10 +1020,10 @@ public KeyBundle updateKey(String vaultBaseUrl, String keyName, String keyVersio * @param keyAttributes the KeyAttributes value * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags), serviceCallback); + public ServiceFuture updateKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, List keyOps, KeyAttributes keyAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, keyOps, keyAttributes, tags), serviceCallback); } /** @@ -1118,10 +1118,10 @@ public KeyBundle getKey(String vaultBaseUrl, String keyName, String keyVersion) * @param keyName The name of the key to get. * @param keyVersion Adding the version parameter retrieves a specific version of a key. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); + public ServiceFuture getKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion), serviceCallback); } /** @@ -1207,10 +1207,10 @@ public Page nextPage(String nextPageLink) { * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param keyName The name of the key. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName), new Func1>>>() { @Override @@ -1317,10 +1317,10 @@ public Page nextPage(String nextPageLink) { * @param keyName The name of the key. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getKeyVersionsAsync(final String vaultBaseUrl, final String keyName, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getKeyVersionsSinglePageAsync(vaultBaseUrl, keyName, maxresults), new Func1>>>() { @Override @@ -1432,10 +1432,10 @@ public Page nextPage(String nextPageLink) { * * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getKeysAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getKeysSinglePageAsync(vaultBaseUrl), new Func1>>>() { @Override @@ -1534,10 +1534,10 @@ public Page nextPage(String nextPageLink) { * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getKeysAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getKeysSinglePageAsync(vaultBaseUrl, maxresults), new Func1>>>() { @Override @@ -1639,10 +1639,10 @@ public BackupKeyResult backupKey(String vaultBaseUrl, String keyName) { * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param keyName The name of the key. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(backupKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback); + public ServiceFuture backupKeyAsync(String vaultBaseUrl, String keyName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(backupKeyWithServiceResponseAsync(vaultBaseUrl, keyName), serviceCallback); } /** @@ -1717,10 +1717,10 @@ public KeyBundle restoreKey(String vaultBaseUrl, byte[] keyBundleBackup) { * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param keyBundleBackup The backup blob associated with a key bundle. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup), serviceCallback); + public ServiceFuture restoreKeyAsync(String vaultBaseUrl, byte[] keyBundleBackup, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(restoreKeyWithServiceResponseAsync(vaultBaseUrl, keyBundleBackup), serviceCallback); } /** @@ -1803,10 +1803,10 @@ public KeyOperationResult encrypt(String vaultBaseUrl, String keyName, String ke * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + public ServiceFuture encryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(encryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -1905,10 +1905,10 @@ public KeyOperationResult decrypt(String vaultBaseUrl, String keyName, String ke * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(decryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + public ServiceFuture decryptAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(decryptWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -2007,10 +2007,10 @@ public KeyOperationResult sign(String vaultBaseUrl, String keyName, String keyVe * @param algorithm The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. Possible values include: 'RS256', 'RS384', 'RS512', 'RSNULL' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + public ServiceFuture signAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(signWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -2111,10 +2111,10 @@ public KeyVerifyResult verify(String vaultBaseUrl, String keyName, String keyVer * @param digest The digest used for signing. * @param signature The signature to be verified. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature), serviceCallback); + public ServiceFuture verifyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeySignatureAlgorithm algorithm, byte[] digest, byte[] signature, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(verifyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, digest, signature), serviceCallback); } /** @@ -2219,10 +2219,10 @@ public KeyOperationResult wrapKey(String vaultBaseUrl, String keyName, String ke * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + public ServiceFuture wrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(wrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -2321,10 +2321,10 @@ public KeyOperationResult unwrapKey(String vaultBaseUrl, String keyName, String * @param algorithm algorithm identifier. Possible values include: 'RSA-OAEP', 'RSA1_5' * @param value the Base64Url value * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); + public ServiceFuture unwrapKeyAsync(String vaultBaseUrl, String keyName, String keyVersion, JsonWebKeyEncryptionAlgorithm algorithm, byte[] value, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(unwrapKeyWithServiceResponseAsync(vaultBaseUrl, keyName, keyVersion, algorithm, value), serviceCallback); } /** @@ -2419,10 +2419,10 @@ public SecretBundle setSecret(String vaultBaseUrl, String secretName, String val * @param secretName The name of the secret. * @param value The value of the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value), serviceCallback); + public ServiceFuture setSecretAsync(String vaultBaseUrl, String secretName, String value, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value), serviceCallback); } /** @@ -2511,10 +2511,10 @@ public SecretBundle setSecret(String vaultBaseUrl, String secretName, String val * @param contentType Type of the secret value such as a password. * @param secretAttributes The secret management attributes. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes), serviceCallback); + public ServiceFuture setSecretAsync(String vaultBaseUrl, String secretName, String value, Map tags, String contentType, SecretAttributes secretAttributes, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(setSecretWithServiceResponseAsync(vaultBaseUrl, secretName, value, tags, contentType, secretAttributes), serviceCallback); } /** @@ -2607,10 +2607,10 @@ public SecretBundle deleteSecret(String vaultBaseUrl, String secretName) { * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param secretName The name of the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName), serviceCallback); + public ServiceFuture deleteSecretAsync(String vaultBaseUrl, String secretName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteSecretWithServiceResponseAsync(vaultBaseUrl, secretName), serviceCallback); } /** @@ -2687,10 +2687,10 @@ public SecretBundle updateSecret(String vaultBaseUrl, String secretName, String * @param secretName The name of the secret. * @param secretVersion The version of the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + public ServiceFuture updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); } /** @@ -2778,10 +2778,10 @@ public SecretBundle updateSecret(String vaultBaseUrl, String secretName, String * @param secretAttributes The secret management attributes. * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags), serviceCallback); + public ServiceFuture updateSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, String contentType, SecretAttributes secretAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion, contentType, secretAttributes, tags), serviceCallback); } /** @@ -2875,10 +2875,10 @@ public SecretBundle getSecret(String vaultBaseUrl, String secretName, String sec * @param secretName The name of the secret. * @param secretVersion The version of the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); + public ServiceFuture getSecretAsync(String vaultBaseUrl, String secretName, String secretVersion, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getSecretWithServiceResponseAsync(vaultBaseUrl, secretName, secretVersion), serviceCallback); } /** @@ -2962,10 +2962,10 @@ public Page nextPage(String nextPageLink) { * * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getSecretsAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getSecretsSinglePageAsync(vaultBaseUrl), new Func1>>>() { @Override @@ -3064,10 +3064,10 @@ public Page nextPage(String nextPageLink) { * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getSecretsAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getSecretsSinglePageAsync(vaultBaseUrl, maxresults), new Func1>>>() { @Override @@ -3175,10 +3175,10 @@ public Page nextPage(String nextPageLink) { * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param secretName The name of the secret. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName), new Func1>>>() { @Override @@ -3285,10 +3285,10 @@ public Page nextPage(String nextPageLink) { * @param secretName The name of the secret. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getSecretVersionsAsync(final String vaultBaseUrl, final String secretName, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getSecretVersionsSinglePageAsync(vaultBaseUrl, secretName, maxresults), new Func1>>>() { @Override @@ -3400,10 +3400,10 @@ public Page nextPage(String nextPageLink) { * * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getCertificatesAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getCertificatesSinglePageAsync(vaultBaseUrl), new Func1>>>() { @Override @@ -3502,10 +3502,10 @@ public Page nextPage(String nextPageLink) { * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getCertificatesAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getCertificatesSinglePageAsync(vaultBaseUrl, maxresults), new Func1>>>() { @Override @@ -3607,10 +3607,10 @@ public CertificateBundle deleteCertificate(String vaultBaseUrl, String certifica * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param certificateName The name of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + public ServiceFuture deleteCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** @@ -3685,10 +3685,10 @@ public Contacts setCertificateContacts(String vaultBaseUrl, Contacts contacts) { * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param contacts The contacts for the key vault certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts), serviceCallback); + public ServiceFuture setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(setCertificateContactsWithServiceResponseAsync(vaultBaseUrl, contacts), serviceCallback); } /** @@ -3762,10 +3762,10 @@ public Contacts getCertificateContacts(String vaultBaseUrl) { * * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(getCertificateContactsWithServiceResponseAsync(vaultBaseUrl), serviceCallback); + public ServiceFuture getCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getCertificateContactsWithServiceResponseAsync(vaultBaseUrl), serviceCallback); } /** @@ -3833,10 +3833,10 @@ public Contacts deleteCertificateContacts(String vaultBaseUrl) { * * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl), serviceCallback); + public ServiceFuture deleteCertificateContactsAsync(String vaultBaseUrl, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteCertificateContactsWithServiceResponseAsync(vaultBaseUrl), serviceCallback); } /** @@ -3910,10 +3910,10 @@ public Page nextPage(String nextPageLink) { * * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getCertificateIssuersAsync(final String vaultBaseUrl, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getCertificateIssuersSinglePageAsync(vaultBaseUrl), new Func1>>>() { @Override @@ -4012,10 +4012,10 @@ public Page nextPage(String nextPageLink) { * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getCertificateIssuersAsync(final String vaultBaseUrl, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults), new Func1>>>() { @Override @@ -4119,10 +4119,10 @@ public IssuerBundle setCertificateIssuer(String vaultBaseUrl, String issuerName, * @param issuerName The name of the issuer. * @param provider The issuer provider. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider), serviceCallback); + public ServiceFuture setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider), serviceCallback); } /** @@ -4211,10 +4211,10 @@ public IssuerBundle setCertificateIssuer(String vaultBaseUrl, String issuerName, * @param organizationDetails Details of the organization as provided to the issuer. * @param attributes Attributes of the issuer object. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + public ServiceFuture setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(setCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); } /** @@ -4308,10 +4308,10 @@ public IssuerBundle updateCertificateIssuer(String vaultBaseUrl, String issuerNa * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); + public ServiceFuture updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); } /** @@ -4396,10 +4396,10 @@ public IssuerBundle updateCertificateIssuer(String vaultBaseUrl, String issuerNa * @param organizationDetails Details of the organization as provided to the issuer. * @param attributes Attributes of the issuer object. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); + public ServiceFuture updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, attributes), serviceCallback); } /** @@ -4490,10 +4490,10 @@ public IssuerBundle getCertificateIssuer(String vaultBaseUrl, String issuerName) * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); + public ServiceFuture getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); } /** @@ -4568,10 +4568,10 @@ public IssuerBundle deleteCertificateIssuer(String vaultBaseUrl, String issuerNa * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param issuerName The name of the issuer. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); + public ServiceFuture deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteCertificateIssuerWithServiceResponseAsync(vaultBaseUrl, issuerName), serviceCallback); } /** @@ -4646,10 +4646,10 @@ public CertificateOperation createCertificate(String vaultBaseUrl, String certif * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param certificateName The name of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + public ServiceFuture createCertificateAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** @@ -4730,10 +4730,10 @@ public CertificateOperation createCertificate(String vaultBaseUrl, String certif * @param certificateAttributes The attributes of the certificate (optional). * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags), serviceCallback); + public ServiceFuture createCertificateAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, tags), serviceCallback); } /** @@ -4823,10 +4823,10 @@ public CertificateBundle importCertificate(String vaultBaseUrl, String certifica * @param certificateName The name of the certificate. * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This certificate needs to contain the private key. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate), serviceCallback); + public ServiceFuture importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate), serviceCallback); } /** @@ -4919,10 +4919,10 @@ public CertificateBundle importCertificate(String vaultBaseUrl, String certifica * @param certificateAttributes The attributes of the certificate (optional). * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags), serviceCallback); + public ServiceFuture importCertificateAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(importCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags), serviceCallback); } /** @@ -5025,10 +5025,10 @@ public Page nextPage(String nextPageLink) { * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param certificateName The name of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName), new Func1>>>() { @Override @@ -5135,10 +5135,10 @@ public Page nextPage(String nextPageLink) { * @param certificateName The name of the certificate. * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to 25 results. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getCertificateVersionsAsync(final String vaultBaseUrl, final String certificateName, final Integer maxresults, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults), new Func1>>>() { @Override @@ -5246,10 +5246,10 @@ public CertificatePolicy getCertificatePolicy(String vaultBaseUrl, String certif * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param certificateName The name of the certificate in a given key vault. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + public ServiceFuture getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** @@ -5326,10 +5326,10 @@ public CertificatePolicy updateCertificatePolicy(String vaultBaseUrl, String cer * @param certificateName The name of the certificate in the given vault. * @param certificatePolicy The policy for the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy), serviceCallback); + public ServiceFuture updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, CertificatePolicy certificatePolicy, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateCertificatePolicyWithServiceResponseAsync(vaultBaseUrl, certificateName, certificatePolicy), serviceCallback); } /** @@ -5412,10 +5412,10 @@ public CertificateBundle updateCertificate(String vaultBaseUrl, String certifica * @param certificateName The name of the certificate in the given key vault. * @param certificateVersion The version of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + public ServiceFuture updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); } /** @@ -5503,10 +5503,10 @@ public CertificateBundle updateCertificate(String vaultBaseUrl, String certifica * @param certificateAttributes The attributes of the certificate (optional). * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags), serviceCallback); + public ServiceFuture updateCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, certificateAttributes, tags), serviceCallback); } /** @@ -5601,10 +5601,10 @@ public CertificateBundle getCertificate(String vaultBaseUrl, String certificateN * @param certificateName The name of the certificate in the given vault. * @param certificateVersion The version of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); + public ServiceFuture getCertificateAsync(String vaultBaseUrl, String certificateName, String certificateVersion, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, certificateVersion), serviceCallback); } /** @@ -5686,10 +5686,10 @@ public CertificateOperation updateCertificateOperation(String vaultBaseUrl, Stri * @param certificateName The name of the certificate. * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(updateCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName, cancellationRequested), serviceCallback); + public ServiceFuture updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, boolean cancellationRequested, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName, cancellationRequested), serviceCallback); } /** @@ -5768,10 +5768,10 @@ public CertificateOperation getCertificateOperation(String vaultBaseUrl, String * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param certificateName The name of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + public ServiceFuture getCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** @@ -5846,10 +5846,10 @@ public CertificateOperation deleteCertificateOperation(String vaultBaseUrl, Stri * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. * @param certificateName The name of the certificate. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); + public ServiceFuture deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteCertificateOperationWithServiceResponseAsync(vaultBaseUrl, certificateName), serviceCallback); } /** @@ -5926,10 +5926,10 @@ public CertificateBundle mergeCertificate(String vaultBaseUrl, String certificat * @param certificateName The name of the certificate. * @param x509Certificates The certificate or the certificate chain to merge. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates), serviceCallback); + public ServiceFuture mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates), serviceCallback); } /** @@ -6015,10 +6015,10 @@ public CertificateBundle mergeCertificate(String vaultBaseUrl, String certificat * @param certificateAttributes The attributes of the certificate (optional). * @param tags Application specific metadata in the form of key-value pairs. * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { - return ServiceCall.fromResponse(mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags), serviceCallback); + public ServiceFuture mergeCertificateAsync(String vaultBaseUrl, String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, Map tags, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(mergeCertificateWithServiceResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, tags), serviceCallback); } /** @@ -6112,12 +6112,12 @@ public Page nextPage(String nextPageLink) { * Retrieves a list of individual key versions with the same key name. The full key identifier, attributes, and tags are provided in the response. Authorization: Requires the keys/list permission. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceFuture the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getKeyVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getKeyVersionsNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getKeyVersionsNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6216,12 +6216,12 @@ public Page nextPage(String nextPageLink) { * List keys in the specified vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceFuture the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getKeysNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getKeysNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getKeysNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6320,12 +6320,12 @@ public Page nextPage(String nextPageLink) { * List secrets in a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceFuture the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getSecretsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getSecretsNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getSecretsNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6424,12 +6424,12 @@ public Page nextPage(String nextPageLink) { * List the versions of the specified secret. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceFuture the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getSecretVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getSecretVersionsNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getSecretVersionsNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6528,12 +6528,12 @@ public Page nextPage(String nextPageLink) { * List certificates in a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceFuture the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getCertificatesNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getCertificatesNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getCertificatesNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6632,12 +6632,12 @@ public Page nextPage(String nextPageLink) { * List certificate issuers for a specified key vault. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceFuture the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getCertificateIssuersNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getCertificateIssuersNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getCertificateIssuersNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override @@ -6736,12 +6736,12 @@ public Page nextPage(String nextPageLink) { * List the versions of a certificate. * * @param nextPageLink The NextLink from the previous successful call to List operation. - * @param serviceCall the ServiceCall object tracking the Retrofit calls + * @param serviceFuture the ServiceCall object tracking the Retrofit calls * @param serviceCallback the async ServiceCallback to handle successful and failed responses. - * @return the {@link ServiceCall} object + * @return the {@link ServiceFuture} object */ - public ServiceCall> getCertificateVersionsNextAsync(final String nextPageLink, final ServiceCall> serviceCall, final ListOperationCallback serviceCallback) { - return AzureServiceCall.fromPageResponse( + public ServiceFuture> getCertificateVersionsNextAsync(final String nextPageLink, final ServiceFuture> serviceFuture, final ListOperationCallback serviceCallback) { + return AzureServiceFuture.fromPageResponse( getCertificateVersionsNextSinglePageAsync(nextPageLink), new Func1>>>() { @Override From 50947018ea020291284765b80c13aadb2a2b3583 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 27 Feb 2017 10:57:46 -0800 Subject: [PATCH 55/56] Add pom files --- .gitignore | 292 +++++--------------------- azure-keyvault-core/pom.xml | 2 +- azure-keyvault-cryptography/pom.xml | 2 +- azure-keyvault-extensions/pom.xml | 2 +- azure-keyvault-webkey/pom.xml | 2 +- azure-keyvault/pom.xml | 2 +- pom.xml | 304 ++++++++++++++++++++++++++++ 7 files changed, 357 insertions(+), 249 deletions(-) create mode 100644 pom.xml diff --git a/.gitignore b/.gitignore index f1e3d20e05685..9d6304e11c8f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,252 +1,56 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. +*.class -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates +#External libs +extlib/ -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs +# Auth files +*.auth +*.azureauth -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ +# Local checkstyle +*.checkstyle -# Visual Studio 2015 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ +# Mobile Tools for Java (J2ME) +.mtj.tmp/ -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* +# Package Files # +*.jar +*.war +*.ear -# NUNIT -*.VisualState.xml -TestResult.xml +# Azure Tooling # +node_modules +packages -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# DNX -project.lock.json -artifacts/ - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh +# Eclipse # +*.pydevproject +.project +.metadata +bin/** +tmp/** +tmp/**/* *.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config -# NuGet v3's project.json files produces more ignoreable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ -orleans.codegen.cs - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# Other Tooling # +.classpath +.project +target +.idea +*.iml + +# Mac OS # +.DS_Store +.DS_Store? + +# Windows # +Thumbs.db + +# reduced pom files should not be included +dependency-reduced-pom.xml \ No newline at end of file diff --git a/azure-keyvault-core/pom.xml b/azure-keyvault-core/pom.xml index 71a25c5008440..1ae87e1b1176f 100755 --- a/azure-keyvault-core/pom.xml +++ b/azure-keyvault-core/pom.xml @@ -7,7 +7,7 @@ 4.0.0 com.microsoft.azure - azure-parent + azure-keyvault-parent 1.0.0-beta6-SNAPSHOT ../pom.xml diff --git a/azure-keyvault-cryptography/pom.xml b/azure-keyvault-cryptography/pom.xml index 2b541491227de..efbdba24c9880 100755 --- a/azure-keyvault-cryptography/pom.xml +++ b/azure-keyvault-cryptography/pom.xml @@ -8,7 +8,7 @@ com.microsoft.azure - azure-parent + azure-keyvault-parent 1.0.0-beta6-SNAPSHOT ../pom.xml diff --git a/azure-keyvault-extensions/pom.xml b/azure-keyvault-extensions/pom.xml index fdd10a9b7f2af..ac865845cfed4 100755 --- a/azure-keyvault-extensions/pom.xml +++ b/azure-keyvault-extensions/pom.xml @@ -7,7 +7,7 @@ 4.0.0 com.microsoft.azure - azure-parent + azure-keyvault-parent 1.0.0-beta6-SNAPSHOT ../pom.xml diff --git a/azure-keyvault-webkey/pom.xml b/azure-keyvault-webkey/pom.xml index e058fbabf99df..f39ebfeff52ac 100644 --- a/azure-keyvault-webkey/pom.xml +++ b/azure-keyvault-webkey/pom.xml @@ -7,7 +7,7 @@ 4.0.0 com.microsoft.azure - azure-parent + azure-keyvault-parent 1.0.0-beta6-SNAPSHOT ../pom.xml diff --git a/azure-keyvault/pom.xml b/azure-keyvault/pom.xml index c9e4c8ed95351..66bad0f465a2a 100755 --- a/azure-keyvault/pom.xml +++ b/azure-keyvault/pom.xml @@ -7,7 +7,7 @@ 4.0.0 com.microsoft.azure - azure-parent + azure-keyvault-parent 1.0.0-beta6-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000..3f7e076f5feeb --- /dev/null +++ b/pom.xml @@ -0,0 +1,304 @@ + + + 4.0.0 + com.microsoft.azure + 1.0.0-beta6-SNAPSHOT + azure-keyvault-parent + pom + + Microsoft Azure Key Vault SDK Parent + This package contains the parent module of Microsoft Azure Key Vault SDK. + https://github.com/Azure/azure-key-vault-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + scm:git:https://github.com/Azure/azure-key-vault-sdk-for-java + scm:git:https://github.com/Azure/azure-sdk-for-java.git + HEAD + + + + UTF-8 + + playback + + + + + microsoft + Microsoft + + + + + + ossrh + Sonatype Snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + default + + true + always + + + + + + + ossrh + Sonatype Snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + default + + true + always + + + + + + + ossrh + Sonatype Snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + true + default + + + + + + + com.fasterxml.jackson.core + jackson-core + 2.7.2 + + + com.fasterxml.jackson.core + jackson-databind + 2.7.2 + + + com.fasterxml.jackson.core + jackson-annotations + 2.7.0 + + + commons-codec + commons-codec + 1.10 + + + io.reactivex + rxjava + 1.2.4 + + + com.microsoft.azure + azure-client-runtime + 1.0.0 + + + com.microsoft.azure + azure-client-authentication + 1.0.0-beta6 + + + com.google.guava + guava + 20.0 + + + + junit + junit + 4.12 + test + + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.17 + + + com.microsoft.azure + autorest-build-tools + 1.0.0-beta6-SNAPSHOT + + + com.puppycrawl.tools + checkstyle + 6.18 + + + + checkstyle.xml + samedir=runtimes/build-tools/src/main/resources + suppressions.xml + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + true + true + -Xlint:unchecked + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.storage + /** +
* Copyright (c) Microsoft Corporation. All rights reserved. +
* Licensed under the MIT License. See License.txt in the project root for +
* license information. +
*/]]>
+
+
+ + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + +
+ + + + org.apache.maven.plugins + maven-resources-plugin + 2.4.3 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + + **/Test*.java + **/*Test.java + **/*Tests.java + **/*TestCase.java + + + ${testMode} + + + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.2 + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + com.googlecode.addjars-maven-plugin + + + addjars-maven-plugin + + [1.0.5,) + + add-jars + + + + + + + + + + + + +
+ + + run-shade-plugin + + runShadePlugin + + + + + org.apache.maven.plugins + maven-shade-plugin + 2.4.1 + + + + + shade-plugin + package + + shade + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + + + + + + + ./azure-keyvault + ./azure-keyvault-core + ./azure-keyvault-cryptography + ./azure-keyvault-extensions + ./azure-keyvault-webkey + +
From f86da5e2d39408b395485838122009d2112f1f88 Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 27 Feb 2017 11:00:59 -0800 Subject: [PATCH 56/56] Add simple travis config --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000000..2cac09f02bfa5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: java +sudo: false +jdk: +- oraclejdk8 +script: +- mvn install -DskipTests=true +- mvn package javadoc:aggregate -DskipTests=true \ No newline at end of file