Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Security Libraries to New Codesnippet Tooling #25441

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions sdk/attestation/azure-resourcemanager-attestation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<legal><![CDATA[[INFO] Any downloads listed may be third party software. Microsoft grants you no rights for third party software.]]></legal>
<codesnippet.skip>false</codesnippet.skip>
<javadocDoclet></javadocDoclet>
<javadocDocletOptions></javadocDocletOptions>
</properties>
<dependencies>
<dependency>
Expand Down
8 changes: 4 additions & 4 deletions sdk/attestation/azure-security-attestation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ Maven dependency for the Azure Attestation library. Add it to your project's PO
- [Azure Subscription][azure_subscription]
- An existing [Azure Attestation][azure_attestation]. If you need to create an attestation instance, you can use the [Azure Cloud Shell][azure_cloud_shell] to create one with this Azure CLI command. Replace `<your-resource-group-name>` and `<your-instance-name>` with your own, unique names:

```bash
az attestation create --resource-group <your-resource-group-name> --name <your-key-vault-name>
```
```bash
az attestation create --resource-group <your-resource-group-name> --name <your-key-vault-name>
```

### Authenticate the client
In order to interact with the Azure Attestation service, your client must present an Azure Active Directory bearer token to the service.

The simplest way of providing a bearer token is to use the `DefaultAzureCredential` authentication method by providing client secret credentials is being used in this getting started section but you can find more ways to authenticate with [azure-identity][azure_identity].
The simplest way of providing a bearer token is to use the `DefaultAzureCredential` authentication method by providing client secret credentials is being used in this getting started section, but you can find more ways to authenticate with [azure-identity][azure_identity].


## Key concepts
Expand Down
3 changes: 3 additions & 0 deletions sdk/attestation/azure-security-attestation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
--add-opens com.azure.security.attestation/com.azure.security.attestation.models=ALL-UNNAMED
--add-opens com.azure.security.attestation/com.azure.security.attestation.models=com.fasterxml.jackson.databind
</javaModulesSurefireArgLine>
<codesnippet.skip>false</codesnippet.skip>
<javadocDoclet></javadocDoclet>
<javadocDocletOptions></javadocDocletOptions>
Comment on lines +43 to +44
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having empty tags seems a bit odd and is done in almost all libraries. Can we invert this pattern where libraries having a non-empty value would override what's in parent pom? (Of course, this might be easier after majority of the libraries have migrated to the new tool)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These empty lines will go away once the codesnippet tooling transition is complete. They're empty as the configuration in the parent POM is to enable the previous codesnippet doclet and this empty configuration disables it.

