Skip to content

Commit 195eac9

Browse files
Complete the Attestation Administration APIs. (Azure#25480)
* Complete policy management management APIs * Removed a bunch of dead code; cleaned up some comments * Use Options for Set policy management certificates * Mandatory parameters are now ctor parameters for PolicyManagementCertificateOptions object
1 parent 628ffe8 commit 195eac9

File tree

151 files changed

+1989
-2597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+1989
-2597
lines changed

sdk/attestation/azure-security-attestation/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ be introduced later.)
4545
design guidelines.
4646
* Removed `buildPolicyClient`, `buildPolicyAsyncClient`, `buildPolicyCertificatesClient` and `buildPolicyCertificatesAsyncClient` methods
4747
on the `AttestationClientBuilder` class and implemented a new `AttestationAdministrationClient` class which contains the administrative APIs.
48+
* Removed `buildPolicyCertificatesClient` and `buildPolicyCertificatesAsyncClient`, and `PolicyCertificatesClient` and `PolicyCertificatesAsyncClient` replacing the functionality
49+
with the `listPolicyManagementCertificates`, `addPolicyManagementCertificate` and `removePolicyManagementCertificate` APIs on the `AttestationAdministrationClient` object.
50+
* Removed `JsonWebKey`, `JsonWebKeySet`, `PolicyCertificatesModificationResult`, `PolicyCertificatesModifyResponse`, and `CertificatesResponse` objects
51+
because they are no longer a part of the public API surface.
4852

4953
### Bugs Fixed
5054
* Attestation tests now all pass when run in Live mode.

sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAdministrationAsyncClient.java

Lines changed: 286 additions & 19 deletions
Large diffs are not rendered by default.

sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAdministrationClient.java

Lines changed: 129 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@
1212
import com.azure.core.util.Context;
1313
import com.azure.security.attestation.models.AttestationPolicySetOptions;
1414
import com.azure.security.attestation.models.AttestationResponse;
15+
import com.azure.security.attestation.models.AttestationSigner;
1516
import com.azure.security.attestation.models.AttestationSigningKey;
17+
import com.azure.security.attestation.models.AttestationTokenValidationOptions;
1618
import com.azure.security.attestation.models.AttestationType;
19+
import com.azure.security.attestation.models.PolicyCertificatesModificationResult;
20+
import com.azure.security.attestation.models.PolicyManagementCertificateOptions;
1721
import com.azure.security.attestation.models.PolicyResult;
1822

