diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index e1fcaad967a2..2213d1d1e593 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -190,6 +190,7 @@ com.azure:azure-template-perf;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-verticals-agrifood-farming;1.0.0-beta.3;1.0.0-beta.4 com.azure:azure-xml;1.0.0-beta.2;1.0.0-beta.3 com.azure:perf-test-core;1.0.0-beta.1;1.0.0-beta.1 +com.azure:com.azure.developer.signing;1.0.0-beta.1;1.0.0-beta.1 com.azure.spring:azure-monitor-spring-native;1.0.0-beta.1;1.0.0-beta.1 com.azure.spring:azure-monitor-spring-native-test;1.0.0-beta.1;1.0.0-beta.1 com.azure.spring:spring-cloud-azure-appconfiguration-config-web;4.11.0;4.12.0-beta.1 diff --git a/pom.xml b/pom.xml index 2933b7b5264a..40bb58f4397d 100644 --- a/pom.xml +++ b/pom.xml @@ -39,6 +39,7 @@ sdk/botservice sdk/changeanalysis sdk/chaos + sdk/codesigning sdk/cognitiveservices sdk/commerce sdk/communication diff --git a/sdk/codesigning/ci.yml b/sdk/codesigning/ci.yml new file mode 100644 index 000000000000..143b9b37a1f0 --- /dev/null +++ b/sdk/codesigning/ci.yml @@ -0,0 +1,47 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/codesigning/ci.yml + - sdk/codesigning/com.azure.developer.signing/ + exclude: + - sdk/codesigning/pom.xml + - sdk/codesigning/com.azure.developer.signing/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/codesigning/ci.yml + - sdk/codesigning/com.azure.developer.signing/ + exclude: + - sdk/codesigning/pom.xml + - sdk/codesigning/com.azure.developer.signing/pom.xml + +parameters: + - name: release_com.azure.developer.signing + displayName: com.azure.developer.signing + type: boolean + default: true + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: codesigning + EnableBatchRelease: true + Artifacts: + - name: com.azure.developer.signing + groupId: com.azure + safeName: com.azure.developer.signing + releaseInBatch: ${{ parameters.release_com.azure.developer.signing }} diff --git a/sdk/codesigning/com.azure.developer.signing/CHANGELOG.md b/sdk/codesigning/com.azure.developer.signing/CHANGELOG.md new file mode 100644 index 000000000000..11996c823ec9 --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/CHANGELOG.md @@ -0,0 +1,13 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +- Azure Signing client library for Java. This package contains Microsoft Azure Signing client library. + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/codesigning/com.azure.developer.signing/README.md b/sdk/codesigning/com.azure.developer.signing/README.md new file mode 100644 index 000000000000..f37a3ac5101f --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/README.md @@ -0,0 +1,65 @@ +# Azure Signing client library for Java + +Azure Signing client library for Java. + +This package contains Microsoft Azure Signing client library. + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] +- [Product documentation][product_documentation] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure:azure-developer-signing;current}) +```xml + + com.azure + azure-developer-signing + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Authentication + +[Azure Identity][azure_identity] package provides the default implementation for authenticating the client. + +## Key concepts + +## Examples + +```java azure.developer.signing.readme +``` + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[product_documentation]: https://azure.microsoft.com/services/ +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://docs.microsoft.com/java/azure/jdk/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fcodesigning%2Fcom.azure.developer.signing%2FREADME.png) diff --git a/sdk/codesigning/com.azure.developer.signing/assets.json b/sdk/codesigning/com.azure.developer.signing/assets.json new file mode 100644 index 000000000000..a49bdc1dbe51 --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo" : "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath" : "java", + "TagPrefix" : "java/codesigning/azure-developer-signing", + "Tag" : "" +} \ No newline at end of file diff --git a/sdk/codesigning/com.azure.developer.signing/pom.xml b/sdk/codesigning/com.azure.developer.signing/pom.xml new file mode 100644 index 000000000000..e15b651b4184 --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure + azure-developer-signing + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Signing + This package contains Microsoft Azure Signing client library. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + + + + com.azure + azure-core + 1.44.0 + + + com.azure + azure-core-http-netty + 1.13.8 + + + org.junit.jupiter + junit-jupiter-api + 5.9.3 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.9.3 + test + + + org.mockito + mockito-core + 4.11.0 + test + + + com.azure + azure-core-test + 1.21.0 + test + + + com.azure + azure-identity + 1.10.3 + test + + + org.slf4j + slf4j-simple + 1.7.36 + test + + + com.azure + azure-core-experimental + 1.0.0-beta.44 + + + diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/SigningAsyncClient.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/SigningAsyncClient.java new file mode 100644 index 000000000000..1fb75867cd7c --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/SigningAsyncClient.java @@ -0,0 +1,265 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package azure.developer.signing; + +import azure.developer.signing.implementation.SigningClientImpl; +import azure.developer.signing.models.ExtendedKeyUsage; +import azure.developer.signing.models.SignResult; +import azure.developer.signing.models.SigningPayloadOptions; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import java.util.stream.Collectors; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the asynchronous SigningClient type. */ +@ServiceClient(builder = SigningClientBuilder.class, isAsync = true) +public final class SigningAsyncClient { + @Generated private final SigningClientImpl serviceClient; + + /** + * Initializes an instance of SigningAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SigningAsyncClient(SigningClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Gets the signing root certificate on the certificate chain for that account and profile name. + * + *

The root certificate is generated as part of the initial account creation and it is used to sign the bits for + * the profile provided. + * + *

Response Body Schema + * + *

