Class CertificateClient

java.lang.Object
com.azure.security.keyvault.certificates.CertificateClient

public final class CertificateClient extends Object
The CertificateClient provides synchronous methods to manage certifcates in the Azure Key Vault. The client supports creating, retrieving, updating, merging, deleting, purging, backing up, restoring and listing the certificates. The client also supports listing deleted certificates for a soft-delete enabled Azure Key Vault.

The client further allows creating, retrieving, updating, deleting and listing the certificate issuers. The client also supports creating, listing and deleting certificate contacts

Samples to construct the sync client

 CertificateClient certificateClient = new CertificateClientBuilder()
     .credential(new DefaultAzureCredentialBuilder().build())
     .vaultUrl("https://myvault.vault.azure.net/")
     .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
     .buildClient();
 
See Also:
  • Method Details

    • getVaultUrl

      public String getVaultUrl()
      Get the vault endpoint url to which service requests are sent to.
      Returns:
      the vault endpoint url
    • beginCreateCertificate

      public SyncPoller<CertificateOperation,KeyVaultCertificateWithPolicy> beginCreateCertificate(String certificateName, CertificatePolicy policy, Boolean isEnabled, Map<String,String> tags)
      Creates a new certificate. If this is the first version, the certificate resource is created. This operation requires the certificates/create permission.

      Create certificate is a long running operation. It indefinitely waits for the create certificate operation to complete on service side.

      Code Samples

      Create certificate is a long running operation. The createCertificate indefinitely waits for the operation to complete and returns its last status. The details of the last certificate operation status are printed when a response is received

       CertificatePolicy certificatePolicyPkcsSelf = new CertificatePolicy("Self",
           "CN=SelfSignedJavaPkcs12");
       SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> certificateSyncPoller = certificateClient
           .beginCreateCertificate("certificateName", certificatePolicyPkcsSelf, true, new HashMap<>());
       certificateSyncPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
       KeyVaultCertificate createdCertificate = certificateSyncPoller.getFinalResult();
       System.out.printf("Certificate created with name %s%n", createdCertificate.getName());
       
      Parameters:
      certificateName - The name of the certificate to be created.
      policy - The policy of the certificate to be created.
      isEnabled - The enabled status of the certificate.
      tags - The application specific metadata to set.
      Returns:
      A SyncPoller to poll on the create certificate operation status.
      Throws:
      ResourceModifiedException - when invalid certificate policy configuration is provided.
    • beginCreateCertificate

      public SyncPoller<CertificateOperation,KeyVaultCertificateWithPolicy> beginCreateCertificate(String certificateName, CertificatePolicy policy)
      Creates a new certificate. If this is the first version, the certificate resource is created. This operation requires the certificates/create permission.

      Create certificate is a long running operation. It indefinitely waits for the create certificate operation to complete on service side.

      Code Samples

      Create certificate is a long running operation. The createCertificate indefinitely waits for the operation to complete and returns its last status. The details of the last certificate operation status are printed when a response is received

       CertificatePolicy certPolicy = new CertificatePolicy("Self",
           "CN=SelfSignedJavaPkcs12");
       SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> certPoller = certificateClient
           .beginCreateCertificate("certificateName", certPolicy);
       certPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
       KeyVaultCertificate cert = certPoller.getFinalResult();
       System.out.printf("Certificate created with name %s%n", cert.getName());
       
      Parameters:
      certificateName - The name of the certificate to be created.
      policy - The policy of the certificate to be created.
      Returns:
      A SyncPoller to poll on the create certificate operation status.
      Throws:
      ResourceModifiedException - when invalid certificate policy configuration is provided.
    • getCertificateOperation

      public SyncPoller<CertificateOperation,KeyVaultCertificateWithPolicy> getCertificateOperation(String certificateName)
      Gets a pending CertificateOperation from the key vault. This operation requires the certificates/get permission.

      Code Samples

      Geta a pending certificate operation. The poller allows users to automatically poll on the certificate operation status.

       SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> getCertPoller = certificateClient
           .getCertificateOperation("certificateName");
       getCertPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
       KeyVaultCertificate cert = getCertPoller.getFinalResult();
       System.out.printf("Certificate created with name %s%n", cert.getName());
       
      Parameters:
      certificateName - The name of the certificate.
      Returns:
      A SyncPoller to poll on the certificate operation status.
      Throws:
      ResourceNotFoundException - when a certificate operation for a certificate with certificateName doesn't exist.
    • getCertificate

      public KeyVaultCertificateWithPolicy getCertificate(String certificateName)
      Gets information about the latest version of the specified certificate. This operation requires the certificates/get permission.

      Code Samples

      Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when a response has been received.

       KeyVaultCertificateWithPolicy certificate = certificateClient.getCertificate("certificateName");
       System.out.printf("Received certificate with name %s and version %s and secret id %s%n",
           certificate.getProperties().getName(),
           certificate.getProperties().getVersion(), certificate.getSecretId());
       
      Parameters:
      certificateName - The name of the certificate to retrieve, cannot be null
      Returns:
      The requested certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - if certificateName is empty string.
    • getCertificateWithResponse

      public Response<KeyVaultCertificateWithPolicy> getCertificateWithResponse(String certificateName, Context context)
      Gets information about the latest version of the specified certificate. This operation requires the certificates/get permission.

      Code Samples

      Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when a response has been received.

       Response<KeyVaultCertificateWithPolicy> certificateWithResponse = certificateClient
           .getCertificateWithResponse("certificateName", new Context(key1, value1));
       System.out.printf("Received certificate with name %s and version %s and secret id %s%n",
           certificateWithResponse.getValue().getProperties().getName(),
           certificateWithResponse.getValue().getProperties().getVersion(), certificate.getSecretId());
       
      Parameters:
      certificateName - The name of the certificate to retrieve, cannot be null
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the requested certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - if certificateName is empty string.
    • getCertificateVersionWithResponse

      public Response<KeyVaultCertificate> getCertificateVersionWithResponse(String certificateName, String version, Context context)
      Gets information about the latest version of the specified certificate. This operation requires the certificates/get permission.

      Code Samples

      Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when a response has been received.

       Response<KeyVaultCertificate> returnedCertificateWithResponse = certificateClient
           .getCertificateVersionWithResponse("certificateName", "certificateVersion",
               new Context(key1, value1));
       System.out.printf("Received certificate with name %s and version %s and secret id %s%n",
           returnedCertificateWithResponse.getValue().getProperties().getName(),
           returnedCertificateWithResponse.getValue().getProperties().getVersion(),
           returnedCertificateWithResponse.getValue().getSecretId());
       
      Parameters:
      certificateName - The name of the certificate to retrieve, cannot be null
      version - The version of the certificate to retrieve. If this is an empty String or null then latest version of the certificate is retrieved.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the requested certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - if certificateName is empty string.
    • getCertificateVersion

      public KeyVaultCertificate getCertificateVersion(String certificateName, String version)
      Gets information about the specified version of the specified certificate. This operation requires the certificates/get permission.

      Code Samples

      Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when a response has been received.

       KeyVaultCertificate returnedCertificate = certificateClient.getCertificateVersion("certificateName",
           "certificateVersion");
       System.out.printf("Received certificate with name %s and version %s and secret id %s%n",
           returnedCertificate.getProperties().getName(), returnedCertificate.getProperties().getVersion(),
           returnedCertificate.getSecretId());
       
      Parameters:
      certificateName - The name of the certificate to retrieve, cannot be null
      version - The version of the certificate to retrieve. If this is an empty String or null then latest version of the certificate is retrieved.
      Returns:
      The requested certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - if certificateName is empty string.
    • updateCertificateProperties

      public KeyVaultCertificate updateCertificateProperties(CertificateProperties properties)
      Updates the specified attributes associated with the specified certificate. The update operation changes specified attributes of an existing stored certificate and attributes that are not specified in the request are left unchanged. This operation requires the certificates/update permission.

      Code Samples

      Gets latest version of the certificate, changes its tags and enabled status and then updates it in the Azure Key Vault. Prints out the returned certificate details when a response has been received.

       KeyVaultCertificate certificate = certificateClient.getCertificate("certificateName");
       // Update certificate enabled status
       certificate.getProperties().setEnabled(false);
       KeyVaultCertificate updatedCertificate = certificateClient.updateCertificateProperties(certificate.getProperties());
       System.out.printf("Updated Certificate with name %s and enabled status %s%n",
           updatedCertificate.getProperties().getName(), updatedCertificate.getProperties().isEnabled());
       
      Parameters:
      properties - The CertificateProperties object with updated properties.
      Returns:
      The updated certificate.
      Throws:
      NullPointerException - if certificate is null.
      ResourceNotFoundException - when a certificate with certificateName and version doesn't exist in the key vault.
      HttpRequestException - if certificateName or version is empty string.
    • updateCertificatePropertiesWithResponse

      public Response<KeyVaultCertificate> updateCertificatePropertiesWithResponse(CertificateProperties properties, Context context)
      Updates the specified attributes associated with the specified certificate. The update operation changes specified attributes of an existing stored certificate and attributes that are not specified in the request are left unchanged. This operation requires the certificates/update permission.

      Code Samples

      Gets latest version of the certificate, changes its tags and enabled status and then updates it in the Azure Key Vault. Prints out the returned certificate details when a response has been received.

       KeyVaultCertificate certificateToUpdate = certificateClient.getCertificate("certificateName");
       // Update certificate enabled status
       certificateToUpdate.getProperties().setEnabled(false);
       Response<KeyVaultCertificate> updatedCertificateResponse = certificateClient.
           updateCertificatePropertiesWithResponse(certificateToUpdate.getProperties(), new Context(key1, value1));
       System.out.printf("Updated Certificate with name %s and enabled status %s%n",
           updatedCertificateResponse.getValue().getProperties().getName(),
           updatedCertificateResponse.getValue().getProperties().isEnabled());
       
      Parameters:
      properties - The CertificateProperties object with updated properties.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the updated certificate.
      Throws:
      NullPointerException - if certificate is null.
      ResourceNotFoundException - when a certificate with certificateName and version doesn't exist in the key vault.
      HttpRequestException - if certificateName or version is empty string.
    • beginDeleteCertificate

      public SyncPoller<DeletedCertificate,Void> beginDeleteCertificate(String certificateName)
      Deletes a certificate from a specified key vault. All the versions of the certificate along with its associated policy get deleted. If soft-delete is enabled on the key vault then the certificate is placed in the deleted state and requires to be purged for permanent deletion else the certificate is permanently deleted. The delete operation applies to any certificate stored in Azure Key Vault but it cannot be applied to an individual version of a certificate. This operation requires the certificates/delete permission.

      Code Samples

      Deletes the certificate in the Azure Key Vault. Prints out the deleted certificate details when a response has been received.

       SyncPoller<DeletedCertificate, Void> deleteCertPoller =
           certificateClient.beginDeleteCertificate("certificateName");
       // Deleted Certificate is accessible as soon as polling beings.
       PollResponse<DeletedCertificate> deleteCertPollResponse = deleteCertPoller.poll();
       System.out.printf("Deleted certificate with name %s and recovery id %s%n",
           deleteCertPollResponse.getValue().getName(), deleteCertPollResponse.getValue().getRecoveryId());
       deleteCertPoller.waitForCompletion();
       
      Parameters:
      certificateName - The name of the certificate to be deleted.
      Returns:
      A SyncPoller to poll on and retrieve deleted certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - when a certificate with certificateName is empty string.
    • getDeletedCertificate

      public DeletedCertificate getDeletedCertificate(String certificateName)
      Retrieves information about the specified deleted certificate. The GetDeletedCertificate operation is applicable for soft-delete enabled vaults and additionally retrieves deleted certificate's attributes, such as retention interval, scheduled permanent deletion and the current deletion recovery level. This operation requires the certificates/get permission.

      Code Samples

      Gets the deleted certificate from the key vault enabled for soft-delete. Prints out the deleted certificate details when a response has been received.

       DeletedCertificate deletedCertificate = certificateClient.getDeletedCertificate("certificateName");
       System.out.printf("Deleted certificate with name %s and recovery id %s%n", deletedCertificate.getName(),
           deletedCertificate.getRecoveryId());
       
      Parameters:
      certificateName - The name of the deleted certificate.
      Returns:
      The deleted certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - when a certificate with certificateName is empty string.
    • getDeletedCertificateWithResponse

      public Response<DeletedCertificate> getDeletedCertificateWithResponse(String certificateName, Context context)
      Retrieves information about the specified deleted certificate. The GetDeletedCertificate operation is applicable for soft-delete enabled vaults and additionally retrieves deleted certificate's attributes, such as retention interval, scheduled permanent deletion and the current deletion recovery level. This operation requires the certificates/get permission.

      Code Samples

      Gets the deleted certificate from the key vault enabled for soft-delete. Prints out the deleted certificate details when a response has been received.

       Response<DeletedCertificate> deletedCertificateWithResponse = certificateClient
           .getDeletedCertificateWithResponse("certificateName", new Context(key1, value1));
       System.out.printf("Deleted certificate with name %s and recovery id %s%n",
           deletedCertificateWithResponse.getValue().getName(),
           deletedCertificateWithResponse.getValue().getRecoveryId());
       
      Parameters:
      certificateName - The name of the deleted certificate.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the deleted certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - when a certificate with certificateName is empty string.
    • purgeDeletedCertificate

      public void purgeDeletedCertificate(String certificateName)
      Permanently deletes the specified deleted certificate without possibility for recovery. The Purge Deleted Certificate operation is applicable for soft-delete enabled vaults and is not available if the recovery level does not specify 'Purgeable'. This operation requires the certificate/purge permission.

      Code Samples

      Purges the deleted certificate from the key vault enabled for soft-delete. Prints out the status code from the server response when a response has been received.

       certificateClient.purgeDeletedCertificate("certificateName");
       
      Parameters:
      certificateName - The name of the deleted certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - when a certificate with certificateName is empty string.
    • purgeDeletedCertificateWithResponse

      public Response<Void> purgeDeletedCertificateWithResponse(String certificateName, Context context)
      Permanently deletes the specified deleted certificate without possibility for recovery. The Purge Deleted Certificate operation is applicable for soft-delete enabled vaults and is not available if the recovery level does not specify 'Purgeable'. This operation requires the certificate/purge permission.

      Code Samples

      Purges the deleted certificate from the key vault enabled for soft-delete. Prints out the status code from the server response when a response has been received.

       Response<Void> purgeResponse = certificateClient.purgeDeletedCertificateWithResponse("certificateName",
           new Context(key1, value1));
       System.out.printf("Purged Deleted certificate with status %d%n", purgeResponse.getStatusCode());
       
      Parameters:
      certificateName - The name of the deleted certificate.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A response containing status code and HTTP headers.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - when a certificate with certificateName is empty string.
    • beginRecoverDeletedCertificate

      public SyncPoller<KeyVaultCertificateWithPolicy,Void> beginRecoverDeletedCertificate(String certificateName)
      Recovers the deleted certificate back to its current version under /certificates and can only be performed on a soft-delete enabled vault. The RecoverDeletedCertificate operation performs the reversal of the Delete operation and must be issued during the retention interval (available in the deleted certificate's attributes). This operation requires the certificates/recover permission.

      Code Samples

      Recovers the deleted certificate from the key vault enabled for soft-delete. Prints out the recovered certificate details when a response has been received.

       SyncPoller<KeyVaultCertificateWithPolicy, Void> recoverDeletedCertPoller = certificateClient
           .beginRecoverDeletedCertificate("deletedCertificateName");
       // Recovered certificate is accessible as soon as polling beings
       PollResponse<KeyVaultCertificateWithPolicy> recoverDeletedCertPollResponse = recoverDeletedCertPoller.poll();
       System.out.printf(" Recovered Deleted certificate with name %s and id %s%n",
           recoverDeletedCertPollResponse.getValue().getProperties().getName(),
           recoverDeletedCertPollResponse.getValue().getProperties().getId());
       recoverDeletedCertPoller.waitForCompletion();
       
      Parameters:
      certificateName - The name of the deleted certificate to be recovered.
      Returns:
      A SyncPoller to poll on and retrieve recovered certificate.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the certificate vault.
      HttpRequestException - when a certificate with certificateName is empty string.
    • backupCertificate

      public byte[] backupCertificate(String certificateName)
      Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate will be downloaded. This operation requires the certificates/backup permission.

      Code Samples

      Backs up the certificate from the key vault. Prints out the length of the certificate's backup byte array returned in the response.

       byte[] certificateBackup = certificateClient.backupCertificate("certificateName");
       System.out.printf("Backed up certificate with back up blob length %d%n", certificateBackup.length);
       
      Parameters:
      certificateName - The name of the certificate.
      Returns:
      The backed up certificate blob.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - when a certificate with certificateName is empty string.
    • backupCertificateWithResponse

      public Response<byte[]> backupCertificateWithResponse(String certificateName, Context context)
      Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate will be downloaded. This operation requires the certificates/backup permission.

      Code Samples

      Backs up the certificate from the key vault. Prints out the length of the certificate's backup byte array returned in the response.

       Response<byte[]> certificateBackupWithResponse = certificateClient
           .backupCertificateWithResponse("certificateName", new Context(key1, value1));
       System.out.printf("Backed up certificate with back up blob length %d%n",
           certificateBackupWithResponse.getValue().length);
       
      Parameters:
      certificateName - The certificateName of the certificate.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the backed up certificate blob.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - when a certificate with certificateName is empty string.
    • restoreCertificateBackup

      public KeyVaultCertificateWithPolicy restoreCertificateBackup(byte[] backup)
      Restores a backed up certificate to the vault. All the versions of the certificate are restored to the vault. This operation requires the certificates/restore permission.

      Code Samples

      Restores the certificate in the key vault from its backup. Prints out the restored certificate details when a response has been received.

       byte[] certificateBackupBlob = {};
       KeyVaultCertificate certificate = certificateClient.restoreCertificateBackup(certificateBackupBlob);
       System.out.printf(" Restored certificate with name %s and id %s%n",
           certificate.getProperties().getName(), certificate.getProperties().getId());
       
      Parameters:
      backup - The backup blob associated with the certificate.
      Returns:
      The restored certificate.
      Throws:
      ResourceModifiedException - when backup blob is malformed.
    • restoreCertificateBackupWithResponse

      public Response<KeyVaultCertificateWithPolicy> restoreCertificateBackupWithResponse(byte[] backup, Context context)
      Restores a backed up certificate to the vault. All the versions of the certificate are restored to the vault. This operation requires the certificates/restore permission.

      Code Samples

      Restores the certificate in the key vault from its backup. Prints out the restored certificate details when a response has been received.

       byte[] certificateBackupBlobArray = {};
       Response<KeyVaultCertificateWithPolicy> certificateResponse = certificateClient
           .restoreCertificateBackupWithResponse(certificateBackupBlobArray, new Context(key1, value1));
       System.out.printf(" Restored certificate with name %s and id %s%n",
           certificateResponse.getValue().getProperties().getName(),
           certificateResponse.getValue().getProperties().getId());
       
      Parameters:
      backup - The backup blob associated with the certificate.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the restored certificate.
      Throws:
      ResourceModifiedException - when backup blob is malformed.
    • listPropertiesOfCertificates

      public PagedIterable<CertificateProperties> listPropertiesOfCertificates()
      List certificates in a the key vault. Retrieves the set of certificates resources in the key vault and the individual certificate response in the iterable is represented by CertificateProperties as only the certificate identifier, thumbprint, attributes and tags are provided in the response. The policy and individual certificate versions are not listed in the response. This operation requires the certificates/list permission.

      It is possible to get certificates with all the properties excluding the policy from this information. Loop over the CertificateProperties and call getCertificateVersion(String, String) . This will return the certificate with all its properties excluding the policy.

       for (CertificateProperties certificateProperties : certificateClient.listPropertiesOfCertificates()) {
           KeyVaultCertificate certificateWithAllProperties = certificateClient
               .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion());
           System.out.printf("Received certificate with name %s and secret id %s%n",
               certificateWithAllProperties.getProperties().getName(),
               certificateWithAllProperties.getSecretId());
       }
       
      Returns:
      A PagedIterable containing certificate for all the certificates in the vault.
    • listPropertiesOfCertificates

      public PagedIterable<CertificateProperties> listPropertiesOfCertificates(boolean includePending, Context context)
      List certificates in a the key vault. Retrieves the set of certificates resources in the key vault and the individual certificate response in the iterable is represented by CertificateProperties as only the certificate identifier, thumbprint, attributes and tags are provided in the response. The policy and individual certificate versions are not listed in the response. This operation requires the certificates/list permission.

      It is possible to get certificates with all the properties excluding the policy from this information. Loop over the CertificateProperties and call getCertificateVersion(String, String) . This will return the certificate with all its properties excluding the policy.

       for (CertificateProperties certificateProperties : certificateClient
           .listPropertiesOfCertificates(true, new Context(key1, value1))) {
           KeyVaultCertificate certificateWithAllProperties = certificateClient
               .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion());
           System.out.printf("Received certificate with name %s and secret id %s%n",
               certificateWithAllProperties.getProperties().getName(),
               certificateWithAllProperties.getSecretId());
       }
       
      Parameters:
      includePending - indicate if pending certificates should be included in the results.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A PagedIterable containing certificate for all the certificates in the vault.
    • listDeletedCertificates

      public PagedIterable<DeletedCertificate> listDeletedCertificates()
      Lists the deleted certificates in the key vault currently available for recovery. This operation includes deletion-specific information and is applicable for vaults enabled for soft-delete. This operation requires the certificates/get/list permission.

      Code Samples

      Lists the deleted certificates in the key vault. Prints out the recovery id of each deleted certificate when a response has been received.

       for (DeletedCertificate deletedCertificate : certificateClient.listDeletedCertificates()) {
           System.out.printf("Deleted certificate's recovery Id %s%n", deletedCertificate.getRecoveryId());
       }
       
      Returns:
      A PagedIterable containing all of the deleted certificates in the vault.
    • listDeletedCertificates

      public PagedIterable<DeletedCertificate> listDeletedCertificates(boolean includePending, Context context)
      Lists the deleted certificates in the key vault currently available for recovery. This operation includes deletion-specific information and is applicable for vaults enabled for soft-delete. This operation requires the certificates/get/list permission.

      Code Samples

      Lists the deleted certificates in the key vault. Prints out the recovery id of each deleted certificate when a response has been received.

       for (DeletedCertificate deletedCertificate : certificateClient
           .listDeletedCertificates(true, new Context(key1, value1))) {
           System.out.printf("Deleted certificate's recovery Id %s%n", deletedCertificate.getRecoveryId());
       }
       
      Parameters:
      includePending - indicate if pending deleted certificates should be included in the results.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A PagedIterable containing all of the deleted certificates in the vault.
    • listPropertiesOfCertificateVersions

      public PagedIterable<CertificateProperties> listPropertiesOfCertificateVersions(String certificateName)
      List all versions of the specified certificate. The individual certificate response in the iterable is represented by CertificateProperties as only the certificate identifier, thumbprint, attributes and tags are provided in the response. The policy is not listed in the response. This operation requires the certificates/list permission.

      It is possible to get the certificates with properties excluding the policy for all the versions from this information. Loop over the CertificateProperties and call getCertificateVersion(String, String). This will return the certificate with all its properties excluding the policy.

       for (CertificateProperties certificateProperties : certificateClient
           .listPropertiesOfCertificateVersions("certificateName")) {
           KeyVaultCertificate certificateWithAllProperties = certificateClient
               .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion());
           System.out.printf("Received certificate's version with name %s, version %s and secret id %s%n",
               certificateWithAllProperties.getProperties().getName(),
               certificateWithAllProperties.getProperties().getVersion(), certificateWithAllProperties.getSecretId());
       }
       
      Parameters:
      certificateName - The name of the certificate.
      Returns:
      A PagedIterable containing certificate of all the versions of the specified certificate in the vault. Paged Iterable is empty if certificate with certificateName does not exist in key vault.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - when a certificate with certificateName is empty string.
    • listPropertiesOfCertificateVersions

      public PagedIterable<CertificateProperties> listPropertiesOfCertificateVersions(String certificateName, Context context)
      List all versions of the specified certificate. The individual certificate response in the iterable is represented by CertificateProperties as only the certificate identifier, thumbprint, attributes and tags are provided in the response. The policy is not listed in the response. This operation requires the certificates/list permission.

      It is possible to get the certificates with properties excluding the policy for all the versions from this information. Loop over the CertificateProperties and call getCertificateVersion(String, String). This will return the certificate with all its properties excluding the policy.

       for (CertificateProperties certificateProperties : certificateClient
           .listPropertiesOfCertificateVersions("certificateName")) {
           KeyVaultCertificate certificateWithAllProperties = certificateClient
               .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion());
           System.out.printf("Received certificate's version with name %s, version %s and secret id %s%n",
               certificateWithAllProperties.getProperties().getName(),
               certificateWithAllProperties.getProperties().getVersion(), certificateWithAllProperties.getSecretId());
       }
       
      Parameters:
      certificateName - The name of the certificate.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A PagedIterable containing certificate of all the versions of the specified certificate in the vault. Iterable is empty if certificate with certificateName does not exist in key vault.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - when a certificate with certificateName is empty string.
    • getCertificatePolicy

      public CertificatePolicy getCertificatePolicy(String certificateName)
      Retrieves the policy of the specified certificate in the key vault. This operation requires the certificates/get permission.

      Code Samples

      Gets the policy of a certirifcate in the key vault. Prints out the returned certificate policy details when a response has been received.

       CertificatePolicy policy = certificateClient.getCertificatePolicy("certificateName");
       System.out.printf("Received policy with subject name %s%n", policy.getSubject());
       
      Parameters:
      certificateName - The name of the certificate whose policy is to be retrieved, cannot be null
      Returns:
      The requested certificate policy.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - if certificateName is empty string.
    • getCertificatePolicyWithResponse

      public Response<CertificatePolicy> getCertificatePolicyWithResponse(String certificateName, Context context)
      Retrieves the policy of the specified certificate in the key vault. This operation requires the certificates/get permission.

      Code Samples

      Gets the policy of a certirifcate in the key vault. Prints out the returned certificate policy details when a response has been received.

       Response<CertificatePolicy> returnedPolicyWithResponse = certificateClient.getCertificatePolicyWithResponse(
           "certificateName", new Context(key1, value1));
       System.out.printf("Received policy with subject name %s%n",
           returnedPolicyWithResponse.getValue().getSubject());
       
      Parameters:
      certificateName - The name of the certificate whose policy is to be retrieved, cannot be null
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the requested certificate policy.
      Throws:
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - if certificateName is empty string.
    • updateCertificatePolicy

      public CertificatePolicy updateCertificatePolicy(String certificateName, CertificatePolicy policy)
      Updates the policy for a certificate. The update operation changes specified attributes of the certificate policy and attributes that are not specified in the request are left unchanged. This operation requires the certificates/update permission.

      Code Samples

      Gets the certificate policy, changes its properties and then updates it in the Azure Key Vault. Prints out the returned policy details when a response has been received.

       CertificatePolicy certificatePolicy = certificateClient.getCertificatePolicy("certificateName");
       //Update the certificate policy cert transparency property.
       certificatePolicy.setCertificateTransparent(true);
       CertificatePolicy updatedCertPolicy = certificateClient.updateCertificatePolicy("certificateName",
           certificatePolicy);
       System.out.printf("Updated Certificate Policy transparency status %s%n",
           updatedCertPolicy.isCertificateTransparent());
       
      Parameters:
      certificateName - The name of the certificate whose policy is to be updated.
      policy - The certificate policy to be updated.
      Returns:
      The updated certificate policy.
      Throws:
      NullPointerException - if policy is null.
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - if certificateName is empty string or if policy is invalid.
    • updateCertificatePolicyWithResponse

      public Response<CertificatePolicy> updateCertificatePolicyWithResponse(String certificateName, CertificatePolicy policy, Context context)
      Updates the policy for a certificate. The update operation changes specified attributes of the certificate policy and attributes that are not specified in the request are left unchanged. This operation requires the certificates/update permission.

      Code Samples

      Gets the certificate policy, changes its properties and then updates it in the Azure Key Vault. Prints out the returned policy details when a response has been received.

       CertificatePolicy certificatePolicyToUpdate = certificateClient.getCertificatePolicy("certificateName");
       //Update the certificate policy cert transparency property.
       certificatePolicyToUpdate.setCertificateTransparent(true);
       Response<CertificatePolicy> updatedCertPolicyWithResponse = certificateClient
           .updateCertificatePolicyWithResponse("certificateName", certificatePolicyToUpdate,
               new Context(key1, value1));
       System.out.printf("Updated Certificate Policy transparency status %s%n", updatedCertPolicyWithResponse
           .getValue().isCertificateTransparent());
       
      Parameters:
      certificateName - The certificateName of the certificate whose policy is to be updated.
      policy - The certificate policy to be updated.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the updated certificate policy.
      Throws:
      NullPointerException - if policy is null.
      ResourceNotFoundException - when a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - if certificateName is empty string or if policy is invalid.
    • createIssuer

      public CertificateIssuer createIssuer(CertificateIssuer issuer)
      Creates the specified certificate issuer. The SetCertificateIssuer operation updates the specified certificate issuer if it already exists or adds it if doesn't exist. This operation requires the certificates/setissuers permission.

      Code Samples

      Creates a new certificate issuer in the key vault. Prints out the created certificate issuer details when a response has been received.

       CertificateIssuer issuerToCreate = new CertificateIssuer("myissuer", "myProvider")
           .setAccountId("testAccount")
           .setAdministratorContacts(Collections.singletonList(new AdministratorContact().setFirstName("test")
               .setLastName("name").setEmail("test@example.com")));
       CertificateIssuer returnedIssuer = certificateClient.createIssuer(issuerToCreate);
       System.out.printf("Created Issuer with name %s provider %s%n", returnedIssuer.getName(),
           returnedIssuer.getProvider());
       
      Parameters:
      issuer - The configuration of the certificate issuer to be created.
      Returns:
      The created certificate issuer.
      Throws:
      ResourceModifiedException - when invalid certificate issuer issuer configuration is provided.
      HttpRequestException - when a certificate issuer with name is empty string.
    • createIssuerWithResponse

      public Response<CertificateIssuer> createIssuerWithResponse(CertificateIssuer issuer, Context context)
      Creates the specified certificate issuer. The SetCertificateIssuer operation updates the specified certificate issuer if it already exists or adds it if doesn't exist. This operation requires the certificates/setissuers permission.

      Code Samples

      Creates a new certificate issuer in the key vault. Prints out the created certificate issuer details when a response has been received.

       CertificateIssuer issuer = new CertificateIssuer("issuerName", "myProvider")
           .setAccountId("testAccount")
           .setAdministratorContacts(Collections.singletonList(new AdministratorContact().setFirstName("test")
               .setLastName("name").setEmail("test@example.com")));
       Response<CertificateIssuer> issuerResponse = certificateClient.createIssuerWithResponse(issuer,
           new Context(key1, value1));
       System.out.printf("Created Issuer with name %s provider %s%n", issuerResponse.getValue().getName(),
           issuerResponse.getValue().getProvider());
       
      Parameters:
      issuer - The configuration of the certificate issuer to be created.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the created certificate issuer.
      Throws:
      ResourceModifiedException - when invalid certificate issuer issuer configuration is provided.
      HttpRequestException - when a certificate issuer with name is empty string.
    • getIssuerWithResponse

      public Response<CertificateIssuer> getIssuerWithResponse(String issuerName, Context context)
      Retrieves the specified certificate issuer from the key vault. This operation requires the certificates/manageissuers/getissuers permission.

      Code Samples

      Gets the specificed certifcate issuer in the key vault. Prints out the returned certificate issuer details when a response has been received.

       Response<CertificateIssuer> issuerResponse = certificateClient.getIssuerWithResponse("issuerName",
           new Context(key1, value1));
       System.out.printf("Retrieved issuer with name %s and provider %s%n", issuerResponse.getValue().getName(),
           issuerResponse.getValue().getProvider());
       
      Parameters:
      issuerName - The name of the certificate issuer to retrieve, cannot be null
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the requested certificate issuer.
      Throws:
      ResourceNotFoundException - when a certificate issuer with issuerName doesn't exist in the key vault.
      HttpRequestException - if issuerName is empty string.
    • getIssuer

      public CertificateIssuer getIssuer(String issuerName)
      Retrieves the specified certificate issuer from the key vault. This operation requires the certificates/manageissuers/getissuers permission.

      Code Samples

      Gets the specified certificate issuer in the key vault. Prints out the returned certificate issuer details when a response has been received.

       CertificateIssuer returnedIssuer = certificateClient.getIssuer("issuerName");
       System.out.printf("Retrieved issuer with name %s and provider %s%n", returnedIssuer.getName(),
           returnedIssuer.getProvider());
       
      Parameters:
      issuerName - The name of the certificate issuer to retrieve, cannot be null
      Returns:
      The requested certificate issuer.
      Throws:
      ResourceNotFoundException - when a certificate issuer with issuerName doesn't exist in the key vault.
      HttpRequestException - if issuerName is empty string.
    • deleteIssuerWithResponse

      public Response<CertificateIssuer> deleteIssuerWithResponse(String issuerName, Context context)
      Deletes the specified certificate issuer. The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the key vault. This operation requires the certificates/manageissuers/deleteissuers permission.

      Code Samples

      Deletes the certificate issuer in the Azure Key Vault. Prints out the deleted certificate details when a response has been received.

       CertificateIssuer deletedIssuer = certificateClient.deleteIssuer("certificateName");
       System.out.printf("Deleted certificate issuer with name %s and provider id %s%n", deletedIssuer.getName(),
           deletedIssuer.getProvider());
       
      Parameters:
      issuerName - The name of the certificate issuer to be deleted.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the deleted issuer.
      Throws:
      ResourceNotFoundException - when a certificate issuer with issuerName doesn't exist in the key vault.
      HttpRequestException - when a certificate issuer with issuerName is empty string.
    • deleteIssuer

      public CertificateIssuer deleteIssuer(String issuerName)
      Deletes the specified certificate issuer. The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the key vault. This operation requires the certificates/manageissuers/deleteissuers permission.

      Code Samples

      Deletes the certificate issuer in the Azure Key Vault. Prints out the deleted certificate details when a response has been received.

       Response<CertificateIssuer> deletedIssuerWithResponse = certificateClient.
           deleteIssuerWithResponse("certificateName", new Context(key1, value1));
       System.out.printf("Deleted certificate issuer with name %s and provider id %s%n",
           deletedIssuerWithResponse.getValue().getName(),
           deletedIssuerWithResponse.getValue().getProvider());
       
      Parameters:
      issuerName - The name of the certificate issuer to be deleted.
      Returns:
      The deleted issuer.
      Throws:
      ResourceNotFoundException - when a certificate issuer with issuerName doesn't exist in the key vault.
      HttpRequestException - when a certificate issuer with issuerName is empty string.
    • listPropertiesOfIssuers

      public PagedIterable<IssuerProperties> listPropertiesOfIssuers()
      List all the certificate issuers resources in the key vault. The individual certificate issuer response in the iterable is represented by IssuerProperties as only the certificate issuer identifier and provider are provided in the response. This operation requires the certificates/manageissuers/getissuers permission.

      It is possible to get the certificate issuer with all of its properties from this information. Loop over the issuerProperties and call getIssuer(String) . This will return the issuer with all its properties.

      .
       for (IssuerProperties issuer : certificateClient.listPropertiesOfIssuers()) {
           CertificateIssuer retrievedIssuer = certificateClient.getIssuer(issuer.getName());
           System.out.printf("Received issuer with name %s and provider %s%n", retrievedIssuer.getName(),
               retrievedIssuer.getProvider());
       }
       
      Returns:
      A PagedIterable containing all of the certificate issuers in the vault.
    • listPropertiesOfIssuers

      public PagedIterable<IssuerProperties> listPropertiesOfIssuers(Context context)
      List all the certificate issuers resources in the key vault. The individual certificate issuer response in the iterable is represented by IssuerProperties as only the certificate issuer identifier and provider are provided in the response. This operation requires the certificates/manageissuers/getissuers permission.

      It is possible to get the certificate issuer with all of its properties from this information. Loop over the issuerProperties and call getIssuer(String). This will return the issuer with all its properties.

      .
       for (IssuerProperties issuer : certificateClient.listPropertiesOfIssuers(new Context(key1, value1))) {
           CertificateIssuer retrievedIssuer = certificateClient.getIssuer(issuer.getName());
           System.out.printf("Received issuer with name %s and provider %s%n", retrievedIssuer.getName(),
               retrievedIssuer.getProvider());
       }
       
      Parameters:
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A PagedIterable containing all of the certificate issuers in the vault.
    • updateIssuer

      public CertificateIssuer updateIssuer(CertificateIssuer issuer)
      Updates the specified certificate issuer. The UpdateCertificateIssuer operation updates the specified attributes of the certificate issuer entity. This operation requires the certificates/setissuers permission.

      Code Samples

      Gets the certificate issuer, changes its attributes/properties then updates it in the Azure Key Vault. Prints out the returned certificate issuer details when a response has been received.

       CertificateIssuer returnedIssuer = certificateClient.getIssuer("issuerName");
       returnedIssuer.setAccountId("newAccountId");
       CertificateIssuer updatedIssuer = certificateClient.updateIssuer(returnedIssuer);
       System.out.printf("Updated issuer with name %s, provider %s and account Id %s%n", updatedIssuer.getName(),
           updatedIssuer.getProvider(), updatedIssuer.getAccountId());
       
      Parameters:
      issuer - The issuer with updated properties.
      Returns:
      The updated issuer.
      Throws:
      NullPointerException - if issuer is null.
      ResourceNotFoundException - when a certificate issuer with name doesn't exist in the key vault.
      HttpRequestException - if name is empty string.
    • updateIssuerWithResponse

      public Response<CertificateIssuer> updateIssuerWithResponse(CertificateIssuer issuer, Context context)
      Updates the specified certificate issuer. The UpdateCertificateIssuer operation updates the specified attributes of the certificate issuer entity. This operation requires the certificates/setissuers permission.

      Code Samples

      Gets the certificate issuer, changes its attributes/properties then updates it in the Azure Key Vault. Prints out the returned certificate issuer details when a response has been received.

       CertificateIssuer issuer = certificateClient.getIssuer("issuerName");
       returnedIssuer.setAccountId("newAccountId");
       Response<CertificateIssuer> updatedIssuerWithResponse = certificateClient.updateIssuerWithResponse(issuer,
           new Context(key1, value1));
       System.out.printf("Updated issuer with name %s, provider %s and account Id %s%n",
           updatedIssuerWithResponse.getValue().getName(),
           updatedIssuerWithResponse.getValue().getProvider(),
           updatedIssuerWithResponse.getValue().getAccountId());
       
      Parameters:
      issuer - The issuer with updated properties.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the updated issuer.
      Throws:
      NullPointerException - if issuer is null.
      ResourceNotFoundException - when a certificate issuer with name doesn't exist in the key vault.
      HttpRequestException - if name is empty string.
    • setContacts

      public PagedIterable<CertificateContact> setContacts(List<CertificateContact> contacts)
      Sets the certificate contacts on the key vault. This operation requires the certificates/managecontacts permission.

      The LifetimeAction of type CertificatePolicyAction.EMAIL_CONTACTS set on a CertificatePolicy emails the contacts set on the vault when triggered.

      Code Samples

      Sets the certificate contacts in the Azure Key Vault. Prints out the returned contacts details.

       CertificateContact contactToAdd = new CertificateContact().setName("user").setEmail("useremail@example.com");
       for (CertificateContact contact : certificateClient.setContacts(Collections.singletonList(contactToAdd))) {
           System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(),
               contact.getEmail());
       }
       
      Parameters:
      contacts - The list of contacts to set on the vault.
      Returns:
      A PagedIterable containing all of the certificate contacts in the vault.
      Throws:
      HttpRequestException - when a contact information provided is invalid/incomplete.
    • setContacts

      public PagedIterable<CertificateContact> setContacts(List<CertificateContact> contacts, Context context)
      Sets the certificate contacts on the key vault. This operation requires the certificates/managecontacts permission.

      The LifetimeAction of type CertificatePolicyAction.EMAIL_CONTACTS set on a CertificatePolicy emails the contacts set on the vault when triggered.

      Code Samples

      Sets the certificate contacts in the Azure Key Vault. Prints out the returned contacts details.

       CertificateContact sampleContact = new CertificateContact().setName("user").setEmail("useremail@example.com");
       for (CertificateContact contact : certificateClient.setContacts(Collections.singletonList(sampleContact),
           new Context(key1, value1))) {
           System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(),
               contact.getEmail());
       }
       
      Parameters:
      contacts - The list of contacts to set on the vault.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A PagedIterable containing all of the certificate contacts in the vault.
      Throws:
      HttpRequestException - when a contact information provided is invalid/incomplete.
    • listContacts

      public PagedIterable<CertificateContact> listContacts()
      Lists the certificate contacts in the key vault. This operation requires the certificates/managecontacts permission.

      Code Samples

      Lists the certificate contacts in the Azure Key Vault. Prints out the returned contacts details in the response.

       for (CertificateContact contact : certificateClient.listContacts()) {
           System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(),
               contact.getEmail());
       }
       
      Returns:
      A PagedIterable containing all of the certificate contacts in the vault.
    • listContacts

      public PagedIterable<CertificateContact> listContacts(Context context)
      Lists the certificate contacts in the key vault. This operation requires the certificates/managecontacts permission.

      Code Samples

      Lists the certificate contacts in the Azure Key Vault. Prints out the returned contacts details in the response.

       for (CertificateContact contact : certificateClient.listContacts(new Context(key1, value1))) {
           System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(),
               contact.getEmail());
       }
       
      Parameters:
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A PagedIterable containing all of the certificate contacts in the vault.
    • deleteContacts

      public PagedIterable<CertificateContact> deleteContacts()
      Deletes the certificate contacts in the key vault. This operation requires the certificates/managecontacts permission.

      Code Samples

      Deletes the certificate contacts in the Azure Key Vault. Subscribes to the call and prints out the deleted contacts details.

       for (CertificateContact contact : certificateClient.deleteContacts()) {
           System.out.printf("Deleted contact with name %s and email %s from key vault%n", contact.getName(),
               contact.getEmail());
       }
       
      Returns:
      A PagedIterable containing all of the deleted certificate contacts in the vault.
    • deleteContacts

      public PagedIterable<CertificateContact> deleteContacts(Context context)
      Deletes the certificate contacts in the key vault. This operation requires the certificates/managecontacts permission.

      Code Samples

      Deletes the certificate contacts in the Azure Key Vault. Prints out the deleted contacts details in the response.

       for (CertificateContact contact : certificateClient.deleteContacts(new Context(key1, value1))) {
           System.out.printf("Deleted contact with name %s and email %s from key vault%n", contact.getName(),
               contact.getEmail());
       }
       
      Parameters:
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A PagedIterable containing all of the deleted certificate contacts in the vault.
    • deleteCertificateOperation

      public CertificateOperation deleteCertificateOperation(String certificateName)
      Deletes the creation operation for the specified certificate that is in the process of being created. The certificate is no longer created. This operation requires the certificates/update permission.

      Code Samples

      Triggers certificate creation and then deletes the certificate creation operation in the Azure Key Vault. Subscribes to the call and prints out the deleted certificate operation details when a response has been received.

       Response<CertificateOperation> deletedCertificateOperationWithResponse = certificateClient
           .deleteCertificateOperationWithResponse("certificateName", new Context(key1, value1));
       System.out.printf("Deleted Certificate Operation's last status %s%n",
           deletedCertificateOperationWithResponse.getValue().getStatus());
       
      Parameters:
      certificateName - The name of the certificate.
      Returns:
      The deleted certificate operation.
      Throws:
      ResourceNotFoundException - when a certificate operation for a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - when the certificateName is empty string.
    • deleteCertificateOperationWithResponse

      public Response<CertificateOperation> deleteCertificateOperationWithResponse(String certificateName, Context context)
      Deletes the creation operation for the specified certificate that is in the process of being created. The certificate is no longer created. This operation requires the certificates/update permission.

      Code Samples

      Triggers certificate creation and then deletes the certificate creation operation in the Azure Key Vault. Subscribes to the call and prints out the deleted certificate operation details when a response has been received.

       CertificateOperation deletedCertificateOperation = certificateClient
           .deleteCertificateOperation("certificateName");
       System.out.printf("Deleted Certificate Operation's last status %s%n", deletedCertificateOperation.getStatus());
       
      Parameters:
      certificateName - The name of the certificate.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the deleted certificate operation.
      Throws:
      ResourceNotFoundException - when a certificate operation for a certificate with certificateName doesn't exist in the key vault.
      HttpRequestException - when the certificateName is empty string.
    • cancelCertificateOperation

      public CertificateOperation cancelCertificateOperation(String certificateName)
      Cancels a certificate creation operation that is already in progress. This operation requires the certificates/update permission.

      Code Samples

      Triggers certificate creation and then cancels the certificate creation operation in the Azure Key Vault. Subscribes to the call and prints out the updated certificate operation details when a response has been received.

       CertificateOperation certificateOperation = certificateClient
           .cancelCertificateOperation("certificateName");
       System.out.printf("Certificate Operation status %s%n", certificateOperation.getStatus());
       
      Parameters:
      certificateName - The name of the certificate which is in the process of being created.
      Returns:
      A Response whose value contains the cancelled certificate operation.
      Throws:
      ResourceNotFoundException - when a certificate operation for a certificate with name doesn't exist in the key vault.
      HttpRequestException - when the name is empty string.
    • cancelCertificateOperationWithResponse

      public Response<CertificateOperation> cancelCertificateOperationWithResponse(String certificateName, Context context)
      Cancels a certificate creation operation that is already in progress. This operation requires the certificates/update permission.

      Code Samples

      Triggers certificate creation and then cancels the certificate creation operation in the Azure Key Vault. Subscribes to the call and prints out the updated certificate operation details when a response has been received.

       Response<CertificateOperation> certificateOperationWithResponse = certificateClient
           .cancelCertificateOperationWithResponse("certificateName", new Context(key1, value1));
       System.out.printf("Certificate Operation status %s%n", certificateOperationWithResponse.getValue().getStatus());
       
      Parameters:
      certificateName - The name of the certificate which is in the process of being created.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the cancelled certificate operation.
      Throws:
      ResourceNotFoundException - when a certificate operation for a certificate with name doesn't exist in the key vault.
      HttpRequestException - when the name is empty string.
    • mergeCertificate

      public KeyVaultCertificateWithPolicy mergeCertificate(MergeCertificateOptions mergeCertificateOptions)
      Merges a certificate or a certificate chain with a key pair currently available in the service. This operation requires the certificates/create permission.

      Code Samples

      Merges a certificate with a kay pair available in the service.

       List<byte[]> x509CertificatesToMerge = new ArrayList<>();
       MergeCertificateOptions config =
           new MergeCertificateOptions("certificateName", x509CertificatesToMerge)
               .setEnabled(false);
       KeyVaultCertificate mergedCertificate = certificateClient.mergeCertificate(config);
       System.out.printf("Received Certificate with name %s and key id %s%n",
           mergedCertificate.getProperties().getName(), mergedCertificate.getKeyId());
       
      Parameters:
      mergeCertificateOptions - the merge certificate configuration holding the x509 certificates.
      Returns:
      The merged certificate.
      Throws:
      NullPointerException - when mergeCertificateOptions is null.
      HttpRequestException - if mergeCertificateOptions is invalid/corrupt.
    • mergeCertificateWithResponse

      public Response<KeyVaultCertificateWithPolicy> mergeCertificateWithResponse(MergeCertificateOptions mergeCertificateOptions, Context context)
      Merges a certificate or a certificate chain with a key pair currently available in the service. This operation requires the certificates/create permission.

      Code Samples

      Merges a certificate with a kay pair available in the service.

       List<byte[]> x509CertsToMerge = new ArrayList<>();
       MergeCertificateOptions mergeConfig =
           new MergeCertificateOptions("certificateName", x509CertsToMerge)
               .setEnabled(false);
       Response<KeyVaultCertificateWithPolicy> mergedCertificateWithResponse =
           certificateClient.mergeCertificateWithResponse(mergeConfig, new Context(key2, value2));
       System.out.printf("Received Certificate with name %s and key id %s%n",
           mergedCertificateWithResponse.getValue().getProperties().getName(),
           mergedCertificateWithResponse.getValue().getKeyId());
       
      Parameters:
      mergeCertificateOptions - the merge certificate configuration holding the x509 certificates.
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the merged certificate.
      Throws:
      NullPointerException - when mergeCertificateOptions is null.
      HttpRequestException - if mergeCertificateOptions is invalid/corrupt.
    • importCertificate

      public KeyVaultCertificateWithPolicy importCertificate(ImportCertificateOptions importCertificateOptions)
      Imports a pre-existing certificate to the key vault. The specified certificate must be in PFX or PEM format, and must contain the private key as well as the x509 certificates. This operation requires the certificates/import permission.

      Code Samples

      Imports a certificate into the key vault.

       byte[] certificateToImport = new byte[100];
       ImportCertificateOptions config =
           new ImportCertificateOptions("certificateName", certificateToImport).setEnabled(false);
       KeyVaultCertificate importedCertificate = certificateClient.importCertificate(config);
       System.out.printf("Received Certificate with name %s and key id %s%n",
           importedCertificate.getProperties().getName(), importedCertificate.getKeyId());
       
      Parameters:
      importCertificateOptions - The details of the certificate to import to the key vault
      Returns:
      the imported certificate.
      Throws:
      HttpRequestException - when the importCertificateOptions are invalid.
    • importCertificateWithResponse

      public Response<KeyVaultCertificateWithPolicy> importCertificateWithResponse(ImportCertificateOptions importCertificateOptions, Context context)
      Imports a pre-existing certificate to the key vault. The specified certificate must be in PFX or PEM format, and must contain the private key as well as the x509 certificates. This operation requires the certificates/import permission.

      Code Samples

      Imports a certificate into the key vault.

       byte[] certToImport = new byte[100];
       ImportCertificateOptions importCertificateOptions =
           new ImportCertificateOptions("certificateName", certToImport).setEnabled(false);
       Response<KeyVaultCertificateWithPolicy> importedCertificateWithResponse =
           certificateClient.importCertificateWithResponse(importCertificateOptions, new Context(key2, value2));
       System.out.printf("Received Certificate with name %s and key id %s%n",
           importedCertificateWithResponse.getValue().getProperties().getName(),
           importedCertificateWithResponse.getValue().getKeyId());
       
      Parameters:
      importCertificateOptions - The details of the certificate to import to the key vault
      context - Additional context that is passed through the Http pipeline during the service call.
      Returns:
      A Response whose value contains the imported certificate.
      Throws:
      HttpRequestException - when the importCertificateOptions are invalid.