23+
import java.util.List;
24+
1925
/**
2026
*
2127
* The AttestationAdministrationClient provides access to the administrative policy APIs
@@ -58,7 +64,7 @@ public final class AttestationAdministrationClient {
5864
*
5965
* <p>
6066
* <b>NOTE:</b>
61-
* The {@link AttestationAdministrationClient#getAttestationPolicyWithResponse(AttestationType, Context)} API returns the underlying
67+
* The {@link AttestationAdministrationClient#getAttestationPolicyWithResponse(AttestationType, AttestationTokenValidationOptions, Context)} API returns the underlying
6268
* attestation policy specified by the user. This is NOT the full attestation policy maintained by
6369
* the attestation service. Specifically it does not include the signing certificates used to verify the attestation
6470
* policy.
@@ -73,15 +79,16 @@ public final class AttestationAdministrationClient {
7379
* </p>
7480
*
7581
* @param attestationType Specifies the trusted execution environment whose policy should be retrieved.
82+
* @param validationOptions Options used when validating the token returned by the attestation service.
7683
* @param context Context for the operation.
7784
* @throws IllegalArgumentException thrown if parameters fail the validation.
7885
* @throws HttpResponseException thrown if the request is rejected by server.
7986
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
8087
* @return the attestation policy expressed as a string.
8188
*/
8289
@ServiceMethod(returns = ReturnType.SINGLE)
83-
public Response<String> getAttestationPolicyWithResponse(AttestationType attestationType, Context context) {
84-
return asyncClient.getAttestationPolicyWithResponse(attestationType, context).block();
90+
public Response<String> getAttestationPolicyWithResponse(AttestationType attestationType, AttestationTokenValidationOptions validationOptions, Context context) {
91+
return asyncClient.getAttestationPolicyWithResponse(attestationType, validationOptions, context).block();
8592
}
8693

8794
/**
@@ -94,7 +101,7 @@ public Response<String> getAttestationPolicyWithResponse(AttestationType attesta
94101
* policy.
95102
* </p>
96103
* <p>
97-
* To retrieve the signing certificates used to sign the policy, use the {@link AttestationAdministrationClient#getAttestationPolicyWithResponse(AttestationType, Context)} API.
104+
* To retrieve the signing certificates used to sign the policy, use the {@link AttestationAdministrationClient#getAttestationPolicyWithResponse(AttestationType, AttestationTokenValidationOptions, Context)} API.
98105
* The {@link Response} object is an instance of an {@link com.azure.security.attestation.models.AttestationResponse} object
99106
* and the caller can retrieve the full information maintained by the service by calling the {@link AttestationResponse#getToken()} method.
100107
* The returned {@link com.azure.security.attestation.models.AttestationToken} object will be
@@ -247,4 +254,122 @@ public Response<PolicyResult> resetAttestationPolicyWithResponse(AttestationType
247254
}
248255

249256
// endregion
257+
258+
/**
259+
* Retrieves the current set of attestation policy signing certificates for this instance.
260+
*
261+
* <p>
262+
* On an Isolated attestation instance, each {@link AttestationAdministrationAsyncClient#setAttestationPolicy(AttestationType, AttestationPolicySetOptions)}
263+
* or {@link AttestationAdministrationAsyncClient#resetAttestationPolicy(AttestationType, AttestationPolicySetOptions)} API call
264+
* must be signed with the private key corresponding to one of the certificates in the list returned
265+
* by this API.
266+
*</p>
267+
* <p>
268+
* This establishes that the sender is in possession of the private key associated with the
269+
* configured attestation policy management certificates, and thus the sender is authorized
270+
* to perform the API operation.
271+
* </p>
272+
*
273+
* @param tokenValidationOptions Options to be used validating the token returned by the attestation service.
274+
* @param context Context for the operation.
275+
* @throws IllegalArgumentException thrown if parameters fail the validation.
276+
* @throws HttpResponseException thrown if the request is rejected by server.
277+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
278+
* @return the attestation policy expressed as a string.
279+
*/
280+
@ServiceMethod(returns = ReturnType.SINGLE)
281+
public Response<List<AttestationSigner>> listPolicyManagementCertificatesWithResponse(AttestationTokenValidationOptions tokenValidationOptions, Context context) {
282+
return asyncClient.listPolicyManagementCertificatesWithResponse(tokenValidationOptions, context).block();
283+
}
284+
285+
/**
286+
/**
287+
* Retrieves the current set of attestation policy signing certificates for this instance.
288+
*
289+
* <p>
290+
* On an Isolated attestation instance, each {@link AttestationAdministrationAsyncClient#setAttestationPolicy(AttestationType, AttestationPolicySetOptions)}
291+
* or {@link AttestationAdministrationAsyncClient#resetAttestationPolicy(AttestationType, AttestationPolicySetOptions)} API call
292+
* must be signed with the private key corresponding to one of the certificates in the list returned
293+
* by this API.
294+
* </p>
295+
* <p>
296+
* This establishes that the sender is in possession of the private key associated with the
297+
* configured attestation policy management certificates, and thus the sender is authorized
298+
* to perform the API operation.
299+
* </p>
300+
*
301+
*
302+
* @throws IllegalArgumentException thrown if parameters fail the validation.
303+
* @throws HttpResponseException thrown if the request is rejected by server.
304+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
305+
* @return the response to an attestation policy operation.
306+
*/
307+
@ServiceMethod(returns = ReturnType.SINGLE)
308+
public List<AttestationSigner> listPolicyManagementCertificates() {
309+
return asyncClient.listPolicyManagementCertificates().block();
310+
}
311+
312+
/**
313+
* Adds a new attestation policy certificate to the set of policy management certificates.
314+
*
315+
* @param options Options for this API call, encapsulating both the X.509 certificate to add to the set of policy
316+
* signing certificates and the signing key used to sign the request to the service.
317+
* @throws IllegalArgumentException thrown if parameters fail the validation.
318+
* @throws HttpResponseException thrown if the request is rejected by server.
319+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
320+
* @return the response to an attestation policy operation.
321+
*/
322+
@ServiceMethod(returns = ReturnType.SINGLE)
323+
public PolicyCertificatesModificationResult addPolicyManagementCertificate(PolicyManagementCertificateOptions options) {
324+
return asyncClient.addPolicyManagementCertificate(options).block();
325+
}
326+
327+
/**
328+
* Adds a new attestation policy certificate to the set of policy management certificates.
329+
*
330+
* @param options Options for this API call, encapsulating both the X.509 certificate to add to the set of policy
331+
* signing certificates and the signing key used to sign the request to the service.
332+
* @param context Context for the operation.
333+
* @throws IllegalArgumentException thrown if parameters fail the validation.
334+
* @throws HttpResponseException thrown if the request is rejected by server.
335+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
336+
* @return the response to an attestation policy operation.
337+
*/
338+
@ServiceMethod(returns = ReturnType.SINGLE)
339+
public Response<PolicyCertificatesModificationResult> addPolicyManagementCertificateWithResponse(PolicyManagementCertificateOptions options, Context context) {
340+
return asyncClient.addPolicyManagementCertificateWithResponse(options, context).block();
341+
}
342+
343+
/**
344+
* Adds a new attestation policy certificate to the set of policy management certificates.
345+
*
346+
* @param options Options for this API call, encapsulating both the X.509 certificate to remove from the set of policy
347+
* signing certificates and the signing key used to sign the request to the service.
348+
* @throws IllegalArgumentException thrown if parameters fail the validation.
349+
* @throws HttpResponseException thrown if the request is rejected by server.
350+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
351+
* @return the response to an attestation policy operation.
352+
*/
353+
@ServiceMethod(returns = ReturnType.SINGLE)
354+
public PolicyCertificatesModificationResult removePolicyManagementCertificate(PolicyManagementCertificateOptions options) {
355+
return asyncClient.removePolicyManagementCertificate(options).block();
356+
}
357+
358+
/**
359+
* Adds a new attestation policy certificate to the set of policy management certificates.
360+
*
361+
* @param options Options for this API call, encapsulating both the X.509 certificate to remove from the set of policy
362+
* signing certificates and the signing key used to sign the request to the service.
363+
* @param context Context for the operation.
364+
* @throws IllegalArgumentException thrown if parameters fail the validation.
365+
* @throws HttpResponseException thrown if the request is rejected by server.
366+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
367+
* @return the response to an attestation policy operation.
368+
*/
369+
@ServiceMethod(returns = ReturnType.SINGLE)
370+
public Response<PolicyCertificatesModificationResult> removePolicyManagementCertificateWithResponse(PolicyManagementCertificateOptions options, Context context) {
371+
return asyncClient.removePolicyManagementCertificateWithResponse(options, context).block();
372+
}
373+
374+
250375
};

