Search in sources :

Example 6 with IssuerBundle

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

the class KeyVaultClientImpl method updateCertificateIssuerWithServiceResponseAsync.

/**
     * Updates the specified certificate issuer.
     *
     * @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
     */
public Observable<ServiceResponse<IssuerBundle>> updateCertificateIssuerWithServiceResponseAsync(String vaultBaseUrl, String issuerName) {
    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.");
    }
    final String provider = null;
    final IssuerCredentials credentials = null;
    final OrganizationDetails organizationDetails = null;
    final IssuerAttributes attributes = null;
    CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters();
    parameter.withProvider(null);
    parameter.withCredentials(null);
    parameter.withOrganizationDetails(null);
    parameter.withAttributes(null);
    String parameterizedHost = Joiner.on(", ").join("{vaultBaseUrl}", vaultBaseUrl);
    return service.updateCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<IssuerBundle>>>() {

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

Example 7 with IssuerBundle

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

the class CertificateOperationsTest method issuerCrudOperations.

/**
     * 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<AdministratorDetails> administratorsDetails = new ArrayList<AdministratorDetails>();
    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());
    validateCertificateIssuer(certificateIssuer, createdCertificateIssuer);
    String certificateIssuerName = createdCertificateIssuer.issuerIdentifier().name();
    IssuerBundle retrievedCertificateIssuer = keyVaultClient.getCertificateIssuer(getVaultUri(), certificateIssuerName);
    validateCertificateIssuer(certificateIssuer, retrievedCertificateIssuer);
    IssuerCredentials updatedCredentials = new IssuerCredentials().withAccountId("account2").withPassword("Secur!Ty");
    retrievedCertificateIssuer.withCredentials(updatedCredentials);
    IssuerBundle updatedCertificateIssuer = keyVaultClient.updateCertificateIssuer(new UpdateCertificateIssuerRequest.Builder(getVaultUri(), certificateIssuerName).withProvider(ISSUER_TEST).withCredentials(updatedCredentials).withOrganizationDetails(retrievedCertificateIssuer.organizationDetails()).withAttributes(retrievedCertificateIssuer.attributes()).build());
    validateCertificateIssuer(retrievedCertificateIssuer, updatedCertificateIssuer);
    Assert.assertNotNull(updatedCertificateIssuer.organizationDetails());
    IssuerBundle deletedCertificateIssuer = keyVaultClient.deleteCertificateIssuer(getVaultUri(), certificateIssuerName);
    validateCertificateIssuer(updatedCertificateIssuer, deletedCertificateIssuer);
    try {
        keyVaultClient.getCertificateIssuer(getVaultUri(), certificateIssuerName);
    } catch (KeyVaultErrorException e) {
        Assert.assertNotNull(e.body().error());
        Assert.assertEquals("CertificateIssuerNotFound", e.body().error().code());
    }
}
Also used : IssuerBundle(com.microsoft.azure.keyvault.models.IssuerBundle) KeyVaultErrorException(com.microsoft.azure.keyvault.models.KeyVaultErrorException) IssuerCredentials(com.microsoft.azure.keyvault.models.IssuerCredentials) OrganizationDetails(com.microsoft.azure.keyvault.models.OrganizationDetails) ArrayList(java.util.ArrayList) AdministratorDetails(com.microsoft.azure.keyvault.models.AdministratorDetails) Test(org.junit.Test)

Example 8 with IssuerBundle

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

the class KeyVaultClientImpl method setCertificateIssuerWithServiceResponseAsync.

/**
     * Sets the specified certificate issuer.
     *
     * @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.
     * @return the observable to the IssuerBundle object
     */
public Observable<ServiceResponse<IssuerBundle>> 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.");
    }
    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);
    return service.setCertificateIssuer(issuerName, this.apiVersion(), this.acceptLanguage(), parameter, parameterizedHost, this.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<IssuerBundle>>>() {

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

Aggregations

IssuerBundle (com.microsoft.azure.keyvault.models.IssuerBundle)8 IssuerCredentials (com.microsoft.azure.keyvault.models.IssuerCredentials)5 OrganizationDetails (com.microsoft.azure.keyvault.models.OrganizationDetails)5 ServiceResponse (com.microsoft.rest.ServiceResponse)4 ResponseBody (okhttp3.ResponseBody)4 Test (org.junit.Test)4 Response (retrofit2.Response)4 Observable (rx.Observable)4 AdministratorDetails (com.microsoft.azure.keyvault.models.AdministratorDetails)3 KeyVaultErrorException (com.microsoft.azure.keyvault.models.KeyVaultErrorException)3 ArrayList (java.util.ArrayList)3 CertificateBundle (com.microsoft.azure.keyvault.models.CertificateBundle)2 CertificateIssuerSetParameters (com.microsoft.azure.keyvault.models.CertificateIssuerSetParameters)2 CertificateIssuerUpdateParameters (com.microsoft.azure.keyvault.models.CertificateIssuerUpdateParameters)2 CertificateOperation (com.microsoft.azure.keyvault.models.CertificateOperation)2 CertificatePolicy (com.microsoft.azure.keyvault.models.CertificatePolicy)2 IssuerAttributes (com.microsoft.azure.keyvault.models.IssuerAttributes)2 IssuerParameters (com.microsoft.azure.keyvault.models.IssuerParameters)2 SecretProperties (com.microsoft.azure.keyvault.models.SecretProperties)2 X509CertificateProperties (com.microsoft.azure.keyvault.models.X509CertificateProperties)2