</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,15 @@ Mono<Response<PolicyResult>> setAttestationPolicyWithResponse(AttestationType at
* which the customer specified.
*
* For an example of how to check the policy token hash:
* {@codesnippet com.azure.security.attestation.AttestationAdministrationAsyncClient.checkPolicyTokenHash}
* <!-- src_embed com.azure.security.attestation.AttestationAdministrationAsyncClient.checkPolicyTokenHash -->
* <pre>
* BinaryData expectedHash = client.calculatePolicyTokenHash&#40;policyToSet, null&#41;;
* BinaryData actualHash = result.getPolicyTokenHash&#40;&#41;;
* if &#40;!expectedHash.equals&#40;actualHash&#41;&#41; &#123;
* throw new RuntimeException&#40;&quot;Policy was set but not received!!!&quot;&#41;;
* &#125;
* </pre>
* <!-- end com.azure.security.attestation.AttestationAdministrationAsyncClient.checkPolicyTokenHash -->
*
* @param policy AttestationPolicy document use in the underlying JWT.
* @param signer Optional signing key used to sign the underlying JWT.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,15 @@ public Response<PolicyResult> setAttestationPolicyWithResponse(AttestationType a
* which the customer specified.
*
* For an example of how to check the policy token hash:
* {@codesnippet com.azure.security.attestation.AttestationAdministrationAsyncClient.checkPolicyTokenHash}
* <!-- src_embed com.azure.security.attestation.AttestationAdministrationAsyncClient.checkPolicyTokenHash -->
* <pre>
* BinaryData expectedHash = client.calculatePolicyTokenHash&#40;policyToSet, null&#41;;
* BinaryData actualHash = result.getPolicyTokenHash&#40;&#41;;
* if &#40;!expectedHash.equals&#40;actualHash&#41;&#41; &#123;
* throw new RuntimeException&#40;&quot;Policy was set but not received!!!&quot;&#41;;
* &#125;
* </pre>
* <!-- end com.azure.security.attestation.AttestationAdministrationAsyncClient.checkPolicyTokenHash -->
*
* @param policy AttestationPolicy document use in the underlying JWT.
* @param signer Optional signing key used to sign the underlying JWT.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ public AttestationAdministrationClientBuilder tokenValidationOptions(Attestation
*
* Instantiating a synchronous Attestation client:
* <br>
* {@codesnippet com.azure.security.attestation.AttestationAdministrationClientBuilder.buildClient}
* <!-- src_embed com.azure.security.attestation.AttestationAdministrationClientBuilder.buildClient -->
* <pre>
* AttestationAdministrationClient client = new AttestationAdministrationClientBuilder&#40;&#41;
* .endpoint&#40;endpoint&#41;
* .buildClient&#40;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.AttestationAdministrationClientBuilder.buildClient -->
* @return an instance of {@link AttestationClient}.
*/
public AttestationAdministrationClient buildClient() {
Expand All @@ -202,7 +208,13 @@ public AttestationAdministrationClient buildClient() {
*
* Instantiating a synchronous Attestation client:
* <br>
* {@codesnippet com.azure.security.attestation.AttestationAdministrationClientBuilder.buildAsyncClient}
* <!-- src_embed com.azure.security.attestation.AttestationAdministrationClientBuilder.buildAsyncClient -->
* <pre>
* AttestationAdministrationAsyncClient asyncClient = new AttestationAdministrationClientBuilder&#40;&#41;
* .endpoint&#40;endpoint&#41;
* .buildAsyncClient&#40;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.AttestationAdministrationClientBuilder.buildAsyncClient -->
* @return an instance of {@link AttestationClient}.
*/
public AttestationAdministrationAsyncClient buildAsyncClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ public final class AttestationAsyncClient {
* Retrieves metadata about the attestation signing keys in use by the attestation service.
*
* <p><strong>Retrieve the OpenID metadata for this async client.</strong></p>
* {@codesnippet com.azure.security.attestation.AttestationAsyncClient.getOpenIdMetadataWithResponse}
* <!-- src_embed com.azure.security.attestation.AttestationAsyncClient.getOpenIdMetadataWithResponse -->
* <pre>
* Mono&lt;Response&lt;AttestationOpenIdMetadata&gt;&gt; response = client.getOpenIdMetadataWithResponse&#40;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.AttestationAsyncClient.getOpenIdMetadataWithResponse -->
*
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
Expand All @@ -191,7 +195,11 @@ Mono<Response<AttestationOpenIdMetadata>> getOpenIdMetadataWithResponse(Context
* Retrieves metadata about the attestation signing keys in use by the attestation service.

* <p><strong>Retrieve the OpenID metadata for this async client.</strong></p>
* {@codesnippet com.azure.security.attestation.AttestationAsyncClient.getOpenIdMetadata}
* <!-- src_embed com.azure.security.attestation.AttestationAsyncClient.getOpenIdMetadata -->
* <pre>
* Mono&lt;AttestationOpenIdMetadata&gt; openIdMetadata = client.getOpenIdMetadata&#40;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.AttestationAsyncClient.getOpenIdMetadata -->
*
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
Expand All @@ -211,7 +219,23 @@ public Mono<AttestationOpenIdMetadata> getOpenIdMetadata() {
* to validate an attestation token returned by the service.
* </p>
* <p><strong>Retrieve Attestation Signers for this async client.</strong></p>
* {@codesnippet com.azure.security.attestation.AttestationAsyncClient.getAttestationSigners}
* <!-- src_embed com.azure.security.attestation.AttestationAsyncClient.getAttestationSigners -->
* <pre>
* Mono&lt;List&lt;AttestationSigner&gt;&gt; signers = client.listAttestationSigners&#40;&#41;;
* signers.block&#40;&#41;.forEach&#40;cert -&gt; &#123;
* System.out.println&#40;&quot;Found certificate.&quot;&#41;;
* if &#40;cert.getKeyId&#40;&#41; != null&#41; &#123;
* System.out.println&#40;&quot; Certificate Key ID: &quot; + cert.getKeyId&#40;&#41;&#41;;
* &#125; else &#123;
* System.out.println&#40;&quot; Signer does not have a Key ID&quot;&#41;;
* &#125;
* cert.getCertificates&#40;&#41;.forEach&#40;chainElement -&gt; &#123;
* System.out.println&#40;&quot; Cert Subject: &quot; + chainElement.getSubjectDN&#40;&#41;.getName&#40;&#41;&#41;;
* System.out.println&#40;&quot; Cert Issuer: &quot; + chainElement.getIssuerDN&#40;&#41;.getName&#40;&#41;&#41;;
* &#125;&#41;;
* &#125;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.AttestationAsyncClient.getAttestationSigners -->
*
* @return Returns an array of {@link AttestationSigner} objects.
*/
Expand All @@ -228,7 +252,11 @@ public Mono<List<AttestationSigner>> listAttestationSigners() {
* to validate an attestation token returned by the service.
* </p>
* <p><strong>Retrieve Attestation Signers for this async client.</strong></p>
* {@codesnippet com.azure.security.attestation.AttestationAsyncClient.getAttestationSignersWithResponse}
* <!-- src_embed com.azure.security.attestation.AttestationAsyncClient.getAttestationSignersWithResponse -->
* <pre>
* Mono&lt;Response&lt;List&lt;AttestationSigner&gt;&gt;&gt; responseOfSigners = client.listAttestationSignersWithResponse&#40;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.AttestationAsyncClient.getAttestationSignersWithResponse -->
*
* @return Returns an array of {@link AttestationSigner} objects.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,13 @@ public AttestationClientBuilder tokenValidationOptions(AttestationTokenValidatio
*
* Instantiating a synchronous Attestation client:
* <br>
* {@codesnippet com.azure.security.attestation.AttestationClientBuilder.buildClient}
* <!-- src_embed com.azure.security.attestation.AttestationClientBuilder.buildClient -->
* <pre>
* AttestationClient client = new AttestationClientBuilder&#40;&#41;
* .endpoint&#40;endpoint&#41;
* .buildClient&#40;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.AttestationClientBuilder.buildClient -->
* @return an instance of {@link AttestationClient}.
*/
public AttestationClient buildClient() {
Expand All @@ -200,7 +206,13 @@ public AttestationClient buildClient() {
*
* Instantiating a synchronous Attestation client:
* <br>
* {@codesnippet com.azure.security.attestation.AttestationClientBuilder.buildAsyncClient}
* <!-- src_embed com.azure.security.attestation.AttestationClientBuilder.buildAsyncClient -->
* <pre>
* AttestationAsyncClient asyncClient = new AttestationClientBuilder&#40;&#41;
* .endpoint&#40;endpoint&#41;
* .buildAsyncClient&#40;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.AttestationClientBuilder.buildAsyncClient -->
* @return an instance of {@link AttestationClient}.
*/
public AttestationAsyncClient buildAsyncClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* The versions of Azure Metrics Advisor supported by this client library.
*/
public enum AttestationServiceVersion implements ServiceVersion {
/**
* Service version {@code 2020-10-01}.
*/
V2020_10_01("2020-10-01");

private final String version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ public final class AttestationOptions {
* The evidence will typically take the form of either an OpenEnclave report or an Intel SGX quote.
*
* <p><strong>Create an AttestationOptions from an SGX quote:</strong></p>
* {@codesnippet com.azure.security.attestation.models..fromEvidence#byte}
* <!-- src_embed com.azure.security.attestation.models..fromEvidence#byte -->
* <pre>
* AttestationOptions options = new AttestationOptions&#40;sgxQuote&#41;;
* </pre>
* <!-- end com.azure.security.attestation.models..fromEvidence#byte -->
* @param evidence to be used in the attest request.
*/
public AttestationOptions(BinaryData evidence) {
Expand Down Expand Up @@ -110,7 +114,12 @@ public BinaryData getEvidence() {
* the {@link AttestationDataInterpretation} specified for the RunTime Data was set to "BINARY", or
*
* <p><strong>Setting RunTime Data Property</strong></p>
* {@codesnippet com.azure.security.attestation.models..setInitTimeData#byte}
* <!-- src_embed com.azure.security.attestation.models..setInitTimeData#byte -->
* <pre>
* AttestationOptions optionsWithInitTimeData = new AttestationOptions&#40;openEnclaveReport&#41;
* .setInitTimeData&#40;new AttestationData&#40;inittimeData, AttestationDataInterpretation.BINARY&#41;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.models..setInitTimeData#byte -->
* @param attestationData the runtimeData value to set.
* @return this {@link AttestationOptions} object itself.
*/
Expand All @@ -122,7 +131,14 @@ public AttestationOptions setRunTimeData(AttestationData attestationData) {
/**
* Retrieves the RunTimeData property to be sent to the service.
* <p><strong>Retrieve the RunTimeData value.</strong></p>
* {@codesnippet com.azure.security.attestation.models.AttestationOptions.getRunTimeData}
* <!-- src_embed com.azure.security.attestation.models.AttestationOptions.getRunTimeData -->
* <pre>
* AttestationOptions attestationOptions = new AttestationOptions&#40;openEnclaveReport&#41;
* .setRunTimeData&#40;new AttestationData&#40;runtimeData, AttestationDataInterpretation.JSON&#41;&#41;;
*
* AttestationData existingRuntimeData = attestationOptions.getRunTimeData&#40;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.models.AttestationOptions.getRunTimeData -->
* @return The RunTimeData value set by {@link AttestationOptions#setRunTimeData}
*/
public AttestationData getRunTimeData() {
Expand All @@ -140,7 +156,12 @@ public AttestationData getRunTimeData() {
* for the {@link AttestationData} is set to "JSON".
*
* <p><strong>Setting InitTime Data Property</strong></p>
* {@codesnippet com.azure.security.attestation.models..setInitTimeData#byte}
* <!-- src_embed com.azure.security.attestation.models..setInitTimeData#byte -->
* <pre>
* AttestationOptions optionsWithInitTimeData = new AttestationOptions&#40;openEnclaveReport&#41;
* .setInitTimeData&#40;new AttestationData&#40;inittimeData, AttestationDataInterpretation.BINARY&#41;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.models..setInitTimeData#byte -->
* @param attestationData the InitTimeData value to set.
* @return this {@link AttestationOptions} object itself.
*/
Expand All @@ -152,7 +173,14 @@ public AttestationOptions setInitTimeData(AttestationData attestationData) {
/**
* Retrieves the InitTimeData property to be sent to the service.
* <p><strong>Retrieve the InitTimeData value.</strong></p>
* {@codesnippet com.azure.security.attestation.models.AttestationOptions.getInitTimeData}
* <!-- src_embed com.azure.security.attestation.models.AttestationOptions.getInitTimeData -->
* <pre>
* AttestationOptions attestationOptions = new AttestationOptions&#40;openEnclaveReport&#41;
* .setInitTimeData&#40;new AttestationData&#40;inittimeData, AttestationDataInterpretation.JSON&#41;&#41;;
*
* AttestationData existingRuntimeData = attestationOptions.getInitTimeData&#40;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.models.AttestationOptions.getInitTimeData -->
* @return The InitTimeData value set by {@link AttestationOptions#setInitTimeData}
*/
public AttestationData getInitTimeData() {
Expand All @@ -165,7 +193,12 @@ public AttestationData getInitTimeData() {
* determine how a proposed attestation policy would affect an attestation token.</p>
* <b><i>Note that the resulting token cannot be validated.</i></b>
* <p><b><i>Example of setting AttestationOptions with a draft policy.</i></b></p>
* {@codesnippet com.azure.security.attestation.models.AttestationOptions.setDraftPolicyForAttestation#String}
* <!-- src_embed com.azure.security.attestation.models.AttestationOptions.setDraftPolicyForAttestation#String -->
* <pre>
* AttestationOptions request = new AttestationOptions&#40;openEnclaveReport&#41;
* .setDraftPolicyForAttestation&#40;&quot;version=1.0; authorizationrules&#123;=&gt; permit&#40;&#41;;&#125;; issuancerules&#123;&#125;;&quot;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.models.AttestationOptions.setDraftPolicyForAttestation#String -->
* @param draftPolicyForAttestation the draftPolicyForAttestation value to set.
* @return this {@link AttestationOptions} object itself.
*/
Expand All @@ -178,7 +211,14 @@ public AttestationOptions setDraftPolicyForAttestation(String draftPolicyForAtte
* Gets the draftPolicyForAttestation property which is used to attest against the draft policy.
*
* <p>Gets the previously set draft policy for attestation.</p>
* {@codesnippet com.azure.security.attestation.models.AttestationOptions.getDraftPolicyForAttestation}
* <!-- src_embed com.azure.security.attestation.models.AttestationOptions.getDraftPolicyForAttestation -->
* <pre>
* AttestationOptions getOptions = new AttestationOptions&#40;openEnclaveReport&#41;
* .setDraftPolicyForAttestation&#40;&quot;version=1.0; authorizationrules&#123;=&gt; permit&#40;&#41;;&#125;; issuancerules&#123;&#125;;&quot;&#41;;
*
* String draftPolicy = getOptions.getDraftPolicyForAttestation&#40;&#41;;
* </pre>
* <!-- end com.azure.security.attestation.models.AttestationOptions.getDraftPolicyForAttestation -->
* @return The draft policy if set.
*/
public String getDraftPolicyForAttestation() {
Expand Down
Loading