Search in sources :

Example 16 with CertificateBundle

use of com.microsoft.azure.keyvault.models.CertificateBundle in project azure-sdk-for-java by Azure.

the class KeyVaultClientImpl method mergeCertificateWithServiceResponseAsync.

/**
     * Merges a certificate or a certificate chain with a key pair existing on the server.
     *
     * @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<ServiceResponse<CertificateBundle>> mergeCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, List<byte[]> x509Certificates, CertificateAttributes certificateAttributes, Map<String, String> tags) {
    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);
    return service.mergeCertificate(certificateName, this.apiVersion(), this.acceptLanguage(), parameters, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<CertificateBundle>>>() {

        @Override
        public Observable<ServiceResponse<CertificateBundle>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<CertificateBundle> clientResponse = mergeCertificateDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse) CertificateBundle(com.microsoft.azure.keyvault.models.CertificateBundle) CertificateMergeParameters(com.microsoft.azure.keyvault.models.CertificateMergeParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody)

Aggregations

CertificateBundle (com.microsoft.azure.keyvault.models.CertificateBundle)16 CertificatePolicy (com.microsoft.azure.keyvault.models.CertificatePolicy)12 SecretProperties (com.microsoft.azure.keyvault.models.SecretProperties)10 Test (org.junit.Test)10 KeyVaultErrorException (com.microsoft.azure.keyvault.models.KeyVaultErrorException)9 IssuerParameters (com.microsoft.azure.keyvault.models.IssuerParameters)7 CertificateAttributes (com.microsoft.azure.keyvault.models.CertificateAttributes)6 CertificateOperation (com.microsoft.azure.keyvault.models.CertificateOperation)6 X509CertificateProperties (com.microsoft.azure.keyvault.models.X509CertificateProperties)6 CreateCertificateRequest (com.microsoft.azure.keyvault.requests.CreateCertificateRequest)6 ServiceResponse (com.microsoft.rest.ServiceResponse)6 ResponseBody (okhttp3.ResponseBody)6 Response (retrofit2.Response)6 Observable (rx.Observable)6 SecretIdentifier (com.microsoft.azure.keyvault.SecretIdentifier)3 Attributes (com.microsoft.azure.keyvault.models.Attributes)3 CertificateItem (com.microsoft.azure.keyvault.models.CertificateItem)3 SecretBundle (com.microsoft.azure.keyvault.models.SecretBundle)3 KeyStore (java.security.KeyStore)3 X509Certificate (java.security.cert.X509Certificate)3