Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -262,39 +262,16 @@ public Response<KeyVaultCertificate> updateCertificatePropertiesWithResponse(Cer
* <p>Deletes the certificate in the Azure Key Vault. Prints out the
* deleted certificate details when a response has been received.</p>
*
* {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.deleteCertificate#string}
* {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.begindeleteCertificate#string}
Comment thread
g2vinay marked this conversation as resolved.
Outdated
*
* @param name The name of the certificate to be deleted.
* @throws ResourceNotFoundException when a certificate with {@code name} doesn't exist in the key vault.
* @throws HttpRequestException when a certificate with {@code name} is empty string.
* @return The {@link DeletedCertificate deleted certificate}.
* @return A {@link SyncPoller} to poll on and retrieve {@link DeletedCertificate deleted certificate}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public DeletedCertificate deleteCertificate(String name) {
return deleteCertificateWithResponse(name, Context.NONE).getValue();
}

/**
* 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.
*
* <p><strong>Code Samples</strong></p>
* <p>Deletes the certificate in the Azure Key Vault. Prints out the
* deleted certificate details when a response has been received.</p>
*
* {@codesnippet com.azure.security.keyvault.certificates.CertificateClient.deleteCertificateWithResponse#String-Context}
*
* @param name The name of the certificate to be deleted.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @throws ResourceNotFoundException when a certificate with {@code name} doesn't exist in the key vault.
* @throws HttpRequestException when a certificate with {@code name} is empty string.
* @return A {@link Response} whose {@link Response#getValue() value} contains the {@link DeletedCertificate deleted certificate}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<DeletedCertificate> deleteCertificateWithResponse(String name, Context context) {
return client.deleteCertificateWithResponse(name, context).block();
public SyncPoller<DeletedCertificate, Void> beginDeleteCertificate(String name) {
return client.beginDeleteCertificate(name).getSyncPoller();
}

/**
Expand Down Expand Up @@ -389,38 +366,16 @@ public Response<Void> purgeDeletedCertificateWithResponse(String name, Context c
* <p>Recovers the deleted certificate from the key vault enabled for soft-delete. Prints out the
* recovered certificate details when a response has been received.</p>

* {@codesnippet com.azure.security.certificatevault.certificates.CertificateClient.recoverDeletedCertificate#string}
* {@codesnippet com.azure.security.certificatevault.certificates.CertificateClient.beginrecoverDeletedCertificate#string}
Comment thread
g2vinay marked this conversation as resolved.
Outdated
*
* @param name The name of the deleted certificate to be recovered.
* @throws ResourceNotFoundException when a certificate with {@code name} doesn't exist in the certificate vault.
* @throws HttpRequestException when a certificate with {@code name} is empty string.
* @return The {@link KeyVaultCertificate recovered certificate}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public KeyVaultCertificate recoverDeletedCertificate(String name) {
return recoverDeletedCertificateWithResponse(name, Context.NONE).getValue();
}

/**
* 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.
*
* <p><strong>Code Samples</strong></p>
* <p>Recovers the deleted certificate from the key vault enabled for soft-delete. Prints out the
* recovered certificate details when a response has been received.</p>

* {@codesnippet com.azure.security.certificatevault.certificates.CertificateClient.recoverDeletedCertificateWithResponse#String-Context}
*
* @param name The name of the deleted certificate to be recovered.
* @param context Additional context that is passed through the Http pipeline during the service call.
* @throws ResourceNotFoundException when a certificate with {@code name} doesn't exist in the certificate vault.
* @throws HttpRequestException when a certificate with {@code name} is empty string.
* @return A {@link Response} whose {@link Response#getValue() value} contains the {@link KeyVaultCertificate recovered certificate}.
* @return A {@link SyncPoller} to poll on and retrieve {@link KeyVaultCertificate recovered certificate}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<KeyVaultCertificate> recoverDeletedCertificateWithResponse(String name, Context context) {
return client.recoverDeletedCertificateWithResponse(name, context).block();
public SyncPoller<KeyVaultCertificate, Void> beginRecoverDeletedCertificate(String name) {
return client.beginRecoverDeletedCertificate(name).getSyncPoller();
}

/**
Expand Down Expand Up @@ -812,7 +767,7 @@ public CertificateIssuer getIssuer(String name) {
* Gets information about the certificate issuer which represents the {@link IssuerProperties} from the key vault. This operation
* requires the certificates/manageissuers/getissuers permission.
*
* <p>The list operations {@link CertificateClient#listIssuers()} return the {@link PagedIterable} containing
* <p>The list operations {@link CertificateClient#listPropertiesOfIssuers()} return the {@link PagedIterable} containing
* {@link IssuerProperties issuerProperties} as output excluding the properties like accountId and organization details of the certificate issuer.
* This operation can then be used to get the full certificate issuer with its properties from {@code issuerProperties}.</p>
*
Expand All @@ -832,7 +787,7 @@ public CertificateIssuer getIssuer(IssuerProperties issuerProperties) {
* Gets information about the certificate issuer which represents the {@link IssuerProperties} from the key vault. This operation
* requires the certificates/manageissuers/getissuers permission.
*
* <p>The list operations {@link CertificateClient#listIssuers()} return the {@link PagedIterable} containing
* <p>The list operations {@link CertificateClient#listPropertiesOfIssuers()} return the {@link PagedIterable} containing
* {@link IssuerProperties issuerProperties} as output excluding the properties like accountId and organization details of the certificate issuer.
* This operation can then be used to get the full certificate issuer with its properties from {@code issuerProperties}.</p>
*
Expand Down Expand Up @@ -904,8 +859,8 @@ public CertificateIssuer deleteIssuer(String name) {
* @return A {@link PagedIterable} containing all of the {@link IssuerProperties certificate issuers} in the vault.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<IssuerProperties> listIssuers() {
return listIssuers(Context.NONE);
public PagedIterable<IssuerProperties> listPropertiesOfIssuers() {
Comment thread
g2vinay marked this conversation as resolved.
return listPropertiesOfIssuers(Context.NONE);
}

/**
Expand All @@ -923,8 +878,8 @@ public PagedIterable<IssuerProperties> listIssuers() {
* @return A {@link PagedIterable} containing all of the {@link IssuerProperties certificate issuers} in the vault.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<IssuerProperties> listIssuers(Context context) {
return new PagedIterable<>(client.listIssuers(context));
public PagedIterable<IssuerProperties> listPropertiesOfIssuers(Context context) {
return new PagedIterable<>(client.listPropertiesOfIssuers(context));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class CertificateRequestAttributes {
if (certificateProperties.getNotBefore() != null) {
this.notBefore = certificateProperties.getNotBefore().toEpochSecond();
}
if (certificateProperties.getExpires() != null) {
this.expires = certificateProperties.getExpires().toEpochSecond();
if (certificateProperties.getExpiresOn() != null) {
this.expires = certificateProperties.getExpiresOn().toEpochSecond();
}
this.enabled = certificateProperties.isEnabled();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ Mono<Response<KeyVaultCertificate>> getCertificate(@HostParam("url") String url,
@HeaderParam("Content-Type") String type,
Context context);

@Get("certificates/{certificate-name}/{certificate-version}")
@ExpectedResponses({200, 404})
@UnexpectedResponseExceptionType(code = {403}, value = ResourceModifiedException.class)
@UnexpectedResponseExceptionType(HttpResponseException.class)
Mono<Response<KeyVaultCertificate>> getCertificatePoller(@HostParam("url") String url,
@PathParam("certificate-name") String certificateName,
@PathParam("certificate-version") String certificateVersion,
@QueryParam("api-version") String apiVersion,
@HeaderParam("accept-language") String acceptLanguage,
@HeaderParam("Content-Type") String type,
Context context);

@Get("certificates/{certificate-name}/{certificate-version}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(code = {404}, value = ResourceNotFoundException.class)
Expand Down Expand Up @@ -181,6 +193,16 @@ Mono<Response<DeletedCertificate>> getDeletedCertificate(@HostParam("url") Strin
@HeaderParam("Content-Type") String type,
Context context);

@Get("deletedcertificates/{certificate-name}")
@ExpectedResponses({200, 404})
@UnexpectedResponseExceptionType(HttpResponseException.class)
Mono<Response<DeletedCertificate>> getDeletedCertificatePoller(@HostParam("url") String url,
@PathParam("certificate-name") String certificateName,
@QueryParam("api-version") String apiVersion,
@HeaderParam("accept-language") String acceptLanguage,
@HeaderParam("Content-Type") String type,
Context context);

@Delete("deletedcertificates/{certificate-name}")
@ExpectedResponses({204})
@UnexpectedResponseExceptionType(code = {404}, value = ResourceNotFoundException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package com.azure.security.keyvault.certificates;

import com.azure.security.keyvault.certificates.models.Administrator;
import com.azure.security.keyvault.certificates.models.AdministratorContact;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;
Expand All @@ -23,7 +23,7 @@ class OrganizationDetails {
* Details of the organization administrator.
*/
@JsonProperty(value = "admin_details")
private List<Administrator> adminDetails;
Comment thread
samvaity marked this conversation as resolved.
private List<AdministratorContact> adminDetails;
Comment thread
g2vinay marked this conversation as resolved.

/**
* Get the id value.
Expand All @@ -50,7 +50,7 @@ OrganizationDetails id(String id) {
*
* @return the adminDetails value
*/
List<Administrator> adminDetails() {
List<AdministratorContact> adminDetails() {
return this.adminDetails;
}

Expand All @@ -60,7 +60,7 @@ List<Administrator> adminDetails() {
* @param adminDetails the adminDetails value to set
* @return the OrganizationDetails object itself.
*/
OrganizationDetails adminDetails(List<Administrator> adminDetails) {
OrganizationDetails adminDetails(List<AdministratorContact> adminDetails) {
this.adminDetails = adminDetails;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Represents an administrator in {@link CertificateIssuer}
*/
public final class Administrator {
public final class AdministratorContact {
/**
* First name.
*/
Expand Down Expand Up @@ -39,7 +39,7 @@ public final class Administrator {
* @param lastName the last name of the issuer.
* @param email the email of the issuer.
*/
public Administrator(String firstName, String lastName, String email) {
public AdministratorContact(String firstName, String lastName, String email) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
Expand All @@ -52,7 +52,7 @@ public Administrator(String firstName, String lastName, String email) {
* @param email the email of the admin.
* @param contact tne contact info of the admin.
*/
public Administrator(String firstName, String lastName, String email, String contact) {
public AdministratorContact(String firstName, String lastName, String email, String contact) {
Comment thread
g2vinay marked this conversation as resolved.
Outdated
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class CertificateIssuer {
/**
* The administrators.
*/
private List<Administrator> administrators;
private List<AdministratorContact> administratorContacts;

/**
* The Issuer properties
Expand Down Expand Up @@ -154,17 +154,17 @@ public CertificateIssuer setOrganizationId(String organizationId) {
* Get the administrators of the isssuer.
* @return the administrators
*/
public List<Administrator> getAdministrators() {
return administrators;
public List<AdministratorContact> getAdministratorContacts() {
return administratorContacts;
}

/**
* Set the administrators of the isssuer.
Comment thread
g2vinay marked this conversation as resolved.
Outdated
* @param administrators the administrators to set.
* @param administratorContacts the administrators to set.
* @return the Issuer object itself.
*/
public CertificateIssuer setAdministrators(List<Administrator> administrators) {
this.administrators = administrators;
public CertificateIssuer setAdministratorContacts(List<AdministratorContact> administratorContacts) {
this.administratorContacts = administratorContacts;
return this;
}

Expand Down Expand Up @@ -211,21 +211,21 @@ private void unpackCredentials(Map<String, Object> credentials) {
@JsonProperty(value = "org_details")
@SuppressWarnings("unchecked")
private void unpacOrganizationalDetails(Map<String, Object> orgDetails) {
Comment thread
g2vinay marked this conversation as resolved.
Outdated
this.administrators = orgDetails.containsKey("admin_details") ? parseAdministrators((List<Object>) orgDetails.get("admin_details")) : null;
this.administratorContacts = orgDetails.containsKey("admin_details") ? parseAdministrators((List<Object>) orgDetails.get("admin_details")) : null;
this.organizationId = (String) orgDetails.get("id");
}

@SuppressWarnings("unchecked")
private List<Administrator> parseAdministrators(List<Object> admins) {
List<Administrator> output = new ArrayList<>();
private List<AdministratorContact> parseAdministrators(List<Object> admins) {
List<AdministratorContact> output = new ArrayList<>();

for (Object admin : admins) {
LinkedHashMap<String, String> map = (LinkedHashMap<String, String>) admin;
String firstName = map.containsKey("first_name") ? map.get("first_name") : "";
String lastName = map.containsKey("last_name") ? map.get("last_name") : "";
String email = map.containsKey("email") ? map.get("email") : "";
String phone = map.containsKey("phone") ? map.get("phone") : "";
output.add(new Administrator(firstName, lastName, email, phone));
output.add(new AdministratorContact(firstName, lastName, email, phone));
}
return output;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ public final class CertificatePolicy {
/**
* Creation time in UTC.
Comment thread
g2vinay marked this conversation as resolved.
*/
private OffsetDateTime created;
private OffsetDateTime createdOn;

/**
* Last updated time in UTC.
*/
private OffsetDateTime updated;
private OffsetDateTime updatedOn;

/**
* Determines whether the object is enabled.
Expand Down Expand Up @@ -277,17 +277,17 @@ public CertificateKeyCurveName getKeyCurveName() {
*
* @return the created UTC time.
*/
public OffsetDateTime getCreated() {
return created;
public OffsetDateTime getCreatedOn() {
return createdOn;
}

/**
* Get the UTC time at which certificate policy was last updated.
*
* @return the last updated UTC time.
*/
public OffsetDateTime getUpdated() {
return updated;
public OffsetDateTime getUpdatedOn() {
return updatedOn;
}


Expand Down Expand Up @@ -576,8 +576,8 @@ private void unpackLifeTimeActions(List<Object> lifetimeActions) {
@JsonProperty("attributes")
private void unpackAttributes(Map<String, Object> attributes) {
this.enabled = (Boolean) attributes.get("enabled");
this.created = epochToOffsetDateTime(attributes.get("created"));
this.updated = epochToOffsetDateTime(attributes.get("updated"));
this.createdOn = epochToOffsetDateTime(attributes.get("created"));
this.updatedOn = epochToOffsetDateTime(attributes.get("updated"));
}

private OffsetDateTime epochToOffsetDateTime(Object epochValue) {
Expand Down
Loading