Search in sources :

Example 6 with CertificateAttributes

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

the class KeyVaultClientImpl method importCertificateWithServiceResponseAsync.

/**
     * Imports a certificate into a specified key vault.
     *
     * @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
     */
public Observable<ServiceResponse<CertificateBundle>> importCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName, String base64EncodedCertificate) {
    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<String, String> 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);
    return service.importCertificate(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 = importCertificateDelegate(response);
                return Observable.just(clientResponse);
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : CertificateAttributes(com.microsoft.azure.keyvault.models.CertificateAttributes) CertificateBundle(com.microsoft.azure.keyvault.models.CertificateBundle) CertificatePolicy(com.microsoft.azure.keyvault.models.CertificatePolicy) CertificateImportParameters(com.microsoft.azure.keyvault.models.CertificateImportParameters) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody) Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse)

Example 7 with CertificateAttributes

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

the class KeyVaultClientImpl method createCertificateWithServiceResponseAsync.

/**
     * Creates a new certificate. If this is the first version, the certificate resource is created.
     *
     * @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<ServiceResponse<CertificateOperation>> createCertificateWithServiceResponseAsync(String vaultBaseUrl, String certificateName) {
    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<String, String> tags = null;
    CertificateCreateParameters parameters = new CertificateCreateParameters();
    parameters.withCertificatePolicy(null);
    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<Response<ResponseBody>, Observable<ServiceResponse<CertificateOperation>>>() {

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

Aggregations

CertificateAttributes (com.microsoft.azure.keyvault.models.CertificateAttributes)7 CertificateBundle (com.microsoft.azure.keyvault.models.CertificateBundle)6 CertificatePolicy (com.microsoft.azure.keyvault.models.CertificatePolicy)6 ServiceResponse (com.microsoft.rest.ServiceResponse)4 ResponseBody (okhttp3.ResponseBody)4 Response (retrofit2.Response)4 Observable (rx.Observable)4 Attributes (com.microsoft.azure.keyvault.models.Attributes)3 SecretProperties (com.microsoft.azure.keyvault.models.SecretProperties)3 Test (org.junit.Test)3 SecretIdentifier (com.microsoft.azure.keyvault.SecretIdentifier)2 CertificateOperation (com.microsoft.azure.keyvault.models.CertificateOperation)2 IssuerParameters (com.microsoft.azure.keyvault.models.IssuerParameters)2 KeyVaultErrorException (com.microsoft.azure.keyvault.models.KeyVaultErrorException)2 SecretBundle (com.microsoft.azure.keyvault.models.SecretBundle)2 KeyStore (java.security.KeyStore)2 X509Certificate (java.security.cert.X509Certificate)2 DateTime (org.joda.time.DateTime)2 KeyIdentifier (com.microsoft.azure.keyvault.KeyIdentifier)1 CertificateCreateParameters (com.microsoft.azure.keyvault.models.CertificateCreateParameters)1