Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
23 changes: 15 additions & 8 deletions sdk/keyvault/azure-security-keyvault-certificates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,16 @@ System.out.printf("Updated Certificate with name %s and enabled status %s", upda

### Delete a Certificate

Delete an existing Certificate by calling `deleteCertificate`.
Delete an existing Certificate by calling `beginDeleteCertificate`.

```Java
DeletedCertificate deletedCertificate = certificateClient.deleteCertificate("certificateName");
System.out.printf("Deleted certificate with name %s and recovery id %s", deletedCertificate.getName(),
deletedCertificate.getRecoveryId());
SyncPoller<DeletedCertificate, Void> deletedCertificatePoller =
Comment thread
g2vinay marked this conversation as resolved.
Outdated
certificateClient.beginDeleteCertificate("certificateName");
// Deleted Certificate is accessible as soon as polling beings.
PollResponse<DeletedCertificate> pollResponse = deletedCertificatePoller.poll();
System.out.printf("Deleted certitifcate with name %s and recovery id %s", pollResponse.getValue().getName(),
pollResponse.getValue().getRecoveryId());
deletedCertificatePoller.waitForCompletion();
```

### List Certificates
Comment thread
g2vinay marked this conversation as resolved.
Expand Down Expand Up @@ -301,12 +305,15 @@ certificateAsyncClient.getCertificate("certificateName")

### Delete a Certificate Asynchronously

Delete an existing Certificate by calling `deleteCertificate`.
Delete an existing Certificate by calling `beginDeleteCertificate`.

```java
certificateAsyncClient.deleteCertificate("certificateName")
.subscribe(deletedSecretResponse ->
System.out.printf("Deleted Certificate's Recovery Id %s \n", deletedSecretResponse.getRecoveryId()));
certificateAsyncClient.beginDeleteCertificate("certificateName")
.subscribe(pollResponse -> {
System.out.println("Delete Status: " + pollResponse.getStatus().toString());
System.out.println("Delete Certificate Name: " + pollResponse.getValue().getName());
System.out.println("Certificate Delete Date: " + pollResponse.getValue().getDeletedOn().toString());
});
```

### List Certificates Asynchronously
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import com.azure.core.util.CoreUtils;
import com.azure.core.util.Configuration;
import com.azure.core.util.logging.ClientLogger;
import com.azure.security.keyvault.certificates.implementation.KeyVaultCredentialPolicy;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package com.azure.security.keyvault.certificates;

import com.azure.security.keyvault.certificates.models.CertificateImportOptions;
import com.azure.security.keyvault.certificates.models.ImportCertificateOptions;
import com.azure.security.keyvault.certificates.models.CertificateProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

Expand All @@ -25,14 +25,14 @@ 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();
}