sdk/attestation/azure-security-attestation/src/main/java/com/azure/security/attestation/AttestationAdministrationClientBuilder.java

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,62 @@
1616
import com.azure.core.util.serializer.SerializerAdapter;
1717
import com.azure.security.attestation.implementation.AttestationClientImpl;
1818
import com.azure.security.attestation.implementation.AttestationClientImplBuilder;
19+
import com.azure.security.attestation.models.AttestationPolicySetOptions;
1920
import com.azure.security.attestation.models.AttestationTokenValidationOptions;
21+
import com.azure.security.attestation.models.AttestationType;
2022

2123
import java.net.MalformedURLException;
2224
import java.net.URL;
2325
import java.util.Objects;
2426

25-
/** A builder for creating a new instance of the AttestationClient type. */
27+
/**
28+
* A builder for creating a new instance of the AttestationClient type.
29+
*
30+
* The AttestationAdministrationClient provides access to the administrative policy APIs
31+
* implemented by the Attestation Service.
32+
* <p>
33+
* More information on attestation policies can be found <a href='https://docs.microsoft.com/azure/attestation/basic-concepts#attestation-policy'>here</a>
34+
* </p>
35+
*
36+
* There are two main families of APIs available from the Administration client.
37+
* <ul>
38+
* <li>Attestation Policy Management</li>
39+
* <li>Policy Management Certificate Management</li>
40+
* </ul>
41+
*
42+
* The Policy Management APIs provide the ability to retrieve, modify and reset attestation policies.
43+
* The policy management APIs are:
44+
* <ul>
45+
* <li>
46+
* {@link AttestationAdministrationClient#getAttestationPolicy(AttestationType)}
47+
* </li>
48+
* <li>
49+
* {@link AttestationAdministrationAsyncClient#getAttestationPolicy(AttestationType)}
50+
* </li>
51+
* <li>
52+
* {@link AttestationAdministrationClient#setAttestationPolicy(AttestationType, AttestationPolicySetOptions)}
53+
* </li>
54+
* <li>
55+
* {@link AttestationAdministrationAsyncClient#setAttestationPolicy(AttestationType, AttestationPolicySetOptions)}
56+
* </li>
57+
* <li>
58+
* {@link AttestationAdministrationClient#resetAttestationPolicy(AttestationType, AttestationPolicySetOptions)}
59+
* </li>
60+
* <li>
61+
* {@link AttestationAdministrationAsyncClient#resetAttestationPolicy(AttestationType, AttestationPolicySetOptions)}
62+
* </li>
63+
* </ul>
64+
* <p>
65+
* The Policy Management Certificate APIs provide the ability to manage the certificates which are
66+
* used to establish authorization for Isolated mode attestation service instances. They include apis to
67+
* enumerate, add and remove policy management certificates.
68+
* </p>
69+
*
70+
*/
2671
@ServiceClientBuilder(
2772
serviceClients = {
2873
AttestationAdministrationClient.class,
2974
AttestationAdministrationAsyncClient.class,
30-
PolicyCertificatesClient.class,
31-
PolicyCertificatesAsyncClient.class,
3275
})
3376
public final class AttestationAdministrationClientBuilder {
3477
private static final String SDK_NAME = "name";
@@ -239,23 +282,4 @@ private AttestationClientImpl buildInnerClient() {
239282
}
240283
return clientImplBuilder.buildClient();
241284
}
242-
243-
/**
244-
* Builds an instance of PolicyCertificatesAsyncClient async client.
245-
*
246-
* @return an instance of PolicyCertificatesAsyncClient.
247-
*/
248-
public PolicyCertificatesAsyncClient buildPolicyCertificatesAsyncClient() {
249-
return new PolicyCertificatesAsyncClient(buildInnerClient().getPolicyCertificates());
250-
}
251-
252-
/**
253-
* Builds an instance of PolicyCertificatesClient sync client.
254-
*
255-
* @return an instance of PolicyCertificatesClient.
256-
*/
257-
public PolicyCertificatesClient buildPolicyCertificatesClient() {
258-
return new PolicyCertificatesClient(buildInnerClient().getPolicyCertificates());
259-
}
260-
261285
}

0 commit comments

Comments
 (0)