{@code
+     * BinaryData
+     * }
+ * + * @param accountName Signing account name. + * @param certificateProfile Signing Certificate profile name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getSignRootCertificateWithResponse( + String accountName, String certificateProfile, RequestOptions requestOptions) { + return this.serviceClient.getSignRootCertificateWithResponseAsync( + accountName, certificateProfile, requestOptions); + } + + /** + * Gets a list of extended key usage object identifiers that are allowed for this account and profile combination. + * + *

The list of extended key usages are used to determine the purpose of the certificate usage as part of the + * signing operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     eku: String (Required)
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExtendedKeyUsage items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listExtendedKeyUsages( + String accountName, String certificateProfile, RequestOptions requestOptions) { + return this.serviceClient.listExtendedKeyUsagesAsync(accountName, certificateProfile, requestOptions); + } + + /** + * Submit a sign operation. + * + *

Submit a sign operation under the created account and profile name provided. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     signatureAlgorithm: String(RS256/RS384/RS512/PS256/PS384/PS512/ES256/ES384/ES512/ES256K) (Required)
+     *     digest: byte[] (Required)
+     *     fileHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     *     authenticodeHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param signingPayloadOptions The artifact request information to be signed by the service. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginSign( + String accountName, + String certificateProfile, + BinaryData signingPayloadOptions, + RequestOptions requestOptions) { + return this.serviceClient.beginSignAsync( + accountName, certificateProfile, signingPayloadOptions, requestOptions); + } + + /** + * Gets the signing root certificate on the certificate chain for that account and profile name. + * + *

The root certificate is generated as part of the initial account creation and it is used to sign the bits for + * the profile provided. + * + * @param accountName Signing account name. + * @param certificateProfile Signing Certificate profile name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getSignRootCertificate(String accountName, String certificateProfile) { + // Generated convenience method for getSignRootCertificateWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getSignRootCertificateWithResponse(accountName, certificateProfile, requestOptions) + .flatMap(FluxUtil::toMono); + } + + /** + * Gets a list of extended key usage object identifiers that are allowed for this account and profile combination. + * + *

The list of extended key usages are used to determine the purpose of the certificate usage as part of the + * signing operation. + * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ExtendedKeyUsage items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listExtendedKeyUsages(String accountName, String certificateProfile) { + // Generated convenience method for listExtendedKeyUsages + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = + listExtendedKeyUsages(accountName, certificateProfile, requestOptions); + return PagedFlux.create( + () -> + (continuationToken, pageSize) -> { + Flux> flux = + (continuationToken == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationToken).take(1); + return flux.map( + pagedResponse -> + new PagedResponseBase( + pagedResponse.getRequest(), + pagedResponse.getStatusCode(), + pagedResponse.getHeaders(), + pagedResponse.getValue().stream() + .map( + protocolMethodData -> + protocolMethodData.toObject( + ExtendedKeyUsage.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), + null)); + }); + } + + /** + * Submit a sign operation. + * + *

Submit a sign operation under the created account and profile name provided. + * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param signingPayloadOptions The artifact request information to be signed by the service. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginSign( + String accountName, String certificateProfile, SigningPayloadOptions signingPayloadOptions) { + // Generated convenience method for beginSignWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginSignWithModelAsync( + accountName, certificateProfile, BinaryData.fromObject(signingPayloadOptions), requestOptions); + } +} diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/SigningClient.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/SigningClient.java new file mode 100644 index 000000000000..fb1e3b690f75 --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/SigningClient.java @@ -0,0 +1,235 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package azure.developer.signing; + +import azure.developer.signing.implementation.SigningClientImpl; +import azure.developer.signing.models.ExtendedKeyUsage; +import azure.developer.signing.models.SignResult; +import azure.developer.signing.models.SigningPayloadOptions; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.polling.SyncPoller; + +/** Initializes a new instance of the synchronous SigningClient type. */ +@ServiceClient(builder = SigningClientBuilder.class) +public final class SigningClient { + @Generated private final SigningClientImpl serviceClient; + + /** + * Initializes an instance of SigningClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + SigningClient(SigningClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Gets the signing root certificate on the certificate chain for that account and profile name. + * + *

The root certificate is generated as part of the initial account creation and it is used to sign the bits for + * the profile provided. + * + *

Response Body Schema + * + *

{@code
+     * BinaryData
+     * }
+ * + * @param accountName Signing account name. + * @param certificateProfile Signing Certificate profile name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getSignRootCertificateWithResponse( + String accountName, String certificateProfile, RequestOptions requestOptions) { + return this.serviceClient.getSignRootCertificateWithResponse(accountName, certificateProfile, requestOptions); + } + + /** + * Gets a list of extended key usage object identifiers that are allowed for this account and profile combination. + * + *

The list of extended key usages are used to determine the purpose of the certificate usage as part of the + * signing operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     eku: String (Required)
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExtendedKeyUsage items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listExtendedKeyUsages( + String accountName, String certificateProfile, RequestOptions requestOptions) { + return this.serviceClient.listExtendedKeyUsages(accountName, certificateProfile, requestOptions); + } + + /** + * Submit a sign operation. + * + *

Submit a sign operation under the created account and profile name provided. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     signatureAlgorithm: String(RS256/RS384/RS512/PS256/PS384/PS512/ES256/ES384/ES512/ES256K) (Required)
+     *     digest: byte[] (Required)
+     *     fileHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     *     authenticodeHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param signingPayloadOptions The artifact request information to be signed by the service. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginSign( + String accountName, + String certificateProfile, + BinaryData signingPayloadOptions, + RequestOptions requestOptions) { + return this.serviceClient.beginSign(accountName, certificateProfile, signingPayloadOptions, requestOptions); + } + + /** + * Gets the signing root certificate on the certificate chain for that account and profile name. + * + *

The root certificate is generated as part of the initial account creation and it is used to sign the bits for + * the profile provided. + * + * @param accountName Signing account name. + * @param certificateProfile Signing Certificate profile name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData getSignRootCertificate(String accountName, String certificateProfile) { + // Generated convenience method for getSignRootCertificateWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getSignRootCertificateWithResponse(accountName, certificateProfile, requestOptions).getValue(); + } + + /** + * Gets a list of extended key usage object identifiers that are allowed for this account and profile combination. + * + *

The list of extended key usages are used to determine the purpose of the certificate usage as part of the + * signing operation. + * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged collection of ExtendedKeyUsage items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listExtendedKeyUsages(String accountName, String certificateProfile) { + // Generated convenience method for listExtendedKeyUsages + RequestOptions requestOptions = new RequestOptions(); + return serviceClient + .listExtendedKeyUsages(accountName, certificateProfile, requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(ExtendedKeyUsage.class)); + } + + /** + * Submit a sign operation. + * + *

Submit a sign operation under the created account and profile name provided. + * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param signingPayloadOptions The artifact request information to be signed by the service. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of status details for long running operations. + */ + @Generated + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginSign( + String accountName, String certificateProfile, SigningPayloadOptions signingPayloadOptions) { + // Generated convenience method for beginSignWithModel + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.beginSignWithModel( + accountName, certificateProfile, BinaryData.fromObject(signingPayloadOptions), requestOptions); + } +} diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/SigningClientBuilder.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/SigningClientBuilder.java new file mode 100644 index 000000000000..c0cc7bebcbcd --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/SigningClientBuilder.java @@ -0,0 +1,303 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package azure.developer.signing; + +import azure.developer.signing.implementation.SigningClientImpl; +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.client.traits.ConfigurationTrait; +import com.azure.core.client.traits.HttpTrait; +import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.AddHeadersPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.util.ClientOptions; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.builder.ClientBuilderUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.serializer.JacksonAdapter; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** A builder for creating a new instance of the SigningClient type. */ +@ServiceClientBuilder(serviceClients = {SigningClient.class, SigningAsyncClient.class}) +public final class SigningClientBuilder + implements HttpTrait, + ConfigurationTrait, + TokenCredentialTrait { + @Generated private static final String SDK_NAME = "name"; + + @Generated private static final String SDK_VERSION = "version"; + + @Generated private static final String[] DEFAULT_SCOPES = new String[] {"https://codesigning.azure.net/.default"}; + + @Generated + private static final Map PROPERTIES = CoreUtils.getProperties("azure-developer-signing.properties"); + + @Generated private final List pipelinePolicies; + + /** Create an instance of the SigningClientBuilder. */ + @Generated + public SigningClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Generated private HttpPipeline pipeline; + + /** {@inheritDoc}. */ + @Generated + @Override + public SigningClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.info("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Generated private HttpClient httpClient; + + /** {@inheritDoc}. */ + @Generated + @Override + public SigningClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Generated private HttpLogOptions httpLogOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public SigningClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The client options such as application ID and custom headers to set on a request. + */ + @Generated private ClientOptions clientOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public SigningClientBuilder clientOptions(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Generated private RetryOptions retryOptions; + + /** {@inheritDoc}. */ + @Generated + @Override + public SigningClientBuilder retryOptions(RetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** {@inheritDoc}. */ + @Generated + @Override + public SigningClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Generated private Configuration configuration; + + /** {@inheritDoc}. */ + @Generated + @Override + public SigningClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The TokenCredential used for authentication. + */ + @Generated private TokenCredential tokenCredential; + + /** {@inheritDoc}. */ + @Generated + @Override + public SigningClientBuilder credential(TokenCredential tokenCredential) { + this.tokenCredential = tokenCredential; + return this; + } + + /* + * The Azure region wherein requests for signing will be sent. + */ + @Generated private String region; + + /** + * Sets The Azure region wherein requests for signing will be sent. + * + * @param region the region value. + * @return the SigningClientBuilder. + */ + @Generated + public SigningClientBuilder region(String region) { + this.region = region; + return this; + } + + /* + * Service version + */ + @Generated private SigningServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the SigningClientBuilder. + */ + @Generated + public SigningClientBuilder serviceVersion(SigningServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /* + * The retry policy that will attempt to retry failed requests, if applicable. + */ + @Generated private RetryPolicy retryPolicy; + + /** + * Sets The retry policy that will attempt to retry failed requests, if applicable. + * + * @param retryPolicy the retryPolicy value. + * @return the SigningClientBuilder. + */ + @Generated + public SigningClientBuilder retryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = retryPolicy; + return this; + } + + /** + * Builds an instance of SigningClientImpl with the provided parameters. + * + * @return an instance of SigningClientImpl. + */ + @Generated + private SigningClientImpl buildInnerClient() { + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + SigningServiceVersion localServiceVersion = + (serviceVersion != null) ? serviceVersion : SigningServiceVersion.getLatest(); + SigningClientImpl client = + new SigningClientImpl( + localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), + this.region, + localServiceVersion); + return client; + } + + @Generated + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration = + (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions; + List policies = new ArrayList<>(); + String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName"); + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions); + policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); + policies.add(new RequestIdPolicy()); + policies.add(new AddHeadersFromContextPolicy()); + HttpHeaders headers = new HttpHeaders(); + localClientOptions + .getHeaders() + .forEach(header -> headers.set(HttpHeaderName.fromString(header.getName()), header.getValue())); + if (headers.getSize() > 0) { + policies.add(new AddHeadersPolicy(headers)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); + policies.add(new AddDatePolicy()); + if (tokenCredential != null) { + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); + } + this.pipelinePolicies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .forEach(p -> policies.add(p)); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .httpClient(httpClient) + .clientOptions(localClientOptions) + .build(); + return httpPipeline; + } + + /** + * Builds an instance of SigningAsyncClient class. + * + * @return an instance of SigningAsyncClient. + */ + @Generated + public SigningAsyncClient buildAsyncClient() { + return new SigningAsyncClient(buildInnerClient()); + } + + /** + * Builds an instance of SigningClient class. + * + * @return an instance of SigningClient. + */ + @Generated + public SigningClient buildClient() { + return new SigningClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SigningClientBuilder.class); +} diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/SigningServiceVersion.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/SigningServiceVersion.java new file mode 100644 index 000000000000..13b11b2fad59 --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/SigningServiceVersion.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package azure.developer.signing; + +import com.azure.core.util.ServiceVersion; + +/** Service version of SigningClient. */ +public enum SigningServiceVersion implements ServiceVersion { + /** Enum value 2023-06-15-preview. */ + V2023_06_15_PREVIEW("2023-06-15-preview"); + + private final String version; + + SigningServiceVersion(String version) { + this.version = version; + } + + /** {@inheritDoc} */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link SigningServiceVersion}. + */ + public static SigningServiceVersion getLatest() { + return V2023_06_15_PREVIEW; + } +} diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/implementation/SigningClientImpl.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/implementation/SigningClientImpl.java new file mode 100644 index 000000000000..93d58914f361 --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/implementation/SigningClientImpl.java @@ -0,0 +1,1088 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package azure.developer.signing.implementation; + +import azure.developer.signing.SigningServiceVersion; +import azure.developer.signing.models.SignResult; +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.experimental.models.PollResult; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.PollingStrategyOptions; +import com.azure.core.util.polling.SyncPoller; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.TypeReference; +import java.time.Duration; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the SigningClient type. */ +public final class SigningClientImpl { + /** The proxy service used to perform REST calls. */ + private final SigningClientService service; + + /** The Azure region wherein requests for signing will be sent. */ + private final String region; + + /** + * Gets The Azure region wherein requests for signing will be sent. + * + * @return the region value. + */ + public String getRegion() { + return this.region; + } + + /** Service version. */ + private final SigningServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public SigningServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** The HTTP pipeline to send requests through. */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** The serializer to serialize an object into a string. */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * Initializes an instance of SigningClient client. + * + * @param region The Azure region wherein requests for signing will be sent. + * @param serviceVersion Service version. + */ + public SigningClientImpl(String region, SigningServiceVersion serviceVersion) { + this( + new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), + region, + serviceVersion); + } + + /** + * Initializes an instance of SigningClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param region The Azure region wherein requests for signing will be sent. + * @param serviceVersion Service version. + */ + public SigningClientImpl(HttpPipeline httpPipeline, String region, SigningServiceVersion serviceVersion) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), region, serviceVersion); + } + + /** + * Initializes an instance of SigningClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param region The Azure region wherein requests for signing will be sent. + * @param serviceVersion Service version. + */ + public SigningClientImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + String region, + SigningServiceVersion serviceVersion) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.region = region; + this.serviceVersion = serviceVersion; + this.service = RestProxy.create(SigningClientService.class, this.httpPipeline, this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for SigningClient to be used by the proxy service to perform REST calls. + */ + @Host("https://{region}.codesigning.azure.net/") + @ServiceInterface(name = "SigningClient") + public interface SigningClientService { + @Get("/codesigningaccounts/{accountName}/certificateprofiles/{certificateProfile}/sign/rootcert") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getSignRootCertificate( + @HostParam("region") String region, + @QueryParam("api-version") String apiVersion, + @PathParam("accountName") String accountName, + @PathParam("certificateProfile") String certificateProfile, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/codesigningaccounts/{accountName}/certificateprofiles/{certificateProfile}/sign/rootcert") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getSignRootCertificateSync( + @HostParam("region") String region, + @QueryParam("api-version") String apiVersion, + @PathParam("accountName") String accountName, + @PathParam("certificateProfile") String certificateProfile, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/codesigningaccounts/{accountName}/certificateprofiles/{certificateProfile}/sign/eku") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listExtendedKeyUsages( + @HostParam("region") String region, + @QueryParam("api-version") String apiVersion, + @PathParam("accountName") String accountName, + @PathParam("certificateProfile") String certificateProfile, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("/codesigningaccounts/{accountName}/certificateprofiles/{certificateProfile}/sign/eku") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listExtendedKeyUsagesSync( + @HostParam("region") String region, + @QueryParam("api-version") String apiVersion, + @PathParam("accountName") String accountName, + @PathParam("certificateProfile") String certificateProfile, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Post("/codesigningaccounts/{accountName}/certificateprofiles/{certificateProfile}:sign") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> sign( + @HostParam("region") String region, + @QueryParam("api-version") String apiVersion, + @PathParam("accountName") String accountName, + @PathParam("certificateProfile") String certificateProfile, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData signingPayloadOptions, + RequestOptions requestOptions, + Context context); + + @Post("/codesigningaccounts/{accountName}/certificateprofiles/{certificateProfile}:sign") + @ExpectedResponses({202}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response signSync( + @HostParam("region") String region, + @QueryParam("api-version") String apiVersion, + @PathParam("accountName") String accountName, + @PathParam("certificateProfile") String certificateProfile, + @HeaderParam("accept") String accept, + @BodyParam("application/json") BinaryData signingPayloadOptions, + RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> listExtendedKeyUsagesNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("region") String region, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType( + value = ClientAuthenticationException.class, + code = {401}) + @UnexpectedResponseExceptionType( + value = ResourceNotFoundException.class, + code = {404}) + @UnexpectedResponseExceptionType( + value = ResourceModifiedException.class, + code = {409}) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response listExtendedKeyUsagesNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("region") String region, + @HeaderParam("accept") String accept, + RequestOptions requestOptions, + Context context); + } + + /** + * Gets the signing root certificate on the certificate chain for that account and profile name. + * + *

The root certificate is generated as part of the initial account creation and it is used to sign the bits for + * the profile provided. + * + *

Response Body Schema + * + *

{@code
+     * BinaryData
+     * }
+ * + * @param accountName Signing account name. + * @param certificateProfile Signing Certificate profile name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getSignRootCertificateWithResponseAsync( + String accountName, String certificateProfile, RequestOptions requestOptions) { + final String accept = "application/json, application/x-x509-ca-cert"; + return FluxUtil.withContext( + context -> + service.getSignRootCertificate( + this.getRegion(), + this.getServiceVersion().getVersion(), + accountName, + certificateProfile, + accept, + requestOptions, + context)); + } + + /** + * Gets the signing root certificate on the certificate chain for that account and profile name. + * + *

The root certificate is generated as part of the initial account creation and it is used to sign the bits for + * the profile provided. + * + *

Response Body Schema + * + *

{@code
+     * BinaryData
+     * }
+ * + * @param accountName Signing account name. + * @param certificateProfile Signing Certificate profile name. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getSignRootCertificateWithResponse( + String accountName, String certificateProfile, RequestOptions requestOptions) { + final String accept = "application/json, application/x-x509-ca-cert"; + return service.getSignRootCertificateSync( + this.getRegion(), + this.getServiceVersion().getVersion(), + accountName, + certificateProfile, + accept, + requestOptions, + Context.NONE); + } + + /** + * Gets a list of extended key usage object identifiers that are allowed for this account and profile combination. + * + *

The list of extended key usages are used to determine the purpose of the certificate usage as part of the + * signing operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     eku: String (Required)
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExtendedKeyUsage items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listExtendedKeyUsagesSinglePageAsync( + String accountName, String certificateProfile, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.listExtendedKeyUsages( + this.getRegion(), + this.getServiceVersion().getVersion(), + accountName, + certificateProfile, + accept, + requestOptions, + context)) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null)); + } + + /** + * Gets a list of extended key usage object identifiers that are allowed for this account and profile combination. + * + *

The list of extended key usages are used to determine the purpose of the certificate usage as part of the + * signing operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     eku: String (Required)
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExtendedKeyUsage items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listExtendedKeyUsagesAsync( + String accountName, String certificateProfile, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE); + return new PagedFlux<>( + () -> listExtendedKeyUsagesSinglePageAsync(accountName, certificateProfile, requestOptions), + nextLink -> listExtendedKeyUsagesNextSinglePageAsync(nextLink, requestOptionsForNextPage)); + } + + /** + * Gets a list of extended key usage object identifiers that are allowed for this account and profile combination. + * + *

The list of extended key usages are used to determine the purpose of the certificate usage as part of the + * signing operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     eku: String (Required)
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExtendedKeyUsage items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listExtendedKeyUsagesSinglePage( + String accountName, String certificateProfile, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = + service.listExtendedKeyUsagesSync( + this.getRegion(), + this.getServiceVersion().getVersion(), + accountName, + certificateProfile, + accept, + requestOptions, + Context.NONE); + return new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null); + } + + /** + * Gets a list of extended key usage object identifiers that are allowed for this account and profile combination. + * + *

The list of extended key usages are used to determine the purpose of the certificate usage as part of the + * signing operation. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     eku: String (Required)
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExtendedKeyUsage items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listExtendedKeyUsages( + String accountName, String certificateProfile, RequestOptions requestOptions) { + RequestOptions requestOptionsForNextPage = new RequestOptions(); + requestOptionsForNextPage.setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE); + return new PagedIterable<>( + () -> listExtendedKeyUsagesSinglePage(accountName, certificateProfile, requestOptions), + nextLink -> listExtendedKeyUsagesNextSinglePage(nextLink, requestOptionsForNextPage)); + } + + /** + * Submit a sign operation. + * + *

Submit a sign operation under the created account and profile name provided. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     signatureAlgorithm: String(RS256/RS384/RS512/PS256/PS384/PS512/ES256/ES384/ES512/ES256K) (Required)
+     *     digest: byte[] (Required)
+     *     fileHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     *     authenticodeHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param signingPayloadOptions The artifact request information to be signed by the service. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return status details for long running operations along with {@link Response} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> signWithResponseAsync( + String accountName, + String certificateProfile, + BinaryData signingPayloadOptions, + RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.sign( + this.getRegion(), + this.getServiceVersion().getVersion(), + accountName, + certificateProfile, + accept, + signingPayloadOptions, + requestOptions, + context)); + } + + /** + * Submit a sign operation. + * + *

Submit a sign operation under the created account and profile name provided. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     signatureAlgorithm: String(RS256/RS384/RS512/PS256/PS384/PS512/ES256/ES384/ES512/ES256K) (Required)
+     *     digest: byte[] (Required)
+     *     fileHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     *     authenticodeHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param signingPayloadOptions The artifact request information to be signed by the service. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return status details for long running operations along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Response signWithResponse( + String accountName, + String certificateProfile, + BinaryData signingPayloadOptions, + RequestOptions requestOptions) { + final String accept = "application/json"; + return service.signSync( + this.getRegion(), + this.getServiceVersion().getVersion(), + accountName, + certificateProfile, + accept, + signingPayloadOptions, + requestOptions, + Context.NONE); + } + + /** + * Submit a sign operation. + * + *

Submit a sign operation under the created account and profile name provided. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     signatureAlgorithm: String(RS256/RS384/RS512/PS256/PS384/PS512/ES256/ES384/ES512/ES256K) (Required)
+     *     digest: byte[] (Required)
+     *     fileHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     *     authenticodeHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param signingPayloadOptions The artifact request information to be signed by the service. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginSignAsync( + String accountName, + String certificateProfile, + BinaryData signingPayloadOptions, + RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> + this.signWithResponseAsync( + accountName, certificateProfile, signingPayloadOptions, requestOptions), + new com.azure.core.experimental.util.polling.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint(null) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE)), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Submit a sign operation. + * + *

Submit a sign operation under the created account and profile name provided. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     signatureAlgorithm: String(RS256/RS384/RS512/PS256/PS384/PS512/ES256/ES384/ES512/ES256K) (Required)
+     *     digest: byte[] (Required)
+     *     fileHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     *     authenticodeHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param signingPayloadOptions The artifact request information to be signed by the service. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginSign( + String accountName, + String certificateProfile, + BinaryData signingPayloadOptions, + RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.signWithResponse(accountName, certificateProfile, signingPayloadOptions, requestOptions), + new com.azure.core.experimental.util.polling.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint(null) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE)), + TypeReference.createInstance(BinaryData.class), + TypeReference.createInstance(BinaryData.class)); + } + + /** + * Submit a sign operation. + * + *

Submit a sign operation under the created account and profile name provided. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     signatureAlgorithm: String(RS256/RS384/RS512/PS256/PS384/PS512/ES256/ES384/ES512/ES256K) (Required)
+     *     digest: byte[] (Required)
+     *     fileHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     *     authenticodeHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param signingPayloadOptions The artifact request information to be signed by the service. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link PollerFlux} for polling of status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public PollerFlux beginSignWithModelAsync( + String accountName, + String certificateProfile, + BinaryData signingPayloadOptions, + RequestOptions requestOptions) { + return PollerFlux.create( + Duration.ofSeconds(1), + () -> + this.signWithResponseAsync( + accountName, certificateProfile, signingPayloadOptions, requestOptions), + new com.azure.core.experimental.util.polling.OperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint(null) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE)), + TypeReference.createInstance(PollResult.class), + TypeReference.createInstance(SignResult.class)); + } + + /** + * Submit a sign operation. + * + *

Submit a sign operation under the created account and profile name provided. + * + *

Request Body Schema + * + *

{@code
+     * {
+     *     signatureAlgorithm: String(RS256/RS384/RS512/PS256/PS384/PS512/ES256/ES384/ES512/ES256K) (Required)
+     *     digest: byte[] (Required)
+     *     fileHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     *     authenticodeHashList (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+ * + *

Response Body Schema + * + *

{@code
+     * {
+     *     id: String (Required)
+     *     status: String (Required)
+     *     error (Optional): {
+     *         code: String (Required)
+     *         message: String (Required)
+     *         target: String (Optional)
+     *         details (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *         innererror (Optional): {
+     *             code: String (Optional)
+     *             innererror (Optional): (recursive schema, see innererror above)
+     *         }
+     *     }
+     * }
+     * }
+ * + * @param accountName Azure Developer Signing account name. + * @param certificateProfile Azure Developer Signing certificate profile name under an account. + * @param signingPayloadOptions The artifact request information to be signed by the service. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link SyncPoller} for polling of status details for long running operations. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller beginSignWithModel( + String accountName, + String certificateProfile, + BinaryData signingPayloadOptions, + RequestOptions requestOptions) { + return SyncPoller.createPoller( + Duration.ofSeconds(1), + () -> this.signWithResponse(accountName, certificateProfile, signingPayloadOptions, requestOptions), + new com.azure.core.experimental.util.polling.SyncOperationLocationPollingStrategy<>( + new PollingStrategyOptions(this.getHttpPipeline()) + .setEndpoint(null) + .setContext( + requestOptions != null && requestOptions.getContext() != null + ? requestOptions.getContext() + : Context.NONE)), + TypeReference.createInstance(PollResult.class), + TypeReference.createInstance(SignResult.class)); + } + + /** + * Gets a list of extended key usage object identifiers that are allowed for this account and profile combination. + * + *

Get the next page of items. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     eku: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExtendedKeyUsage items along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listExtendedKeyUsagesNextSinglePageAsync( + String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil.withContext( + context -> + service.listExtendedKeyUsagesNext( + nextLink, this.getRegion(), accept, requestOptions, context)) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null)); + } + + /** + * Gets a list of extended key usage object identifiers that are allowed for this account and profile combination. + * + *

Get the next page of items. + * + *

Response Body Schema + * + *

{@code
+     * {
+     *     eku: String (Required)
+     * }
+     * }
+ * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return paged collection of ExtendedKeyUsage items along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listExtendedKeyUsagesNextSinglePage( + String nextLink, RequestOptions requestOptions) { + final String accept = "application/json"; + Response res = + service.listExtendedKeyUsagesNextSync(nextLink, this.getRegion(), accept, requestOptions, Context.NONE); + return new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + getValues(res.getValue(), "value"), + getNextLink(res.getValue(), "nextLink"), + null); + } + + private List getValues(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + List values = (List) obj.get(path); + return values.stream().map(BinaryData::fromObject).collect(Collectors.toList()); + } catch (RuntimeException e) { + return null; + } + } + + private String getNextLink(BinaryData binaryData, String path) { + try { + Map obj = binaryData.toObject(Map.class); + return (String) obj.get(path); + } catch (RuntimeException e) { + return null; + } + } +} diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/implementation/package-info.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/implementation/package-info.java new file mode 100644 index 000000000000..33e5de88da5e --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the implementations for Signing. Azure Developer Signing is a service that provides managed + * artifact signing for all. + */ +package azure.developer.signing.implementation; diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/ExtendedKeyUsage.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/ExtendedKeyUsage.java new file mode 100644 index 000000000000..848b32ef0bc2 --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/ExtendedKeyUsage.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package azure.developer.signing.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Extended key usage object identifier that are allowable. */ +@Immutable +public final class ExtendedKeyUsage { + /* + * An oid string that represents an eku. + */ + @Generated + @JsonProperty(value = "eku", access = JsonProperty.Access.WRITE_ONLY) + private String eku; + + /** Creates an instance of ExtendedKeyUsage class. */ + @Generated + private ExtendedKeyUsage() {} + + /** + * Get the eku property: An oid string that represents an eku. + * + * @return the eku value. + */ + @Generated + public String getEku() { + return this.eku; + } +} diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/SignResult.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/SignResult.java new file mode 100644 index 000000000000..3aaf5197332b --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/SignResult.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package azure.developer.signing.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The sign status model. */ +@Immutable +public final class SignResult { + /* + * Digital signature of the requested content digest. + */ + @Generated + @JsonProperty(value = "signature") + private byte[] signature; + + /* + * Signing certificate corresponding to the private key used to sign the requested + * digest. + */ + @Generated + @JsonProperty(value = "signingCertificate") + private byte[] signingCertificate; + + /** Creates an instance of SignResult class. */ + @Generated + private SignResult() {} + + /** + * Get the signature property: Digital signature of the requested content digest. + * + * @return the signature value. + */ + @Generated + public byte[] getSignature() { + return CoreUtils.clone(this.signature); + } + + /** + * Get the signingCertificate property: Signing certificate corresponding to the private key used to sign the + * requested digest. + * + * @return the signingCertificate value. + */ + @Generated + public byte[] getSigningCertificate() { + return CoreUtils.clone(this.signingCertificate); + } +} diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/SignatureAlgorithm.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/SignatureAlgorithm.java new file mode 100644 index 000000000000..d945c23feb45 --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/SignatureAlgorithm.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package azure.developer.signing.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Algorithms supported for signing. */ +public final class SignatureAlgorithm extends ExpandableStringEnum { + /** RSASSA-PKCS1-v1_5 using SHA-256 hash algorithm. */ + @Generated public static final SignatureAlgorithm RS256 = fromString("RS256"); + + /** RSASSA-PKCS1-v1_5 using SHA-384 hash algorithm. */ + @Generated public static final SignatureAlgorithm RS384 = fromString("RS384"); + + /** RSASSA-PKCS1-v1_5 using SHA-512 hash algorithm. */ + @Generated public static final SignatureAlgorithm RS512 = fromString("RS512"); + + /** RSASSA-PSS using SHA-256 hash algorithm. */ + @Generated public static final SignatureAlgorithm PS256 = fromString("PS256"); + + /** RSASSA-PSS using SHA-384 hash algorithm. */ + @Generated public static final SignatureAlgorithm PS384 = fromString("PS384"); + + /** RSASSA-PSS using SHA-512 hash algorithm. */ + @Generated public static final SignatureAlgorithm PS512 = fromString("PS512"); + + /** ECDSA using P-256 and SHA-256 hash algorithm. */ + @Generated public static final SignatureAlgorithm ES256 = fromString("ES256"); + + /** ECDSA using P-384 and SHA-384 hash algorithm. */ + @Generated public static final SignatureAlgorithm ES384 = fromString("ES384"); + + /** ECDSA using P-521 and SHA-512 hash algorithm. */ + @Generated public static final SignatureAlgorithm ES512 = fromString("ES512"); + + /** ECDSA using secp256k1 and SHA-256 hash algorithm. */ + @Generated public static final SignatureAlgorithm ES256K = fromString("ES256K"); + + /** + * Creates a new instance of SignatureAlgorithm value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Generated + @Deprecated + public SignatureAlgorithm() {} + + /** + * Creates or finds a SignatureAlgorithm from its string representation. + * + * @param name a name to look for. + * @return the corresponding SignatureAlgorithm. + */ + @Generated + @JsonCreator + public static SignatureAlgorithm fromString(String name) { + return fromString(name, SignatureAlgorithm.class); + } + + /** + * Gets known SignatureAlgorithm values. + * + * @return known SignatureAlgorithm values. + */ + @Generated + public static Collection values() { + return values(SignatureAlgorithm.class); + } +} diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/SigningPayloadOptions.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/SigningPayloadOptions.java new file mode 100644 index 000000000000..e79442141f83 --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/SigningPayloadOptions.java @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package azure.developer.signing.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.core.util.CoreUtils; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The artifact request information to be signed by the service. */ +@Fluent +public final class SigningPayloadOptions { + /* + * The supported signature algorithm identifiers. + */ + @Generated + @JsonProperty(value = "signatureAlgorithm") + private SignatureAlgorithm signatureAlgorithm; + + /* + * Content digest to sign. + */ + @Generated + @JsonProperty(value = "digest") + private byte[] digest; + + /* + * List of full file digital signatures. + */ + @Generated + @JsonProperty(value = "fileHashList") + private List fileHashList; + + /* + * List of authenticode digital signatures. + */ + @Generated + @JsonProperty(value = "authenticodeHashList") + private List authenticodeHashList; + + /** + * Creates an instance of SigningPayloadOptions class. + * + * @param signatureAlgorithm the signatureAlgorithm value to set. + * @param digest the digest value to set. + */ + @Generated + @JsonCreator + public SigningPayloadOptions( + @JsonProperty(value = "signatureAlgorithm") SignatureAlgorithm signatureAlgorithm, + @JsonProperty(value = "digest") byte[] digest) { + this.signatureAlgorithm = signatureAlgorithm; + this.digest = digest; + } + + /** + * Get the signatureAlgorithm property: The supported signature algorithm identifiers. + * + * @return the signatureAlgorithm value. + */ + @Generated + public SignatureAlgorithm getSignatureAlgorithm() { + return this.signatureAlgorithm; + } + + /** + * Get the digest property: Content digest to sign. + * + * @return the digest value. + */ + @Generated + public byte[] getDigest() { + return CoreUtils.clone(this.digest); + } + + /** + * Get the fileHashList property: List of full file digital signatures. + * + * @return the fileHashList value. + */ + @Generated + public List getFileHashList() { + return this.fileHashList; + } + + /** + * Set the fileHashList property: List of full file digital signatures. + * + * @param fileHashList the fileHashList value to set. + * @return the SigningPayloadOptions object itself. + */ + @Generated + public SigningPayloadOptions setFileHashList(List fileHashList) { + this.fileHashList = fileHashList; + return this; + } + + /** + * Get the authenticodeHashList property: List of authenticode digital signatures. + * + * @return the authenticodeHashList value. + */ + @Generated + public List getAuthenticodeHashList() { + return this.authenticodeHashList; + } + + /** + * Set the authenticodeHashList property: List of authenticode digital signatures. + * + * @param authenticodeHashList the authenticodeHashList value to set. + * @return the SigningPayloadOptions object itself. + */ + @Generated + public SigningPayloadOptions setAuthenticodeHashList(List authenticodeHashList) { + this.authenticodeHashList = authenticodeHashList; + return this; + } +} diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/package-info.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/package-info.java new file mode 100644 index 000000000000..48557abf705b --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the data models for Signing. Azure Developer Signing is a service that provides managed artifact + * signing for all. + */ +package azure.developer.signing.models; diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/package-info.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/package-info.java new file mode 100644 index 000000000000..99bc3ec29b9d --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/azure/developer/signing/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the classes for Signing. Azure Developer Signing is a service that provides managed artifact + * signing for all. + */ +package azure.developer.signing; diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/java/module-info.java b/sdk/codesigning/com.azure.developer.signing/src/main/java/module-info.java new file mode 100644 index 000000000000..d633828b645a --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/java/module-info.java @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +module azure.developer.signing { + requires transitive com.azure.core; + requires transitive com.azure.core.experimental; + + exports azure.developer.signing; + exports azure.developer.signing.models; + + opens azure.developer.signing.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/codesigning/com.azure.developer.signing/src/main/resources/azure-developer-signing.properties b/sdk/codesigning/com.azure.developer.signing/src/main/resources/azure-developer-signing.properties new file mode 100644 index 000000000000..ca812989b4f2 --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/main/resources/azure-developer-signing.properties @@ -0,0 +1,2 @@ +name=${project.artifactId} +version=${project.version} diff --git a/sdk/codesigning/com.azure.developer.signing/src/samples/java/azure/developer/signing/ReadmeSamples.java b/sdk/codesigning/com.azure.developer.signing/src/samples/java/azure/developer/signing/ReadmeSamples.java new file mode 100644 index 000000000000..744eeb171fda --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/samples/java/azure/developer/signing/ReadmeSamples.java @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package azure.developer.signing; + +public final class ReadmeSamples { + public void readmeSamples() { + // BEGIN: azure.developer.signing.readme + // END: azure.developer.signing.readme + } +} diff --git a/sdk/codesigning/com.azure.developer.signing/src/test/java/azure/developer/signing/generated/SigningClientTestBase.java b/sdk/codesigning/com.azure.developer.signing/src/test/java/azure/developer/signing/generated/SigningClientTestBase.java new file mode 100644 index 000000000000..3399d35c423f --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/src/test/java/azure/developer/signing/generated/SigningClientTestBase.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package azure.developer.signing.generated; + +// The Java test files under 'generated' package are generated for your reference. +// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. +// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. + +import azure.developer.signing.SigningClient; +import azure.developer.signing.SigningClientBuilder; +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.test.TestMode; +import com.azure.core.test.TestProxyTestBase; +import com.azure.core.util.Configuration; +import com.azure.identity.DefaultAzureCredentialBuilder; +import java.time.OffsetDateTime; +import reactor.core.publisher.Mono; + +class SigningClientTestBase extends TestProxyTestBase { + protected SigningClient signingClient; + + @Override + protected void beforeTest() { + SigningClientBuilder signingClientbuilder = + new SigningClientBuilder() + .region(Configuration.getGlobalConfiguration().get("REGION", "region")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + signingClientbuilder + .httpClient(interceptorManager.getPlaybackClient()) + .credential(request -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX))); + } else if (getTestMode() == TestMode.RECORD) { + signingClientbuilder + .addPolicy(interceptorManager.getRecordPolicy()) + .credential(new DefaultAzureCredentialBuilder().build()); + } else if (getTestMode() == TestMode.LIVE) { + signingClientbuilder.credential(new DefaultAzureCredentialBuilder().build()); + } + signingClient = signingClientbuilder.buildClient(); + } +} diff --git a/sdk/codesigning/com.azure.developer.signing/tsp-location.yaml b/sdk/codesigning/com.azure.developer.signing/tsp-location.yaml new file mode 100644 index 000000000000..c988a70db731 --- /dev/null +++ b/sdk/codesigning/com.azure.developer.signing/tsp-location.yaml @@ -0,0 +1,5 @@ +repo: Azure/azure-rest-api-specs +directory: specification/codesigning/CodeSigning +additionalDirectories: [] +commit: 32fe89b5cc906d9840632c3c02b2535633abe445 + diff --git a/sdk/codesigning/pom.xml b/sdk/codesigning/pom.xml new file mode 100644 index 000000000000..8e948570d8d4 --- /dev/null +++ b/sdk/codesigning/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-codesigning-service + pom + 1.0.0 + + + com.azure.developer.signing + +