CertificateRequestAttributes(CertificateImportOptions certificateImportOptions) {
this.enabled = certificateImportOptions.isEnabled();
CertificateRequestAttributes(ImportCertificateOptions importCertificateOptions) {
this.enabled = importCertificateOptions.isEnabled();
}

CertificateRequestAttributes() {
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 Expand Up @@ -233,6 +255,7 @@ Mono<Response<KeyVaultCertificate>> restoreCertificate(@HostParam("url") String
@ReturnValueWireType(DeletedCertificatePage.class)
Mono<PagedResponse<DeletedCertificate>> getDeletedCertificates(@HostParam("url") String url,
@QueryParam("maxresults") Integer maxresults,
@QueryParam("includePending") Boolean includePending,
@QueryParam("api-version") String apiVersion,
@HeaderParam("accept-language") String acceptLanguage,
@HeaderParam("Content-Type") String type,
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
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.security.keyvault.certificates;

import com.azure.security.keyvault.certificates.models.CertificatePolicy;
import com.azure.security.keyvault.certificates.models.MergeCertificateOptions;

/**
* Represents well known issuer names to refer in {@link CertificatePolicy}
*/
public class WellKnownIssuerNames {

/**
* Create a self-issued certificate.
*/
public static final String SELF = "Self";


/**
* Creates a certificate that requires merging an external X.509 certificate using
* {@link CertificateClient#mergeCertificate(MergeCertificateOptions)} or
* {@link CertificateAsyncClient#mergeCertificate(MergeCertificateOptions)}.
*/
public static final String UNKNOWN = "Unknown";

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.security.keyvault.certificates;
package com.azure.security.keyvault.certificates.implementation;

import com.azure.core.credential.TokenCredential;
import com.azure.core.credential.TokenRequestContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.security.keyvault.certificates;
package com.azure.security.keyvault.certificates.implementation;

import com.azure.core.credential.AccessToken;
import com.azure.core.credential.TokenRequestContext;
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 All @@ -31,15 +31,15 @@ public final class Administrator {
* Phone number.
*/
@JsonProperty(value = "phone")
private String contact;
private String phone;

/**
* Creates an administrator of the issuer.
* @param firstName the firstName of the issuer.
* @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 @@ -50,13 +50,13 @@ public Administrator(String firstName, String lastName, String email) {
* @param firstName the firstName of the admin.
* @param lastName the last name of the admin.
* @param email the email of the admin.
* @param contact tne contact info of the admin.
* @param phone tne contact info of the admin.
Comment thread
g2vinay marked this conversation as resolved.
Outdated
*/
public Administrator(String firstName, String lastName, String email, String contact) {
public AdministratorContact(String firstName, String lastName, String email, String phone) {
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
this.contact = contact;
this.phone = phone;
}

/**
Expand Down Expand Up @@ -87,7 +87,7 @@ public String getEmail() {
* Get the contact of the admin.
* @return the contact of admin.
*/
public String getContact() {
return contact;
public String getPhone() {
return phone;
}
}
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 @@ -97,15 +97,15 @@ public String getName() {
}

/**
* Get the account id of the isssuer.
* Get the account id of the issuer.
* @return the account id
*/
public String getAccountId() {
return accountId;
}

/**
* Set the account id of the isssuer.
* Set the account id of the issuer.
* @param accountId the account id to set.
* @return the Issuer object itself.
*/
Expand All @@ -115,15 +115,15 @@ public CertificateIssuer setAccountId(String accountId) {
}

/**
* Get the password of the isssuer.
* Get the password of the issuer.
* @return the password
*/
public String getPassword() {
return password;
}

/**
* Set the password id of the isssuer.
* Set the password id of the issuer.
* @param password the password set.
* @return the Issuer object itself.
*/
Expand All @@ -133,7 +133,7 @@ public CertificateIssuer setPassword(String password) {
}

/**
* Get the organization id of the isssuer.
* Get the organization id of the issuer.
* @return the organization id
*/
public String getOrganizationId() {
Expand All @@ -151,20 +151,20 @@ public CertificateIssuer setOrganizationId(String organizationId) {
}

/**
* Get the administrators of the isssuer.
* Get the administrators of the issuer.
* @return the administrators
*/
public List<Administrator> getAdministrators() {
return administrators;
public List<AdministratorContact> getAdministratorContacts() {
return administratorContacts;
}

/**
* Set the administrators of the isssuer.
* @param administrators the administrators to set.
* Set the administrators of the issuer.
* @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 @@ -210,22 +210,22 @@ private void unpackCredentials(Map<String, Object> credentials) {

@JsonProperty(value = "org_details")
@SuppressWarnings("unchecked")
private void unpacOrganizationalDetails(Map<String, Object> orgDetails) {
this.administrators = orgDetails.containsKey("admin_details") ? parseAdministrators((List<Object>) orgDetails.get("admin_details")) : null;
private void unpackOrganizationalDetails(Map<String, Object> orgDetails) {
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 @@ -64,7 +64,7 @@ public final class CertificateOperation {
* Error encountered, if any, during the certificate operation.
*/
@JsonProperty(value = "error")
private Error error;
private CertificateOperationError error;

/**
* Location which contains the result of the certificate operation.
Expand Down Expand Up @@ -155,7 +155,7 @@ public String getStatusDetails() {
*
* @return the error
*/
public Error getError() {
public CertificateOperationError getError() {
return this.error;
}

Expand Down
Loading