Class CertificateClient
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 Summary
Modifier and TypeMethodDescriptionbyte[]
backupCertificate
(String certificateName) Requests that a backup of the specified certificate be downloaded to the client.Response<byte[]>
backupCertificateWithResponse
(String certificateName, Context context) Requests that a backup of the specified certificate be downloaded to the client.beginCreateCertificate
(String certificateName, CertificatePolicy policy) Creates a new certificate.beginCreateCertificate
(String certificateName, CertificatePolicy policy, Boolean isEnabled, Map<String, String> tags) Creates a new certificate.beginDeleteCertificate
(String certificateName) Deletes a certificate from a specified key vault.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.cancelCertificateOperation
(String certificateName) Cancels a certificate creation operation that is already in progress.cancelCertificateOperationWithResponse
(String certificateName, Context context) Cancels a certificate creation operation that is already in progress.createIssuer
(CertificateIssuer issuer) Creates the specified certificate issuer.createIssuerWithResponse
(CertificateIssuer issuer, Context context) Creates the specified certificate issuer.deleteCertificateOperation
(String certificateName) Deletes the creation operation for the specified certificate that is in the process of being created.deleteCertificateOperationWithResponse
(String certificateName, Context context) Deletes the creation operation for the specified certificate that is in the process of being created.Deletes the certificate contacts in the key vault.deleteContacts
(Context context) Deletes the certificate contacts in the key vault.deleteIssuer
(String issuerName) Deletes the specified certificate issuer.deleteIssuerWithResponse
(String issuerName, Context context) Deletes the specified certificate issuer.getCertificate
(String certificateName) Gets information about the latest version of the specified certificate.getCertificateOperation
(String certificateName) Gets a pendingCertificateOperation
from the key vault.getCertificatePolicy
(String certificateName) Retrieves the policy of the specified certificate in the key vault.getCertificatePolicyWithResponse
(String certificateName, Context context) Retrieves the policy of the specified certificate in the key vault.getCertificateVersion
(String certificateName, String version) Gets information about the specified version of the specified certificate.getCertificateVersionWithResponse
(String certificateName, String version, Context context) Gets information about the latest version of the specified certificate.getCertificateWithResponse
(String certificateName, Context context) Gets information about the latest version of the specified certificate.getDeletedCertificate
(String certificateName) Retrieves information about the specified deleted certificate.getDeletedCertificateWithResponse
(String certificateName, Context context) Retrieves information about the specified deleted certificate.Retrieves the specified certificate issuer from the key vault.getIssuerWithResponse
(String issuerName, Context context) Retrieves the specified certificate issuer from the key vault.Get the vault endpoint url to which service requests are sent to.importCertificate
(ImportCertificateOptions importCertificateOptions) Imports a pre-existing certificate to the key vault.importCertificateWithResponse
(ImportCertificateOptions importCertificateOptions, Context context) Imports a pre-existing certificate to the key vault.Lists the certificate contacts in the key vault.listContacts
(Context context) Lists the certificate contacts in the key vault.Lists thedeleted certificates
in the key vault currently available for recovery.listDeletedCertificates
(boolean includePending, Context context) Lists thedeleted certificates
in the key vault currently available for recovery.List certificates in a the key vault.listPropertiesOfCertificates
(boolean includePending, Context context) List certificates in a the key vault.listPropertiesOfCertificateVersions
(String certificateName) List all versions of the specified certificate.listPropertiesOfCertificateVersions
(String certificateName, Context context) List all versions of the specified certificate.List all the certificate issuers resources in the key vault.listPropertiesOfIssuers
(Context context) List all the certificate issuers resources in the key vault.mergeCertificate
(MergeCertificateOptions mergeCertificateOptions) Merges a certificate or a certificate chain with a key pair currently available in the service.mergeCertificateWithResponse
(MergeCertificateOptions mergeCertificateOptions, Context context) Merges a certificate or a certificate chain with a key pair currently available in the service.void
purgeDeletedCertificate
(String certificateName) Permanently deletes the specified deleted certificate without possibility for recovery.purgeDeletedCertificateWithResponse
(String certificateName, Context context) Permanently deletes the specified deleted certificate without possibility for recovery.restoreCertificateBackup
(byte[] backup) Restores a backed up certificate to the vault.restoreCertificateBackupWithResponse
(byte[] backup, Context context) Restores a backed up certificate to the vault.setContacts
(List<CertificateContact> contacts) Sets the certificate contacts on the key vault.setContacts
(List<CertificateContact> contacts, Context context) Sets the certificate contacts on the key vault.updateCertificatePolicy
(String certificateName, CertificatePolicy policy) Updates the policy for a certificate.updateCertificatePolicyWithResponse
(String certificateName, CertificatePolicy policy, Context context) Updates the policy for a certificate.updateCertificateProperties
(CertificateProperties properties) Updates the specified attributes associated with the specified certificate.updateCertificatePropertiesWithResponse
(CertificateProperties properties, Context context) Updates the specified attributes associated with the specified certificate.updateIssuer
(CertificateIssuer issuer) Updates the specified certificate issuer.updateIssuerWithResponse
(CertificateIssuer issuer, Context context) Updates the specified certificate issuer.
-
Method Details
-
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 pendingCertificateOperation
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 withcertificateName
doesn't exist.
-
getCertificate
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 withcertificateName
doesn't exist in the key vault.HttpRequestException
- ifcertificateName
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 nullcontext
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains the requestedcertificate
. - Throws:
ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.HttpRequestException
- ifcertificateName
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 nullversion
- 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
whosevalue
contains the requestedcertificate
. - Throws:
ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.HttpRequestException
- ifcertificateName
is empty string.
-
getCertificateVersion
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 nullversion
- 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 withcertificateName
doesn't exist in the key vault.HttpRequestException
- ifcertificateName
is empty string.
-
updateCertificateProperties
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
- TheCertificateProperties
object with updated properties.- Returns:
- The
updated certificate
. - Throws:
NullPointerException
- ifcertificate
isnull
.ResourceNotFoundException
- when a certificate withcertificateName
andversion
doesn't exist in the key vault.HttpRequestException
- ifcertificateName
orversion
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
- TheCertificateProperties
object with updated properties.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains theupdated certificate
. - Throws:
NullPointerException
- ifcertificate
isnull
.ResourceNotFoundException
- when a certificate withcertificateName
andversion
doesn't exist in the key vault.HttpRequestException
- ifcertificateName
orversion
is empty string.
-
beginDeleteCertificate
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 retrievedeleted certificate
. - Throws:
ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.HttpRequestException
- when a certificate withcertificateName
is empty string.
-
getDeletedCertificate
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 withcertificateName
doesn't exist in the key vault.HttpRequestException
- when a certificate withcertificateName
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
whosevalue
contains thedeleted certificate
. - Throws:
ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.HttpRequestException
- when a certificate withcertificateName
is empty string.
-
purgeDeletedCertificate
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 withcertificateName
doesn't exist in the key vault.HttpRequestException
- when a certificate withcertificateName
is empty string.
-
purgeDeletedCertificateWithResponse
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 withcertificateName
doesn't exist in the key vault.HttpRequestException
- when a certificate withcertificateName
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 retrieverecovered certificate
. - Throws:
ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the certificate vault.HttpRequestException
- when a certificate withcertificateName
is empty string.
-
backupCertificate
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 withcertificateName
doesn't exist in the key vault.HttpRequestException
- when a certificate withcertificateName
is empty string.
-
backupCertificateWithResponse
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
whosevalue
contains the backed up certificate blob. - Throws:
ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.HttpRequestException
- when a certificate withcertificateName
is empty string.
-
restoreCertificateBackup
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
- whenbackup
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
whosevalue
contains therestored certificate
. - Throws:
ResourceModifiedException
- whenbackup
blob is malformed.
-
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 byCertificateProperties
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 callgetCertificateVersion(String, String)
. This will return thecertificate
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
containingcertificate
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 byCertificateProperties
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 callgetCertificateVersion(String, String)
. This will return thecertificate
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
containingcertificate
for all the certificates in the vault.
-
listDeletedCertificates
Lists thedeleted 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 thecertificates/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 thedeleted certificates
in the vault.
-
listDeletedCertificates
public PagedIterable<DeletedCertificate> listDeletedCertificates(boolean includePending, Context context) Lists thedeleted 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 thecertificates/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 thedeleted 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 byCertificateProperties
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 callgetCertificateVersion(String, String)
. This will return thecertificate
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
containingcertificate
of all the versions of the specified certificate in the vault. Paged Iterable is empty if certificate withcertificateName
does not exist in key vault. - Throws:
ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.HttpRequestException
- when a certificate withcertificateName
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 byCertificateProperties
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 callgetCertificateVersion(String, String)
. This will return thecertificate
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
containingcertificate
of all the versions of the specified certificate in the vault. Iterable is empty if certificate withcertificateName
does not exist in key vault. - Throws:
ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.HttpRequestException
- when a certificate withcertificateName
is empty string.
-
getCertificatePolicy
Retrieves the policy of the specified certificate in the key vault. This operation requires thecertificates/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 withcertificateName
doesn't exist in the key vault.HttpRequestException
- ifcertificateName
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 thecertificates/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 nullcontext
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains the requestedcertificate policy
. - Throws:
ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.HttpRequestException
- ifcertificateName
is empty string.
-
updateCertificatePolicy
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 thecertificates/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
- ifpolicy
isnull
.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.HttpRequestException
- ifcertificateName
is empty string or ifpolicy
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 thecertificates/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
whosevalue
contains the updatedcertificate policy
. - Throws:
NullPointerException
- ifpolicy
isnull
.ResourceNotFoundException
- when a certificate withcertificateName
doesn't exist in the key vault.HttpRequestException
- ifcertificateName
is empty string or ifpolicy
is invalid.
-
createIssuer
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 issuerissuer
configuration is provided.HttpRequestException
- when a certificate issuer withname
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
whosevalue
contains the createdcertificate issuer
. - Throws:
ResourceModifiedException
- when invalid certificate issuerissuer
configuration is provided.HttpRequestException
- when a certificate issuer withname
is empty string.
-
getIssuerWithResponse
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 nullcontext
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains the requestedcertificate issuer
. - Throws:
ResourceNotFoundException
- when a certificate issuer withissuerName
doesn't exist in the key vault.HttpRequestException
- ifissuerName
is empty string.
-
getIssuer
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 withissuerName
doesn't exist in the key vault.HttpRequestException
- ifissuerName
is empty string.
-
deleteIssuerWithResponse
Deletes the specified certificate issuer. The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the key vault. This operation requires thecertificates/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
whosevalue
contains thedeleted issuer
. - Throws:
ResourceNotFoundException
- when a certificate issuer withissuerName
doesn't exist in the key vault.HttpRequestException
- when a certificate issuer withissuerName
is empty string.
-
deleteIssuer
Deletes the specified certificate issuer. The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the key vault. This operation requires thecertificates/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 withissuerName
doesn't exist in the key vault.HttpRequestException
- when a certificate issuer withissuerName
is empty string.
-
listPropertiesOfIssuers
List all the certificate issuers resources in the key vault. The individual certificate issuer response in the iterable is represented byIssuerProperties
as only the certificate issuer identifier and provider are provided in the response. This operation requires thecertificates/manageissuers/getissuers
permission.It is possible to get the certificate issuer with all of its properties from this information. Loop over the
.issuerProperties
and callgetIssuer(String)
. This will return theissuer
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 thecertificate issuers
in the vault.
-
listPropertiesOfIssuers
List all the certificate issuers resources in the key vault. The individual certificate issuer response in the iterable is represented byIssuerProperties
as only the certificate issuer identifier and provider are provided in the response. This operation requires thecertificates/manageissuers/getissuers
permission.It is possible to get the certificate issuer with all of its properties from this information. Loop over the
.issuerProperties
and callgetIssuer(String)
. This will return theissuer
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 thecertificate issuers
in the vault.
-
updateIssuer
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
- Theissuer
with updated properties.- Returns:
- The
updated issuer
. - Throws:
NullPointerException
- ifissuer
isnull
.ResourceNotFoundException
- when a certificate issuer withname
doesn't exist in the key vault.HttpRequestException
- ifname
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
- Theissuer
with updated properties.context
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains theupdated issuer
. - Throws:
NullPointerException
- ifissuer
isnull
.ResourceNotFoundException
- when a certificate issuer withname
doesn't exist in the key vault.HttpRequestException
- ifname
is empty string.
-
setContacts
Sets the certificate contacts on the key vault. This operation requires thecertificates/managecontacts
permission.The
LifetimeAction
of typeCertificatePolicyAction.EMAIL_CONTACTS
set on aCertificatePolicy
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 thecertificate 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 thecertificates/managecontacts
permission.The
LifetimeAction
of typeCertificatePolicyAction.EMAIL_CONTACTS
set on aCertificatePolicy
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 thecertificate contacts
in the vault. - Throws:
HttpRequestException
- when a contact information provided is invalid/incomplete.
-
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 thecertificate contacts
in the vault.
-
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(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 thecertificate contacts
in the vault.
-
deleteContacts
Deletes the certificate contacts in the key vault. This operation requires thecertificates/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 deletedcertificate contacts
in the vault.
-
deleteContacts
Deletes the certificate contacts in the key vault. This operation requires thecertificates/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 deletedcertificate contacts
in the vault.
-
deleteCertificateOperation
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 thecertificates/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 withcertificateName
doesn't exist in the key vault.HttpRequestException
- when thecertificateName
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 thecertificates/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
whosevalue
contains thedeleted certificate operation
. - Throws:
ResourceNotFoundException
- when a certificate operation for a certificate withcertificateName
doesn't exist in the key vault.HttpRequestException
- when thecertificateName
is empty string.
-
cancelCertificateOperation
Cancels a certificate creation operation that is already in progress. This operation requires thecertificates/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
whosevalue
contains thecancelled certificate operation
. - Throws:
ResourceNotFoundException
- when a certificate operation for a certificate withname
doesn't exist in the key vault.HttpRequestException
- when thename
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 thecertificates/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
whosevalue
contains thecancelled certificate operation
. - Throws:
ResourceNotFoundException
- when a certificate operation for a certificate withname
doesn't exist in the key vault.HttpRequestException
- when thename
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 thecertificates/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
- whenmergeCertificateOptions
is null.HttpRequestException
- ifmergeCertificateOptions
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 thecertificates/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
whosevalue
contains the merged certificate. - Throws:
NullPointerException
- whenmergeCertificateOptions
is null.HttpRequestException
- ifmergeCertificateOptions
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 thecertificates/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 theimportCertificateOptions
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 thecertificates/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 vaultcontext
- Additional context that is passed through the Http pipeline during the service call.- Returns:
- A
Response
whosevalue
contains theimported certificate
. - Throws:
HttpRequestException
- when theimportCertificateOptions
are invalid.
-