diff --git a/sdk/keyvault/azure-security-keyvault-certificates/CHANGELOG.md b/sdk/keyvault/azure-security-keyvault-certificates/CHANGELOG.md deleted file mode 100644 index 2739cd4e23a4..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/CHANGELOG.md +++ /dev/null @@ -1,710 +0,0 @@ -# Release History - -## 4.8.0-beta.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - -## 4.7.2 (2025-01-14) - -### Bugs Fixed -- Fixed issue where certain `toString()` calls could cause a `NullPointerException`. ([#43776](https://github.com/Azure/azure-sdk-for-java/pull/43776)) - -## 4.7.1 (2024-12-04) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.53.0` to version `1.54.1`. -- Upgraded `azure-core-http-netty` from `1.15.5` to version `1.15.7`. - -## 4.7.0 (2024-10-15) - -## Features Added -- Added support for Continuous Access Evaluation (CAE). ([#41814](https://github.com/Azure/azure-sdk-for-java/pull/41814)) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.52.0` to version `1.53.0`. -- Upgraded `azure-core-http-netty` from `1.15.4` to version `1.15.5`. - -## 4.6.7 (2024-09-27) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-json` from `1.2.0` to version `1.3.0`. -- Upgraded `azure-core-http-netty` from `1.15.3` to version `1.15.4`. -- Upgraded `azure-core` from `1.51.0` to version `1.52.0`. - - -## 4.6.6 (2024-08-24) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.50.0` to version `1.51.0`. -- Upgraded `azure-core-http-netty` from `1.15.2` to version `1.15.3`. - - -## 4.6.5 (2024-07-29) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.49.1` to version `1.50.0`. -- Upgraded `azure-json` from `1.1.0` to version `1.2.0`. -- Upgraded `azure-core-http-netty` from `1.15.1` to version `1.15.2`. - -## 4.6.4 (2024-06-27) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.49.0` to version `1.49.1`. -- Upgraded `azure-core-http-netty` from `1.15.0` to version `1.15.1`. - -## 4.6.3 (2024-05-13) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.48.0` to version `1.49.0`. -- Upgraded `azure-core-http-netty` from `1.14.2` to version `1.15.0`. - -## 4.6.2 (2024-04-23) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.47.0` to version `1.48.0`. -- Upgraded `azure-core-http-netty` from `1.14.1` to version `1.14.2`. - -## 4.6.1 (2024-03-20) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.46.0` to version `1.47.0`. -- Upgraded `azure-core-http-netty` from `1.14.0` to version `1.14.1`. - -## 4.6.0 (2024-02-22) -Changes when compared to the last stable release (`4.5.9`) include: - -### Features Added -- Added support for service version `7.5`. -- Added `CertificateProperties.getX509ThumbprintAsString()` to return the hexadecimal string representation of the SHA-1 hash of a certificate. - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.45.1` to version `1.46.0`. -- Upgraded `azure-core-http-netty` from `1.13.11` to version `1.14.0`. - -## 4.5.9 (2023-12-04) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core-http-netty` from `1.13.10` to version `1.13.11`. -- Upgraded `azure-core` from `1.45.0` to version `1.45.1`. - -## 4.5.8 (2023-11-20) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.44.1` to version `1.45.0`. -- Upgraded `azure-core-http-netty` from `1.13.9` to version `1.13.10`. - -## 4.6.0-beta.1 (2023-11-09) - -### Features Added -- Added support for service version `7.5-preview.1`. - -#### Dependency Updates -- Upgraded `azure-core` from `1.44.1` to version `1.45.0`. -- Upgraded `azure-core-http-netty` from `1.13.9` to version `1.13.10`. - -## 4.5.7 (2023-10-20) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.43.0` to version `1.44.1`. -- Upgraded `azure-core-http-netty` from `1.13.7` to version `1.13.9`. - -## 4.5.6 (2023-09-25) - -### Bugs Fixed -- Fixed response code for certificate merging operations from `200` to the correct `201`. -([#36260](https://github.com/Azure/azure-sdk-for-java/issues/36260)) - -#### Dependency Updates - -- Upgraded `azure-core` from `1.42.0` to version `1.43.0`. -- Upgraded `azure-core-http-netty` from `1.13.6` to version `1.13.7`. - -## 4.5.5 (2023-08-21) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.41.0` to version `1.42.0`. -- Upgraded `azure-core-http-netty` from `1.13.5` to version `1.13.6`. - -## 4.5.4 (2023-07-25) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.40.0` to version `1.41.0`. -- Upgraded `azure-core-http-netty` from `1.13.4` to version `1.13.5`. - -## 4.5.3 (2023-06-20) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.39.0` to version `1.40.0`. -- Upgraded `azure-core-http-netty` from `1.13.3` to version `1.13.4`. - -## 4.5.2 (2023-05-23) - -### Other Changes -- Migrate Test recordings to assets repo. - -#### Dependency Updates - -- Upgraded `azure-core-http-netty` from `1.13.2` to version `1.13.3`. -- Upgraded `azure-core` from `1.38.0` to version `1.39.0`. - -## 4.5.1 (2023-04-20) - -### Other Changes - -- Test proxy server migration. -- Made all logger instances static. - -#### Dependency Updates - -- Upgraded `azure-core-http-netty` from `1.13.1` to version `1.13.2`. -- Upgraded `azure-core` from `1.37.0` to version `1.38.0`. - -## 4.5.0 (2023-03-18) - -### Features Added -- Added support for service version `7.4`. - -### Other Changes -- Upgraded `azure-core-http-netty` from `1.13.0` to version `1.13.1`. -- Upgraded `azure-core` from `1.36.0` to version `1.37.0`. - -## 4.4.4 (2023-02-16) - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core-http-netty` from `1.12.8` to version `1.13.0`. -- Upgraded `azure-core` from `1.35.0` to version `1.36.0`. - -## 4.4.3 (2023-01-09) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` from `1.34.0` to version `1.35.0`. -- Upgraded `azure-core-http-netty` from `1.12.7` to version `1.12.8`. - -## 4.4.2 (2022-11-10) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` from `1.33.0` to version `1.34.0`. -- Upgraded `azure-core-http-netty` from `1.12.6` to version `1.12.7`. - -## 4.4.1 (2022-10-17) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` from `1.32.0` to version `1.33.0`. -- Upgraded `azure-core-http-netty` from `1.12.5` to version `1.12.6`. - -## 4.4.0 (2022-09-20) - -### Breaking Changes -- Made it so that we verify that the challenge resource matches the vault domain by default. This should affect few customers who can use the `disableChallengeResourceVerification()` method in client builders to disable this functionality. See https://aka.ms/azsdk/blog/vault-uri for more information. - -### Other Changes - -#### Dependency Updates - -- Upgraded `azure-core` from `1.31.0` to version `1.32.0`. -- Upgraded `azure-core-http-netty` from `1.12.4` to version `1.12.5`. - -## 4.3.5 (2022-08-15) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.31.0`. -- Upgraded `azure-core-http-netty` dependency to `1.12.4`. - -## 4.3.4 (2022-07-06) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.30.0`. -- Upgraded `azure-core-http-netty` dependency to `1.12.3`. - -## 4.3.3 (2022-06-10) - -### Bugs Fixed -- Fixed an issue that caused the `organizationId` and `enabled` parameters not be sent to the Key Vault service when creating or updating a `CertificateIssuer`. - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.29.1`. -- Upgraded `azure-core-http-netty` dependency to `1.12.2`. - -## 4.3.2 (2022-05-10) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.28.0`. -- Upgraded `azure-core-http-netty` dependency to `1.12.0`. - -## 4.3.1 (2022-04-08) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.27.0`. -- Upgraded `azure-core-http-netty` dependency to `1.11.9`. - -## 4.3.0 (2022-03-31) - -### Features Added -- Added support for service version `7.3`. -- Implemented new traits (micro-interfaces) in `CertificateClientBuilder`. This makes the experience of using client builders more consistent across libraries in the Azure SDK for Java. - -## 4.2.8 (2022-03-17) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.26.0` -- Upgraded `azure-core-http-netty` dependency to `1.11.8` - -## 4.3.0-beta.5 (2022-02-11) - -### Features added -- Implemented new traits (micro-interfaces) in `CertificateClientBuilder`. This makes the experience of using client builders more consistent across libraries in the Azure SDK for Java. - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.25.0` -- Upgraded `azure-core-http-netty` dependency to `1.11.7` - -## 4.2.7 (2022-02-11) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.25.0` -- Upgraded `azure-core-http-netty` dependency to `1.11.7` - -## 4.3.0-beta.4 (2022-01-13) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.24.1` -- Upgraded `azure-core-http-netty` dependency to `1.11.6` - -## 4.2.6 (2022-01-12) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.24.1` -- Upgraded `azure-core-http-netty` dependency to `1.11.6` - -## 4.3.0-beta.3 (2021-11-12) - -### Features Added - -- Added support for multi-tenant authentication in clients. - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.22.0` -- Upgraded `azure-core-http-netty` dependency to `1.11.2` - -## 4.2.5 (2021-11-12) - -### Features Added - -- Added support for multi-tenant authentication in clients. - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.22.0` -- Upgraded `azure-core-http-netty` dependency to `1.11.2` - - - -## 4.3.0-beta.2 (2021-10-07) - -### Bugs Fixed -- Fixed an issue that made clients send unnecessary unauthorized requests to obtain a bearer challenge from the service even when already possessing a valid bearer token. - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.21.0` -- Upgraded `azure-core-http-netty` dependency to `1.11.1` - -## 4.2.4 (2021-10-06) - -### Bugs Fixed -- Fixed an issue that made clients send unnecessary unauthorized requests to obtain a bearer challenge from the service even when already possessing a valid bearer token. - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.21.0` -- Upgraded `azure-core-http-netty` dependency to `1.11.1` - -## 4.3.0-beta.1 (2021-09-10) - -### Features Added -- Added support for service version `7.3-preview`. - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.20.0` -- Upgraded `azure-core-http-netty` dependency to `1.11.0` - -## 4.2.3 (2021-09-10) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.20.0` -- Upgraded `azure-core-http-netty` dependency to `1.11.0` - -## 4.2.2 (2021-08-12) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.19.0` -- Upgraded `azure-core-http-netty` dependency to `1.10.2` - - -## 4.2.1 (2021-07-08) - -### Other Changes - -#### Dependency Updates -- Upgraded `azure-core` dependency to `1.18.0` -- Upgraded `azure-core-http-netty` dependency to `1.10.1` - -## 4.2.0 (2021-06-17) - -### Features Added -- Changed default service version to `7.2`. -- Added `KeyVaultCertificateIdentifier` to parse certificate URLs. - -### Changes since 4.2.0-beta.6 - -#### Bug Fixes -- Ensured that `RetryPolicy` and `HttpLogOptions` use a default implementation when creating Key Vault clients if not set or set to `null`. - -#### New Features -- `KeyVaultCertificateIdentifier` can now be used to parse any Key Vault identifier. - -#### Breaking Changes -- Removed service method overloads that take a `pollingInterval`, since `PollerFlux` and `SyncPoller` objects allow for setting this value directly on them. - -#### Non-Breaking Changes -- Renamed `certificateId` to `sourceId` in `KeyVaultCertificateIdentifier`. -- Added the `@ServiceMethod` annotation to all public methods that call the Key Vault service in `CertificateClient` and `CertificateAsyncClient`. - -## 4.2.0-beta.6 (2021-05-15) - -### Dependency Updates -- Upgraded `azure-core` dependency to `1.16.0` -- Upgraded `azure-core-http-netty` dependency to `1.9.2` -- Upgraded `azure-core-http-okhttp` dependency to `1.6.2` -- Upgraded `azure-identity` dependency to `1.3.0` - -## 4.2.0-beta.5 (2021-04-09) - -### New features -- Added support for service version `7.2`. -- Added support to specify whether or not a pipeline policy should be added per call or per retry. - -### Breaking Changes -- Changed `KeyVaultCertificateIdentifier` so it is instantiated via its constructor as opposed to via a `parse()` factory method. - -## 4.2.0-beta.4 (2021-03-12) - -### Changed -- Changed logging level in `onRequest` and `onSuccess` calls for service operations from `INFO` to `VERBOSE`. - -### Dependency Updates -- Upgraded `azure-core` dependency to `1.14.0` -- Upgraded `azure-core-http-netty` dependency to `1.9.0` -- Upgraded `azure-core-http-okhttp` dependency to `1.6.0` -- Upgraded `azure-identity` dependency to `1.2.4` - -## 4.2.0-beta.3 (2021-02-11) - -### Dependency Updates -- Upgraded `azure-core` dependency to `1.13.0` -- Upgraded `azure-core-http-netty` dependency to `1.8.0` -- Upgraded `azure-core-http-okhttp` dependency to `1.5.0` -- Upgraded `azure-identity` dependency to `1.2.3` - -## 4.1.5 (2021-02-11) - -### Dependency Updates -- Upgraded `azure-core` dependency to `1.13.0` -- Upgraded `azure-core-http-netty` dependency to `1.8.0` -- Upgraded `azure-core-http-okhttp` dependency to `1.5.0` -- Upgraded `azure-identity` dependency to `1.2.3` - -## 4.1.4 (2021-01-15) - -### Dependency Updates -- Upgraded `azure-core` dependency to `1.12.0` -- Upgraded `azure-core-http-netty` dependency to `1.7.1` -- Upgraded `azure-core-http-okhttp` dependency to `1.4.1` -- Upgraded `azure-identity` dependency to `1.2.2` - -## 4.1.3 (2020-11-12) - -### Dependency Updates -- Upgraded `azure-core` dependency to `1.10.0` -- Upgraded `azure-core-http-netty` dependency to `1.6.3` -- Upgraded `azure-core-http-okhttp` dependency to `1.3.3` -- Upgraded `azure-core-test` dependency to `1.5.1` -- Upgraded `azure-identity` dependency to `1.2.0` - -## 4.2.0-beta.2 (2020-10-09) - -### New Features -- Added `KeyVaultCertificateIdentifier`. Use its [`parse`](https://github.com/Azure/azure-sdk-for-java/blob/ff52067a3772a430e5913b898f2806078aec8ef2/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificateIdentifier.java#L79) method to parse the different elements of a given certificate identifier. -- Added API overloads that allow for passing specific polling intervals for long-running operations: - - `CertificateAsyncClient` - - `beginCreateCertificate(String, CertificatePolicy, Boolean, Map, Duration)` - - `getCertificateOperation(String, Duration)` - - `beginDeleteCertificate(String, Duration)` - - `beginRecoverDeletedCertificate(String, Duration)` - - `CertificateClient` - - `beginCreateCertificate(String, CertificatePolicy, Boolean, Map, Duration)` - - `getCertificateOperation(String, Duration)` - - `beginDeleteCertificate(String, Duration)` - - `beginRecoverDeletedCertificate(String, Duration)` -- Added support for `com.azure.core.util.ClientOptions` in client builders. - -### Dependency Updates -- Upgraded `azure-core` dependency to `1.9.0` -- Upgraded `azure-core-http-netty` dependency to `1.6.2` -- Upgraded `azure-core-http-okhttp` dependency to `1.3.2` -- Upgraded `azure-core-test` dependency to `1.5.0` -- Upgraded `azure-identity` dependency to `1.1.3` - -## 4.1.2 (2020-10-08) - -### Dependency Updates -- Upgraded `azure-core` dependency to `1.9.0` -- Upgraded `azure-core-http-netty` dependency to `1.6.2` -- Upgraded `azure-core-http-okhttp` dependency to `1.3.2` -- Upgraded `azure-core-test` dependency to `1.5.0` -- Upgraded `azure-identity` dependency to `1.1.3` - -## 4.2.0-beta.1 (2020-09-11) -- Updated versions for azure-core and azure-identity. - -## 4.1.1 (2020-09-10) -- Updated versions for azure-core and azure-identity. - -## 4.1.0 (2020-08-12) -- Added support for service version `7.1`. -- Added `retryPolicy` setter in `CertificateClientBuilder`. -- Added `recoverableDays` property to `CertificateProperties`. - -## 4.1.0-beta.4 (2020-07-08) -- Updated versions for azure-core, azure-identity. - -## 4.0.5 (2020-07-08) -- Updated versions for azure-core and azure-identity. - -## 4.1.0-beta.3 (2020-06-10) -- Updated version for azure-core, azure-identity and external dependencies. - -## 4.0.4 (2020-06-10) -- Updated version for azure-core, azure-identity and external dependencies. - -## 4.0.3 (2020-05-06) -- Update azure-core dependency to version 1.5.0. - -## 4.1.0-beta.2 (2020-04-09) -- Added `retryPolicy` setter in `CertificateClientBuilder` -- Update azure-core dependency to version 1.4.0. - -## 4.0.2 (2020-04-07) -- Update azure-core dependency to version 1.4.0. - -## 4.0.1 (2020-03-25) -- Update azure-core dependency to version 1.3.0. - -## 4.1.0-beta.1 (2020-03-10) -- Added `recoverableDays` property to `CertificateProperties`. -- Added support for `7.1-Preview` service version - -## 4.0.0 (2020-01-07) -- Update azure-core dependency to version 1.2.0. - -## 4.0.0-beta.7 (2019-12-17) -- `beginDeleteCertificate` and `beginRecoverDeletedCertificate` methods now return a poll response with a status of SUCCESSFULLY_COMPLETED when service returns 403 status. -- `CertificateClient.createIssuer` and `CertificateAsyncClient.createIssuer` now require a `CertificateIssuer` with both a name and provider. -- Removed constructor overload for `CertificateIssuer(String name, String provider)` from `CertificateIssuer` model. -- Removed `AdministratorContact` constructor overloads and introduced setters for all parameters. -- Removed `CertificateContact` constructor overloads and introduced setters for all parameters. - -## 4.0.0-beta.6 (2019-12-04) - -### Breaking changes - -- Moved `CertificateClient.cancelCertificationOperation` to `SyncPoller.cancel` and `CertificateAsyncClient.cancelCertificationOperation` to `PollerFlux.cancel` respectively. -- deleteCertificate method has been renamed to beginDeleteCertificate and now returns a SyncPoller in `CertificateClient` and PollerFlux in `CertificateAsyncClient` to track this long-running operation. -- recoverDeletedCertificate method has been renamed to beginRecoverDeletedCertificate and now returns a SyncPoller in `CertificateClient` and PollerFlux in `CertificateAsyncClient` to track this long-running operation. -- `subject` and `issuerName` constructor parameters have been switched on `CertificatePolicy`. -- `subjectAlternativeNames` and `issuerName` constructor parameters have been switched on `CertificatePolicy`. -- The `SubjectAlternativeNames` class has been rewritten to contain `DnsNames`, `Emails`, and `UserPrincipalNames` collection properties. -- `CertificateIssuer.administrators` has been renamed to `CertificateIssuer.administratorContacts`. -- `CertificateKeyType.Oct` has been removed. -- `ImportCertificateOptions.value` has been renamed to `ImportCertificateOptions.certificate`. -- `LifeTimeAction` has been renamed to `LifetimeAction`. -- `CertificateKeyCurveName` and `CertificateKeyType` have been moved from package `com.azure.security.keyvault.certificates.models.webkey` to `com.azure.security.keyvault.certificates.models`. -- On `CertificateProperties`, expires, created, and updated have been renamed to expiresOn, createdOn, and updatedOn respectively. -- On `DeletedCertificate`, deletedDate has been renamed to DeletedOn. -- `CertificateImportOptions` has been renamed to `ImportCertificateOptions`. -- `CertificateMergeOptions` has been renamed to `MergeCertificateOptions`. -- `CertificatePolicy.DEFAULT` has been removed. - - -### Major changes - -- The `SubjectAlternativeNames` class now allows you to set multiple types of subject alternative names using any of the `DnsNames`, `Emails`, and `UserPrincipalNames` collection properties. -- A new `CertificatePolicy` constructor allows you to both pass in both the `subject` and `subjectAlternativeNames` parameters. -- `CertificateIssuer.provider` was added. -- `CertificatePolicy.getDefault()` was added and allows you to get the default policy. - - -## 4.0.0-preview.5 (2019-11-01) - -### Breaking changes -- `beginCreateCertificate` method now returns a SyncPoller in `CertificateClient` and a PollerFlux in`CertificateAsyncClient` -- Certificate has been renamed to KeyVaultCertificate to avoid ambiguity with other libraries and to yield better search results. -- endpoint method on CertificateClientBuilder has been renamed to vaultUrl. -- listCertificates and listCertificateVersions methods have been renamed to listPropertiesOfCertificates and listPropertiesOfCertificateVersions respectively in `CertificateClient` and `CertificateAsyncClient`. -- restoreCertificate method has been renamed to restoreCertificateBackup in `CertificateClient` and `CertificatAsyncClient` to better associate it with CertificateClient.backupCertificate. -- LifetimeActionType class has been renamed to CertificatePolicyAction. -- Contact class has been renamed to CertificateContact. -- Issuer class has been renamed to CertificateIssuer. -- getCertificate method has been renamed to getCertificateVersion in `CertificateClient` and `CertificateAsyncClient` -- getCertificateWithPolicy method has been renamed to getCertificate and now returns KeyVaultCertificateWithPolicy in `CertificateClient` and `CertificateAsyncClient` -- getPendingCertificateSigningRequest method has been removed from `CertificateClient` and `CertificateAsyncClient` - -### Major changes -- CertificateClient.vaultUrl has been added with the original value pass to CertificateClient. -- KeyVaultCertificateWithPolicy has been added and is returned by getCertificate method in `CertificateClient` and `CertificateAsyncClient` - - -## 4.0.0-preview.4 (2019-10-08) -For details on the Azure SDK for Java (September 2019 Preview) release refer to the [release announcement](https://aka.ms/azure-sdk-preview4-java). - -- `importCertificate` API has been added to `CertificateClient` and `CertificateAsyncClient`. -- Updated to be fully compliant with the Java 9 Platform Module System. - -### Breaking changes - -- `CertificateBase` has been renamed to `CertificateProperties`. -- `Certificate` no longer extends `CertificateProperties`, but instead contains a `CertificateProperties` property named `Properties`. -- `IssuerBase` has been renamed to `IssuerProperties`. -- `Issuer` no longer extends `IssuerProperties`, but instead contains a `IssuerProperties` property named `Properties`. -- `CertificatePolicy` has been flattened to include all properties from `KeyOptions` and derivative classes. -- `KeyOptions` and derivative classes have been removed. -- `KeyType` has been renamed to `CertificateKeyType`. -- `KeyCurveName` has been renamed to `CertificateKeyCurveName`. -- `KeyUsage` has been renamed to `CertificateKeyUsage`. -- `SecretContentType` has been renamed to `CertificateContentType`. -- `updateCertificate` method has been renamed to `updateCertificateProperties` in `CertificateClient` and `CertificateAsyncClient`. -- Getters and setters were updated to use Java Bean notation. -- Changed VoidResponse to Response on sync API, and Mono to Mono> on async API. -- `createCertificate` API has been renamed to `beginCreateCertificate` in in `CertificateClient` and `CertificateAsyncClient`. -- Enumerations including `CertificateKeyCurveName`, `CertificateKeyUsage`, `CertificateContentType` and `CertificateKeyType` are now structures that define well-known, supported static fields. - -## 4.0.0-preview.3 (2019-09-10) -For details on the Azure SDK for Java (August 2019 Preview) release refer to the [release announcement](https://aka.ms/azure-sdk-preview3-java). - -This library is not a direct replacement for certificates management operations from [microsoft-azure-keyvault](https://github.com/Azure/azure-sdk-for-java/tree/azure-security-keyvault-keys_4.0.0/sdk/keyvault/microsoft-azure-keyvault). Applications using that library would require code changes to use `azure-keyvault-certificates`. -This package's -[documentation](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md) -and -[samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java) -demonstrate the new API. - - -### Features Added -- Packages scoped by functionality - - `azure-keyvault-keys` contains a `KeyClient` and `KeyAsyncClient` for key operations, - `azure-keyvault-secrets` contains a `SecretClient` and `SecretAsyncClient` for secret operations, - `azure-keyvault-certificates` contains a `CertificateClient` and `CertificateAsyncClient` for certificate operations -- Client instances are scoped to vaults (an instance interacts with one vault -only) -- Reactive streams support using [Project Reactor](https://projectreactor.io/). -- Authentication using `azure-identity` credentials - - see this package's - [documentation](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md) - , and the - [Azure Identity documentation](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity/README.md) - for more information -- Added support for HTTP challenge based authentication, allowing clients to interact with vaults in sovereign clouds. diff --git a/sdk/keyvault/azure-security-keyvault-certificates/README.md b/sdk/keyvault/azure-security-keyvault-certificates/README.md deleted file mode 100644 index 6bad6846d26f..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/README.md +++ /dev/null @@ -1,290 +0,0 @@ -# Azure Key Vault Certificate client library for Java -Azure Key Vault allows you to securely manage and tightly control your certificates. The Azure Key Vault Certificate client library supports certificates backed by RSA and EC keys. - -Multiple certificates and multiple versions of the same certificate can be kept in the Key Vault. Cryptographic keys in Azure Key Vault backing the certificates are represented as [JSON Web Key (JWK)][jwk_specification] objects. This library offers operations to create, retrieve, update, delete, purge, backup, restore, and list the certificates, as well as its versions. - -[Source code][source_code] | [API reference documentation][api_documentation] | [Product documentation][azkeyvault_docs] | [Samples][certificates_samples] - -## Getting started -### Include the package -#### Include the BOM file -Please include the `azure-sdk-bom` to your project to take dependency on the General Availability (GA) version of the library. In the following snippet, replace the {bom_version_to_target} placeholder with the version number. To learn more about the BOM, see the [AZURE SDK BOM README](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/boms/azure-sdk-bom/README.md). - -```xml - - - - com.azure - azure-sdk-bom - {bom_version_to_target} - pom - import - - - -``` - -and then include the direct dependency in the dependencies section without the version tag as shown below. - -```xml - - - com.azure - azure-security-keyvault-certificates - - -``` - -#### Include direct dependency -If you want to take dependency on a particular version of the library that is not present in the BOM, add the direct dependency to your project as follows. - -[//]: # ({x-version-update-start;com.azure:azure-security-keyvault-certificates;current}) -```xml - - com.azure - azure-security-keyvault-certificates - 4.7.2 - -``` -[//]: # ({x-version-update-end}) - -### Prerequisites -- A [Java Development Kit (JDK)][jdk_link], version 8 or later. - - Here are details about [Java 8 client compatibility with Azure Certificate Authority](https://learn.microsoft.com/azure/security/fundamentals/azure-ca-details?tabs=root-and-subordinate-cas-list#client-compatibility-for-public-pkis). -- An [Azure Subscription][azure_subscription]. -- An existing [Azure Key Vault][azure_keyvault]. If you need to create a key vault, you can do so in the Azure Portal by following the steps in [this document][azure_keyvault_portal]. Alternatively, you can use the Azure CLI by following the steps in [this document][azure_keyvault_cli]. - -### Authenticate the client -In order to interact with the Azure Key Vault service, you will need to create an instance of the [`CertificateClient`](#create-certificate-client) class, a **vault url** and a credential object. The examples shown in this document use a credential object named [`DefaultAzureCredential`][default_azure_credential], which is appropriate for most scenarios, including local development and production environments. Additionally, we recommend using a [managed identity][managed_identity] for authentication in production environments. - -You can find more information on different ways of authenticating and their corresponding credential types in the [Azure Identity documentation][azure_identity]. - -#### Create certificate client -Once you perform [the authentication set up that suits you best][default_azure_credential] and replaced **your-key-vault-url** with the URL for your key vault, you can create the `CertificateClient`: - -```java readme-sample-createCertificateClient -CertificateClient certificateClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); -``` - -> NOTE: For using an asynchronous client use `CertificateAsyncClient` instead of `CertificateClient` and call `buildAsyncClient()`. - -## Key concepts -### Certificate -Azure Key Vault supports certificates with secret content types (`PKCS12` & `PEM`). The certificate can be backed by keys in Azure Key Vault of types (`EC` & `RSA`). In addition to the certificate policy, the following attributes may be specified: -* enabled: Specifies whether the certificate is enabled and usable. -* created: Indicates when this version of the certificate was created. -* updated: Indicates when this version of the certificate was updated. - -### Certificate client -The certificate client performs the interactions with the Azure Key Vault service for getting, setting, updating, deleting, and listing certificates and its versions. The client also supports CRUD operations for certificate issuers and contacts in the key vault. Asynchronous (`CertificateAsyncClient`) and synchronous (`CertificateClient`) clients exist in the SDK allowing for the selection of a client based on an application's use case. Once you've initialized a certificate, you can interact with the primary resource types in Azure Key Vault. - -## Examples -### Sync API -The following sections provide several code snippets covering some of the most common Azure Key Vault Certificate service tasks, including: -- [Create a certificate](#create-a-certificate) -- [Retrieve a certificate](#retrieve-a-certificate) -- [Update an existing certificate](#update-an-existing-certificate) -- [Delete a certificate](#delete-a-certificate) -- [List certificates](#list-certificates) - -### Create a certificate -Create a certificate to be stored in the Azure Key Vault. -- `beginCreateCertificate` creates a new certificate in the Azure Key Vault. If a certificate with the same name already exists then a new version of the certificate is created. - -```java readme-sample-createCertificate -SyncPoller certificatePoller = - certificateClient.beginCreateCertificate("certificateName", CertificatePolicy.getDefault()); -certificatePoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); -KeyVaultCertificate certificate = certificatePoller.getFinalResult(); -System.out.printf("Certificate created with name \"%s\"%n", certificate.getName()); -``` - -### Retrieve a certificate -Retrieve a previously stored certificate by calling `getCertificate` or `getCertificateVersion`. - -```java readme-sample-retrieveCertificate -KeyVaultCertificateWithPolicy certificate = certificateClient.getCertificate(""); -System.out.printf("Received certificate with name \"%s\", version %s and secret id %s%n", - certificate.getProperties().getName(), certificate.getProperties().getVersion(), certificate.getSecretId()); -``` - -### Update an existing certificate -Update an existing certificate by calling `updateCertificateProperties`. - -```java readme-sample-updateCertificate -// Get the certificate to update. -KeyVaultCertificate certificate = certificateClient.getCertificate(""); -// Update certificate enabled status. -certificate.getProperties().setEnabled(false); -KeyVaultCertificate updatedCertificate = certificateClient.updateCertificateProperties(certificate.getProperties()); -System.out.printf("Updated certificate with name \"%s\" and enabled status \"%s\"%n", - updatedCertificate.getProperties().getName(), updatedCertificate.getProperties().isEnabled()); -``` - -### Delete a certificate -Delete an existing certificate by calling `beginDeleteCertificate`. - -```java readme-sample-deleteCertificate -SyncPoller deleteCertificatePoller = - certificateClient.beginDeleteCertificate(""); - -// Deleted certificate is accessible as soon as polling beings. -PollResponse pollResponse = deleteCertificatePoller.poll(); - -// Deletion date only works for a SoftDelete-enabled Key Vault. -System.out.printf("Deleted certificate with name \"%s\" and recovery id %s", pollResponse.getValue().getName(), - pollResponse.getValue().getRecoveryId()); - -// Certificate is being deleted on server. -deleteCertificatePoller.waitForCompletion(); -``` - -### List certificates -List the certificates in the key vault by calling `listPropertiesOfCertificates`. - -```java readme-sample-listCertificates -// List operations don't return the certificates with their full information. So, for each returned certificate we call -// getCertificate to get the certificate with all its properties excluding the policy. -for (CertificateProperties certificateProperties : certificateClient.listPropertiesOfCertificates()) { - KeyVaultCertificate certificateWithAllProperties = - certificateClient.getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); - System.out.printf("Received certificate with name \"%s\" and secret id %s", - certificateWithAllProperties.getProperties().getName(), certificateWithAllProperties.getSecretId()); -} -``` - -### Async API -The following sections provide several code snippets covering some of the most common asynchronous Azure Key Vault Certificate service tasks, including: -- [Create a certificate asynchronously](#create-a-certificate-asynchronously) -- [Retrieve a certificate asynchronously](#retrieve-a-certificate-asynchronously) -- [Update an existing certificate asynchronously](#update-an-existing-certificate-asynchronously) -- [Delete a certificate asynchronously](#delete-a-certificate-asynchronously) -- [List certificates asynchronously](#list-certificates-asynchronously) - -> Note : You should add `System.in.read()` or `Thread.sleep()` after the function calls in the main class/thread to allow async functions/operations to execute and finish before the main application/thread exits. - -### Create a certificate asynchronously -Create a certificate to be stored in the Azure Key Vault. -- `beginCreateCertificate` creates a new certificate in the Azure Key Vault. If a certificate with same name already exists then a new version of the certificate is created. - -```java readme-sample-createCertificateAsync -// Creates a certificate using the default policy and polls on its progress. -certificateAsyncClient.beginCreateCertificate("", CertificatePolicy.getDefault()) - .subscribe(pollResponse -> { - System.out.println("---------------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }); -``` - -### Retrieve a certificate asynchronously -Retrieve a previously stored certificate by calling `getCertificate` or `getCertificateVersion`. - -```java readme-sample-retrieveCertificateAsync -certificateAsyncClient.getCertificate("") - .subscribe(certificateResponse -> - System.out.printf("Certificate was returned with name \"%s\" and secretId %s%n", - certificateResponse.getProperties().getName(), certificateResponse.getSecretId())); -``` - -### Update an existing certificate asynchronously -Update an existing certificate by calling `updateCertificateProperties`. - -```java readme-sample-updateCertificateAsync -certificateAsyncClient.getCertificate("") - .flatMap(certificate -> { - // Update enabled status of the certificate. - certificate.getProperties().setEnabled(false); - return certificateAsyncClient.updateCertificateProperties(certificate.getProperties()); - }).subscribe(certificateResponse -> System.out.printf("Certificate's enabled status: %s%n", - certificateResponse.getProperties().isEnabled())); -``` - -### Delete a certificate asynchronously -Delete an existing certificate by calling `beginDeleteCertificate`. - -```java readme-sample-deleteCertificateAsync -certificateAsyncClient.beginDeleteCertificate("") - .subscribe(pollResponse -> { - System.out.printf("Deletion status: %s%n", pollResponse.getStatus()); - System.out.printf("Deleted certificate name: %s%n", pollResponse.getValue().getName()); - System.out.printf("Certificate deletion date: %s%n", pollResponse.getValue().getDeletedOn()); - }); -``` - -### List certificates asynchronously -List the certificates in the Azure Key Vault by calling `listPropertiesOfCertificates`. - -```java readme-sample-listCertificateAsync -// The List Certificates operation returns certificates without their full properties, so for each certificate returned -// we call `getCertificate` to get all its attributes excluding the policy. -certificateAsyncClient.listPropertiesOfCertificates() - .flatMap(certificateProperties -> certificateAsyncClient - .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion())) - .subscribe(certificateResponse -> - System.out.printf("Received certificate with name \"%s\" and key id %s", certificateResponse.getName(), - certificateResponse.getKeyId())); -``` - -## Troubleshooting -See our [troubleshooting guide](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/TROUBLESHOOTING.md) for details on how to diagnose various failure scenarios. - -### General -Azure Key Vault Certificate clients raise exceptions. For example, if you try to retrieve a certificate after it is deleted a `404` error is returned, indicating the resource was not found. In the following snippet, the error is handled gracefully by catching the exception and displaying additional information about the error. - -```java readme-sample-troubleshooting -try { - certificateClient.getCertificate(""); -} catch (ResourceNotFoundException e) { - System.out.println(e.getMessage()); -} -``` - -### Default HTTP client -All client libraries by default use the Netty HTTP client. Adding the above dependency will automatically configure the client library to use the Netty HTTP client. Configuring or changing the HTTP client is detailed in the [HTTP clients wiki][http_clients_wiki]. - -### Default SSL library -All client libraries, by default, use the Tomcat-native Boring SSL library to enable native-level performance for SSL operations. The Boring SSL library is an Uber JAR containing native libraries for Linux / macOS / Windows, and provides better performance compared to the default SSL implementation within the JDK. For more information, including how to reduce the dependency size, refer to the [performance tuning][performance_tuning] section of the wiki. - -## Next steps -Several Key Vault Java SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Key Vault. - -## Next steps samples -Samples are explained in detail [here][samples_readme]. - -### Additional documentation -For more extensive documentation on Azure Key Vault, see the [API reference documentation][azkeyvault_rest]. - -## Contributing -This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. - -When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. - -This project has adopted the [Microsoft Open Source Code of Conduct][microsoft_code_of_conduct]. For more information see the Code of Conduct FAQ or contact with any additional questions or comments. - - -[source_code]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/src -[api_documentation]: https://azure.github.io/azure-sdk-for-java -[azkeyvault_docs]: https://learn.microsoft.com/azure/key-vault/ -[certificates_samples]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates -[managed_identity]: https://learn.microsoft.com/azure/active-directory/managed-identities-azure-resources/overview -[azure_identity]: https://learn.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable -[azure_subscription]: https://azure.microsoft.com/ -[azure_keyvault]: https://learn.microsoft.com/azure/key-vault/general/overview -[azure_keyvault_cli]: https://learn.microsoft.com/azure/key-vault/general/quick-create-cli -[azure_keyvault_portal]: https://learn.microsoft.com/azure/key-vault/general/quick-create-portal -[default_azure_credential]: https://learn.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable#defaultazurecredential -[azkeyvault_rest]: https://learn.microsoft.com/rest/api/keyvault/ -[certificates_samples]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates -[samples_readme]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples/README.md -[performance_tuning]: https://github.com/Azure/azure-sdk-for-java/wiki/Performance-Tuning -[jdk_link]: https://learn.microsoft.com/java/azure/jdk/?view=azure-java-stable -[jwk_specification]: https://tools.ietf.org/html/rfc7517 -[http_clients_wiki]: https://learn.microsoft.com/azure/developer/java/sdk/http-client-pipeline#http-clients -[microsoft_code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fkeyvault%2Fazure-security-keyvault-certificates%2FREADME.png) diff --git a/sdk/keyvault/azure-security-keyvault-certificates/TROUBLESHOOTING.md b/sdk/keyvault/azure-security-keyvault-certificates/TROUBLESHOOTING.md deleted file mode 100644 index 7ae436b8c34d..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/TROUBLESHOOTING.md +++ /dev/null @@ -1,2 +0,0 @@ -# Troubleshooting Azure Key Vault Certificates SDK Issues -See our general [Azure Key Vault SDK Troubleshooting Guide](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/TROUBLESHOOTING.md) to troubleshoot issues common to the Azure Key Vault SDKs for Java. diff --git a/sdk/keyvault/azure-security-keyvault-certificates/assets.json b/sdk/keyvault/azure-security-keyvault-certificates/assets.json deleted file mode 100644 index 7235a61b39fc..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/assets.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "AssetsRepo": "Azure/azure-sdk-assets", - "AssetsRepoPrefixPath": "java", - "TagPrefix": "java/keyvault/azure-security-keyvault-certificates", - "Tag": "java/keyvault/azure-security-keyvault-certificates_e018897fab" -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/checkstyle-suppressions.xml b/sdk/keyvault/azure-security-keyvault-certificates/checkstyle-suppressions.xml deleted file mode 100644 index 5c4942a1773d..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/checkstyle-suppressions.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/keyvault/azure-security-keyvault-certificates/migration_guide.md b/sdk/keyvault/azure-security-keyvault-certificates/migration_guide.md deleted file mode 100644 index 846d7c81c260..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/migration_guide.md +++ /dev/null @@ -1,273 +0,0 @@ -# Guide for migrating to azure-security-keyvault-certificates from azure-keyvault -This guide is intended to assist in the migration to `azure-security-keyvault-certificates` from [deprecated] `azure-keyvault`. It will focus on side-by-side comparisons for similar operations between the two packages. - -Familiarity with the `azure-keyvault` package is assumed. For those new to the Key Vault Certificate client library for Java, please refer to the [README](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md) rather than this guide. - -## Table of contents -- [Migration benefits](#migration-benefits) -- [Cross Service SDK improvements](#cross-service-sdk-improvements) -- [Important changes](#important-changes) - - [Separate packages and clients](#separate-packages-and-clients) - - [Package names and namespaces](#package-names-and-namespaces) - - [Client instantiation](#client-instantiation) - - [Authentication](#authentication) - - [Common scenarios](#common-scenarios) - - [Async operations](#async-operations) - - [Create a certificate](#create-a-certificate) - - [Import a certificate](#import-a-certificate) - - [Retrieve a certificate](#retrieve-a-certificate) - - [List properties of certificates](#list-properties-of-certificates) - - [Delete a certificate](#delete-a-certificate) -- [Additional samples](#additional-samples) -- [Support](#support) - -## Migration benefits -> Note: `azure-keyvault` has been [deprecated]. Please upgrade to `azure-security-keyvault-certificates` for continued support. - -A natural question to ask when considering whether or not to adopt a new version or library is what the benefits of doing so would be. As Azure has matured and been embraced by a more diverse group of developers, we have been focused on learning the patterns and practices to best support developer productivity and to understand the gaps that the Java client libraries have. - -There were several areas of consistent feedback expressed across the Azure client library ecosystem. One of the most important is that the client libraries for different Azure services have not had a consistent approach to organization, naming, and API structure. Additionally, many developers have felt that the learning curve was difficult, and the APIs did not offer a good, approachable, and consistent onboarding story for those learning Azure or exploring a specific Azure service. - -To try and improve the development experience across Azure services, a set of uniform [design guidelines](https://azure.github.io/azure-sdk/general_introduction.html) was created for all languages to drive a consistent experience with established API patterns for all services. A set of [Java-specific guidelines](https://azure.github.io/azure-sdk/java_introduction.html) was also introduced to ensure that Java clients have a natural and idiomatic feel with respect to the Java ecosystem. Further details are available in the guidelines for those interested. - -### Cross Service SDK improvements -The modern Key Vault Certificate client library also provides the ability to share in some of the cross-service improvements made to the Azure development experience, such as: - -- Using the new Azure Identity library to share a single authentication approach between clients. -- A unified logging and diagnostics pipeline offering a common view of the activities across each of the client libraries. - -## Important changes -### Separate packages and clients -In the interest of simplifying the API for working with Key Vault certificates, keys and secrets, the `azure-keyvault` was split into separate packages: - -- `azure-security-keyvault-certificates` contains `CertificateClient` for working with Key Vault certificates. -- [`azure-security-keyvault-keys`](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-keys/README.md) contains `KeyClient` for working with Key Vault keys and `CryptographyClient` for performing cryptographic operations. -- [`azure-security-keyvault-secrets`](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md) contains `SecretClient` for working with Key Vault secrets. - -### Package names and namespaces -Package names and the namespace root for the modern Azure client libraries for Java have changed. Each will follow the pattern `com.azure..` where the legacy clients followed the pattern `com.microsoft.azure.`. This provides a quick and accessible means to help understand, at a glance, whether you are using the modern or legacy clients. - -In the case of the Key Vault, the modern client libraries have packages and namespaces that begin with `com.azure.security.keyvault` and were released beginning with version `4.0.0`. The legacy client libraries have packages and namespaces that begin with `com.microsoft.azure.keyvault` and a version of `1.x.x` or below. - -### Client instantiation -Previously in `azure-keyvault` you could create a `KeyVaultClient`, via a public constructor that took an authentication delegate and could be used for multiple Key Vault endpoints. - -```java -import com.microsoft.azure.keyvault.KeyVaultClient; -import com.microsoft.azure.keyvault.authentication.KeyVaultCredentials; - -KeyVaultCredentials keyVaultCredentials = new MyKeyVaultCredentials("", ""); -KeyVaultClient keyVaultClient = new KeyVaultClient(keyVaultCredentials); -``` - -Now, across all modern Azure client libraries, client instances are created via builders, which consistently take an endpoint or connection string along with token credentials. This means that you can use a single client builder to instantiate multiple clients that share some configuration. - -```java -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.CertificateClient; -import com.azure.security.keyvault.certificates.CertificateClientBuilder; - -TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); -CertificateClientBuilder certificateClientBuilder = new CertificateClientBuilder() - .vaultUrl("") - .credential(tokenCredential); - -// Create a client. -CertificateClient someCertificateClient = certificateClientBuilder.buildClient(); - -// Create a client with the same configuration, plus some more. -CertificateClient anotherCertificateClient = certificateClientBuilder - .addPolicy(new AddDatePolicy()) - .buildClient(); -``` - -### Authentication -Previously in `azure-keyvault` you could create a `KeyVaultClient` by passing either a `KeyVaultCredential` or `RestClient` from `client-runtime`: - -```java -import com.microsoft.azure.keyvault.KeyVaultClient; -import com.microsoft.azure.keyvault.authentication.KeyVaultCredentials; - -KeyVaultCredentials keyVaultCredentials = new MyKeyVaultCredentials("", ""); -KeyVaultClient keyVaultClient = new KeyVaultClient(keyVaultCredentials); -``` - -Now in `azure-security-keyvault-certificates` you can create a `CertificateClient` using any credential from [`azure-identity`](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity/README.md). Below is an example using [`DefaultAzureCredential`](https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable#defaultazurecredential): - -```java -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.CertificateClient; -import com.azure.security.keyvault.certificates.CertificateClientBuilder; - -TokenCredential tokenCredentials = new DefaultAzureCredentialBuilder().build(); - -CertificateClient certificateClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(tokenCredential) - .buildClient(); -``` - -### Async operations -The modern `azure-security-keyvault-certificates` library includes a complete set of async APIs that return [Project Reactor-based types](https://projectreactor.io/), as opposed to `azure-keyvault` async APIs that return either [Observable](https://reactivex.io/RxJava/javadoc/io/reactivex/Observable.html) or [ServiceFuture](https://azure.github.io/ref-docs/java/com/microsoft/rest/ServiceFuture.html). - -Another difference is that async operations are available on their own separate async clients, which include the word `Async` in their name, like `CertificateAsyncClient`. - -All modern Azure async clients can be created virtually the same way as sync clients, with the slight difference of calling `buildAsyncClient` on the client builder instead of `buildClient`: - -```java -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.CertificateClient; -import com.azure.security.keyvault.certificates.CertificateClientBuilder; - -TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); -CertificateClientBuilder certificateClientBuilder = new CertificateClientBuilder() - .vaultUrl("") - .credential(tokenCredential); - -// To create an async client. -CertificateAsyncClient certificateAsyncClient = certificateClientBuilder.buildAsyncClient(); - -// To create a sync client. -CertificateClient certificateClient = certificateClientBuilder.buildClient(); -``` - -### Common scenarios -#### Create a certificate -In `azure-keyvault` you could create a certificate by using `KeyVaultClient`'s `createCertificate` method, which required a vault endpoint, certificate name, and certificate value. This method returned a `CertificateOperation`, which can be used to check for the status of the creation operation and obtain certificate details. - -```java -String keyVaultUrl = "https://.vault.azure.net/"; - -CertificateOperation certificate = keyVaultClient.createCertificate(keyVaultUrl, ""); - -// Get the status of the the creation operation -String status = certificateOperation.status(); - -// Get the id of the certificate -String certificateId = certificateOperation.id(); -``` - -Now in `azure-security-keyvault-certificates` you can create a certificate by providing a certificate name and a custom management policy or a default policy to the `beginCreateCertificate` method. This method returns a long operation poller object that can be used to wait/check on the operation. Calling `poll` on the poller will return information about the created certificate (as a `KeyVaultCertificateWithPolicy`) without waiting for the operation to complete, but calling `waitForCompletion` will wait for the deletion to complete. Once completed, the certificate can be retrieved by calling `getFinalResult`. - -```java -// Create a certificate by providing name and policy. -SyncPoller certificatePoller = - certificateClient.beginCreateCertificate("", CertificatePolicy.getDefault()); - -// You can poll for the status of the creation operation. -PollResponse pollResponse = certificatePoller.poll(); -CertificateOperation certificateOperation = pollResponse.getValue(); -LongRunningOperationStatus status = certificateOperationPollResponse.getStatus(); - -// Wait for completion before attempting to get the certificate. -certificatePoller.waitForCompletion(); -KeyVaultCertificate certificate = certificatePoller.getFinalResult(); -``` - -#### Import a certificate -In `azure-keyvault` you could import a certificate by using `KeyVaultClient`'s `importCertificate` method, which required a vault endpoint, certificate name, and base64-encoded certificate contents. This method returned a `CertificateBundle`. - -```java -CertificateBundle certificateBundle = - keyVaultClient.importCertificate(keyVaultUrl, "", ""); -``` - -Now in `azure-security-keyvault-certificates` you can import a certificate by providing the certificate name and contents to `importCertificate`, which returns a `KeyVaultCertificateWithPolicy`. - -```java -byte[] certificateContents; - -KeyVaultCertificateWithPolicy certificate = - certificateClient.importCertificate( - new ImportCertificateOptions("", certificateContents)); -``` - -#### Retrieve a certificate -In `azure-keyvault` you could retrieve a certificate (in a `CertificateBundle`) by using `getCertificate` in one of the following ways: - -- Using the desired key vault endpoint and certificate name to get the latest version of a certificate. -- Using the desired key vault endpoint, certificate name and certificate version to get a specific certificate version. -- Using the certificate identifier to get a specific certificate version. - -Additionally, you could list the properties of the versions of a certificate with the `getCertificateVersions` method, which returned a `PagedList` of `CertificateItem`. - -```java -String keyVaultUrl = "https://.vault.azure.net/"; - -// Get a certificate's latest version. -CertificateBundle certificate = keyVaultClient.getCertificate(keyVaultUrl, ""); - -// Get a certificate's specific version. -CertificateBundle certificateVersion = keyVaultClient.getCertificate(keyVaultUrl, "", ""); - -// Get a certificate's specific version using its id. -String certificateIdentifier = "https://.vault.azure.net/certificates//"; -CertificateBundle certificateWithId = keyVaultClient.getCertificate(certificateIdentifier); - -// Get a key's versions. -PagedList certificateVersions = keyVaultClient.getCertificateVersions(keyVaultUrl, ""); -``` - -Now in `azure-security-keyvault-certificates` you can retrieve a certificate's latest version (as a `KeyVaultCertificate`) by providing the certificate name to the `getCertificate` method. You can also get a certificate's specific version by passing the certificate name and certificate version to `getCertificateVersion`. - -Additionally, you con list the properties of the versions of a certificate with the `getCertificateVersions` method, which returned a `PagedIterable` of `CertificateProperties`. - -```java -// Get a certificate's latest version. -KeyVaultCertificate certificate = certificateClient.getCertificate(""); - -// Get a certificate's specific version. -KeyVaultCertificate certificateVersion = certificateClient.getCertificateVersion("", ""); - -// Get a certificates's versions' properties. -PagedIterable certificateVersionsProperties = certificateClient.listPropertiesOfCertificateVersions(""); -``` - -#### List properties of certificates -In `azure-keyvault` you could list the properties of certificates in a specified vault with the `getCertificates` methods. This returned a `PagedList` containing `CertificateItem` instances. - -```java -PagedList certificatesProperties = keyVaultClient.getCertificates(keyVaultUrl); -``` - -Now in `azure-security-keyvault-certificates` you can list the properties of certificates in a vault with the `listPropertiesOfCertificates` method. This returns an iterator-like object containing `CertificateProperties` instances. - -```java -PagedIterable certificatesProperties = certificateClient.listPropertiesOfCertificates(); -``` - -#### Delete a certificate -In `azure-keyvault` you could delete all versions of a certificate with the `deleteCertificate` method. This returned information about the deleted certificate (as a `DeletedCertificateBundle`), but you could not poll the deletion operation to know when it completed. This would be valuable information if you intended to permanently delete the deleted certificate with `purgeDeletedCertificate`. - -```java -DeletedCertificateBundle deletedCertificate = keyVaultClient.deleteCertificate(keyVaultUrl, ""); - -// This purge would fail if deletion hadn't finished -keyVaultClient.purgeDeletedCertificate(keyVaultUrl, ""); -``` - -Now in `azure-security-keyvault-certificates` you can delete a certificate with `beginDeleteCertificate`, which returns a long operation poller object that can be used to wait/check on the operation. Calling `poll` on the poller will return information about the deleted certificate (as a `DeletedCertificate`) without waiting for the operation to complete, but calling `waitForCompletion` will wait for the deletion to complete. Again, `purgeDeletedCertificate` will permanently delete your deleted certificate and make it unrecoverable. - -```java -SyncPoller deletedCertificatePoller = - certificateClient.beginDeleteCertificate(""); -PollResponse pollResponse = deletedCertificatePoller.poll(); -DeletedCertificate deletedCertificate = pollResponse.getValue(); - -// Wait for completion before attempting to purge the certificate. -deletedCertificatePoller.waitForCompletion(); -certificateClient.purgeDeletedCertificate(""); -``` - -## Additional samples -More examples can be found [here](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples). - -## Support - -If you have migrated your code base and experiencing errors, see our [troubleshooting guide][troubleshooting_guide]. For additional support, please search our [existing issues][existing_issues] or [open a new issue][open_new_issue]. You may also find existing answers on community sites like [Stack Overflow]. - -[deprecated]: https://aka.ms/azsdk/deprecated -[existing_issues]: https://github.com/Azure/azure-sdk-for-java/issues -[open_new_issue]: https://github.com/Azure/azure-sdk-for-java/issues/new/choose -[stack_overflow]: https://stackoverflow.com/questions/tagged/azure-keyvault+java -[troubleshooting_guide]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/TROUBLESHOOTING.md diff --git a/sdk/keyvault/azure-security-keyvault-certificates/pom.xml b/sdk/keyvault/azure-security-keyvault-certificates/pom.xml deleted file mode 100644 index cc28d96e759d..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/pom.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - 4.0.0 - - azure-client-sdk-parent - com.azure - 1.7.0 - ../../parents/azure-client-sdk-parent - - - com.azure - azure-security-keyvault-certificates - 4.8.0-beta.1 - - Microsoft Azure client library for KeyVault Certificates - This module contains client library for Microsoft Azure KeyVault Certificates. - https://github.com/Azure/azure-sdk-for-java - - - - azure-java-build-docs - ${site.url}/site/${project.artifactId} - - - - - scm:git:https://github.com/Azure/azure-sdk-for-java - scm:git:git@github.com:Azure/azure-sdk-for-java.git - HEAD - - - - - - --add-exports com.azure.core/com.azure.core.implementation.http=ALL-UNNAMED - --add-exports com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED - - --add-opens com.azure.security.keyvault.certificates/com.azure.security.keyvault.certificates=ALL-UNNAMED - --add-opens com.azure.security.keyvault.certificates/com.azure.security.keyvault.certificates.implementation=ALL-UNNAMED - --add-opens com.azure.security.keyvault.certificates/com.azure.security.keyvault.certificates.models=ALL-UNNAMED - - - checkstyle-suppressions.xml - false - spotbugs-exclude.xml - - - - - com.azure - azure-core - 1.54.1 - - - com.azure - azure-json - 1.4.0 - - - - com.azure - azure-core-http-netty - 1.15.7 - - - - - com.azure - azure-core-test - 1.27.0-beta.4 - test - - - com.azure - azure-identity - 1.15.0 - test - - - org.bouncycastle - bcpkix-lts8on - 2.73.6 - test - - - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.3.1 - - - copy-resources - validate - - copy-resources - - - ${basedir}/target/test-classes - - - ${basedir}/src/test/resources - - - - - - - - - diff --git a/sdk/keyvault/azure-security-keyvault-certificates/spotbugs-exclude.xml b/sdk/keyvault/azure-security-keyvault-certificates/spotbugs-exclude.xml deleted file mode 100644 index 4c1d8e4609b6..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/spotbugs-exclude.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateAsyncClient.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateAsyncClient.java deleted file mode 100644 index 826e0b66ab37..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateAsyncClient.java +++ /dev/null @@ -1,2131 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.HttpPipeline; -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.Response; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollResponse; -import com.azure.core.util.polling.PollerFlux; -import com.azure.core.util.polling.PollingContext; -import com.azure.security.keyvault.certificates.implementation.CertificateClientImpl; -import com.azure.security.keyvault.certificates.implementation.CertificateIssuerHelper; -import com.azure.security.keyvault.certificates.implementation.CertificateOperationHelper; -import com.azure.security.keyvault.certificates.implementation.CertificatePolicyHelper; -import com.azure.security.keyvault.certificates.implementation.CertificatePropertiesHelper; -import com.azure.security.keyvault.certificates.implementation.DeletedCertificateHelper; -import com.azure.security.keyvault.certificates.implementation.IssuerPropertiesHelper; -import com.azure.security.keyvault.certificates.implementation.KeyVaultCertificateWithPolicyHelper; -import com.azure.security.keyvault.certificates.implementation.models.CertificateAttributes; -import com.azure.security.keyvault.certificates.implementation.models.CertificateIssuerItem; -import com.azure.security.keyvault.certificates.implementation.models.CertificateItem; -import com.azure.security.keyvault.certificates.implementation.models.Contacts; -import com.azure.security.keyvault.certificates.implementation.models.DeletedCertificateItem; -import com.azure.security.keyvault.certificates.implementation.models.IssuerBundle; -import com.azure.security.keyvault.certificates.implementation.models.KeyVaultErrorException; -import com.azure.security.keyvault.certificates.models.CertificateContact; -import com.azure.security.keyvault.certificates.models.CertificateContentType; -import com.azure.security.keyvault.certificates.models.CertificateIssuer; -import com.azure.security.keyvault.certificates.models.CertificateOperation; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.CertificatePolicyAction; -import com.azure.security.keyvault.certificates.models.CertificateProperties; -import com.azure.security.keyvault.certificates.models.DeletedCertificate; -import com.azure.security.keyvault.certificates.models.ImportCertificateOptions; -import com.azure.security.keyvault.certificates.models.IssuerProperties; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy; -import com.azure.security.keyvault.certificates.models.LifetimeAction; -import com.azure.security.keyvault.certificates.models.MergeCertificateOptions; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.net.HttpURLConnection; -import java.nio.charset.StandardCharsets; -import java.time.Duration; -import java.util.ArrayList; -import java.util.Base64; -import java.util.List; -import java.util.Map; -import java.util.function.Function; - -import static com.azure.core.util.FluxUtil.monoError; -import static com.azure.security.keyvault.certificates.implementation.CertificateIssuerHelper.createCertificateIssuer; -import static com.azure.security.keyvault.certificates.implementation.CertificateIssuerHelper.getIssuerBundle; -import static com.azure.security.keyvault.certificates.implementation.CertificateOperationHelper.createCertificateOperation; -import static com.azure.security.keyvault.certificates.implementation.CertificatePolicyHelper.createCertificatePolicy; -import static com.azure.security.keyvault.certificates.implementation.CertificatePolicyHelper.getImplCertificatePolicy; -import static com.azure.security.keyvault.certificates.implementation.DeletedCertificateHelper.createDeletedCertificate; -import static com.azure.security.keyvault.certificates.implementation.IssuerPropertiesHelper.createIssuerProperties; -import static com.azure.security.keyvault.certificates.implementation.KeyVaultCertificateWithPolicyHelper.createCertificateWithPolicy; - -/** - * The CertificateAsyncClient provides asynchronous methods to manage {@link KeyVaultCertificate certifcates} in the - * key vault. The client supports creating, retrieving, updating, merging, deleting, purging, backing up, - * restoring and listing the {@link KeyVaultCertificate certificates}. The client also supports listing - * {@link DeletedCertificate deleted certificates} for a soft-delete enabled key vault. - * - *

The client further allows creating, retrieving, updating, deleting and listing the - * {@link CertificateIssuer certificate issuers}. The client also supports creating, listing and deleting - * {@link CertificateContact certificate contacts}

- * - *

Getting Started

- * - *

In order to interact with the Azure Key Vault service, you will need to create an instance of the - * {@link CertificateAsyncClient} class, a vault url and a credential object.

- * - *

The examples shown in this document use a credential object named DefaultAzureCredential for authentication, - * which is appropriate for most scenarios, including local development and production environments. Additionally, - * we recommend using a - * - * managed identity for authentication in production environments. - * You can find more information on different ways of authenticating and their corresponding credential types in the - * - * Azure Identity documentation".

- * - *

Sample: Construct Asynchronous Certificate Client

- * - *

The following code sample demonstrates the creation of a - * {@link com.azure.security.keyvault.certificates.CertificateAsyncClient}, using the - * {@link com.azure.security.keyvault.certificates.CertificateClientBuilder} to configure it.

- * - * - *
- * CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
- *     .credential(new DefaultAzureCredentialBuilder().build())
- *     .vaultUrl("<your-key-vault-url>")
- *     .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
- *     .buildAsyncClient();
- * 
- * - * - *
- * - *
- * - *

Create a Certificate

- * The {@link CertificateAsyncClient} can be used to create a certificate in the key vault. - * - *

Code Sample:

- *

The following code sample demonstrates how to asynchronously create a certificate in the key vault, - * using the {@link CertificateAsyncClient#beginCreateCertificate(String, CertificatePolicy)} API.

- * - * - *
- * CertificatePolicy certPolicy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12");
- * certificateAsyncClient.beginCreateCertificate("certificateName", certPolicy)
- *     .subscribe(pollResponse -> {
- *         System.out.println("---------------------------------------------------------------------------------");
- *         System.out.println(pollResponse.getStatus());
- *         System.out.println(pollResponse.getValue().getStatus());
- *         System.out.println(pollResponse.getValue().getStatusDetails());
- *     });
- * 
- * - * - *

Note: For the synchronous sample, refer to {@link CertificateClient}.

- * - *
- * - *
- * - *

Get a Certificate

- * The {@link CertificateAsyncClient} can be used to retrieve a certificate from the key vault. - * - *

Code Sample:

- *

The following code sample demonstrates how to asynchronously retrieve a certificate from the key vault, using - * the {@link CertificateAsyncClient#getCertificate(String)} API.

- * - * - *
- * certificateAsyncClient.getCertificate("certificateName")
- *     .contextWrite(Context.of(key1, value1, key2, value2))
- *     .subscribe(certificateResponse ->
- *         System.out.printf("Certificate is returned with name %s and secretId %s %n",
- *             certificateResponse.getProperties().getName(), certificateResponse.getSecretId()));
- * 
- * - * - *

Note: For the synchronous sample, refer to {@link CertificateClient}.

- * - *
- * - *
- * - *

Delete a Certificate

- * The {@link CertificateAsyncClient} can be used to delete a certificate from the key vault. - * - *

Code Sample:

- *

The following code sample demonstrates how to asynchronously delete a certificate from the Azure - * KeyVault, using the {@link CertificateAsyncClient#beginDeleteCertificate(String)} API.

- * - * - *
- * certificateAsyncClient.beginDeleteCertificate("certificateName")
- *     .subscribe(pollResponse -> {
- *         System.out.println("Delete Status: " + pollResponse.getStatus().toString());
- *         System.out.println("Delete Certificate Name: " + pollResponse.getValue().getName());
- *         System.out.println("Certificate Delete Date: " + pollResponse.getValue().getDeletedOn().toString());
- *     });
- * 
- * - * - *

Note: For the synchronous sample, refer to {@link CertificateClient}.

- * - * @see com.azure.security.keyvault.certificates - * @see CertificateClientBuilder - */ -@ServiceClient( - builder = CertificateClientBuilder.class, - isAsync = true, - serviceInterfaces = CertificateClientImpl.CertificateClientService.class) -public final class CertificateAsyncClient { - private static final ClientLogger LOGGER = new ClientLogger(CertificateAsyncClient.class); - - private final CertificateClientImpl implClient; - private final String vaultUrl; - - /** - * Creates a CertificateAsyncClient to service requests - * - * @param implClient The implementation client to route requests through. - * @param vaultUrl The vault url. - */ - CertificateAsyncClient(CertificateClientImpl implClient, String vaultUrl) { - this.implClient = implClient; - this.vaultUrl = vaultUrl; - } - - /** - * Get the vault endpoint url to which service requests are sent to. - * @return the vault endpoint url - */ - public String getVaultUrl() { - return vaultUrl; - } - - /** - * Gets the {@link HttpPipeline} powering this client. - * - * @return The pipeline. - */ - HttpPipeline getHttpPipeline() { - return implClient.getHttpPipeline(); - } - - /** - * Creates a new certificate. If this is the first version, the certificate resource is created. This operation - * requires the certificates/create permission. - * - *

Code Samples

- *

Create certificate is a long running operation. The {@link PollerFlux poller} allows users to automatically - * poll on the create certificate operation status. It is possible to monitor each intermediate poll response during - * the poll operation.

- * - * - *
-     * CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12");
-     * Map<String, String> tags = new HashMap<>();
-     * tags.put("foo", "bar");
-     * certificateAsyncClient.beginCreateCertificate("certificateName", policy, true, tags)
-     *     .subscribe(pollResponse -> {
-     *         System.out.println("---------------------------------------------------------------------------------");
-     *         System.out.println(pollResponse.getStatus());
-     *         System.out.println(pollResponse.getValue().getStatus());
-     *         System.out.println(pollResponse.getValue().getStatusDetails());
-     *     });
-     * 
- * - * - * @param certificateName The name of the certificate to be created. - * @param policy The policy of the certificate to be created. - * @param isEnabled The enabled status for the certificate. - * @param tags The application specific metadata to set. - * @throws NullPointerException if {@code policy} is null. - * @throws ResourceModifiedException when invalid certificate policy configuration is provided. - * @return A {@link PollerFlux} polling on the create certificate operation status. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux beginCreateCertificate( - String certificateName, CertificatePolicy policy, Boolean isEnabled, Map tags) { - if (policy == null) { - return PollerFlux.error(LOGGER.logExceptionAsError(new NullPointerException("'policy' cannot be null."))); - } - - return new PollerFlux<>(Duration.ofSeconds(1), - ignored -> createCertificateActivation(certificateName, policy, isEnabled, tags), - ignored -> certificatePollOperation(certificateName), - (ignored1, ignored2) -> certificateCancellationOperation(certificateName), - ignored -> fetchCertificateOperation(certificateName)); - } - - private Mono createCertificateActivation(String certificateName, CertificatePolicy policy, - Boolean isEnabled, Map tags) { - com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy implPolicy - = CertificatePolicyHelper.getImplCertificatePolicy(policy); - return implClient - .createCertificateAsync(vaultUrl, certificateName, implPolicy, - new CertificateAttributes().setEnabled(isEnabled), tags) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapCreateCertificateException) - .map(CertificateOperationHelper::createCertificateOperation); - } - - static HttpResponseException mapCreateCertificateException(KeyVaultErrorException ex) { - return ex.getResponse().getStatusCode() == 400 - ? new ResourceModifiedException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - - private Mono> certificatePollOperation(String certificateName) { - return implClient.getCertificateOperationAsync(vaultUrl, certificateName) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapGetCertificateOperationException) - .map(CertificateAsyncClient::processCertificateOperationResponse); - } - - static HttpResponseException mapGetCertificateOperationException(KeyVaultErrorException ex) { - if (ex.getResponse().getStatusCode() == 404) { - return new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()); - } else if (ex.getResponse().getStatusCode() == 400) { - return new ResourceModifiedException(ex.getMessage(), ex.getResponse(), ex.getValue()); - } else { - return ex; - } - } - - static PollResponse processCertificateOperationResponse( - com.azure.security.keyvault.certificates.implementation.models.CertificateOperation impl) { - return new PollResponse<>(mapStatus(impl.getStatus()), - CertificateOperationHelper.createCertificateOperation(impl)); - } - - private static LongRunningOperationStatus mapStatus(String status) { - switch (status) { - case "inProgress": - return LongRunningOperationStatus.IN_PROGRESS; - - case "completed": - return LongRunningOperationStatus.SUCCESSFULLY_COMPLETED; - - case "failed": - return LongRunningOperationStatus.FAILED; - - default: - return LongRunningOperationStatus.fromString(status, true); - } - } - - private Mono certificateCancellationOperation(String certificateName) { - return implClient.updateCertificateOperationAsync(vaultUrl, certificateName, true) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapUpdateCertificateOperationException) - .map(CertificateOperationHelper::createCertificateOperation); - } - - static HttpResponseException mapUpdateCertificateOperationException(KeyVaultErrorException ex) { - if (ex.getResponse().getStatusCode() == 404) { - return new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()); - } else if (ex.getResponse().getStatusCode() == 400) { - return new ResourceModifiedException(ex.getMessage(), ex.getResponse(), ex.getValue()); - } else { - return ex; - } - } - - private Mono fetchCertificateOperation(String certificateName) { - return implClient.getCertificateAsync(vaultUrl, certificateName, null) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapGetCertificateException) - .map(KeyVaultCertificateWithPolicyHelper::createCertificateWithPolicy); - } - - static HttpResponseException mapGetCertificateException(KeyVaultErrorException ex) { - if (ex.getResponse().getStatusCode() == 404) { - return new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()); - } else if (ex.getResponse().getStatusCode() == 403) { - return new ResourceModifiedException(ex.getMessage(), ex.getResponse(), ex.getValue()); - } else { - return ex; - } - } - - /** - * Creates a new certificate. If this is the first version, the certificate resource is created. This operation - * requires the certificates/create permission. - * - *

Code Samples

- *

Create certificate is a long running operation. The {@link PollerFlux poller} allows users to automatically - * poll on the create certificate operation status. It is possible to monitor each intermediate poll response during - * the poll operation.

- * - * - *
-     * CertificatePolicy certPolicy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12");
-     * certificateAsyncClient.beginCreateCertificate("certificateName", certPolicy)
-     *     .subscribe(pollResponse -> {
-     *         System.out.println("---------------------------------------------------------------------------------");
-     *         System.out.println(pollResponse.getStatus());
-     *         System.out.println(pollResponse.getValue().getStatus());
-     *         System.out.println(pollResponse.getValue().getStatusDetails());
-     *     });
-     * 
- * - * - * @param certificateName The name of the certificate to be created. - * @param policy The policy of the certificate to be created. - * @throws NullPointerException if {@code policy} is null. - * @throws ResourceModifiedException when invalid certificate policy configuration is provided. - * @return A {@link PollerFlux} polling on the create certificate operation status. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux - beginCreateCertificate(String certificateName, CertificatePolicy policy) { - return beginCreateCertificate(certificateName, policy, true, null); - } - - /** - * Gets a pending {@link CertificateOperation} from the key vault. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Get a pending certificate operation. The {@link PollerFlux poller} allows users to automatically poll on the - * certificate operation status. It is possible to monitor each intermediate poll response during the poll - * operation.

- * - * - *
-     * certificateAsyncClient.getCertificateOperation("certificateName")
-     *     .subscribe(pollResponse -> {
-     *         System.out.println("---------------------------------------------------------------------------------");
-     *         System.out.println(pollResponse.getStatus());
-     *         System.out.println(pollResponse.getValue().getStatus());
-     *         System.out.println(pollResponse.getValue().getStatusDetails());
-     *     });
-     * 
- * - * - * @param certificateName The name of the certificate. - * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code certificateName} - * doesn't exist. - * @return A {@link PollerFlux} polling on the certificate operation status. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux - getCertificateOperation(String certificateName) { - return new PollerFlux<>(Duration.ofSeconds(1), pollingContext -> Mono.empty(), - ignored -> certificatePollOperation(certificateName), - (ignored1, ignored2) -> certificateCancellationOperation(certificateName), - ignored -> fetchCertificateOperation(certificateName)); - } - - /** - * Gets information about the latest version of the specified certificate. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Gets a specific version of the certificate in the key vault. Prints out the - * returned certificate details when a response has been received.

- * - * - *
-     * certificateAsyncClient.getCertificate("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificateResponse ->
-     *         System.out.printf("Certificate is returned with name %s and secretId %s %n",
-     *             certificateResponse.getProperties().getName(), certificateResponse.getSecretId()));
-     * 
- * - * - * @param certificateName The name of the certificate to retrieve, cannot be null - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException if {@code certificateName} is empty string. - * @return A {@link Mono} containing the requested {@link KeyVaultCertificateWithPolicy certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificate(String certificateName) { - return getCertificateWithResponse(certificateName).flatMap(FluxUtil::toMono); - } - - /** - * Gets information about the latest version of the specified certificate. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Gets a specific version of the certificate in the key vault. Prints out the - * returned certificate details when a response has been received.

- * - * - *
-     * certificateAsyncClient.getCertificateWithResponse("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificateResponse ->
-     *         System.out.printf("Certificate is returned with name %s and secretId %s %n",
-     *             certificateResponse.getValue().getProperties().getName(),
-     *             certificateResponse.getValue().getSecretId()));
-     * 
- * - * - * @param certificateName The name of the certificate to retrieve, cannot be null - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException if {@code certificateName} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * requested {@link KeyVaultCertificateWithPolicy certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateWithResponse(String certificateName) { - try { - return implClient.getCertificateWithResponseAsync(vaultUrl, certificateName, null) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapGetCertificateException) - .map(response -> new SimpleResponse<>(response, createCertificateWithPolicy(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Gets information about the latest version of the specified certificate. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Gets a specific version of the certificate in the key vault. Prints out the - * returned certificate details when a response has been received.

- * - * - *
-     * String certificateVersion = "6A385B124DEF4096AF1361A85B16C204";
-     * certificateAsyncClient.getCertificateVersionWithResponse("certificateName", certificateVersion)
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificateWithVersion ->
-     *         System.out.printf("Certificate is returned with name %s and secretId %s %n",
-     *             certificateWithVersion.getValue().getProperties().getName(),
-     *             certificateWithVersion.getValue().getSecretId()));
-     * 
- * - * - * @param certificateName The name of the certificate to retrieve, cannot be null - * @param version The version of the certificate to retrieve. If this is an empty String or null then latest version - * of the certificate is retrieved. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException if {@code certificateName} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * requested {@link KeyVaultCertificate certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateVersionWithResponse(String certificateName, - String version) { - try { - return implClient.getCertificateWithResponseAsync(vaultUrl, certificateName, version) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapGetCertificateException) - .map(response -> new SimpleResponse<>(response, createCertificateWithPolicy(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Gets information about the specified version of the specified certificate. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Gets a specific version of the certificate in the key vault. Prints out the - * returned certificate details when a response has been received.

- * - * - *
-     * certificateAsyncClient.getCertificateVersion("certificateName", certificateVersion)
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificateWithVersion ->
-     *         System.out.printf("Certificate is returned with name %s and secretId %s %n",
-     *             certificateWithVersion.getProperties().getName(), certificateWithVersion.getSecretId()));
-     * 
- * - * - * @param certificateName The name of the certificate to retrieve, cannot be null - * @param version The version of the certificate to retrieve. If this is an empty String or null then latest version - * of the certificate is retrieved. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException if {@code certificateName} is empty string. - * @return A {@link Mono} containing the requested {@link KeyVaultCertificate certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificateVersion(String certificateName, String version) { - return getCertificateVersionWithResponse(certificateName, version).flatMap(FluxUtil::toMono); - } - - /** - * Updates the specified attributes associated with the specified certificate. The update operation changes - * specified attributes of an existing stored certificate and attributes that are not specified in the request are - * left unchanged. This operation requires the certificates/update permission. - * - *

Code Samples

- *

Gets latest version of the certificate, changes its tags and enabled status and then updates it in the Azure - * Key Vault. Prints out the returned certificate details when a response has been received.

- * - * - *
-     * certificateAsyncClient.getCertificate("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificateResponseValue -> {
-     *         KeyVaultCertificate certificate = certificateResponseValue;
-     *         //Update enabled status of the certificate
-     *         certificate.getProperties().setEnabled(false);
-     *         certificateAsyncClient.updateCertificateProperties(certificate.getProperties())
-     *             .subscribe(certificateResponse ->
-     *                 System.out.printf("Certificate's enabled status %s %n",
-     *                     certificateResponse.getProperties().isEnabled().toString()));
-     *     });
-     * 
- * - * - * @param properties The {@link CertificateProperties} object with updated properties. - * @throws NullPointerException if {@code properties} is null. - * @throws ResourceNotFoundException when a certificate with {@link CertificateProperties#getName() name} and - * {@link CertificateProperties#getVersion() version} doesn't exist in the key vault. - * @throws HttpResponseException if {@link CertificateProperties#getName() name} or - * {@link CertificateProperties#getVersion() version} is empty string. - * @return A {@link Mono} containing the {@link CertificateProperties updated certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateCertificateProperties(CertificateProperties properties) { - return updateCertificatePropertiesWithResponse(properties).flatMap(FluxUtil::toMono); - } - - /** - * Updates the specified attributes associated with the specified certificate. The update operation changes - * specified attributes of an existing stored certificate and attributes that are not specified in the request are - * left unchanged. This operation requires the certificates/update permission. - * - *

Code Samples

- *

Gets latest version of the certificate, changes its enabled status and then updates it in the Azure Key Vault. - * Prints out the returned certificate details when a response has been received.

- * - * - *
-     * certificateAsyncClient.getCertificate("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificateResponseValue -> {
-     *         KeyVaultCertificate certificate = certificateResponseValue;
-     *         //Update the enabled status of the certificate.
-     *         certificate.getProperties().setEnabled(false);
-     *         certificateAsyncClient.updateCertificatePropertiesWithResponse(certificate.getProperties())
-     *             .subscribe(certificateResponse ->
-     *                 System.out.printf("Certificate's enabled status %s %n",
-     *                     certificateResponse.getValue().getProperties().isEnabled().toString()));
-     *     });
-     * 
- * - * - * @param properties The {@link CertificateProperties} object with updated properties. - * @throws NullPointerException if {@code properties} is null. - * @throws ResourceNotFoundException when a certificate with {@link CertificateProperties#getName() name} and - * {@link CertificateProperties#getVersion() version} doesn't exist in the key vault. - * @throws HttpResponseException if {@link CertificateProperties#getName() name} or - * {@link CertificateProperties#getVersion() version} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link CertificateProperties updated certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - updateCertificatePropertiesWithResponse(CertificateProperties properties) { - if (properties == null) { - return monoError(LOGGER, new NullPointerException("'properties' cannot be null.")); - } - - try { - CertificateAttributes certificateAttributes = new CertificateAttributes().setEnabled(properties.isEnabled()) - .setExpires(properties.getExpiresOn()) - .setNotBefore(properties.getNotBefore()); - - return implClient - .updateCertificateWithResponseAsync(vaultUrl, properties.getName(), properties.getVersion(), null, - certificateAttributes, properties.getTags()) - .map(response -> new SimpleResponse<>(response, createCertificateWithPolicy(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Deletes a certificate from a specified key vault. All the versions of the certificate along with its associated - * policy get deleted. If soft-delete is enabled on the key vault then the certificate is placed in the deleted - * state and requires to be purged for permanent deletion else the certificate is permanently deleted. The delete - * operation applies to any certificate stored in Azure Key Vault, but it cannot be applied to an individual version - * of a certificate. This operation requires the certificates/delete permission. - * - *

Code Samples

- *

Deletes the certificate in the Azure Key Vault. Prints out the deleted certificate details when a response has - * been received.

- * - * - *
-     * certificateAsyncClient.beginDeleteCertificate("certificateName")
-     *     .subscribe(pollResponse -> {
-     *         System.out.println("Delete Status: " + pollResponse.getStatus().toString());
-     *         System.out.println("Delete Certificate Name: " + pollResponse.getValue().getName());
-     *         System.out.println("Certificate Delete Date: " + pollResponse.getValue().getDeletedOn().toString());
-     *     });
-     * 
- * - * - * @param certificateName The name of the certificate to be deleted. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException when a certificate with {@code certificateName} is empty string. - * @return A {@link PollerFlux} to poll on the {@link DeletedCertificate deleted certificate}. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux beginDeleteCertificate(String certificateName) { - return new PollerFlux<>(Duration.ofSeconds(1), ignored -> deleteCertificateActivation(certificateName), - pollingContext -> deleteCertificatePollOperation(certificateName, pollingContext), - (pollingContext, firstResponse) -> Mono.empty(), pollingContext -> Mono.empty()); - } - - private Mono deleteCertificateActivation(String certificateName) { - return implClient.deleteCertificateAsync(vaultUrl, certificateName) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapDeleteCertificateException) - .map(DeletedCertificateHelper::createDeletedCertificate); - } - - static HttpResponseException mapDeleteCertificateException(KeyVaultErrorException ex) { - return ex.getResponse().getStatusCode() == 404 - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - - private Mono> deleteCertificatePollOperation(String certificateName, - PollingContext pollingContext) { - return implClient.getDeletedCertificateAsync(vaultUrl, certificateName) - .map(bundle -> new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - createDeletedCertificate(bundle))) - .onErrorResume(KeyVaultErrorException.class, ex -> { - if (ex.getResponse().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return Mono.just(new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, - pollingContext.getLatestResponse().getValue())); - } else { - // This means either vault has soft-delete disabled or permission is not granted for the get deleted - // certificate operation. In both cases deletion operation was successful when activation operation - // succeeded before reaching here. - return Mono.just(new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - pollingContext.getLatestResponse().getValue())); - } - }) - // This means either vault has soft-delete disabled or permission is not granted for the get deleted - // certificate operation. In both cases deletion operation was successful when activation operation - // succeeded before reaching here. - .onErrorReturn(new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - pollingContext.getLatestResponse().getValue())); - } - - /** - * Retrieves information about the specified deleted certificate. The GetDeletedCertificate operation is applicable - * for soft-delete enabled vaults and additionally retrieves deleted certificate's attributes, such as retention - * interval, scheduled permanent deletion and the current deletion recovery level. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Gets the deleted certificate from the key vault enabled for soft-delete. Prints out the deleted certificate - * details when a response has been received.

- * - * - *
-     * certificateAsyncClient.getDeletedCertificate("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(deletedSecretResponse ->
-     *         System.out.printf("Deleted Certificate's Recovery Id %s %n", deletedSecretResponse.getRecoveryId()));
-     * 
- * - * - * @param certificateName The name of the deleted certificate. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException when a certificate with {@code certificateName} is empty string. - * @return A {@link Mono} containing the {@link DeletedCertificate deleted certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getDeletedCertificate(String certificateName) { - return getDeletedCertificateWithResponse(certificateName).flatMap(FluxUtil::toMono); - } - - /** - * Retrieves information about the specified deleted certificate. The GetDeletedCertificate operation is applicable - * for soft-delete enabled vaults and additionally retrieves deleted certificate's attributes, such as retention - * interval, scheduled permanent deletion and the current deletion recovery level. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Gets the deleted certificate from the key vault enabled for soft-delete. Prints out the deleted certificate - * details when a response has been received.

- * - * - *
-     * certificateAsyncClient.getDeletedCertificateWithResponse("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(deletedSecretResponse ->
-     *         System.out.printf("Deleted Certificate's Recovery Id %s %n",
-     *             deletedSecretResponse.getValue().getRecoveryId()));
-     * 
- * - * - * @param certificateName The name of the deleted certificate. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException when a certificate with {@code certificateName} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link DeletedCertificate deleted certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedCertificateWithResponse(String certificateName) { - try { - return implClient.getDeletedCertificateWithResponseAsync(vaultUrl, certificateName) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapGetDeletedCertificateException) - .map(response -> new SimpleResponse<>(response, createDeletedCertificate(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - static HttpResponseException mapGetDeletedCertificateException(KeyVaultErrorException ex) { - return ex.getResponse().getStatusCode() == 404 - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - - /** - * Permanently deletes the specified deleted certificate without possibility for recovery. The Purge Deleted - * Certificate operation is applicable for soft-delete enabled vaults and is not available if the recovery level - * does not specify 'Purgeable'. This operation requires the certificate/purge permission. - * - *

Code Samples

- *

Purges the deleted certificate from the key vault enabled for soft-delete. Prints out the status code from the - * server response when a response has been received.

- * - * - *
-     * certificateAsyncClient.purgeDeletedCertificateWithResponse("deletedCertificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(purgeResponse ->
-     *         System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode()));
-     * 
- * - * - * @param certificateName The name of the deleted certificate. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException when a certificate with {@code certificateName} is empty string. - * @return An empty {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono purgeDeletedCertificate(String certificateName) { - return purgeDeletedCertificateWithResponse(certificateName).flatMap(FluxUtil::toMono); - } - - /** - * Permanently deletes the specified deleted certificate without possibility for recovery. The Purge Deleted - * Certificate operation is applicable for soft-delete enabled vaults and is not available if the recovery level - * does not specify 'Purgeable'. This operation requires the certificate/purge permission. - * - *

Code Samples

- *

Purges the deleted certificate from the key vault enabled for soft-delete. Prints out the status code from the - * server response when a response has been received.

- * - * - *
-     * certificateAsyncClient.purgeDeletedCertificateWithResponse("deletedCertificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(purgeResponse ->
-     *         System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode()));
-     * 
- * - * - * @param certificateName The name of the deleted certificate. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException when a certificate with {@code certificateName} is empty string. - * @return A {@link Mono} containing a Void Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> purgeDeletedCertificateWithResponse(String certificateName) { - try { - return implClient.purgeDeletedCertificateWithResponseAsync(vaultUrl, certificateName) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapPurgeDeletedCertificateException); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - static HttpResponseException mapPurgeDeletedCertificateException(KeyVaultErrorException ex) { - return ex.getResponse().getStatusCode() == 404 - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - - /** - * Recovers the deleted certificate back to its current version under /certificates and can only be performed on a - * soft-delete enabled vault. The RecoverDeletedCertificate operation performs the reversal of the Delete operation - * and must be issued during the retention interval (available in the deleted certificate's attributes). This - * operation requires the certificates/recover permission. - * - *

Code Samples

- *

Recovers the deleted certificate from the key vault enabled for soft-delete. Prints out the recovered - * certificate details when a response has been received.

- * - * - *
-     * certificateAsyncClient.beginRecoverDeletedCertificate("deletedCertificateName")
-     *     .subscribe(pollResponse -> {
-     *         System.out.println("Recovery Status: " + pollResponse.getStatus().toString());
-     *         System.out.println("Recover Certificate Name: " + pollResponse.getValue().getName());
-     *         System.out.println("Recover Certificate Id: " + pollResponse.getValue().getId());
-     *     });
-     * 
- * - * - * @param certificateName The name of the deleted certificate to be recovered. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the - * certificate vault. - * @throws HttpResponseException when a certificate with {@code certificateName} is empty string. - * @return A {@link PollerFlux} to poll on the {@link KeyVaultCertificate recovered certificate}. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux beginRecoverDeletedCertificate(String certificateName) { - return new PollerFlux<>(Duration.ofSeconds(1), ignored -> recoverDeletedCertificateActivation(certificateName), - pollingContext -> recoverDeletedCertificatePollOperation(certificateName, pollingContext), - (pollingContext, firstResponse) -> Mono.empty(), pollingContext -> Mono.empty()); - } - - private Mono recoverDeletedCertificateActivation(String certificateName) { - return implClient.recoverDeletedCertificateAsync(vaultUrl, certificateName) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapRecoverDeletedCertificateException) - .map(KeyVaultCertificateWithPolicyHelper::createCertificateWithPolicy); - } - - static HttpResponseException mapRecoverDeletedCertificateException(KeyVaultErrorException ex) { - return ex.getResponse().getStatusCode() == 404 - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - - private Mono> recoverDeletedCertificatePollOperation( - String certificateName, PollingContext pollingContext) { - return implClient.getCertificateAsync(vaultUrl, certificateName, null) - .map(bundle -> new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - createCertificateWithPolicy(bundle))) - .onErrorResume(KeyVaultErrorException.class, ex -> { - if (ex.getResponse().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return Mono.just(new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, - pollingContext.getLatestResponse().getValue())); - } else { - // This means permission is not granted for the get deleted key operation. - // In both cases deletion operation was successful when activation operation succeeded before - // reaching here. - return Mono.just(new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - pollingContext.getLatestResponse().getValue())); - } - }) - // This means permission is not granted for the get deleted key operation. - // In both cases deletion operation was successful when activation operation succeeded before reaching - // here. - .onErrorReturn(new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - pollingContext.getLatestResponse().getValue())); - } - - /** - * Requests that a backup of the specified certificate be downloaded to the client. All versions of the - * certificate will be downloaded. This operation requires the certificates/backup permission. - * - *

Code Samples

- *

Backs up the certificate from the key vault. Prints out the length of the certificate's backup byte array - * returned in the response.

- * - * - *
-     * certificateAsyncClient.backupCertificate("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificateBackupResponse ->
-     *         System.out.printf("Certificate's Backup Byte array's length %s %n", certificateBackupResponse.length));
-     * 
- * - * - * @param certificateName The name of the certificate. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException when a certificate with {@code certificateName} is empty string. - * @return A {@link Mono} containing the backed up certificate blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono backupCertificate(String certificateName) { - return backupCertificateWithResponse(certificateName).flatMap(FluxUtil::toMono); - } - - /** - * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate - * will be downloaded. This operation requires the certificates/backup permission. - * - *

Code Samples

- *

Backs up the certificate from the key vault. Prints out the length of the certificate's backup byte array - * returned in the response.

- * - * - *
-     * certificateAsyncClient.backupCertificateWithResponse("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificateBackupResponse ->
-     *         System.out.printf("Certificate's Backup Byte array's length %s %n",
-     *             certificateBackupResponse.getValue().length));
-     * 
- * - * - * @param certificateName The name of the certificate. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException when a certificate with {@code certificateName} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the backed - * up certificate blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> backupCertificateWithResponse(String certificateName) { - try { - return implClient.backupCertificateWithResponseAsync(vaultUrl, certificateName) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapBackupCertificateException) - .map(response -> new SimpleResponse<>(response, response.getValue().getValue())); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - static HttpResponseException mapBackupCertificateException(KeyVaultErrorException ex) { - return ex.getResponse().getStatusCode() == 404 - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - - /** - * Restores a backed up certificate to the vault. All the versions of the certificate are restored to the vault. - * This operation requires the certificates/restore permission. - * - *

Code Samples

- *

Restores the certificate in the key vault from its backup. Prints out the restored certificate details when a - * response has been received.

- * - * - *
-     * byte[] certificateBackupByteArray = {};
-     * certificateAsyncClient.restoreCertificateBackup(certificateBackupByteArray)
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificateResponse -> System.out.printf("Restored Certificate with name %s and key id %s %n",
-     *         certificateResponse.getProperties().getName(), certificateResponse.getKeyId()));
-     * 
- * - * - * @param backup The backup blob associated with the certificate. - * @throws ResourceModifiedException when {@code backup} blob is malformed. - * @return A {@link Mono} containing the {@link KeyVaultCertificate restored certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono restoreCertificateBackup(byte[] backup) { - return restoreCertificateBackupWithResponse(backup).flatMap(FluxUtil::toMono); - } - - /** - * Restores a backed up certificate to the vault. All the versions of the certificate are restored to the vault. - * This operation requires the certificates/restore permission. - * - *

Code Samples

- *

Restores the certificate in the key vault from its backup. Prints out the restored certificate details when a - * response has been received.

- * - * - *
-     * byte[] certificateBackup = {};
-     * certificateAsyncClient.restoreCertificateBackup(certificateBackup)
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificateResponse -> System.out.printf("Restored Certificate with name %s and key id %s %n",
-     *         certificateResponse.getProperties().getName(), certificateResponse.getKeyId()));
-     * 
- * - * - * @param backup The backup blob associated with the certificate. - * @throws ResourceModifiedException when {@code backup} blob is malformed. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link KeyVaultCertificate restored certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> restoreCertificateBackupWithResponse(byte[] backup) { - try { - return implClient.restoreCertificateWithResponseAsync(vaultUrl, backup) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapRestoreCertificateException) - .map(response -> new SimpleResponse<>(response, createCertificateWithPolicy(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - static HttpResponseException mapRestoreCertificateException(KeyVaultErrorException ex) { - return ex.getResponse().getStatusCode() == 400 - ? new ResourceModifiedException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - - /** - * List certificates in the key vault. Retrieves the set of certificates resources in the key vault and the - * individual certificate response in the flux is represented by {@link CertificateProperties} as only the - * certificate identifier, thumbprint, attributes and tags are provided in the response. The policy and individual - * certificate versions are not listed in the response. This operation requires the certificates/list permission. - * - *

It is possible to get certificates with all the properties excluding the policy from this information. Convert - * the {@link Flux} containing {@link CertificateProperties} to {@link Flux} containing - * {@link KeyVaultCertificate certificate} using - * {@link CertificateAsyncClient#getCertificateVersion(String, String)} within {@link Flux#flatMap(Function)}.

- * - * - *
-     * certificateAsyncClient.listPropertiesOfCertificates()
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificate -> certificateAsyncClient.getCertificateVersion(certificate.getName(),
-     *         certificate.getVersion())
-     *         .subscribe(certificateResponse -> System.out.printf("Received certificate with name %s and key id %s",
-     *             certificateResponse.getName(), certificateResponse.getKeyId())));
-     * 
- * - * - * @param includePending indicate if pending certificates should be included in the results. - * @return A {@link PagedFlux} containing {@link CertificateProperties certificate} for all the certificates in the - * vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listPropertiesOfCertificates(boolean includePending) { - return new PagedFlux<>( - maxResults -> implClient.getCertificatesSinglePageAsync(vaultUrl, maxResults, includePending) - .map(CertificateAsyncClient::mapCertificateItemPage), - (continuationToken, maxResults) -> implClient - .getCertificatesNextSinglePageAsync(continuationToken, vaultUrl) - .map(CertificateAsyncClient::mapCertificateItemPage)); - } - - /** - * List certificates in a key vault. Retrieves the set of certificates resources in the key vault and the individual - * certificate response in the flux is represented by {@link CertificateProperties} as only the certificate - * identifier, thumbprint, attributes and tags are provided in the response. The policy and individual certificate - * versions are not listed in the response. This operation requires the certificates/list permission. - * - *

It is possible to get certificates with all the properties excluding the policy from this information. Convert - * the {@link Flux} containing {@link CertificateProperties} to {@link Flux} containing - * {@link KeyVaultCertificate certificate} using - * {@link CertificateAsyncClient#getCertificateVersion(String, String)} within {@link Flux#flatMap(Function)}.

- * - * - *
-     * certificateAsyncClient.listPropertiesOfCertificates()
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificate -> certificateAsyncClient.getCertificateVersion(certificate.getName(),
-     *         certificate.getVersion())
-     *         .subscribe(certificateResponse -> System.out.printf("Received certificate with name %s and key id %s",
-     *             certificateResponse.getName(), certificateResponse.getKeyId())));
-     * 
- * - * - * @return A {@link PagedFlux} containing {@link CertificateProperties certificate} for all the certificates in the - * vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listPropertiesOfCertificates() { - return listPropertiesOfCertificates(false); - } - - /** - * Lists the {@link DeletedCertificate deleted certificates} in the key vault currently available for recovery. This - * operation includes deletion-specific information and is applicable for vaults enabled for soft-delete. This - * operation requires the certificates/get/list permission. - * - *

Code Samples

- *

Lists the deleted certificates in the key vault. Prints out the recovery id of each deleted certificate when a - * response has been received.

- * - * - *
-     * certificateAsyncClient.listDeletedCertificates()
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(deletedCertificateResponse ->  System.out.printf("Deleted Certificate's Recovery Id %s %n",
-     *         deletedCertificateResponse.getRecoveryId()));
-     * 
- * - * - * @return A {@link PagedFlux} containing all of the {@link DeletedCertificate deleted certificates} in the vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listDeletedCertificates() { - return listDeletedCertificates(false); - } - - /** - * Lists the {@link DeletedCertificate deleted certificates} in the key vault currently available for recovery. This - * operation includes deletion-specific information and is applicable for vaults enabled for soft-delete. This - * operation requires the certificates/get/list permission. - * - *

Code Samples

- *

Lists the deleted certificates in the key vault. Prints out the recovery id of each deleted certificate when a - * response has been received.

- * - * - *
-     * certificateAsyncClient.listDeletedCertificates()
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(deletedCertificateResponse ->  System.out.printf("Deleted Certificate's Recovery Id %s %n",
-     *         deletedCertificateResponse.getRecoveryId()));
-     * 
- * - * - * @param includePending indicate if pending deleted certificates should be included in the results. - * @return A {@link PagedFlux} containing all of the {@link DeletedCertificate deleted certificates} in the vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listDeletedCertificates(boolean includePending) { - return new PagedFlux<>( - maxResults -> implClient.getDeletedCertificatesSinglePageAsync(vaultUrl, maxResults, includePending) - .map(CertificateAsyncClient::mapDeletedCertificateItemPage), - (continuationToken, maxResults) -> implClient - .getDeletedCertificatesNextSinglePageAsync(continuationToken, vaultUrl) - .map(CertificateAsyncClient::mapDeletedCertificateItemPage)); - } - - static PagedResponse mapDeletedCertificateItemPage(PagedResponse page) { - return mapPagedResponse(page, DeletedCertificateHelper::createDeletedCertificate); - } - - /** - * List all versions of the specified certificate. The individual certificate response in the flux is represented by - * {@link CertificateProperties} as only the certificate identifier, thumbprint, attributes and tags are provided in - * the response. The policy is not listed in the response. This operation requires the certificates/list permission. - * - *

It is possible to get the certificates with properties excluding the policy for all the versions from this - * information. Convert the {@link PagedFlux} containing {@link CertificateProperties} to {@link PagedFlux} - * containing {@link KeyVaultCertificate certificate} using - * {@link CertificateAsyncClient#getCertificateVersion(String, String)} within {@link Flux#flatMap(Function)}.

- * - * - *
-     * certificateAsyncClient.listPropertiesOfCertificateVersions("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificate -> certificateAsyncClient.getCertificateVersion(certificate.getName(),
-     *         certificate.getVersion())
-     *         .subscribe(certificateResponse -> System.out.printf("Received certificate with name %s and key id %s",
-     *             certificateResponse.getProperties().getName(), certificateResponse.getKeyId())));
-     * 
- * - * - * @param certificateName The name of the certificate. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException when a certificate with {@code certificateName} is empty string. - * @return A {@link PagedFlux} containing {@link CertificateProperties certificate} of all the versions of the - * specified certificate in the vault. Flux is empty if certificate with {@code certificateName} does not exist in - * key vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listPropertiesOfCertificateVersions(String certificateName) { - return new PagedFlux<>( - maxResults -> implClient.getCertificateVersionsSinglePageAsync(vaultUrl, certificateName, maxResults) - .map(CertificateAsyncClient::mapCertificateItemPage), - (continuationToken, maxResults) -> implClient - .getCertificateVersionsNextSinglePageAsync(continuationToken, vaultUrl) - .map(CertificateAsyncClient::mapCertificateItemPage)); - } - - static PagedResponse mapCertificateItemPage(PagedResponse page) { - return mapPagedResponse(page, CertificatePropertiesHelper::createCertificateProperties); - } - - private static PagedResponse mapPagedResponse(PagedResponse page, Function itemMapper) { - List mappedValues = new ArrayList<>(page.getValue().size()); - for (T item : page.getValue()) { - mappedValues.add(itemMapper.apply(item)); - } - - return new PagedResponseBase<>(page.getRequest(), page.getStatusCode(), page.getHeaders(), mappedValues, - page.getContinuationToken(), null); - } - - /** - * Merges a certificate or a certificate chain with a key pair currently available in the service. This operation - * requires the certificates/create permission. - * - *

Code Samples

- *

Merges a certificate with a kay pair available in the service.

- * - * - *
-     * List<byte[]> x509CertificatesToMerge = new ArrayList<>();
-     * MergeCertificateOptions config =
-     *     new MergeCertificateOptions("certificateName", x509CertificatesToMerge).setEnabled(false);
-     * certificateAsyncClient.mergeCertificate(config)
-     *     .subscribe(certificate -> System.out.printf("Received Certificate with name %s and key id %s",
-     *         certificate.getProperties().getName(), certificate.getKeyId()));
-     * 
- * - * - * @param mergeCertificateOptions the merge certificate options holding the x509 certificates. - * - * @throws NullPointerException when {@code mergeCertificateOptions} is null. - * @throws HttpResponseException if {@code mergeCertificateOptions} is invalid/corrupt. - * @return A {@link Mono} containing the merged certificate. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono mergeCertificate(MergeCertificateOptions mergeCertificateOptions) { - return mergeCertificateWithResponse(mergeCertificateOptions).flatMap(FluxUtil::toMono); - } - - /** - * Merges a certificate or a certificate chain with a key pair currently available in the service. This operation - * requires the certificates/create permission. - * - *

Code Samples

- *

Merges a certificate with a kay pair available in the service.

- * - * - *
-     * List<byte[]> x509CertsToMerge = new ArrayList<>();
-     * MergeCertificateOptions mergeConfig =
-     *     new MergeCertificateOptions("certificateName", x509CertsToMerge).setEnabled(false);
-     * certificateAsyncClient.mergeCertificateWithResponse(mergeConfig)
-     *     .subscribe(certificateResponse -> System.out.printf("Received Certificate with name %s and key id %s",
-     *         certificateResponse.getValue().getProperties().getName(), certificateResponse.getValue().getKeyId()));
-     * 
- * - * - * @param mergeCertificateOptions the merge certificate options holding the x509 certificates. - * - * @throws NullPointerException when {@code mergeCertificateOptions} is null. - * @throws HttpResponseException if {@code mergeCertificateOptions} is invalid/corrupt. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the merged - * certificate. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - mergeCertificateWithResponse(MergeCertificateOptions mergeCertificateOptions) { - if (mergeCertificateOptions == null) { - return monoError(LOGGER, new NullPointerException("'mergeCertificateOptions' cannot be null.")); - } - - try { - return implClient - .mergeCertificateWithResponseAsync(vaultUrl, mergeCertificateOptions.getName(), - mergeCertificateOptions.getX509Certificates(), - new CertificateAttributes().setEnabled(mergeCertificateOptions.isEnabled()), - mergeCertificateOptions.getTags()) - .map(response -> new SimpleResponse<>(response, createCertificateWithPolicy(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Retrieves the policy of the specified certificate in the key vault. This operation requires the certificates/get - * permission. - * - *

Code Samples

- *

Gets the policy of a certificate in the key vault. Prints out the returned certificate policy details when a - * response has been received.

- * - * - *
-     * certificateAsyncClient.getCertificatePolicy("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(policy ->
-     *         System.out.printf("Certificate policy is returned with issuer name %s and subject name %s %n",
-     *             policy.getIssuerName(), policy.getSubject()));
-     * 
- * - * - * @param certificateName The name of the certificate whose policy is to be retrieved, cannot be null - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException if {@code certificateName} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * requested {@link CertificatePolicy certificate policy}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificatePolicy(String certificateName) { - return getCertificatePolicyWithResponse(certificateName).flatMap(FluxUtil::toMono); - } - - /** - * Retrieves the policy of the specified certificate in the key vault. This operation requires the certificates/get - * permission. - * - *

Code Samples

- *

Gets the policy of a certificate in the key vault. Prints out the returned certificate policy details when a - * response has been received.

- * - * - *
-     * certificateAsyncClient.getCertificatePolicyWithResponse("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(policyResponse ->
-     *         System.out.printf("Certificate policy is returned with issuer name %s and subject name %s %n",
-     *             policyResponse.getValue().getIssuerName(), policyResponse.getValue().getSubject()));
-     * 
- * - * - * @param certificateName The name of the certificate whose policy is to be retrieved, cannot be null - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException if {@code certificateName} is empty string. - * @return A {@link Mono} containing the requested {@link CertificatePolicy certificate policy}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificatePolicyWithResponse(String certificateName) { - try { - return implClient.getCertificatePolicyWithResponseAsync(vaultUrl, certificateName) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapGetCertificatePolicyException) - .map(response -> new SimpleResponse<>(response, createCertificatePolicy(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - static HttpResponseException mapGetCertificatePolicyException(KeyVaultErrorException ex) { - if (ex.getResponse().getStatusCode() == 404) { - return new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()); - } else if (ex.getResponse().getStatusCode() == 403) { - return new ResourceModifiedException(ex.getMessage(), ex.getResponse(), ex.getValue()); - } else { - return ex; - } - } - - /** - * Updates the policy for a certificate. The update operation changes specified attributes of the certificate policy - * and attributes that are not specified in the request are left unchanged. This operation requires the - * certificates/update permission. - * - *

Code Samples

- *

Gets the certificate policy, changes its properties and then updates it in the Azure Key Vault. Prints out the - * returned policy details when a response has been received.

- * - * - *
-     * certificateAsyncClient.getCertificatePolicy("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificatePolicyResponseValue -> {
-     *         CertificatePolicy certificatePolicy = certificatePolicyResponseValue;
-     *         // Update transparency
-     *         certificatePolicy.setCertificateTransparent(true);
-     *         certificateAsyncClient.updateCertificatePolicy("certificateName", certificatePolicy)
-     *             .subscribe(updatedPolicy ->
-     *                 System.out.printf("Certificate policy's updated transparency status %s %n",
-     *                     updatedPolicy.isCertificateTransparent()));
-     *     });
-     * 
- * - * - * @param certificateName The name of the certificate whose policy is to be updated. - * @param policy The certificate policy to be updated. - * @throws NullPointerException if {@code policy} is null. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException if {@code certificateName} is empty string or if {@code policy} is invalid. - * @return A {@link Mono} containing the updated {@link CertificatePolicy certificate policy}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateCertificatePolicy(String certificateName, CertificatePolicy policy) { - return updateCertificatePolicyWithResponse(certificateName, policy).flatMap(FluxUtil::toMono); - } - - /** - * Updates the policy for a certificate. The update operation changes specified attributes of the certificate policy - * and attributes that are not specified in the request are left unchanged. This operation requires the - * certificates/update permission. - * - *

Code Samples

- *

Gets the certificate policy, changes its properties and then updates it in the Azure Key Vault. Prints out the - * returned policy details when a response has been received.

- * - * - *
-     * certificateAsyncClient.getCertificatePolicy("certificateName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(certificatePolicyResponseValue -> {
-     *         CertificatePolicy certificatePolicy = certificatePolicyResponseValue;
-     *         // Update transparency
-     *         certificatePolicy.setCertificateTransparent(true);
-     *         certificateAsyncClient.updateCertificatePolicyWithResponse("certificateName",
-     *             certificatePolicy)
-     *             .subscribe(updatedPolicyResponse ->
-     *                 System.out.printf("Certificate policy's updated transparency status %s %n",
-     *                     updatedPolicyResponse.getValue().isCertificateTransparent()));
-     *     });
-     * 
- * - * - * @param certificateName The name of the certificate whose policy is to be updated. - * @param policy The certificate policy is to be updated. - * @throws NullPointerException if {@code policy} is null. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpResponseException if {@code name} is empty string or if {@code policy} is invalid. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the updated - * {@link CertificatePolicy certificate policy}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateCertificatePolicyWithResponse(String certificateName, - CertificatePolicy policy) { - if (policy == null) { - return monoError(LOGGER, new NullPointerException("'policy' cannot be null.")); - } - - try { - return implClient - .updateCertificatePolicyWithResponseAsync(vaultUrl, certificateName, getImplCertificatePolicy(policy)) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapUpdateCertificatePolicyException) - .map(response -> new SimpleResponse<>(response, createCertificatePolicy(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - static HttpResponseException mapUpdateCertificatePolicyException(KeyVaultErrorException ex) { - return (ex.getResponse().getStatusCode() == 404) - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - - /** - * Creates the specified certificate issuer. The SetCertificateIssuer operation updates the specified certificate - * issuer if it already exists or adds it if it doesn't exist. This operation requires the certificates/setissuers - * permission. - * - *

Code Samples

- *

Creates a new certificate issuer in the key vault. Prints out the created certificate issuer details when a - * response has been received.

- * - * - *
-     * CertificateIssuer issuer = new CertificateIssuer("issuerName", "providerName")
-     *     .setAccountId("keyvaultuser")
-     *     .setPassword("fakePasswordPlaceholder");
-     * certificateAsyncClient.createIssuer(issuer)
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(issuerResponse -> {
-     *         System.out.printf("Issuer created with %s and %s", issuerResponse.getName(),
-     *             issuerResponse.getProvider());
-     *     });
-     * 
- * - * - * @param issuer The configuration of the certificate issuer to be created. - * @throws NullPointerException if {@code issuer} is null. - * @throws ResourceModifiedException when invalid certificate issuer {@code issuer} configuration is provided. - * @throws HttpResponseException when a certificate issuer with {@code issuerName} is empty string. - * @return A {@link Mono} containing the created {@link CertificateIssuer certificate issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createIssuer(CertificateIssuer issuer) { - return createIssuerWithResponse(issuer).flatMap(FluxUtil::toMono); - } - - /** - * Creates the specified certificate issuer. The SetCertificateIssuer operation updates the specified certificate - * issuer if it already exists or adds it if it doesn't exist. This operation requires the certificates/setissuers - * permission. - * - *

Code Samples

- *

Creates a new certificate issuer in the key vault. Prints out the created certificate issuer details when a - * response has been received.

- * - * - *
-     * CertificateIssuer newIssuer = new CertificateIssuer("issuerName", "providerName")
-     *     .setAccountId("keyvaultuser")
-     *     .setPassword("fakePasswordPlaceholder");
-     * certificateAsyncClient.createIssuerWithResponse(newIssuer)
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(issuerResponse -> {
-     *         System.out.printf("Issuer created with %s and %s", issuerResponse.getValue().getName(),
-     *             issuerResponse.getValue().getProvider());
-     *     });
-     * 
- * - * - * @param issuer The configuration of the certificate issuer to be created. Use - * {@link CertificateIssuer#CertificateIssuer(String, String)} to initialize the issuer object - * @throws NullPointerException if {@code issuer} is null. - * @throws ResourceModifiedException when invalid certificate issuer {@code issuer} configuration is provided. - * @throws HttpResponseException when a certificate issuer with {@link CertificateIssuer#getName() name} is empty - * string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * created {@link CertificateIssuer certificate issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createIssuerWithResponse(CertificateIssuer issuer) { - if (issuer == null) { - return monoError(LOGGER, new NullPointerException("'issuer' cannot be null.")); - } - - try { - IssuerBundle issuerBundle = getIssuerBundle(issuer); - return implClient - .setCertificateIssuerWithResponseAsync(vaultUrl, issuer.getName(), issuer.getProvider(), - issuerBundle.getCredentials(), issuerBundle.getOrganizationDetails(), issuerBundle.getAttributes()) - .map(response -> new SimpleResponse<>(response, createCertificateIssuer(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Retrieves the specified certificate issuer from the key vault. This operation requires the - * certificates/manageissuers/getissuers permission. - * - *

Code Samples

- *

Gets the specified certificate issuer in the key vault. Prints out the returned certificate issuer details - * when a response has been received.

- * - * - *
-     * certificateAsyncClient.getIssuerWithResponse("issuerName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(issuerResponse -> {
-     *         System.out.printf("Issuer returned with %s and %s", issuerResponse.getValue().getName(),
-     *             issuerResponse.getValue().getProvider());
-     *     });
-     * 
- * - * - * @param issuerName The name of the certificate issuer to retrieve, cannot be null - * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key - * vault. - * @throws HttpResponseException if {@code issuerName} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * requested {@link CertificateIssuer certificate issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getIssuerWithResponse(String issuerName) { - try { - return implClient.getCertificateIssuerWithResponseAsync(vaultUrl, issuerName) - .map(response -> new SimpleResponse<>(response, createCertificateIssuer(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Retrieves the specified certificate issuer from the key vault. This operation requires the - * certificates/manageissuers/getissuers permission. - * - *

Code Samples

- *

Gets the specified certificate issuer in the key vault. Prints out the returned certificate issuer details - * when a response has been received.

- * - * - *
-     * certificateAsyncClient.getIssuer("issuerName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(issuer -> {
-     *         System.out.printf("Issuer returned with %s and %s", issuer.getName(),
-     *             issuer.getProvider());
-     *     });
-     * 
- * - * - * @param issuerName The name of the certificate to retrieve, cannot be null - * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key - * vault. - * @throws HttpResponseException if {@code issuerName} is empty string. - * @return A {@link Mono} containing the requested {@link CertificateIssuer certificate issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getIssuer(String issuerName) { - return getIssuerWithResponse(issuerName).flatMap(FluxUtil::toMono); - } - - /** - * Deletes the specified certificate issuer. The DeleteCertificateIssuer operation permanently removes the specified - * certificate issuer from the key vault. This operation requires the certificates/manageissuers/deleteissuers - * permission. - * - *

Code Samples

- *

Deletes the certificate issuer in the Azure Key Vault. Prints out the deleted certificate details when a - * response has been received.

- * - * - *
-     * certificateAsyncClient.deleteIssuerWithResponse("issuerName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(deletedIssuerResponse ->
-     *         System.out.printf("Deleted issuer with name %s %n", deletedIssuerResponse.getValue().getName()));
-     * 
- * - * - * @param issuerName The name of the certificate issuer to be deleted. - * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key - * vault. - * @throws HttpResponseException when a certificate issuer with {@code issuerName} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link CertificateIssuer deleted issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteIssuerWithResponse(String issuerName) { - try { - return implClient.deleteCertificateIssuerWithResponseAsync(vaultUrl, issuerName) - .onErrorMap(KeyVaultErrorException.class, CertificateAsyncClient::mapDeleteCertificateIssuerException) - .map(response -> new SimpleResponse<>(response, createCertificateIssuer(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - static HttpResponseException mapDeleteCertificateIssuerException(KeyVaultErrorException ex) { - return (ex.getResponse().getStatusCode() == 404) - ? new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()) - : ex; - } - - /** - * Deletes the specified certificate issuer. The DeleteCertificateIssuer operation permanently removes the specified - * certificate issuer from the key vault. This operation requires the certificates/manageissuers/deleteissuers - * permission. - * - *

Code Samples

- *

Deletes the certificate issuer in the Azure Key Vault. Prints out the deleted certificate details when a - * response has been received.

- * - * - *
-     * certificateAsyncClient.deleteIssuer("issuerName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(deletedIssuerResponse ->
-     *         System.out.printf("Deleted issuer with name %s %n", deletedIssuerResponse.getName()));
-     * 
- * - * - * @param issuerName The name of the certificate issuer to be deleted. - * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key - * vault. - * @throws HttpResponseException when a certificate issuer with {@code issuerName} is empty string. - * @return A {@link Mono} containing the {@link CertificateIssuer deleted issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteIssuer(String issuerName) { - return deleteIssuerWithResponse(issuerName).flatMap(FluxUtil::toMono); - } - - /** - * List all the certificate issuers resources in the key vault. The individual certificate issuer response in the - * flux is represented by {@link IssuerProperties} as only the certificate issuer identifier and provider are - * provided in the response. This operation requires the certificates/manageissuers/getissuers permission. - * - *

It is possible to get the certificate issuer with all of its properties from this information. Convert the - * {@link PagedFlux} containing {@link IssuerProperties issuerProperties} to {@link PagedFlux} containing - * {@link CertificateIssuer issuer} using {@link CertificateAsyncClient#getIssuer(String)} - * - * - *

-     * certificateAsyncClient.listPropertiesOfIssuers()
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(issuerProperties -> certificateAsyncClient.getIssuer(issuerProperties.getName())
-     *         .subscribe(issuerResponse -> System.out.printf("Received issuer with name %s and provider %s",
-     *             issuerResponse.getName(), issuerResponse.getProvider())));
-     * 
- * - * - * @return A {@link PagedFlux} containing all of the {@link IssuerProperties certificate issuers} in the vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listPropertiesOfIssuers() { - return new PagedFlux<>( - maxResults -> implClient.getCertificateIssuersSinglePageAsync(vaultUrl, maxResults) - .map(CertificateAsyncClient::mapIssuersPagedResponse), - (continuationToken, maxResults) -> implClient - .getCertificateIssuersNextSinglePageAsync(continuationToken, vaultUrl) - .map(CertificateAsyncClient::mapIssuersPagedResponse)); - } - - static PagedResponse mapIssuersPagedResponse(PagedResponse page) { - return mapPagedResponse(page, IssuerPropertiesHelper::createIssuerProperties); - } - - /** - * Updates the specified certificate issuer. The UpdateCertificateIssuer operation updates the specified attributes - * of the certificate issuer entity. This operation requires the certificates/setissuers permission. - * - *

Code Samples

- *

Gets the certificate issuer, changes its attributes/properties then updates it in the Azure Key Vault. Prints - * out the returned certificate issuer details when a response has been received.

- * - * - *
-     * certificateAsyncClient.getIssuer("issuerName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(issuerResponseValue -> {
-     *         CertificateIssuer issuer = issuerResponseValue;
-     *         //Update the enabled status of the issuer.
-     *         issuer.setEnabled(false);
-     *         certificateAsyncClient.updateIssuer(issuer)
-     *             .subscribe(issuerResponse ->
-     *                 System.out.printf("Issuer's enabled status %s %n",
-     *                     issuerResponse.isEnabled().toString()));
-     *     });
-     * 
- * - * - * @param issuer The {@link CertificateIssuer issuer} with updated properties. Use - * {@link CertificateIssuer#CertificateIssuer(String)} to initialize the issuer object - * @throws NullPointerException if {@code issuer} is null. - * @throws ResourceNotFoundException when a certificate issuer with {@link CertificateIssuer#getName() name} doesn't - * exist in the key vault. - * @throws HttpResponseException if {@link CertificateIssuer#getName() name} is empty string. - * @return A {@link Mono} containing the {@link CertificateIssuer updated issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateIssuer(CertificateIssuer issuer) { - return updateIssuerWithResponse(issuer).flatMap(FluxUtil::toMono); - } - - /** - * Updates the specified certificate issuer. The UpdateCertificateIssuer operation updates the specified attributes - * of the certificate issuer entity. This operation requires the certificates/setissuers permission. - * - *

Code Samples

- *

Gets the certificate issuer, changes its attributes/properties then updates it in the Azure Key Vault. Prints - * out the returned certificate issuer details when a response has been received.

- * - * - *
-     * certificateAsyncClient.getIssuer("issuerName")
-     *     .contextWrite(Context.of(key1, value1, key2, value2))
-     *     .subscribe(issuerResponseValue -> {
-     *         CertificateIssuer issuer = issuerResponseValue;
-     *         //Update the enabled status of the issuer.
-     *         issuer.setEnabled(false);
-     *         certificateAsyncClient.updateIssuer(issuer)
-     *             .subscribe(issuerResponse ->
-     *                 System.out.printf("Issuer's enabled status %s %n",
-     *                     issuerResponse.isEnabled().toString()));
-     *     });
-     * 
- * - * - * @param issuer The {@link CertificateIssuer issuer} with updated properties. - * @throws NullPointerException if {@code issuer} is null. - * @throws ResourceNotFoundException when a certificate issuer with {@link CertificateIssuer#getName() name} doesn't - * exist in the key vault. - * @throws HttpResponseException if {@link CertificateIssuer#getName() name} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link CertificateIssuer updated issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateIssuerWithResponse(CertificateIssuer issuer) { - if (issuer == null) { - return monoError(LOGGER, new NullPointerException("'issuer' cannot be null.")); - } - - try { - IssuerBundle issuerBundle = CertificateIssuerHelper.getIssuerBundle(issuer); - return implClient - .updateCertificateIssuerWithResponseAsync(vaultUrl, issuer.getName(), issuer.getProvider(), - issuerBundle.getCredentials(), issuerBundle.getOrganizationDetails(), issuerBundle.getAttributes()) - .map(response -> new SimpleResponse<>(response, createCertificateIssuer(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Sets the certificate contacts on the key vault. This operation requires the certificates/managecontacts - * permission. - * - *

The {@link LifetimeAction} of type {@link CertificatePolicyAction#EMAIL_CONTACTS} set on a - * {@link CertificatePolicy} emails the contacts set on the vault when triggered.

- * - *

Code Samples

- *

Sets the certificate contacts in the Azure Key Vault. Prints out the returned contacts details.

- * - * - *
-     * CertificateContact contactToAdd = new CertificateContact().setName("user").setEmail("useremail@example.com");
-     * certificateAsyncClient.setContacts(Collections.singletonList(contactToAdd)).subscribe(contact ->
-     *     System.out.printf("Contact name %s and email %s", contact.getName(), contact.getEmail())
-     * );
-     * 
- * - * - * @param contacts The list of contacts to set on the vault. - * @throws HttpResponseException when a contact information provided is invalid/incomplete. - * @return A {@link PagedFlux} containing all of the {@link CertificateContact certificate contacts} in the vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux setContacts(List contacts) { - return new PagedFlux<>( - () -> implClient.setCertificateContactsWithResponseAsync(vaultUrl, new Contacts().setContactList(contacts)) - .map(CertificateAsyncClient::mapContactsToPagedResponse)); - } - - /** - * Lists the certificate contacts in the key vault. This operation requires the certificates/managecontacts - * permission. - * - *

Code Samples

- *

Lists the certificate contacts in the Azure Key Vault. Prints out the returned contacts details.

- * - * - *
-     * certificateAsyncClient.listContacts().subscribe(contact ->
-     *     System.out.printf("Contact name %s and email %s", contact.getName(), contact.getEmail())
-     * );
-     * 
- * - * - * @return A {@link PagedFlux} containing all of the {@link CertificateContact certificate contacts} in the vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listContacts() { - return new PagedFlux<>(() -> implClient.getCertificateContactsWithResponseAsync(vaultUrl) - .map(CertificateAsyncClient::mapContactsToPagedResponse)); - } - - /** - * Deletes the certificate contacts in the key vault. This operation requires the certificates/managecontacts - * permission. - * - *

Code Samples

- *

Deletes the certificate contacts in the Azure Key Vault. Prints out the deleted contacts details.

- * - * - *
-     * certificateAsyncClient.deleteContacts().subscribe(contact ->
-     *     System.out.printf("Deleted Contact name %s and email %s", contact.getName(), contact.getEmail())
-     * );
-     * 
- * - * - * @return A {@link PagedFlux} containing all of the {@link CertificateContact deleted certificate contacts} in the - * vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux deleteContacts() { - return new PagedFlux<>(() -> implClient.deleteCertificateContactsWithResponseAsync(vaultUrl) - .map(CertificateAsyncClient::mapContactsToPagedResponse)); - } - - static PagedResponse mapContactsToPagedResponse(Response response) { - return new PagedResponseBase<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - response.getValue().getContactList(), null, null); - } - - /** - * Deletes the creation operation for the specified certificate that is in the process of being created. The - * certificate is no longer created. This operation requires the certificates/update permission. - * - *

Code Samples

- *

Triggers certificate creation and then deletes the certificate creation operation in the Azure Key Vault. - * Prints out the deleted certificate operation details when a response has been received.

- * - * - *
-     * certificateAsyncClient.deleteCertificateOperation("certificateName")
-     *     .subscribe(certificateOperation -> System.out.printf("Deleted Certificate operation last status %s",
-     *         certificateOperation.getStatus()));
-     * 
- * - * - * @param certificateName The name of the certificate which is in the process of being created. - * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code certificateName} - * doesn't exist in the key vault. - * @throws HttpResponseException when the {@code certificateName} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link CertificateOperation deleted certificate operation}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteCertificateOperation(String certificateName) { - return deleteCertificateOperationWithResponse(certificateName).flatMap(FluxUtil::toMono); - } - - /** - * Deletes the creation operation for the specified certificate that is in the process of being created. The - * certificate is no longer created. This operation requires the certificates/update permission. - * - *

Code Samples

- *

Triggers certificate creation and then deletes the certificate creation operation in the Azure Key Vault. - * Prints out the deleted certificate operation details when a response has been received.

- * - * - *
-     * certificateAsyncClient.deleteCertificateOperationWithResponse("certificateName")
-     *     .subscribe(certificateOperationResponse -> System.out.printf("Deleted Certificate operation's last"
-     *         + " status %s", certificateOperationResponse.getValue().getStatus()));
-     * 
- * - * - * @param certificateName The name of the certificate which is in the process of being created. - * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code certificateName} - * doesn't exist in the key vault. - * @throws HttpResponseException when the {@code certificateName} is empty string. - * @return A {@link Mono} containing the {@link CertificateOperation deleted certificate operation}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteCertificateOperationWithResponse(String certificateName) { - try { - return implClient.deleteCertificateOperationWithResponseAsync(vaultUrl, certificateName) - .onErrorMap(KeyVaultErrorException.class, - CertificateAsyncClient::mapDeleteCertificateOperationException) - .map(response -> new SimpleResponse<>(response, createCertificateOperation(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - static HttpResponseException mapDeleteCertificateOperationException(KeyVaultErrorException ex) { - if (ex.getResponse().getStatusCode() == 400) { - return new ResourceModifiedException(ex.getMessage(), ex.getResponse(), ex.getValue()); - } else if (ex.getResponse().getStatusCode() == 404) { - return new ResourceNotFoundException(ex.getMessage(), ex.getResponse(), ex.getValue()); - } else { - return ex; - } - } - - /** - * Cancels a certificate creation operation that is already in progress. This operation requires the - * certificates/update permission. - * - *

Code Samples

- *

Triggers certificate creation and then cancels the certificate creation operation in the Azure Key Vault. - * Prints out the updated certificate operation details when a response has been received.

- * - * - *
-     * certificateAsyncClient.cancelCertificateOperation("certificateName")
-     *     .subscribe(certificateOperation -> System.out.printf("Certificate operation status %s",
-     *         certificateOperation.getStatus()));
-     * 
- * - * - * @param certificateName The name of the certificate which is in the process of being created. - * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code name} doesn't exist - * in the key vault. - * @throws HttpResponseException when the {@code name} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link CertificateOperation cancelled certificate operation}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono cancelCertificateOperation(String certificateName) { - return cancelCertificateOperationWithResponse(certificateName).flatMap(FluxUtil::toMono); - } - - /** - * Cancels a certificate creation operation that is already in progress. This operation requires the - * certificates/update permission. - * - *

Code Samples

- *

Triggers certificate creation and then cancels the certificate creation operation in the Azure Key Vault. - * Prints out the updated certificate operation details when a response has been received.

- * - * - *
-     * certificateAsyncClient.cancelCertificateOperationWithResponse("certificateName")
-     *     .subscribe(certificateOperationResponse -> System.out.printf("Certificate operation status %s",
-     *         certificateOperationResponse.getValue().getStatus()));
-     * 
- * - * - * @param certificateName The name of the certificate which is in the process of being created. - * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code name} doesn't exist - * in the key vault. - * @throws HttpResponseException when the {@code name} is empty string. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link CertificateOperation cancelled certificate operation}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> cancelCertificateOperationWithResponse(String certificateName) { - try { - return implClient.updateCertificateOperationWithResponseAsync(vaultUrl, certificateName, true) - .onErrorMap(KeyVaultErrorException.class, - CertificateAsyncClient::mapUpdateCertificateOperationException) - .map(response -> new SimpleResponse<>(response, createCertificateOperation(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - /** - * Imports an existing valid certificate, containing a private key, into Azure Key Vault. This operation requires - * the certificates/import permission. The certificate to be imported can be in either PFX or PEM format. If the - * certificate is in PEM format the PEM file must contain the key as well as x509 certificates. Key Vault will only - * accept a key in PKCS#8 format. - * - *

Code Samples

- *

Imports a certificate into the key vault.

- * - * - *
-     * byte[] certificateToImport = new byte[100];
-     * ImportCertificateOptions config =
-     *     new ImportCertificateOptions("certificateName", certificateToImport).setEnabled(false);
-     * certificateAsyncClient.importCertificate(config)
-     *     .subscribe(certificate -> System.out.printf("Received Certificate with name %s and key id %s",
-     *         certificate.getProperties().getName(), certificate.getKeyId()));
-     * 
- * - * - * @param importCertificateOptions The details of the certificate to import to the key vault - * @throws NullPointerException if {@code importCertificateOptions} is null. - * @throws HttpResponseException when the {@code importCertificateOptions} are invalid. - * @return A {@link Response} whose {@link Response#getValue() value} contains the - * {@link KeyVaultCertificateWithPolicy imported certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono importCertificate(ImportCertificateOptions importCertificateOptions) { - return importCertificateWithResponse(importCertificateOptions).flatMap(FluxUtil::toMono); - } - - /** - * Imports a pre-existing certificate to the key vault. The specified certificate must be in PFX or PEM format, and - * must contain the private key as well as the x509 certificates. This operation requires the certificates/import - * permission. - * - *

Code Samples

- *

Imports a certificate into the key vault.

- * - * - *
-     * byte[] certToImport = new byte[100];
-     * ImportCertificateOptions importCertificateOptions  =
-     *     new ImportCertificateOptions("certificateName", certToImport).setEnabled(false);
-     * certificateAsyncClient.importCertificateWithResponse(importCertificateOptions)
-     *     .subscribe(certificateResponse -> System.out.printf("Received Certificate with name %s and key id %s",
-     *         certificateResponse.getValue().getProperties().getName(), certificateResponse.getValue().getKeyId()));
-     * 
- * - * - * @param importCertificateOptions The details of the certificate to import to the key vault - * @throws NullPointerException if {@code importCertificateOptions} is null. - * @throws HttpResponseException when the {@code importCertificateOptions} are invalid. - * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the - * {@link KeyVaultCertificateWithPolicy imported certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> - importCertificateWithResponse(ImportCertificateOptions importCertificateOptions) { - if (importCertificateOptions == null) { - return monoError(LOGGER, new NullPointerException("'importCertificateOptions' cannot be null.")); - } - - try { - com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy implPolicy - = getImplCertificatePolicy(importCertificateOptions.getPolicy()); - - return implClient.importCertificateWithResponseAsync(vaultUrl, importCertificateOptions.getName(), - transformCertificateForImport(importCertificateOptions), importCertificateOptions.getPassword(), - implPolicy, implPolicy == null ? null : implPolicy.getAttributes(), importCertificateOptions.getTags()) - .map(response -> new SimpleResponse<>(response, createCertificateWithPolicy(response.getValue()))); - } catch (RuntimeException ex) { - return monoError(LOGGER, ex); - } - } - - static String transformCertificateForImport(ImportCertificateOptions options) { - CertificatePolicy policy = options.getPolicy(); - - return (policy != null && CertificateContentType.PEM.equals(policy.getContentType())) - ? new String(options.getCertificate(), StandardCharsets.US_ASCII) - : Base64.getEncoder().encodeToString(options.getCertificate()); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClient.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClient.java deleted file mode 100644 index 4b9f28fde155..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClient.java +++ /dev/null @@ -1,2050 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.annotation.ReturnType; -import com.azure.core.annotation.ServiceClient; -import com.azure.core.annotation.ServiceMethod; -import com.azure.core.exception.HttpRequestException; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.SimpleResponse; -import com.azure.core.util.Context; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollResponse; -import com.azure.core.util.polling.PollingContext; -import com.azure.core.util.polling.SyncPoller; -import com.azure.security.keyvault.certificates.implementation.CertificateClientImpl; -import com.azure.security.keyvault.certificates.implementation.CertificateIssuerHelper; -import com.azure.security.keyvault.certificates.implementation.CertificateOperationHelper; -import com.azure.security.keyvault.certificates.implementation.CertificatePolicyHelper; -import com.azure.security.keyvault.certificates.implementation.DeletedCertificateHelper; -import com.azure.security.keyvault.certificates.implementation.KeyVaultCertificateWithPolicyHelper; -import com.azure.security.keyvault.certificates.implementation.models.BackupCertificateResult; -import com.azure.security.keyvault.certificates.implementation.models.CertificateAttributes; -import com.azure.security.keyvault.certificates.implementation.models.CertificateBundle; -import com.azure.security.keyvault.certificates.implementation.models.Contacts; -import com.azure.security.keyvault.certificates.implementation.models.IssuerBundle; -import com.azure.security.keyvault.certificates.implementation.models.KeyVaultErrorException; -import com.azure.security.keyvault.certificates.models.CertificateContact; -import com.azure.security.keyvault.certificates.models.CertificateIssuer; -import com.azure.security.keyvault.certificates.models.CertificateOperation; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.CertificatePolicyAction; -import com.azure.security.keyvault.certificates.models.CertificateProperties; -import com.azure.security.keyvault.certificates.models.DeletedCertificate; -import com.azure.security.keyvault.certificates.models.ImportCertificateOptions; -import com.azure.security.keyvault.certificates.models.IssuerProperties; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy; -import com.azure.security.keyvault.certificates.models.LifetimeAction; -import com.azure.security.keyvault.certificates.models.MergeCertificateOptions; - -import java.net.HttpURLConnection; -import java.time.Duration; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.function.Supplier; - -import static com.azure.security.keyvault.certificates.CertificateAsyncClient.mapCertificateItemPage; -import static com.azure.security.keyvault.certificates.CertificateAsyncClient.mapContactsToPagedResponse; -import static com.azure.security.keyvault.certificates.CertificateAsyncClient.mapDeletedCertificateItemPage; -import static com.azure.security.keyvault.certificates.CertificateAsyncClient.mapIssuersPagedResponse; -import static com.azure.security.keyvault.certificates.CertificateAsyncClient.processCertificateOperationResponse; -import static com.azure.security.keyvault.certificates.CertificateAsyncClient.transformCertificateForImport; -import static com.azure.security.keyvault.certificates.implementation.CertificateIssuerHelper.getIssuerBundle; -import static com.azure.security.keyvault.certificates.implementation.CertificateOperationHelper.createCertificateOperation; -import static com.azure.security.keyvault.certificates.implementation.CertificatePolicyHelper.getImplCertificatePolicy; -import static com.azure.security.keyvault.certificates.implementation.DeletedCertificateHelper.createDeletedCertificate; -import static com.azure.security.keyvault.certificates.implementation.KeyVaultCertificateWithPolicyHelper.createCertificateWithPolicy; - -/** - * The CertificateClient provides synchronous methods to manage {@link KeyVaultCertificate certifcates} in the key - * vault. The client supports creating, retrieving, updating, merging, deleting, purging, backing up, restoring and - * listing the {@link KeyVaultCertificate certificates}. The client also supports listing - * {@link DeletedCertificate deleted certificates} for a soft-delete enabled key vault. - * - *

The client further allows creating, retrieving, updating, deleting and listing the - * {@link CertificateIssuer certificate issuers}. The client also supports creating, listing and deleting - * {@link CertificateContact certificate contacts}

- * - *

Getting Started

- * - *

In order to interact with the Azure Key Vault service, you will need to create an instance of the - * {@link CertificateClient} class, a vault url and a credential object.

- * - *

The examples shown in this document use a credential object named DefaultAzureCredential for authentication, - * which is appropriate for most scenarios, including local development and production environments. Additionally, - * we recommend using a - * - * managed identity for authentication in production environments. - * You can find more information on different ways of authenticating and their corresponding credential types in the - * - * Azure Identity documentation".

- * - *

Sample: Construct Synchronous Certificate Client

- * - *

The following code sample demonstrates the creation of a {@link CertificateClient}, - * using the {@link CertificateClientBuilder} to configure it.

- * - * - *
- * CertificateClient certificateClient = new CertificateClientBuilder()
- *     .credential(new DefaultAzureCredentialBuilder().build())
- *     .vaultUrl("<your-key-vault-url>")
- *     .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
- *     .buildClient();
- * 
- * - * - *
- * - *
- * - *

Create a Certificate

- * The {@link CertificateClient} can be used to create a certificate in the key vault. - * - *

Code Sample:

- *

The following code sample demonstrates how to synchronously create a certificate in the key vault, - * using the {@link CertificateClient#beginCreateCertificate(String, CertificatePolicy)} API.

- * - * - *
- * CertificatePolicy certPolicy = new CertificatePolicy("Self",
- *     "CN=SelfSignedJavaPkcs12");
- * SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> certPoller = certificateClient
- *     .beginCreateCertificate("certificateName", certPolicy);
- * certPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
- * KeyVaultCertificate cert = certPoller.getFinalResult();
- * System.out.printf("Certificate created with name %s%n", cert.getName());
- * 
- * - * - *

Note: For the asynchronous sample, refer to {@link CertificateAsyncClient}.

- * - *
- * - *
- * - *

Get a Certificate

- * The {@link CertificateClient} can be used to retrieve a certificate from the key vault. - * - *

Code Sample:

- *

The following code sample demonstrates how to synchronously retrieve a certificate from the key vault, using - * the {@link CertificateClient#getCertificate(String)} API.

- * - * - *
- * CertificatePolicy policy = certificateClient.getCertificatePolicy("certificateName");
- * System.out.printf("Received policy with subject name %s%n", policy.getSubject());
- * 
- * - * - *

Note: For the asynchronous sample, refer to {@link CertificateAsyncClient}.

- * - *
- * - *
- * - *

Delete a Certificate

- * The {@link CertificateClient} can be used to delete a certificate from the key vault. - * - *

Code Sample:

- *

The following code sample demonstrates how to synchronously delete a certificate from the - * key vault, using the {@link CertificateClient#beginDeleteCertificate(String)} API.

- * - * - *
- * SyncPoller<DeletedCertificate, Void> deleteCertPoller =
- *     certificateClient.beginDeleteCertificate("certificateName");
- * // Deleted Certificate is accessible as soon as polling beings.
- * PollResponse<DeletedCertificate> deleteCertPollResponse = deleteCertPoller.poll();
- * System.out.printf("Deleted certificate with name %s and recovery id %s%n",
- *     deleteCertPollResponse.getValue().getName(), deleteCertPollResponse.getValue().getRecoveryId());
- * deleteCertPoller.waitForCompletion();
- * 
- * - * - *

Note: For the asynchronous sample, refer to {@link CertificateAsyncClient}.

- * - * @see com.azure.security.keyvault.certificates - * @see CertificateClientBuilder - */ -@ServiceClient( - builder = CertificateClientBuilder.class, - serviceInterfaces = CertificateClientImpl.CertificateClientService.class) -public final class CertificateClient { - private static final ClientLogger LOGGER = new ClientLogger(CertificateClient.class); - - private final CertificateClientImpl implClient; - private final String vaultUrl; - - /** - * Creates a CertificateClient that uses {@code pipeline} to service requests - * - * @param implClient The implementation client to route requests through. - * @param vaultUrl The vault url. - */ - CertificateClient(CertificateClientImpl implClient, String vaultUrl) { - this.implClient = implClient; - this.vaultUrl = vaultUrl; - } - - /** - * Get the vault endpoint url to which service requests are sent to. - * @return the vault endpoint url - */ - public String getVaultUrl() { - return vaultUrl; - } - - /** - * Creates a new certificate. If this is the first version, the certificate resource is created. This operation - * requires the certificates/create permission. - * - *

Create certificate is a long running operation. It indefinitely waits for the create certificate operation to - * complete on service side.

- * - *

Code Samples

- *

Create certificate is a long running operation. The createCertificate indefinitely waits for the operation to - * complete and returns its last status. The details of the last certificate operation status are printed when a - * response is received

- * - * - *
-     * CertificatePolicy certificatePolicyPkcsSelf = new CertificatePolicy("Self",
-     *     "CN=SelfSignedJavaPkcs12");
-     * SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> certificateSyncPoller = certificateClient
-     *     .beginCreateCertificate("certificateName", certificatePolicyPkcsSelf, true, new HashMap<>());
-     * certificateSyncPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
-     * KeyVaultCertificate createdCertificate = certificateSyncPoller.getFinalResult();
-     * System.out.printf("Certificate created with name %s%n", createdCertificate.getName());
-     * 
- * - * - * @param certificateName The name of the certificate to be created. - * @param policy The policy of the certificate to be created. - * @param isEnabled The enabled status of the certificate. - * @param tags The application specific metadata to set. - * @throws NullPointerException if {@code policy} is null. - * @throws ResourceModifiedException when invalid certificate policy configuration is provided. - * @return A {@link SyncPoller} to poll on the create certificate operation status. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller beginCreateCertificate( - String certificateName, CertificatePolicy policy, Boolean isEnabled, Map tags) { - if (policy == null) { - throw LOGGER.logExceptionAsError(new NullPointerException("'policy' cannot be null.")); - } - - return SyncPoller.createPoller(Duration.ofSeconds(1), - ignored -> createCertificateActivation(certificateName, policy, isEnabled, tags), - ignored -> certificatePollOperation(certificateName), - (ignored1, ignored2) -> certificateCancellationOperation(certificateName), - ignored -> fetchCertificateOperation(certificateName)); - } - - private PollResponse createCertificateActivation(String certificateName, - CertificatePolicy policy, Boolean isEnabled, Map tags) { - com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy implPolicy - = getImplCertificatePolicy(policy); - - return new PollResponse<>(LongRunningOperationStatus.NOT_STARTED, - createCertificateOperation(callWithMappedException( - () -> implClient.createCertificate(vaultUrl, certificateName, implPolicy, - new CertificateAttributes().setEnabled(isEnabled), tags), - CertificateAsyncClient::mapCreateCertificateException))); - } - - private PollResponse certificatePollOperation(String certificateName) { - return processCertificateOperationResponse( - callWithMappedException(() -> implClient.getCertificateOperation(vaultUrl, certificateName), - CertificateAsyncClient::mapGetCertificateOperationException)); - } - - private CertificateOperation certificateCancellationOperation(String certificateName) { - return createCertificateOperation( - callWithMappedException(() -> implClient.updateCertificateOperation(vaultUrl, certificateName, true), - CertificateAsyncClient::mapUpdateCertificateOperationException)); - } - - private KeyVaultCertificateWithPolicy fetchCertificateOperation(String certificateName) { - return createCertificateWithPolicy( - callWithMappedException(() -> implClient.getCertificate(vaultUrl, certificateName, null), - CertificateAsyncClient::mapGetCertificateException)); - } - - /** - * Creates a new certificate. If this is the first version, the certificate resource is created. This operation - * requires the certificates/create permission. - * - *

Create certificate is a long running operation. It indefinitely waits for the create certificate operation to - * complete on service side.

- * - *

Code Samples

- *

Create certificate is a long running operation. The createCertificate indefinitely waits for the operation to - * complete and returns its last status. The details of the last certificate operation status are printed when a - * response is received

- * - * - *
-     * CertificatePolicy certPolicy = new CertificatePolicy("Self",
-     *     "CN=SelfSignedJavaPkcs12");
-     * SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> certPoller = certificateClient
-     *     .beginCreateCertificate("certificateName", certPolicy);
-     * certPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
-     * KeyVaultCertificate cert = certPoller.getFinalResult();
-     * System.out.printf("Certificate created with name %s%n", cert.getName());
-     * 
- * - * - * @param certificateName The name of the certificate to be created. - * @param policy The policy of the certificate to be created. - * @throws NullPointerException if {@code policy} is null. - * @throws ResourceModifiedException when invalid certificate policy configuration is provided. - * @return A {@link SyncPoller} to poll on the create certificate operation status. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller - beginCreateCertificate(String certificateName, CertificatePolicy policy) { - return beginCreateCertificate(certificateName, policy, true, null); - } - - /** - * Gets a pending {@link CertificateOperation} from the key vault. This operation requires the certificates/get - * permission. - * - *

Code Samples

- *

Geta a pending certificate operation. The {@link SyncPoller poller} allows users to automatically poll on the - * certificate operation status.

- * - * - *
-     * SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> getCertPoller = certificateClient
-     *     .getCertificateOperation("certificateName");
-     * getCertPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
-     * KeyVaultCertificate cert = getCertPoller.getFinalResult();
-     * System.out.printf("Certificate created with name %s%n", cert.getName());
-     * 
- * - * - * @param certificateName The name of the certificate. - * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code certificateName} - * doesn't exist. - * @return A {@link SyncPoller} to poll on the certificate operation status. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller - getCertificateOperation(String certificateName) { - return SyncPoller.createPoller(Duration.ofSeconds(1), - ignored -> new PollResponse<>(LongRunningOperationStatus.NOT_STARTED, null), - ignored -> certificatePollOperation(certificateName), - (ignored1, ignored2) -> certificateCancellationOperation(certificateName), - ignored -> fetchCertificateOperation(certificateName)); - } - - /** - * Gets information about the latest version of the specified certificate. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when - * a response has been received.

- * - * - *
-     * KeyVaultCertificateWithPolicy certificate = certificateClient.getCertificate("certificateName");
-     * System.out.printf("Received certificate with name %s and version %s and secret id %s%n",
-     *     certificate.getProperties().getName(),
-     *     certificate.getProperties().getVersion(), certificate.getSecretId());
-     * 
- * - * - * @param certificateName The name of the certificate to retrieve, cannot be null - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException if {@code certificateName} is empty string. - * @return The requested {@link KeyVaultCertificateWithPolicy certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultCertificateWithPolicy getCertificate(String certificateName) { - return getCertificateWithResponse(certificateName, Context.NONE).getValue(); - } - - /** - * Gets information about the latest version of the specified certificate. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when - * a response has been received.

- * - * - *
-     * Response<KeyVaultCertificateWithPolicy> certificateWithResponse = certificateClient
-     *     .getCertificateWithResponse("certificateName", new Context(key1, value1));
-     * System.out.printf("Received certificate with name %s and version %s and secret id %s%n",
-     *     certificateWithResponse.getValue().getProperties().getName(),
-     *     certificateWithResponse.getValue().getProperties().getVersion(), certificate.getSecretId());
-     * 
- * - * - * @param certificateName The name of the certificate to retrieve, cannot be null - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException if {@code certificateName} is empty string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the requested - * {@link KeyVaultCertificateWithPolicy certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getCertificateWithResponse(String certificateName, Context context) { - return callWithMappedResponseAndException( - () -> implClient.getCertificateWithResponse(vaultUrl, certificateName, null, context), - KeyVaultCertificateWithPolicyHelper::createCertificateWithPolicy, - CertificateAsyncClient::mapGetCertificateException); - } - - /** - * Gets information about the latest version of the specified certificate. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when - * a response has been received.

- * - * - *
-     * Response<KeyVaultCertificate> returnedCertificateWithResponse = certificateClient
-     *     .getCertificateVersionWithResponse("certificateName", "certificateVersion",
-     *         new Context(key1, value1));
-     * System.out.printf("Received certificate with name %s and version %s and secret id %s%n",
-     *     returnedCertificateWithResponse.getValue().getProperties().getName(),
-     *     returnedCertificateWithResponse.getValue().getProperties().getVersion(),
-     *     returnedCertificateWithResponse.getValue().getSecretId());
-     * 
- * - * - * @param certificateName The name of the certificate to retrieve, cannot be null - * @param version The version of the certificate to retrieve. If this is an empty String or null then latest version - * of the certificate is retrieved. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException if {@code certificateName} is empty string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the requested - * {@link KeyVaultCertificate certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getCertificateVersionWithResponse(String certificateName, String version, - Context context) { - return callWithMappedResponseAndException( - () -> implClient.getCertificateWithResponse(vaultUrl, certificateName, version, context), - KeyVaultCertificateWithPolicyHelper::createCertificateWithPolicy, - CertificateAsyncClient::mapGetCertificateException); - } - - /** - * Gets information about the specified version of the specified certificate. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Gets a specific version of the certificate in the key vault. Prints out the returned certificate details when - * a response has been received.

- * - * - *
-     * KeyVaultCertificate returnedCertificate = certificateClient.getCertificateVersion("certificateName",
-     *     "certificateVersion");
-     * System.out.printf("Received certificate with name %s and version %s and secret id %s%n",
-     *     returnedCertificate.getProperties().getName(), returnedCertificate.getProperties().getVersion(),
-     *     returnedCertificate.getSecretId());
-     * 
- * - * - * @param certificateName The name of the certificate to retrieve, cannot be null - * @param version The version of the certificate to retrieve. If this is an empty String or null then latest version - * of the certificate is retrieved. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException if {@code certificateName} is empty string. - * @return The requested {@link KeyVaultCertificate certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultCertificate getCertificateVersion(String certificateName, String version) { - return getCertificateVersionWithResponse(certificateName, version, Context.NONE).getValue(); - } - - /** - * Updates the specified attributes associated with the specified certificate. The update operation changes - * specified attributes of an existing stored certificate and attributes that are not specified in the request are - * left unchanged. This operation requires the certificates/update permission. - * - *

Code Samples

- *

Gets latest version of the certificate, changes its tags and enabled status and then updates it in the Azure - * Key Vault. Prints out the returned certificate details when a response has been received.

- * - * - *
-     * KeyVaultCertificate certificate = certificateClient.getCertificate("certificateName");
-     * // Update certificate enabled status
-     * certificate.getProperties().setEnabled(false);
-     * KeyVaultCertificate updatedCertificate = certificateClient.updateCertificateProperties(certificate.getProperties());
-     * System.out.printf("Updated Certificate with name %s and enabled status %s%n",
-     *     updatedCertificate.getProperties().getName(), updatedCertificate.getProperties().isEnabled());
-     * 
- * - * - * @param properties The {@link CertificateProperties} object with updated properties. - * @throws NullPointerException if {@code properties} is null. - * @throws ResourceNotFoundException when a certificate with {@link CertificateProperties#getName() certificateName} - * and {@link CertificateProperties#getVersion() version} doesn't exist in the key vault. - * @throws HttpRequestException if {@link CertificateProperties#getName() certificateName} or - * {@link CertificateProperties#getVersion() version} is empty string. - * @return The {@link CertificateProperties updated certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultCertificate updateCertificateProperties(CertificateProperties properties) { - return updateCertificatePropertiesWithResponse(properties, Context.NONE).getValue(); - } - - /** - * Updates the specified attributes associated with the specified certificate. The update operation changes - * specified attributes of an existing stored certificate and attributes that are not specified in the request are - * left unchanged. This operation requires the certificates/update permission. - * - *

Code Samples

- *

Gets latest version of the certificate, changes its tags and enabled status and then updates it in the Azure - * Key Vault. Prints out the returned certificate details when a response has been received.

- * - * - *
-     * KeyVaultCertificate certificateToUpdate = certificateClient.getCertificate("certificateName");
-     * // Update certificate enabled status
-     * certificateToUpdate.getProperties().setEnabled(false);
-     * Response<KeyVaultCertificate> updatedCertificateResponse = certificateClient.
-     *     updateCertificatePropertiesWithResponse(certificateToUpdate.getProperties(), new Context(key1, value1));
-     * System.out.printf("Updated Certificate with name %s and enabled status %s%n",
-     *     updatedCertificateResponse.getValue().getProperties().getName(),
-     *     updatedCertificateResponse.getValue().getProperties().isEnabled());
-     * 
- * - * - * @param properties The {@link CertificateProperties} object with updated properties. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws NullPointerException if {@code properties} is null. - * @throws ResourceNotFoundException when a certificate with {@link CertificateProperties#getName() certificateName} - * and {@link CertificateProperties#getVersion() version} doesn't exist in the key vault. - * @throws HttpRequestException if {@link CertificateProperties#getName() certificateName} or - * {@link CertificateProperties#getVersion() version} is empty string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the {@link CertificateProperties updated certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateCertificatePropertiesWithResponse(CertificateProperties properties, - Context context) { - if (properties == null) { - throw LOGGER.logExceptionAsError(new NullPointerException("'properties' cannot be null.")); - } - - CertificateAttributes certificateAttributes = new CertificateAttributes().setEnabled(properties.isEnabled()) - .setExpires(properties.getExpiresOn()) - .setNotBefore(properties.getNotBefore()); - - Response response = implClient.updateCertificateWithResponse(vaultUrl, properties.getName(), - properties.getVersion(), null, certificateAttributes, properties.getTags(), context); - - return new SimpleResponse<>(response, createCertificateWithPolicy(response.getValue())); - } - - /** - * Deletes a certificate from a specified key vault. All the versions of the certificate along with its associated - * policy get deleted. If soft-delete is enabled on the key vault then the certificate is placed in the deleted - * state and requires to be purged for permanent deletion else the certificate is permanently deleted. The delete - * operation applies to any certificate stored in Azure Key Vault, but it cannot be applied to an individual version - * of a certificate. This operation requires the certificates/delete permission. - * - *

Code Samples

- *

Deletes the certificate in the Azure Key Vault. Prints out the deleted certificate details when a response has - * been received.

- * - * - *
-     * SyncPoller<DeletedCertificate, Void> deleteCertPoller =
-     *     certificateClient.beginDeleteCertificate("certificateName");
-     * // Deleted Certificate is accessible as soon as polling beings.
-     * PollResponse<DeletedCertificate> deleteCertPollResponse = deleteCertPoller.poll();
-     * System.out.printf("Deleted certificate with name %s and recovery id %s%n",
-     *     deleteCertPollResponse.getValue().getName(), deleteCertPollResponse.getValue().getRecoveryId());
-     * deleteCertPoller.waitForCompletion();
-     * 
- * - * - * @param certificateName The name of the certificate to be deleted. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException when a certificate with {@code certificateName} is empty string. - * @return A {@link SyncPoller} to poll on and retrieve {@link DeletedCertificate deleted certificate}. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller beginDeleteCertificate(String certificateName) { - return SyncPoller.createPoller(Duration.ofSeconds(1), ignored -> deleteCertificateActivation(certificateName), - pollingContext -> deleteCertificatePollOperation(certificateName, pollingContext), - (pollingContext, firstResponse) -> null, pollingContext -> null); - } - - private PollResponse deleteCertificateActivation(String certificateName) { - return new PollResponse<>(LongRunningOperationStatus.NOT_STARTED, - createDeletedCertificate( - callWithMappedException(() -> implClient.deleteCertificate(vaultUrl, certificateName), - CertificateAsyncClient::mapDeleteCertificateException))); - } - - private PollResponse deleteCertificatePollOperation(String certificateName, - PollingContext pollingContext) { - try { - return new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - createDeletedCertificate(implClient.getDeletedCertificate(vaultUrl, certificateName))); - } catch (KeyVaultErrorException ex) { - if (ex.getResponse().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, - pollingContext.getLatestResponse().getValue()); - } else { - // This means either vault has soft-delete disabled or permission is not granted for the get deleted - // certificate operation. In both cases deletion operation was successful when activation operation - // succeeded before reaching here. - return new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - pollingContext.getLatestResponse().getValue()); - } - } catch (Exception ex) { - // This means either vault has soft-delete disabled or permission is not granted for the get deleted - // certificate operation. In both cases deletion operation was successful when activation operation - // succeeded before reaching here. - return new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - pollingContext.getLatestResponse().getValue()); - } - } - - /** - * Retrieves information about the specified deleted certificate. The GetDeletedCertificate operation is applicable - * for soft-delete enabled vaults and additionally retrieves deleted certificate's attributes, such as retention - * interval, scheduled permanent deletion and the current deletion recovery level. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Gets the deleted certificate from the key vault enabled for soft-delete. Prints out the deleted certificate - * details when a response has been received.

- * - * - *
-     * DeletedCertificate deletedCertificate = certificateClient.getDeletedCertificate("certificateName");
-     * System.out.printf("Deleted certificate with name %s and recovery id %s%n", deletedCertificate.getName(),
-     *     deletedCertificate.getRecoveryId());
-     * 
- * - * - * @param certificateName The name of the deleted certificate. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException when a certificate with {@code certificateName} is empty string. - * @return The {@link DeletedCertificate deleted certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public DeletedCertificate getDeletedCertificate(String certificateName) { - return getDeletedCertificateWithResponse(certificateName, Context.NONE).getValue(); - } - - /** - * Retrieves information about the specified deleted certificate. The GetDeletedCertificate operation is applicable - * for soft-delete enabled vaults and additionally retrieves deleted certificate's attributes, such as retention - * interval, scheduled permanent deletion and the current deletion recovery level. This operation requires the - * certificates/get permission. - * - *

Code Samples

- *

Gets the deleted certificate from the key vault enabled for soft-delete. Prints out the deleted certificate - * details when a response has been received.

- * - * - *
-     * Response<DeletedCertificate> deletedCertificateWithResponse = certificateClient
-     *     .getDeletedCertificateWithResponse("certificateName", new Context(key1, value1));
-     * System.out.printf("Deleted certificate with name %s and recovery id %s%n",
-     *     deletedCertificateWithResponse.getValue().getName(),
-     *     deletedCertificateWithResponse.getValue().getRecoveryId());
-     * 
- * - * - * @param certificateName The name of the deleted certificate. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException when a certificate with {@code certificateName} is empty string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the - * {@link DeletedCertificate deleted certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getDeletedCertificateWithResponse(String certificateName, Context context) { - return callWithMappedResponseAndException( - () -> implClient.getDeletedCertificateWithResponse(vaultUrl, certificateName, context), - DeletedCertificateHelper::createDeletedCertificate, - CertificateAsyncClient::mapGetDeletedCertificateException); - } - - /** - * Permanently deletes the specified deleted certificate without possibility for recovery. The Purge Deleted - * Certificate operation is applicable for soft-delete enabled vaults and is not available if the recovery level - * does not specify 'Purgeable'. This operation requires the certificate/purge permission. - * - *

Code Samples

- *

Purges the deleted certificate from the key vault enabled for soft-delete. Prints out the status code from the - * server response when a response has been received.

- - * - *
-     * certificateClient.purgeDeletedCertificate("certificateName");
-     * 
- * - * - * @param certificateName The name of the deleted certificate. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException when a certificate with {@code certificateName} is empty string. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void purgeDeletedCertificate(String certificateName) { - purgeDeletedCertificateWithResponse(certificateName, Context.NONE); - } - - /** - * Permanently deletes the specified deleted certificate without possibility for recovery. The Purge Deleted - * Certificate operation is applicable for soft-delete enabled vaults and is not available if the recovery level - * does not specify 'Purgeable'. This operation requires the certificate/purge permission. - * - *

Code Samples

- *

Purges the deleted certificate from the key vault enabled for soft-delete. Prints out the status code from the - * server response when a response has been received.

- - * - *
-     * Response<Void> purgeResponse = certificateClient.purgeDeletedCertificateWithResponse("certificateName",
-     *     new Context(key1, value1));
-     * System.out.printf("Purged Deleted certificate with status %d%n", purgeResponse.getStatusCode());
-     * 
- * - * - * @param certificateName The name of the deleted certificate. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException when a certificate with {@code certificateName} is empty string. - * @return A response containing status code and HTTP headers. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response purgeDeletedCertificateWithResponse(String certificateName, Context context) { - return callWithMappedResponseAndException( - () -> implClient.purgeDeletedCertificateWithResponse(vaultUrl, certificateName, context), t -> t, - CertificateAsyncClient::mapPurgeDeletedCertificateException); - } - - /** - * Recovers the deleted certificate back to its current version under /certificates and can only be performed on a - * soft-delete enabled vault. The RecoverDeletedCertificate operation performs the reversal of the Delete operation - * and must be issued during the retention interval (available in the deleted certificate's attributes). This - * operation requires the certificates/recover permission. - * - *

Code Samples

- *

Recovers the deleted certificate from the key vault enabled for soft-delete. Prints out the recovered - * certificate details when a response has been received.

- * - * - *
-     * SyncPoller<KeyVaultCertificateWithPolicy, Void> recoverDeletedCertPoller = certificateClient
-     *     .beginRecoverDeletedCertificate("deletedCertificateName");
-     * // Recovered certificate is accessible as soon as polling beings
-     * PollResponse<KeyVaultCertificateWithPolicy> recoverDeletedCertPollResponse = recoverDeletedCertPoller.poll();
-     * System.out.printf(" Recovered Deleted certificate with name %s and id %s%n",
-     *     recoverDeletedCertPollResponse.getValue().getProperties().getName(),
-     *     recoverDeletedCertPollResponse.getValue().getProperties().getId());
-     * recoverDeletedCertPoller.waitForCompletion();
-     * 
- * - * - * @param certificateName The name of the deleted certificate to be recovered. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the - * certificate vault. - * @throws HttpRequestException when a certificate with {@code certificateName} is empty string. - * @return A {@link SyncPoller} to poll on and retrieve {@link KeyVaultCertificateWithPolicy recovered certificate}. - */ - @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller beginRecoverDeletedCertificate(String certificateName) { - return SyncPoller.createPoller(Duration.ofSeconds(1), - ignored -> recoverDeletedCertificateActivation(certificateName), - pollingContext -> recoverDeletedCertificatePollOperation(certificateName, pollingContext), - (pollingContext, firstResponse) -> null, pollingContext -> null); - } - - private PollResponse recoverDeletedCertificateActivation(String certificateName) { - return new PollResponse<>(LongRunningOperationStatus.NOT_STARTED, - createCertificateWithPolicy( - callWithMappedException(() -> implClient.recoverDeletedCertificate(vaultUrl, certificateName), - CertificateAsyncClient::mapRecoverDeletedCertificateException))); - } - - private PollResponse recoverDeletedCertificatePollOperation(String certificateName, - PollingContext pollingContext) { - try { - return new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - createCertificateWithPolicy(implClient.getCertificate(vaultUrl, certificateName, null))); - } catch (KeyVaultErrorException ex) { - if (ex.getResponse().getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) { - return new PollResponse<>(LongRunningOperationStatus.IN_PROGRESS, - pollingContext.getLatestResponse().getValue()); - } else { - // This means permission is not granted for the get deleted key operation. - // In both cases deletion operation was successful when activation operation succeeded before - // reaching here. - return new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - pollingContext.getLatestResponse().getValue()); - } - } catch (Exception ex) { - // This means permission is not granted for the get deleted key operation. - // In both cases deletion operation was successful when activation operation succeeded before reaching - // here. - return new PollResponse<>(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - pollingContext.getLatestResponse().getValue()); - } - } - - /** - * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate - * will be downloaded. This operation requires the certificates/backup permission. - * - *

Code Samples

- *

Backs up the certificate from the key vault. Prints out the length of the certificate's backup byte array - * returned in the response.

- * - * - *
-     * byte[] certificateBackup = certificateClient.backupCertificate("certificateName");
-     * System.out.printf("Backed up certificate with back up blob length %d%n", certificateBackup.length);
-     * 
- * - * - * @param certificateName The name of the certificate. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException when a certificate with {@code certificateName} is empty string. - * @return The backed up certificate blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public byte[] backupCertificate(String certificateName) { - return backupCertificateWithResponse(certificateName, Context.NONE).getValue(); - } - - /** - * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate - * will be downloaded. This operation requires the certificates/backup permission. - * - *

Code Samples

- *

Backs up the certificate from the key vault. Prints out the length of the certificate's backup byte array - * returned in the response.

- * - * - *
-     * Response<byte[]> certificateBackupWithResponse = certificateClient
-     *     .backupCertificateWithResponse("certificateName", new Context(key1, value1));
-     * System.out.printf("Backed up certificate with back up blob length %d%n",
-     *     certificateBackupWithResponse.getValue().length);
-     * 
- * - * - * @param certificateName The certificateName of the certificate. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException when a certificate with {@code certificateName} is empty string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the backed up certificate blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response backupCertificateWithResponse(String certificateName, Context context) { - return callWithMappedResponseAndException( - () -> implClient.backupCertificateWithResponse(vaultUrl, certificateName, context), - BackupCertificateResult::getValue, CertificateAsyncClient::mapBackupCertificateException); - } - - /** - * Restores a backed up certificate to the vault. All the versions of the certificate are restored to the vault. - * This operation requires the certificates/restore permission. - * - *

Code Samples

- *

Restores the certificate in the key vault from its backup. Prints out the restored certificate details when a - * response has been received.

- * - * - *
-     * byte[] certificateBackupBlob = {};
-     * KeyVaultCertificate certificate = certificateClient.restoreCertificateBackup(certificateBackupBlob);
-     * System.out.printf(" Restored certificate with name %s and id %s%n",
-     *     certificate.getProperties().getName(), certificate.getProperties().getId());
-     * 
- * - * - * @param backup The backup blob associated with the certificate. - * @throws ResourceModifiedException when {@code backup} blob is malformed. - * @return The {@link KeyVaultCertificate restored certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultCertificateWithPolicy restoreCertificateBackup(byte[] backup) { - return restoreCertificateBackupWithResponse(backup, Context.NONE).getValue(); - } - - /** - * Restores a backed up certificate to the vault. All the versions of the certificate are restored to the vault. - * This operation requires the certificates/restore permission. - * - *

Code Samples

- *

Restores the certificate in the key vault from its backup. Prints out the restored certificate details when a - * response has been received.

- * - * - *
-     * byte[] certificateBackupBlobArray = {};
-     * Response<KeyVaultCertificateWithPolicy> certificateResponse = certificateClient
-     *     .restoreCertificateBackupWithResponse(certificateBackupBlobArray, new Context(key1, value1));
-     * System.out.printf(" Restored certificate with name %s and id %s%n",
-     *     certificateResponse.getValue().getProperties().getName(),
-     *     certificateResponse.getValue().getProperties().getId());
-     * 
- * - * - * @param backup The backup blob associated with the certificate. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws ResourceModifiedException when {@code backup} blob is malformed. - * @return A {@link Response} whose {@link Response#getValue() value} contains the - * {@link KeyVaultCertificate restored certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response restoreCertificateBackupWithResponse(byte[] backup, - Context context) { - return callWithMappedResponseAndException( - () -> implClient.restoreCertificateWithResponse(vaultUrl, backup, context), - KeyVaultCertificateWithPolicyHelper::createCertificateWithPolicy, - CertificateAsyncClient::mapRestoreCertificateException); - } - - /** - * List certificates in the key vault. Retrieves the set of certificates resources in the key vault and the - * individual certificate response in the iterable is represented by {@link CertificateProperties} as only the - * certificate identifier, thumbprint, attributes and tags are provided in the response. The policy and individual - * certificate versions are not listed in the response. This operation requires the certificates/list permission. - * - *

It is possible to get certificates with all the properties excluding the policy from this information. Loop - * over the {@link CertificateProperties} and call {@link CertificateClient#getCertificateVersion(String, String)} . - * This will return the {@link KeyVaultCertificate certificate} with all its properties excluding the policy.

- * - * - *
-     * for (CertificateProperties certificateProperties : certificateClient.listPropertiesOfCertificates()) {
-     *     KeyVaultCertificate certificateWithAllProperties = certificateClient
-     *         .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion());
-     *     System.out.printf("Received certificate with name %s and secret id %s%n",
-     *         certificateWithAllProperties.getProperties().getName(),
-     *         certificateWithAllProperties.getSecretId());
-     * }
-     * 
- * - * - * @return A {@link PagedIterable} containing {@link CertificateProperties certificate} for all the certificates in - * the vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listPropertiesOfCertificates() { - return listPropertiesOfCertificates(false, Context.NONE); - } - - /** - * List certificates in the key vault. Retrieves the set of certificates resources in the key vault and the - * individual certificate response in the iterable is represented by {@link CertificateProperties} as only the - * certificate identifier, thumbprint, attributes and tags are provided in the response. The policy and individual - * certificate versions are not listed in the response. This operation requires the certificates/list permission. - * - *

It is possible to get certificates with all the properties excluding the policy from this information. Loop - * over the {@link CertificateProperties} and call {@link CertificateClient#getCertificateVersion(String, String)} . - * This will return the {@link KeyVaultCertificate certificate} with all its properties excluding the policy.

- * - * - *
-     * for (CertificateProperties certificateProperties : certificateClient
-     *     .listPropertiesOfCertificates(true, new Context(key1, value1))) {
-     *     KeyVaultCertificate certificateWithAllProperties = certificateClient
-     *         .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion());
-     *     System.out.printf("Received certificate with name %s and secret id %s%n",
-     *         certificateWithAllProperties.getProperties().getName(),
-     *         certificateWithAllProperties.getSecretId());
-     * }
-     * 
- * - * - * @param includePending indicate if pending certificates should be included in the results. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link PagedIterable} containing {@link CertificateProperties certificate} for all the certificates in - * the vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listPropertiesOfCertificates(boolean includePending, Context context) { - return new PagedIterable<>( - maxResults -> mapCertificateItemPage( - implClient.getCertificatesSinglePage(vaultUrl, maxResults, includePending, context)), - (continuationToken, maxResults) -> mapCertificateItemPage( - implClient.getCertificatesNextSinglePage(continuationToken, vaultUrl, context))); - } - - /** - * Lists the {@link DeletedCertificate deleted certificates} in the key vault currently available for recovery. This - * operation includes deletion-specific information and is applicable for vaults enabled for soft-delete. This - * operation requires the certificates/get/list permission. - * - *

Code Samples

- *

Lists the deleted certificates in the key vault. Prints out the recovery id of each deleted certificate when a - * response has been received.

- * - * - *
-     * for (DeletedCertificate deletedCertificate : certificateClient.listDeletedCertificates()) {
-     *     System.out.printf("Deleted certificate's recovery Id %s%n", deletedCertificate.getRecoveryId());
-     * }
-     * 
- * - * - * @return A {@link PagedIterable} containing all of the {@link DeletedCertificate deleted certificates} in the - * vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listDeletedCertificates() { - return listDeletedCertificates(false, Context.NONE); - } - - /** - * Lists the {@link DeletedCertificate deleted certificates} in the key vault currently available for recovery. This - * operation includes deletion-specific information and is applicable for vaults enabled for soft-delete. This - * operation requires the certificates/get/list permission. - * - *

Code Samples

- *

Lists the deleted certificates in the key vault. Prints out the recovery id of each deleted certificate when a - * response has been received.

- * - * - *
-     * for (DeletedCertificate deletedCertificate : certificateClient
-     *     .listDeletedCertificates(true, new Context(key1, value1))) {
-     *     System.out.printf("Deleted certificate's recovery Id %s%n", deletedCertificate.getRecoveryId());
-     * }
-     * 
- * - * - * @param includePending indicate if pending deleted certificates should be included in the results. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link PagedIterable} containing all of the {@link DeletedCertificate deleted certificates} in the - * vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listDeletedCertificates(boolean includePending, Context context) { - return new PagedIterable<>( - maxResults -> mapDeletedCertificateItemPage( - implClient.getDeletedCertificatesSinglePage(vaultUrl, maxResults, includePending, context)), - (continuationToken, maxResults) -> mapDeletedCertificateItemPage( - implClient.getDeletedCertificatesNextSinglePage(continuationToken, vaultUrl, context))); - } - - /** - * List all versions of the specified certificate. The individual certificate response in the iterable is - * represented by {@link CertificateProperties} as only the certificate identifier, thumbprint, attributes and tags - * are provided in the response. The policy is not listed in the response. This operation requires the - * certificates/list permission. - * - *

It is possible to get the certificates with properties excluding the policy for all the versions from this - * information. Loop over the {@link CertificateProperties} and call - * {@link CertificateClient#getCertificateVersion(String, String)}. This will return the - * {@link KeyVaultCertificate certificate} with all its properties excluding the policy.

- * - * - *
-     * for (CertificateProperties certificateProperties : certificateClient
-     *     .listPropertiesOfCertificateVersions("certificateName")) {
-     *     KeyVaultCertificate certificateWithAllProperties = certificateClient
-     *         .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion());
-     *     System.out.printf("Received certificate's version with name %s, version %s and secret id %s%n",
-     *         certificateWithAllProperties.getProperties().getName(),
-     *         certificateWithAllProperties.getProperties().getVersion(), certificateWithAllProperties.getSecretId());
-     * }
-     * 
- * - * - * @param certificateName The name of the certificate. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException when a certificate with {@code certificateName} is empty string. - * @return A {@link PagedIterable} containing {@link CertificateProperties certificate} of all the versions of the - * specified certificate in the vault. Paged Iterable is empty if certificate with {@code certificateName} does not - * exist in key vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listPropertiesOfCertificateVersions(String certificateName) { - return listPropertiesOfCertificateVersions(certificateName, Context.NONE); - } - - /** - * List all versions of the specified certificate. The individual certificate response in the iterable is - * represented by {@link CertificateProperties} as only the certificate identifier, thumbprint, attributes and tags - * are provided in the response. The policy is not listed in the response. This operation requires the - * certificates/list permission. - * - *

It is possible to get the certificates with properties excluding the policy for all the versions from this - * information. Loop over the {@link CertificateProperties} and call - * {@link CertificateClient#getCertificateVersion(String, String)}. This will return the - * {@link KeyVaultCertificate certificate} with all its properties excluding the policy.

- * - * - *
-     * for (CertificateProperties certificateProperties : certificateClient
-     *     .listPropertiesOfCertificateVersions("certificateName")) {
-     *     KeyVaultCertificate certificateWithAllProperties = certificateClient
-     *         .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion());
-     *     System.out.printf("Received certificate's version with name %s, version %s and secret id %s%n",
-     *         certificateWithAllProperties.getProperties().getName(),
-     *         certificateWithAllProperties.getProperties().getVersion(), certificateWithAllProperties.getSecretId());
-     * }
-     * 
- * - * - * @param certificateName The name of the certificate. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException when a certificate with {@code certificateName} is empty string. - * @return A {@link PagedIterable} containing {@link CertificateProperties certificate} of all the versions of the - * specified certificate in the vault. Iterable is empty if certificate with {@code certificateName} does not exist - * in key vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listPropertiesOfCertificateVersions(String certificateName, - Context context) { - return new PagedIterable<>( - maxResults -> mapCertificateItemPage( - implClient.getCertificateVersionsSinglePage(vaultUrl, certificateName, maxResults, context)), - (continuationToken, maxResults) -> mapCertificateItemPage( - implClient.getCertificateVersionsNextSinglePage(continuationToken, vaultUrl, context))); - } - - /** - * Retrieves the policy of the specified certificate in the key vault. This operation requires the certificates/get - * permission. - * - *

Code Samples

- *

Gets the policy of a certificate in the key vault. Prints out the returned certificate policy details when a - * response has been received.

- * - * - *
-     * CertificatePolicy policy = certificateClient.getCertificatePolicy("certificateName");
-     * System.out.printf("Received policy with subject name %s%n", policy.getSubject());
-     * 
- * - * - * @param certificateName The name of the certificate whose policy is to be retrieved, cannot be null - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException if {@code certificateName} is empty string. - * @return The requested {@link CertificatePolicy certificate policy}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificatePolicy getCertificatePolicy(String certificateName) { - return getCertificatePolicyWithResponse(certificateName, Context.NONE).getValue(); - } - - /** - * Retrieves the policy of the specified certificate in the key vault. This operation requires the certificates/get - * permission. - * - *

Code Samples

- *

Gets the policy of a certificate in the key vault. Prints out the returned certificate policy details when a - * response has been received.

- * - * - *
-     * Response<CertificatePolicy> returnedPolicyWithResponse = certificateClient.getCertificatePolicyWithResponse(
-     *     "certificateName", new Context(key1, value1));
-     * System.out.printf("Received policy with subject name %s%n",
-     *     returnedPolicyWithResponse.getValue().getSubject());
-     * 
- * - * - * @param certificateName The name of the certificate whose policy is to be retrieved, cannot be null - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException if {@code certificateName} is empty string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the requested - * {@link CertificatePolicy certificate policy}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getCertificatePolicyWithResponse(String certificateName, Context context) { - return callWithMappedResponseAndException( - () -> implClient.getCertificatePolicyWithResponse(vaultUrl, certificateName, context), - CertificatePolicyHelper::createCertificatePolicy, CertificateAsyncClient::mapGetCertificatePolicyException); - } - - /** - * Updates the policy for a certificate. The update operation changes specified attributes of the certificate policy - * and attributes that are not specified in the request are left unchanged. This operation requires the - * certificates/update permission. - * - *

Code Samples

- *

Gets the certificate policy, changes its properties and then updates it in the Azure Key Vault. Prints out the - * returned policy details when a response has been received.

- * - * - *
-     * CertificatePolicy certificatePolicy = certificateClient.getCertificatePolicy("certificateName");
-     * //Update the certificate policy cert transparency property.
-     * certificatePolicy.setCertificateTransparent(true);
-     * CertificatePolicy updatedCertPolicy = certificateClient.updateCertificatePolicy("certificateName",
-     *     certificatePolicy);
-     * System.out.printf("Updated Certificate Policy transparency status %s%n",
-     *     updatedCertPolicy.isCertificateTransparent());
-     * 
- * - * - * @param certificateName The name of the certificate whose policy is to be updated. - * @param policy The certificate policy to be updated. - * @throws NullPointerException if {@code policy} is null. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException if {@code certificateName} is empty string or if {@code policy} is invalid. - * @return The updated {@link CertificatePolicy certificate policy}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificatePolicy updateCertificatePolicy(String certificateName, CertificatePolicy policy) { - return updateCertificatePolicyWithResponse(certificateName, policy, Context.NONE).getValue(); - } - - /** - * Updates the policy for a certificate. The update operation changes specified attributes of the certificate policy - * and attributes that are not specified in the request are left unchanged. This operation requires the - * certificates/update permission. - * - *

Code Samples

- *

Gets the certificate policy, changes its properties and then updates it in the Azure Key Vault. Prints out the - * returned policy details when a response has been received.

- * - * - *
-     * CertificatePolicy certificatePolicyToUpdate = certificateClient.getCertificatePolicy("certificateName");
-     * //Update the certificate policy cert transparency property.
-     * certificatePolicyToUpdate.setCertificateTransparent(true);
-     * Response<CertificatePolicy> updatedCertPolicyWithResponse = certificateClient
-     *     .updateCertificatePolicyWithResponse("certificateName", certificatePolicyToUpdate,
-     *         new Context(key1, value1));
-     * System.out.printf("Updated Certificate Policy transparency status %s%n", updatedCertPolicyWithResponse
-     *     .getValue().isCertificateTransparent());
-     * 
- * - * - * @param certificateName The certificateName of the certificate whose policy is to be updated. - * @param policy The certificate policy to be updated. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws NullPointerException if {@code policy} is null. - * @throws ResourceNotFoundException when a certificate with {@code certificateName} doesn't exist in the key vault. - * @throws HttpRequestException if {@code certificateName} is empty string or if {@code policy} is invalid. - * @return A {@link Response} whose {@link Response#getValue() value} contains the updated - * {@link CertificatePolicy certificate policy}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateCertificatePolicyWithResponse(String certificateName, - CertificatePolicy policy, Context context) { - if (policy == null) { - throw LOGGER.logExceptionAsError(new NullPointerException("'policy' cannot be null.")); - } - - return callWithMappedResponseAndException( - () -> implClient.updateCertificatePolicyWithResponse(vaultUrl, certificateName, - getImplCertificatePolicy(policy), context), - CertificatePolicyHelper::createCertificatePolicy, - CertificateAsyncClient::mapUpdateCertificatePolicyException); - } - - /** - * Creates the specified certificate issuer. The SetCertificateIssuer operation updates the specified certificate - * issuer if it already exists or adds it if it doesn't exist. This operation requires the - * certificates/setissuers permission. - * - *

Code Samples

- *

Creates a new certificate issuer in the key vault. Prints out the created certificate issuer details when a - * response has been received.

- * - * - *
-     * CertificateIssuer issuerToCreate = new CertificateIssuer("myissuer", "myProvider")
-     *     .setAccountId("testAccount")
-     *     .setAdministratorContacts(Collections.singletonList(new AdministratorContact().setFirstName("test")
-     *         .setLastName("name").setEmail("test@example.com")));
-     * CertificateIssuer returnedIssuer = certificateClient.createIssuer(issuerToCreate);
-     * System.out.printf("Created Issuer with name %s provider %s%n", returnedIssuer.getName(),
-     *     returnedIssuer.getProvider());
-     * 
- * - * - * @param issuer The configuration of the certificate issuer to be created. - * @throws NullPointerException if {@code issuer} is null. - * @throws ResourceModifiedException when invalid certificate issuer {@code issuer} configuration is provided. - * @throws HttpRequestException when a certificate issuer with {@link CertificateIssuer#getName() name} is empty - * string. - * @return The created {@link CertificateIssuer certificate issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateIssuer createIssuer(CertificateIssuer issuer) { - return createIssuerWithResponse(issuer, Context.NONE).getValue(); - } - - /** - * Creates the specified certificate issuer. The SetCertificateIssuer operation updates the specified certificate - * issuer if it already exists or adds it if it doesn't exist. This operation requires the - * certificates/setissuers permission. - * - *

Code Samples

- *

Creates a new certificate issuer in the key vault. Prints out the created certificate issuer details when a - * response has been received.

- * - * - *
-     * CertificateIssuer issuer = new CertificateIssuer("issuerName", "myProvider")
-     *     .setAccountId("testAccount")
-     *     .setAdministratorContacts(Collections.singletonList(new AdministratorContact().setFirstName("test")
-     *         .setLastName("name").setEmail("test@example.com")));
-     * Response<CertificateIssuer> issuerResponse = certificateClient.createIssuerWithResponse(issuer,
-     *     new Context(key1, value1));
-     * System.out.printf("Created Issuer with name %s provider %s%n", issuerResponse.getValue().getName(),
-     *     issuerResponse.getValue().getProvider());
-     * 
- * - * - * @param issuer The configuration of the certificate issuer to be created. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws NullPointerException if {@code issuer} is null. - * @throws ResourceModifiedException when invalid certificate issuer {@code issuer} configuration is provided. - * @throws HttpRequestException when a certificate issuer with {@link CertificateIssuer#getName() name} is empty - * string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the created - * {@link CertificateIssuer certificate issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createIssuerWithResponse(CertificateIssuer issuer, Context context) { - if (issuer == null) { - throw LOGGER.logExceptionAsError(new NullPointerException("'issuer' cannot be null.")); - } - - IssuerBundle issuerBundle = getIssuerBundle(issuer); - return callWithMappedResponseAndException(() -> implClient.setCertificateIssuerWithResponse(vaultUrl, - issuer.getName(), issuer.getProvider(), issuerBundle.getCredentials(), - issuerBundle.getOrganizationDetails(), issuerBundle.getAttributes(), context), - CertificateIssuerHelper::createCertificateIssuer, ex -> ex); - } - - /** - * Retrieves the specified certificate issuer from the key vault. This operation requires the - * certificates/manageissuers/getissuers permission. - * - *

Code Samples

- *

Gets the specified certificate issuer in the key vault. Prints out the returned certificate issuer details - * when a response has been received.

- * - * - *
-     * Response<CertificateIssuer> issuerResponse = certificateClient.getIssuerWithResponse("issuerName",
-     *     new Context(key1, value1));
-     * System.out.printf("Retrieved issuer with name %s and provider %s%n", issuerResponse.getValue().getName(),
-     *     issuerResponse.getValue().getProvider());
-     * 
- * - * - * @param issuerName The name of the certificate issuer to retrieve, cannot be null - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key - * vault. - * @throws HttpRequestException if {@code issuerName} is empty string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the requested - * {@link CertificateIssuer certificate issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getIssuerWithResponse(String issuerName, Context context) { - return callWithMappedResponseAndException( - () -> implClient.getCertificateIssuerWithResponse(vaultUrl, issuerName, context), - CertificateIssuerHelper::createCertificateIssuer, ex -> ex); - } - - /** - * Retrieves the specified certificate issuer from the key vault. This operation requires the - * certificates/manageissuers/getissuers permission. - * - *

Code Samples

- *

Gets the specified certificate issuer in the key vault. Prints out the returned certificate issuer details - * when a response has been received.

- * - * - *
-     * CertificateIssuer returnedIssuer = certificateClient.getIssuer("issuerName");
-     * System.out.printf("Retrieved issuer with name %s and provider %s%n", returnedIssuer.getName(),
-     *     returnedIssuer.getProvider());
-     * 
- * - * - * @param issuerName The name of the certificate issuer to retrieve, cannot be null - * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key - * vault. - * @throws HttpRequestException if {@code issuerName} is empty string. - * @return The requested {@link CertificateIssuer certificate issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateIssuer getIssuer(String issuerName) { - return getIssuerWithResponse(issuerName, Context.NONE).getValue(); - } - - /** - * Deletes the specified certificate issuer. The DeleteCertificateIssuer operation permanently removes the specified - * certificate issuer from the key vault. This operation requires the certificates/manageissuers/deleteissuers - * permission. - * - *

Code Samples

- *

Deletes the certificate issuer in the Azure Key Vault. Prints out the - * deleted certificate details when a response has been received.

- * - * - *
-     * CertificateIssuer deletedIssuer = certificateClient.deleteIssuer("issuerName");
-     * System.out.printf("Deleted certificate issuer with name %s and provider id %s%n", deletedIssuer.getName(),
-     *     deletedIssuer.getProvider());
-     * 
- * - * - * @param issuerName The name of the certificate issuer to be deleted. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key - * vault. - * @throws HttpRequestException when a certificate issuer with {@code issuerName} is empty string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the - * {@link CertificateIssuer deleted issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteIssuerWithResponse(String issuerName, Context context) { - return callWithMappedResponseAndException( - () -> implClient.deleteCertificateIssuerWithResponse(vaultUrl, issuerName, context), - CertificateIssuerHelper::createCertificateIssuer, - CertificateAsyncClient::mapDeleteCertificateIssuerException); - } - - /** - * Deletes the specified certificate issuer. The DeleteCertificateIssuer operation permanently removes the specified - * certificate issuer from the key vault. This operation requires the certificates/manageissuers/deleteissuers - * permission. - * - *

Code Samples

- *

Deletes the certificate issuer in the Azure Key Vault. Prints out the deleted certificate details when a - * response has been received.

- * - * - *
-     * Response<CertificateIssuer> deletedIssuerWithResponse = certificateClient.
-     *     deleteIssuerWithResponse("issuerName", new Context(key1, value1));
-     * System.out.printf("Deleted certificate issuer with name %s and provider id %s%n",
-     *     deletedIssuerWithResponse.getValue().getName(),
-     *     deletedIssuerWithResponse.getValue().getProvider());
-     * 
- * - * - * @param issuerName The name of the certificate issuer to be deleted. - * @throws ResourceNotFoundException when a certificate issuer with {@code issuerName} doesn't exist in the key - * vault. - * @throws HttpRequestException when a certificate issuer with {@code issuerName} is empty string. - * @return The {@link CertificateIssuer deleted issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateIssuer deleteIssuer(String issuerName) { - return deleteIssuerWithResponse(issuerName, Context.NONE).getValue(); - } - - /** - * List all the certificate issuers resources in the key vault. The individual certificate issuer response in the - * iterable is represented by {@link IssuerProperties} as only the certificate issuer identifier and provider are - * provided in the response. This operation requires the certificates/manageissuers/getissuers permission. - * - *

It is possible to get the certificate issuer with all of its properties from this information. Loop over the - * {@link IssuerProperties issuerProperties} and call {@link CertificateClient#getIssuer(String)}. This will return - * the {@link CertificateIssuer issuer} with all its properties.

. - * - * - *
-     * for (IssuerProperties issuer : certificateClient.listPropertiesOfIssuers()) {
-     *     CertificateIssuer retrievedIssuer = certificateClient.getIssuer(issuer.getName());
-     *     System.out.printf("Received issuer with name %s and provider %s%n", retrievedIssuer.getName(),
-     *         retrievedIssuer.getProvider());
-     * }
-     * 
- * - * - * @return A {@link PagedIterable} containing all of the {@link IssuerProperties certificate issuers} in the vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listPropertiesOfIssuers() { - return listPropertiesOfIssuers(Context.NONE); - } - - /** - * List all the certificate issuers resources in the key vault. The individual certificate issuer response in the - * iterable is represented by {@link IssuerProperties} as only the certificate issuer identifier and provider are - * provided in the response. This operation requires the certificates/manageissuers/getissuers permission. - * - *

It is possible to get the certificate issuer with all of its properties from this information. Loop over the - * {@link IssuerProperties issuerProperties} and call {@link CertificateClient#getIssuer(String)}. This will return - * the {@link CertificateIssuer issuer} with all its properties.

. - * - * - *
-     * for (IssuerProperties issuer : certificateClient.listPropertiesOfIssuers(new Context(key1, value1))) {
-     *     CertificateIssuer retrievedIssuer = certificateClient.getIssuer(issuer.getName());
-     *     System.out.printf("Received issuer with name %s and provider %s%n", retrievedIssuer.getName(),
-     *         retrievedIssuer.getProvider());
-     * }
-     * 
- * - * - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link PagedIterable} containing all of the {@link IssuerProperties certificate issuers} in the vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listPropertiesOfIssuers(Context context) { - return new PagedIterable<>( - maxResults -> mapIssuersPagedResponse( - implClient.getCertificateIssuersSinglePage(vaultUrl, maxResults, context)), - (continuationToken, maxResults) -> mapIssuersPagedResponse( - implClient.getCertificateIssuersNextSinglePage(continuationToken, vaultUrl, context))); - } - - /** - * Updates the specified certificate issuer. The UpdateCertificateIssuer operation updates the specified attributes - * of the certificate issuer entity. This operation requires the certificates/setissuers permission. - * - *

Code Samples

- *

Gets the certificate issuer, changes its attributes/properties then updates it in the Azure Key Vault. Prints - * out the returned certificate issuer details when a response has been received.

- * - * - *
-     * CertificateIssuer returnedIssuer = certificateClient.getIssuer("issuerName");
-     * returnedIssuer.setAccountId("newAccountId");
-     * CertificateIssuer updatedIssuer = certificateClient.updateIssuer(returnedIssuer);
-     * System.out.printf("Updated issuer with name %s, provider %s and account Id %s%n", updatedIssuer.getName(),
-     *     updatedIssuer.getProvider(), updatedIssuer.getAccountId());
-     * 
- * - * - * @param issuer The {@link CertificateIssuer issuer} with updated properties. - * @throws NullPointerException if {@code issuer} is null. - * @throws ResourceNotFoundException when a certificate issuer with {@link CertificateIssuer#getName() name} doesn't - * exist in the key vault. - * @throws HttpRequestException if {@link CertificateIssuer#getName() name} is empty string. - * @return The {@link CertificateIssuer updated issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateIssuer updateIssuer(CertificateIssuer issuer) { - return updateIssuerWithResponse(issuer, Context.NONE).getValue(); - } - - /** - * Updates the specified certificate issuer. The UpdateCertificateIssuer operation updates the specified attributes - * of the certificate issuer entity. This operation requires the certificates/setissuers permission. - * - *

Code Samples

- *

Gets the certificate issuer, changes its attributes/properties then updates it in the Azure Key Vault. Prints - * out the returned certificate issuer details when a response has been received.

- * - * - *
-     * CertificateIssuer issuer = certificateClient.getIssuer("issuerName");
-     * returnedIssuer.setAccountId("newAccountId");
-     * Response<CertificateIssuer> updatedIssuerWithResponse = certificateClient.updateIssuerWithResponse(issuer,
-     *     new Context(key1, value1));
-     * System.out.printf("Updated issuer with name %s, provider %s and account Id %s%n",
-     *     updatedIssuerWithResponse.getValue().getName(),
-     *     updatedIssuerWithResponse.getValue().getProvider(),
-     *     updatedIssuerWithResponse.getValue().getAccountId());
-     * 
- * - * - * @param issuer The {@link CertificateIssuer issuer} with updated properties. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws NullPointerException if {@code issuer} is null. - * @throws ResourceNotFoundException when a certificate issuer with {@link CertificateIssuer#getName() name} doesn't - * exist in the key vault. - * @throws HttpRequestException if {@link CertificateIssuer#getName() name} is empty string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the - * {@link CertificateIssuer updated issuer}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateIssuerWithResponse(CertificateIssuer issuer, Context context) { - if (issuer == null) { - throw LOGGER.logExceptionAsError(new NullPointerException("'issuer' cannot be null.")); - } - - IssuerBundle issuerBundle = CertificateIssuerHelper.getIssuerBundle(issuer); - return callWithMappedResponseAndException(() -> implClient.updateCertificateIssuerWithResponse(vaultUrl, - issuer.getName(), issuer.getProvider(), issuerBundle.getCredentials(), - issuerBundle.getOrganizationDetails(), issuerBundle.getAttributes(), context), - CertificateIssuerHelper::createCertificateIssuer, ex -> ex); - } - - /** - * Sets the certificate contacts on the key vault. This operation requires the certificates/managecontacts - * permission. - * - *

The {@link LifetimeAction} of type {@link CertificatePolicyAction#EMAIL_CONTACTS} set on a - * {@link CertificatePolicy} emails the contacts set on the vault when triggered.

- * - *

Code Samples

- *

Sets the certificate contacts in the Azure Key Vault. Prints out the returned contacts details.

- * - * - *
-     * CertificateContact contactToAdd = new CertificateContact().setName("user").setEmail("useremail@example.com");
-     * for (CertificateContact contact : certificateClient.setContacts(Collections.singletonList(contactToAdd))) {
-     *     System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(),
-     *         contact.getEmail());
-     * }
-     * 
- * - * - * @param contacts The list of contacts to set on the vault. - * @throws HttpRequestException when a contact information provided is invalid/incomplete. - * @return A {@link PagedIterable} containing all of the {@link CertificateContact certificate contacts} in the - * vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable setContacts(List contacts) { - return setContacts(contacts, Context.NONE); - } - - /** - * Sets the certificate contacts on the key vault. This operation requires the certificates/managecontacts - * permission. - * - *

The {@link LifetimeAction} of type {@link CertificatePolicyAction#EMAIL_CONTACTS} set on a - * {@link CertificatePolicy} emails the contacts set on the vault when triggered.

- * - *

Code Samples

- *

Sets the certificate contacts in the Azure Key Vault. Prints out the returned contacts details.

- * - * - *
-     * CertificateContact sampleContact = new CertificateContact().setName("user").setEmail("useremail@example.com");
-     * for (CertificateContact contact : certificateClient.setContacts(Collections.singletonList(sampleContact),
-     *     new Context(key1, value1))) {
-     *     System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(),
-     *         contact.getEmail());
-     * }
-     * 
- * - * - * @param contacts The list of contacts to set on the vault. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws HttpRequestException when a contact information provided is invalid/incomplete. - * @return A {@link PagedIterable} containing all of the {@link CertificateContact certificate contacts} in the - * vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable setContacts(List contacts, Context context) { - return new PagedIterable<>(() -> mapContactsToPagedResponse( - implClient.setCertificateContactsWithResponse(vaultUrl, new Contacts().setContactList(contacts), context))); - } - - /** - * Lists the certificate contacts in the key vault. This operation requires the certificates/managecontacts - * permission. - * - *

Code Samples

- *

Lists the certificate contacts in the Azure Key Vault. Prints out the returned contacts details in the - * response.

- * - * - *
-     * for (CertificateContact contact : certificateClient.listContacts()) {
-     *     System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(),
-     *         contact.getEmail());
-     * }
-     * 
- * - * - * @return A {@link PagedIterable} containing all of the {@link CertificateContact certificate contacts} in the - * vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listContacts() { - return listContacts(Context.NONE); - } - - /** - * Lists the certificate contacts in the key vault. This operation requires the certificates/managecontacts - * permission. - * - *

Code Samples

- *

Lists the certificate contacts in the Azure Key Vault. Prints out the returned contacts details in the - * response.

- * - * - *
-     * for (CertificateContact contact : certificateClient.listContacts(new Context(key1, value1))) {
-     *     System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(),
-     *         contact.getEmail());
-     * }
-     * 
- * - * - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link PagedIterable} containing all of the {@link CertificateContact certificate contacts} in the - * vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listContacts(Context context) { - return new PagedIterable<>( - () -> mapContactsToPagedResponse(implClient.getCertificateContactsWithResponse(vaultUrl, context))); - } - - /** - * Deletes the certificate contacts in the key vault. This operation requires the certificates/managecontacts - * permission. - * - *

Code Samples

- *

Deletes the certificate contacts in the Azure Key Vault. Subscribes to the call and prints out the deleted - * contacts details.

- * - * - *
-     * for (CertificateContact contact : certificateClient.deleteContacts()) {
-     *     System.out.printf("Deleted contact with name %s and email %s from key vault%n", contact.getName(),
-     *         contact.getEmail());
-     * }
-     * 
- * - * - * @return A {@link PagedIterable} containing the deleted {@link CertificateContact certificate contacts} in the - * vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable deleteContacts() { - return deleteContacts(Context.NONE); - } - - /** - * Deletes the certificate contacts in the key vault. This operation requires the certificates/managecontacts - * permission. - * - *

Code Samples

- *

Deletes the certificate contacts in the Azure Key Vault. Prints out the deleted contacts details in the - * response.

- * - * - *
-     * for (CertificateContact contact : certificateClient.deleteContacts(new Context(key1, value1))) {
-     *     System.out.printf("Deleted contact with name %s and email %s from key vault%n", contact.getName(),
-     *         contact.getEmail());
-     * }
-     * 
- * - * - * @param context Additional context that is passed through the Http pipeline during the service call. - * @return A {@link PagedIterable} containing the deleted {@link CertificateContact certificate contacts} in the - * vault. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable deleteContacts(Context context) { - return new PagedIterable<>( - () -> mapContactsToPagedResponse(implClient.deleteCertificateContactsWithResponse(vaultUrl, context))); - } - - /** - * Deletes the creation operation for the specified certificate that is in the process of being created. The - * certificate is no longer created. This operation requires the certificates/update permission. - * - *

Code Samples

- *

Triggers certificate creation and then deletes the certificate creation operation in the Azure Key Vault. - * Subscribes to the call and prints out the deleted certificate operation details when a response has been - * received.

- * - * - *
-     * Response<CertificateOperation> deletedCertificateOperationWithResponse = certificateClient
-     *     .deleteCertificateOperationWithResponse("certificateName", new Context(key1, value1));
-     * System.out.printf("Deleted Certificate Operation's last status %s%n",
-     *     deletedCertificateOperationWithResponse.getValue().getStatus());
-     * 
- * - * - * @param certificateName The name of the certificate. - * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code certificateName} - * doesn't exist in the key vault. - * @throws HttpRequestException when the {@code certificateName} is empty string. - * @return The deleted {@link CertificateOperation certificate operation}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateOperation deleteCertificateOperation(String certificateName) { - return deleteCertificateOperationWithResponse(certificateName, Context.NONE).getValue(); - } - - /** - * Deletes the creation operation for the specified certificate that is in the process of being created. The - * certificate is no longer created. This operation requires the certificates/update permission. - * - *

Code Samples

- *

Triggers certificate creation and then deletes the certificate creation operation in the Azure Key Vault. - * Subscribes to the call and prints out the deleted certificate operation details when a response has been - * received.

- * - * - *
-     * CertificateOperation deletedCertificateOperation = certificateClient
-     *     .deleteCertificateOperation("certificateName");
-     * System.out.printf("Deleted Certificate Operation's last status %s%n", deletedCertificateOperation.getStatus());
-     * 
- * - * - * @param certificateName The name of the certificate. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code certificateName} - * doesn't exist in the key vault. - * @throws HttpRequestException when the {@code certificateName} is empty string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the - * {@link CertificateOperation deleted certificate operation}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteCertificateOperationWithResponse(String certificateName, - Context context) { - return callWithMappedResponseAndException( - () -> implClient.deleteCertificateOperationWithResponse(vaultUrl, certificateName, context), - CertificateOperationHelper::createCertificateOperation, - CertificateAsyncClient::mapDeleteCertificateOperationException); - } - - /** - * Cancels a certificate creation operation that is already in progress. This operation requires the - * certificates/update permission. - * - *

Code Samples

- *

Triggers certificate creation and then cancels the certificate creation operation in the Azure Key Vault. - * Subscribes to the call and prints out the updated certificate operation details when a response has been - * received.

- * - * - *
-     * CertificateOperation certificateOperation = certificateClient
-     *     .cancelCertificateOperation("certificateName");
-     * System.out.printf("Certificate Operation status %s%n", certificateOperation.getStatus());
-     * 
- * - * - * @param certificateName The name of the certificate which is in the process of being created. - * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code name} doesn't exist - * in the key vault. - * @throws HttpRequestException when the {@code name} is empty string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the - * {@link CertificateOperation cancelled certificate operation}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateOperation cancelCertificateOperation(String certificateName) { - return cancelCertificateOperationWithResponse(certificateName, Context.NONE).getValue(); - } - - /** - * Cancels a certificate creation operation that is already in progress. This operation requires the - * certificates/update permission. - * - *

Code Samples

- *

Triggers certificate creation and then cancels the certificate creation operation in the Azure Key Vault. - * Subscribes to the call and prints out the updated certificate operation details when a response has been - * received.

- * - * - *
-     * Response<CertificateOperation> certificateOperationWithResponse = certificateClient
-     *     .cancelCertificateOperationWithResponse("certificateName", new Context(key1, value1));
-     * System.out.printf("Certificate Operation status %s%n", certificateOperationWithResponse.getValue().getStatus());
-     * 
- * - * - * @param certificateName The name of the certificate which is in the process of being created. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws ResourceNotFoundException when a certificate operation for a certificate with {@code name} doesn't exist - * in the key vault. - * @throws HttpRequestException when the {@code name} is empty string. - * @return A {@link Response} whose {@link Response#getValue() value} contains the - * {@link CertificateOperation cancelled certificate operation}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response cancelCertificateOperationWithResponse(String certificateName, - Context context) { - return callWithMappedResponseAndException( - () -> implClient.updateCertificateOperationWithResponse(vaultUrl, certificateName, true, context), - CertificateOperationHelper::createCertificateOperation, - CertificateAsyncClient::mapUpdateCertificateOperationException); - } - - /** - * Merges a certificate or a certificate chain with a key pair currently available in the service. This operation - * requires the certificates/create permission. - * - *

Code Samples

- *

Merges a certificate with a kay pair available in the service.

- * - * - *
-     * List<byte[]> x509CertificatesToMerge = new ArrayList<>();
-     * MergeCertificateOptions config =
-     *     new MergeCertificateOptions("certificateName", x509CertificatesToMerge)
-     *         .setEnabled(false);
-     * KeyVaultCertificate mergedCertificate = certificateClient.mergeCertificate(config);
-     * System.out.printf("Received Certificate with name %s and key id %s%n",
-     *     mergedCertificate.getProperties().getName(), mergedCertificate.getKeyId());
-     * 
- * - * - * @param mergeCertificateOptions the merge certificate configuration holding the x509 certificates. - * @throws NullPointerException when {@code mergeCertificateOptions} is null. - * @throws HttpRequestException if {@code mergeCertificateOptions} is invalid/corrupt. - * @return The merged certificate. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultCertificateWithPolicy mergeCertificate(MergeCertificateOptions mergeCertificateOptions) { - return mergeCertificateWithResponse(mergeCertificateOptions, Context.NONE).getValue(); - } - - /** - * Merges a certificate or a certificate chain with a key pair currently available in the service. This operation - * requires the certificates/create permission. - * - *

Code Samples

- *

Merges a certificate with a kay pair available in the service.

- * - * - *
-     * List<byte[]> x509CertsToMerge = new ArrayList<>();
-     * MergeCertificateOptions mergeConfig =
-     *     new MergeCertificateOptions("certificateName", x509CertsToMerge)
-     *         .setEnabled(false);
-     * Response<KeyVaultCertificateWithPolicy> mergedCertificateWithResponse =
-     *     certificateClient.mergeCertificateWithResponse(mergeConfig, new Context(key2, value2));
-     * System.out.printf("Received Certificate with name %s and key id %s%n",
-     *     mergedCertificateWithResponse.getValue().getProperties().getName(),
-     *     mergedCertificateWithResponse.getValue().getKeyId());
-     * 
- * - * - * @param mergeCertificateOptions the merge certificate configuration holding the x509 certificates. - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws NullPointerException when {@code mergeCertificateOptions} is null. - * @throws HttpRequestException if {@code mergeCertificateOptions} is invalid/corrupt. - * @return A {@link Response} whose {@link Response#getValue() value} contains the merged certificate. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response - mergeCertificateWithResponse(MergeCertificateOptions mergeCertificateOptions, Context context) { - if (mergeCertificateOptions == null) { - throw LOGGER.logExceptionAsError(new NullPointerException("'mergeCertificateOptions' cannot be null.")); - } - - return callWithMappedResponseAndException( - () -> implClient.mergeCertificateWithResponse(vaultUrl, mergeCertificateOptions.getName(), - mergeCertificateOptions.getX509Certificates(), - new CertificateAttributes().setEnabled(mergeCertificateOptions.isEnabled()), - mergeCertificateOptions.getTags(), context), - KeyVaultCertificateWithPolicyHelper::createCertificateWithPolicy, ex -> ex); - } - - /** - * Imports a pre-existing certificate to the key vault. The specified certificate must be in PFX or PEM format, - * and must contain the private key as well as the x509 certificates. This operation requires the - * certificates/import permission. - * - *

Code Samples

- *

Imports a certificate into the key vault.

- * - * - *
-     * byte[] certificateToImport = new byte[100];
-     * ImportCertificateOptions config =
-     *     new ImportCertificateOptions("certificateName", certificateToImport).setEnabled(false);
-     * KeyVaultCertificate importedCertificate = certificateClient.importCertificate(config);
-     * System.out.printf("Received Certificate with name %s and key id %s%n",
-     *     importedCertificate.getProperties().getName(), importedCertificate.getKeyId());
-     * 
- * - * - * @param importCertificateOptions The details of the certificate to import to the key vault - * @throws HttpRequestException when the {@code importCertificateOptions} are invalid. - * @throws NullPointerException when {@code importCertificateOptions} is null. - * @return the {@link KeyVaultCertificateWithPolicy imported certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public KeyVaultCertificateWithPolicy importCertificate(ImportCertificateOptions importCertificateOptions) { - return importCertificateWithResponse(importCertificateOptions, Context.NONE).getValue(); - } - - /** - * Imports a pre-existing certificate to the key vault. The specified certificate must be in PFX or PEM format, - * and must contain the private key as well as the x509 certificates. This operation requires the - * certificates/import permission. - * - *

Code Samples

- *

Imports a certificate into the key vault.

- * - * - *
-     * byte[] certToImport = new byte[100];
-     * ImportCertificateOptions importCertificateOptions =
-     *     new ImportCertificateOptions("certificateName", certToImport).setEnabled(false);
-     * Response<KeyVaultCertificateWithPolicy> importedCertificateWithResponse =
-     *     certificateClient.importCertificateWithResponse(importCertificateOptions, new Context(key2, value2));
-     * System.out.printf("Received Certificate with name %s and key id %s%n",
-     *     importedCertificateWithResponse.getValue().getProperties().getName(),
-     *     importedCertificateWithResponse.getValue().getKeyId());
-     * 
- * - * - * @param importCertificateOptions The details of the certificate to import to the key vault - * @param context Additional context that is passed through the Http pipeline during the service call. - * @throws HttpRequestException when the {@code importCertificateOptions} are invalid. - * @throws NullPointerException when {@code importCertificateOptions} is null. - * @return A {@link Response} whose {@link Response#getValue() value} contains the - * {@link KeyVaultCertificateWithPolicy imported certificate}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response - importCertificateWithResponse(ImportCertificateOptions importCertificateOptions, Context context) { - if (importCertificateOptions == null) { - throw LOGGER.logExceptionAsError(new NullPointerException("'importCertificateOptions' cannot be null.")); - } - - com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy implPolicy - = getImplCertificatePolicy(importCertificateOptions.getPolicy()); - - return callWithMappedResponseAndException(() -> implClient.importCertificateWithResponse(vaultUrl, - importCertificateOptions.getName(), transformCertificateForImport(importCertificateOptions), - importCertificateOptions.getPassword(), implPolicy, implPolicy == null ? null : implPolicy.getAttributes(), - importCertificateOptions.getTags(), context), - KeyVaultCertificateWithPolicyHelper::createCertificateWithPolicy, ex -> ex); - } - - private static T callWithMappedException(Supplier apiCall, - Function exceptionMapper) { - try { - return apiCall.get(); - } catch (KeyVaultErrorException ex) { - throw exceptionMapper.apply(ex); - } - } - - private static Response callWithMappedResponseAndException(Supplier> apiCall, - Function responseValueMapper, Function exceptionMapper) { - try { - Response responseInn = apiCall.get(); - return new SimpleResponse<>(responseInn, responseValueMapper.apply(responseInn.getValue())); - } catch (KeyVaultErrorException ex) { - throw exceptionMapper.apply(ex); - } - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java deleted file mode 100644 index d84a98fed951..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java +++ /dev/null @@ -1,524 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -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.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.AddHeadersPolicy; -import com.azure.core.http.policy.HttpLogDetailLevel; -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.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.HttpClientOptions; -import com.azure.core.util.TracingOptions; -import com.azure.core.util.builder.ClientBuilderUtil; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.tracing.Tracer; -import com.azure.core.util.tracing.TracerProvider; -import com.azure.security.keyvault.certificates.implementation.CertificateClientImpl; -import com.azure.security.keyvault.certificates.implementation.KeyVaultCredentialPolicy; -import com.azure.security.keyvault.certificates.implementation.KeyVaultErrorCodeStrings; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificateIdentifier; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * This class provides a fluent builder API to help aid the configuration and instantiation of the {@link - * CertificateAsyncClient certificate async client} and {@link CertificateClient certificate sync client}, - * by calling {@link CertificateClientBuilder#buildAsyncClient() buildAsyncClient} and {@link - * CertificateClientBuilder#buildClient() buildClient} respectively - * It constructs an instance of the desired client. - * - *

The minimal configuration options required by {@link CertificateClientBuilder} to build {@link - * CertificateAsyncClient} - * are {@link String vaultUrl} and {@link TokenCredential credential}.

- * - * - *
- * CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
- *     .credential(new DefaultAzureCredentialBuilder().build())
- *     .vaultUrl("<your-key-vault-url>")
- *     .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
- *     .buildAsyncClient();
- * 
- * - * - *

The {@link HttpLogDetailLevel log detail level}, multiple custom {@link HttpLoggingPolicy policies} and custom - * {@link HttpClient http client} can be optionally configured in the {@link CertificateClientBuilder}.

- * - * - *
- * CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
- *     .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
- *     .vaultUrl("<your-key-vault-url>")
- *     .credential(new DefaultAzureCredentialBuilder().build())
- *     .httpClient(HttpClient.createDefault())
- *     .buildAsyncClient();
- * 
- * - * - *

Alternatively, custom {@link HttpPipeline http pipeline} with custom {@link HttpPipelinePolicy} policies and - * {@link String vaultUrl} - * can be specified. It provides finer control over the construction of {@link CertificateAsyncClient} and {@link - * CertificateClient}

- * - *

The minimal configuration options required by {@link CertificateClientBuilder certificateClientBuilder} to build - * {@link CertificateClient} - * are {@link String vaultUrl} and {@link TokenCredential credential}.

- * - * - *
- * CertificateClient certificateClient = new CertificateClientBuilder()
- *     .credential(new DefaultAzureCredentialBuilder().build())
- *     .vaultUrl("<your-key-vault-url>")
- *     .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
- *     .buildClient();
- * 
- * - * - * @see CertificateAsyncClient - * @see CertificateClient - */ -@ServiceClientBuilder(serviceClients = { CertificateClient.class, CertificateAsyncClient.class }) -public final class CertificateClientBuilder implements TokenCredentialTrait, - HttpTrait, ConfigurationTrait { - private static final ClientLogger LOGGER = new ClientLogger(CertificateClientBuilder.class); - - private static final String CLIENT_NAME; - private static final String CLIENT_VERSION; - - static { - // This is properties file's name. - Map properties = CoreUtils.getProperties("azure-key-vault-certificates.properties"); - CLIENT_NAME = properties.getOrDefault("name", "UnknownName"); - CLIENT_VERSION = properties.getOrDefault("version", "UnknownVersion"); - } - - // Please see here - // for more information on Azure resource provider namespaces. - private static final String KEYVAULT_TRACING_NAMESPACE_VALUE = "Microsoft.KeyVault"; - private static final ClientOptions DEFAULT_CLIENT_OPTIONS = new ClientOptions(); - private final List perCallPolicies; - private final List perRetryPolicies; - - private TokenCredential credential; - private HttpPipeline pipeline; - private String vaultUrl; - private HttpClient httpClient; - private HttpLogOptions httpLogOptions; - private RetryPolicy retryPolicy; - private RetryOptions retryOptions; - private Configuration configuration; - private CertificateServiceVersion version; - private ClientOptions clientOptions; - private boolean disableChallengeResourceVerification = false; - - /** - * The constructor with defaults. - */ - public CertificateClientBuilder() { - httpLogOptions = new HttpLogOptions(); - perCallPolicies = new ArrayList<>(); - perRetryPolicies = new ArrayList<>(); - } - - /** - * Creates a {@link CertificateClient} based on options set in the builder. - * Every time {@code buildClient()} is called, a new instance of {@link CertificateClient} is created. - * - *

If {@link CertificateClientBuilder#pipeline(HttpPipeline) pipeline} is set, then the {@code pipeline} and - * {@link CertificateClientBuilder#vaultUrl(String) serviceEndpoint} are used to create the - * {@link CertificateClientBuilder client}. All other builder settings are ignored. If {@code pipeline} is not set, - * then {@link CertificateClientBuilder#credential(TokenCredential) key vault credential} and - * {@link CertificateClientBuilder#vaultUrl(String) key vault url} are required to build the {@link - * CertificateClient client}.

- * - * @return A {@link CertificateClient} with the options set from the builder. - * - * @throws IllegalStateException If {@link CertificateClientBuilder#credential(TokenCredential)} or - * {@link CertificateClientBuilder#vaultUrl(String)} have not been set. - * @throws IllegalStateException If both {@link #retryOptions(RetryOptions)} - * and {@link #retryPolicy(RetryPolicy)} have been set. - */ - public CertificateClient buildClient() { - return new CertificateClient(buildInnerClient(), vaultUrl); - } - - /** - * Creates a {@link CertificateAsyncClient} based on options set in the builder. Every time - * {@code buildAsyncClient()} is called, a new instance of {@link CertificateAsyncClient} is created. - * - *

If {@link CertificateClientBuilder#pipeline(HttpPipeline) pipeline} is set, then the {@code pipeline} and - * {@link CertificateClientBuilder#vaultUrl(String) serviceEndpoint} are used to create the {@link - * CertificateClientBuilder client}. All other builder settings are ignored. If {@code pipeline} is not set, then - * {@link CertificateClientBuilder#credential(TokenCredential) key vault credential} and {@link - * CertificateClientBuilder#vaultUrl(String)} key vault url are required to build the {@link CertificateAsyncClient - * client}.

- * - * @return A {@link CertificateAsyncClient} with the options set from the builder. - * - * @throws IllegalStateException If {@link CertificateClientBuilder#credential(TokenCredential)} or {@link - * CertificateClientBuilder#vaultUrl(String)} have not been set. - * @throws IllegalStateException If both {@link #retryOptions(RetryOptions)} - * and {@link #retryPolicy(RetryPolicy)} have been set. - */ - public CertificateAsyncClient buildAsyncClient() { - return new CertificateAsyncClient(buildInnerClient(), vaultUrl); - } - - private CertificateClientImpl buildInnerClient() { - Configuration buildConfiguration - = (configuration != null) ? configuration : Configuration.getGlobalConfiguration().clone(); - - String buildEndpoint = getBuildEndpoint(buildConfiguration); - - if (buildEndpoint == null) { - throw LOGGER - .logExceptionAsError(new IllegalStateException(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED)); - } - - CertificateServiceVersion serviceVersion = version != null ? version : CertificateServiceVersion.getLatest(); - - if (pipeline != null) { - return new CertificateClientImpl(pipeline, serviceVersion.getVersion()); - } - - if (credential == null) { - throw LOGGER.logExceptionAsError(new IllegalStateException(KeyVaultErrorCodeStrings.CREDENTIALS_REQUIRED)); - } - - // Closest to API goes first, closest to wire goes last. - final List policies = new ArrayList<>(); - - httpLogOptions = (httpLogOptions == null) ? new HttpLogOptions() : httpLogOptions; - - ClientOptions localClientOptions = clientOptions != null ? clientOptions : DEFAULT_CLIENT_OPTIONS; - policies.add(new UserAgentPolicy(CoreUtils.getApplicationId(localClientOptions, httpLogOptions), CLIENT_NAME, - CLIENT_VERSION, buildConfiguration)); - - HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); - if (headers != null) { - policies.add(new AddHeadersPolicy(headers)); - } - - // Add per call additional policies. - policies.addAll(perCallPolicies); - HttpPolicyProviders.addBeforeRetryPolicies(policies); - - // Add retry policy. - policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions)); - - policies.add(new KeyVaultCredentialPolicy(credential, disableChallengeResourceVerification)); - - // Add per retry additional policies. - policies.addAll(perRetryPolicies); - - HttpPolicyProviders.addAfterRetryPolicies(policies); - policies.add(new HttpLoggingPolicy(httpLogOptions)); - - TracingOptions tracingOptions = localClientOptions.getTracingOptions(); - Tracer tracer = TracerProvider.getDefaultProvider() - .createTracer(CLIENT_NAME, CLIENT_VERSION, KEYVAULT_TRACING_NAMESPACE_VALUE, tracingOptions); - - HttpPipeline pipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) - .httpClient(httpClient) - .tracer(tracer) - .clientOptions(localClientOptions) - .build(); - - return new CertificateClientImpl(pipeline, serviceVersion.getVersion()); - } - - /** - * Sets the vault endpoint URL to send HTTP requests to. You should validate that this URL references a valid Key - * Vault resource. Refer to the following documentation for details. - * - * @param vaultUrl The vault endpoint url is used as destination on Azure to send requests to. If you have a - * certificate identifier, create a new {@link KeyVaultCertificateIdentifier} to parse it and obtain the - * {@code vaultUrl} and other information. - * - * @return The updated {@link CertificateClientBuilder} object. - * - * @throws IllegalArgumentException if {@code vaultUrl} is null or it cannot be parsed into a valid URL. - */ - public CertificateClientBuilder vaultUrl(String vaultUrl) { - if (vaultUrl == null) { - throw LOGGER.logExceptionAsError(new NullPointerException("'vaultUrl' cannot be null.")); - } - - try { - URL url = new URL(vaultUrl); - this.vaultUrl = url.toString(); - } catch (MalformedURLException e) { - throw LOGGER - .logExceptionAsError(new IllegalArgumentException("The Azure Key Vault endpoint url is malformed.", e)); - } - - return this; - } - - /** - * Sets the {@link TokenCredential} used to authorize requests sent to the service. Refer to the Azure SDK for Java - * identity and authentication - * documentation for more details on proper usage of the {@link TokenCredential} type. - * - * @param credential {@link TokenCredential} used to authorize requests sent to the service. - * - * @return The updated {@link CertificateClientBuilder} object. - * - * @throws NullPointerException If {@code credential} is {@code null}. - * - */ - @Override - public CertificateClientBuilder credential(TokenCredential credential) { - if (credential == null) { - throw LOGGER.logExceptionAsError(new NullPointerException("'credential' cannot be null.")); - } - - this.credential = credential; - - return this; - } - - /** - * Sets the {@link HttpLogOptions logging configuration} to use when sending and receiving requests to and from - * the service. If a {@code logLevel} is not provided, default value of {@link HttpLogDetailLevel#NONE} is set. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param logOptions The {@link HttpLogOptions logging configuration} to use when sending and receiving requests to - * and from the service. - * @return The updated {@link CertificateClientBuilder} object. - */ - @Override - public CertificateClientBuilder httpLogOptions(HttpLogOptions logOptions) { - httpLogOptions = logOptions; - - return this; - } - - /** - * Adds a {@link HttpPipelinePolicy pipeline policy} to apply on each request sent. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param policy A {@link HttpPipelinePolicy pipeline policy}. - * @return The updated {@link CertificateClientBuilder} object. - * - * @throws NullPointerException If {@code policy} is {@code null}. - */ - @Override - public CertificateClientBuilder addPolicy(HttpPipelinePolicy policy) { - if (policy == null) { - throw LOGGER.logExceptionAsError(new NullPointerException("'policy' cannot be null.")); - } - - if (policy.getPipelinePosition() == HttpPipelinePosition.PER_CALL) { - perCallPolicies.add(policy); - } else { - perRetryPolicies.add(policy); - } - - return this; - } - - /** - * Sets the {@link HttpClient} to use for sending and receiving requests to and from the service. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param client The {@link HttpClient} to use for requests. - * @return The updated {@link CertificateClientBuilder} object. - */ - @Override - public CertificateClientBuilder httpClient(HttpClient client) { - this.httpClient = client; - - return this; - } - - /** - * Sets the {@link HttpPipeline} to use for the service client. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- *

- * The {@link #vaultUrl(String) vaultUrl} is not ignored when - * {@code pipeline} is set. - * - * @param pipeline {@link HttpPipeline} to use for sending service requests and receiving responses. - * @return The updated {@link CertificateClientBuilder} object. - */ - @Override - public CertificateClientBuilder pipeline(HttpPipeline pipeline) { - this.pipeline = pipeline; - - return this; - } - - /** - * Sets the configuration store that is used during construction of the service client. - *

- * The default configuration store is a clone of the {@link Configuration#getGlobalConfiguration() global - * configuration store}, use {@link Configuration#NONE} to bypass using configuration settings during construction. - * - * @param configuration The configuration store used to get configuration details. - * - * @return The updated {@link CertificateClientBuilder} object. - */ - @Override - public CertificateClientBuilder configuration(Configuration configuration) { - this.configuration = configuration; - - return this; - } - - /** - * Sets the {@link CertificateServiceVersion} that is used when making API requests. - *

- * If a service version is not provided, the service version that will be used will be the latest known service - * version based on the version of the client library being used. If no service version is specified, updating to a - * newer version the client library will have the result of potentially moving to a newer service version. - * - * @param version {@link CertificateServiceVersion} of the service to be used when making requests. - * - * @return The updated {@link CertificateClientBuilder} object. - */ - public CertificateClientBuilder serviceVersion(CertificateServiceVersion version) { - this.version = version; - - return this; - } - - /** - * Sets the {@link RetryPolicy} that is used when each request is sent. - *

- * The default retry policy will be used in the pipeline, if not provided. - *

- * Setting this is mutually exclusive with using {@link #retryOptions(RetryOptions)}. - * - * @param retryPolicy user's retry policy applied to each request. - * - * @return The updated {@link CertificateClientBuilder} object. - */ - public CertificateClientBuilder retryPolicy(RetryPolicy retryPolicy) { - this.retryPolicy = retryPolicy; - - return this; - } - - /** - * Sets the {@link RetryOptions} for all the requests made through the client. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- *

- * Setting this is mutually exclusive with using {@link #retryPolicy(RetryPolicy)}. - * - * @param retryOptions The {@link RetryOptions} to use for all the requests made through the client. - * @return The updated {@link CertificateClientBuilder} object. - */ - @Override - public CertificateClientBuilder retryOptions(RetryOptions retryOptions) { - this.retryOptions = retryOptions; - return this; - } - - /** - * Allows for setting common properties such as application ID, headers, proxy configuration, etc. Note that it is - * recommended that this method be called with an instance of the {@link HttpClientOptions} - * class (a subclass of the {@link ClientOptions} base class). The HttpClientOptions subclass provides more - * configuration options suitable for HTTP clients, which is applicable for any class that implements this HttpTrait - * interface. - * - *

Note: It is important to understand the precedence order of the HttpTrait APIs. In - * particular, if a {@link HttpPipeline} is specified, this takes precedence over all other APIs in the trait, and - * they will be ignored. If no {@link HttpPipeline} is specified, a HTTP pipeline will be constructed internally - * based on the settings provided to this trait. Additionally, there may be other APIs in types that implement this - * trait that are also ignored if an {@link HttpPipeline} is specified, so please be sure to refer to the - * documentation of types that implement this trait to understand the full set of implications.

- * - * @param clientOptions A configured instance of {@link HttpClientOptions}. - * @see HttpClientOptions - * @return The updated {@link CertificateClientBuilder} object. - */ - @Override - public CertificateClientBuilder clientOptions(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - - return this; - } - - /** - * Disables verifying if the authentication challenge resource matches the Key Vault domain. This verification is - * performed by default. - * - * @return The updated {@link CertificateClientBuilder} object. - */ - public CertificateClientBuilder disableChallengeResourceVerification() { - this.disableChallengeResourceVerification = true; - - return this; - } - - private String getBuildEndpoint(Configuration configuration) { - if (vaultUrl != null) { - return vaultUrl; - } - - String configEndpoint = configuration.get("AZURE_KEYVAULT_ENDPOINT"); - if (CoreUtils.isNullOrEmpty(configEndpoint)) { - return null; - } - - try { - URL url = new URL(configEndpoint); - return url.toString(); - } catch (MalformedURLException ex) { - return null; - } - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateServiceVersion.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateServiceVersion.java deleted file mode 100644 index c9be34b86aa7..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateServiceVersion.java +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.util.ServiceVersion; - -/** - * The versions of Azure Key Vault Certificate supported by this client library. - */ -public enum CertificateServiceVersion implements ServiceVersion { - /** - * Service version {@code 7.0}. - */ - V7_0("7.0"), - - /** - * Service version {@code 7.1}. - */ - V7_1("7.1"), - - /** - * Service version {@code 7.2}. - */ - V7_2("7.2"), - - /** - * Service version {@code 7.3}. - */ - V7_3("7.3"), - - /** - * Service version {@code 7.4}. - */ - V7_4("7.4"), - - /** - * Service version {@code 7.5}. - */ - V7_5("7.5"), - - /** - * Service version {@code 7.6-preview.1}. - */ - V7_6_PREVIEW_1("7.6-preview.1"); - - private final String version; - - CertificateServiceVersion(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 CertificateServiceVersion} - */ - public static CertificateServiceVersion getLatest() { - return V7_6_PREVIEW_1; - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificateClientImpl.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificateClientImpl.java deleted file mode 100644 index a47916467488..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificateClientImpl.java +++ /dev/null @@ -1,4862 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation; - -import com.azure.core.annotation.BodyParam; -import com.azure.core.annotation.Delete; -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.Patch; -import com.azure.core.annotation.PathParam; -import com.azure.core.annotation.Post; -import com.azure.core.annotation.Put; -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.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.Response; -import com.azure.core.http.rest.RestProxy; -import com.azure.core.util.Context; -import com.azure.core.util.FluxUtil; -import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.core.util.serializer.SerializerAdapter; -import com.azure.security.keyvault.certificates.implementation.models.BackupCertificateResult; -import com.azure.security.keyvault.certificates.implementation.models.CertificateAttributes; -import com.azure.security.keyvault.certificates.implementation.models.CertificateBundle; -import com.azure.security.keyvault.certificates.implementation.models.CertificateCreateParameters; -import com.azure.security.keyvault.certificates.implementation.models.CertificateImportParameters; -import com.azure.security.keyvault.certificates.implementation.models.CertificateIssuerItem; -import com.azure.security.keyvault.certificates.implementation.models.CertificateIssuerListResult; -import com.azure.security.keyvault.certificates.implementation.models.CertificateIssuerSetParameters; -import com.azure.security.keyvault.certificates.implementation.models.CertificateIssuerUpdateParameters; -import com.azure.security.keyvault.certificates.implementation.models.CertificateItem; -import com.azure.security.keyvault.certificates.implementation.models.CertificateListResult; -import com.azure.security.keyvault.certificates.implementation.models.CertificateMergeParameters; -import com.azure.security.keyvault.certificates.implementation.models.CertificateOperation; -import com.azure.security.keyvault.certificates.implementation.models.CertificateOperationUpdateParameter; -import com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.implementation.models.CertificateRestoreParameters; -import com.azure.security.keyvault.certificates.implementation.models.CertificateUpdateParameters; -import com.azure.security.keyvault.certificates.implementation.models.Contacts; -import com.azure.security.keyvault.certificates.implementation.models.DeletedCertificateBundle; -import com.azure.security.keyvault.certificates.implementation.models.DeletedCertificateItem; -import com.azure.security.keyvault.certificates.implementation.models.DeletedCertificateListResult; -import com.azure.security.keyvault.certificates.implementation.models.IssuerAttributes; -import com.azure.security.keyvault.certificates.implementation.models.IssuerBundle; -import com.azure.security.keyvault.certificates.implementation.models.IssuerCredentials; -import com.azure.security.keyvault.certificates.implementation.models.KeyVaultErrorException; -import com.azure.security.keyvault.certificates.implementation.models.OrganizationDetails; -import java.util.List; -import java.util.Map; -import reactor.core.publisher.Mono; - -/** - * Initializes a new instance of the CertificateClient type. - */ -public final class CertificateClientImpl { - /** - * The proxy service used to perform REST calls. - */ - private final CertificateClientService service; - - /** - * Api Version. - */ - private final String apiVersion; - - /** - * Gets Api Version. - * - * @return the apiVersion value. - */ - public String getApiVersion() { - return this.apiVersion; - } - - /** - * 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 CertificateClient client. - * - * @param apiVersion Api Version. - */ - public CertificateClientImpl(String apiVersion) { - this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), - JacksonAdapter.createDefaultSerializerAdapter(), apiVersion); - } - - /** - * Initializes an instance of CertificateClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param apiVersion Api Version. - */ - public CertificateClientImpl(HttpPipeline httpPipeline, String apiVersion) { - this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), apiVersion); - } - - /** - * Initializes an instance of CertificateClient client. - * - * @param httpPipeline The HTTP pipeline to send requests through. - * @param serializerAdapter The serializer to serialize an object into a string. - * @param apiVersion Api Version. - */ - public CertificateClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String apiVersion) { - this.httpPipeline = httpPipeline; - this.serializerAdapter = serializerAdapter; - this.apiVersion = apiVersion; - this.service = RestProxy.create(CertificateClientService.class, this.httpPipeline, this.getSerializerAdapter()); - } - - /** - * The interface defining all the services for CertificateClient to be used by the proxy service to perform REST - * calls. - */ - @Host("{vaultBaseUrl}") - @ServiceInterface(name = "CertificateClient") - public interface CertificateClientService { - @Get("/certificates") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getCertificates(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("maxresults") Integer maxresults, @QueryParam("includePending") Boolean includePending, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getCertificatesSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("maxresults") Integer maxresults, @QueryParam("includePending") Boolean includePending, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); - - @Delete("/certificates/{certificate-name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> deleteCertificate(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/certificates/{certificate-name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response deleteCertificateSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Put("/certificates/contacts") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> setCertificateContacts(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("api-version") String apiVersion, @BodyParam("application/json") Contacts contacts, - @HeaderParam("Accept") String accept, Context context); - - @Put("/certificates/contacts") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response setCertificateContactsSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("api-version") String apiVersion, @BodyParam("application/json") Contacts contacts, - @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates/contacts") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getCertificateContacts(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates/contacts") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getCertificateContactsSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); - - @Delete("/certificates/contacts") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> deleteCertificateContacts(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); - - @Delete("/certificates/contacts") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response deleteCertificateContactsSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates/issuers") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getCertificateIssuers( - @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("maxresults") Integer maxresults, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates/issuers") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getCertificateIssuersSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("maxresults") Integer maxresults, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Put("/certificates/issuers/{issuer-name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> setCertificateIssuer(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("issuer-name") String issuerName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateIssuerSetParameters parameter, - @HeaderParam("Accept") String accept, Context context); - - @Put("/certificates/issuers/{issuer-name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response setCertificateIssuerSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("issuer-name") String issuerName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateIssuerSetParameters parameter, - @HeaderParam("Accept") String accept, Context context); - - @Patch("/certificates/issuers/{issuer-name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> updateCertificateIssuer(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("issuer-name") String issuerName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateIssuerUpdateParameters parameter, - @HeaderParam("Accept") String accept, Context context); - - @Patch("/certificates/issuers/{issuer-name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response updateCertificateIssuerSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("issuer-name") String issuerName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateIssuerUpdateParameters parameter, - @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates/issuers/{issuer-name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getCertificateIssuer(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("issuer-name") String issuerName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates/issuers/{issuer-name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getCertificateIssuerSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("issuer-name") String issuerName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/certificates/issuers/{issuer-name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> deleteCertificateIssuer(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("issuer-name") String issuerName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/certificates/issuers/{issuer-name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response deleteCertificateIssuerSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("issuer-name") String issuerName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Post("/certificates/{certificate-name}/create") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> createCertificate(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateCreateParameters parameters, @HeaderParam("Accept") String accept, - Context context); - - @Post("/certificates/{certificate-name}/create") - @ExpectedResponses({ 202 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response createCertificateSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateCreateParameters parameters, @HeaderParam("Accept") String accept, - Context context); - - @Post("/certificates/{certificate-name}/import") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> importCertificate(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateImportParameters parameters, @HeaderParam("Accept") String accept, - Context context); - - @Post("/certificates/{certificate-name}/import") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response importCertificateSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateImportParameters parameters, @HeaderParam("Accept") String accept, - Context context); - - @Get("/certificates/{certificate-name}/versions") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getCertificateVersions(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("maxresults") Integer maxresults, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates/{certificate-name}/versions") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getCertificateVersionsSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("maxresults") Integer maxresults, - @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates/{certificate-name}/policy") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getCertificatePolicy(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates/{certificate-name}/policy") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getCertificatePolicySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Patch("/certificates/{certificate-name}/policy") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> updateCertificatePolicy(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificatePolicy certificatePolicy, @HeaderParam("Accept") String accept, - Context context); - - @Patch("/certificates/{certificate-name}/policy") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response updateCertificatePolicySync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificatePolicy certificatePolicy, @HeaderParam("Accept") String accept, - Context context); - - @Patch("/certificates/{certificate-name}/{certificate-version}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> updateCertificate(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, - @PathParam("certificate-version") String certificateVersion, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateUpdateParameters parameters, @HeaderParam("Accept") String accept, - Context context); - - @Patch("/certificates/{certificate-name}/{certificate-version}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response updateCertificateSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, - @PathParam("certificate-version") String certificateVersion, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateUpdateParameters parameters, @HeaderParam("Accept") String accept, - Context context); - - @Get("/certificates/{certificate-name}/{certificate-version}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getCertificate(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, - @PathParam("certificate-version") String certificateVersion, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates/{certificate-name}/{certificate-version}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getCertificateSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, - @PathParam("certificate-version") String certificateVersion, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Patch("/certificates/{certificate-name}/pending") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> updateCertificateOperation(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateOperationUpdateParameter certificateOperation, - @HeaderParam("Accept") String accept, Context context); - - @Patch("/certificates/{certificate-name}/pending") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response updateCertificateOperationSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateOperationUpdateParameter certificateOperation, - @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates/{certificate-name}/pending") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getCertificateOperation(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Get("/certificates/{certificate-name}/pending") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getCertificateOperationSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/certificates/{certificate-name}/pending") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> deleteCertificateOperation(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/certificates/{certificate-name}/pending") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response deleteCertificateOperationSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Post("/certificates/{certificate-name}/pending/merge") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> mergeCertificate(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateMergeParameters parameters, @HeaderParam("Accept") String accept, - Context context); - - @Post("/certificates/{certificate-name}/pending/merge") - @ExpectedResponses({ 201 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response mergeCertificateSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateMergeParameters parameters, @HeaderParam("Accept") String accept, - Context context); - - @Post("/certificates/{certificate-name}/backup") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> backupCertificate(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Post("/certificates/{certificate-name}/backup") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response backupCertificateSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Post("/certificates/restore") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> restoreCertificate(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateRestoreParameters parameters, - @HeaderParam("Accept") String accept, Context context); - - @Post("/certificates/restore") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response restoreCertificateSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @QueryParam("api-version") String apiVersion, - @BodyParam("application/json") CertificateRestoreParameters parameters, - @HeaderParam("Accept") String accept, Context context); - - @Get("/deletedcertificates") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getDeletedCertificates( - @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("maxresults") Integer maxresults, - @QueryParam("includePending") Boolean includePending, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Get("/deletedcertificates") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getDeletedCertificatesSync( - @HostParam("vaultBaseUrl") String vaultBaseUrl, @QueryParam("maxresults") Integer maxresults, - @QueryParam("includePending") Boolean includePending, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Get("/deletedcertificates/{certificate-name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getDeletedCertificate(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Get("/deletedcertificates/{certificate-name}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getDeletedCertificateSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/deletedcertificates/{certificate-name}") - @ExpectedResponses({ 204 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> purgeDeletedCertificate(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Delete("/deletedcertificates/{certificate-name}") - @ExpectedResponses({ 204 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response purgeDeletedCertificateSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Post("/deletedcertificates/{certificate-name}/recover") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> recoverDeletedCertificate(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Post("/deletedcertificates/{certificate-name}/recover") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response recoverDeletedCertificateSync(@HostParam("vaultBaseUrl") String vaultBaseUrl, - @PathParam("certificate-name") String certificateName, @QueryParam("api-version") String apiVersion, - @HeaderParam("Accept") String accept, Context context); - - @Get("{nextLink}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getCertificatesNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); - - @Get("{nextLink}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getCertificatesNextSync( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); - - @Get("{nextLink}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getCertificateIssuersNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); - - @Get("{nextLink}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getCertificateIssuersNextSync( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); - - @Get("{nextLink}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getCertificateVersionsNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); - - @Get("{nextLink}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getCertificateVersionsNextSync( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); - - @Get("{nextLink}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Mono> getDeletedCertificatesNext( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); - - @Get("{nextLink}") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(KeyVaultErrorException.class) - Response getDeletedCertificatesNextSync( - @PathParam(value = "nextLink", encoded = true) String nextLink, - @HostParam("vaultBaseUrl") String vaultBaseUrl, @HeaderParam("Accept") String accept, Context context); - } - - /** - * List certificates in a specified key vault - * - * The GetCertificates operation returns the set of certificates resources in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificatesSinglePageAsync(String vaultBaseUrl, Integer maxresults, - Boolean includePending) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.getCertificates(vaultBaseUrl, maxresults, includePending, - this.getApiVersion(), accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * List certificates in a specified key vault - * - * The GetCertificates operation returns the set of certificates resources in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificatesSinglePageAsync(String vaultBaseUrl, Integer maxresults, - Boolean includePending, Context context) { - final String accept = "application/json"; - return service.getCertificates(vaultBaseUrl, maxresults, includePending, this.getApiVersion(), accept, context) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * List certificates in a specified key vault - * - * The GetCertificates operation returns the set of certificates resources in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getCertificatesAsync(String vaultBaseUrl, Integer maxresults, - Boolean includePending) { - return new PagedFlux<>(() -> getCertificatesSinglePageAsync(vaultBaseUrl, maxresults, includePending), - nextLink -> getCertificatesNextSinglePageAsync(nextLink, vaultBaseUrl)); - } - - /** - * List certificates in a specified key vault - * - * The GetCertificates operation returns the set of certificates resources in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getCertificatesAsync(String vaultBaseUrl, Integer maxresults, - Boolean includePending, Context context) { - return new PagedFlux<>(() -> getCertificatesSinglePageAsync(vaultBaseUrl, maxresults, includePending, context), - nextLink -> getCertificatesNextSinglePageAsync(nextLink, vaultBaseUrl, context)); - } - - /** - * List certificates in a specified key vault - * - * The GetCertificates operation returns the set of certificates resources in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getCertificatesSinglePage(String vaultBaseUrl, Integer maxresults, - Boolean includePending) { - final String accept = "application/json"; - Response res = service.getCertificatesSync(vaultBaseUrl, maxresults, includePending, - this.getApiVersion(), accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * List certificates in a specified key vault - * - * The GetCertificates operation returns the set of certificates resources in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getCertificatesSinglePage(String vaultBaseUrl, Integer maxresults, - Boolean includePending, Context context) { - final String accept = "application/json"; - Response res = service.getCertificatesSync(vaultBaseUrl, maxresults, includePending, - this.getApiVersion(), accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * List certificates in a specified key vault - * - * The GetCertificates operation returns the set of certificates resources in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getCertificates(String vaultBaseUrl, Integer maxresults, - Boolean includePending) { - return new PagedIterable<>( - () -> getCertificatesSinglePage(vaultBaseUrl, maxresults, includePending, Context.NONE), - nextLink -> getCertificatesNextSinglePage(nextLink, vaultBaseUrl)); - } - - /** - * List certificates in a specified key vault - * - * The GetCertificates operation returns the set of certificates resources in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getCertificates(String vaultBaseUrl, Integer maxresults, - Boolean includePending, Context context) { - return new PagedIterable<>(() -> getCertificatesSinglePage(vaultBaseUrl, maxresults, includePending, context), - nextLink -> getCertificatesNextSinglePage(nextLink, vaultBaseUrl, context)); - } - - /** - * Deletes a certificate from a specified key vault. - * - * Deletes all versions of a certificate object along with its associated policy. Delete certificate cannot be used - * to remove individual versions of a certificate object. This operation requires the certificates/delete - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on - * when it will be purged along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName) { - return FluxUtil - .withContext(context -> deleteCertificateWithResponseAsync(vaultBaseUrl, certificateName, context)); - } - - /** - * Deletes a certificate from a specified key vault. - * - * Deletes all versions of a certificate object along with its associated policy. Delete certificate cannot be used - * to remove individual versions of a certificate object. This operation requires the certificates/delete - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on - * when it will be purged along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, Context context) { - final String accept = "application/json"; - return service.deleteCertificate(vaultBaseUrl, certificateName, this.getApiVersion(), accept, context); - } - - /** - * Deletes a certificate from a specified key vault. - * - * Deletes all versions of a certificate object along with its associated policy. Delete certificate cannot be used - * to remove individual versions of a certificate object. This operation requires the certificates/delete - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on - * when it will be purged on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteCertificateAsync(String vaultBaseUrl, String certificateName) { - return deleteCertificateWithResponseAsync(vaultBaseUrl, certificateName) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Deletes a certificate from a specified key vault. - * - * Deletes all versions of a certificate object along with its associated policy. Delete certificate cannot be used - * to remove individual versions of a certificate object. This operation requires the certificates/delete - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on - * when it will be purged on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteCertificateAsync(String vaultBaseUrl, String certificateName, - Context context) { - return deleteCertificateWithResponseAsync(vaultBaseUrl, certificateName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Deletes a certificate from a specified key vault. - * - * Deletes all versions of a certificate object along with its associated policy. Delete certificate cannot be used - * to remove individual versions of a certificate object. This operation requires the certificates/delete - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on - * when it will be purged along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteCertificateWithResponse(String vaultBaseUrl, String certificateName, - Context context) { - final String accept = "application/json"; - return service.deleteCertificateSync(vaultBaseUrl, certificateName, this.getApiVersion(), accept, context); - } - - /** - * Deletes a certificate from a specified key vault. - * - * Deletes all versions of a certificate object along with its associated policy. Delete certificate cannot be used - * to remove individual versions of a certificate object. This operation requires the certificates/delete - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on - * when it will be purged. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public DeletedCertificateBundle deleteCertificate(String vaultBaseUrl, String certificateName) { - return deleteCertificateWithResponse(vaultBaseUrl, certificateName, Context.NONE).getValue(); - } - - /** - * Sets the certificate contacts for the specified key vault. - * - * Sets the certificate contacts for the specified key vault. This operation requires the - * certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param contacts The contacts for the key vault certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setCertificateContactsWithResponseAsync(String vaultBaseUrl, Contacts contacts) { - return FluxUtil - .withContext(context -> setCertificateContactsWithResponseAsync(vaultBaseUrl, contacts, context)); - } - - /** - * Sets the certificate contacts for the specified key vault. - * - * Sets the certificate contacts for the specified key vault. This operation requires the - * certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param contacts The contacts for the key vault certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setCertificateContactsWithResponseAsync(String vaultBaseUrl, Contacts contacts, - Context context) { - final String accept = "application/json"; - return service.setCertificateContacts(vaultBaseUrl, this.getApiVersion(), contacts, accept, context); - } - - /** - * Sets the certificate contacts for the specified key vault. - * - * Sets the certificate contacts for the specified key vault. This operation requires the - * certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param contacts The contacts for the key vault certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts) { - return setCertificateContactsWithResponseAsync(vaultBaseUrl, contacts) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Sets the certificate contacts for the specified key vault. - * - * Sets the certificate contacts for the specified key vault. This operation requires the - * certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param contacts The contacts for the key vault certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setCertificateContactsAsync(String vaultBaseUrl, Contacts contacts, Context context) { - return setCertificateContactsWithResponseAsync(vaultBaseUrl, contacts, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Sets the certificate contacts for the specified key vault. - * - * Sets the certificate contacts for the specified key vault. This operation requires the - * certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param contacts The contacts for the key vault certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setCertificateContactsWithResponse(String vaultBaseUrl, Contacts contacts, - Context context) { - final String accept = "application/json"; - return service.setCertificateContactsSync(vaultBaseUrl, this.getApiVersion(), contacts, accept, context); - } - - /** - * Sets the certificate contacts for the specified key vault. - * - * Sets the certificate contacts for the specified key vault. This operation requires the - * certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param contacts The contacts for the key vault certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Contacts setCertificateContacts(String vaultBaseUrl, Contacts contacts) { - return setCertificateContactsWithResponse(vaultBaseUrl, contacts, Context.NONE).getValue(); - } - - /** - * Lists the certificate contacts for a specified key vault. - * - * The GetCertificateContacts operation returns the set of certificate contact resources in the specified key vault. - * This operation requires the certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateContactsWithResponseAsync(String vaultBaseUrl) { - return FluxUtil.withContext(context -> getCertificateContactsWithResponseAsync(vaultBaseUrl, context)); - } - - /** - * Lists the certificate contacts for a specified key vault. - * - * The GetCertificateContacts operation returns the set of certificate contact resources in the specified key vault. - * This operation requires the certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateContactsWithResponseAsync(String vaultBaseUrl, Context context) { - final String accept = "application/json"; - return service.getCertificateContacts(vaultBaseUrl, this.getApiVersion(), accept, context); - } - - /** - * Lists the certificate contacts for a specified key vault. - * - * The GetCertificateContacts operation returns the set of certificate contact resources in the specified key vault. - * This operation requires the certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificateContactsAsync(String vaultBaseUrl) { - return getCertificateContactsWithResponseAsync(vaultBaseUrl).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Lists the certificate contacts for a specified key vault. - * - * The GetCertificateContacts operation returns the set of certificate contact resources in the specified key vault. - * This operation requires the certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificateContactsAsync(String vaultBaseUrl, Context context) { - return getCertificateContactsWithResponseAsync(vaultBaseUrl, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Lists the certificate contacts for a specified key vault. - * - * The GetCertificateContacts operation returns the set of certificate contact resources in the specified key vault. - * This operation requires the certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getCertificateContactsWithResponse(String vaultBaseUrl, Context context) { - final String accept = "application/json"; - return service.getCertificateContactsSync(vaultBaseUrl, this.getApiVersion(), accept, context); - } - - /** - * Lists the certificate contacts for a specified key vault. - * - * The GetCertificateContacts operation returns the set of certificate contact resources in the specified key vault. - * This operation requires the certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Contacts getCertificateContacts(String vaultBaseUrl) { - return getCertificateContactsWithResponse(vaultBaseUrl, Context.NONE).getValue(); - } - - /** - * Deletes the certificate contacts for a specified key vault. - * - * Deletes the certificate contacts for a specified key vault certificate. This operation requires the - * certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteCertificateContactsWithResponseAsync(String vaultBaseUrl) { - return FluxUtil.withContext(context -> deleteCertificateContactsWithResponseAsync(vaultBaseUrl, context)); - } - - /** - * Deletes the certificate contacts for a specified key vault. - * - * Deletes the certificate contacts for a specified key vault certificate. This operation requires the - * certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteCertificateContactsWithResponseAsync(String vaultBaseUrl, Context context) { - final String accept = "application/json"; - return service.deleteCertificateContacts(vaultBaseUrl, this.getApiVersion(), accept, context); - } - - /** - * Deletes the certificate contacts for a specified key vault. - * - * Deletes the certificate contacts for a specified key vault certificate. This operation requires the - * certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteCertificateContactsAsync(String vaultBaseUrl) { - return deleteCertificateContactsWithResponseAsync(vaultBaseUrl) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Deletes the certificate contacts for a specified key vault. - * - * Deletes the certificate contacts for a specified key vault certificate. This operation requires the - * certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteCertificateContactsAsync(String vaultBaseUrl, Context context) { - return deleteCertificateContactsWithResponseAsync(vaultBaseUrl, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Deletes the certificate contacts for a specified key vault. - * - * Deletes the certificate contacts for a specified key vault certificate. This operation requires the - * certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteCertificateContactsWithResponse(String vaultBaseUrl, Context context) { - final String accept = "application/json"; - return service.deleteCertificateContactsSync(vaultBaseUrl, this.getApiVersion(), accept, context); - } - - /** - * Deletes the certificate contacts for a specified key vault. - * - * Deletes the certificate contacts for a specified key vault certificate. This operation requires the - * certificates/managecontacts permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the contacts for the vault certificates. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Contacts deleteCertificateContacts(String vaultBaseUrl) { - return deleteCertificateContactsWithResponse(vaultBaseUrl, Context.NONE).getValue(); - } - - /** - * List certificate issuers for a specified key vault. - * - * The GetCertificateIssuers operation returns the set of certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate issuer list result along with {@link PagedResponse} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateIssuersSinglePageAsync(String vaultBaseUrl, - Integer maxresults) { - final String accept = "application/json"; - return FluxUtil.withContext( - context -> service.getCertificateIssuers(vaultBaseUrl, maxresults, this.getApiVersion(), accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * List certificate issuers for a specified key vault. - * - * The GetCertificateIssuers operation returns the set of certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate issuer list result along with {@link PagedResponse} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateIssuersSinglePageAsync(String vaultBaseUrl, - Integer maxresults, Context context) { - final String accept = "application/json"; - return service.getCertificateIssuers(vaultBaseUrl, maxresults, this.getApiVersion(), accept, context) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * List certificate issuers for a specified key vault. - * - * The GetCertificateIssuers operation returns the set of certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate issuer list result as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getCertificateIssuersAsync(String vaultBaseUrl, Integer maxresults) { - return new PagedFlux<>(() -> getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults), - nextLink -> getCertificateIssuersNextSinglePageAsync(nextLink, vaultBaseUrl)); - } - - /** - * List certificate issuers for a specified key vault. - * - * The GetCertificateIssuers operation returns the set of certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate issuer list result as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getCertificateIssuersAsync(String vaultBaseUrl, Integer maxresults, - Context context) { - return new PagedFlux<>(() -> getCertificateIssuersSinglePageAsync(vaultBaseUrl, maxresults, context), - nextLink -> getCertificateIssuersNextSinglePageAsync(nextLink, vaultBaseUrl, context)); - } - - /** - * List certificate issuers for a specified key vault. - * - * The GetCertificateIssuers operation returns the set of certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate issuer list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getCertificateIssuersSinglePage(String vaultBaseUrl, - Integer maxresults) { - final String accept = "application/json"; - Response res - = service.getCertificateIssuersSync(vaultBaseUrl, maxresults, this.getApiVersion(), accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * List certificate issuers for a specified key vault. - * - * The GetCertificateIssuers operation returns the set of certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate issuer list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getCertificateIssuersSinglePage(String vaultBaseUrl, Integer maxresults, - Context context) { - final String accept = "application/json"; - Response res - = service.getCertificateIssuersSync(vaultBaseUrl, maxresults, this.getApiVersion(), accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * List certificate issuers for a specified key vault. - * - * The GetCertificateIssuers operation returns the set of certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate issuer list result as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getCertificateIssuers(String vaultBaseUrl, Integer maxresults) { - return new PagedIterable<>(() -> getCertificateIssuersSinglePage(vaultBaseUrl, maxresults, Context.NONE), - nextLink -> getCertificateIssuersNextSinglePage(nextLink, vaultBaseUrl)); - } - - /** - * List certificate issuers for a specified key vault. - * - * The GetCertificateIssuers operation returns the set of certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate issuer list result as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getCertificateIssuers(String vaultBaseUrl, Integer maxresults, - Context context) { - return new PagedIterable<>(() -> getCertificateIssuersSinglePage(vaultBaseUrl, maxresults, context), - nextLink -> getCertificateIssuersNextSinglePage(nextLink, vaultBaseUrl, context)); - } - - /** - * Sets the specified certificate issuer. - * - * The SetCertificateIssuer operation adds or updates the specified certificate issuer. This operation requires the - * certificates/setissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. The value you provide may be copied globally for the purpose of running - * the service. The value provided should not include personally identifiable or sensitive information. - * @param provider The issuer provider. - * @param credentials The credentials to be used for the issuer. - * @param organizationDetails Details of the organization as provided to the issuer. - * @param attributes Attributes of the issuer object. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setCertificateIssuerWithResponseAsync(String vaultBaseUrl, String issuerName, - String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, - IssuerAttributes attributes) { - return FluxUtil.withContext(context -> setCertificateIssuerWithResponseAsync(vaultBaseUrl, issuerName, provider, - credentials, organizationDetails, attributes, context)); - } - - /** - * Sets the specified certificate issuer. - * - * The SetCertificateIssuer operation adds or updates the specified certificate issuer. This operation requires the - * certificates/setissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. The value you provide may be copied globally for the purpose of running - * the service. The value provided should not include personally identifiable or sensitive information. - * @param provider The issuer provider. - * @param credentials The credentials to be used for the issuer. - * @param organizationDetails Details of the organization as provided to the issuer. - * @param attributes Attributes of the issuer object. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> setCertificateIssuerWithResponseAsync(String vaultBaseUrl, String issuerName, - String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, - IssuerAttributes attributes, Context context) { - final String accept = "application/json"; - CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); - parameter.setProvider(provider); - parameter.setCredentials(credentials); - parameter.setOrganizationDetails(organizationDetails); - parameter.setAttributes(attributes); - return service.setCertificateIssuer(vaultBaseUrl, issuerName, this.getApiVersion(), parameter, accept, context); - } - - /** - * Sets the specified certificate issuer. - * - * The SetCertificateIssuer operation adds or updates the specified certificate issuer. This operation requires the - * certificates/setissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. The value you provide may be copied globally for the purpose of running - * the service. The value provided should not include personally identifiable or sensitive information. - * @param provider The issuer provider. - * @param credentials The credentials to be used for the issuer. - * @param organizationDetails Details of the organization as provided to the issuer. - * @param attributes Attributes of the issuer object. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, - IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { - return setCertificateIssuerWithResponseAsync(vaultBaseUrl, issuerName, provider, credentials, - organizationDetails, attributes).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Sets the specified certificate issuer. - * - * The SetCertificateIssuer operation adds or updates the specified certificate issuer. This operation requires the - * certificates/setissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. The value you provide may be copied globally for the purpose of running - * the service. The value provided should not include personally identifiable or sensitive information. - * @param provider The issuer provider. - * @param credentials The credentials to be used for the issuer. - * @param organizationDetails Details of the organization as provided to the issuer. - * @param attributes Attributes of the issuer object. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono setCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, - IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, - Context context) { - return setCertificateIssuerWithResponseAsync(vaultBaseUrl, issuerName, provider, credentials, - organizationDetails, attributes, context).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Sets the specified certificate issuer. - * - * The SetCertificateIssuer operation adds or updates the specified certificate issuer. This operation requires the - * certificates/setissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. The value you provide may be copied globally for the purpose of running - * the service. The value provided should not include personally identifiable or sensitive information. - * @param provider The issuer provider. - * @param credentials The credentials to be used for the issuer. - * @param organizationDetails Details of the organization as provided to the issuer. - * @param attributes Attributes of the issuer object. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response setCertificateIssuerWithResponse(String vaultBaseUrl, String issuerName, - String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, - IssuerAttributes attributes, Context context) { - final String accept = "application/json"; - CertificateIssuerSetParameters parameter = new CertificateIssuerSetParameters(); - parameter.setProvider(provider); - parameter.setCredentials(credentials); - parameter.setOrganizationDetails(organizationDetails); - parameter.setAttributes(attributes); - return service.setCertificateIssuerSync(vaultBaseUrl, issuerName, this.getApiVersion(), parameter, accept, - context); - } - - /** - * Sets the specified certificate issuer. - * - * The SetCertificateIssuer operation adds or updates the specified certificate issuer. This operation requires the - * certificates/setissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. The value you provide may be copied globally for the purpose of running - * the service. The value provided should not include personally identifiable or sensitive information. - * @param provider The issuer provider. - * @param credentials The credentials to be used for the issuer. - * @param organizationDetails Details of the organization as provided to the issuer. - * @param attributes Attributes of the issuer object. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public IssuerBundle setCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, - IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { - return setCertificateIssuerWithResponse(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, - attributes, Context.NONE).getValue(); - } - - /** - * Updates the specified certificate issuer. - * - * The UpdateCertificateIssuer operation performs an update on the specified certificate issuer entity. This - * operation requires the certificates/setissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @param provider The issuer provider. - * @param credentials The credentials to be used for the issuer. - * @param organizationDetails Details of the organization as provided to the issuer. - * @param attributes Attributes of the issuer object. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateCertificateIssuerWithResponseAsync(String vaultBaseUrl, String issuerName, - String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, - IssuerAttributes attributes) { - return FluxUtil.withContext(context -> updateCertificateIssuerWithResponseAsync(vaultBaseUrl, issuerName, - provider, credentials, organizationDetails, attributes, context)); - } - - /** - * Updates the specified certificate issuer. - * - * The UpdateCertificateIssuer operation performs an update on the specified certificate issuer entity. This - * operation requires the certificates/setissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @param provider The issuer provider. - * @param credentials The credentials to be used for the issuer. - * @param organizationDetails Details of the organization as provided to the issuer. - * @param attributes Attributes of the issuer object. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateCertificateIssuerWithResponseAsync(String vaultBaseUrl, String issuerName, - String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, - IssuerAttributes attributes, Context context) { - final String accept = "application/json"; - CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); - parameter.setProvider(provider); - parameter.setCredentials(credentials); - parameter.setOrganizationDetails(organizationDetails); - parameter.setAttributes(attributes); - return service.updateCertificateIssuer(vaultBaseUrl, issuerName, this.getApiVersion(), parameter, accept, - context); - } - - /** - * Updates the specified certificate issuer. - * - * The UpdateCertificateIssuer operation performs an update on the specified certificate issuer entity. This - * operation requires the certificates/setissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @param provider The issuer provider. - * @param credentials The credentials to be used for the issuer. - * @param organizationDetails Details of the organization as provided to the issuer. - * @param attributes Attributes of the issuer object. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, - IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { - return updateCertificateIssuerWithResponseAsync(vaultBaseUrl, issuerName, provider, credentials, - organizationDetails, attributes).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Updates the specified certificate issuer. - * - * The UpdateCertificateIssuer operation performs an update on the specified certificate issuer entity. This - * operation requires the certificates/setissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @param provider The issuer provider. - * @param credentials The credentials to be used for the issuer. - * @param organizationDetails Details of the organization as provided to the issuer. - * @param attributes Attributes of the issuer object. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateCertificateIssuerAsync(String vaultBaseUrl, String issuerName, String provider, - IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes, - Context context) { - return updateCertificateIssuerWithResponseAsync(vaultBaseUrl, issuerName, provider, credentials, - organizationDetails, attributes, context).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Updates the specified certificate issuer. - * - * The UpdateCertificateIssuer operation performs an update on the specified certificate issuer entity. This - * operation requires the certificates/setissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @param provider The issuer provider. - * @param credentials The credentials to be used for the issuer. - * @param organizationDetails Details of the organization as provided to the issuer. - * @param attributes Attributes of the issuer object. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateCertificateIssuerWithResponse(String vaultBaseUrl, String issuerName, - String provider, IssuerCredentials credentials, OrganizationDetails organizationDetails, - IssuerAttributes attributes, Context context) { - final String accept = "application/json"; - CertificateIssuerUpdateParameters parameter = new CertificateIssuerUpdateParameters(); - parameter.setProvider(provider); - parameter.setCredentials(credentials); - parameter.setOrganizationDetails(organizationDetails); - parameter.setAttributes(attributes); - return service.updateCertificateIssuerSync(vaultBaseUrl, issuerName, this.getApiVersion(), parameter, accept, - context); - } - - /** - * Updates the specified certificate issuer. - * - * The UpdateCertificateIssuer operation performs an update on the specified certificate issuer entity. This - * operation requires the certificates/setissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @param provider The issuer provider. - * @param credentials The credentials to be used for the issuer. - * @param organizationDetails Details of the organization as provided to the issuer. - * @param attributes Attributes of the issuer object. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public IssuerBundle updateCertificateIssuer(String vaultBaseUrl, String issuerName, String provider, - IssuerCredentials credentials, OrganizationDetails organizationDetails, IssuerAttributes attributes) { - return updateCertificateIssuerWithResponse(vaultBaseUrl, issuerName, provider, credentials, organizationDetails, - attributes, Context.NONE).getValue(); - } - - /** - * Lists the specified certificate issuer. - * - * The GetCertificateIssuer operation returns the specified certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateIssuerWithResponseAsync(String vaultBaseUrl, String issuerName) { - return FluxUtil - .withContext(context -> getCertificateIssuerWithResponseAsync(vaultBaseUrl, issuerName, context)); - } - - /** - * Lists the specified certificate issuer. - * - * The GetCertificateIssuer operation returns the specified certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateIssuerWithResponseAsync(String vaultBaseUrl, String issuerName, - Context context) { - final String accept = "application/json"; - return service.getCertificateIssuer(vaultBaseUrl, issuerName, this.getApiVersion(), accept, context); - } - - /** - * Lists the specified certificate issuer. - * - * The GetCertificateIssuer operation returns the specified certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { - return getCertificateIssuerWithResponseAsync(vaultBaseUrl, issuerName) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Lists the specified certificate issuer. - * - * The GetCertificateIssuer operation returns the specified certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificateIssuerAsync(String vaultBaseUrl, String issuerName, Context context) { - return getCertificateIssuerWithResponseAsync(vaultBaseUrl, issuerName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Lists the specified certificate issuer. - * - * The GetCertificateIssuer operation returns the specified certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getCertificateIssuerWithResponse(String vaultBaseUrl, String issuerName, - Context context) { - final String accept = "application/json"; - return service.getCertificateIssuerSync(vaultBaseUrl, issuerName, this.getApiVersion(), accept, context); - } - - /** - * Lists the specified certificate issuer. - * - * The GetCertificateIssuer operation returns the specified certificate issuer resources in the specified key vault. - * This operation requires the certificates/manageissuers/getissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public IssuerBundle getCertificateIssuer(String vaultBaseUrl, String issuerName) { - return getCertificateIssuerWithResponse(vaultBaseUrl, issuerName, Context.NONE).getValue(); - } - - /** - * Deletes the specified certificate issuer. - * - * The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the vault. This - * operation requires the certificates/manageissuers/deleteissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteCertificateIssuerWithResponseAsync(String vaultBaseUrl, - String issuerName) { - return FluxUtil - .withContext(context -> deleteCertificateIssuerWithResponseAsync(vaultBaseUrl, issuerName, context)); - } - - /** - * Deletes the specified certificate issuer. - * - * The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the vault. This - * operation requires the certificates/manageissuers/deleteissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteCertificateIssuerWithResponseAsync(String vaultBaseUrl, String issuerName, - Context context) { - final String accept = "application/json"; - return service.deleteCertificateIssuer(vaultBaseUrl, issuerName, this.getApiVersion(), accept, context); - } - - /** - * Deletes the specified certificate issuer. - * - * The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the vault. This - * operation requires the certificates/manageissuers/deleteissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName) { - return deleteCertificateIssuerWithResponseAsync(vaultBaseUrl, issuerName) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Deletes the specified certificate issuer. - * - * The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the vault. This - * operation requires the certificates/manageissuers/deleteissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteCertificateIssuerAsync(String vaultBaseUrl, String issuerName, Context context) { - return deleteCertificateIssuerWithResponseAsync(vaultBaseUrl, issuerName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Deletes the specified certificate issuer. - * - * The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the vault. This - * operation requires the certificates/manageissuers/deleteissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteCertificateIssuerWithResponse(String vaultBaseUrl, String issuerName, - Context context) { - final String accept = "application/json"; - return service.deleteCertificateIssuerSync(vaultBaseUrl, issuerName, this.getApiVersion(), accept, context); - } - - /** - * Deletes the specified certificate issuer. - * - * The DeleteCertificateIssuer operation permanently removes the specified certificate issuer from the vault. This - * operation requires the certificates/manageissuers/deleteissuers permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param issuerName The name of the issuer. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the issuer for Key Vault certificate. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public IssuerBundle deleteCertificateIssuer(String vaultBaseUrl, String issuerName) { - return deleteCertificateIssuerWithResponse(vaultBaseUrl, issuerName, Context.NONE).getValue(); - } - - /** - * Creates a new certificate. - * - * If this is the first version, the certificate resource is created. This operation requires the - * certificates/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. The value you provide may be copied globally for the purpose - * of running the service. The value provided should not include personally identifiable or sensitive information. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, - Map tags) { - return FluxUtil.withContext(context -> createCertificateWithResponseAsync(vaultBaseUrl, certificateName, - certificatePolicy, certificateAttributes, tags, context)); - } - - /** - * Creates a new certificate. - * - * If this is the first version, the certificate resource is created. This operation requires the - * certificates/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. The value you provide may be copied globally for the purpose - * of running the service. The value provided should not include personally identifiable or sensitive information. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, - Map tags, Context context) { - final String accept = "application/json"; - CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - return service.createCertificate(vaultBaseUrl, certificateName, this.getApiVersion(), parameters, accept, - context); - } - - /** - * Creates a new certificate. - * - * If this is the first version, the certificate resource is created. This operation requires the - * certificates/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. The value you provide may be copied globally for the purpose - * of running the service. The value provided should not include personally identifiable or sensitive information. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createCertificateAsync(String vaultBaseUrl, String certificateName, - CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { - return createCertificateWithResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, - certificateAttributes, tags).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Creates a new certificate. - * - * If this is the first version, the certificate resource is created. This operation requires the - * certificates/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. The value you provide may be copied globally for the purpose - * of running the service. The value provided should not include personally identifiable or sensitive information. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createCertificateAsync(String vaultBaseUrl, String certificateName, - CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, - Context context) { - return createCertificateWithResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, - certificateAttributes, tags, context).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Creates a new certificate. - * - * If this is the first version, the certificate resource is created. This operation requires the - * certificates/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. The value you provide may be copied globally for the purpose - * of running the service. The value provided should not include personally identifiable or sensitive information. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response createCertificateWithResponse(String vaultBaseUrl, String certificateName, - CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags, - Context context) { - final String accept = "application/json"; - CertificateCreateParameters parameters = new CertificateCreateParameters(); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - return service.createCertificateSync(vaultBaseUrl, certificateName, this.getApiVersion(), parameters, accept, - context); - } - - /** - * Creates a new certificate. - * - * If this is the first version, the certificate resource is created. This operation requires the - * certificates/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. The value you provide may be copied globally for the purpose - * of running the service. The value provided should not include personally identifiable or sensitive information. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateOperation createCertificate(String vaultBaseUrl, String certificateName, - CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { - return createCertificateWithResponse(vaultBaseUrl, certificateName, certificatePolicy, certificateAttributes, - tags, Context.NONE).getValue(); - } - - /** - * Imports a certificate into a specified key vault. - * - * Imports an existing valid certificate, containing a private key, into Azure Key Vault. This operation requires - * the certificates/import permission. The certificate to be imported can be in either PFX or PEM format. If the - * certificate is in PEM format the PEM file must contain the key as well as x509 certificates. Key Vault will only - * accept a key in PKCS#8 format. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. The value you provide may be copied globally for the purpose - * of running the service. The value provided should not include personally identifiable or sensitive information. - * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This - * certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> importCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, - CertificateAttributes certificateAttributes, Map tags) { - return FluxUtil.withContext(context -> importCertificateWithResponseAsync(vaultBaseUrl, certificateName, - base64EncodedCertificate, password, certificatePolicy, certificateAttributes, tags, context)); - } - - /** - * Imports a certificate into a specified key vault. - * - * Imports an existing valid certificate, containing a private key, into Azure Key Vault. This operation requires - * the certificates/import permission. The certificate to be imported can be in either PFX or PEM format. If the - * certificate is in PEM format the PEM file must contain the key as well as x509 certificates. Key Vault will only - * accept a key in PKCS#8 format. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. The value you provide may be copied globally for the purpose - * of running the service. The value provided should not include personally identifiable or sensitive information. - * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This - * certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> importCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, - CertificateAttributes certificateAttributes, Map tags, Context context) { - final String accept = "application/json"; - CertificateImportParameters parameters = new CertificateImportParameters(); - parameters.setBase64EncodedCertificate(base64EncodedCertificate); - parameters.setPassword(password); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - return service.importCertificate(vaultBaseUrl, certificateName, this.getApiVersion(), parameters, accept, - context); - } - - /** - * Imports a certificate into a specified key vault. - * - * Imports an existing valid certificate, containing a private key, into Azure Key Vault. This operation requires - * the certificates/import permission. The certificate to be imported can be in either PFX or PEM format. If the - * certificate is in PEM format the PEM file must contain the key as well as x509 certificates. Key Vault will only - * accept a key in PKCS#8 format. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. The value you provide may be copied globally for the purpose - * of running the service. The value provided should not include personally identifiable or sensitive information. - * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This - * certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono importCertificateAsync(String vaultBaseUrl, String certificateName, - String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, - CertificateAttributes certificateAttributes, Map tags) { - return importCertificateWithResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, - certificatePolicy, certificateAttributes, tags).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Imports a certificate into a specified key vault. - * - * Imports an existing valid certificate, containing a private key, into Azure Key Vault. This operation requires - * the certificates/import permission. The certificate to be imported can be in either PFX or PEM format. If the - * certificate is in PEM format the PEM file must contain the key as well as x509 certificates. Key Vault will only - * accept a key in PKCS#8 format. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. The value you provide may be copied globally for the purpose - * of running the service. The value provided should not include personally identifiable or sensitive information. - * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This - * certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono importCertificateAsync(String vaultBaseUrl, String certificateName, - String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, - CertificateAttributes certificateAttributes, Map tags, Context context) { - return importCertificateWithResponseAsync(vaultBaseUrl, certificateName, base64EncodedCertificate, password, - certificatePolicy, certificateAttributes, tags, context).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Imports a certificate into a specified key vault. - * - * Imports an existing valid certificate, containing a private key, into Azure Key Vault. This operation requires - * the certificates/import permission. The certificate to be imported can be in either PFX or PEM format. If the - * certificate is in PEM format the PEM file must contain the key as well as x509 certificates. Key Vault will only - * accept a key in PKCS#8 format. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. The value you provide may be copied globally for the purpose - * of running the service. The value provided should not include personally identifiable or sensitive information. - * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This - * certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response importCertificateWithResponse(String vaultBaseUrl, String certificateName, - String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, - CertificateAttributes certificateAttributes, Map tags, Context context) { - final String accept = "application/json"; - CertificateImportParameters parameters = new CertificateImportParameters(); - parameters.setBase64EncodedCertificate(base64EncodedCertificate); - parameters.setPassword(password); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - return service.importCertificateSync(vaultBaseUrl, certificateName, this.getApiVersion(), parameters, accept, - context); - } - - /** - * Imports a certificate into a specified key vault. - * - * Imports an existing valid certificate, containing a private key, into Azure Key Vault. This operation requires - * the certificates/import permission. The certificate to be imported can be in either PFX or PEM format. If the - * certificate is in PEM format the PEM file must contain the key as well as x509 certificates. Key Vault will only - * accept a key in PKCS#8 format. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. The value you provide may be copied globally for the purpose - * of running the service. The value provided should not include personally identifiable or sensitive information. - * @param base64EncodedCertificate Base64 encoded representation of the certificate object to import. This - * certificate needs to contain the private key. - * @param password If the private key in base64EncodedCertificate is encrypted, the password used for encryption. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateBundle importCertificate(String vaultBaseUrl, String certificateName, - String base64EncodedCertificate, String password, CertificatePolicy certificatePolicy, - CertificateAttributes certificateAttributes, Map tags) { - return importCertificateWithResponse(vaultBaseUrl, certificateName, base64EncodedCertificate, password, - certificatePolicy, certificateAttributes, tags, Context.NONE).getValue(); - } - - /** - * List the versions of a certificate. - * - * The GetCertificateVersions operation returns the versions of a certificate in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateVersionsSinglePageAsync(String vaultBaseUrl, - String certificateName, Integer maxresults) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.getCertificateVersions(vaultBaseUrl, certificateName, maxresults, - this.getApiVersion(), accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * List the versions of a certificate. - * - * The GetCertificateVersions operation returns the versions of a certificate in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateVersionsSinglePageAsync(String vaultBaseUrl, - String certificateName, Integer maxresults, Context context) { - final String accept = "application/json"; - return service - .getCertificateVersions(vaultBaseUrl, certificateName, maxresults, this.getApiVersion(), accept, context) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * List the versions of a certificate. - * - * The GetCertificateVersions operation returns the versions of a certificate in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getCertificateVersionsAsync(String vaultBaseUrl, String certificateName, - Integer maxresults) { - return new PagedFlux<>(() -> getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults), - nextLink -> getCertificateVersionsNextSinglePageAsync(nextLink, vaultBaseUrl)); - } - - /** - * List the versions of a certificate. - * - * The GetCertificateVersions operation returns the versions of a certificate in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getCertificateVersionsAsync(String vaultBaseUrl, String certificateName, - Integer maxresults, Context context) { - return new PagedFlux<>( - () -> getCertificateVersionsSinglePageAsync(vaultBaseUrl, certificateName, maxresults, context), - nextLink -> getCertificateVersionsNextSinglePageAsync(nextLink, vaultBaseUrl, context)); - } - - /** - * List the versions of a certificate. - * - * The GetCertificateVersions operation returns the versions of a certificate in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getCertificateVersionsSinglePage(String vaultBaseUrl, String certificateName, - Integer maxresults) { - final String accept = "application/json"; - Response res = service.getCertificateVersionsSync(vaultBaseUrl, certificateName, - maxresults, this.getApiVersion(), accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * List the versions of a certificate. - * - * The GetCertificateVersions operation returns the versions of a certificate in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getCertificateVersionsSinglePage(String vaultBaseUrl, String certificateName, - Integer maxresults, Context context) { - final String accept = "application/json"; - Response res = service.getCertificateVersionsSync(vaultBaseUrl, certificateName, - maxresults, this.getApiVersion(), accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * List the versions of a certificate. - * - * The GetCertificateVersions operation returns the versions of a certificate in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getCertificateVersions(String vaultBaseUrl, String certificateName, - Integer maxresults) { - return new PagedIterable<>( - () -> getCertificateVersionsSinglePage(vaultBaseUrl, certificateName, maxresults, Context.NONE), - nextLink -> getCertificateVersionsNextSinglePage(nextLink, vaultBaseUrl)); - } - - /** - * List the versions of a certificate. - * - * The GetCertificateVersions operation returns the versions of a certificate in the specified key vault. This - * operation requires the certificates/list permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result as paginated response with {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getCertificateVersions(String vaultBaseUrl, String certificateName, - Integer maxresults, Context context) { - return new PagedIterable<>( - () -> getCertificateVersionsSinglePage(vaultBaseUrl, certificateName, maxresults, context), - nextLink -> getCertificateVersionsNextSinglePage(nextLink, vaultBaseUrl, context)); - } - - /** - * Lists the policy for a certificate. - * - * The GetCertificatePolicy operation returns the specified certificate policy resources in the specified key vault. - * This operation requires the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in a given key vault. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a certificate along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificatePolicyWithResponseAsync(String vaultBaseUrl, - String certificateName) { - return FluxUtil - .withContext(context -> getCertificatePolicyWithResponseAsync(vaultBaseUrl, certificateName, context)); - } - - /** - * Lists the policy for a certificate. - * - * The GetCertificatePolicy operation returns the specified certificate policy resources in the specified key vault. - * This operation requires the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in a given key vault. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a certificate along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificatePolicyWithResponseAsync(String vaultBaseUrl, - String certificateName, Context context) { - final String accept = "application/json"; - return service.getCertificatePolicy(vaultBaseUrl, certificateName, this.getApiVersion(), accept, context); - } - - /** - * Lists the policy for a certificate. - * - * The GetCertificatePolicy operation returns the specified certificate policy resources in the specified key vault. - * This operation requires the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in a given key vault. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificatePolicyAsync(String vaultBaseUrl, String certificateName) { - return getCertificatePolicyWithResponseAsync(vaultBaseUrl, certificateName) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Lists the policy for a certificate. - * - * The GetCertificatePolicy operation returns the specified certificate policy resources in the specified key vault. - * This operation requires the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in a given key vault. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificatePolicyAsync(String vaultBaseUrl, String certificateName, - Context context) { - return getCertificatePolicyWithResponseAsync(vaultBaseUrl, certificateName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Lists the policy for a certificate. - * - * The GetCertificatePolicy operation returns the specified certificate policy resources in the specified key vault. - * This operation requires the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in a given key vault. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a certificate along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getCertificatePolicyWithResponse(String vaultBaseUrl, String certificateName, - Context context) { - final String accept = "application/json"; - return service.getCertificatePolicySync(vaultBaseUrl, certificateName, this.getApiVersion(), accept, context); - } - - /** - * Lists the policy for a certificate. - * - * The GetCertificatePolicy operation returns the specified certificate policy resources in the specified key vault. - * This operation requires the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in a given key vault. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a certificate. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificatePolicy getCertificatePolicy(String vaultBaseUrl, String certificateName) { - return getCertificatePolicyWithResponse(vaultBaseUrl, certificateName, Context.NONE).getValue(); - } - - /** - * Updates the policy for a certificate. - * - * Set specified members in the certificate policy. Leave others as null. This operation requires the - * certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given vault. - * @param certificatePolicy The policy for the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a certificate along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateCertificatePolicyWithResponseAsync(String vaultBaseUrl, - String certificateName, CertificatePolicy certificatePolicy) { - return FluxUtil.withContext(context -> updateCertificatePolicyWithResponseAsync(vaultBaseUrl, certificateName, - certificatePolicy, context)); - } - - /** - * Updates the policy for a certificate. - * - * Set specified members in the certificate policy. Leave others as null. This operation requires the - * certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given vault. - * @param certificatePolicy The policy for the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a certificate along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateCertificatePolicyWithResponseAsync(String vaultBaseUrl, - String certificateName, CertificatePolicy certificatePolicy, Context context) { - final String accept = "application/json"; - return service.updateCertificatePolicy(vaultBaseUrl, certificateName, this.getApiVersion(), certificatePolicy, - accept, context); - } - - /** - * Updates the policy for a certificate. - * - * Set specified members in the certificate policy. Leave others as null. This operation requires the - * certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given vault. - * @param certificatePolicy The policy for the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, - CertificatePolicy certificatePolicy) { - return updateCertificatePolicyWithResponseAsync(vaultBaseUrl, certificateName, certificatePolicy) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Updates the policy for a certificate. - * - * Set specified members in the certificate policy. Leave others as null. This operation requires the - * certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given vault. - * @param certificatePolicy The policy for the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateCertificatePolicyAsync(String vaultBaseUrl, String certificateName, - CertificatePolicy certificatePolicy, Context context) { - return updateCertificatePolicyWithResponseAsync(vaultBaseUrl, certificateName, certificatePolicy, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Updates the policy for a certificate. - * - * Set specified members in the certificate policy. Leave others as null. This operation requires the - * certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given vault. - * @param certificatePolicy The policy for the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a certificate along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateCertificatePolicyWithResponse(String vaultBaseUrl, String certificateName, - CertificatePolicy certificatePolicy, Context context) { - final String accept = "application/json"; - return service.updateCertificatePolicySync(vaultBaseUrl, certificateName, this.getApiVersion(), - certificatePolicy, accept, context); - } - - /** - * Updates the policy for a certificate. - * - * Set specified members in the certificate policy. Leave others as null. This operation requires the - * certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given vault. - * @param certificatePolicy The policy for the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return management policy for a certificate. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificatePolicy updateCertificatePolicy(String vaultBaseUrl, String certificateName, - CertificatePolicy certificatePolicy) { - return updateCertificatePolicyWithResponse(vaultBaseUrl, certificateName, certificatePolicy, Context.NONE) - .getValue(); - } - - /** - * Updates the specified attributes associated with the given certificate. - * - * The UpdateCertificate operation applies the specified update on the given certificate; the only elements updated - * are the certificate's attributes. This operation requires the certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given key vault. - * @param certificateVersion The version of the certificate. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, - CertificateAttributes certificateAttributes, Map tags) { - return FluxUtil.withContext(context -> updateCertificateWithResponseAsync(vaultBaseUrl, certificateName, - certificateVersion, certificatePolicy, certificateAttributes, tags, context)); - } - - /** - * Updates the specified attributes associated with the given certificate. - * - * The UpdateCertificate operation applies the specified update on the given certificate; the only elements updated - * are the certificate's attributes. This operation requires the certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given key vault. - * @param certificateVersion The version of the certificate. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, String certificateVersion, CertificatePolicy certificatePolicy, - CertificateAttributes certificateAttributes, Map tags, Context context) { - final String accept = "application/json"; - CertificateUpdateParameters parameters = new CertificateUpdateParameters(); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - return service.updateCertificate(vaultBaseUrl, certificateName, certificateVersion, this.getApiVersion(), - parameters, accept, context); - } - - /** - * Updates the specified attributes associated with the given certificate. - * - * The UpdateCertificate operation applies the specified update on the given certificate; the only elements updated - * are the certificate's attributes. This operation requires the certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given key vault. - * @param certificateVersion The version of the certificate. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateCertificateAsync(String vaultBaseUrl, String certificateName, - String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, - Map tags) { - return updateCertificateWithResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, - certificateAttributes, tags).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Updates the specified attributes associated with the given certificate. - * - * The UpdateCertificate operation applies the specified update on the given certificate; the only elements updated - * are the certificate's attributes. This operation requires the certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given key vault. - * @param certificateVersion The version of the certificate. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateCertificateAsync(String vaultBaseUrl, String certificateName, - String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, - Map tags, Context context) { - return updateCertificateWithResponseAsync(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, - certificateAttributes, tags, context).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Updates the specified attributes associated with the given certificate. - * - * The UpdateCertificate operation applies the specified update on the given certificate; the only elements updated - * are the certificate's attributes. This operation requires the certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given key vault. - * @param certificateVersion The version of the certificate. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateCertificateWithResponse(String vaultBaseUrl, String certificateName, - String certificateVersion, CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, - Map tags, Context context) { - final String accept = "application/json"; - CertificateUpdateParameters parameters = new CertificateUpdateParameters(); - parameters.setCertificatePolicy(certificatePolicy); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - return service.updateCertificateSync(vaultBaseUrl, certificateName, certificateVersion, this.getApiVersion(), - parameters, accept, context); - } - - /** - * Updates the specified attributes associated with the given certificate. - * - * The UpdateCertificate operation applies the specified update on the given certificate; the only elements updated - * are the certificate's attributes. This operation requires the certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given key vault. - * @param certificateVersion The version of the certificate. - * @param certificatePolicy The management policy for the certificate. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateBundle updateCertificate(String vaultBaseUrl, String certificateName, String certificateVersion, - CertificatePolicy certificatePolicy, CertificateAttributes certificateAttributes, Map tags) { - return updateCertificateWithResponse(vaultBaseUrl, certificateName, certificateVersion, certificatePolicy, - certificateAttributes, tags, Context.NONE).getValue(); - } - - /** - * Gets information about a certificate. - * - * Gets information about a specific certificate. This operation requires the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given vault. - * @param certificateVersion The version of the certificate. This URI fragment is optional. If not specified, the - * latest version of the certificate is returned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return information about a specific certificate along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, String certificateVersion) { - return FluxUtil.withContext( - context -> getCertificateWithResponseAsync(vaultBaseUrl, certificateName, certificateVersion, context)); - } - - /** - * Gets information about a certificate. - * - * Gets information about a specific certificate. This operation requires the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given vault. - * @param certificateVersion The version of the certificate. This URI fragment is optional. If not specified, the - * latest version of the certificate is returned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return information about a specific certificate along with {@link Response} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, String certificateVersion, Context context) { - final String accept = "application/json"; - return service.getCertificate(vaultBaseUrl, certificateName, certificateVersion, this.getApiVersion(), accept, - context); - } - - /** - * Gets information about a certificate. - * - * Gets information about a specific certificate. This operation requires the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given vault. - * @param certificateVersion The version of the certificate. This URI fragment is optional. If not specified, the - * latest version of the certificate is returned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return information about a specific certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificateAsync(String vaultBaseUrl, String certificateName, - String certificateVersion) { - return getCertificateWithResponseAsync(vaultBaseUrl, certificateName, certificateVersion) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Gets information about a certificate. - * - * Gets information about a specific certificate. This operation requires the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given vault. - * @param certificateVersion The version of the certificate. This URI fragment is optional. If not specified, the - * latest version of the certificate is returned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return information about a specific certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificateAsync(String vaultBaseUrl, String certificateName, - String certificateVersion, Context context) { - return getCertificateWithResponseAsync(vaultBaseUrl, certificateName, certificateVersion, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Gets information about a certificate. - * - * Gets information about a specific certificate. This operation requires the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given vault. - * @param certificateVersion The version of the certificate. This URI fragment is optional. If not specified, the - * latest version of the certificate is returned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return information about a specific certificate along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getCertificateWithResponse(String vaultBaseUrl, String certificateName, - String certificateVersion, Context context) { - final String accept = "application/json"; - return service.getCertificateSync(vaultBaseUrl, certificateName, certificateVersion, this.getApiVersion(), - accept, context); - } - - /** - * Gets information about a certificate. - * - * Gets information about a specific certificate. This operation requires the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate in the given vault. - * @param certificateVersion The version of the certificate. This URI fragment is optional. If not specified, the - * latest version of the certificate is returned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return information about a specific certificate. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateBundle getCertificate(String vaultBaseUrl, String certificateName, String certificateVersion) { - return getCertificateWithResponse(vaultBaseUrl, certificateName, certificateVersion, Context.NONE).getValue(); - } - - /** - * Updates a certificate operation. - * - * Updates a certificate creation operation that is already in progress. This operation requires the - * certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateCertificateOperationWithResponseAsync(String vaultBaseUrl, - String certificateName, boolean cancellationRequested) { - return FluxUtil.withContext(context -> updateCertificateOperationWithResponseAsync(vaultBaseUrl, - certificateName, cancellationRequested, context)); - } - - /** - * Updates a certificate operation. - * - * Updates a certificate creation operation that is already in progress. This operation requires the - * certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateCertificateOperationWithResponseAsync(String vaultBaseUrl, - String certificateName, boolean cancellationRequested, Context context) { - final String accept = "application/json"; - CertificateOperationUpdateParameter certificateOperation = new CertificateOperationUpdateParameter(); - certificateOperation.setCancellationRequested(cancellationRequested); - return service.updateCertificateOperation(vaultBaseUrl, certificateName, this.getApiVersion(), - certificateOperation, accept, context); - } - - /** - * Updates a certificate operation. - * - * Updates a certificate creation operation that is already in progress. This operation requires the - * certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, - boolean cancellationRequested) { - return updateCertificateOperationWithResponseAsync(vaultBaseUrl, certificateName, cancellationRequested) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Updates a certificate operation. - * - * Updates a certificate creation operation that is already in progress. This operation requires the - * certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateCertificateOperationAsync(String vaultBaseUrl, String certificateName, - boolean cancellationRequested, Context context) { - return updateCertificateOperationWithResponseAsync(vaultBaseUrl, certificateName, cancellationRequested, - context).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Updates a certificate operation. - * - * Updates a certificate creation operation that is already in progress. This operation requires the - * certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateCertificateOperationWithResponse(String vaultBaseUrl, - String certificateName, boolean cancellationRequested, Context context) { - final String accept = "application/json"; - CertificateOperationUpdateParameter certificateOperation = new CertificateOperationUpdateParameter(); - certificateOperation.setCancellationRequested(cancellationRequested); - return service.updateCertificateOperationSync(vaultBaseUrl, certificateName, this.getApiVersion(), - certificateOperation, accept, context); - } - - /** - * Updates a certificate operation. - * - * Updates a certificate creation operation that is already in progress. This operation requires the - * certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param cancellationRequested Indicates if cancellation was requested on the certificate operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateOperation updateCertificateOperation(String vaultBaseUrl, String certificateName, - boolean cancellationRequested) { - return updateCertificateOperationWithResponse(vaultBaseUrl, certificateName, cancellationRequested, - Context.NONE).getValue(); - } - - /** - * Gets the creation operation of a certificate. - * - * Gets the creation operation associated with a specified certificate. This operation requires the certificates/get - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the creation operation associated with a specified certificate along with {@link Response} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateOperationWithResponseAsync(String vaultBaseUrl, - String certificateName) { - return FluxUtil - .withContext(context -> getCertificateOperationWithResponseAsync(vaultBaseUrl, certificateName, context)); - } - - /** - * Gets the creation operation of a certificate. - * - * Gets the creation operation associated with a specified certificate. This operation requires the certificates/get - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the creation operation associated with a specified certificate along with {@link Response} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateOperationWithResponseAsync(String vaultBaseUrl, - String certificateName, Context context) { - final String accept = "application/json"; - return service.getCertificateOperation(vaultBaseUrl, certificateName, this.getApiVersion(), accept, context); - } - - /** - * Gets the creation operation of a certificate. - * - * Gets the creation operation associated with a specified certificate. This operation requires the certificates/get - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the creation operation associated with a specified certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificateOperationAsync(String vaultBaseUrl, String certificateName) { - return getCertificateOperationWithResponseAsync(vaultBaseUrl, certificateName) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Gets the creation operation of a certificate. - * - * Gets the creation operation associated with a specified certificate. This operation requires the certificates/get - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the creation operation associated with a specified certificate on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getCertificateOperationAsync(String vaultBaseUrl, String certificateName, - Context context) { - return getCertificateOperationWithResponseAsync(vaultBaseUrl, certificateName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Gets the creation operation of a certificate. - * - * Gets the creation operation associated with a specified certificate. This operation requires the certificates/get - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the creation operation associated with a specified certificate along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getCertificateOperationWithResponse(String vaultBaseUrl, - String certificateName, Context context) { - final String accept = "application/json"; - return service.getCertificateOperationSync(vaultBaseUrl, certificateName, this.getApiVersion(), accept, - context); - } - - /** - * Gets the creation operation of a certificate. - * - * Gets the creation operation associated with a specified certificate. This operation requires the certificates/get - * permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the creation operation associated with a specified certificate. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateOperation getCertificateOperation(String vaultBaseUrl, String certificateName) { - return getCertificateOperationWithResponse(vaultBaseUrl, certificateName, Context.NONE).getValue(); - } - - /** - * Deletes the creation operation for a specific certificate. - * - * Deletes the creation operation for a specified certificate that is in the process of being created. The - * certificate is no longer created. This operation requires the certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteCertificateOperationWithResponseAsync(String vaultBaseUrl, - String certificateName) { - return FluxUtil.withContext( - context -> deleteCertificateOperationWithResponseAsync(vaultBaseUrl, certificateName, context)); - } - - /** - * Deletes the creation operation for a specific certificate. - * - * Deletes the creation operation for a specified certificate that is in the process of being created. The - * certificate is no longer created. This operation requires the certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> deleteCertificateOperationWithResponseAsync(String vaultBaseUrl, - String certificateName, Context context) { - final String accept = "application/json"; - return service.deleteCertificateOperation(vaultBaseUrl, certificateName, this.getApiVersion(), accept, context); - } - - /** - * Deletes the creation operation for a specific certificate. - * - * Deletes the creation operation for a specified certificate that is in the process of being created. The - * certificate is no longer created. This operation requires the certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName) { - return deleteCertificateOperationWithResponseAsync(vaultBaseUrl, certificateName) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Deletes the creation operation for a specific certificate. - * - * Deletes the creation operation for a specified certificate that is in the process of being created. The - * certificate is no longer created. This operation requires the certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteCertificateOperationAsync(String vaultBaseUrl, String certificateName, - Context context) { - return deleteCertificateOperationWithResponseAsync(vaultBaseUrl, certificateName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Deletes the creation operation for a specific certificate. - * - * Deletes the creation operation for a specified certificate that is in the process of being created. The - * certificate is no longer created. This operation requires the certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response deleteCertificateOperationWithResponse(String vaultBaseUrl, - String certificateName, Context context) { - final String accept = "application/json"; - return service.deleteCertificateOperationSync(vaultBaseUrl, certificateName, this.getApiVersion(), accept, - context); - } - - /** - * Deletes the creation operation for a specific certificate. - * - * Deletes the creation operation for a specified certificate that is in the process of being created. The - * certificate is no longer created. This operation requires the certificates/update permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate operation is returned in case of asynchronous requests. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateOperation deleteCertificateOperation(String vaultBaseUrl, String certificateName) { - return deleteCertificateOperationWithResponse(vaultBaseUrl, certificateName, Context.NONE).getValue(); - } - - /** - * Merges a certificate or a certificate chain with a key pair existing on the server. - * - * The MergeCertificate operation performs the merging of a certificate or certificate chain with a key pair - * currently available in the service. This operation requires the certificates/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param x509Certificates The certificate or the certificate chain to merge. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> mergeCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, - Map tags) { - return FluxUtil.withContext(context -> mergeCertificateWithResponseAsync(vaultBaseUrl, certificateName, - x509Certificates, certificateAttributes, tags, context)); - } - - /** - * Merges a certificate or a certificate chain with a key pair existing on the server. - * - * The MergeCertificate operation performs the merging of a certificate or certificate chain with a key pair - * currently available in the service. This operation requires the certificates/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param x509Certificates The certificate or the certificate chain to merge. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> mergeCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, List x509Certificates, CertificateAttributes certificateAttributes, - Map tags, Context context) { - final String accept = "application/json"; - CertificateMergeParameters parameters = new CertificateMergeParameters(); - parameters.setX509Certificates(x509Certificates); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - return service.mergeCertificate(vaultBaseUrl, certificateName, this.getApiVersion(), parameters, accept, - context); - } - - /** - * Merges a certificate or a certificate chain with a key pair existing on the server. - * - * The MergeCertificate operation performs the merging of a certificate or certificate chain with a key pair - * currently available in the service. This operation requires the certificates/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param x509Certificates The certificate or the certificate chain to merge. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono mergeCertificateAsync(String vaultBaseUrl, String certificateName, - List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { - return mergeCertificateWithResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, - tags).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Merges a certificate or a certificate chain with a key pair existing on the server. - * - * The MergeCertificate operation performs the merging of a certificate or certificate chain with a key pair - * currently available in the service. This operation requires the certificates/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param x509Certificates The certificate or the certificate chain to merge. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono mergeCertificateAsync(String vaultBaseUrl, String certificateName, - List x509Certificates, CertificateAttributes certificateAttributes, Map tags, - Context context) { - return mergeCertificateWithResponseAsync(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, - tags, context).flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Merges a certificate or a certificate chain with a key pair existing on the server. - * - * The MergeCertificate operation performs the merging of a certificate or certificate chain with a key pair - * currently available in the service. This operation requires the certificates/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param x509Certificates The certificate or the certificate chain to merge. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response mergeCertificateWithResponse(String vaultBaseUrl, String certificateName, - List x509Certificates, CertificateAttributes certificateAttributes, Map tags, - Context context) { - final String accept = "application/json"; - CertificateMergeParameters parameters = new CertificateMergeParameters(); - parameters.setX509Certificates(x509Certificates); - parameters.setCertificateAttributes(certificateAttributes); - parameters.setTags(tags); - return service.mergeCertificateSync(vaultBaseUrl, certificateName, this.getApiVersion(), parameters, accept, - context); - } - - /** - * Merges a certificate or a certificate chain with a key pair existing on the server. - * - * The MergeCertificate operation performs the merging of a certificate or certificate chain with a key pair - * currently available in the service. This operation requires the certificates/create permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param x509Certificates The certificate or the certificate chain to merge. - * @param certificateAttributes The attributes of the certificate (optional). - * @param tags Application specific metadata in the form of key-value pairs. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateBundle mergeCertificate(String vaultBaseUrl, String certificateName, - List x509Certificates, CertificateAttributes certificateAttributes, Map tags) { - return mergeCertificateWithResponse(vaultBaseUrl, certificateName, x509Certificates, certificateAttributes, - tags, Context.NONE).getValue(); - } - - /** - * Backs up the specified certificate. - * - * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate - * will be downloaded. This operation requires the certificates/backup permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the backup certificate result, containing the backup blob along with {@link Response} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> backupCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName) { - return FluxUtil - .withContext(context -> backupCertificateWithResponseAsync(vaultBaseUrl, certificateName, context)); - } - - /** - * Backs up the specified certificate. - * - * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate - * will be downloaded. This operation requires the certificates/backup permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the backup certificate result, containing the backup blob along with {@link Response} on successful - * completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> backupCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, Context context) { - final String accept = "application/json"; - return service.backupCertificate(vaultBaseUrl, certificateName, this.getApiVersion(), accept, context); - } - - /** - * Backs up the specified certificate. - * - * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate - * will be downloaded. This operation requires the certificates/backup permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the backup certificate result, containing the backup blob on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono backupCertificateAsync(String vaultBaseUrl, String certificateName) { - return backupCertificateWithResponseAsync(vaultBaseUrl, certificateName) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Backs up the specified certificate. - * - * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate - * will be downloaded. This operation requires the certificates/backup permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the backup certificate result, containing the backup blob on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono backupCertificateAsync(String vaultBaseUrl, String certificateName, - Context context) { - return backupCertificateWithResponseAsync(vaultBaseUrl, certificateName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Backs up the specified certificate. - * - * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate - * will be downloaded. This operation requires the certificates/backup permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the backup certificate result, containing the backup blob along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response backupCertificateWithResponse(String vaultBaseUrl, String certificateName, - Context context) { - final String accept = "application/json"; - return service.backupCertificateSync(vaultBaseUrl, certificateName, this.getApiVersion(), accept, context); - } - - /** - * Backs up the specified certificate. - * - * Requests that a backup of the specified certificate be downloaded to the client. All versions of the certificate - * will be downloaded. This operation requires the certificates/backup permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the backup certificate result, containing the backup blob. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BackupCertificateResult backupCertificate(String vaultBaseUrl, String certificateName) { - return backupCertificateWithResponse(vaultBaseUrl, certificateName, Context.NONE).getValue(); - } - - /** - * Restores a backed up certificate to a vault. - * - * Restores a backed up certificate, and all its versions, to a vault. This operation requires the - * certificates/restore permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateBundleBackup The backup blob associated with a certificate bundle. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> restoreCertificateWithResponseAsync(String vaultBaseUrl, - byte[] certificateBundleBackup) { - return FluxUtil.withContext( - context -> restoreCertificateWithResponseAsync(vaultBaseUrl, certificateBundleBackup, context)); - } - - /** - * Restores a backed up certificate to a vault. - * - * Restores a backed up certificate, and all its versions, to a vault. This operation requires the - * certificates/restore permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateBundleBackup The backup blob associated with a certificate bundle. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> restoreCertificateWithResponseAsync(String vaultBaseUrl, - byte[] certificateBundleBackup, Context context) { - final String accept = "application/json"; - CertificateRestoreParameters parameters = new CertificateRestoreParameters(); - parameters.setCertificateBundleBackup(certificateBundleBackup); - return service.restoreCertificate(vaultBaseUrl, this.getApiVersion(), parameters, accept, context); - } - - /** - * Restores a backed up certificate to a vault. - * - * Restores a backed up certificate, and all its versions, to a vault. This operation requires the - * certificates/restore permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateBundleBackup The backup blob associated with a certificate bundle. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono restoreCertificateAsync(String vaultBaseUrl, byte[] certificateBundleBackup) { - return restoreCertificateWithResponseAsync(vaultBaseUrl, certificateBundleBackup) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Restores a backed up certificate to a vault. - * - * Restores a backed up certificate, and all its versions, to a vault. This operation requires the - * certificates/restore permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateBundleBackup The backup blob associated with a certificate bundle. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono restoreCertificateAsync(String vaultBaseUrl, byte[] certificateBundleBackup, - Context context) { - return restoreCertificateWithResponseAsync(vaultBaseUrl, certificateBundleBackup, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Restores a backed up certificate to a vault. - * - * Restores a backed up certificate, and all its versions, to a vault. This operation requires the - * certificates/restore permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateBundleBackup The backup blob associated with a certificate bundle. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response restoreCertificateWithResponse(String vaultBaseUrl, - byte[] certificateBundleBackup, Context context) { - final String accept = "application/json"; - CertificateRestoreParameters parameters = new CertificateRestoreParameters(); - parameters.setCertificateBundleBackup(certificateBundleBackup); - return service.restoreCertificateSync(vaultBaseUrl, this.getApiVersion(), parameters, accept, context); - } - - /** - * Restores a backed up certificate to a vault. - * - * Restores a backed up certificate, and all its versions, to a vault. This operation requires the - * certificates/restore permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateBundleBackup The backup blob associated with a certificate bundle. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateBundle restoreCertificate(String vaultBaseUrl, byte[] certificateBundleBackup) { - return restoreCertificateWithResponse(vaultBaseUrl, certificateBundleBackup, Context.NONE).getValue(); - } - - /** - * Lists the deleted certificates in the specified vault currently available for recovery. - * - * The GetDeletedCertificates operation retrieves the certificates in the current vault which are in a deleted state - * and ready for recovery or purging. This operation includes deletion-specific information. This operation requires - * the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of certificates that have been deleted in this vault along with {@link PagedResponse} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedCertificatesSinglePageAsync(String vaultBaseUrl, - Integer maxresults, Boolean includePending) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.getDeletedCertificates(vaultBaseUrl, maxresults, includePending, - this.getApiVersion(), accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Lists the deleted certificates in the specified vault currently available for recovery. - * - * The GetDeletedCertificates operation retrieves the certificates in the current vault which are in a deleted state - * and ready for recovery or purging. This operation includes deletion-specific information. This operation requires - * the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of certificates that have been deleted in this vault along with {@link PagedResponse} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedCertificatesSinglePageAsync(String vaultBaseUrl, - Integer maxresults, Boolean includePending, Context context) { - final String accept = "application/json"; - return service - .getDeletedCertificates(vaultBaseUrl, maxresults, includePending, this.getApiVersion(), accept, context) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Lists the deleted certificates in the specified vault currently available for recovery. - * - * The GetDeletedCertificates operation retrieves the certificates in the current vault which are in a deleted state - * and ready for recovery or purging. This operation includes deletion-specific information. This operation requires - * the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of certificates that have been deleted in this vault as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getDeletedCertificatesAsync(String vaultBaseUrl, Integer maxresults, - Boolean includePending) { - return new PagedFlux<>(() -> getDeletedCertificatesSinglePageAsync(vaultBaseUrl, maxresults, includePending), - nextLink -> getDeletedCertificatesNextSinglePageAsync(nextLink, vaultBaseUrl)); - } - - /** - * Lists the deleted certificates in the specified vault currently available for recovery. - * - * The GetDeletedCertificates operation retrieves the certificates in the current vault which are in a deleted state - * and ready for recovery or purging. This operation includes deletion-specific information. This operation requires - * the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of certificates that have been deleted in this vault as paginated response with {@link PagedFlux}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux getDeletedCertificatesAsync(String vaultBaseUrl, Integer maxresults, - Boolean includePending, Context context) { - return new PagedFlux<>( - () -> getDeletedCertificatesSinglePageAsync(vaultBaseUrl, maxresults, includePending, context), - nextLink -> getDeletedCertificatesNextSinglePageAsync(nextLink, vaultBaseUrl, context)); - } - - /** - * Lists the deleted certificates in the specified vault currently available for recovery. - * - * The GetDeletedCertificates operation retrieves the certificates in the current vault which are in a deleted state - * and ready for recovery or purging. This operation includes deletion-specific information. This operation requires - * the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of certificates that have been deleted in this vault along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getDeletedCertificatesSinglePage(String vaultBaseUrl, - Integer maxresults, Boolean includePending) { - final String accept = "application/json"; - Response res = service.getDeletedCertificatesSync(vaultBaseUrl, maxresults, - includePending, this.getApiVersion(), accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * Lists the deleted certificates in the specified vault currently available for recovery. - * - * The GetDeletedCertificates operation retrieves the certificates in the current vault which are in a deleted state - * and ready for recovery or purging. This operation includes deletion-specific information. This operation requires - * the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of certificates that have been deleted in this vault along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getDeletedCertificatesSinglePage(String vaultBaseUrl, - Integer maxresults, Boolean includePending, Context context) { - final String accept = "application/json"; - Response res = service.getDeletedCertificatesSync(vaultBaseUrl, maxresults, - includePending, this.getApiVersion(), accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * Lists the deleted certificates in the specified vault currently available for recovery. - * - * The GetDeletedCertificates operation retrieves the certificates in the current vault which are in a deleted state - * and ready for recovery or purging. This operation includes deletion-specific information. This operation requires - * the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of certificates that have been deleted in this vault as paginated response with - * {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getDeletedCertificates(String vaultBaseUrl, Integer maxresults, - Boolean includePending) { - return new PagedIterable<>( - () -> getDeletedCertificatesSinglePage(vaultBaseUrl, maxresults, includePending, Context.NONE), - nextLink -> getDeletedCertificatesNextSinglePage(nextLink, vaultBaseUrl)); - } - - /** - * Lists the deleted certificates in the specified vault currently available for recovery. - * - * The GetDeletedCertificates operation retrieves the certificates in the current vault which are in a deleted state - * and ready for recovery or purging. This operation includes deletion-specific information. This operation requires - * the certificates/get/list permission. This operation can only be enabled on soft-delete enabled vaults. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param maxresults Maximum number of results to return in a page. If not specified the service will return up to - * 25 results. - * @param includePending Specifies whether to include certificates which are not completely provisioned. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of certificates that have been deleted in this vault as paginated response with - * {@link PagedIterable}. - */ - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable getDeletedCertificates(String vaultBaseUrl, Integer maxresults, - Boolean includePending, Context context) { - return new PagedIterable<>( - () -> getDeletedCertificatesSinglePage(vaultBaseUrl, maxresults, includePending, context), - nextLink -> getDeletedCertificatesNextSinglePage(nextLink, vaultBaseUrl, context)); - } - - /** - * Retrieves information about the specified deleted certificate. - * - * The GetDeletedCertificate operation retrieves the deleted certificate information plus its attributes, such as - * retention interval, scheduled permanent deletion and the current deletion recovery level. This operation requires - * the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on - * when it will be purged along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName) { - return FluxUtil - .withContext(context -> getDeletedCertificateWithResponseAsync(vaultBaseUrl, certificateName, context)); - } - - /** - * Retrieves information about the specified deleted certificate. - * - * The GetDeletedCertificate operation retrieves the deleted certificate information plus its attributes, such as - * retention interval, scheduled permanent deletion and the current deletion recovery level. This operation requires - * the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on - * when it will be purged along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, Context context) { - final String accept = "application/json"; - return service.getDeletedCertificate(vaultBaseUrl, certificateName, this.getApiVersion(), accept, context); - } - - /** - * Retrieves information about the specified deleted certificate. - * - * The GetDeletedCertificate operation retrieves the deleted certificate information plus its attributes, such as - * retention interval, scheduled permanent deletion and the current deletion recovery level. This operation requires - * the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on - * when it will be purged on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getDeletedCertificateAsync(String vaultBaseUrl, String certificateName) { - return getDeletedCertificateWithResponseAsync(vaultBaseUrl, certificateName) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Retrieves information about the specified deleted certificate. - * - * The GetDeletedCertificate operation retrieves the deleted certificate information plus its attributes, such as - * retention interval, scheduled permanent deletion and the current deletion recovery level. This operation requires - * the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on - * when it will be purged on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getDeletedCertificateAsync(String vaultBaseUrl, String certificateName, - Context context) { - return getDeletedCertificateWithResponseAsync(vaultBaseUrl, certificateName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Retrieves information about the specified deleted certificate. - * - * The GetDeletedCertificate operation retrieves the deleted certificate information plus its attributes, such as - * retention interval, scheduled permanent deletion and the current deletion recovery level. This operation requires - * the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on - * when it will be purged along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getDeletedCertificateWithResponse(String vaultBaseUrl, - String certificateName, Context context) { - final String accept = "application/json"; - return service.getDeletedCertificateSync(vaultBaseUrl, certificateName, this.getApiVersion(), accept, context); - } - - /** - * Retrieves information about the specified deleted certificate. - * - * The GetDeletedCertificate operation retrieves the deleted certificate information plus its attributes, such as - * retention interval, scheduled permanent deletion and the current deletion recovery level. This operation requires - * the certificates/get permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on - * when it will be purged. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public DeletedCertificateBundle getDeletedCertificate(String vaultBaseUrl, String certificateName) { - return getDeletedCertificateWithResponse(vaultBaseUrl, certificateName, Context.NONE).getValue(); - } - - /** - * Permanently deletes the specified deleted certificate. - * - * The PurgeDeletedCertificate operation performs an irreversible deletion of the specified certificate, without - * possibility for recovery. The operation is not available if the recovery level does not specify 'Purgeable'. This - * operation requires the certificate/purge permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> purgeDeletedCertificateWithResponseAsync(String vaultBaseUrl, String certificateName) { - return FluxUtil - .withContext(context -> purgeDeletedCertificateWithResponseAsync(vaultBaseUrl, certificateName, context)); - } - - /** - * Permanently deletes the specified deleted certificate. - * - * The PurgeDeletedCertificate operation performs an irreversible deletion of the specified certificate, without - * possibility for recovery. The operation is not available if the recovery level does not specify 'Purgeable'. This - * operation requires the certificate/purge permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> purgeDeletedCertificateWithResponseAsync(String vaultBaseUrl, String certificateName, - Context context) { - final String accept = "application/json"; - return service.purgeDeletedCertificate(vaultBaseUrl, certificateName, this.getApiVersion(), accept, context); - } - - /** - * Permanently deletes the specified deleted certificate. - * - * The PurgeDeletedCertificate operation performs an irreversible deletion of the specified certificate, without - * possibility for recovery. The operation is not available if the recovery level does not specify 'Purgeable'. This - * operation requires the certificate/purge permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono purgeDeletedCertificateAsync(String vaultBaseUrl, String certificateName) { - return purgeDeletedCertificateWithResponseAsync(vaultBaseUrl, certificateName).flatMap(ignored -> Mono.empty()); - } - - /** - * Permanently deletes the specified deleted certificate. - * - * The PurgeDeletedCertificate operation performs an irreversible deletion of the specified certificate, without - * possibility for recovery. The operation is not available if the recovery level does not specify 'Purgeable'. This - * operation requires the certificate/purge permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono purgeDeletedCertificateAsync(String vaultBaseUrl, String certificateName, Context context) { - return purgeDeletedCertificateWithResponseAsync(vaultBaseUrl, certificateName, context) - .flatMap(ignored -> Mono.empty()); - } - - /** - * Permanently deletes the specified deleted certificate. - * - * The PurgeDeletedCertificate operation performs an irreversible deletion of the specified certificate, without - * possibility for recovery. The operation is not available if the recovery level does not specify 'Purgeable'. This - * operation requires the certificate/purge permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response purgeDeletedCertificateWithResponse(String vaultBaseUrl, String certificateName, - Context context) { - final String accept = "application/json"; - return service.purgeDeletedCertificateSync(vaultBaseUrl, certificateName, this.getApiVersion(), accept, - context); - } - - /** - * Permanently deletes the specified deleted certificate. - * - * The PurgeDeletedCertificate operation performs an irreversible deletion of the specified certificate, without - * possibility for recovery. The operation is not available if the recovery level does not specify 'Purgeable'. This - * operation requires the certificate/purge permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public void purgeDeletedCertificate(String vaultBaseUrl, String certificateName) { - purgeDeletedCertificateWithResponse(vaultBaseUrl, certificateName, Context.NONE); - } - - /** - * Recovers the deleted certificate back to its current version under /certificates. - * - * The RecoverDeletedCertificate operation performs the reversal of the Delete operation. The operation is - * applicable in vaults enabled for soft-delete, and must be issued during the retention interval (available in the - * deleted certificate's attributes). This operation requires the certificates/recover permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the deleted certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> recoverDeletedCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName) { - return FluxUtil - .withContext(context -> recoverDeletedCertificateWithResponseAsync(vaultBaseUrl, certificateName, context)); - } - - /** - * Recovers the deleted certificate back to its current version under /certificates. - * - * The RecoverDeletedCertificate operation performs the reversal of the Delete operation. The operation is - * applicable in vaults enabled for soft-delete, and must be issued during the retention interval (available in the - * deleted certificate's attributes). This operation requires the certificates/recover permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the deleted certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> recoverDeletedCertificateWithResponseAsync(String vaultBaseUrl, - String certificateName, Context context) { - final String accept = "application/json"; - return service.recoverDeletedCertificate(vaultBaseUrl, certificateName, this.getApiVersion(), accept, context); - } - - /** - * Recovers the deleted certificate back to its current version under /certificates. - * - * The RecoverDeletedCertificate operation performs the reversal of the Delete operation. The operation is - * applicable in vaults enabled for soft-delete, and must be issued during the retention interval (available in the - * deleted certificate's attributes). This operation requires the certificates/recover permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the deleted certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono recoverDeletedCertificateAsync(String vaultBaseUrl, String certificateName) { - return recoverDeletedCertificateWithResponseAsync(vaultBaseUrl, certificateName) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Recovers the deleted certificate back to its current version under /certificates. - * - * The RecoverDeletedCertificate operation performs the reversal of the Delete operation. The operation is - * applicable in vaults enabled for soft-delete, and must be issued during the retention interval (available in the - * deleted certificate's attributes). This operation requires the certificates/recover permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the deleted certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono recoverDeletedCertificateAsync(String vaultBaseUrl, String certificateName, - Context context) { - return recoverDeletedCertificateWithResponseAsync(vaultBaseUrl, certificateName, context) - .flatMap(res -> Mono.justOrEmpty(res.getValue())); - } - - /** - * Recovers the deleted certificate back to its current version under /certificates. - * - * The RecoverDeletedCertificate operation performs the reversal of the Delete operation. The operation is - * applicable in vaults enabled for soft-delete, and must be issued during the retention interval (available in the - * deleted certificate's attributes). This operation requires the certificates/recover permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the deleted certificate. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response recoverDeletedCertificateWithResponse(String vaultBaseUrl, - String certificateName, Context context) { - final String accept = "application/json"; - return service.recoverDeletedCertificateSync(vaultBaseUrl, certificateName, this.getApiVersion(), accept, - context); - } - - /** - * Recovers the deleted certificate back to its current version under /certificates. - * - * The RecoverDeletedCertificate operation performs the reversal of the Delete operation. The operation is - * applicable in vaults enabled for soft-delete, and must be issued during the retention interval (available in the - * deleted certificate's attributes). This operation requires the certificates/recover permission. - * - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param certificateName The name of the deleted certificate. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a certificate bundle consists of a certificate (X509) plus its attributes. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public CertificateBundle recoverDeletedCertificate(String vaultBaseUrl, String certificateName) { - return recoverDeletedCertificateWithResponse(vaultBaseUrl, certificateName, Context.NONE).getValue(); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificatesNextSinglePageAsync(String nextLink, - String vaultBaseUrl) { - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.getCertificatesNext(nextLink, vaultBaseUrl, accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificatesNextSinglePageAsync(String nextLink, String vaultBaseUrl, - Context context) { - final String accept = "application/json"; - return service.getCertificatesNext(nextLink, vaultBaseUrl, accept, context) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getCertificatesNextSinglePage(String nextLink, String vaultBaseUrl) { - final String accept = "application/json"; - Response res - = service.getCertificatesNextSync(nextLink, vaultBaseUrl, accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getCertificatesNextSinglePage(String nextLink, String vaultBaseUrl, - Context context) { - final String accept = "application/json"; - Response res = service.getCertificatesNextSync(nextLink, vaultBaseUrl, accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate issuer list result along with {@link PagedResponse} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateIssuersNextSinglePageAsync(String nextLink, - String vaultBaseUrl) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.getCertificateIssuersNext(nextLink, vaultBaseUrl, accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate issuer list result along with {@link PagedResponse} on successful completion of - * {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateIssuersNextSinglePageAsync(String nextLink, - String vaultBaseUrl, Context context) { - final String accept = "application/json"; - return service.getCertificateIssuersNext(nextLink, vaultBaseUrl, accept, context) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate issuer list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getCertificateIssuersNextSinglePage(String nextLink, - String vaultBaseUrl) { - final String accept = "application/json"; - Response res - = service.getCertificateIssuersNextSync(nextLink, vaultBaseUrl, accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate issuer list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getCertificateIssuersNextSinglePage(String nextLink, - String vaultBaseUrl, Context context) { - final String accept = "application/json"; - Response res - = service.getCertificateIssuersNextSync(nextLink, vaultBaseUrl, accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateVersionsNextSinglePageAsync(String nextLink, - String vaultBaseUrl) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.getCertificateVersionsNext(nextLink, vaultBaseUrl, accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getCertificateVersionsNextSinglePageAsync(String nextLink, - String vaultBaseUrl, Context context) { - final String accept = "application/json"; - return service.getCertificateVersionsNext(nextLink, vaultBaseUrl, accept, context) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getCertificateVersionsNextSinglePage(String nextLink, String vaultBaseUrl) { - final String accept = "application/json"; - Response res - = service.getCertificateVersionsNextSync(nextLink, vaultBaseUrl, accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the certificate list result along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getCertificateVersionsNextSinglePage(String nextLink, String vaultBaseUrl, - Context context) { - final String accept = "application/json"; - Response res - = service.getCertificateVersionsNextSync(nextLink, vaultBaseUrl, accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of certificates that have been deleted in this vault along with {@link PagedResponse} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedCertificatesNextSinglePageAsync(String nextLink, - String vaultBaseUrl) { - final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.getDeletedCertificatesNext(nextLink, vaultBaseUrl, accept, context)) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of certificates that have been deleted in this vault along with {@link PagedResponse} on - * successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getDeletedCertificatesNextSinglePageAsync(String nextLink, - String vaultBaseUrl, Context context) { - final String accept = "application/json"; - return service.getDeletedCertificatesNext(nextLink, vaultBaseUrl, accept, context) - .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null)); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of certificates that have been deleted in this vault along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getDeletedCertificatesNextSinglePage(String nextLink, - String vaultBaseUrl) { - final String accept = "application/json"; - Response res - = service.getDeletedCertificatesNextSync(nextLink, vaultBaseUrl, accept, Context.NONE); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } - - /** - * Get the next page of items. - * - * @param nextLink The URL to get the next list of items. - * @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net. - * @param context The context to associate with this operation. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws KeyVaultErrorException thrown if the request is rejected by server. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return a list of certificates that have been deleted in this vault along with {@link PagedResponse}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public PagedResponse getDeletedCertificatesNextSinglePage(String nextLink, - String vaultBaseUrl, Context context) { - final String accept = "application/json"; - Response res - = service.getDeletedCertificatesNextSync(nextLink, vaultBaseUrl, accept, context); - return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), - res.getValue().getValue(), res.getValue().getNextLink(), null); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificateIssuerHelper.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificateIssuerHelper.java deleted file mode 100644 index 9bd27f53f596..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificateIssuerHelper.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.security.keyvault.certificates.implementation; - -import com.azure.security.keyvault.certificates.implementation.models.IssuerBundle; -import com.azure.security.keyvault.certificates.models.CertificateIssuer; - -public final class CertificateIssuerHelper { - private static CertificateIssuerAccessor accessor; - - public interface CertificateIssuerAccessor { - CertificateIssuer createCertificateIssuer(IssuerBundle impl); - - IssuerBundle getImpl(CertificateIssuer certificateIssuer); - } - - public static CertificateIssuer createCertificateIssuer(IssuerBundle impl) { - if (accessor == null) { - new CertificateIssuer(""); - } - - assert accessor != null; - return accessor.createCertificateIssuer(impl); - } - - public static IssuerBundle getIssuerBundle(CertificateIssuer certificateIssuer) { - if (accessor == null) { - new CertificateIssuer(""); - } - - assert accessor != null; - return accessor.getImpl(certificateIssuer); - } - - public static void setAccessor(CertificateIssuerAccessor accessor) { - CertificateIssuerHelper.accessor = accessor; - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificateOperationHelper.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificateOperationHelper.java deleted file mode 100644 index a487cd21a404..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificateOperationHelper.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.security.keyvault.certificates.implementation; - -import com.azure.security.keyvault.certificates.models.CertificateOperation; - -public final class CertificateOperationHelper { - private static CertificateOperationAccessor accessor; - - public interface CertificateOperationAccessor { - CertificateOperation createCertificateOperation( - com.azure.security.keyvault.certificates.implementation.models.CertificateOperation impl); - } - - public static CertificateOperation createCertificateOperation( - com.azure.security.keyvault.certificates.implementation.models.CertificateOperation impl) { - if (accessor == null) { - new CertificateOperation(); - } - - assert accessor != null; - return accessor.createCertificateOperation(impl); - } - - public static void setAccessor(CertificateOperationAccessor accessor) { - CertificateOperationHelper.accessor = accessor; - } - - private CertificateOperationHelper() { - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificatePolicyHelper.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificatePolicyHelper.java deleted file mode 100644 index 9cd64fcccb64..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificatePolicyHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.security.keyvault.certificates.implementation; - -import com.azure.security.keyvault.certificates.models.CertificatePolicy; - -public final class CertificatePolicyHelper { - private static CertificatePolicyAccessor accessor; - - public interface CertificatePolicyAccessor { - CertificatePolicy - createPolicy(com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy impl); - - com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy - getPolicy(CertificatePolicy policy); - } - - public static CertificatePolicy - createCertificatePolicy(com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy impl) { - if (accessor == null) { - new CertificatePolicy("", ""); - } - - assert accessor != null; - return accessor.createPolicy(impl); - } - - public static com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy - getImplCertificatePolicy(CertificatePolicy policy) { - if (accessor == null) { - new CertificatePolicy("", ""); - } - - assert accessor != null; - return accessor.getPolicy(policy); - } - - public static void setAccessor(CertificatePolicyAccessor accessor) { - CertificatePolicyHelper.accessor = accessor; - } - - private CertificatePolicyHelper() { - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificatePropertiesHelper.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificatePropertiesHelper.java deleted file mode 100644 index 690dd442f312..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificatePropertiesHelper.java +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.security.keyvault.certificates.implementation; - -import com.azure.security.keyvault.certificates.implementation.models.CertificateItem; -import com.azure.security.keyvault.certificates.models.CertificateProperties; -import com.azure.security.keyvault.certificates.models.DeletedCertificate; - -public final class CertificatePropertiesHelper { - private static CertificatePropertiesAccessor accessor; - - public interface CertificatePropertiesAccessor { - CertificateProperties createCertificateProperties(CertificateItem item); - } - - public static CertificateProperties createCertificateProperties(CertificateItem item) { - if (accessor == null) { - // CertificateProperties doesn't have a public constructor but DeletedCertificate does and creates an - // instance of CertificateProperties. This will result in CertificateProperties being loaded by the class - // loader. - new DeletedCertificate(); - } - - assert accessor != null; - return accessor.createCertificateProperties(item); - } - - public static void setAccessor(CertificatePropertiesAccessor accessor) { - CertificatePropertiesHelper.accessor = accessor; - } - - private CertificatePropertiesHelper() { - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificatesUtils.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificatesUtils.java deleted file mode 100644 index 0b852ba7b2b6..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/CertificatesUtils.java +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.security.keyvault.certificates.implementation; - -import com.azure.core.util.CoreUtils; -import com.azure.core.util.logging.ClientLogger; - -import java.net.MalformedURLException; -import java.net.URL; - -/** - * Utility methods for Key Vault Certificates. - */ -public final class CertificatesUtils { - public static IdMetadata getIdMetadata(String id, int vaultUrlIndex, int nameIndex, int versionIndex, - ClientLogger logger) { - if (CoreUtils.isNullOrEmpty(id)) { - return new IdMetadata(id, null, null, null); - } - - try { - URL url = new URL(id); - String[] tokens = url.getPath().split("/"); - return new IdMetadata(id, getIdMetadataPiece(tokens, vaultUrlIndex), getIdMetadataPiece(tokens, nameIndex), - getIdMetadataPiece(tokens, versionIndex)); - } catch (MalformedURLException e) { - // Should never come here. - logger.error("Received Malformed Secret Id URL from KV Service"); - return new IdMetadata(id, null, null, null); - } - } - - private static String getIdMetadataPiece(String[] pieces, int index) { - if (index == -1) { - return null; - } - - return pieces.length >= index + 1 ? pieces[index] : null; - } - - private CertificatesUtils() { - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/DeletedCertificateHelper.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/DeletedCertificateHelper.java deleted file mode 100644 index a1d4400de644..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/DeletedCertificateHelper.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.security.keyvault.certificates.implementation; - -import com.azure.security.keyvault.certificates.implementation.models.DeletedCertificateBundle; -import com.azure.security.keyvault.certificates.implementation.models.DeletedCertificateItem; -import com.azure.security.keyvault.certificates.models.DeletedCertificate; - -public final class DeletedCertificateHelper { - private static DeletedCertificateAccessor accessor; - - public interface DeletedCertificateAccessor { - DeletedCertificate createDeletedCertificate(DeletedCertificateItem item); - - DeletedCertificate createDeletedCertificate(DeletedCertificateBundle bundle); - } - - public static DeletedCertificate createDeletedCertificate(DeletedCertificateItem item) { - if (accessor == null) { - new DeletedCertificate(); - } - - assert accessor != null; - return accessor.createDeletedCertificate(item); - } - - public static DeletedCertificate createDeletedCertificate(DeletedCertificateBundle bundle) { - if (accessor == null) { - new DeletedCertificate(); - } - - assert accessor != null; - return accessor.createDeletedCertificate(bundle); - } - - public static void setAccessor(DeletedCertificateAccessor accessor) { - DeletedCertificateHelper.accessor = accessor; - } - - private DeletedCertificateHelper() { - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/IdMetadata.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/IdMetadata.java deleted file mode 100644 index af0240c85877..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/IdMetadata.java +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.security.keyvault.certificates.implementation; - -/** - * Model class containing metadata about a certificate identifier. - *

- * Creation of this class splits the ID into the sub parts vault URL, name, anc version. - */ -public final class IdMetadata { - private final String id; - private final String vaultUrl; - private final String name; - private final String version; - - IdMetadata(String id, String vaultUrl, String name, String version) { - this.id = id; - this.vaultUrl = vaultUrl; - this.name = name; - this.version = version; - } - - /** - * Get the full identifier of the certificate. - * - * @return the id of the certificate. - */ - public String getId() { - return id; - } - - /** - * Get the vault url of the certificate. - * - * @return the vault url. - */ - public String getVaultUrl() { - return vaultUrl; - } - - /** - * Get the name of the certificate. - * - * @return the name of the certificate. - */ - public String getName() { - return name; - } - - /** - * Get the version of the certificate. - * - * @return the version of the certificate. - */ - public String getVersion() { - return version; - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/IssuerPropertiesHelper.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/IssuerPropertiesHelper.java deleted file mode 100644 index ab8404812ace..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/IssuerPropertiesHelper.java +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.security.keyvault.certificates.implementation; - -import com.azure.security.keyvault.certificates.implementation.models.CertificateIssuerItem; -import com.azure.security.keyvault.certificates.models.IssuerProperties; - -public final class IssuerPropertiesHelper { - private static IssuerPropertiesAccessor accessor; - - public interface IssuerPropertiesAccessor { - IssuerProperties createIssuerProperties(CertificateIssuerItem impl); - } - - public static IssuerProperties createIssuerProperties(CertificateIssuerItem impl) { - if (accessor == null) { - new IssuerProperties(); - } - - assert accessor != null; - return accessor.createIssuerProperties(impl); - } - - public static void setAccessor(IssuerPropertiesAccessor accessor) { - IssuerPropertiesHelper.accessor = accessor; - } - - private IssuerPropertiesHelper() { - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/KeyVaultCertificateWithPolicyHelper.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/KeyVaultCertificateWithPolicyHelper.java deleted file mode 100644 index 71fb5f49288f..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/KeyVaultCertificateWithPolicyHelper.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.security.keyvault.certificates.implementation; - -import com.azure.security.keyvault.certificates.implementation.models.CertificateBundle; -import com.azure.security.keyvault.certificates.models.DeletedCertificate; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy; - -public final class KeyVaultCertificateWithPolicyHelper { - private static KeyVaultCertificateWithPolicyAccessor accessor; - - public interface KeyVaultCertificateWithPolicyAccessor { - KeyVaultCertificateWithPolicy createCertificateWithPolicy(CertificateBundle bundle); - } - - public static KeyVaultCertificateWithPolicy createCertificateWithPolicy(CertificateBundle bundle) { - if (accessor == null) { - // KeyVaultCertificateWithPolicy doesn't have a public constructor but DeletedCertificate does and is a - // subtype of it. This will result in KeyVaultCertificateWithPolicy being loaded by the class loader. - new DeletedCertificate(); - } - - assert accessor != null; - return accessor.createCertificateWithPolicy(bundle); - } - - public static void setAccessor(KeyVaultCertificateWithPolicyAccessor accessor) { - KeyVaultCertificateWithPolicyHelper.accessor = accessor; - } - - private KeyVaultCertificateWithPolicyHelper() { - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/KeyVaultCredentialPolicy.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/KeyVaultCredentialPolicy.java deleted file mode 100644 index 27a9c1d5ffa5..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/KeyVaultCredentialPolicy.java +++ /dev/null @@ -1,526 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.security.keyvault.certificates.implementation; - -import com.azure.core.credential.TokenCredential; -import com.azure.core.credential.TokenRequestContext; -import com.azure.core.http.HttpPipelineCallContext; -import com.azure.core.http.HttpPipelineNextPolicy; -import com.azure.core.http.HttpPipelineNextSyncPolicy; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; -import com.azure.core.util.Base64Util; -import com.azure.core.util.BinaryData; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.logging.ClientLogger; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import static com.azure.core.http.HttpHeaderName.CONTENT_LENGTH; -import static com.azure.core.http.HttpHeaderName.WWW_AUTHENTICATE; - -/** - * A policy that authenticates requests with the Azure Key Vault service. The content added by this policy is - * leveraged in {@link TokenCredential} to get and set the correct "Authorization" header value. - * - * @see TokenCredential - */ -public class KeyVaultCredentialPolicy extends BearerTokenAuthenticationPolicy { - private static final ClientLogger LOGGER = new ClientLogger(KeyVaultCredentialPolicy.class); - private static final String BEARER_TOKEN_PREFIX = "Bearer "; - private static final String KEY_VAULT_STASHED_CONTENT_KEY = "KeyVaultCredentialPolicyStashedBody"; - private static final String KEY_VAULT_STASHED_CONTENT_LENGTH_KEY = "KeyVaultCredentialPolicyStashedContentLength"; - private static final ConcurrentMap CHALLENGE_CACHE = new ConcurrentHashMap<>(); - private ChallengeParameters challenge; - private final boolean disableChallengeResourceVerification; - - /** - * Creates a {@link KeyVaultCredentialPolicy}. - * - * @param credential The token credential to authenticate the request. - */ - public KeyVaultCredentialPolicy(TokenCredential credential, boolean disableChallengeResourceVerification) { - super(credential); - - this.disableChallengeResourceVerification = disableChallengeResourceVerification; - } - - /** - * Extracts attributes off the bearer challenge in the authentication header. - * - * @param authenticateHeader The authentication header containing the challenge. - * @param authChallengePrefix The authentication challenge name. - * - * @return A challenge attributes map. - */ - private static Map extractChallengeAttributes(String authenticateHeader, - String authChallengePrefix) { - if (!isBearerChallenge(authenticateHeader, authChallengePrefix)) { - return Collections.emptyMap(); - } - - String[] attributes = authenticateHeader.replace("\"", "").substring(authChallengePrefix.length()).split(","); - Map attributeMap = new HashMap<>(); - - for (String pair : attributes) { - // Using trim is ugly, but we need it here because currently the 'claims' attribute comes after two spaces. - String[] keyValue = pair.trim().split("=", 2); - - attributeMap.put(keyValue[0], keyValue[1]); - } - - return attributeMap; - } - - /** - * Verifies whether a challenge is bearer or not. - * - * @param authenticateHeader The authentication header containing all the challenges. - * @param authChallengePrefix The authentication challenge name. - * - * @return A boolean indicating if the challenge is a bearer challenge or not. - */ - private static boolean isBearerChallenge(String authenticateHeader, String authChallengePrefix) { - return (!CoreUtils.isNullOrEmpty(authenticateHeader) - && authenticateHeader.toLowerCase(Locale.ROOT).startsWith(authChallengePrefix.toLowerCase(Locale.ROOT))); - } - - @Override - public Mono authorizeRequest(HttpPipelineCallContext context) { - return Mono.defer(() -> { - HttpRequest request = context.getHttpRequest(); - - // If this policy doesn't have challenge parameters cached try to get it from the static challenge cache. - if (this.challenge == null) { - this.challenge = CHALLENGE_CACHE.get(getRequestAuthority(request)); - } - - if (this.challenge != null) { - // We fetched the challenge from the cache, but we have not initialized the scopes in the base yet. - TokenRequestContext tokenRequestContext - = new TokenRequestContext().addScopes(this.challenge.getScopes()) - .setTenantId(this.challenge.getTenantId()) - .setCaeEnabled(true); - - return setAuthorizationHeader(context, tokenRequestContext); - } - - // The body is removed from the initial request because Key Vault supports other authentication schemes - // which also protect the body of the request. As a result, before we know the auth scheme we need to - // avoid sending an unprotected body to Key Vault. We don't currently support this enhanced auth scheme - // in the SDK, but we still don't want to send any unprotected data to vaults which require it. - - // Do not overwrite previous contents if retrying after initial request failed (e.g. timeout). - if (!context.getData(KEY_VAULT_STASHED_CONTENT_KEY).isPresent()) { - if (request.getBody() != null) { - context.setData(KEY_VAULT_STASHED_CONTENT_KEY, request.getBody()); - context.setData(KEY_VAULT_STASHED_CONTENT_LENGTH_KEY, - request.getHeaders().getValue(CONTENT_LENGTH)); - request.setHeader(CONTENT_LENGTH, "0"); - request.setBody((Flux) null); - } - } - - return Mono.empty(); - }); - } - - @SuppressWarnings("unchecked") - @Override - public Mono authorizeRequestOnChallenge(HttpPipelineCallContext context, HttpResponse response) { - return Mono.defer(() -> { - HttpRequest request = context.getHttpRequest(); - Optional contentOptional = context.getData(KEY_VAULT_STASHED_CONTENT_KEY); - Optional contentLengthOptional = context.getData(KEY_VAULT_STASHED_CONTENT_LENGTH_KEY); - - if (request.getBody() == null && contentOptional.isPresent() && contentLengthOptional.isPresent()) { - request.setBody((Flux) contentOptional.get()); - request.setHeader(CONTENT_LENGTH, (String) contentLengthOptional.get()); - } - - String authority = getRequestAuthority(request); - Map challengeAttributes - = extractChallengeAttributes(response.getHeaderValue(WWW_AUTHENTICATE), BEARER_TOKEN_PREFIX); - String scope = challengeAttributes.get("resource"); - - if (scope != null) { - scope = scope + "/.default"; - } else { - scope = challengeAttributes.get("scope"); - } - - if (scope == null) { - this.challenge = CHALLENGE_CACHE.get(authority); - - if (this.challenge == null) { - return Mono.just(false); - } - } else { - if (!disableChallengeResourceVerification) { - if (!isChallengeResourceValid(request, scope)) { - throw LOGGER.logExceptionAsError(new RuntimeException(String - .format("The challenge resource '%s' does not match the requested domain. If you wish to " - + "disable this check for your client, pass 'true' to the SecretClientBuilder" - + ".disableChallengeResourceVerification() method when building it. See " - + "https://aka.ms/azsdk/blog/vault-uri for more information.", scope))); - } - } - - String authorization = challengeAttributes.get("authorization"); - - if (authorization == null) { - authorization = challengeAttributes.get("authorization_uri"); - } - - final URI authorizationUri; - - try { - authorizationUri = new URI(authorization); - } catch (URISyntaxException e) { - throw LOGGER.logExceptionAsError(new RuntimeException( - String.format("The challenge authorization URI '%s' is invalid.", authorization), e)); - } - - this.challenge = new ChallengeParameters(authorizationUri, new String[] { scope }); - - CHALLENGE_CACHE.put(authority, this.challenge); - } - - TokenRequestContext tokenRequestContext = new TokenRequestContext().addScopes(this.challenge.getScopes()) - .setTenantId(this.challenge.getTenantId()) - .setCaeEnabled(true); - - String error = challengeAttributes.get("error"); - - if (error != null) { - LOGGER.verbose("The challenge response contained an error: {}", error); - - if ("insufficient_claims".equalsIgnoreCase(error)) { - String claims = challengeAttributes.get("claims"); - - if (claims != null) { - tokenRequestContext - .setClaims(new String(Base64Util.decodeString(claims), StandardCharsets.UTF_8)); - } - } - } - - return setAuthorizationHeader(context, tokenRequestContext).then(Mono.just(true)); - }); - } - - @Override - public void authorizeRequestSync(HttpPipelineCallContext context) { - HttpRequest request = context.getHttpRequest(); - - // If this policy doesn't have challenge parameters cached try to get it from the static challenge cache. - if (this.challenge == null) { - this.challenge = CHALLENGE_CACHE.get(getRequestAuthority(request)); - } - - if (this.challenge != null) { - // We fetched the challenge from the cache, but we have not initialized the scopes in the base yet. - TokenRequestContext tokenRequestContext = new TokenRequestContext().addScopes(this.challenge.getScopes()) - .setTenantId(this.challenge.getTenantId()) - .setCaeEnabled(true); - - setAuthorizationHeaderSync(context, tokenRequestContext); - - return; - } - - // The body is removed from the initial request because Key Vault supports other authentication schemes which - // also protect the body of the request. As a result, before we know the auth scheme we need to avoid sending an - // unprotected body to Key Vault. We don't currently support this enhanced auth scheme in the SDK, but we still - // don't want to send any unprotected data to vaults which require it. - - // Do not overwrite previous contents if retrying after initial request failed (e.g. timeout). - if (!context.getData(KEY_VAULT_STASHED_CONTENT_KEY).isPresent()) { - if (request.getBodyAsBinaryData() != null) { - context.setData(KEY_VAULT_STASHED_CONTENT_KEY, request.getBodyAsBinaryData()); - context.setData(KEY_VAULT_STASHED_CONTENT_LENGTH_KEY, request.getHeaders().getValue(CONTENT_LENGTH)); - request.setHeader(CONTENT_LENGTH, "0"); - request.setBody((BinaryData) null); - } - } - } - - @Override - public boolean authorizeRequestOnChallengeSync(HttpPipelineCallContext context, HttpResponse response) { - HttpRequest request = context.getHttpRequest(); - Optional contentOptional = context.getData(KEY_VAULT_STASHED_CONTENT_KEY); - Optional contentLengthOptional = context.getData(KEY_VAULT_STASHED_CONTENT_LENGTH_KEY); - - if (request.getBody() == null && contentOptional.isPresent() && contentLengthOptional.isPresent()) { - request.setBody((BinaryData) (contentOptional.get())); - request.setHeader(CONTENT_LENGTH, (String) contentLengthOptional.get()); - } - - String authority = getRequestAuthority(request); - Map challengeAttributes - = extractChallengeAttributes(response.getHeaderValue(WWW_AUTHENTICATE), BEARER_TOKEN_PREFIX); - String scope = challengeAttributes.get("resource"); - - if (scope != null) { - scope = scope + "/.default"; - } else { - scope = challengeAttributes.get("scope"); - } - - if (scope == null) { - this.challenge = CHALLENGE_CACHE.get(authority); - - if (this.challenge == null) { - return false; - } - } else { - if (!disableChallengeResourceVerification) { - if (!isChallengeResourceValid(request, scope)) { - throw LOGGER.logExceptionAsError(new RuntimeException(String.format( - "The challenge resource '%s' does not match the requested domain. If you wish to disable " - + "this check for your client, pass 'true' to the SecretClientBuilder" - + ".disableChallengeResourceVerification() method when building it. See " - + "https://aka.ms/azsdk/blog/vault-uri for more information.", - scope))); - } - } - - String authorization = challengeAttributes.get("authorization"); - - if (authorization == null) { - authorization = challengeAttributes.get("authorization_uri"); - } - - final URI authorizationUri; - - try { - authorizationUri = new URI(authorization); - } catch (URISyntaxException e) { - throw LOGGER.logExceptionAsError(new RuntimeException( - String.format("The challenge authorization URI '%s' is invalid.", authorization), e)); - } - - this.challenge = new ChallengeParameters(authorizationUri, new String[] { scope }); - - CHALLENGE_CACHE.put(authority, this.challenge); - } - - TokenRequestContext tokenRequestContext = new TokenRequestContext().addScopes(this.challenge.getScopes()) - .setTenantId(this.challenge.getTenantId()) - .setCaeEnabled(true); - - String error = challengeAttributes.get("error"); - - if (error != null) { - LOGGER.verbose("The challenge response contained an error: {}", error); - - if ("insufficient_claims".equalsIgnoreCase(error)) { - String claims = challengeAttributes.get("claims"); - - if (claims != null) { - tokenRequestContext.setClaims(new String(Base64Util.decodeString(claims))); - } - } - } - - setAuthorizationHeaderSync(context, tokenRequestContext); - - return true; - } - - @Override - public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { - if (!"https".equals(context.getHttpRequest().getUrl().getProtocol())) { - return Mono.error(new RuntimeException("Token credentials require a URL using the HTTPS protocol scheme.")); - } - - HttpPipelineNextPolicy nextPolicy = next.clone(); - - return authorizeRequest(context).then(Mono.defer(next::process)).flatMap(httpResponse -> { - String authHeader = httpResponse.getHeaderValue(WWW_AUTHENTICATE); - - if (httpResponse.getStatusCode() == 401 && authHeader != null) { - return handleChallenge(context, httpResponse, nextPolicy); - } - - return Mono.just(httpResponse); - }); - } - - @Override - public HttpResponse processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next) { - if (!"https".equals(context.getHttpRequest().getUrl().getProtocol())) { - throw LOGGER.logExceptionAsError( - new RuntimeException("Token credentials require a URL using the HTTPS protocol scheme.")); - } - - HttpPipelineNextSyncPolicy nextPolicy = next.clone(); - - authorizeRequestSync(context); - - HttpResponse httpResponse = next.processSync(); - String authHeader = httpResponse.getHeaderValue(WWW_AUTHENTICATE); - - if (httpResponse.getStatusCode() == 401 && authHeader != null) { - return handleChallengeSync(context, httpResponse, nextPolicy); - } - - return httpResponse; - } - - private Mono handleChallenge(HttpPipelineCallContext context, HttpResponse httpResponse, - HttpPipelineNextPolicy next) { - return authorizeRequestOnChallenge(context, httpResponse).flatMap(authorized -> { - if (authorized) { - // The body needs to be closed or read to the end to release the connection. - httpResponse.close(); - - HttpPipelineNextPolicy nextPolicy = next.clone(); - - return next.process().flatMap(newResponse -> { - String authHeader = newResponse.getHeaderValue(WWW_AUTHENTICATE); - - if (newResponse.getStatusCode() == 401 - && authHeader != null - && isClaimsPresent(newResponse) - && !isClaimsPresent(httpResponse)) { - - return handleChallenge(context, newResponse, nextPolicy); - } else { - return Mono.just(newResponse); - } - }); - } - - return Mono.just(httpResponse); - }); - } - - private HttpResponse handleChallengeSync(HttpPipelineCallContext context, HttpResponse httpResponse, - HttpPipelineNextSyncPolicy next) { - if (authorizeRequestOnChallengeSync(context, httpResponse)) { - // The body needs to be closed or read to the end to release the connection. - httpResponse.close(); - - HttpPipelineNextSyncPolicy nextPolicy = next.clone(); - HttpResponse newResponse = next.processSync(); - String authHeader = newResponse.getHeaderValue(WWW_AUTHENTICATE); - - if (newResponse.getStatusCode() == 401 - && authHeader != null - && isClaimsPresent(newResponse) - && !isClaimsPresent(httpResponse)) { - - return handleChallengeSync(context, newResponse, nextPolicy); - } - - return newResponse; - } - - return httpResponse; - } - - private boolean isClaimsPresent(HttpResponse httpResponse) { - Map challengeAttributes - = extractChallengeAttributes(httpResponse.getHeaderValue(WWW_AUTHENTICATE), BEARER_TOKEN_PREFIX); - - String error = challengeAttributes.get("error"); - - if (error != null) { - String base64Claims = challengeAttributes.get("claims"); - - return "insufficient_claims".equalsIgnoreCase(error) && base64Claims != null; - } - - return false; - } - - private static class ChallengeParameters { - private final URI authorizationUri; - private final String tenantId; - private final String[] scopes; - - ChallengeParameters(URI authorizationUri, String[] scopes) { - this.authorizationUri = authorizationUri; - tenantId = authorizationUri.getPath().split("/")[1]; - this.scopes = scopes; - } - - /** - * Get the {@code authorization} or {@code authorization_uri} parameter from the challenge response. - */ - public URI getAuthorizationUri() { - return authorizationUri; - } - - /** - * Get the {@code resource} or {@code scope} parameter from the challenge response. This should end with - * "/.default". - */ - public String[] getScopes() { - return scopes; - } - - /** - * Get the tenant ID from {@code authorizationUri}. - */ - public String getTenantId() { - return tenantId; - } - } - - public static void clearCache() { - CHALLENGE_CACHE.clear(); - } - - /** - * Gets the host name and port of the Key Vault or Managed HSM endpoint. - * - * @param request The {@link HttpRequest} to extract the host name and port from. - * - * @return The host name and port of the Key Vault or Managed HSM endpoint. - */ - private static String getRequestAuthority(HttpRequest request) { - URL url = request.getUrl(); - String authority = url.getAuthority(); - int port = url.getPort(); - - // Append port for complete authority. - if (!authority.contains(":") && port > 0) { - authority = authority + ":" + port; - } - - return authority; - } - - private static boolean isChallengeResourceValid(HttpRequest request, String scope) { - final URI scopeUri; - - try { - scopeUri = new URI(scope); - } catch (URISyntaxException e) { - throw LOGGER.logExceptionAsError( - new RuntimeException(String.format("The challenge resource '%s' is not a valid URI.", scope), e)); - } - - // Returns false if the host specified in the scope does not match the requested domain. - return request.getUrl() - .getHost() - .toLowerCase(Locale.ROOT) - .endsWith("." + scopeUri.getHost().toLowerCase(Locale.ROOT)); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/KeyVaultErrorCodeStrings.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/KeyVaultErrorCodeStrings.java deleted file mode 100644 index 1e9ad99ab5ba..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/KeyVaultErrorCodeStrings.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.implementation; - -public final class KeyVaultErrorCodeStrings { - public static final String CREDENTIALS_REQUIRED = "Azure Key Vault credentials are required."; - public static final String VAULT_END_POINT_REQUIRED = "Azure Key Vault endpoint url is required."; - public static final String PARAMETER_REQUIRED = "%s cannot be null."; -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/Action.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/Action.java deleted file mode 100644 index 1d2be598f24a..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/Action.java +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.models.CertificatePolicyAction; -import java.io.IOException; - -/** - * The action that will be executed. - */ -@Fluent -public final class Action implements JsonSerializable { - /* - * The type of the action. - */ - private CertificatePolicyAction actionType; - - /** - * Creates an instance of Action class. - */ - public Action() { - } - - /** - * Get the actionType property: The type of the action. - * - * @return the actionType value. - */ - public CertificatePolicyAction getActionType() { - return this.actionType; - } - - /** - * Set the actionType property: The type of the action. - * - * @param actionType the actionType value to set. - * @return the Action object itself. - */ - public Action setActionType(CertificatePolicyAction actionType) { - this.actionType = actionType; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("action_type", this.actionType == null ? null : this.actionType.toString()); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of Action from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of Action if the JsonReader was pointing to an instance of it, or null if it was pointing to - * JSON null. - * @throws IOException If an error occurs while reading the Action. - */ - public static Action fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - Action deserializedAction = new Action(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("action_type".equals(fieldName)) { - deserializedAction.actionType = CertificatePolicyAction.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } - - return deserializedAction; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/Attributes.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/Attributes.java deleted file mode 100644 index 28ec25a8a0c1..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/Attributes.java +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; - -/** - * The object attributes managed by the KeyVault service. - */ -@Fluent -public class Attributes implements JsonSerializable { - /* - * Determines whether the object is enabled. - */ - private Boolean enabled; - - /* - * Not before date in UTC. - */ - private Long notBefore; - - /* - * Expiry date in UTC. - */ - private Long expires; - - /* - * Creation time in UTC. - */ - private Long created; - - /* - * Last updated time in UTC. - */ - private Long updated; - - /** - * Creates an instance of Attributes class. - */ - public Attributes() { - } - - /** - * Get the enabled property: Determines whether the object is enabled. - * - * @return the enabled value. - */ - public Boolean isEnabled() { - return this.enabled; - } - - /** - * Set the enabled property: Determines whether the object is enabled. - * - * @param enabled the enabled value to set. - * @return the Attributes object itself. - */ - public Attributes setEnabled(Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Get the notBefore property: Not before date in UTC. - * - * @return the notBefore value. - */ - public OffsetDateTime getNotBefore() { - if (this.notBefore == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.notBefore), ZoneOffset.UTC); - } - - /** - * Set the notBefore property: Not before date in UTC. - * - * @param notBefore the notBefore value to set. - * @return the Attributes object itself. - */ - public Attributes setNotBefore(OffsetDateTime notBefore) { - if (notBefore == null) { - this.notBefore = null; - } else { - this.notBefore = notBefore.toEpochSecond(); - } - return this; - } - - /** - * Get the expires property: Expiry date in UTC. - * - * @return the expires value. - */ - public OffsetDateTime getExpires() { - if (this.expires == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.expires), ZoneOffset.UTC); - } - - /** - * Set the expires property: Expiry date in UTC. - * - * @param expires the expires value to set. - * @return the Attributes object itself. - */ - public Attributes setExpires(OffsetDateTime expires) { - if (expires == null) { - this.expires = null; - } else { - this.expires = expires.toEpochSecond(); - } - return this; - } - - /** - * Get the created property: Creation time in UTC. - * - * @return the created value. - */ - public OffsetDateTime getCreated() { - if (this.created == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.created), ZoneOffset.UTC); - } - - /** - * Set the created property: Creation time in UTC. - * - * @param created the created value to set. - * @return the Attributes object itself. - */ - Attributes setCreated(OffsetDateTime created) { - if (created == null) { - this.created = null; - } else { - this.created = created.toEpochSecond(); - } - return this; - } - - /** - * Get the updated property: Last updated time in UTC. - * - * @return the updated value. - */ - public OffsetDateTime getUpdated() { - if (this.updated == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.updated), ZoneOffset.UTC); - } - - /** - * Set the updated property: Last updated time in UTC. - * - * @param updated the updated value to set. - * @return the Attributes object itself. - */ - Attributes setUpdated(OffsetDateTime updated) { - if (updated == null) { - this.updated = null; - } else { - this.updated = updated.toEpochSecond(); - } - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeBooleanField("enabled", this.enabled); - jsonWriter.writeNumberField("nbf", this.notBefore); - jsonWriter.writeNumberField("exp", this.expires); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of Attributes from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of Attributes if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. - * @throws IOException If an error occurs while reading the Attributes. - */ - public static Attributes fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - Attributes deserializedAttributes = new Attributes(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("enabled".equals(fieldName)) { - deserializedAttributes.enabled = reader.getNullable(JsonReader::getBoolean); - } else if ("nbf".equals(fieldName)) { - deserializedAttributes.notBefore = reader.getNullable(JsonReader::getLong); - } else if ("exp".equals(fieldName)) { - deserializedAttributes.expires = reader.getNullable(JsonReader::getLong); - } else if ("created".equals(fieldName)) { - deserializedAttributes.created = reader.getNullable(JsonReader::getLong); - } else if ("updated".equals(fieldName)) { - deserializedAttributes.updated = reader.getNullable(JsonReader::getLong); - } else { - reader.skipChildren(); - } - } - - return deserializedAttributes; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/BackupCertificateResult.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/BackupCertificateResult.java deleted file mode 100644 index 3031631df13a..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/BackupCertificateResult.java +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Immutable; -import com.azure.core.util.Base64Url; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The backup certificate result, containing the backup blob. - */ -@Immutable -public final class BackupCertificateResult implements JsonSerializable { - /* - * The backup blob containing the backed up certificate. - */ - private Base64Url value; - - /** - * Creates an instance of BackupCertificateResult class. - */ - public BackupCertificateResult() { - } - - /** - * Get the value property: The backup blob containing the backed up certificate. - * - * @return the value value. - */ - public byte[] getValue() { - if (this.value == null) { - return null; - } - return this.value.decodedBytes(); - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of BackupCertificateResult from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of BackupCertificateResult if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. - * @throws IOException If an error occurs while reading the BackupCertificateResult. - */ - public static BackupCertificateResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - BackupCertificateResult deserializedBackupCertificateResult = new BackupCertificateResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("value".equals(fieldName)) { - deserializedBackupCertificateResult.value - = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); - } else { - reader.skipChildren(); - } - } - - return deserializedBackupCertificateResult; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateAttributes.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateAttributes.java deleted file mode 100644 index d7e7a407d66c..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateAttributes.java +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; - -/** - * The certificate management attributes. - */ -@Fluent -public final class CertificateAttributes extends Attributes { - /* - * softDelete data retention days. Value should be >=7 and <=90 when softDelete enabled, otherwise 0. - */ - private Integer recoverableDays; - - /* - * Reflects the deletion recovery level currently in effect for certificates in the current vault. If it contains - * 'Purgeable', the certificate can be permanently deleted by a privileged user; otherwise, only the system can - * purge the certificate, at the end of the retention interval. - */ - private DeletionRecoveryLevel recoveryLevel; - - /* - * Last updated time in UTC. - */ - private Long updated; - - /* - * Creation time in UTC. - */ - private Long created; - - /** - * Creates an instance of CertificateAttributes class. - */ - public CertificateAttributes() { - } - - /** - * Get the recoverableDays property: softDelete data retention days. Value should be >=7 and <=90 when - * softDelete enabled, otherwise 0. - * - * @return the recoverableDays value. - */ - public Integer getRecoverableDays() { - return this.recoverableDays; - } - - /** - * Get the recoveryLevel property: Reflects the deletion recovery level currently in effect for certificates in the - * current vault. If it contains 'Purgeable', the certificate can be permanently deleted by a privileged user; - * otherwise, only the system can purge the certificate, at the end of the retention interval. - * - * @return the recoveryLevel value. - */ - public DeletionRecoveryLevel getRecoveryLevel() { - return this.recoveryLevel; - } - - /** - * Get the updated property: Last updated time in UTC. - * - * @return the updated value. - */ - @Override - public OffsetDateTime getUpdated() { - if (this.updated == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.updated), ZoneOffset.UTC); - } - - /** - * Get the created property: Creation time in UTC. - * - * @return the created value. - */ - @Override - public OffsetDateTime getCreated() { - if (this.created == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.created), ZoneOffset.UTC); - } - - /** - * {@inheritDoc} - */ - @Override - public CertificateAttributes setEnabled(Boolean enabled) { - super.setEnabled(enabled); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public CertificateAttributes setNotBefore(OffsetDateTime notBefore) { - super.setNotBefore(notBefore); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public CertificateAttributes setExpires(OffsetDateTime expires) { - super.setExpires(expires); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeBooleanField("enabled", isEnabled()); - if (getNotBefore() != null) { - jsonWriter.writeNumberField("nbf", getNotBefore().toEpochSecond()); - } - if (getExpires() != null) { - jsonWriter.writeNumberField("exp", getExpires().toEpochSecond()); - } - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateAttributes from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateAttributes if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificateAttributes. - */ - public static CertificateAttributes fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateAttributes deserializedCertificateAttributes = new CertificateAttributes(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("enabled".equals(fieldName)) { - deserializedCertificateAttributes.setEnabled(reader.getNullable(JsonReader::getBoolean)); - } else if ("nbf".equals(fieldName)) { - Long notBeforeHolder = reader.getNullable(JsonReader::getLong); - if (notBeforeHolder != null) { - deserializedCertificateAttributes.setNotBefore( - OffsetDateTime.ofInstant(Instant.ofEpochSecond(notBeforeHolder), ZoneOffset.UTC)); - } - } else if ("exp".equals(fieldName)) { - Long expiresHolder = reader.getNullable(JsonReader::getLong); - if (expiresHolder != null) { - deserializedCertificateAttributes - .setExpires(OffsetDateTime.ofInstant(Instant.ofEpochSecond(expiresHolder), ZoneOffset.UTC)); - } - } else if ("created".equals(fieldName)) { - deserializedCertificateAttributes.created = reader.getNullable(JsonReader::getLong); - } else if ("updated".equals(fieldName)) { - deserializedCertificateAttributes.updated = reader.getNullable(JsonReader::getLong); - } else if ("recoverableDays".equals(fieldName)) { - deserializedCertificateAttributes.recoverableDays = reader.getNullable(JsonReader::getInt); - } else if ("recoveryLevel".equals(fieldName)) { - deserializedCertificateAttributes.recoveryLevel - = DeletionRecoveryLevel.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateAttributes; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateBundle.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateBundle.java deleted file mode 100644 index 06c7d4101038..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateBundle.java +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.Base64Url; -import com.azure.core.util.CoreUtils; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.Map; - -/** - * A certificate bundle consists of a certificate (X509) plus its attributes. - */ -@Fluent -public class CertificateBundle implements JsonSerializable { - /* - * The certificate id. - */ - private String id; - - /* - * The key id. - */ - private String kid; - - /* - * The secret id. - */ - private String sid; - - /* - * Thumbprint of the certificate. - */ - private Base64Url x509Thumbprint; - - /* - * The management policy. - */ - private CertificatePolicy policy; - - /* - * CER contents of x509 certificate. - */ - private byte[] cer; - - /* - * The content type of the secret. eg. 'application/x-pem-file' or 'application/x-pkcs12', - */ - private String contentType; - - /* - * The certificate attributes. - */ - private CertificateAttributes attributes; - - /* - * Application specific metadata in the form of key-value pairs - */ - private Map tags; - - /** - * Creates an instance of CertificateBundle class. - */ - public CertificateBundle() { - } - - /** - * Get the id property: The certificate id. - * - * @return the id value. - */ - public String getId() { - return this.id; - } - - /** - * Set the id property: The certificate id. - * - * @param id the id value to set. - * @return the CertificateBundle object itself. - */ - CertificateBundle setId(String id) { - this.id = id; - return this; - } - - /** - * Get the kid property: The key id. - * - * @return the kid value. - */ - public String getKid() { - return this.kid; - } - - /** - * Set the kid property: The key id. - * - * @param kid the kid value to set. - * @return the CertificateBundle object itself. - */ - CertificateBundle setKid(String kid) { - this.kid = kid; - return this; - } - - /** - * Get the sid property: The secret id. - * - * @return the sid value. - */ - public String getSid() { - return this.sid; - } - - /** - * Set the sid property: The secret id. - * - * @param sid the sid value to set. - * @return the CertificateBundle object itself. - */ - CertificateBundle setSid(String sid) { - this.sid = sid; - return this; - } - - /** - * Get the x509Thumbprint property: Thumbprint of the certificate. - * - * @return the x509Thumbprint value. - */ - public byte[] getX509Thumbprint() { - if (this.x509Thumbprint == null) { - return null; - } - return this.x509Thumbprint.decodedBytes(); - } - - /** - * Set the x509Thumbprint property: Thumbprint of the certificate. - * - * @param x509Thumbprint the x509Thumbprint value to set. - * @return the CertificateBundle object itself. - */ - CertificateBundle setX509Thumbprint(byte[] x509Thumbprint) { - if (x509Thumbprint == null) { - this.x509Thumbprint = null; - } else { - this.x509Thumbprint = Base64Url.encode(CoreUtils.clone(x509Thumbprint)); - } - return this; - } - - /** - * Get the policy property: The management policy. - * - * @return the policy value. - */ - public CertificatePolicy getPolicy() { - return this.policy; - } - - /** - * Set the policy property: The management policy. - * - * @param policy the policy value to set. - * @return the CertificateBundle object itself. - */ - CertificateBundle setPolicy(CertificatePolicy policy) { - this.policy = policy; - return this; - } - - /** - * Get the cer property: CER contents of x509 certificate. - * - * @return the cer value. - */ - public byte[] getCer() { - return CoreUtils.clone(this.cer); - } - - /** - * Set the cer property: CER contents of x509 certificate. - * - * @param cer the cer value to set. - * @return the CertificateBundle object itself. - */ - public CertificateBundle setCer(byte[] cer) { - this.cer = CoreUtils.clone(cer); - return this; - } - - /** - * Get the contentType property: The content type of the secret. eg. 'application/x-pem-file' or - * 'application/x-pkcs12',. - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: The content type of the secret. eg. 'application/x-pem-file' or - * 'application/x-pkcs12',. - * - * @param contentType the contentType value to set. - * @return the CertificateBundle object itself. - */ - public CertificateBundle setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Get the attributes property: The certificate attributes. - * - * @return the attributes value. - */ - public CertificateAttributes getAttributes() { - return this.attributes; - } - - /** - * Set the attributes property: The certificate attributes. - * - * @param attributes the attributes value to set. - * @return the CertificateBundle object itself. - */ - public CertificateBundle setAttributes(CertificateAttributes attributes) { - this.attributes = attributes; - return this; - } - - /** - * Get the tags property: Application specific metadata in the form of key-value pairs. - * - * @return the tags value. - */ - public Map getTags() { - return this.tags; - } - - /** - * Set the tags property: Application specific metadata in the form of key-value pairs. - * - * @param tags the tags value to set. - * @return the CertificateBundle object itself. - */ - public CertificateBundle setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeBinaryField("cer", this.cer); - jsonWriter.writeStringField("contentType", this.contentType); - jsonWriter.writeJsonField("attributes", this.attributes); - jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateBundle from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateBundle if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificateBundle. - */ - public static CertificateBundle fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateBundle deserializedCertificateBundle = new CertificateBundle(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedCertificateBundle.id = reader.getString(); - } else if ("kid".equals(fieldName)) { - deserializedCertificateBundle.kid = reader.getString(); - } else if ("sid".equals(fieldName)) { - deserializedCertificateBundle.sid = reader.getString(); - } else if ("x5t".equals(fieldName)) { - deserializedCertificateBundle.x509Thumbprint - = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); - } else if ("policy".equals(fieldName)) { - deserializedCertificateBundle.policy = CertificatePolicy.fromJson(reader); - } else if ("cer".equals(fieldName)) { - deserializedCertificateBundle.cer = reader.getBinary(); - } else if ("contentType".equals(fieldName)) { - deserializedCertificateBundle.contentType = reader.getString(); - } else if ("attributes".equals(fieldName)) { - deserializedCertificateBundle.attributes = CertificateAttributes.fromJson(reader); - } else if ("tags".equals(fieldName)) { - Map tags = reader.readMap(reader1 -> reader1.getString()); - deserializedCertificateBundle.tags = tags; - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateBundle; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateCreateParameters.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateCreateParameters.java deleted file mode 100644 index b2f4d960f564..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateCreateParameters.java +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.Map; - -/** - * The certificate create parameters. - */ -@Fluent -public final class CertificateCreateParameters implements JsonSerializable { - /* - * The management policy for the certificate. - */ - private CertificatePolicy certificatePolicy; - - /* - * The attributes of the certificate (optional). - */ - private CertificateAttributes certificateAttributes; - - /* - * Application specific metadata in the form of key-value pairs. - */ - private Map tags; - - /** - * Creates an instance of CertificateCreateParameters class. - */ - public CertificateCreateParameters() { - } - - /** - * Get the certificatePolicy property: The management policy for the certificate. - * - * @return the certificatePolicy value. - */ - public CertificatePolicy getCertificatePolicy() { - return this.certificatePolicy; - } - - /** - * Set the certificatePolicy property: The management policy for the certificate. - * - * @param certificatePolicy the certificatePolicy value to set. - * @return the CertificateCreateParameters object itself. - */ - public CertificateCreateParameters setCertificatePolicy(CertificatePolicy certificatePolicy) { - this.certificatePolicy = certificatePolicy; - return this; - } - - /** - * Get the certificateAttributes property: The attributes of the certificate (optional). - * - * @return the certificateAttributes value. - */ - public CertificateAttributes getCertificateAttributes() { - return this.certificateAttributes; - } - - /** - * Set the certificateAttributes property: The attributes of the certificate (optional). - * - * @param certificateAttributes the certificateAttributes value to set. - * @return the CertificateCreateParameters object itself. - */ - public CertificateCreateParameters setCertificateAttributes(CertificateAttributes certificateAttributes) { - this.certificateAttributes = certificateAttributes; - return this; - } - - /** - * Get the tags property: Application specific metadata in the form of key-value pairs. - * - * @return the tags value. - */ - public Map getTags() { - return this.tags; - } - - /** - * Set the tags property: Application specific metadata in the form of key-value pairs. - * - * @param tags the tags value to set. - * @return the CertificateCreateParameters object itself. - */ - public CertificateCreateParameters setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeJsonField("policy", this.certificatePolicy); - jsonWriter.writeJsonField("attributes", this.certificateAttributes); - jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateCreateParameters from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateCreateParameters if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificateCreateParameters. - */ - public static CertificateCreateParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateCreateParameters deserializedCertificateCreateParameters = new CertificateCreateParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("policy".equals(fieldName)) { - deserializedCertificateCreateParameters.certificatePolicy = CertificatePolicy.fromJson(reader); - } else if ("attributes".equals(fieldName)) { - deserializedCertificateCreateParameters.certificateAttributes - = CertificateAttributes.fromJson(reader); - } else if ("tags".equals(fieldName)) { - Map tags = reader.readMap(reader1 -> reader1.getString()); - deserializedCertificateCreateParameters.tags = tags; - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateCreateParameters; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateImportParameters.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateImportParameters.java deleted file mode 100644 index 63c062bced7a..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateImportParameters.java +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.Map; - -/** - * The certificate import parameters. - */ -@Fluent -public final class CertificateImportParameters implements JsonSerializable { - /* - * Base64 encoded representation of the certificate object to import. This certificate needs to contain the private - * key. - */ - private String base64EncodedCertificate; - - /* - * If the private key in base64EncodedCertificate is encrypted, the password used for encryption. - */ - private String password; - - /* - * The management policy for the certificate. - */ - private CertificatePolicy certificatePolicy; - - /* - * The attributes of the certificate (optional). - */ - private CertificateAttributes certificateAttributes; - - /* - * Application specific metadata in the form of key-value pairs. - */ - private Map tags; - - /** - * Creates an instance of CertificateImportParameters class. - */ - public CertificateImportParameters() { - } - - /** - * Get the base64EncodedCertificate property: Base64 encoded representation of the certificate object to import. - * This certificate needs to contain the private key. - * - * @return the base64EncodedCertificate value. - */ - public String getBase64EncodedCertificate() { - return this.base64EncodedCertificate; - } - - /** - * Set the base64EncodedCertificate property: Base64 encoded representation of the certificate object to import. - * This certificate needs to contain the private key. - * - * @param base64EncodedCertificate the base64EncodedCertificate value to set. - * @return the CertificateImportParameters object itself. - */ - public CertificateImportParameters setBase64EncodedCertificate(String base64EncodedCertificate) { - this.base64EncodedCertificate = base64EncodedCertificate; - return this; - } - - /** - * Get the password property: If the private key in base64EncodedCertificate is encrypted, the password used for - * encryption. - * - * @return the password value. - */ - public String getPassword() { - return this.password; - } - - /** - * Set the password property: If the private key in base64EncodedCertificate is encrypted, the password used for - * encryption. - * - * @param password the password value to set. - * @return the CertificateImportParameters object itself. - */ - public CertificateImportParameters setPassword(String password) { - this.password = password; - return this; - } - - /** - * Get the certificatePolicy property: The management policy for the certificate. - * - * @return the certificatePolicy value. - */ - public CertificatePolicy getCertificatePolicy() { - return this.certificatePolicy; - } - - /** - * Set the certificatePolicy property: The management policy for the certificate. - * - * @param certificatePolicy the certificatePolicy value to set. - * @return the CertificateImportParameters object itself. - */ - public CertificateImportParameters setCertificatePolicy(CertificatePolicy certificatePolicy) { - this.certificatePolicy = certificatePolicy; - return this; - } - - /** - * Get the certificateAttributes property: The attributes of the certificate (optional). - * - * @return the certificateAttributes value. - */ - public CertificateAttributes getCertificateAttributes() { - return this.certificateAttributes; - } - - /** - * Set the certificateAttributes property: The attributes of the certificate (optional). - * - * @param certificateAttributes the certificateAttributes value to set. - * @return the CertificateImportParameters object itself. - */ - public CertificateImportParameters setCertificateAttributes(CertificateAttributes certificateAttributes) { - this.certificateAttributes = certificateAttributes; - return this; - } - - /** - * Get the tags property: Application specific metadata in the form of key-value pairs. - * - * @return the tags value. - */ - public Map getTags() { - return this.tags; - } - - /** - * Set the tags property: Application specific metadata in the form of key-value pairs. - * - * @param tags the tags value to set. - * @return the CertificateImportParameters object itself. - */ - public CertificateImportParameters setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("value", this.base64EncodedCertificate); - jsonWriter.writeStringField("pwd", this.password); - jsonWriter.writeJsonField("policy", this.certificatePolicy); - jsonWriter.writeJsonField("attributes", this.certificateAttributes); - jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateImportParameters from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateImportParameters if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the CertificateImportParameters. - */ - public static CertificateImportParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateImportParameters deserializedCertificateImportParameters = new CertificateImportParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("value".equals(fieldName)) { - deserializedCertificateImportParameters.base64EncodedCertificate = reader.getString(); - } else if ("pwd".equals(fieldName)) { - deserializedCertificateImportParameters.password = reader.getString(); - } else if ("policy".equals(fieldName)) { - deserializedCertificateImportParameters.certificatePolicy = CertificatePolicy.fromJson(reader); - } else if ("attributes".equals(fieldName)) { - deserializedCertificateImportParameters.certificateAttributes - = CertificateAttributes.fromJson(reader); - } else if ("tags".equals(fieldName)) { - Map tags = reader.readMap(reader1 -> reader1.getString()); - deserializedCertificateImportParameters.tags = tags; - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateImportParameters; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateIssuerItem.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateIssuerItem.java deleted file mode 100644 index b3a82fd210d3..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateIssuerItem.java +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The certificate issuer item containing certificate issuer metadata. - */ -@Fluent -public final class CertificateIssuerItem implements JsonSerializable { - /* - * Certificate Identifier. - */ - private String id; - - /* - * The issuer provider. - */ - private String provider; - - /** - * Creates an instance of CertificateIssuerItem class. - */ - public CertificateIssuerItem() { - } - - /** - * Get the id property: Certificate Identifier. - * - * @return the id value. - */ - public String getId() { - return this.id; - } - - /** - * Set the id property: Certificate Identifier. - * - * @param id the id value to set. - * @return the CertificateIssuerItem object itself. - */ - public CertificateIssuerItem setId(String id) { - this.id = id; - return this; - } - - /** - * Get the provider property: The issuer provider. - * - * @return the provider value. - */ - public String getProvider() { - return this.provider; - } - - /** - * Set the provider property: The issuer provider. - * - * @param provider the provider value to set. - * @return the CertificateIssuerItem object itself. - */ - public CertificateIssuerItem setProvider(String provider) { - this.provider = provider; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("id", this.id); - jsonWriter.writeStringField("provider", this.provider); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateIssuerItem from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateIssuerItem if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificateIssuerItem. - */ - public static CertificateIssuerItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateIssuerItem deserializedCertificateIssuerItem = new CertificateIssuerItem(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedCertificateIssuerItem.id = reader.getString(); - } else if ("provider".equals(fieldName)) { - deserializedCertificateIssuerItem.provider = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateIssuerItem; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateIssuerListResult.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateIssuerListResult.java deleted file mode 100644 index 73495be17c0a..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateIssuerListResult.java +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.List; - -/** - * The certificate issuer list result. - */ -@Immutable -public final class CertificateIssuerListResult implements JsonSerializable { - /* - * A response message containing a list of certificate issuers in the key vault along with a link to the next page - * of certificate issuers. - */ - private List value; - - /* - * The URL to get the next set of certificate issuers. - */ - private String nextLink; - - /** - * Creates an instance of CertificateIssuerListResult class. - */ - public CertificateIssuerListResult() { - } - - /** - * Get the value property: A response message containing a list of certificate issuers in the key vault along with a - * link to the next page of certificate issuers. - * - * @return the value value. - */ - public List getValue() { - return this.value; - } - - /** - * Get the nextLink property: The URL to get the next set of certificate issuers. - * - * @return the nextLink value. - */ - public String getNextLink() { - return this.nextLink; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateIssuerListResult from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateIssuerListResult if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificateIssuerListResult. - */ - public static CertificateIssuerListResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateIssuerListResult deserializedCertificateIssuerListResult = new CertificateIssuerListResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("value".equals(fieldName)) { - List value - = reader.readArray(reader1 -> CertificateIssuerItem.fromJson(reader1)); - deserializedCertificateIssuerListResult.value = value; - } else if ("nextLink".equals(fieldName)) { - deserializedCertificateIssuerListResult.nextLink = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateIssuerListResult; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateIssuerSetParameters.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateIssuerSetParameters.java deleted file mode 100644 index ce6e00c1243e..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateIssuerSetParameters.java +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The certificate issuer set parameters. - */ -@Fluent -public final class CertificateIssuerSetParameters implements JsonSerializable { - /* - * The issuer provider. - */ - private String provider; - - /* - * The credentials to be used for the issuer. - */ - private IssuerCredentials credentials; - - /* - * Details of the organization as provided to the issuer. - */ - private OrganizationDetails organizationDetails; - - /* - * Attributes of the issuer object. - */ - private IssuerAttributes attributes; - - /** - * Creates an instance of CertificateIssuerSetParameters class. - */ - public CertificateIssuerSetParameters() { - } - - /** - * Get the provider property: The issuer provider. - * - * @return the provider value. - */ - public String getProvider() { - return this.provider; - } - - /** - * Set the provider property: The issuer provider. - * - * @param provider the provider value to set. - * @return the CertificateIssuerSetParameters object itself. - */ - public CertificateIssuerSetParameters setProvider(String provider) { - this.provider = provider; - return this; - } - - /** - * Get the credentials property: The credentials to be used for the issuer. - * - * @return the credentials value. - */ - public IssuerCredentials getCredentials() { - return this.credentials; - } - - /** - * Set the credentials property: The credentials to be used for the issuer. - * - * @param credentials the credentials value to set. - * @return the CertificateIssuerSetParameters object itself. - */ - public CertificateIssuerSetParameters setCredentials(IssuerCredentials credentials) { - this.credentials = credentials; - return this; - } - - /** - * Get the organizationDetails property: Details of the organization as provided to the issuer. - * - * @return the organizationDetails value. - */ - public OrganizationDetails getOrganizationDetails() { - return this.organizationDetails; - } - - /** - * Set the organizationDetails property: Details of the organization as provided to the issuer. - * - * @param organizationDetails the organizationDetails value to set. - * @return the CertificateIssuerSetParameters object itself. - */ - public CertificateIssuerSetParameters setOrganizationDetails(OrganizationDetails organizationDetails) { - this.organizationDetails = organizationDetails; - return this; - } - - /** - * Get the attributes property: Attributes of the issuer object. - * - * @return the attributes value. - */ - public IssuerAttributes getAttributes() { - return this.attributes; - } - - /** - * Set the attributes property: Attributes of the issuer object. - * - * @param attributes the attributes value to set. - * @return the CertificateIssuerSetParameters object itself. - */ - public CertificateIssuerSetParameters setAttributes(IssuerAttributes attributes) { - this.attributes = attributes; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("provider", this.provider); - jsonWriter.writeJsonField("credentials", this.credentials); - jsonWriter.writeJsonField("org_details", this.organizationDetails); - jsonWriter.writeJsonField("attributes", this.attributes); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateIssuerSetParameters from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateIssuerSetParameters if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the CertificateIssuerSetParameters. - */ - public static CertificateIssuerSetParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateIssuerSetParameters deserializedCertificateIssuerSetParameters - = new CertificateIssuerSetParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("provider".equals(fieldName)) { - deserializedCertificateIssuerSetParameters.provider = reader.getString(); - } else if ("credentials".equals(fieldName)) { - deserializedCertificateIssuerSetParameters.credentials = IssuerCredentials.fromJson(reader); - } else if ("org_details".equals(fieldName)) { - deserializedCertificateIssuerSetParameters.organizationDetails - = OrganizationDetails.fromJson(reader); - } else if ("attributes".equals(fieldName)) { - deserializedCertificateIssuerSetParameters.attributes = IssuerAttributes.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateIssuerSetParameters; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateIssuerUpdateParameters.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateIssuerUpdateParameters.java deleted file mode 100644 index 4109a4a35ce1..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateIssuerUpdateParameters.java +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The certificate issuer update parameters. - */ -@Fluent -public final class CertificateIssuerUpdateParameters implements JsonSerializable { - /* - * The issuer provider. - */ - private String provider; - - /* - * The credentials to be used for the issuer. - */ - private IssuerCredentials credentials; - - /* - * Details of the organization as provided to the issuer. - */ - private OrganizationDetails organizationDetails; - - /* - * Attributes of the issuer object. - */ - private IssuerAttributes attributes; - - /** - * Creates an instance of CertificateIssuerUpdateParameters class. - */ - public CertificateIssuerUpdateParameters() { - } - - /** - * Get the provider property: The issuer provider. - * - * @return the provider value. - */ - public String getProvider() { - return this.provider; - } - - /** - * Set the provider property: The issuer provider. - * - * @param provider the provider value to set. - * @return the CertificateIssuerUpdateParameters object itself. - */ - public CertificateIssuerUpdateParameters setProvider(String provider) { - this.provider = provider; - return this; - } - - /** - * Get the credentials property: The credentials to be used for the issuer. - * - * @return the credentials value. - */ - public IssuerCredentials getCredentials() { - return this.credentials; - } - - /** - * Set the credentials property: The credentials to be used for the issuer. - * - * @param credentials the credentials value to set. - * @return the CertificateIssuerUpdateParameters object itself. - */ - public CertificateIssuerUpdateParameters setCredentials(IssuerCredentials credentials) { - this.credentials = credentials; - return this; - } - - /** - * Get the organizationDetails property: Details of the organization as provided to the issuer. - * - * @return the organizationDetails value. - */ - public OrganizationDetails getOrganizationDetails() { - return this.organizationDetails; - } - - /** - * Set the organizationDetails property: Details of the organization as provided to the issuer. - * - * @param organizationDetails the organizationDetails value to set. - * @return the CertificateIssuerUpdateParameters object itself. - */ - public CertificateIssuerUpdateParameters setOrganizationDetails(OrganizationDetails organizationDetails) { - this.organizationDetails = organizationDetails; - return this; - } - - /** - * Get the attributes property: Attributes of the issuer object. - * - * @return the attributes value. - */ - public IssuerAttributes getAttributes() { - return this.attributes; - } - - /** - * Set the attributes property: Attributes of the issuer object. - * - * @param attributes the attributes value to set. - * @return the CertificateIssuerUpdateParameters object itself. - */ - public CertificateIssuerUpdateParameters setAttributes(IssuerAttributes attributes) { - this.attributes = attributes; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("provider", this.provider); - jsonWriter.writeJsonField("credentials", this.credentials); - jsonWriter.writeJsonField("org_details", this.organizationDetails); - jsonWriter.writeJsonField("attributes", this.attributes); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateIssuerUpdateParameters from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateIssuerUpdateParameters if the JsonReader was pointing to an instance of it, or - * null if it was pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificateIssuerUpdateParameters. - */ - public static CertificateIssuerUpdateParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateIssuerUpdateParameters deserializedCertificateIssuerUpdateParameters - = new CertificateIssuerUpdateParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("provider".equals(fieldName)) { - deserializedCertificateIssuerUpdateParameters.provider = reader.getString(); - } else if ("credentials".equals(fieldName)) { - deserializedCertificateIssuerUpdateParameters.credentials = IssuerCredentials.fromJson(reader); - } else if ("org_details".equals(fieldName)) { - deserializedCertificateIssuerUpdateParameters.organizationDetails - = OrganizationDetails.fromJson(reader); - } else if ("attributes".equals(fieldName)) { - deserializedCertificateIssuerUpdateParameters.attributes = IssuerAttributes.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateIssuerUpdateParameters; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateItem.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateItem.java deleted file mode 100644 index c10dd8809e71..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateItem.java +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.Base64Url; -import com.azure.core.util.CoreUtils; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.Map; -import java.util.Objects; - -/** - * The certificate item containing certificate metadata. - */ -@Fluent -public class CertificateItem implements JsonSerializable { - /* - * Certificate identifier. - */ - private String id; - - /* - * The certificate management attributes. - */ - private CertificateAttributes attributes; - - /* - * Application specific metadata in the form of key-value pairs. - */ - private Map tags; - - /* - * Thumbprint of the certificate. - */ - private Base64Url x509Thumbprint; - - /** - * Creates an instance of CertificateItem class. - */ - public CertificateItem() { - } - - /** - * Get the id property: Certificate identifier. - * - * @return the id value. - */ - public String getId() { - return this.id; - } - - /** - * Set the id property: Certificate identifier. - * - * @param id the id value to set. - * @return the CertificateItem object itself. - */ - public CertificateItem setId(String id) { - this.id = id; - return this; - } - - /** - * Get the attributes property: The certificate management attributes. - * - * @return the attributes value. - */ - public CertificateAttributes getAttributes() { - return this.attributes; - } - - /** - * Set the attributes property: The certificate management attributes. - * - * @param attributes the attributes value to set. - * @return the CertificateItem object itself. - */ - public CertificateItem setAttributes(CertificateAttributes attributes) { - this.attributes = attributes; - return this; - } - - /** - * Get the tags property: Application specific metadata in the form of key-value pairs. - * - * @return the tags value. - */ - public Map getTags() { - return this.tags; - } - - /** - * Set the tags property: Application specific metadata in the form of key-value pairs. - * - * @param tags the tags value to set. - * @return the CertificateItem object itself. - */ - public CertificateItem setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Get the x509Thumbprint property: Thumbprint of the certificate. - * - * @return the x509Thumbprint value. - */ - public byte[] getX509Thumbprint() { - if (this.x509Thumbprint == null) { - return null; - } - return this.x509Thumbprint.decodedBytes(); - } - - /** - * Set the x509Thumbprint property: Thumbprint of the certificate. - * - * @param x509Thumbprint the x509Thumbprint value to set. - * @return the CertificateItem object itself. - */ - public CertificateItem setX509Thumbprint(byte[] x509Thumbprint) { - if (x509Thumbprint == null) { - this.x509Thumbprint = null; - } else { - this.x509Thumbprint = Base64Url.encode(CoreUtils.clone(x509Thumbprint)); - } - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("id", this.id); - jsonWriter.writeJsonField("attributes", this.attributes); - jsonWriter.writeMapField("tags", this.tags, JsonWriter::writeString); - jsonWriter.writeStringField("x5t", Objects.toString(this.x509Thumbprint, null)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateItem from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateItem if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificateItem. - */ - public static CertificateItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateItem deserializedCertificateItem = new CertificateItem(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedCertificateItem.id = reader.getString(); - } else if ("attributes".equals(fieldName)) { - deserializedCertificateItem.attributes = CertificateAttributes.fromJson(reader); - } else if ("tags".equals(fieldName)) { - Map tags = reader.readMap(reader1 -> reader1.getString()); - deserializedCertificateItem.tags = tags; - } else if ("x5t".equals(fieldName)) { - deserializedCertificateItem.x509Thumbprint - = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateItem; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateListResult.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateListResult.java deleted file mode 100644 index f5ac96a82b6b..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateListResult.java +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.List; - -/** - * The certificate list result. - */ -@Immutable -public final class CertificateListResult implements JsonSerializable { - /* - * A response message containing a list of certificates in the key vault along with a link to the next page of - * certificates. - */ - private List value; - - /* - * The URL to get the next set of certificates. - */ - private String nextLink; - - /** - * Creates an instance of CertificateListResult class. - */ - public CertificateListResult() { - } - - /** - * Get the value property: A response message containing a list of certificates in the key vault along with a link - * to the next page of certificates. - * - * @return the value value. - */ - public List getValue() { - return this.value; - } - - /** - * Get the nextLink property: The URL to get the next set of certificates. - * - * @return the nextLink value. - */ - public String getNextLink() { - return this.nextLink; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateListResult from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateListResult if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificateListResult. - */ - public static CertificateListResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateListResult deserializedCertificateListResult = new CertificateListResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("value".equals(fieldName)) { - List value = reader.readArray(reader1 -> CertificateItem.fromJson(reader1)); - deserializedCertificateListResult.value = value; - } else if ("nextLink".equals(fieldName)) { - deserializedCertificateListResult.nextLink = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateListResult; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateMergeParameters.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateMergeParameters.java deleted file mode 100644 index c5aa619ba09a..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateMergeParameters.java +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -/** - * The certificate merge parameters. - */ -@Fluent -public final class CertificateMergeParameters implements JsonSerializable { - /* - * The certificate or the certificate chain to merge. - */ - private List x509Certificates; - - /* - * The attributes of the certificate (optional). - */ - private CertificateAttributes certificateAttributes; - - /* - * Application specific metadata in the form of key-value pairs. - */ - private Map tags; - - /** - * Creates an instance of CertificateMergeParameters class. - */ - public CertificateMergeParameters() { - } - - /** - * Get the x509Certificates property: The certificate or the certificate chain to merge. - * - * @return the x509Certificates value. - */ - public List getX509Certificates() { - return this.x509Certificates; - } - - /** - * Set the x509Certificates property: The certificate or the certificate chain to merge. - * - * @param x509Certificates the x509Certificates value to set. - * @return the CertificateMergeParameters object itself. - */ - public CertificateMergeParameters setX509Certificates(List x509Certificates) { - this.x509Certificates = x509Certificates; - return this; - } - - /** - * Get the certificateAttributes property: The attributes of the certificate (optional). - * - * @return the certificateAttributes value. - */ - public CertificateAttributes getCertificateAttributes() { - return this.certificateAttributes; - } - - /** - * Set the certificateAttributes property: The attributes of the certificate (optional). - * - * @param certificateAttributes the certificateAttributes value to set. - * @return the CertificateMergeParameters object itself. - */ - public CertificateMergeParameters setCertificateAttributes(CertificateAttributes certificateAttributes) { - this.certificateAttributes = certificateAttributes; - return this; - } - - /** - * Get the tags property: Application specific metadata in the form of key-value pairs. - * - * @return the tags value. - */ - public Map getTags() { - return this.tags; - } - - /** - * Set the tags property: Application specific metadata in the form of key-value pairs. - * - * @param tags the tags value to set. - * @return the CertificateMergeParameters object itself. - */ - public CertificateMergeParameters setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeArrayField("x5c", this.x509Certificates, (writer, element) -> writer.writeBinary(element)); - jsonWriter.writeJsonField("attributes", this.certificateAttributes); - jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateMergeParameters from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateMergeParameters if the JsonReader was pointing to an instance of it, or null if - * it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the CertificateMergeParameters. - */ - public static CertificateMergeParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateMergeParameters deserializedCertificateMergeParameters = new CertificateMergeParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("x5c".equals(fieldName)) { - List x509Certificates = reader.readArray(reader1 -> reader1.getBinary()); - deserializedCertificateMergeParameters.x509Certificates = x509Certificates; - } else if ("attributes".equals(fieldName)) { - deserializedCertificateMergeParameters.certificateAttributes - = CertificateAttributes.fromJson(reader); - } else if ("tags".equals(fieldName)) { - Map tags = reader.readMap(reader1 -> reader1.getString()); - deserializedCertificateMergeParameters.tags = tags; - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateMergeParameters; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateOperation.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateOperation.java deleted file mode 100644 index eb1a7d147d5a..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateOperation.java +++ /dev/null @@ -1,299 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.CoreUtils; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.models.CertificateOperationError; -import java.io.IOException; - -/** - * A certificate operation is returned in case of asynchronous requests. - */ -@Fluent -public final class CertificateOperation implements JsonSerializable { - /* - * The certificate id. - */ - private String id; - - /* - * Parameters for the issuer of the X509 component of a certificate. - */ - private IssuerParameters issuerParameters; - - /* - * The certificate signing request (CSR) that is being used in the certificate operation. - */ - private byte[] csr; - - /* - * Indicates if cancellation was requested on the certificate operation. - */ - private Boolean cancellationRequested; - - /* - * Status of the certificate operation. - */ - private String status; - - /* - * The status details of the certificate operation. - */ - private String statusDetails; - - /* - * Error encountered, if any, during the certificate operation. - */ - private CertificateOperationError error; - - /* - * Location which contains the result of the certificate operation. - */ - private String target; - - /* - * Identifier for the certificate operation. - */ - private String requestId; - - /** - * Creates an instance of CertificateOperation class. - */ - public CertificateOperation() { - } - - /** - * Get the id property: The certificate id. - * - * @return the id value. - */ - public String getId() { - return this.id; - } - - /** - * Get the issuerParameters property: Parameters for the issuer of the X509 component of a certificate. - * - * @return the issuerParameters value. - */ - public IssuerParameters getIssuerParameters() { - return this.issuerParameters; - } - - /** - * Set the issuerParameters property: Parameters for the issuer of the X509 component of a certificate. - * - * @param issuerParameters the issuerParameters value to set. - * @return the CertificateOperation object itself. - */ - public CertificateOperation setIssuerParameters(IssuerParameters issuerParameters) { - this.issuerParameters = issuerParameters; - return this; - } - - /** - * Get the csr property: The certificate signing request (CSR) that is being used in the certificate operation. - * - * @return the csr value. - */ - public byte[] getCsr() { - return CoreUtils.clone(this.csr); - } - - /** - * Set the csr property: The certificate signing request (CSR) that is being used in the certificate operation. - * - * @param csr the csr value to set. - * @return the CertificateOperation object itself. - */ - public CertificateOperation setCsr(byte[] csr) { - this.csr = CoreUtils.clone(csr); - return this; - } - - /** - * Get the cancellationRequested property: Indicates if cancellation was requested on the certificate operation. - * - * @return the cancellationRequested value. - */ - public Boolean isCancellationRequested() { - return this.cancellationRequested; - } - - /** - * Set the cancellationRequested property: Indicates if cancellation was requested on the certificate operation. - * - * @param cancellationRequested the cancellationRequested value to set. - * @return the CertificateOperation object itself. - */ - public CertificateOperation setCancellationRequested(Boolean cancellationRequested) { - this.cancellationRequested = cancellationRequested; - return this; - } - - /** - * Get the status property: Status of the certificate operation. - * - * @return the status value. - */ - public String getStatus() { - return this.status; - } - - /** - * Set the status property: Status of the certificate operation. - * - * @param status the status value to set. - * @return the CertificateOperation object itself. - */ - public CertificateOperation setStatus(String status) { - this.status = status; - return this; - } - - /** - * Get the statusDetails property: The status details of the certificate operation. - * - * @return the statusDetails value. - */ - public String getStatusDetails() { - return this.statusDetails; - } - - /** - * Set the statusDetails property: The status details of the certificate operation. - * - * @param statusDetails the statusDetails value to set. - * @return the CertificateOperation object itself. - */ - public CertificateOperation setStatusDetails(String statusDetails) { - this.statusDetails = statusDetails; - return this; - } - - /** - * Get the error property: Error encountered, if any, during the certificate operation. - * - * @return the error value. - */ - public CertificateOperationError getError() { - return this.error; - } - - /** - * Set the error property: Error encountered, if any, during the certificate operation. - * - * @param error the error value to set. - * @return the CertificateOperation object itself. - */ - public CertificateOperation setError(CertificateOperationError error) { - this.error = error; - return this; - } - - /** - * Get the target property: Location which contains the result of the certificate operation. - * - * @return the target value. - */ - public String getTarget() { - return this.target; - } - - /** - * Set the target property: Location which contains the result of the certificate operation. - * - * @param target the target value to set. - * @return the CertificateOperation object itself. - */ - public CertificateOperation setTarget(String target) { - this.target = target; - return this; - } - - /** - * Get the requestId property: Identifier for the certificate operation. - * - * @return the requestId value. - */ - public String getRequestId() { - return this.requestId; - } - - /** - * Set the requestId property: Identifier for the certificate operation. - * - * @param requestId the requestId value to set. - * @return the CertificateOperation object itself. - */ - public CertificateOperation setRequestId(String requestId) { - this.requestId = requestId; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeJsonField("issuer", this.issuerParameters); - jsonWriter.writeBinaryField("csr", this.csr); - jsonWriter.writeBooleanField("cancellation_requested", this.cancellationRequested); - jsonWriter.writeStringField("status", this.status); - jsonWriter.writeStringField("status_details", this.statusDetails); - jsonWriter.writeJsonField("error", this.error); - jsonWriter.writeStringField("target", this.target); - jsonWriter.writeStringField("request_id", this.requestId); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateOperation from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateOperation if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificateOperation. - */ - public static CertificateOperation fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateOperation deserializedCertificateOperation = new CertificateOperation(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedCertificateOperation.id = reader.getString(); - } else if ("issuer".equals(fieldName)) { - deserializedCertificateOperation.issuerParameters = IssuerParameters.fromJson(reader); - } else if ("csr".equals(fieldName)) { - deserializedCertificateOperation.csr = reader.getBinary(); - } else if ("cancellation_requested".equals(fieldName)) { - deserializedCertificateOperation.cancellationRequested = reader.getNullable(JsonReader::getBoolean); - } else if ("status".equals(fieldName)) { - deserializedCertificateOperation.status = reader.getString(); - } else if ("status_details".equals(fieldName)) { - deserializedCertificateOperation.statusDetails = reader.getString(); - } else if ("error".equals(fieldName)) { - deserializedCertificateOperation.error = CertificateOperationError.fromJson(reader); - } else if ("target".equals(fieldName)) { - deserializedCertificateOperation.target = reader.getString(); - } else if ("request_id".equals(fieldName)) { - deserializedCertificateOperation.requestId = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateOperation; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateOperationUpdateParameter.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateOperationUpdateParameter.java deleted file mode 100644 index c2aeea4bb2a6..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateOperationUpdateParameter.java +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The certificate operation update parameters. - */ -@Fluent -public final class CertificateOperationUpdateParameter - implements JsonSerializable { - /* - * Indicates if cancellation was requested on the certificate operation. - */ - private boolean cancellationRequested; - - /** - * Creates an instance of CertificateOperationUpdateParameter class. - */ - public CertificateOperationUpdateParameter() { - } - - /** - * Get the cancellationRequested property: Indicates if cancellation was requested on the certificate operation. - * - * @return the cancellationRequested value. - */ - public boolean isCancellationRequested() { - return this.cancellationRequested; - } - - /** - * Set the cancellationRequested property: Indicates if cancellation was requested on the certificate operation. - * - * @param cancellationRequested the cancellationRequested value to set. - * @return the CertificateOperationUpdateParameter object itself. - */ - public CertificateOperationUpdateParameter setCancellationRequested(boolean cancellationRequested) { - this.cancellationRequested = cancellationRequested; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeBooleanField("cancellation_requested", this.cancellationRequested); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateOperationUpdateParameter from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateOperationUpdateParameter if the JsonReader was pointing to an instance of it, - * or null if it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the CertificateOperationUpdateParameter. - */ - public static CertificateOperationUpdateParameter fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateOperationUpdateParameter deserializedCertificateOperationUpdateParameter - = new CertificateOperationUpdateParameter(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("cancellation_requested".equals(fieldName)) { - deserializedCertificateOperationUpdateParameter.cancellationRequested = reader.getBoolean(); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateOperationUpdateParameter; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificatePolicy.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificatePolicy.java deleted file mode 100644 index 3e6670a1fee3..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificatePolicy.java +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.List; - -/** - * Management policy for a certificate. - */ -@Fluent -public final class CertificatePolicy implements JsonSerializable { - /* - * The certificate id. - */ - private String id; - - /* - * Properties of the key backing a certificate. - */ - private KeyProperties keyProperties; - - /* - * Properties of the secret backing a certificate. - */ - private SecretProperties secretProperties; - - /* - * Properties of the X509 component of a certificate. - */ - private X509CertificateProperties x509CertificateProperties; - - /* - * Actions that will be performed by Key Vault over the lifetime of a certificate. - */ - private List lifetimeActions; - - /* - * Parameters for the issuer of the X509 component of a certificate. - */ - private IssuerParameters issuerParameters; - - /* - * The certificate attributes. - */ - private CertificateAttributes attributes; - - /** - * Creates an instance of CertificatePolicy class. - */ - public CertificatePolicy() { - } - - /** - * Get the id property: The certificate id. - * - * @return the id value. - */ - public String getId() { - return this.id; - } - - /** - * Get the keyProperties property: Properties of the key backing a certificate. - * - * @return the keyProperties value. - */ - public KeyProperties getKeyProperties() { - return this.keyProperties; - } - - /** - * Set the keyProperties property: Properties of the key backing a certificate. - * - * @param keyProperties the keyProperties value to set. - * @return the CertificatePolicy object itself. - */ - public CertificatePolicy setKeyProperties(KeyProperties keyProperties) { - this.keyProperties = keyProperties; - return this; - } - - /** - * Get the secretProperties property: Properties of the secret backing a certificate. - * - * @return the secretProperties value. - */ - public SecretProperties getSecretProperties() { - return this.secretProperties; - } - - /** - * Set the secretProperties property: Properties of the secret backing a certificate. - * - * @param secretProperties the secretProperties value to set. - * @return the CertificatePolicy object itself. - */ - public CertificatePolicy setSecretProperties(SecretProperties secretProperties) { - this.secretProperties = secretProperties; - return this; - } - - /** - * Get the x509CertificateProperties property: Properties of the X509 component of a certificate. - * - * @return the x509CertificateProperties value. - */ - public X509CertificateProperties getX509CertificateProperties() { - return this.x509CertificateProperties; - } - - /** - * Set the x509CertificateProperties property: Properties of the X509 component of a certificate. - * - * @param x509CertificateProperties the x509CertificateProperties value to set. - * @return the CertificatePolicy object itself. - */ - public CertificatePolicy setX509CertificateProperties(X509CertificateProperties x509CertificateProperties) { - this.x509CertificateProperties = x509CertificateProperties; - return this; - } - - /** - * Get the lifetimeActions property: Actions that will be performed by Key Vault over the lifetime of a certificate. - * - * @return the lifetimeActions value. - */ - public List getLifetimeActions() { - return this.lifetimeActions; - } - - /** - * Set the lifetimeActions property: Actions that will be performed by Key Vault over the lifetime of a certificate. - * - * @param lifetimeActions the lifetimeActions value to set. - * @return the CertificatePolicy object itself. - */ - public CertificatePolicy setLifetimeActions(List lifetimeActions) { - this.lifetimeActions = lifetimeActions; - return this; - } - - /** - * Get the issuerParameters property: Parameters for the issuer of the X509 component of a certificate. - * - * @return the issuerParameters value. - */ - public IssuerParameters getIssuerParameters() { - return this.issuerParameters; - } - - /** - * Set the issuerParameters property: Parameters for the issuer of the X509 component of a certificate. - * - * @param issuerParameters the issuerParameters value to set. - * @return the CertificatePolicy object itself. - */ - public CertificatePolicy setIssuerParameters(IssuerParameters issuerParameters) { - this.issuerParameters = issuerParameters; - return this; - } - - /** - * Get the attributes property: The certificate attributes. - * - * @return the attributes value. - */ - public CertificateAttributes getAttributes() { - return this.attributes; - } - - /** - * Set the attributes property: The certificate attributes. - * - * @param attributes the attributes value to set. - * @return the CertificatePolicy object itself. - */ - public CertificatePolicy setAttributes(CertificateAttributes attributes) { - this.attributes = attributes; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeJsonField("key_props", this.keyProperties); - jsonWriter.writeJsonField("secret_props", this.secretProperties); - jsonWriter.writeJsonField("x509_props", this.x509CertificateProperties); - jsonWriter.writeArrayField("lifetime_actions", this.lifetimeActions, - (writer, element) -> writer.writeJson(element)); - jsonWriter.writeJsonField("issuer", this.issuerParameters); - jsonWriter.writeJsonField("attributes", this.attributes); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificatePolicy from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificatePolicy if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificatePolicy. - */ - public static CertificatePolicy fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificatePolicy deserializedCertificatePolicy = new CertificatePolicy(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedCertificatePolicy.id = reader.getString(); - } else if ("key_props".equals(fieldName)) { - deserializedCertificatePolicy.keyProperties = KeyProperties.fromJson(reader); - } else if ("secret_props".equals(fieldName)) { - deserializedCertificatePolicy.secretProperties = SecretProperties.fromJson(reader); - } else if ("x509_props".equals(fieldName)) { - deserializedCertificatePolicy.x509CertificateProperties - = X509CertificateProperties.fromJson(reader); - } else if ("lifetime_actions".equals(fieldName)) { - List lifetimeActions - = reader.readArray(reader1 -> LifetimeAction.fromJson(reader1)); - deserializedCertificatePolicy.lifetimeActions = lifetimeActions; - } else if ("issuer".equals(fieldName)) { - deserializedCertificatePolicy.issuerParameters = IssuerParameters.fromJson(reader); - } else if ("attributes".equals(fieldName)) { - deserializedCertificatePolicy.attributes = CertificateAttributes.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificatePolicy; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificatePolicyAction.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificatePolicyAction.java deleted file mode 100644 index 3a66756b5c94..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificatePolicyAction.java +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -/** The type of the action. */ -public enum CertificatePolicyAction { - /** Enum value EmailContacts. */ - EMAIL_CONTACTS("EmailContacts"), - - /** Enum value AutoRenew. */ - AUTO_RENEW("AutoRenew"); - - /** The actual serialized value for a CertificatePolicyAction instance. */ - private final String value; - - CertificatePolicyAction(String value) { - this.value = value; - } - - /** - * Parses a serialized value to a CertificatePolicyAction instance. - * - * @param value the serialized value to parse. - * @return the parsed CertificatePolicyAction object, or null if unable to parse. - */ - public static CertificatePolicyAction fromString(String value) { - if (value == null) { - return null; - } - CertificatePolicyAction[] items = CertificatePolicyAction.values(); - for (CertificatePolicyAction item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return this.value; - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateRestoreParameters.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateRestoreParameters.java deleted file mode 100644 index 9f85f49d7f06..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateRestoreParameters.java +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.Base64Url; -import com.azure.core.util.CoreUtils; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.Objects; - -/** - * The certificate restore parameters. - */ -@Fluent -public final class CertificateRestoreParameters implements JsonSerializable { - /* - * The backup blob associated with a certificate bundle. - */ - private Base64Url certificateBundleBackup; - - /** - * Creates an instance of CertificateRestoreParameters class. - */ - public CertificateRestoreParameters() { - } - - /** - * Get the certificateBundleBackup property: The backup blob associated with a certificate bundle. - * - * @return the certificateBundleBackup value. - */ - public byte[] getCertificateBundleBackup() { - if (this.certificateBundleBackup == null) { - return null; - } - return this.certificateBundleBackup.decodedBytes(); - } - - /** - * Set the certificateBundleBackup property: The backup blob associated with a certificate bundle. - * - * @param certificateBundleBackup the certificateBundleBackup value to set. - * @return the CertificateRestoreParameters object itself. - */ - public CertificateRestoreParameters setCertificateBundleBackup(byte[] certificateBundleBackup) { - if (certificateBundleBackup == null) { - this.certificateBundleBackup = null; - } else { - this.certificateBundleBackup = Base64Url.encode(CoreUtils.clone(certificateBundleBackup)); - } - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("value", Objects.toString(this.certificateBundleBackup, null)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateRestoreParameters from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateRestoreParameters if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON null. - * @throws IllegalStateException If the deserialized JSON object was missing any required properties. - * @throws IOException If an error occurs while reading the CertificateRestoreParameters. - */ - public static CertificateRestoreParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateRestoreParameters deserializedCertificateRestoreParameters = new CertificateRestoreParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("value".equals(fieldName)) { - deserializedCertificateRestoreParameters.certificateBundleBackup - = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateRestoreParameters; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateUpdateParameters.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateUpdateParameters.java deleted file mode 100644 index c461ed051123..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/CertificateUpdateParameters.java +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.Map; - -/** - * The certificate update parameters. - */ -@Fluent -public final class CertificateUpdateParameters implements JsonSerializable { - /* - * The management policy for the certificate. - */ - private CertificatePolicy certificatePolicy; - - /* - * The attributes of the certificate (optional). - */ - private CertificateAttributes certificateAttributes; - - /* - * Application specific metadata in the form of key-value pairs. - */ - private Map tags; - - /** - * Creates an instance of CertificateUpdateParameters class. - */ - public CertificateUpdateParameters() { - } - - /** - * Get the certificatePolicy property: The management policy for the certificate. - * - * @return the certificatePolicy value. - */ - public CertificatePolicy getCertificatePolicy() { - return this.certificatePolicy; - } - - /** - * Set the certificatePolicy property: The management policy for the certificate. - * - * @param certificatePolicy the certificatePolicy value to set. - * @return the CertificateUpdateParameters object itself. - */ - public CertificateUpdateParameters setCertificatePolicy(CertificatePolicy certificatePolicy) { - this.certificatePolicy = certificatePolicy; - return this; - } - - /** - * Get the certificateAttributes property: The attributes of the certificate (optional). - * - * @return the certificateAttributes value. - */ - public CertificateAttributes getCertificateAttributes() { - return this.certificateAttributes; - } - - /** - * Set the certificateAttributes property: The attributes of the certificate (optional). - * - * @param certificateAttributes the certificateAttributes value to set. - * @return the CertificateUpdateParameters object itself. - */ - public CertificateUpdateParameters setCertificateAttributes(CertificateAttributes certificateAttributes) { - this.certificateAttributes = certificateAttributes; - return this; - } - - /** - * Get the tags property: Application specific metadata in the form of key-value pairs. - * - * @return the tags value. - */ - public Map getTags() { - return this.tags; - } - - /** - * Set the tags property: Application specific metadata in the form of key-value pairs. - * - * @param tags the tags value to set. - * @return the CertificateUpdateParameters object itself. - */ - public CertificateUpdateParameters setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeJsonField("policy", this.certificatePolicy); - jsonWriter.writeJsonField("attributes", this.certificateAttributes); - jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateUpdateParameters from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateUpdateParameters if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificateUpdateParameters. - */ - public static CertificateUpdateParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateUpdateParameters deserializedCertificateUpdateParameters = new CertificateUpdateParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("policy".equals(fieldName)) { - deserializedCertificateUpdateParameters.certificatePolicy = CertificatePolicy.fromJson(reader); - } else if ("attributes".equals(fieldName)) { - deserializedCertificateUpdateParameters.certificateAttributes - = CertificateAttributes.fromJson(reader); - } else if ("tags".equals(fieldName)) { - Map tags = reader.readMap(reader1 -> reader1.getString()); - deserializedCertificateUpdateParameters.tags = tags; - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateUpdateParameters; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/Contacts.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/Contacts.java deleted file mode 100644 index b8140faf4520..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/Contacts.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.models.CertificateContact; -import java.io.IOException; -import java.util.List; - -/** - * The contacts for the vault certificates. - */ -@Fluent -public final class Contacts implements JsonSerializable { - /* - * Identifier for the contacts collection. - */ - private String id; - - /* - * The contact list for the vault certificates. - */ - private List contactList; - - /** - * Creates an instance of Contacts class. - */ - public Contacts() { - } - - /** - * Get the id property: Identifier for the contacts collection. - * - * @return the id value. - */ - public String getId() { - return this.id; - } - - /** - * Get the contactList property: The contact list for the vault certificates. - * - * @return the contactList value. - */ - public List getContactList() { - return this.contactList; - } - - /** - * Set the contactList property: The contact list for the vault certificates. - * - * @param contactList the contactList value to set. - * @return the Contacts object itself. - */ - public Contacts setContactList(List contactList) { - this.contactList = contactList; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeArrayField("contacts", this.contactList, (writer, element) -> writer.writeJson(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of Contacts from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of Contacts if the JsonReader was pointing to an instance of it, or null if it was pointing - * to JSON null. - * @throws IOException If an error occurs while reading the Contacts. - */ - public static Contacts fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - Contacts deserializedContacts = new Contacts(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedContacts.id = reader.getString(); - } else if ("contacts".equals(fieldName)) { - List contactList - = reader.readArray(reader1 -> CertificateContact.fromJson(reader1)); - deserializedContacts.contactList = contactList; - } else { - reader.skipChildren(); - } - } - - return deserializedContacts; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/DeletedCertificateBundle.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/DeletedCertificateBundle.java deleted file mode 100644 index a03211e2d06d..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/DeletedCertificateBundle.java +++ /dev/null @@ -1,268 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.Base64Url; -import com.azure.json.JsonReader; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.util.Map; - -/** - * A Deleted Certificate consisting of its previous id, attributes and its tags, as well as information on when it will - * be purged. - */ -@Fluent -public final class DeletedCertificateBundle extends CertificateBundle { - /* - * The url of the recovery object, used to identify and recover the deleted certificate. - */ - private String recoveryId; - - /* - * The time when the certificate is scheduled to be purged, in UTC - */ - private Long scheduledPurgeDate; - - /* - * The time when the certificate was deleted, in UTC - */ - private Long deletedDate; - - /* - * The management policy. - */ - private CertificatePolicy policy; - - /* - * Thumbprint of the certificate. - */ - private Base64Url x509Thumbprint; - - /* - * The secret id. - */ - private String sid; - - /* - * The key id. - */ - private String kid; - - /* - * The certificate id. - */ - private String id; - - /** - * Creates an instance of DeletedCertificateBundle class. - */ - public DeletedCertificateBundle() { - } - - /** - * Get the recoveryId property: The url of the recovery object, used to identify and recover the deleted - * certificate. - * - * @return the recoveryId value. - */ - public String getRecoveryId() { - return this.recoveryId; - } - - /** - * Set the recoveryId property: The url of the recovery object, used to identify and recover the deleted - * certificate. - * - * @param recoveryId the recoveryId value to set. - * @return the DeletedCertificateBundle object itself. - */ - public DeletedCertificateBundle setRecoveryId(String recoveryId) { - this.recoveryId = recoveryId; - return this; - } - - /** - * Get the scheduledPurgeDate property: The time when the certificate is scheduled to be purged, in UTC. - * - * @return the scheduledPurgeDate value. - */ - public OffsetDateTime getScheduledPurgeDate() { - if (this.scheduledPurgeDate == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.scheduledPurgeDate), ZoneOffset.UTC); - } - - /** - * Get the deletedDate property: The time when the certificate was deleted, in UTC. - * - * @return the deletedDate value. - */ - public OffsetDateTime getDeletedDate() { - if (this.deletedDate == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.deletedDate), ZoneOffset.UTC); - } - - /** - * Get the policy property: The management policy. - * - * @return the policy value. - */ - @Override - public CertificatePolicy getPolicy() { - return this.policy; - } - - /** - * Get the x509Thumbprint property: Thumbprint of the certificate. - * - * @return the x509Thumbprint value. - */ - @Override - public byte[] getX509Thumbprint() { - if (this.x509Thumbprint == null) { - return null; - } - return this.x509Thumbprint.decodedBytes(); - } - - /** - * Get the sid property: The secret id. - * - * @return the sid value. - */ - @Override - public String getSid() { - return this.sid; - } - - /** - * Get the kid property: The key id. - * - * @return the kid value. - */ - @Override - public String getKid() { - return this.kid; - } - - /** - * Get the id property: The certificate id. - * - * @return the id value. - */ - @Override - public String getId() { - return this.id; - } - - /** - * {@inheritDoc} - */ - @Override - public DeletedCertificateBundle setCer(byte[] cer) { - super.setCer(cer); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public DeletedCertificateBundle setContentType(String contentType) { - super.setContentType(contentType); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public DeletedCertificateBundle setAttributes(CertificateAttributes attributes) { - super.setAttributes(attributes); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public DeletedCertificateBundle setTags(Map tags) { - super.setTags(tags); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeBinaryField("cer", getCer()); - jsonWriter.writeStringField("contentType", getContentType()); - jsonWriter.writeJsonField("attributes", getAttributes()); - jsonWriter.writeMapField("tags", getTags(), (writer, element) -> writer.writeString(element)); - jsonWriter.writeStringField("recoveryId", this.recoveryId); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of DeletedCertificateBundle from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of DeletedCertificateBundle if the JsonReader was pointing to an instance of it, or null if - * it was pointing to JSON null. - * @throws IOException If an error occurs while reading the DeletedCertificateBundle. - */ - public static DeletedCertificateBundle fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - DeletedCertificateBundle deserializedDeletedCertificateBundle = new DeletedCertificateBundle(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedDeletedCertificateBundle.id = reader.getString(); - } else if ("kid".equals(fieldName)) { - deserializedDeletedCertificateBundle.kid = reader.getString(); - } else if ("sid".equals(fieldName)) { - deserializedDeletedCertificateBundle.sid = reader.getString(); - } else if ("x5t".equals(fieldName)) { - deserializedDeletedCertificateBundle.x509Thumbprint - = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); - } else if ("policy".equals(fieldName)) { - deserializedDeletedCertificateBundle.policy = CertificatePolicy.fromJson(reader); - } else if ("cer".equals(fieldName)) { - deserializedDeletedCertificateBundle.setCer(reader.getBinary()); - } else if ("contentType".equals(fieldName)) { - deserializedDeletedCertificateBundle.setContentType(reader.getString()); - } else if ("attributes".equals(fieldName)) { - deserializedDeletedCertificateBundle.setAttributes(CertificateAttributes.fromJson(reader)); - } else if ("tags".equals(fieldName)) { - Map tags = reader.readMap(reader1 -> reader1.getString()); - deserializedDeletedCertificateBundle.setTags(tags); - } else if ("recoveryId".equals(fieldName)) { - deserializedDeletedCertificateBundle.recoveryId = reader.getString(); - } else if ("scheduledPurgeDate".equals(fieldName)) { - deserializedDeletedCertificateBundle.scheduledPurgeDate = reader.getNullable(JsonReader::getLong); - } else if ("deletedDate".equals(fieldName)) { - deserializedDeletedCertificateBundle.deletedDate = reader.getNullable(JsonReader::getLong); - } else { - reader.skipChildren(); - } - } - - return deserializedDeletedCertificateBundle; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/DeletedCertificateItem.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/DeletedCertificateItem.java deleted file mode 100644 index 6aa9797e6620..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/DeletedCertificateItem.java +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.core.util.Base64Url; -import com.azure.json.JsonReader; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; - -import java.io.IOException; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.util.Map; - -/** - * The deleted certificate item containing metadata about the deleted certificate. - */ -@Fluent -public final class DeletedCertificateItem extends CertificateItem { - /* - * The url of the recovery object, used to identify and recover the deleted certificate. - */ - private String recoveryId; - - /* - * The time when the certificate is scheduled to be purged, in UTC - */ - private Long scheduledPurgeDate; - - /* - * The time when the certificate was deleted, in UTC - */ - private Long deletedDate; - - /** - * Creates an instance of DeletedCertificateItem class. - */ - public DeletedCertificateItem() { - } - - /** - * Get the recoveryId property: The url of the recovery object, used to identify and recover the deleted - * certificate. - * - * @return the recoveryId value. - */ - public String getRecoveryId() { - return this.recoveryId; - } - - /** - * Set the recoveryId property: The url of the recovery object, used to identify and recover the deleted - * certificate. - * - * @param recoveryId the recoveryId value to set. - * @return the DeletedCertificateItem object itself. - */ - public DeletedCertificateItem setRecoveryId(String recoveryId) { - this.recoveryId = recoveryId; - return this; - } - - /** - * Get the scheduledPurgeDate property: The time when the certificate is scheduled to be purged, in UTC. - * - * @return the scheduledPurgeDate value. - */ - public OffsetDateTime getScheduledPurgeDate() { - if (this.scheduledPurgeDate == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.scheduledPurgeDate), ZoneOffset.UTC); - } - - /** - * Get the deletedDate property: The time when the certificate was deleted, in UTC. - * - * @return the deletedDate value. - */ - public OffsetDateTime getDeletedDate() { - if (this.deletedDate == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.deletedDate), ZoneOffset.UTC); - } - - /** - * {@inheritDoc} - */ - @Override - public DeletedCertificateItem setId(String id) { - super.setId(id); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public DeletedCertificateItem setAttributes(CertificateAttributes attributes) { - super.setAttributes(attributes); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public DeletedCertificateItem setTags(Map tags) { - super.setTags(tags); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public DeletedCertificateItem setX509Thumbprint(byte[] x509Thumbprint) { - super.setX509Thumbprint(x509Thumbprint); - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("id", getId()); - jsonWriter.writeJsonField("attributes", getAttributes()); - jsonWriter.writeMapField("tags", getTags(), JsonWriter::writeString); - - if (getX509Thumbprint() != null) { - jsonWriter.writeStringField("x5t", Base64Url.encode(getX509Thumbprint()).toString()); - } - - jsonWriter.writeStringField("recoveryId", this.recoveryId); - - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of DeletedCertificateItem from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of DeletedCertificateItem if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. - * @throws IOException If an error occurs while reading the DeletedCertificateItem. - */ - public static DeletedCertificateItem fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - DeletedCertificateItem deserializedDeletedCertificateItem = new DeletedCertificateItem(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedDeletedCertificateItem.setId(reader.getString()); - } else if ("attributes".equals(fieldName)) { - deserializedDeletedCertificateItem.setAttributes(CertificateAttributes.fromJson(reader)); - } else if ("tags".equals(fieldName)) { - Map tags = reader.readMap(reader1 -> reader1.getString()); - deserializedDeletedCertificateItem.setTags(tags); - } else if ("x5t".equals(fieldName)) { - Base64Url x509ThumbprintHolder - = reader.getNullable(nonNullReader -> new Base64Url(nonNullReader.getString())); - if (x509ThumbprintHolder != null) { - deserializedDeletedCertificateItem.setX509Thumbprint(x509ThumbprintHolder.decodedBytes()); - } - } else if ("recoveryId".equals(fieldName)) { - deserializedDeletedCertificateItem.recoveryId = reader.getString(); - } else if ("scheduledPurgeDate".equals(fieldName)) { - deserializedDeletedCertificateItem.scheduledPurgeDate = reader.getNullable(JsonReader::getLong); - } else if ("deletedDate".equals(fieldName)) { - deserializedDeletedCertificateItem.deletedDate = reader.getNullable(JsonReader::getLong); - } else { - reader.skipChildren(); - } - } - - return deserializedDeletedCertificateItem; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/DeletedCertificateListResult.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/DeletedCertificateListResult.java deleted file mode 100644 index f3ba01e6a799..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/DeletedCertificateListResult.java +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.List; - -/** - * A list of certificates that have been deleted in this vault. - */ -@Immutable -public final class DeletedCertificateListResult implements JsonSerializable { - /* - * A response message containing a list of deleted certificates in the vault along with a link to the next page of - * deleted certificates - */ - private List value; - - /* - * The URL to get the next set of deleted certificates. - */ - private String nextLink; - - /** - * Creates an instance of DeletedCertificateListResult class. - */ - public DeletedCertificateListResult() { - } - - /** - * Get the value property: A response message containing a list of deleted certificates in the vault along with a - * link to the next page of deleted certificates. - * - * @return the value value. - */ - public List getValue() { - return this.value; - } - - /** - * Get the nextLink property: The URL to get the next set of deleted certificates. - * - * @return the nextLink value. - */ - public String getNextLink() { - return this.nextLink; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of DeletedCertificateListResult from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of DeletedCertificateListResult if the JsonReader was pointing to an instance of it, or null - * if it was pointing to JSON null. - * @throws IOException If an error occurs while reading the DeletedCertificateListResult. - */ - public static DeletedCertificateListResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - DeletedCertificateListResult deserializedDeletedCertificateListResult = new DeletedCertificateListResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("value".equals(fieldName)) { - List value - = reader.readArray(reader1 -> DeletedCertificateItem.fromJson(reader1)); - deserializedDeletedCertificateListResult.value = value; - } else if ("nextLink".equals(fieldName)) { - deserializedDeletedCertificateListResult.nextLink = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedDeletedCertificateListResult; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/DeletionRecoveryLevel.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/DeletionRecoveryLevel.java deleted file mode 100644 index 788f8a757837..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/DeletionRecoveryLevel.java +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.util.ExpandableStringEnum; -import java.util.Collection; - -/** - * Reflects the deletion recovery level currently in effect for certificates in the current vault. If it contains - * 'Purgeable', the certificate can be permanently deleted by a privileged user; otherwise, only the system can purge - * the certificate, at the end of the retention interval. - */ -public final class DeletionRecoveryLevel extends ExpandableStringEnum { - /** - * Denotes a vault state in which deletion is an irreversible operation, without the possibility for recovery. This - * level corresponds to no protection being available against a Delete operation; the data is irretrievably lost - * upon accepting a Delete operation at the entity level or higher (vault, resource group, subscription etc.). - */ - public static final DeletionRecoveryLevel PURGEABLE = fromString("Purgeable"); - - /** - * Denotes a vault state in which deletion is recoverable, and which also permits immediate and permanent deletion - * (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention interval (90 - * days), unless a Purge operation is requested, or the subscription is cancelled. System wil permanently delete it - * after 90 days, if not recovered. - */ - public static final DeletionRecoveryLevel RECOVERABLE_PURGEABLE = fromString("Recoverable+Purgeable"); - - /** - * Denotes a vault state in which deletion is recoverable without the possibility for immediate and permanent - * deletion (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention - * interval(90 days) and while the subscription is still available. System wil permanently delete it after 90 days, - * if not recovered. - */ - public static final DeletionRecoveryLevel RECOVERABLE = fromString("Recoverable"); - - /** - * Denotes a vault and subscription state in which deletion is recoverable within retention interval (90 days), - * immediate and permanent deletion (i.e. purge) is not permitted, and in which the subscription itself cannot be - * permanently canceled. System wil permanently delete it after 90 days, if not recovered. - */ - public static final DeletionRecoveryLevel RECOVERABLE_PROTECTED_SUBSCRIPTION - = fromString("Recoverable+ProtectedSubscription"); - - /** - * Denotes a vault state in which deletion is recoverable, and which also permits immediate and permanent deletion - * (i.e. purge when 7<= SoftDeleteRetentionInDays < 90). This level guarantees the recoverability of the - * deleted entity during the retention interval, unless a Purge operation is requested, or the subscription is - * cancelled. - */ - public static final DeletionRecoveryLevel CUSTOMIZED_RECOVERABLE_PURGEABLE - = fromString("CustomizedRecoverable+Purgeable"); - - /** - * Denotes a vault state in which deletion is recoverable without the possibility for immediate and permanent - * deletion (i.e. purge when 7<= SoftDeleteRetentionInDays < 90).This level guarantees the recoverability of - * the deleted entity during the retention interval and while the subscription is still available. - */ - public static final DeletionRecoveryLevel CUSTOMIZED_RECOVERABLE = fromString("CustomizedRecoverable"); - - /** - * Denotes a vault and subscription state in which deletion is recoverable, immediate and permanent deletion (i.e. - * purge) is not permitted, and in which the subscription itself cannot be permanently canceled when 7<= - * SoftDeleteRetentionInDays < 90. This level guarantees the recoverability of the deleted entity during the - * retention interval, and also reflects the fact that the subscription itself cannot be cancelled. - */ - public static final DeletionRecoveryLevel CUSTOMIZED_RECOVERABLE_PROTECTED_SUBSCRIPTION - = fromString("CustomizedRecoverable+ProtectedSubscription"); - - /** - * Creates a new instance of DeletionRecoveryLevel value. - * - * @deprecated Use the {@link #fromString(String)} factory method. - */ - @Deprecated - public DeletionRecoveryLevel() { - } - - /** - * Creates or finds a DeletionRecoveryLevel from its string representation. - * - * @param name a name to look for. - * @return the corresponding DeletionRecoveryLevel. - */ - public static DeletionRecoveryLevel fromString(String name) { - return fromString(name, DeletionRecoveryLevel.class); - } - - /** - * Gets known DeletionRecoveryLevel values. - * - * @return known DeletionRecoveryLevel values. - */ - public static Collection values() { - return values(DeletionRecoveryLevel.class); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/IssuerAttributes.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/IssuerAttributes.java deleted file mode 100644 index baeff12b4efc..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/IssuerAttributes.java +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; - -/** - * The attributes of an issuer managed by the Key Vault service. - */ -@Fluent -public final class IssuerAttributes implements JsonSerializable { - /* - * Determines whether the issuer is enabled. - */ - private Boolean enabled; - - /* - * Creation time in UTC. - */ - private Long created; - - /* - * Last updated time in UTC. - */ - private Long updated; - - /** - * Creates an instance of IssuerAttributes class. - */ - public IssuerAttributes() { - } - - /** - * Get the enabled property: Determines whether the issuer is enabled. - * - * @return the enabled value. - */ - public Boolean isEnabled() { - return this.enabled; - } - - /** - * Set the enabled property: Determines whether the issuer is enabled. - * - * @param enabled the enabled value to set. - * @return the IssuerAttributes object itself. - */ - public IssuerAttributes setEnabled(Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Get the created property: Creation time in UTC. - * - * @return the created value. - */ - public OffsetDateTime getCreated() { - if (this.created == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.created), ZoneOffset.UTC); - } - - /** - * Get the updated property: Last updated time in UTC. - * - * @return the updated value. - */ - public OffsetDateTime getUpdated() { - if (this.updated == null) { - return null; - } - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(this.updated), ZoneOffset.UTC); - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeBooleanField("enabled", this.enabled); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of IssuerAttributes from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of IssuerAttributes if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the IssuerAttributes. - */ - public static IssuerAttributes fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - IssuerAttributes deserializedIssuerAttributes = new IssuerAttributes(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("enabled".equals(fieldName)) { - deserializedIssuerAttributes.enabled = reader.getNullable(JsonReader::getBoolean); - } else if ("created".equals(fieldName)) { - deserializedIssuerAttributes.created = reader.getNullable(JsonReader::getLong); - } else if ("updated".equals(fieldName)) { - deserializedIssuerAttributes.updated = reader.getNullable(JsonReader::getLong); - } else { - reader.skipChildren(); - } - } - - return deserializedIssuerAttributes; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/IssuerBundle.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/IssuerBundle.java deleted file mode 100644 index 395bbce737d3..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/IssuerBundle.java +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The issuer for Key Vault certificate. - */ -@Fluent -public final class IssuerBundle implements JsonSerializable { - /* - * Identifier for the issuer object. - */ - private String id; - - /* - * The issuer provider. - */ - private String provider; - - /* - * The credentials to be used for the issuer. - */ - private IssuerCredentials credentials; - - /* - * Details of the organization as provided to the issuer. - */ - private OrganizationDetails organizationDetails; - - /* - * Attributes of the issuer object. - */ - private IssuerAttributes attributes; - - /** - * Creates an instance of IssuerBundle class. - */ - public IssuerBundle() { - } - - /** - * Get the id property: Identifier for the issuer object. - * - * @return the id value. - */ - public String getId() { - return this.id; - } - - /** - * Get the provider property: The issuer provider. - * - * @return the provider value. - */ - public String getProvider() { - return this.provider; - } - - /** - * Set the provider property: The issuer provider. - * - * @param provider the provider value to set. - * @return the IssuerBundle object itself. - */ - public IssuerBundle setProvider(String provider) { - this.provider = provider; - return this; - } - - /** - * Get the credentials property: The credentials to be used for the issuer. - * - * @return the credentials value. - */ - public IssuerCredentials getCredentials() { - return this.credentials; - } - - /** - * Set the credentials property: The credentials to be used for the issuer. - * - * @param credentials the credentials value to set. - * @return the IssuerBundle object itself. - */ - public IssuerBundle setCredentials(IssuerCredentials credentials) { - this.credentials = credentials; - return this; - } - - /** - * Get the organizationDetails property: Details of the organization as provided to the issuer. - * - * @return the organizationDetails value. - */ - public OrganizationDetails getOrganizationDetails() { - return this.organizationDetails; - } - - /** - * Set the organizationDetails property: Details of the organization as provided to the issuer. - * - * @param organizationDetails the organizationDetails value to set. - * @return the IssuerBundle object itself. - */ - public IssuerBundle setOrganizationDetails(OrganizationDetails organizationDetails) { - this.organizationDetails = organizationDetails; - return this; - } - - /** - * Get the attributes property: Attributes of the issuer object. - * - * @return the attributes value. - */ - public IssuerAttributes getAttributes() { - return this.attributes; - } - - /** - * Set the attributes property: Attributes of the issuer object. - * - * @param attributes the attributes value to set. - * @return the IssuerBundle object itself. - */ - public IssuerBundle setAttributes(IssuerAttributes attributes) { - this.attributes = attributes; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("provider", this.provider); - jsonWriter.writeJsonField("credentials", this.credentials); - jsonWriter.writeJsonField("org_details", this.organizationDetails); - jsonWriter.writeJsonField("attributes", this.attributes); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of IssuerBundle from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of IssuerBundle if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the IssuerBundle. - */ - public static IssuerBundle fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - IssuerBundle deserializedIssuerBundle = new IssuerBundle(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedIssuerBundle.id = reader.getString(); - } else if ("provider".equals(fieldName)) { - deserializedIssuerBundle.provider = reader.getString(); - } else if ("credentials".equals(fieldName)) { - deserializedIssuerBundle.credentials = IssuerCredentials.fromJson(reader); - } else if ("org_details".equals(fieldName)) { - deserializedIssuerBundle.organizationDetails = OrganizationDetails.fromJson(reader); - } else if ("attributes".equals(fieldName)) { - deserializedIssuerBundle.attributes = IssuerAttributes.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedIssuerBundle; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/IssuerCredentials.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/IssuerCredentials.java deleted file mode 100644 index f6904d67e66b..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/IssuerCredentials.java +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The credentials to be used for the certificate issuer. - */ -@Fluent -public final class IssuerCredentials implements JsonSerializable { - /* - * The user name/account name/account id. - */ - private String accountId; - - /* - * The password/secret/account key. - */ - private String password; - - /** - * Creates an instance of IssuerCredentials class. - */ - public IssuerCredentials() { - } - - /** - * Get the accountId property: The user name/account name/account id. - * - * @return the accountId value. - */ - public String getAccountId() { - return this.accountId; - } - - /** - * Set the accountId property: The user name/account name/account id. - * - * @param accountId the accountId value to set. - * @return the IssuerCredentials object itself. - */ - public IssuerCredentials setAccountId(String accountId) { - this.accountId = accountId; - return this; - } - - /** - * Get the password property: The password/secret/account key. - * - * @return the password value. - */ - public String getPassword() { - return this.password; - } - - /** - * Set the password property: The password/secret/account key. - * - * @param password the password value to set. - * @return the IssuerCredentials object itself. - */ - public IssuerCredentials setPassword(String password) { - this.password = password; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("account_id", this.accountId); - jsonWriter.writeStringField("pwd", this.password); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of IssuerCredentials from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of IssuerCredentials if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the IssuerCredentials. - */ - public static IssuerCredentials fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - IssuerCredentials deserializedIssuerCredentials = new IssuerCredentials(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("account_id".equals(fieldName)) { - deserializedIssuerCredentials.accountId = reader.getString(); - } else if ("pwd".equals(fieldName)) { - deserializedIssuerCredentials.password = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedIssuerCredentials; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/IssuerParameters.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/IssuerParameters.java deleted file mode 100644 index 18d3de76f283..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/IssuerParameters.java +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * Parameters for the issuer of the X509 component of a certificate. - */ -@Fluent -public final class IssuerParameters implements JsonSerializable { - /* - * Name of the referenced issuer object or reserved names; for example, 'Self' or 'Unknown'. - */ - private String name; - - /* - * Certificate type as supported by the provider (optional); for example 'OV-SSL', 'EV-SSL' - */ - private String certificateType; - - /* - * Indicates if the certificates generated under this policy should be published to certificate transparency logs. - */ - private Boolean certificateTransparency; - - /** - * Creates an instance of IssuerParameters class. - */ - public IssuerParameters() { - } - - /** - * Get the name property: Name of the referenced issuer object or reserved names; for example, 'Self' or 'Unknown'. - * - * @return the name value. - */ - public String getName() { - return this.name; - } - - /** - * Set the name property: Name of the referenced issuer object or reserved names; for example, 'Self' or 'Unknown'. - * - * @param name the name value to set. - * @return the IssuerParameters object itself. - */ - public IssuerParameters setName(String name) { - this.name = name; - return this; - } - - /** - * Get the certificateType property: Certificate type as supported by the provider (optional); for example 'OV-SSL', - * 'EV-SSL'. - * - * @return the certificateType value. - */ - public String getCertificateType() { - return this.certificateType; - } - - /** - * Set the certificateType property: Certificate type as supported by the provider (optional); for example 'OV-SSL', - * 'EV-SSL'. - * - * @param certificateType the certificateType value to set. - * @return the IssuerParameters object itself. - */ - public IssuerParameters setCertificateType(String certificateType) { - this.certificateType = certificateType; - return this; - } - - /** - * Get the certificateTransparency property: Indicates if the certificates generated under this policy should be - * published to certificate transparency logs. - * - * @return the certificateTransparency value. - */ - public Boolean isCertificateTransparency() { - return this.certificateTransparency; - } - - /** - * Set the certificateTransparency property: Indicates if the certificates generated under this policy should be - * published to certificate transparency logs. - * - * @param certificateTransparency the certificateTransparency value to set. - * @return the IssuerParameters object itself. - */ - public IssuerParameters setCertificateTransparency(Boolean certificateTransparency) { - this.certificateTransparency = certificateTransparency; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("name", this.name); - jsonWriter.writeStringField("cty", this.certificateType); - jsonWriter.writeBooleanField("cert_transparency", this.certificateTransparency); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of IssuerParameters from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of IssuerParameters if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the IssuerParameters. - */ - public static IssuerParameters fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - IssuerParameters deserializedIssuerParameters = new IssuerParameters(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("name".equals(fieldName)) { - deserializedIssuerParameters.name = reader.getString(); - } else if ("cty".equals(fieldName)) { - deserializedIssuerParameters.certificateType = reader.getString(); - } else if ("cert_transparency".equals(fieldName)) { - deserializedIssuerParameters.certificateTransparency = reader.getNullable(JsonReader::getBoolean); - } else { - reader.skipChildren(); - } - } - - return deserializedIssuerParameters; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/KeyProperties.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/KeyProperties.java deleted file mode 100644 index 2c49b2a5d6af..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/KeyProperties.java +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.models.CertificateKeyCurveName; -import com.azure.security.keyvault.certificates.models.CertificateKeyType; -import java.io.IOException; - -/** - * Properties of the key pair backing a certificate. - */ -@Fluent -public final class KeyProperties implements JsonSerializable { - /* - * Indicates if the private key can be exported. Release policy must be provided when creating the first version of - * an exportable key. - */ - private Boolean exportable; - - /* - * The key size in bits. For example: 2048, 3072, or 4096 for RSA. - */ - private Integer keySize; - - /* - * Indicates if the same key pair will be used on certificate renewal. - */ - private Boolean reuseKey; - - /* - * JsonWebKey Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - */ - private CertificateKeyType kty; - - /* - * Elliptic curve name. For valid values, see JsonWebKeyCurveName. - */ - private CertificateKeyCurveName crv; - - /** - * Creates an instance of KeyProperties class. - */ - public KeyProperties() { - } - - /** - * Get the exportable property: Indicates if the private key can be exported. Release policy must be provided when - * creating the first version of an exportable key. - * - * @return the exportable value. - */ - public Boolean isExportable() { - return this.exportable; - } - - /** - * Set the exportable property: Indicates if the private key can be exported. Release policy must be provided when - * creating the first version of an exportable key. - * - * @param exportable the exportable value to set. - * @return the KeyProperties object itself. - */ - public KeyProperties setExportable(Boolean exportable) { - this.exportable = exportable; - return this; - } - - /** - * Get the keySize property: The key size in bits. For example: 2048, 3072, or 4096 for RSA. - * - * @return the keySize value. - */ - public Integer getKeySize() { - return this.keySize; - } - - /** - * Set the keySize property: The key size in bits. For example: 2048, 3072, or 4096 for RSA. - * - * @param keySize the keySize value to set. - * @return the KeyProperties object itself. - */ - public KeyProperties setKeySize(Integer keySize) { - this.keySize = keySize; - return this; - } - - /** - * Get the reuseKey property: Indicates if the same key pair will be used on certificate renewal. - * - * @return the reuseKey value. - */ - public Boolean isReuseKey() { - return this.reuseKey; - } - - /** - * Set the reuseKey property: Indicates if the same key pair will be used on certificate renewal. - * - * @param reuseKey the reuseKey value to set. - * @return the KeyProperties object itself. - */ - public KeyProperties setReuseKey(Boolean reuseKey) { - this.reuseKey = reuseKey; - return this; - } - - /** - * Get the kty property: JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - * - * @return the kty value. - */ - public CertificateKeyType getKty() { - return this.kty; - } - - /** - * Set the kty property: JsonWebKey Key Type (kty), as defined in - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - * - * @param kty the kty value to set. - * @return the KeyProperties object itself. - */ - public KeyProperties setKty(CertificateKeyType kty) { - this.kty = kty; - return this; - } - - /** - * Get the crv property: Elliptic curve name. For valid values, see JsonWebKeyCurveName. - * - * @return the crv value. - */ - public CertificateKeyCurveName getCrv() { - return this.crv; - } - - /** - * Set the crv property: Elliptic curve name. For valid values, see JsonWebKeyCurveName. - * - * @param crv the crv value to set. - * @return the KeyProperties object itself. - */ - public KeyProperties setCrv(CertificateKeyCurveName crv) { - this.crv = crv; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeBooleanField("exportable", this.exportable); - jsonWriter.writeNumberField("key_size", this.keySize); - jsonWriter.writeBooleanField("reuse_key", this.reuseKey); - jsonWriter.writeStringField("kty", this.kty == null ? null : this.kty.toString()); - jsonWriter.writeStringField("crv", this.crv == null ? null : this.crv.toString()); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of KeyProperties from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of KeyProperties if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the KeyProperties. - */ - public static KeyProperties fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - KeyProperties deserializedKeyProperties = new KeyProperties(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("exportable".equals(fieldName)) { - deserializedKeyProperties.exportable = reader.getNullable(JsonReader::getBoolean); - } else if ("key_size".equals(fieldName)) { - deserializedKeyProperties.keySize = reader.getNullable(JsonReader::getInt); - } else if ("reuse_key".equals(fieldName)) { - deserializedKeyProperties.reuseKey = reader.getNullable(JsonReader::getBoolean); - } else if ("kty".equals(fieldName)) { - deserializedKeyProperties.kty = CertificateKeyType.fromString(reader.getString()); - } else if ("crv".equals(fieldName)) { - deserializedKeyProperties.crv = CertificateKeyCurveName.fromString(reader.getString()); - } else { - reader.skipChildren(); - } - } - - return deserializedKeyProperties; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/KeyVaultError.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/KeyVaultError.java deleted file mode 100644 index cf3c57b0108b..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/KeyVaultError.java +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.models.CertificateOperationError; -import java.io.IOException; - -/** - * The key vault error exception. - */ -@Immutable -public final class KeyVaultError implements JsonSerializable { - /* - * The key vault server error. - */ - private CertificateOperationError error; - - /** - * Creates an instance of KeyVaultError class. - */ - public KeyVaultError() { - } - - /** - * Get the error property: The key vault server error. - * - * @return the error value. - */ - public CertificateOperationError getError() { - return this.error; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of KeyVaultError from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of KeyVaultError if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the KeyVaultError. - */ - public static KeyVaultError fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - KeyVaultError deserializedKeyVaultError = new KeyVaultError(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("error".equals(fieldName)) { - deserializedKeyVaultError.error = CertificateOperationError.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedKeyVaultError; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/KeyVaultErrorException.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/KeyVaultErrorException.java deleted file mode 100644 index 56278adcfef1..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/KeyVaultErrorException.java +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.exception.HttpResponseException; -import com.azure.core.http.HttpResponse; - -/** - * Exception thrown for an invalid response with KeyVaultError information. - */ -public final class KeyVaultErrorException extends HttpResponseException { - /** - * Initializes a new instance of the KeyVaultErrorException class. - * - * @param message the exception message or the response content if a message is not available. - * @param response the HTTP response. - */ - public KeyVaultErrorException(String message, HttpResponse response) { - super(message, response); - } - - /** - * Initializes a new instance of the KeyVaultErrorException class. - * - * @param message the exception message or the response content if a message is not available. - * @param response the HTTP response. - * @param value the deserialized response value. - */ - public KeyVaultErrorException(String message, HttpResponse response, KeyVaultError value) { - super(message, response, value); - } - - /** - * {@inheritDoc} - */ - @Override - public KeyVaultError getValue() { - return (KeyVaultError) super.getValue(); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/LifetimeAction.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/LifetimeAction.java deleted file mode 100644 index e4b934b07da2..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/LifetimeAction.java +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * Action and its trigger that will be performed by Key Vault over the lifetime of a certificate. - */ -@Fluent -public final class LifetimeAction implements JsonSerializable { - /* - * The condition that will execute the action. - */ - private Trigger trigger; - - /* - * The action that will be executed. - */ - private Action action; - - /** - * Creates an instance of LifetimeAction class. - */ - public LifetimeAction() { - } - - /** - * Get the trigger property: The condition that will execute the action. - * - * @return the trigger value. - */ - public Trigger getTrigger() { - return this.trigger; - } - - /** - * Set the trigger property: The condition that will execute the action. - * - * @param trigger the trigger value to set. - * @return the LifetimeAction object itself. - */ - public LifetimeAction setTrigger(Trigger trigger) { - this.trigger = trigger; - return this; - } - - /** - * Get the action property: The action that will be executed. - * - * @return the action value. - */ - public Action getAction() { - return this.action; - } - - /** - * Set the action property: The action that will be executed. - * - * @param action the action value to set. - * @return the LifetimeAction object itself. - */ - public LifetimeAction setAction(Action action) { - this.action = action; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeJsonField("trigger", this.trigger); - jsonWriter.writeJsonField("action", this.action); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of LifetimeAction from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of LifetimeAction if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the LifetimeAction. - */ - public static LifetimeAction fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - LifetimeAction deserializedLifetimeAction = new LifetimeAction(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("trigger".equals(fieldName)) { - deserializedLifetimeAction.trigger = Trigger.fromJson(reader); - } else if ("action".equals(fieldName)) { - deserializedLifetimeAction.action = Action.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedLifetimeAction; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/OrganizationDetails.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/OrganizationDetails.java deleted file mode 100644 index 013853e98f60..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/OrganizationDetails.java +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.models.AdministratorContact; -import java.io.IOException; -import java.util.List; - -/** - * Details of the organization of the certificate issuer. - */ -@Fluent -public final class OrganizationDetails implements JsonSerializable { - /* - * Id of the organization. - */ - private String id; - - /* - * Details of the organization administrator. - */ - private List adminDetails; - - /** - * Creates an instance of OrganizationDetails class. - */ - public OrganizationDetails() { - } - - /** - * Get the id property: Id of the organization. - * - * @return the id value. - */ - public String getId() { - return this.id; - } - - /** - * Set the id property: Id of the organization. - * - * @param id the id value to set. - * @return the OrganizationDetails object itself. - */ - public OrganizationDetails setId(String id) { - this.id = id; - return this; - } - - /** - * Get the adminDetails property: Details of the organization administrator. - * - * @return the adminDetails value. - */ - public List getAdminDetails() { - return this.adminDetails; - } - - /** - * Set the adminDetails property: Details of the organization administrator. - * - * @param adminDetails the adminDetails value to set. - * @return the OrganizationDetails object itself. - */ - public OrganizationDetails setAdminDetails(List adminDetails) { - this.adminDetails = adminDetails; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("id", this.id); - jsonWriter.writeArrayField("admin_details", this.adminDetails, (writer, element) -> writer.writeJson(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of OrganizationDetails from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of OrganizationDetails if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the OrganizationDetails. - */ - public static OrganizationDetails fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - OrganizationDetails deserializedOrganizationDetails = new OrganizationDetails(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - deserializedOrganizationDetails.id = reader.getString(); - } else if ("admin_details".equals(fieldName)) { - List adminDetails - = reader.readArray(reader1 -> AdministratorContact.fromJson(reader1)); - deserializedOrganizationDetails.adminDetails = adminDetails; - } else { - reader.skipChildren(); - } - } - - return deserializedOrganizationDetails; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/PendingCertificateSigningRequestResult.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/PendingCertificateSigningRequestResult.java deleted file mode 100644 index 043e9a17e5ee..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/PendingCertificateSigningRequestResult.java +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The pending certificate signing request result. - */ -@Immutable -public final class PendingCertificateSigningRequestResult - implements JsonSerializable { - /* - * The pending certificate signing request as Base64 encoded string. - */ - private String value; - - /** - * Creates an instance of PendingCertificateSigningRequestResult class. - */ - public PendingCertificateSigningRequestResult() { - } - - /** - * Get the value property: The pending certificate signing request as Base64 encoded string. - * - * @return the value value. - */ - public String getValue() { - return this.value; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of PendingCertificateSigningRequestResult from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of PendingCertificateSigningRequestResult if the JsonReader was pointing to an instance of - * it, or null if it was pointing to JSON null. - * @throws IOException If an error occurs while reading the PendingCertificateSigningRequestResult. - */ - public static PendingCertificateSigningRequestResult fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - PendingCertificateSigningRequestResult deserializedPendingCertificateSigningRequestResult - = new PendingCertificateSigningRequestResult(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("value".equals(fieldName)) { - deserializedPendingCertificateSigningRequestResult.value = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedPendingCertificateSigningRequestResult; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/SecretProperties.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/SecretProperties.java deleted file mode 100644 index 018493f104b7..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/SecretProperties.java +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * Properties of the key backing a certificate. - */ -@Fluent -public final class SecretProperties implements JsonSerializable { - /* - * The media type (MIME type). - */ - private String contentType; - - /** - * Creates an instance of SecretProperties class. - */ - public SecretProperties() { - } - - /** - * Get the contentType property: The media type (MIME type). - * - * @return the contentType value. - */ - public String getContentType() { - return this.contentType; - } - - /** - * Set the contentType property: The media type (MIME type). - * - * @param contentType the contentType value to set. - * @return the SecretProperties object itself. - */ - public SecretProperties setContentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("contentType", this.contentType); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of SecretProperties from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of SecretProperties if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the SecretProperties. - */ - public static SecretProperties fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - SecretProperties deserializedSecretProperties = new SecretProperties(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("contentType".equals(fieldName)) { - deserializedSecretProperties.contentType = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedSecretProperties; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/Trigger.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/Trigger.java deleted file mode 100644 index 5db6c3e060df..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/Trigger.java +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * A condition to be satisfied for an action to be executed. - */ -@Fluent -public final class Trigger implements JsonSerializable { - /* - * Percentage of lifetime at which to trigger. Value should be between 1 and 99. - */ - private Integer lifetimePercentage; - - /* - * Days before expiry to attempt renewal. Value should be between 1 and validity_in_months multiplied by 27. If - * validity_in_months is 36, then value should be between 1 and 972 (36 * 27). - */ - private Integer daysBeforeExpiry; - - /** - * Creates an instance of Trigger class. - */ - public Trigger() { - } - - /** - * Get the lifetimePercentage property: Percentage of lifetime at which to trigger. Value should be between 1 and - * 99. - * - * @return the lifetimePercentage value. - */ - public Integer getLifetimePercentage() { - return this.lifetimePercentage; - } - - /** - * Set the lifetimePercentage property: Percentage of lifetime at which to trigger. Value should be between 1 and - * 99. - * - * @param lifetimePercentage the lifetimePercentage value to set. - * @return the Trigger object itself. - */ - public Trigger setLifetimePercentage(Integer lifetimePercentage) { - this.lifetimePercentage = lifetimePercentage; - return this; - } - - /** - * Get the daysBeforeExpiry property: Days before expiry to attempt renewal. Value should be between 1 and - * validity_in_months multiplied by 27. If validity_in_months is 36, then value should be between 1 and 972 (36 * - * 27). - * - * @return the daysBeforeExpiry value. - */ - public Integer getDaysBeforeExpiry() { - return this.daysBeforeExpiry; - } - - /** - * Set the daysBeforeExpiry property: Days before expiry to attempt renewal. Value should be between 1 and - * validity_in_months multiplied by 27. If validity_in_months is 36, then value should be between 1 and 972 (36 * - * 27). - * - * @param daysBeforeExpiry the daysBeforeExpiry value to set. - * @return the Trigger object itself. - */ - public Trigger setDaysBeforeExpiry(Integer daysBeforeExpiry) { - this.daysBeforeExpiry = daysBeforeExpiry; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeNumberField("lifetime_percentage", this.lifetimePercentage); - jsonWriter.writeNumberField("days_before_expiry", this.daysBeforeExpiry); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of Trigger from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of Trigger if the JsonReader was pointing to an instance of it, or null if it was pointing to - * JSON null. - * @throws IOException If an error occurs while reading the Trigger. - */ - public static Trigger fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - Trigger deserializedTrigger = new Trigger(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("lifetime_percentage".equals(fieldName)) { - deserializedTrigger.lifetimePercentage = reader.getNullable(JsonReader::getInt); - } else if ("days_before_expiry".equals(fieldName)) { - deserializedTrigger.daysBeforeExpiry = reader.getNullable(JsonReader::getInt); - } else { - reader.skipChildren(); - } - } - - return deserializedTrigger; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/X509CertificateProperties.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/X509CertificateProperties.java deleted file mode 100644 index 3ffccc1c717a..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/X509CertificateProperties.java +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.implementation.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.models.CertificateKeyUsage; -import com.azure.security.keyvault.certificates.models.SubjectAlternativeNames; -import java.io.IOException; -import java.util.List; - -/** - * Properties of the X509 component of a certificate. - */ -@Fluent -public final class X509CertificateProperties implements JsonSerializable { - /* - * The subject name. Should be a valid X509 distinguished Name. - */ - private String subject; - - /* - * The enhanced key usage. - */ - private List ekus; - - /* - * The subject alternative names. - */ - private SubjectAlternativeNames subjectAlternativeNames; - - /* - * Defines how the certificate's key may be used. - */ - private List keyUsage; - - /* - * The duration that the certificate is valid in months. - */ - private Integer validityInMonths; - - /** - * Creates an instance of X509CertificateProperties class. - */ - public X509CertificateProperties() { - } - - /** - * Get the subject property: The subject name. Should be a valid X509 distinguished Name. - * - * @return the subject value. - */ - public String getSubject() { - return this.subject; - } - - /** - * Set the subject property: The subject name. Should be a valid X509 distinguished Name. - * - * @param subject the subject value to set. - * @return the X509CertificateProperties object itself. - */ - public X509CertificateProperties setSubject(String subject) { - this.subject = subject; - return this; - } - - /** - * Get the ekus property: The enhanced key usage. - * - * @return the ekus value. - */ - public List getEkus() { - return this.ekus; - } - - /** - * Set the ekus property: The enhanced key usage. - * - * @param ekus the ekus value to set. - * @return the X509CertificateProperties object itself. - */ - public X509CertificateProperties setEkus(List ekus) { - this.ekus = ekus; - return this; - } - - /** - * Get the subjectAlternativeNames property: The subject alternative names. - * - * @return the subjectAlternativeNames value. - */ - public SubjectAlternativeNames getSubjectAlternativeNames() { - return this.subjectAlternativeNames; - } - - /** - * Set the subjectAlternativeNames property: The subject alternative names. - * - * @param subjectAlternativeNames the subjectAlternativeNames value to set. - * @return the X509CertificateProperties object itself. - */ - public X509CertificateProperties setSubjectAlternativeNames(SubjectAlternativeNames subjectAlternativeNames) { - this.subjectAlternativeNames = subjectAlternativeNames; - return this; - } - - /** - * Get the keyUsage property: Defines how the certificate's key may be used. - * - * @return the keyUsage value. - */ - public List getKeyUsage() { - return this.keyUsage; - } - - /** - * Set the keyUsage property: Defines how the certificate's key may be used. - * - * @param keyUsage the keyUsage value to set. - * @return the X509CertificateProperties object itself. - */ - public X509CertificateProperties setKeyUsage(List keyUsage) { - this.keyUsage = keyUsage; - return this; - } - - /** - * Get the validityInMonths property: The duration that the certificate is valid in months. - * - * @return the validityInMonths value. - */ - public Integer getValidityInMonths() { - return this.validityInMonths; - } - - /** - * Set the validityInMonths property: The duration that the certificate is valid in months. - * - * @param validityInMonths the validityInMonths value to set. - * @return the X509CertificateProperties object itself. - */ - public X509CertificateProperties setValidityInMonths(Integer validityInMonths) { - this.validityInMonths = validityInMonths; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("subject", this.subject); - jsonWriter.writeArrayField("ekus", this.ekus, (writer, element) -> writer.writeString(element)); - jsonWriter.writeJsonField("sans", this.subjectAlternativeNames); - jsonWriter.writeArrayField("key_usage", this.keyUsage, - (writer, element) -> writer.writeString(element == null ? null : element.toString())); - jsonWriter.writeNumberField("validity_months", this.validityInMonths); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of X509CertificateProperties from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of X509CertificateProperties if the JsonReader was pointing to an instance of it, or null if - * it was pointing to JSON null. - * @throws IOException If an error occurs while reading the X509CertificateProperties. - */ - public static X509CertificateProperties fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - X509CertificateProperties deserializedX509CertificateProperties = new X509CertificateProperties(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("subject".equals(fieldName)) { - deserializedX509CertificateProperties.subject = reader.getString(); - } else if ("ekus".equals(fieldName)) { - List ekus = reader.readArray(reader1 -> reader1.getString()); - deserializedX509CertificateProperties.ekus = ekus; - } else if ("sans".equals(fieldName)) { - deserializedX509CertificateProperties.subjectAlternativeNames - = SubjectAlternativeNames.fromJson(reader); - } else if ("key_usage".equals(fieldName)) { - List keyUsage - = reader.readArray(reader1 -> CertificateKeyUsage.fromString(reader1.getString())); - deserializedX509CertificateProperties.keyUsage = keyUsage; - } else if ("validity_months".equals(fieldName)) { - deserializedX509CertificateProperties.validityInMonths = reader.getNullable(JsonReader::getInt); - } else { - reader.skipChildren(); - } - } - - return deserializedX509CertificateProperties; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/package-info.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/package-info.java deleted file mode 100644 index c26554b225b6..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/models/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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 CertificateClient. - * The key vault client performs cryptographic key operations and vault operations against the Key Vault service. - */ -package com.azure.security.keyvault.certificates.implementation.models; diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/package-info.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/package-info.java deleted file mode 100644 index 843b387e49ad..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/implementation/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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 CertificateClient. - * The key vault client performs cryptographic key operations and vault operations against the Key Vault service. - */ -package com.azure.security.keyvault.certificates.implementation; diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/AdministratorContact.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/AdministratorContact.java deleted file mode 100644 index acdbf81bbe92..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/AdministratorContact.java +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * Details of the organization administrator of the certificate issuer. - */ -@Fluent -public final class AdministratorContact implements JsonSerializable { - /* - * First name. - */ - private String firstName; - - /* - * Last name. - */ - private String lastName; - - /* - * Email address. - */ - private String email; - - /* - * Phone number. - */ - private String phone; - - /** - * Creates an instance of AdministratorContact class. - */ - public AdministratorContact() { - } - - /** - * Get the firstName property: First name. - * - * @return the firstName value. - */ - public String getFirstName() { - return this.firstName; - } - - /** - * Set the firstName property: First name. - * - * @param firstName the firstName value to set. - * @return the AdministratorContact object itself. - */ - public AdministratorContact setFirstName(String firstName) { - this.firstName = firstName; - return this; - } - - /** - * Get the lastName property: Last name. - * - * @return the lastName value. - */ - public String getLastName() { - return this.lastName; - } - - /** - * Set the lastName property: Last name. - * - * @param lastName the lastName value to set. - * @return the AdministratorContact object itself. - */ - public AdministratorContact setLastName(String lastName) { - this.lastName = lastName; - return this; - } - - /** - * Get the email property: Email address. - * - * @return the email value. - */ - public String getEmail() { - return this.email; - } - - /** - * Set the email property: Email address. - * - * @param email the email value to set. - * @return the AdministratorContact object itself. - */ - public AdministratorContact setEmail(String email) { - this.email = email; - return this; - } - - /** - * Get the phone property: Phone number. - * - * @return the phone value. - */ - public String getPhone() { - return this.phone; - } - - /** - * Set the phone property: Phone number. - * - * @param phone the phone value to set. - * @return the AdministratorContact object itself. - */ - public AdministratorContact setPhone(String phone) { - this.phone = phone; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("first_name", this.firstName); - jsonWriter.writeStringField("last_name", this.lastName); - jsonWriter.writeStringField("email", this.email); - jsonWriter.writeStringField("phone", this.phone); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of AdministratorContact from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of AdministratorContact if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. - * @throws IOException If an error occurs while reading the AdministratorContact. - */ - public static AdministratorContact fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - AdministratorContact deserializedAdministratorContact = new AdministratorContact(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("first_name".equals(fieldName)) { - deserializedAdministratorContact.firstName = reader.getString(); - } else if ("last_name".equals(fieldName)) { - deserializedAdministratorContact.lastName = reader.getString(); - } else if ("email".equals(fieldName)) { - deserializedAdministratorContact.email = reader.getString(); - } else if ("phone".equals(fieldName)) { - deserializedAdministratorContact.phone = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedAdministratorContact; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateContact.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateContact.java deleted file mode 100644 index a256a84dd06a..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateContact.java +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The contact information for the vault certificates. - */ -@Fluent -public final class CertificateContact implements JsonSerializable { - /* - * Email address. - */ - private String email; - - /* - * Name. - */ - private String name; - - /* - * Phone number. - */ - private String phone; - - /** - * Creates an instance of CertificateContact class. - */ - public CertificateContact() { - } - - /** - * Get the email property: Email address. - * - * @return the email value. - */ - public String getEmail() { - return this.email; - } - - /** - * Set the email property: Email address. - * - * @param email the email value to set. - * @return the CertificateContact object itself. - */ - public CertificateContact setEmail(String email) { - this.email = email; - return this; - } - - /** - * Get the name property: Name. - * - * @return the name value. - */ - public String getName() { - return this.name; - } - - /** - * Set the name property: Name. - * - * @param name the name value to set. - * @return the CertificateContact object itself. - */ - public CertificateContact setName(String name) { - this.name = name; - return this; - } - - /** - * Get the phone property: Phone number. - * - * @return the phone value. - */ - public String getPhone() { - return this.phone; - } - - /** - * Set the phone property: Phone number. - * - * @param phone the phone value to set. - * @return the CertificateContact object itself. - */ - public CertificateContact setPhone(String phone) { - this.phone = phone; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeStringField("email", this.email); - jsonWriter.writeStringField("name", this.name); - jsonWriter.writeStringField("phone", this.phone); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateContact from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateContact if the JsonReader was pointing to an instance of it, or null if it was - * pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificateContact. - */ - public static CertificateContact fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateContact deserializedCertificateContact = new CertificateContact(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("email".equals(fieldName)) { - deserializedCertificateContact.email = reader.getString(); - } else if ("name".equals(fieldName)) { - deserializedCertificateContact.name = reader.getString(); - } else if ("phone".equals(fieldName)) { - deserializedCertificateContact.phone = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateContact; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateContentType.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateContentType.java deleted file mode 100644 index 5d3505da6dd5..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateContentType.java +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.util.ExpandableStringEnum; - -import java.util.Collection; - -/** - * Content type of the certificate when the managed secret is downloaded using a {@code SecretClient}. - */ -public final class CertificateContentType extends ExpandableStringEnum { - - /** - * Static value {@code PKCS12} for {@link CertificateContentType}. - */ - public static final CertificateContentType PKCS12 = fromString("application/x-pkcs12"); - - /** - * Static value {@code PEM} for {@link CertificateContentType}. - */ - public static final CertificateContentType PEM = fromString("application/x-pem-file"); - - /** - * Creates a new instance of CertificateContentType value. - * - * @deprecated Use the {@link #fromString(String)} factory method. - */ - @Deprecated - public CertificateContentType() { - } - - /** - * Creates or finds a {@link CertificateContentType} from its string representation. - * - * @param name A name to look for. - * @return The corresponding {@link CertificateContentType}. - */ - public static CertificateContentType fromString(String name) { - return fromString(name, CertificateContentType.class); - } - - /** - * Gets the known values for {@link CertificateContentType}. - * - * @return Known {@link CertificateContentType} values. - */ - public static Collection values() { - return values(CertificateContentType.class); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateIssuer.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateIssuer.java deleted file mode 100644 index fccf699a2213..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateIssuer.java +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.util.logging.ClientLogger; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.implementation.CertificateIssuerHelper; -import com.azure.security.keyvault.certificates.implementation.models.IssuerAttributes; -import com.azure.security.keyvault.certificates.implementation.models.IssuerBundle; -import com.azure.security.keyvault.certificates.implementation.models.IssuerCredentials; -import com.azure.security.keyvault.certificates.implementation.models.OrganizationDetails; - -import java.io.IOException; -import java.time.OffsetDateTime; -import java.util.List; - -import static com.azure.security.keyvault.certificates.implementation.CertificatesUtils.getIdMetadata; - -/** - * Represents certificate Issuer with all of its properties. - */ -public final class CertificateIssuer implements JsonSerializable { - private static final ClientLogger LOGGER = new ClientLogger(CertificateIssuer.class); - - static { - CertificateIssuerHelper.setAccessor(new CertificateIssuerHelper.CertificateIssuerAccessor() { - @Override - public CertificateIssuer createCertificateIssuer(IssuerBundle impl) { - return new CertificateIssuer(impl); - } - - @Override - public IssuerBundle getImpl(CertificateIssuer certificateIssuer) { - return certificateIssuer.impl; - } - }); - } - - private final IssuerBundle impl; - - /** - * Name of the referenced issuer object or reserved names; for example, - * 'Self' or 'Unknown'. - */ - private final String name; - - /** - * Creates an instance of the issuer. - * - * @param name The name of the issuer. - * @param provider The provider of the issuer. - */ - public CertificateIssuer(String name, String provider) { - this.name = name; - this.impl = new IssuerBundle().setProvider(provider); - } - - /** - * Creates an instance of the issuer. - * - * @param name The name of the issuer. - */ - public CertificateIssuer(String name) { - this(name, null); - } - - private CertificateIssuer(IssuerBundle impl) { - this.impl = impl; - this.name = getIdMetadata(impl.getId(), -1, 3, -1, LOGGER).getName(); - } - - /** - * Get the id of the issuer. - * @return the identifier. - */ - public String getId() { - return impl.getId(); - } - - /** - * Get the issuer provider - * @return the issuer provider - */ - public String getProvider() { - return impl.getProvider(); - } - - /** - * Get the issuer name - * @return the issuer name - */ - public String getName() { - return name; - } - - /** - * Get the account id of the issuer. - * @return the account id - */ - public String getAccountId() { - return impl.getCredentials() == null ? null : impl.getCredentials().getAccountId(); - } - - /** - * Set the account id of the issuer. - * @param accountId the account id to set. - * @return the Issuer object itself. - */ - public CertificateIssuer setAccountId(String accountId) { - if (impl.getCredentials() == null) { - impl.setCredentials(new IssuerCredentials()); - } - - impl.getCredentials().setAccountId(accountId); - return this; - } - - /** - * Get the password of the issuer. - * @return the password - */ - public String getPassword() { - return impl.getCredentials() == null ? null : impl.getCredentials().getPassword(); - } - - /** - * Set the password id of the issuer. - * @param password the password set. - * @return the Issuer object itself. - */ - public CertificateIssuer setPassword(String password) { - if (impl.getCredentials() == null) { - impl.setCredentials(new IssuerCredentials()); - } - - impl.getCredentials().setPassword(password); - return this; - } - - /** - * Get the organization id of the issuer. - * @return the organization id - */ - public String getOrganizationId() { - return impl.getOrganizationDetails() == null ? null : impl.getOrganizationDetails().getId(); - } - - /** - * Set the organization id of the issuer. - * @param organizationId the org id to set. - * @return the Issuer object itself. - */ - public CertificateIssuer setOrganizationId(String organizationId) { - if (impl.getOrganizationDetails() == null) { - impl.setOrganizationDetails(new OrganizationDetails()); - } - - impl.getOrganizationDetails().setId(organizationId); - return this; - } - - /** - * Get the administrators of the issuer. - * @return the administrators - */ - public List getAdministratorContacts() { - return impl.getOrganizationDetails() == null ? null : impl.getOrganizationDetails().getAdminDetails(); - } - - /** - * Set the administrators of the issuer. - * @param administratorContacts the administrators to set. - * @return the Issuer object itself. - */ - public CertificateIssuer setAdministratorContacts(List administratorContacts) { - if (impl.getOrganizationDetails() == null) { - impl.setOrganizationDetails(new OrganizationDetails()); - } - - impl.getOrganizationDetails().setAdminDetails(administratorContacts); - return this; - } - - /** - * Get the enabled status - * @return the enabled status - */ - public Boolean isEnabled() { - return impl.getAttributes() == null ? null : impl.getAttributes().isEnabled(); - } - - /** - * Set the enabled status - * @param enabled the enabled status to set - * @return the Issuer object itself. - */ - public CertificateIssuer setEnabled(Boolean enabled) { - if (impl.getAttributes() == null) { - impl.setAttributes(new IssuerAttributes()); - } - - impl.getAttributes().setEnabled(enabled); - return this; - } - - /** - * Get the created UTC time. - * @return the created UTC time. - */ - public OffsetDateTime getCreatedOn() { - return impl.getAttributes() == null ? null : impl.getAttributes().getCreated(); - } - - /** - * Get the updated UTC time. - * @return the updated UTC time. - */ - public OffsetDateTime getUpdatedOn() { - return impl.getAttributes() == null ? null : impl.getAttributes().getUpdated(); - } - - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - return impl.toJson(jsonWriter); - } - - /** - * Reads a JSON stream into a {@link CertificateIssuer}. - * - * @param jsonReader The {@link JsonReader} being read. - * @return The {@link CertificateIssuer} that the JSON stream represented, may return null. - * @throws IOException If a {@link CertificateIssuer} fails to be read from the {@code jsonReader}. - */ - public static CertificateIssuer fromJson(JsonReader jsonReader) throws IOException { - return new CertificateIssuer(IssuerBundle.fromJson(jsonReader)); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateKeyCurveName.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateKeyCurveName.java deleted file mode 100644 index 023bcbb7845b..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateKeyCurveName.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.util.ExpandableStringEnum; -import java.util.Collection; - -/** - * Elliptic curve name. For valid values, see JsonWebKeyCurveName. - */ -public final class CertificateKeyCurveName extends ExpandableStringEnum { - - /** - * The NIST P-256 elliptic curve, AKA SECG curve SECP256R1. - */ - public static final CertificateKeyCurveName P_256 = fromString("P-256"); - - /** - * The NIST P-384 elliptic curve, AKA SECG curve SECP384R1. - */ - public static final CertificateKeyCurveName P_384 = fromString("P-384"); - - /** - * The NIST P-521 elliptic curve, AKA SECG curve SECP521R1. - */ - public static final CertificateKeyCurveName P_521 = fromString("P-521"); - - /** - * The SECG SECP256K1 elliptic curve. - */ - public static final CertificateKeyCurveName P_256K = fromString("P-256K"); - - /** - * Creates a new instance of CertificateKeyCurveName value. - * - * @deprecated Use the {@link #fromString(String)} factory method. - */ - @Deprecated - public CertificateKeyCurveName() { - } - - /** - * Creates or finds a CertificateKeyCurveName from its string representation. - * - * @param name a name to look for. - * @return the corresponding CertificateKeyCurveName. - */ - public static CertificateKeyCurveName fromString(String name) { - return fromString(name, CertificateKeyCurveName.class); - } - - /** - * Gets known CertificateKeyCurveName values. - * - * @return known CertificateKeyCurveName values. - */ - public static Collection values() { - return values(CertificateKeyCurveName.class); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateKeyType.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateKeyType.java deleted file mode 100644 index 82019be3f0d1..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateKeyType.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.util.ExpandableStringEnum; -import java.util.Collection; - -/** - * JsonWebKey Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. - */ -public final class CertificateKeyType extends ExpandableStringEnum { - /** - * Elliptic Curve. - */ - public static final CertificateKeyType EC = fromString("EC"); - - /** - * Elliptic Curve with a private key which is stored in the HSM. - */ - public static final CertificateKeyType EC_HSM = fromString("EC-HSM"); - - /** - * RSA (https://tools.ietf.org/html/rfc3447). - */ - public static final CertificateKeyType RSA = fromString("RSA"); - - /** - * RSA with a private key which is stored in the HSM. - */ - public static final CertificateKeyType RSA_HSM = fromString("RSA-HSM"); - - /** - * Creates a new instance of CertificateKeyType value. - * - * @deprecated Use the {@link #fromString(String)} factory method. - */ - @Deprecated - public CertificateKeyType() { - } - - /** - * Creates or finds a CertificateKeyType from its string representation. - * - * @param name a name to look for. - * @return the corresponding CertificateKeyType. - */ - public static CertificateKeyType fromString(String name) { - return fromString(name, CertificateKeyType.class); - } - - /** - * Gets known CertificateKeyType values. - * - * @return known CertificateKeyType values. - */ - public static Collection values() { - return values(CertificateKeyType.class); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateKeyUsage.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateKeyUsage.java deleted file mode 100644 index 150976d3ad2d..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateKeyUsage.java +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.util.ExpandableStringEnum; -import java.util.Collection; - -/** - * Defines values for CertificateKeyUsage. - */ -public final class CertificateKeyUsage extends ExpandableStringEnum { - /** - * Static value digitalSignature for CertificateKeyUsage. - */ - public static final CertificateKeyUsage DIGITAL_SIGNATURE = fromString("digitalSignature"); - - /** - * Static value nonRepudiation for CertificateKeyUsage. - */ - public static final CertificateKeyUsage NON_REPUDIATION = fromString("nonRepudiation"); - - /** - * Static value keyEncipherment for CertificateKeyUsage. - */ - public static final CertificateKeyUsage KEY_ENCIPHERMENT = fromString("keyEncipherment"); - - /** - * Static value dataEncipherment for CertificateKeyUsage. - */ - public static final CertificateKeyUsage DATA_ENCIPHERMENT = fromString("dataEncipherment"); - - /** - * Static value keyAgreement for CertificateKeyUsage. - */ - public static final CertificateKeyUsage KEY_AGREEMENT = fromString("keyAgreement"); - - /** - * Static value keyCertSign for CertificateKeyUsage. - */ - public static final CertificateKeyUsage KEY_CERT_SIGN = fromString("keyCertSign"); - - /** - * Static value cRLSign for CertificateKeyUsage. - */ - public static final CertificateKeyUsage CRL_SIGN = fromString("cRLSign"); - - /** - * Static value encipherOnly for CertificateKeyUsage. - */ - public static final CertificateKeyUsage ENCIPHER_ONLY = fromString("encipherOnly"); - - /** - * Static value decipherOnly for CertificateKeyUsage. - */ - public static final CertificateKeyUsage DECIPHER_ONLY = fromString("decipherOnly"); - - /** - * Creates a new instance of CertificateKeyUsage value. - * - * @deprecated Use the {@link #fromString(String)} factory method. - */ - @Deprecated - public CertificateKeyUsage() { - } - - /** - * Creates or finds a CertificateKeyUsage from its string representation. - * - * @param name a name to look for. - * @return the corresponding CertificateKeyUsage. - */ - public static CertificateKeyUsage fromString(String name) { - return fromString(name, CertificateKeyUsage.class); - } - - /** - * Gets known CertificateKeyUsage values. - * - * @return known CertificateKeyUsage values. - */ - public static Collection values() { - return values(CertificateKeyUsage.class); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateOperation.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateOperation.java deleted file mode 100644 index f049e842733b..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateOperation.java +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.util.logging.ClientLogger; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.implementation.CertificateOperationHelper; -import com.azure.security.keyvault.certificates.implementation.IdMetadata; - -import java.io.IOException; - -import static com.azure.security.keyvault.certificates.implementation.CertificatesUtils.getIdMetadata; - -/** - * A certificate operation is returned in case of long-running service requests. - */ -public final class CertificateOperation implements JsonSerializable { - private static final ClientLogger LOGGER = new ClientLogger(CertificateOperation.class); - - static { - CertificateOperationHelper.setAccessor(CertificateOperation::new); - } - - private final com.azure.security.keyvault.certificates.implementation.models.CertificateOperation impl; - - /** - * Creates an instance of {@link CertificateOperation}. - */ - public CertificateOperation() { - this(new com.azure.security.keyvault.certificates.implementation.models.CertificateOperation()); - } - - private CertificateOperation( - com.azure.security.keyvault.certificates.implementation.models.CertificateOperation impl) { - this.impl = impl; - IdMetadata idMetadata = getIdMetadata(impl.getId(), 1, 2, -1, LOGGER); - - this.vaultUrl = idMetadata.getVaultUrl(); - this.name = idMetadata.getName(); - } - - /** - * URL for the Azure KeyVault service. - */ - private final String vaultUrl; - - /** - * The Certificate name. - */ - private final String name; - - /** - * Get the identifier. - * - * @return the identifier. - */ - public String getId() { - return impl.getId(); - } - - /** - * Get the issuer name. - * - * @return the issuer name - */ - public String getIssuerName() { - return impl.getIssuerParameters() == null ? null : impl.getIssuerParameters().getName(); - } - - /** - * Get the certificate type. - * - * @return the certificateType - */ - public String getCertificateType() { - return impl.getIssuerParameters() == null ? null : impl.getIssuerParameters().getCertificateType(); - } - - /** - * Get the certificate transparency status. - * - * @return the certificateTransparency status. - */ - public boolean isCertificateTransparent() { - return impl.getIssuerParameters() != null && impl.getIssuerParameters().isCertificateTransparency(); - } - - /** - * Get the csr. - * - * @return the csr. - */ - public byte[] getCsr() { - return impl.getCsr(); - } - - /** - * Get the cancellation requested status. - * - * @return the cancellationRequested status. - */ - public Boolean getCancellationRequested() { - return impl.isCancellationRequested(); - } - - /** - * Get the status. - * - * @return the status - */ - public String getStatus() { - return impl.getStatus(); - } - - /** - * Get the status details. - * - * @return the status details - */ - public String getStatusDetails() { - return impl.getStatusDetails(); - } - - /** - * Get the error. - * - * @return the error - */ - public CertificateOperationError getError() { - return impl.getError(); - } - - /** - * Get the target. - * - * @return the target - */ - public String getTarget() { - return impl.getTarget(); - } - - /** - * Get the requestId. - * - * @return the requestId - */ - public String getRequestId() { - return impl.getRequestId(); - } - - /** - * Get the URL for the Azure KeyVault service. - * - * @return the value of the URL for the Azure KeyVault service. - */ - public String getVaultUrl() { - return this.vaultUrl; - } - - /** - * Get the certificate name. - * - * @return the name of the certificate. - */ - public String getName() { - return this.name; - } - - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - return impl.toJson(jsonWriter); - } - - /** - * Reads a JSON stream into a {@link CertificateOperation}. - * - * @param jsonReader The {@link JsonReader} being read. - * @return The {@link CertificateOperation} that the JSON stream represented, may return null. - * @throws IOException If a {@link CertificateOperation} fails to be read from the {@code jsonReader}. - */ - public static CertificateOperation fromJson(JsonReader jsonReader) throws IOException { - return new CertificateOperation( - com.azure.security.keyvault.certificates.implementation.models.CertificateOperation.fromJson(jsonReader)); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateOperationError.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateOperationError.java deleted file mode 100644 index 46421d747091..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateOperationError.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.annotation.Immutable; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; - -/** - * The key vault server error. - */ -@Immutable -public final class CertificateOperationError implements JsonSerializable { - /* - * The error code. - */ - private String code; - - /* - * The error message. - */ - private String message; - - /* - * The key vault server error. - */ - private CertificateOperationError innerError; - - /** - * Creates an instance of CertificateOperationError class. - */ - public CertificateOperationError() { - } - - /** - * Get the code property: The error code. - * - * @return the code value. - */ - public String getCode() { - return this.code; - } - - /** - * Get the message property: The error message. - * - * @return the message value. - */ - public String getMessage() { - return this.message; - } - - /** - * Get the innerError property: The key vault server error. - * - * @return the innerError value. - */ - public CertificateOperationError getInnerError() { - return this.innerError; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of CertificateOperationError from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of CertificateOperationError if the JsonReader was pointing to an instance of it, or null if - * it was pointing to JSON null. - * @throws IOException If an error occurs while reading the CertificateOperationError. - */ - public static CertificateOperationError fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - CertificateOperationError deserializedCertificateOperationError = new CertificateOperationError(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("code".equals(fieldName)) { - deserializedCertificateOperationError.code = reader.getString(); - } else if ("message".equals(fieldName)) { - deserializedCertificateOperationError.message = reader.getString(); - } else if ("innererror".equals(fieldName)) { - deserializedCertificateOperationError.innerError = CertificateOperationError.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return deserializedCertificateOperationError; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificatePolicy.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificatePolicy.java deleted file mode 100644 index c4021d98f41e..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificatePolicy.java +++ /dev/null @@ -1,491 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.implementation.CertificatePolicyHelper; -import com.azure.security.keyvault.certificates.implementation.models.CertificateAttributes; -import com.azure.security.keyvault.certificates.implementation.models.IssuerParameters; -import com.azure.security.keyvault.certificates.implementation.models.KeyProperties; -import com.azure.security.keyvault.certificates.implementation.models.SecretProperties; -import com.azure.security.keyvault.certificates.implementation.models.X509CertificateProperties; - -import java.io.IOException; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; - -/** - * The Certificate Management policy for the {@link KeyVaultCertificate certificate}. - */ -public final class CertificatePolicy implements JsonSerializable { - static { - CertificatePolicyHelper.setAccessor(new CertificatePolicyHelper.CertificatePolicyAccessor() { - @Override - public CertificatePolicy - createPolicy(com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy impl) { - return new CertificatePolicy(impl); - } - - @Override - public com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy - getPolicy(CertificatePolicy policy) { - return policy == null ? null : policy.impl; - } - }); - } - - private final com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy impl; - - private List lifetimeActions; - - /** - * Creates certificate policy. - * @param issuerName The issuer name to set. - * @param subject The subject name to set. - */ - public CertificatePolicy(String issuerName, String subject) { - this.impl = new com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy() - .setIssuerParameters(new IssuerParameters().setName(issuerName)) - .setX509CertificateProperties(new X509CertificateProperties().setSubject(subject)); - } - - /** - * Creates certificate policy. - * @param issuerName The issuer name to set. - * @param subjectAlternativeNames The subject alternative names to set. - */ - public CertificatePolicy(String issuerName, SubjectAlternativeNames subjectAlternativeNames) { - this.impl = new com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy() - .setIssuerParameters(new IssuerParameters().setName(issuerName)) - .setX509CertificateProperties( - new X509CertificateProperties().setSubjectAlternativeNames(subjectAlternativeNames)); - } - - /** - * Creates certificate policy. - * @param issuerName The issuer name to set. - * @param subject The subject name to set. - * @param subjectAlternativeNames The subject alternative names to set. - */ - public CertificatePolicy(String issuerName, String subject, SubjectAlternativeNames subjectAlternativeNames) { - this.impl = new com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy() - .setIssuerParameters(new IssuerParameters().setName(issuerName)) - .setX509CertificateProperties(new X509CertificateProperties().setSubject(subject) - .setSubjectAlternativeNames(subjectAlternativeNames)); - } - - private CertificatePolicy(com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy impl) { - this.impl = impl; - } - - /** - * Get the key usage. - * - * @return the key usage - */ - public List getKeyUsage() { - return impl.getX509CertificateProperties().getKeyUsage(); - } - - /** - * Set the key usage. - * - * @param keyUsage the key usage value to set - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setKeyUsage(CertificateKeyUsage... keyUsage) { - if (keyUsage == null) { - impl.getX509CertificateProperties().setKeyUsage(null); - } else { - impl.getX509CertificateProperties().setKeyUsage(Arrays.asList(keyUsage)); - } - - return this; - } - - /** - * Get the enhanced key usage. - * - * @return the enhanced key usage - */ - public List getEnhancedKeyUsage() { - return impl.getX509CertificateProperties().getEkus(); - } - - /** - * Set the enhanced key usage. - * - * @param ekus the ekus value to set - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setEnhancedKeyUsage(List ekus) { - impl.getX509CertificateProperties().setEkus(ekus); - - return this; - } - - /** - * Get the exportable. - * - * @return the exportable value - */ - public Boolean isExportable() { - return impl.getKeyProperties() == null ? null : impl.getKeyProperties().isExportable(); - } - - /** - * Set the exportable value. - * - * @param exportable the exportable value to set - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setExportable(Boolean exportable) { - if (impl.getKeyProperties() == null) { - impl.setKeyProperties(new KeyProperties()); - } - - impl.getKeyProperties().setExportable(exportable); - return this; - } - - /** - * Get the key type. - * - * @return the key type value - */ - public CertificateKeyType getKeyType() { - return impl.getKeyProperties() == null ? null : impl.getKeyProperties().getKty(); - } - - /** - * Get the key type. - * - * @param keyType the key type - * @return the key type - */ - public CertificatePolicy setKeyType(CertificateKeyType keyType) { - if (impl.getKeyProperties() == null) { - impl.setKeyProperties(new KeyProperties()); - } - - impl.getKeyProperties().setKty(keyType); - return this; - } - - /** - * Get the key size. - * - * @return the key size - */ - public Integer getKeySize() { - return impl.getKeyProperties() == null ? null : impl.getKeyProperties().getKeySize(); - } - - /** - * Get the key reuse status. - * - * @return the key reuse status - */ - public Boolean isKeyReusable() { - return impl.getKeyProperties() == null ? null : impl.getKeyProperties().isReuseKey(); - } - - /** - * Set the reuse key value. - * - * @param keyReusable the reuseKey value to set - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setKeyReusable(Boolean keyReusable) { - if (impl.getKeyProperties() == null) { - impl.setKeyProperties(new KeyProperties()); - } - - impl.getKeyProperties().setReuseKey(keyReusable); - return this; - } - - /** - * Get the key curve. - * - * @return the curve value - */ - public CertificateKeyCurveName getKeyCurveName() { - return impl.getKeyProperties() == null ? null : impl.getKeyProperties().getCrv(); - } - - /** - * Get the the UTC time at which certificate policy was created. - * - * @return the created UTC time. - */ - public OffsetDateTime getCreatedOn() { - return impl.getAttributes() == null ? null : impl.getAttributes().getCreated(); - } - - /** - * Get the UTC time at which certificate policy was last updated. - * - * @return the last updated UTC time. - */ - public OffsetDateTime getUpdatedOn() { - return impl.getAttributes() == null ? null : impl.getAttributes().getUpdated(); - } - - /** - * Get the enabled status. - * - * @return the enabled status - */ - public Boolean isEnabled() { - return impl.getAttributes() == null ? null : impl.getAttributes().isEnabled(); - } - - /** - * Set the enabled status. - * @param enabled The enabled status to set. - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setEnabled(Boolean enabled) { - if (impl.getAttributes() == null) { - impl.setAttributes(new CertificateAttributes()); - } - - impl.getAttributes().setEnabled(enabled); - return this; - } - - /** - * Get the content type. - * - * @return the content type - */ - public CertificateContentType getContentType() { - return impl.getSecretProperties() == null - ? null - : CertificateContentType.fromString(impl.getSecretProperties().getContentType()); - } - - /** - * Set the content type. - * - * @param contentType the content type value to set - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setContentType(CertificateContentType contentType) { - if (impl.getSecretProperties() == null) { - impl.setSecretProperties(new SecretProperties()); - } - - impl.getSecretProperties().setContentType(Objects.toString(contentType, null)); - return this; - } - - /** - * Get the subjectAlternativeNames. - * - * @return the subjectAlternativeNames. - */ - public SubjectAlternativeNames getSubjectAlternativeNames() { - return impl.getX509CertificateProperties().getSubjectAlternativeNames(); - } - - /** - * Set the subjectAlternativeNames. - * - * @param subjectAlternativeNames the subjectAlternativeNames to set - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setSubjectAlternativeNames(SubjectAlternativeNames subjectAlternativeNames) { - impl.getX509CertificateProperties().setSubjectAlternativeNames(subjectAlternativeNames); - return this; - } - - /** - * Set the subject Name. - * - * @param subject the subject Name to set - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setSubject(final String subject) { - impl.getX509CertificateProperties().setSubject(subject); - return this; - } - - /** - * Set the validity in months. - * - * @param validityInMonths the validityInMonths value to set - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setValidityInMonths(Integer validityInMonths) { - impl.getX509CertificateProperties().setValidityInMonths(validityInMonths); - return this; - } - - /** - * Set the key size. - * - * @param keySize the key size value to set - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setKeySize(Integer keySize) { - if (impl.getKeyProperties() == null) { - impl.setKeyProperties(new KeyProperties()); - } - - impl.getKeyProperties().setKeySize(keySize); - return this; - } - - /** - * Set the key curve. - * - * @param keyCurveName the key curve value to set - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setKeyCurveName(CertificateKeyCurveName keyCurveName) { - if (impl.getKeyProperties() == null) { - impl.setKeyProperties(new KeyProperties()); - } - - impl.getKeyProperties().setCrv(keyCurveName); - return this; - } - - /** - * Set the certificate type to request from the issuer. - * - * @param certificateType the certificateType to request from issuer. - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setCertificateType(String certificateType) { - impl.getIssuerParameters().setCertificateType(certificateType); - return this; - } - - /** - * Set the certificate transparency status. - * - * @param certificateTransparent the certificateTransparency status to set - * @return the updated CertificatePolicy object itself. - */ - public CertificatePolicy setCertificateTransparent(Boolean certificateTransparent) { - impl.getIssuerParameters().setCertificateTransparency(certificateTransparent); - return this; - } - - /** - * Get the subject. - * - * @return the subject - */ - public String getSubject() { - return impl.getX509CertificateProperties().getSubject(); - } - - /** - * Get the validity in months. - * - * @return the validity in months - */ - public Integer getValidityInMonths() { - return impl.getX509CertificateProperties().getValidityInMonths(); - } - - /** - * Get the issuer name. - * - * @return the issuer name. - */ - public String getIssuerName() { - return impl.getIssuerParameters().getName(); - } - - /** - * Get the certificate type. - * - * @return the certificate type - */ - public String getCertificateType() { - return impl.getIssuerParameters().getCertificateType(); - } - - /** - * Get the certificate transparency status. - * - * @return the certificate transparency status - */ - public Boolean isCertificateTransparent() { - return impl.getIssuerParameters().isCertificateTransparency(); - } - - /** - * Set the lifetime actions - * @param actions the lifetime actions to set. - * @return the updated certificate policy object itself. - */ - public CertificatePolicy setLifetimeActions(LifetimeAction... actions) { - if (actions == null) { - impl.setLifetimeActions(null); - lifetimeActions = null; - } else { - lifetimeActions = Arrays.asList(actions); - List implActions - = new ArrayList<>(actions.length); - for (LifetimeAction action : actions) { - implActions.add(action.getImpl()); - } - impl.setLifetimeActions(implActions); - } - - return this; - } - - /** - * Get the lifetime actions - * @return the lifetime actions - */ - public List getLifetimeActions() { - if (lifetimeActions == null && impl.getLifetimeActions() != null) { - lifetimeActions = new ArrayList<>(impl.getLifetimeActions().size()); - for (com.azure.security.keyvault.certificates.implementation.models.LifetimeAction implAction : impl - .getLifetimeActions()) { - lifetimeActions.add(new LifetimeAction(implAction)); - } - } - - return lifetimeActions; - } - - /** - * Get the default certificate policy. - * @return the default certificate policy. - */ - public static CertificatePolicy getDefault() { - return new CertificatePolicy("Self", "CN=DefaultPolicy"); - } - - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - return impl.toJson(jsonWriter); - } - - /** - * Reads a JSON stream into a {@link CertificatePolicy}. - * - * @param jsonReader The {@link JsonReader} being read. - * @return The {@link CertificatePolicy} that the JSON stream represented, may return null. - * @throws IOException If a {@link CertificatePolicy} fails to be read from the {@code jsonReader}. - */ - public static CertificatePolicy fromJson(JsonReader jsonReader) throws IOException { - return new CertificatePolicy( - com.azure.security.keyvault.certificates.implementation.models.CertificatePolicy.fromJson(jsonReader)); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificatePolicyAction.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificatePolicyAction.java deleted file mode 100644 index 6b78b9423b5e..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificatePolicyAction.java +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.util.ExpandableStringEnum; -import java.util.Collection; - -/** - * The type of the action. - */ -public final class CertificatePolicyAction extends ExpandableStringEnum { - /** - * Static value EmailContacts for CertificatePolicyAction. - */ - public static final CertificatePolicyAction EMAIL_CONTACTS = fromString("EmailContacts"); - - /** - * Static value AutoRenew for CertificatePolicyAction. - */ - public static final CertificatePolicyAction AUTO_RENEW = fromString("AutoRenew"); - - /** - * Creates a new instance of CertificatePolicyAction value. - * - * @deprecated Use the {@link #fromString(String)} factory method. - */ - @Deprecated - public CertificatePolicyAction() { - } - - /** - * Creates or finds a CertificatePolicyAction from its string representation. - * - * @param name a name to look for. - * @return the corresponding CertificatePolicyAction. - */ - public static CertificatePolicyAction fromString(String name) { - return fromString(name, CertificatePolicyAction.class); - } - - /** - * Gets known CertificatePolicyAction values. - * - * @return known CertificatePolicyAction values. - */ - public static Collection values() { - return values(CertificatePolicyAction.class); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateProperties.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateProperties.java deleted file mode 100644 index 1e18bc526668..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/CertificateProperties.java +++ /dev/null @@ -1,350 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.util.Base64Url; -import com.azure.core.util.logging.ClientLogger; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.implementation.CertificatePropertiesHelper; -import com.azure.security.keyvault.certificates.implementation.IdMetadata; -import com.azure.security.keyvault.certificates.implementation.models.CertificateAttributes; -import com.azure.security.keyvault.certificates.implementation.models.CertificateBundle; -import com.azure.security.keyvault.certificates.implementation.models.CertificateItem; - -import java.io.IOException; -import java.time.OffsetDateTime; -import java.util.Map; -import java.util.Objects; - -import static com.azure.core.util.CoreUtils.bytesToHexString; -import static com.azure.security.keyvault.certificates.implementation.CertificatesUtils.getIdMetadata; - -/** - * Represents base properties of a certificate. - */ -public class CertificateProperties implements JsonSerializable { - private static final ClientLogger LOGGER = new ClientLogger(CertificateProperties.class); - - static { - CertificatePropertiesHelper.setAccessor(CertificateProperties::new); - } - - /** - * URL for the Azure KeyVault service. - */ - private final String vaultUrl; - - /** - * The certificate version. - */ - private final String version; - - /** - * The Certificate name. - */ - private String name; - - /** - * Determines whether the object is enabled. - */ - private Boolean enabled; - - /** - * Not before date in UTC. - */ - private final OffsetDateTime notBefore; - - /** - * Expiry date in UTC. - */ - private final OffsetDateTime expiresOn; - - /** - * Creation time in UTC. - */ - private final OffsetDateTime createdOn; - - /** - * Last updated time in UTC. - */ - private final OffsetDateTime updatedOn; - - /** - * Reflects the deletion recovery level currently in effect for certificates in the current vault. If it contains - * 'Purgeable', the certificate can be permanently deleted by a privileged user; otherwise, only the system can - * purge the certificate, at the end of the retention interval. Possible values include: 'Purgeable', - * 'Recoverable+Purgeable', 'Recoverable', 'Recoverable+ProtectedSubscription'. - */ - private final String recoveryLevel; - - /** - * The certificate id. - */ - private final String id; - - /** - * Application specific metadata in the form of key-value pairs. - */ - private Map tags; - - /** - * Thumbprint of the certificate. Read-only. - */ - private final Base64Url x509Thumbprint; - - /** - * The number of days a certificate is retained before being deleted for a soft delete-enabled Key Vault. - */ - private final Integer recoverableDays; - - CertificateProperties() { - this(null, new CertificateAttributes(), null, null, null); - } - - CertificateProperties(CertificateItem item) { - this(item.getId(), item.getAttributes(), item.getTags(), item.getX509Thumbprint(), - item.getAttributes().getRecoverableDays()); - } - - CertificateProperties(CertificateBundle bundle) { - this(bundle.getId(), bundle.getAttributes(), bundle.getTags(), bundle.getX509Thumbprint(), - bundle.getAttributes().getRecoverableDays()); - } - - CertificateProperties(String id, CertificateAttributes attributes, Map tags, byte[] wireThumbprint, - Integer recoverableDays) { - IdMetadata idMetadata = getIdMetadata(id, 1, 2, 3, LOGGER); - this.id = idMetadata.getId(); - this.vaultUrl = idMetadata.getVaultUrl(); - this.name = idMetadata.getName(); - this.version = idMetadata.getVersion(); - - if (attributes != null) { - this.enabled = attributes.isEnabled(); - this.notBefore = attributes.getNotBefore(); - this.expiresOn = attributes.getExpires(); - this.createdOn = attributes.getCreated(); - this.updatedOn = attributes.getUpdated(); - this.recoveryLevel = Objects.toString(attributes.getRecoveryLevel(), null); - } else { - this.enabled = null; - this.notBefore = null; - this.expiresOn = null; - this.createdOn = null; - this.updatedOn = null; - this.recoveryLevel = null; - } - - this.tags = tags; - this.x509Thumbprint - = (wireThumbprint == null || wireThumbprint.length == 0) ? null : Base64Url.encode(wireThumbprint); - this.recoverableDays = recoverableDays; - } - - void setName(String name) { - this.name = name; - } - - /** - * Get the certificate identifier. - * - * @return The certificate identifier - */ - public String getId() { - return this.id; - } - - /** - * Get the notBefore UTC time. - * - * @return The notBefore UTC time. - */ - public OffsetDateTime getNotBefore() { - return notBefore; - } - - /** - * Gets the number of days a key is retained before being deleted for a soft delete-enabled Key Vault. - * - * @return The recoverable days. - */ - public Integer getRecoverableDays() { - return recoverableDays; - } - - /** - * Get the Certificate Expiry time in UTC. - * - * @return The expires UTC time. - */ - public OffsetDateTime getExpiresOn() { - return this.expiresOn; - } - - /** - * Get the UTC time at which certificate was created. - * - * @return The created UTC time. - */ - public OffsetDateTime getCreatedOn() { - return createdOn; - } - - /** - * Get the UTC time at which certificate was last updated. - * - * @return The last updated UTC time. - */ - public OffsetDateTime getUpdatedOn() { - return updatedOn; - } - - /** - * Get the tags associated with the certificate. - * - * @return The value of the tags. - */ - public Map getTags() { - return this.tags; - } - - /** - * Get the URL for the Azure KeyVault service. - * - * @return The value of the URL for the Azure KeyVault service. - */ - public String getVaultUrl() { - return this.vaultUrl; - } - - /** - * Set the tags to be associated with the certificate. - * - * @param tags The tags to set. - * - * @return The updated {@link CertificateProperties} object. - */ - public CertificateProperties setTags(Map tags) { - this.tags = tags; - - return this; - } - - /** - * Get the version of the certificate. - * - * @return The version of the certificate. - */ - public String getVersion() { - return this.version; - } - - /** - * Get the certificate name. - * - * @return The name of the certificate. - */ - public String getName() { - return this.name; - } - - /** - * Get the recovery level of the certificate. - - * @return The recovery level of the certificate. - */ - public String getRecoveryLevel() { - return recoveryLevel; - } - - /** - * Get the enabled status. - * - * @return The enabled status. - */ - public Boolean isEnabled() { - return this.enabled; - } - - /** - * Set the enabled status. - * - * @param enabled The enabled status to set. - * - * @return The updated {@link CertificateProperties} object. - */ - public CertificateProperties setEnabled(Boolean enabled) { - this.enabled = enabled; - - return this; - } - - /** - * Get the X509 Thumbprint of the certificate. - * - * @return The x509Thumbprint. - */ - public byte[] getX509Thumbprint() { - return x509Thumbprint != null ? x509Thumbprint.decodedBytes() : null; - } - - /** - * Gets the thumbprint of the certificate as a hex string which can be used to uniquely identify it. - * - * @return The thumbprint of the certificate as a hex string. - */ - public String getX509ThumbprintAsString() { - return bytesToHexString(getX509Thumbprint()); - } - - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - return jsonWriter.writeStartObject().writeMapField("tags", tags, JsonWriter::writeString).writeEndObject(); - } - - /** - * Reads a JSON stream into a {@link CertificateProperties}. - * - * @param jsonReader The {@link JsonReader} being read. - * - * @return The {@link CertificateProperties} that the JSON stream represented, may return {@code null}. - * - * @throws IOException If a {@link CertificateProperties} fails to be read from the {@code jsonReader}. - */ - public static CertificateProperties fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - CertificateAttributes attributes = null; - Map tags = null; - byte[] wireThumbprint = null; - Integer recoverableDays = null; - - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - - reader.nextToken(); - - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("attributes".equals(fieldName)) { - attributes = CertificateAttributes.fromJson(reader); - } else if ("tags".equals(fieldName)) { - tags = reader.readMap(JsonReader::getString); - } else if ("x5t".equals(fieldName)) { - wireThumbprint = reader.getBinary(); - } else if ("recoverableDays".equals(fieldName)) { - recoverableDays = reader.getInt(); - } else { - reader.skipChildren(); - } - } - - return new CertificateProperties(id, attributes == null ? new CertificateAttributes() : attributes, tags, - wireThumbprint, recoverableDays); - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/DeletedCertificate.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/DeletedCertificate.java deleted file mode 100644 index e25939110c0a..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/DeletedCertificate.java +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.json.JsonReader; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.CertificateAsyncClient; -import com.azure.security.keyvault.certificates.CertificateClient; -import com.azure.security.keyvault.certificates.implementation.CertificatePropertiesHelper; -import com.azure.security.keyvault.certificates.implementation.DeletedCertificateHelper; -import com.azure.security.keyvault.certificates.implementation.models.CertificateAttributes; -import com.azure.security.keyvault.certificates.implementation.models.DeletedCertificateBundle; -import com.azure.security.keyvault.certificates.implementation.models.DeletedCertificateItem; - -import java.io.IOException; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.util.Map; - -/** - * Deleted Certificate is the resource consisting of name, recovery id, deleted date, scheduled purge date and its - * attributes inherited from {@link KeyVaultCertificate}. - * It is managed by Certificate Service. - * - * @see CertificateAsyncClient - * @see CertificateClient - */ -public final class DeletedCertificate extends KeyVaultCertificateWithPolicy { - static { - DeletedCertificateHelper.setAccessor(new DeletedCertificateHelper.DeletedCertificateAccessor() { - @Override - public DeletedCertificate createDeletedCertificate(DeletedCertificateItem item) { - return new DeletedCertificate(item); - } - - @Override - public DeletedCertificate createDeletedCertificate(DeletedCertificateBundle bundle) { - return new DeletedCertificate(bundle); - } - }); - } - - /** - * Creates an instance of {@link DeletedCertificate}. - */ - public DeletedCertificate() { - super(); - - this.recoveryId = null; - this.deletedOn = null; - this.scheduledPurgeDate = null; - } - - private DeletedCertificate(DeletedCertificateItem item) { - super(null, null, null, CertificatePropertiesHelper.createCertificateProperties(item)); - - this.recoveryId = item.getRecoveryId(); - this.deletedOn = item.getDeletedDate(); - this.scheduledPurgeDate = item.getScheduledPurgeDate(); - } - - private DeletedCertificate(DeletedCertificateBundle bundle) { - super(bundle); - - this.recoveryId = bundle.getRecoveryId(); - this.deletedOn = bundle.getDeletedDate(); - this.scheduledPurgeDate = bundle.getScheduledPurgeDate(); - } - - private DeletedCertificate(byte[] cer, String kid, String sid, CertificateProperties properties, - CertificatePolicy policy, String recoveryId, OffsetDateTime deletedOn, OffsetDateTime scheduledPurgeDate) { - super(cer, kid, sid, properties, policy); - - this.recoveryId = recoveryId; - this.deletedOn = deletedOn; - this.scheduledPurgeDate = scheduledPurgeDate; - } - - /** - * The url of the recovery object, used to identify and recover the deleted - * certificate. - */ - private final String recoveryId; - - /** - * The time when the certificate is scheduled to be purged, in UTC. - */ - private final OffsetDateTime scheduledPurgeDate; - - /** - * The time when the certificate was deleted, in UTC. - */ - private final OffsetDateTime deletedOn; - - /** - * Get the recoveryId identifier. - * - * @return the recoveryId identifier. - */ - public String getRecoveryId() { - return this.recoveryId; - } - - /** - * Get the scheduled purge UTC time. - * - * @return the scheduledPurgeDate UTC time. - */ - public OffsetDateTime getScheduledPurgeDate() { - return scheduledPurgeDate; - } - - /** - * Get the deleted UTC time. - * - * @return the deletedDate UTC time. - */ - public OffsetDateTime getDeletedOn() { - return this.deletedOn; - } - - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - return jsonWriter.writeStartObject() - .writeBinaryField("cer", getCer()) - .writeJsonField("policy", getPolicy()) - .writeStringField("recoverId", recoveryId) - .writeEndObject(); - } - - /** - * Reads a JSON stream into a {@link DeletedCertificate}. - * - * @param jsonReader The {@link JsonReader} being read. - * @return The {@link DeletedCertificate} that the JSON stream represented, may return null. - * @throws IOException If a {@link DeletedCertificate} fails to be read from the {@code jsonReader}. - */ - public static DeletedCertificate fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - CertificateAttributes attributes = null; - Map tags = null; - byte[] wireThumbprint = null; - byte[] cer = null; - String keyId = null; - String secretId = null; - CertificatePolicy policy = null; - String recoveryId = null; - OffsetDateTime deletedOn = null; - OffsetDateTime scheduledPurgeDate = null; - - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("attributes".equals(fieldName)) { - attributes = CertificateAttributes.fromJson(reader); - } else if ("tags".equals(fieldName)) { - tags = reader.readMap(JsonReader::getString); - } else if ("x5t".equals(fieldName)) { - wireThumbprint = reader.getBinary(); - } else if ("cer".equals(fieldName)) { - cer = reader.getBinary(); - } else if ("kid".equals(fieldName)) { - keyId = reader.getString(); - } else if ("sid".equals(fieldName)) { - secretId = reader.getString(); - } else if ("policy".equals(fieldName)) { - policy = CertificatePolicy.fromJson(reader); - } else if ("recoveryId".equals(fieldName)) { - recoveryId = reader.getString(); - } else if ("deletedDate".equals(fieldName)) { - deletedOn = reader.getNullable(nonNull -> OffsetDateTime - .ofInstant(Instant.ofEpochMilli(nonNull.getLong() * 1000L), ZoneOffset.UTC)); - } else if ("scheduledPurgeDate".equals(fieldName)) { - scheduledPurgeDate = reader.getNullable(nonNull -> OffsetDateTime - .ofInstant(Instant.ofEpochMilli(nonNull.getLong() * 1000L), ZoneOffset.UTC)); - } else { - reader.skipChildren(); - } - } - - return new DeletedCertificate(cer, keyId, secretId, - new CertificateProperties(id, attributes, tags, wireThumbprint, null), policy, recoveryId, deletedOn, - scheduledPurgeDate); - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/ImportCertificateOptions.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/ImportCertificateOptions.java deleted file mode 100644 index d4124a768872..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/ImportCertificateOptions.java +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.util.CoreUtils; - -import java.util.Map; -import java.util.Objects; - -/** - * Represents the configuration used to import a certificate in the key vault. - */ -public final class ImportCertificateOptions { - - /** - * The file location of the certificate. - */ - private final byte[] certificate; - - /** - * The name of the certificate. - */ - private final String name; - - /** - * If the private key in base64EncodedCertificate is encrypted, the - * password used for encryption. - */ - private String password; - - /** - * Determines whether the object is enabled. - */ - private Boolean enabled; - - /** - * The policy which governs the lifecycle of the imported certificate and it's properties when it is rotated. - */ - private CertificatePolicy policy; - - /** - * Application specific metadata in the form of key-value pairs. - */ - private Map tags; - - /** - * Creates instance of CertificateImportOptions. - * @param name The name of the key. - * @param certificate The PFX or PEM formatted value of the certificate containing both the x509 certificates and the private key. - */ - public ImportCertificateOptions(String name, byte[] certificate) { - Objects.requireNonNull(certificate, "The certificate parameter cannot be null."); - this.name = name; - this.certificate = CoreUtils.clone(certificate); - } - - /** - * Set the enabled status. - * @param enabled The enabled status to set. - * @return the CertificateImportOptions itself - */ - public ImportCertificateOptions setEnabled(Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Get the enabled status. - * - * @return the enabled status - */ - public Boolean isEnabled() { - return this.enabled; - } - - /** - * Get the management policy for the certificate. - * @return the management policy - */ - public CertificatePolicy getPolicy() { - return this.policy; - } - - /** - * Set the management policy for the certificate. - * @param policy the management policy for the certificate - * @return the updated CertificateImportOptions itself - */ - public ImportCertificateOptions setPolicy(CertificatePolicy policy) { - this.policy = policy; - return this; - } - - /** - * Set the application specific maetadata. - * @param tags The metadata to set. - * @return the updated CertificateImportOptions itself - */ - public ImportCertificateOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Get the tags associated with the secret. - * - * @return the value of the tags. - */ - public Map getTags() { - return this.tags; - } - - /** - * Set the password for encrypting the certificate, if its encrypted. - * @param password The password used to encrypt the certificate. - * @return the updated CertificateImportOptions itself - */ - public ImportCertificateOptions setPassword(String password) { - this.password = password; - return this; - } - - /** - * Get the password for encrypting the certificate, if its encrypted. - * @return the password - */ - public String getPassword() { - return this.password; - } - - /** - * Get the name of the certificate. - * @return the name of the certificate. - */ - public String getName() { - return this.name; - } - - /** - * Get the value of the certificate. - * @return the value of the certificate. - */ - public byte[] getCertificate() { - return CoreUtils.clone(this.certificate); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/IssuerProperties.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/IssuerProperties.java deleted file mode 100644 index 456d92c13f11..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/IssuerProperties.java +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.util.logging.ClientLogger; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.implementation.IssuerPropertiesHelper; -import com.azure.security.keyvault.certificates.implementation.models.CertificateIssuerItem; - -import java.io.IOException; - -import static com.azure.security.keyvault.certificates.implementation.CertificatesUtils.getIdMetadata; - -/** - * Represents base properties of an {@link CertificateIssuer}. - */ -public class IssuerProperties implements JsonSerializable { - private static final ClientLogger LOGGER = new ClientLogger(IssuerProperties.class); - - static { - IssuerPropertiesHelper.setAccessor(IssuerProperties::new); - } - - private final CertificateIssuerItem impl; - - /** - * Name of the referenced issuer object or reserved names; for example, - * 'Self' or 'Unknown'. - */ - private final String name; - - /** - * Creates an instance of {@link IssuerProperties}. - */ - public IssuerProperties() { - this(new CertificateIssuerItem()); - } - - private IssuerProperties(CertificateIssuerItem impl) { - this.impl = impl; - this.name = getIdMetadata(impl.getId(), -1, 3, -1, LOGGER).getName(); - } - - /** - * Get the id of the issuer. - * @return the identifier. - */ - public String getId() { - return impl.getId(); - } - - /** - * Get the issuer provider - * @return the issuer provider - */ - public String getProvider() { - return impl.getProvider(); - } - - /** - * Get the issuer name - * @return the issuer name - */ - public String getName() { - return name; - } - - /** - * Set the issuer provider - * @param provider The issuer provider. - * @return the updated IssuerProperties object - */ - public IssuerProperties setProvider(String provider) { - impl.setProvider(provider); - return this; - } - - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - return impl.toJson(jsonWriter); - } - - /** - * Reads a JSON stream into a {@link IssuerProperties}. - * - * @param jsonReader The {@link JsonReader} being read. - * @return The {@link IssuerProperties} that the JSON stream represented, may return null. - * @throws IOException If a {@link IssuerProperties} fails to be read from the {@code jsonReader}. - */ - public static IssuerProperties fromJson(JsonReader jsonReader) throws IOException { - return new IssuerProperties(CertificateIssuerItem.fromJson(jsonReader)); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificate.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificate.java deleted file mode 100644 index 68d16de93845..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificate.java +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.util.CoreUtils; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.implementation.models.CertificateAttributes; - -import java.io.IOException; -import java.util.Map; -import java.util.Objects; - -/** - * Represents a certificate with all of its properties. - */ -public class KeyVaultCertificate implements JsonSerializable { - /** - * CER contents of x509 certificate. - */ - private final byte[] cer; - - /** - * The key id. - */ - private final String keyId; - - /** - * The secret id. - */ - private final String secretId; - - private CertificateProperties properties; - - KeyVaultCertificate() { - this(null, null, null, new CertificateProperties()); - } - - KeyVaultCertificate(byte[] cer, String keyId, String secretId, CertificateProperties properties) { - this.cer = CoreUtils.clone(cer); - this.keyId = keyId; - this.secretId = secretId; - this.properties = properties; - } - - /** - * Get the certificate properties. - * @return the certificate properties. - */ - public CertificateProperties getProperties() { - return properties; - } - - /** - * Set the certificate properties - * @param properties the certificate properties - * @throws NullPointerException if {@code certificateProperties} is null - * @return the updated certificate object itself. - */ - public KeyVaultCertificate setProperties(CertificateProperties properties) { - Objects.requireNonNull(properties, "The certificate properties cannot be null"); - properties.setName(this.properties.getName()); - this.properties = properties; - return this; - } - - /** - * Get the certificate identifier - * @return the certificate identifier - */ - public String getId() { - return properties.getId(); - } - - /** - * Get the certificate name - * @return the certificate name - */ - public String getName() { - return properties.getName(); - } - - /** - * Get the key id of the certificate - * @return the key Id. - */ - public String getKeyId() { - return this.keyId; - } - - /** - * Get the secret id of the certificate - * @return the secret Id. - */ - public String getSecretId() { - return this.secretId; - } - - /** - * Get the cer content of the certificate - * @return the cer content. - */ - public byte[] getCer() { - return CoreUtils.clone(cer); - } - - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - return jsonWriter.writeStartObject().writeBinaryField("cer", cer).writeEndObject(); - } - - /** - * Reads a JSON stream into a {@link KeyVaultCertificate}. - * - * @param jsonReader The {@link JsonReader} being read. - * @return The {@link KeyVaultCertificate} that the JSON stream represented, may return null. - * @throws IOException If a {@link KeyVaultCertificate} fails to be read from the {@code jsonReader}. - */ - public static KeyVaultCertificate fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - CertificateAttributes attributes = null; - Map tags = null; - byte[] wireThumbprint = null; - byte[] cer = null; - String keyId = null; - String secretId = null; - - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("attributes".equals(fieldName)) { - attributes = CertificateAttributes.fromJson(reader); - } else if ("tags".equals(fieldName)) { - tags = reader.readMap(JsonReader::getString); - } else if ("x5t".equals(fieldName)) { - wireThumbprint = reader.getBinary(); - } else if ("cer".equals(fieldName)) { - cer = reader.getBinary(); - } else if ("kid".equals(fieldName)) { - keyId = reader.getString(); - } else if ("sid".equals(fieldName)) { - secretId = reader.getString(); - } else { - reader.skipChildren(); - } - } - - return new KeyVaultCertificate(cer, keyId, secretId, - new CertificateProperties(id, attributes, tags, wireThumbprint, null)); - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificateIdentifier.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificateIdentifier.java deleted file mode 100644 index cadc669e88f2..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificateIdentifier.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.annotation.Immutable; -import com.azure.core.util.logging.ClientLogger; -import com.azure.security.keyvault.certificates.CertificateAsyncClient; -import com.azure.security.keyvault.certificates.CertificateClient; - -import java.net.MalformedURLException; -import java.net.URL; - -/** - * Information about a {@link KeyVaultCertificate} parsed from the certificate URL. You can use this information when - * calling methods of {@link CertificateClient} or {@link CertificateAsyncClient}. - */ -@Immutable -public final class KeyVaultCertificateIdentifier { - private static final ClientLogger LOGGER = new ClientLogger(KeyVaultCertificateIdentifier.class); - - private final String sourceId; - private final String vaultUrl; - private final String name; - private final String version; - - /** - * Create a new {@link KeyVaultCertificateIdentifier} from a given Key Vault identifier. - * - *

Some examples: - * - *

    - *
  • https://{key-vault-name}.vault.azure.net/certificates/{certificate-name}
  • - *
  • https://{key-vault-name}.vault.azure.net/certificates/{certificate-name}/pending
  • - *
  • https://{key-vault-name}.vault.azure.net/certificates/{certificate-name}/{unique-version-id}
  • - *
  • https://{key-vault-name}.vault.azure.net/deletedcertificates/{deleted-certificate-name}
  • - *
- * - * @param sourceId The identifier to extract information from. - * - * @throws IllegalArgumentException If {@code sourceId} is an invalid Key Vault Certificate identifier. - * @throws NullPointerException If {@code sourceId} is {@code null}. - */ - public KeyVaultCertificateIdentifier(String sourceId) { - if (sourceId == null) { - throw LOGGER.logExceptionAsError(new NullPointerException("'sourceId' cannot be null")); - } - - try { - final URL url = new URL(sourceId); - // We expect a sourceId with either 3 or 4 path segments: key vault + collection + name [+ "pending"/version] - final String[] pathSegments = url.getPath().split("/"); - - // More or less segments in the URI than expected. - if (pathSegments.length != 3 && pathSegments.length != 4) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.")); - } - - this.sourceId = sourceId; - this.vaultUrl = url.getProtocol() + "://" + url.getHost(); - this.name = pathSegments[2]; - this.version = pathSegments.length == 4 ? pathSegments[3] : null; - } catch (MalformedURLException e) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e)); - } - } - - /** - * Gets the key identifier used to create this object - * - * @return The certificate identifier. - */ - public String getSourceId() { - return sourceId; - } - - /** - * Gets the URL of the Key Vault. - * - * @return The Key Vault URL. - */ - public String getVaultUrl() { - return vaultUrl; - } - - /** - * Gets the name of the certificate. - * - * @return The certificate name. - */ - public String getName() { - return name; - } - - /** - * Gets the optional version of the certificate. - * - * @return The certificate version. - */ - public String getVersion() { - return version; - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificateWithPolicy.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificateWithPolicy.java deleted file mode 100644 index 019c576bc0ea..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificateWithPolicy.java +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.json.JsonReader; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.implementation.CertificatePolicyHelper; -import com.azure.security.keyvault.certificates.implementation.KeyVaultCertificateWithPolicyHelper; -import com.azure.security.keyvault.certificates.implementation.models.CertificateAttributes; -import com.azure.security.keyvault.certificates.implementation.models.CertificateBundle; - -import java.io.IOException; -import java.util.Map; - -/** - * Represents a certificate with all of its properties including {@link CertificatePolicy}. - */ -public class KeyVaultCertificateWithPolicy extends KeyVaultCertificate { - static { - KeyVaultCertificateWithPolicyHelper.setAccessor(KeyVaultCertificateWithPolicy::new); - } - - /** - * The Certificate policy. - */ - private CertificatePolicy policy; - - KeyVaultCertificateWithPolicy() { - super(); - } - - KeyVaultCertificateWithPolicy(CertificateBundle bundle) { - this(bundle.getCer(), bundle.getKid(), bundle.getSid(), new CertificateProperties(bundle), - CertificatePolicyHelper.createCertificatePolicy(bundle.getPolicy())); - } - - KeyVaultCertificateWithPolicy(byte[] cer, String kid, String sid, CertificateProperties properties) { - this(cer, kid, sid, properties, null); - } - - KeyVaultCertificateWithPolicy(byte[] cer, String kid, String sid, CertificateProperties properties, - CertificatePolicy policy) { - super(cer, kid, sid, properties); - this.policy = policy; - } - - /** - * Set the certificate properties - * @param properties the certificate properties - * @throws NullPointerException if {@code certificateProperties} is null - * @return the updated certificateWithPolicy object itself. - */ - public KeyVaultCertificateWithPolicy setProperties(CertificateProperties properties) { - super.setProperties(properties); - return this; - } - - /** - * Get the certificate policy of the certificate - * @return the cer content. - */ - public CertificatePolicy getPolicy() { - return this.policy; - } - - /** - * Set the certificate policy of the certificate - * - * @param certificatePolicy the policy to set. - * @return the certificateWithPolicy object itself. - */ - public KeyVaultCertificateWithPolicy setPolicy(CertificatePolicy certificatePolicy) { - this.policy = certificatePolicy; - return this; - } - - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - return jsonWriter.writeStartObject() - .writeBinaryField("cer", getCer()) - .writeJsonField("policy", policy) - .writeEndObject(); - } - - /** - * Reads a JSON stream into a {@link KeyVaultCertificateWithPolicy}. - * - * @param jsonReader The {@link JsonReader} being read. - * @return The {@link KeyVaultCertificateWithPolicy} that the JSON stream represented, may return null. - * @throws IOException If a {@link KeyVaultCertificateWithPolicy} fails to be read from the {@code jsonReader}. - */ - public static KeyVaultCertificateWithPolicy fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - String id = null; - CertificateAttributes attributes = null; - Map tags = null; - byte[] wireThumbprint = null; - byte[] cer = null; - String keyId = null; - String secretId = null; - CertificatePolicy policy = null; - - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("id".equals(fieldName)) { - id = reader.getString(); - } else if ("attributes".equals(fieldName)) { - attributes = CertificateAttributes.fromJson(reader); - } else if ("tags".equals(fieldName)) { - tags = reader.readMap(JsonReader::getString); - } else if ("x5t".equals(fieldName)) { - wireThumbprint = reader.getBinary(); - } else if ("cer".equals(fieldName)) { - cer = reader.getBinary(); - } else if ("kid".equals(fieldName)) { - keyId = reader.getString(); - } else if ("sid".equals(fieldName)) { - secretId = reader.getString(); - } else if ("policy".equals(fieldName)) { - policy = CertificatePolicy.fromJson(reader); - } else { - reader.skipChildren(); - } - } - - return new KeyVaultCertificateWithPolicy(cer, keyId, secretId, - new CertificateProperties(id, attributes, tags, wireThumbprint, null), policy); - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/LifetimeAction.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/LifetimeAction.java deleted file mode 100644 index b05a6fb041ec..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/LifetimeAction.java +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonWriter; -import com.azure.security.keyvault.certificates.implementation.models.Action; -import com.azure.security.keyvault.certificates.implementation.models.Trigger; - -import java.io.IOException; - -/** - * Represents a LifeTimeAction in {@link CertificatePolicy} - */ -public final class LifetimeAction implements JsonSerializable { - private final com.azure.security.keyvault.certificates.implementation.models.LifetimeAction impl; - - com.azure.security.keyvault.certificates.implementation.models.LifetimeAction getImpl() { - return this.impl; - } - - /** - * Creates a new LifetimeAction instance, with the provided {@link CertificatePolicyAction}. - * @param action The action type of this LifetimeAction. - */ - public LifetimeAction(CertificatePolicyAction action) { - this.impl = new com.azure.security.keyvault.certificates.implementation.models.LifetimeAction() - .setAction(new Action().setActionType(action)); - } - - LifetimeAction(com.azure.security.keyvault.certificates.implementation.models.LifetimeAction impl) { - this.impl = impl; - } - - /** - * Get the lifetime percentage. - * - * @return the lifetime percentage - */ - public Integer getLifetimePercentage() { - return impl.getTrigger() == null ? null : impl.getTrigger().getLifetimePercentage(); - } - - /** - * Set the lifetime percentage. - * - * @param lifetimePercentage The lifetime percentage to set - * @return the LifetimeAction object itself. - */ - public LifetimeAction setLifetimePercentage(Integer lifetimePercentage) { - if (impl.getTrigger() == null) { - impl.setTrigger(new Trigger()); - } - - impl.getTrigger().setLifetimePercentage(lifetimePercentage); - return this; - } - - /** - * Get the days before expiry. - * - * @return the days before expiry - */ - public Integer getDaysBeforeExpiry() { - return impl.getTrigger() == null ? null : impl.getTrigger().getDaysBeforeExpiry(); - } - - /** - * Set the days before expiry. - * - * @param daysBeforeExpiry The days before expiry to set - * @return the LifetimeAction object itself. - */ - public LifetimeAction setDaysBeforeExpiry(Integer daysBeforeExpiry) { - if (impl.getTrigger() == null) { - impl.setTrigger(new Trigger()); - } - - impl.getTrigger().setDaysBeforeExpiry(daysBeforeExpiry); - return this; - } - - /** - * Get the lifetime action. - * - * @return the lifetime action - */ - public CertificatePolicyAction getAction() { - return impl.getAction() == null ? null : impl.getAction().getActionType(); - } - - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - return impl.toJson(jsonWriter); - } - - /** - * Reads a JSON stream into a {@link LifetimeAction}. - * - * @param jsonReader The {@link JsonReader} being read. - * @return The {@link LifetimeAction} that the JSON stream represented, may return null. - * @throws IOException If a {@link LifetimeAction} fails to be read from the {@code jsonReader}. - */ - public static LifetimeAction fromJson(JsonReader jsonReader) throws IOException { - return new LifetimeAction( - com.azure.security.keyvault.certificates.implementation.models.LifetimeAction.fromJson(jsonReader)); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/MergeCertificateOptions.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/MergeCertificateOptions.java deleted file mode 100644 index 8859de6350f7..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/MergeCertificateOptions.java +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import java.util.List; -import java.util.Map; - -/** - * Represents Merge Certificate Configuration to merge certificates in key vault. - */ -public final class MergeCertificateOptions { - - /** - * The name of the certificate. - */ - private final String name; - - /** - * The certificate or the certificate chain to merge. - */ - private final List x509Certificates; - - /** - * Determines whether the object is enabled. - */ - private boolean enabled; - - /** - * Application specific metadata in the form of key-value pairs. - */ - private Map tags; - - /** - * Creates a new MergeCertificationOptions instance. - * - * @param name The name of the certificate. - * @param x509Certificates The certificate or the certificate chain to merge. - */ - public MergeCertificateOptions(String name, List x509Certificates) { - this.name = name; - this.x509Certificates = x509Certificates; - } - - /** - * Set the tags to be associated with the secret. - * - * @param tags The tags to set - * @return the MergeCertificateOptions object itself. - */ - public MergeCertificateOptions setTags(Map tags) { - this.tags = tags; - return this; - } - - /** - * Get the tags value. - * - * @return the tags value - */ - public Map getTags() { - return this.tags; - } - - /** - * Set the enabled status. - * @param enabled The enabled status to set. - * @return the MergeCertificateOptions object itself. - */ - public MergeCertificateOptions setEnabled(Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Get the enabled status. - * - * @return the enabled status - */ - public Boolean isEnabled() { - return this.enabled; - } - - /** - * Get the certificate name. - * - * @return the certificate name. - */ - public String getName() { - return this.name; - } - - /** - * Get the certificate or certificate chain to merge. - * - * @return the x509 certificates. - */ - public List getX509Certificates() { - return this.x509Certificates; - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/SubjectAlternativeNames.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/SubjectAlternativeNames.java deleted file mode 100644 index f69500231971..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/SubjectAlternativeNames.java +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// Code generated by Microsoft (R) AutoRest Code Generator. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.core.annotation.Fluent; -import com.azure.json.JsonReader; -import com.azure.json.JsonSerializable; -import com.azure.json.JsonToken; -import com.azure.json.JsonWriter; -import java.io.IOException; -import java.util.List; - -/** - * The subject alternate names of a X509 object. - */ -@Fluent -public final class SubjectAlternativeNames implements JsonSerializable { - /* - * Email addresses. - */ - private List emails; - - /* - * Domain names. - */ - private List dnsNames; - - /* - * User principal names. - */ - private List userPrincipalNames; - - /** - * Creates an instance of SubjectAlternativeNames class. - */ - public SubjectAlternativeNames() { - } - - /** - * Get the emails property: Email addresses. - * - * @return the emails value. - */ - public List getEmails() { - return this.emails; - } - - /** - * Set the emails property: Email addresses. - * - * @param emails the emails value to set. - * @return the SubjectAlternativeNames object itself. - */ - public SubjectAlternativeNames setEmails(List emails) { - this.emails = emails; - return this; - } - - /** - * Get the dnsNames property: Domain names. - * - * @return the dnsNames value. - */ - public List getDnsNames() { - return this.dnsNames; - } - - /** - * Set the dnsNames property: Domain names. - * - * @param dnsNames the dnsNames value to set. - * @return the SubjectAlternativeNames object itself. - */ - public SubjectAlternativeNames setDnsNames(List dnsNames) { - this.dnsNames = dnsNames; - return this; - } - - /** - * Get the userPrincipalNames property: User principal names. - * - * @return the userPrincipalNames value. - */ - public List getUserPrincipalNames() { - return this.userPrincipalNames; - } - - /** - * Set the userPrincipalNames property: User principal names. - * - * @param userPrincipalNames the userPrincipalNames value to set. - * @return the SubjectAlternativeNames object itself. - */ - public SubjectAlternativeNames setUserPrincipalNames(List userPrincipalNames) { - this.userPrincipalNames = userPrincipalNames; - return this; - } - - /** - * {@inheritDoc} - */ - @Override - public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { - jsonWriter.writeStartObject(); - jsonWriter.writeArrayField("emails", this.emails, (writer, element) -> writer.writeString(element)); - jsonWriter.writeArrayField("dns_names", this.dnsNames, (writer, element) -> writer.writeString(element)); - jsonWriter.writeArrayField("upns", this.userPrincipalNames, (writer, element) -> writer.writeString(element)); - return jsonWriter.writeEndObject(); - } - - /** - * Reads an instance of SubjectAlternativeNames from the JsonReader. - * - * @param jsonReader The JsonReader being read. - * @return An instance of SubjectAlternativeNames if the JsonReader was pointing to an instance of it, or null if it - * was pointing to JSON null. - * @throws IOException If an error occurs while reading the SubjectAlternativeNames. - */ - public static SubjectAlternativeNames fromJson(JsonReader jsonReader) throws IOException { - return jsonReader.readObject(reader -> { - SubjectAlternativeNames deserializedSubjectAlternativeNames = new SubjectAlternativeNames(); - while (reader.nextToken() != JsonToken.END_OBJECT) { - String fieldName = reader.getFieldName(); - reader.nextToken(); - - if ("emails".equals(fieldName)) { - List emails = reader.readArray(reader1 -> reader1.getString()); - deserializedSubjectAlternativeNames.emails = emails; - } else if ("dns_names".equals(fieldName)) { - List dnsNames = reader.readArray(reader1 -> reader1.getString()); - deserializedSubjectAlternativeNames.dnsNames = dnsNames; - } else if ("upns".equals(fieldName)) { - List userPrincipalNames = reader.readArray(reader1 -> reader1.getString()); - deserializedSubjectAlternativeNames.userPrincipalNames = userPrincipalNames; - } else { - reader.skipChildren(); - } - } - - return deserializedSubjectAlternativeNames; - }); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/WellKnownIssuerNames.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/WellKnownIssuerNames.java deleted file mode 100644 index f8e9218c57a8..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/WellKnownIssuerNames.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import com.azure.security.keyvault.certificates.CertificateAsyncClient; -import com.azure.security.keyvault.certificates.CertificateClient; - -/** - * Represents well known issuer names to refer in {@link CertificatePolicy} - */ -public class WellKnownIssuerNames { - /** - * Creates a new instance of {@link WellKnownIssuerNames}. - */ - public WellKnownIssuerNames() { - } - - /** - * Create a self-issued certificate. - */ - public static final String SELF = "Self"; - - /** - * Creates a certificate that requires merging an external X.509 certificate using - * {@link CertificateClient#mergeCertificate(MergeCertificateOptions)} or - * {@link CertificateAsyncClient#mergeCertificate(MergeCertificateOptions)}. - */ - public static final String UNKNOWN = "Unknown"; - -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/package-info.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/package-info.java deleted file mode 100644 index a863a78a1c37..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/models/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -// 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 CertificateClient. - * The key vault client performs cryptographic key operations and vault operations against the Key Vault service. - */ -package com.azure.security.keyvault.certificates.models; diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/package-info.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/package-info.java deleted file mode 100644 index c562087d17d8..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/package-info.java +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - *

Azure Key Vault is a cloud-based service - * provided by Microsoft Azure that allows users to securely store and manage cryptographic certificates used for encrypting - * and decrypting data. It is a part of Azure Key Vault, which is a cloud-based service for managing cryptographic certificates, - * keys, and secrets.

- * - *

Azure Key Vault Certificates provides a centralized and highly secure location for storing certificates, which - * eliminates the need to store sensitive certificate material in application code or configuration files. - * By leveraging Azure Key Vault, you can better protect your certificates and ensure their availability - * when needed.

- * - *

Key features of the Azure Key Vault Certificates service include:

- * - *
    - *
  • Secure storage: Certificates are stored securely within Azure Key Vault, which provides robust encryption - * and access control mechanisms to protect against unauthorized access.
  • - *
  • Certificate lifecycle management: You can create, import, and manage certificates within Azure Key Vault. - * It supports common certificate formats such as X.509 and PFX.
  • - *
  • Certificate management operations: Azure Key Vault provides a comprehensive set of management operations, - * including certificate creation, deletion, retrieval, renewal, and revocation.
  • - *
  • Integration with Azure services: Key Vault Certificates can be easily integrated with other Azure services, - * such as Azure App Service, Azure Functions, and Azure Virtual Machines, to enable secure authentication - * and encryption.
  • - *
- * - *

The Azure Key Vault Certificates client library allows developers to securely store and manage certificates - * within Azure Key Vault. The library provides a set of APIs that enable developers to securely create, import, - * retrieve, update, and perform other certificate-related operations.

- * - *

Key Concepts:

- * - *

What is a Certificate Client?

- * - *

The certificate client performs the interactions with the Azure Key Vault service for getting, setting, updating, - * deleting, and listing certificates and its versions. Asynchronous (CertificateAsyncClient) and synchronous (CertificateClient) clients - * exist in the SDK allowing for the selection of a client based on an application's use case. Once you have - * initialized a certificate, you can interact with the primary resource types in Azure Key Vault.

- * - *

What is an Azure Key Vault Certificate ?

- * - *

Azure Key Vault supports certificates with secret content types (PKCS12 and PEM). The certificate can be - * backed by keys in Azure Key Vault of types (EC and RSA). In addition to the certificate policy, the following - * attributes may be specified:.

- * - *
    - *
  • enabled: Specifies whether the certificate is enabled and usable.
  • - *
  • created: Indicates when this version of the certificate was created.
  • - *
  • updated: Indicates when this version of the certificate was updated.
  • - *
- * - *

Getting Started

- * - *

In order to interact with the Azure Key Vault service, you will need to create an instance of the - * {@link com.azure.security.keyvault.certificates.CertificateClient} or {@link com.azure.security.keyvault.certificates.CertificateAsyncClient} class, a vault url and a credential object.

- * - *

The examples shown in this document use a credential object named DefaultAzureCredential for authentication, - * which is appropriate for most scenarios, including local development and production environments. Additionally, - * we recommend using a - * - * managed identity for authentication in production environments. - * You can find more information on different ways of authenticating and their corresponding credential types in the - * - * Azure Identity documentation".

- * - *

Sample: Construct Synchronous Certificate Client

- * - *

The following code sample demonstrates the creation of a {@link com.azure.security.keyvault.certificates.CertificateClient}, - * using the {@link com.azure.security.keyvault.certificates.CertificateClientBuilder} to configure it.

- * - * - *
- * CertificateClient certificateClient = new CertificateClientBuilder()
- *     .credential(new DefaultAzureCredentialBuilder().build())
- *     .vaultUrl("<your-key-vault-url>")
- *     .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
- *     .buildClient();
- * 
- * - * - *

Sample: Construct Asynchronous Certificate Client

- * - *

The following code sample demonstrates the creation of a - * {@link com.azure.security.keyvault.certificates.CertificateAsyncClient}, using the - * {@link com.azure.security.keyvault.certificates.CertificateClientBuilder} to configure it.

- * - * - *
- * CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder()
- *     .credential(new DefaultAzureCredentialBuilder().build())
- *     .vaultUrl("<your-key-vault-url>")
- *     .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
- *     .buildAsyncClient();
- * 
- * - * - *
- * - *
- * - *

Create a Certificate

- * The {@link com.azure.security.keyvault.certificates.CertificateClient} or - * {@link com.azure.security.keyvault.certificates.CertificateAsyncClient} can be used to create a certificate in - * the key vault. - * - *

Synchronous Code Sample:

- *

The following code sample demonstrates how to synchronously create a certificate in the key vault, - * using the {@link com.azure.security.keyvault.certificates.CertificateClient#beginCreateCertificate(java.lang.String, com.azure.security.keyvault.certificates.models.CertificatePolicy)} API.

- * - * - *
- * CertificatePolicy certPolicy = new CertificatePolicy("Self",
- *     "CN=SelfSignedJavaPkcs12");
- * SyncPoller<CertificateOperation, KeyVaultCertificateWithPolicy> certPoller = certificateClient
- *     .beginCreateCertificate("certificateName", certPolicy);
- * certPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED);
- * KeyVaultCertificate cert = certPoller.getFinalResult();
- * System.out.printf("Certificate created with name %s%n", cert.getName());
- * 
- * - * - *

Note: For the asynchronous sample, refer to - * {@link com.azure.security.keyvault.certificates.CertificateAsyncClient}.

- * - *
- * - *
- * - *

Get a Certificate

- * The {@link com.azure.security.keyvault.certificates.CertificateClient} or - * {@link com.azure.security.keyvault.certificates.CertificateAsyncClient} can be used to retrieve a certificate from the - * key vault. - * - *

Synchronous Code Sample:

- *

The following code sample demonstrates how to synchronously retrieve a certificate from the key vault, using - * the {@link com.azure.security.keyvault.certificates.CertificateClient#getCertificate(java.lang.String)}.

- * - * - *
- * CertificatePolicy policy = certificateClient.getCertificatePolicy("certificateName");
- * System.out.printf("Received policy with subject name %s%n", policy.getSubject());
- * 
- * - * - *

Note: For the asynchronous sample, refer to - * {@link com.azure.security.keyvault.certificates.CertificateAsyncClient}.

- * - *
- * - *
- * - *

Delete a Certificate

- * The {@link com.azure.security.keyvault.certificates.CertificateClient} or - * {@link com.azure.security.keyvault.certificates.CertificateAsyncClient} can be used to delete a certificate from - * the key vault. - * - *

Synchronous Code Sample:

- *

The following code sample demonstrates how to synchronously delete a certificate from the - * key vault, using the {@link com.azure.security.keyvault.certificates.CertificateClient#beginDeleteCertificate(java.lang.String)} API.

- * - * - *
- * SyncPoller<DeletedCertificate, Void> deleteCertPoller =
- *     certificateClient.beginDeleteCertificate("certificateName");
- * // Deleted Certificate is accessible as soon as polling beings.
- * PollResponse<DeletedCertificate> deleteCertPollResponse = deleteCertPoller.poll();
- * System.out.printf("Deleted certificate with name %s and recovery id %s%n",
- *     deleteCertPollResponse.getValue().getName(), deleteCertPollResponse.getValue().getRecoveryId());
- * deleteCertPoller.waitForCompletion();
- * 
- * - * - *

Note: For the asynchronous sample, refer to - * {@link com.azure.security.keyvault.certificates.CertificateAsyncClient}.

- * - * @see com.azure.security.keyvault.certificates.CertificateClient - * @see com.azure.security.keyvault.certificates.CertificateAsyncClient - * @see com.azure.security.keyvault.certificates.CertificateClientBuilder - */ -package com.azure.security.keyvault.certificates; diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/module-info.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/module-info.java deleted file mode 100644 index edacc9974f28..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/module-info.java +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -module com.azure.security.keyvault.certificates { - requires transitive com.azure.core; - requires com.azure.json; - - exports com.azure.security.keyvault.certificates; - exports com.azure.security.keyvault.certificates.models; - - opens com.azure.security.keyvault.certificates to com.azure.core; - opens com.azure.security.keyvault.certificates.implementation to com.azure.core; - opens com.azure.security.keyvault.certificates.implementation.models to com.azure.core; - opens com.azure.security.keyvault.certificates.models to com.azure.core; -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-certificates/proxy-config.json b/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-certificates/proxy-config.json deleted file mode 100644 index eb990a14f46a..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-certificates/proxy-config.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - [ - "com.azure.security.keyvault.certificates.implementation.CertificateClientImpl$CertificateClientService" - ], - [ - "com.microsoft.aad.msal4jextensions.persistence.mac.ISecurityLibrary" - ] -] diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-certificates/reflect-config.json b/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-certificates/reflect-config.json deleted file mode 100644 index 6ef061b6768d..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-certificates/reflect-config.json +++ /dev/null @@ -1,332 +0,0 @@ -[ - { - "name": "com.azure.security.keyvault.certificates.CertificateAsyncClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.CertificateClient", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.CertificateClientBuilder", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.CertificateServiceVersion", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.Action", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.CertificateBackup", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.CertificateImportParameters", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.CertificateIssuerSetParameters", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.CertificateIssuerUpdateParameters", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.CertificateMergeParameters", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.CertificateOperationUpdateParameter", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.CertificatePolicyRequest", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.CertificatePropertiesPage", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.CertificateRequestAttributes", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.CertificateRequestParameters", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.CertificateRestoreParameters", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.CertificateUpdateParameters", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.ContactPage", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.Contacts", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.DeletedCertificatePage", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.IssuerAttributes", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.IssuerCredentials", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.IssuerParameters", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.IssuerPropertiesPage", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.KeyProperties", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.KeyVaultCredentialPolicy", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.KeyVaultErrorCodeStrings", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.LifetimeActionRequest", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.OrganizationDetails", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.SecretProperties", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.SubjectAlternativeNamesRequest", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.Trigger", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.implementation.X509CertificateProperties", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.AdministratorContact", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.CertificateContact", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.CertificateContentType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.CertificateIssuer", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.CertificateKeyCurveName", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.CertificateKeyType", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.CertificateKeyUsage", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.CertificateOperation", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.CertificateOperationError", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.CertificatePolicy", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.CertificatePolicyAction", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.CertificateProperties", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.DeletedCertificate", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.ImportCertificateOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.IssuerProperties", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.KeyVaultCertificate", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.KeyVaultCertificateIdentifier", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.LifetimeAction", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.MergeCertificateOptions", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.SubjectAlternativeNames", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - }, - { - "name": "com.azure.security.keyvault.certificates.models.WellKnownIssuerNames", - "allDeclaredConstructors": true, - "allDeclaredFields": true, - "allDeclaredMethods": true - } -] diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-certificates/resource-config.json b/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-certificates/resource-config.json deleted file mode 100644 index 007b03e7bfc5..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/META-INF/native-image/com.azure/azure-security-keyvault-certificates/resource-config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "resources": { - "includes": [ - { - "pattern": "\\Qazure-key-vault-certificates.properties\\E" - }, - { - "pattern": "\\Qcom/sun/jna/darwin/libjnidispatch.jnilib\\E" - }, - { - "pattern": "\\QkvErrorStrings.properties\\E" - } - ] - }, - "bundles": [] -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/azure-key-vault-certificates.properties b/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/azure-key-vault-certificates.properties deleted file mode 100644 index ca812989b4f2..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/azure-key-vault-certificates.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=${project.artifactId} -version=${project.version} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/README.md b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/README.md deleted file mode 100644 index f1f04c7c55aa..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/README.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -page_type: sample -languages: - - java -products: - - azure - - azure-key-vault -urlFragment: keyvault-certificates-samples ---- - -# Azure Key Vault Certificate Samples client library for Java -This document explains samples and how to use them. - -## Key concepts -Key concepts are explained in detail [here][SDK_README_KEY_CONCEPTS]. - -## Getting started - -Getting started explained in detail [here][SDK_README_GETTING_STARTED]. - -## Examples - Following section document various examples. - -### Hello World Samples -* [HelloWorld.java][sample_helloWorld] - and [HelloWorldAsync.java][sample_helloWorldAsync] - Contains samples for following scenarios: - * Create a Certificate & Certificate Issuer - * Retrieve a Certificate & Certificate Issuer - * Update a Certificate - * Delete a Certificate - -### List Operations Samples -* [ListOperations.java][sample_list] and [ListOperationsAsync.java][sample_listAsync] - Contains samples for following scenarios: - * Create a Certificate, Certificate Issuer & Certificate Contact - * List Certificates, Certificate Issuers & Certificate Contacts - * Create new version of existing certificate. - * List versions of an existing certificate. - -### Backup And Restore Operations Samples -* [BackupAndRestoreOperations.java][sample_BackupRestore] and [BackupAndRestoreOperationsAsync.java][sample_BackupRestoreAsync] - Contains samples for following scenarios: - * Create a Certificate - * Backup a Certificate -- Write it to a file. - * Delete a certificate - * Restore a certificate - -### Managing Deleted Certificates Samples: -* [ManagingDeletedCertificates.java][sample_ManageDeleted] and [ManagingDeletedCertificatesAsync.java][sample_ManageDeletedAsync] - Contains samples for following scenarios: - * Create a Certificate - * Delete a certificate - * List deleted certificates - * Recover a deleted certificate - * Purge Deleted certificate - -## Troubleshooting -### General -Certificate Vault clients raise exceptions. For example, if you try to retrieve a certificate after it is deleted a `404` error is returned, indicating resource not found. In the following snippet, the error is handled gracefully by catching the exception and displaying additional information about the error. -```java -try { - certificateClient.getCertificate("certificateName") -} catch (ResourceNotFoundException e) { - System.out.println(e.getMessage()); -} -``` - -## Next steps -Start using KeyVault Java SDK in your solutions. Our SDK details could be found at [SDK README][CERT_SDK_README]. - -### Additional Documentation -For more extensive documentation on Azure Key Vault, see the [API reference documentation][azkeyvault_rest]. - -## Contributing -This project welcomes contributions and suggestions. Find [more contributing][SDK_README_CONTRIBUTING] details here. - - -[CERT_SDK_README]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md -[SDK_README_CONTRIBUTING]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md#contributing -[SDK_README_GETTING_STARTED]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md#getting-started -[SDK_README_KEY_CONCEPTS]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md#key-concepts -[azkeyvault_rest]: https://learn.microsoft.com/rest/api/keyvault/ -[sample_helloWorld]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/HelloWorld.java -[sample_helloWorldAsync]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/HelloWorldAsync.java -[sample_list]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ListOperations.java -[sample_listAsync]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ListOperationsAsync.java -[sample_BackupRestore]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/BackupAndRestoreOperations.java -[sample_BackupRestoreAsync]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/BackupAndRestoreOperationsAsync.java -[sample_ManageDeleted]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ManagingDeletedCertificates.java -[sample_ManageDeletedAsync]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ManagingDeletedCertificatesAsync.java - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fkeyvault%2Fazure-security-keyvault-certificates%2Fsrc%2Fsamples%2FREADME.png) diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/BackupAndRestoreOperations.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/BackupAndRestoreOperations.java deleted file mode 100644 index 0341156d2615..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/BackupAndRestoreOperations.java +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.util.Context; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollResponse; -import com.azure.core.util.polling.SyncPoller; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.models.CertificateKeyCurveName; -import com.azure.security.keyvault.certificates.models.CertificateKeyType; -import com.azure.security.keyvault.certificates.models.CertificateOperation; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; -import com.azure.security.keyvault.certificates.models.DeletedCertificate; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy; -import com.azure.security.keyvault.certificates.models.SubjectAlternativeNames; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.file.Files; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -/** - * Sample demonstrates how to backup and restore certificates in the key vault. - */ -public class BackupAndRestoreOperations { - /** - * Authenticates with the key vault and shows how to backup and restore certificates in the key vault. - * - * @param args Unused. Arguments to the program. - * @throws IllegalArgumentException when invalid key vault endpoint is passed. - * @throws InterruptedException when the thread is interrupted in sleep mode. - * @throws IOException when writing backup to file is unsuccessful. - */ - public static void main(String[] args) throws IOException, InterruptedException, IllegalArgumentException { - /* Instantiate a CertificateClient that will be used to call the service. Notice that the client is using - default Azure credentials. For more information on this and other types of credentials, see this document: - https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable. - - To get started, you'll need a URL to an Azure Key Vault. See the README - (https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md) - for links and instructions. */ - CertificateClient certificateClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); - - // Let's create a self-signed certificate valid for 1 year. If the certificate already exists in the key vault, - // then a new version of the certificate is created. - CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12") - .setSubjectAlternativeNames(new SubjectAlternativeNames().setEmails(Arrays.asList("wow@gmail.com"))) - .setKeyReusable(true) - .setKeyCurveName(CertificateKeyCurveName.P_256) - .setKeyType(CertificateKeyType.EC); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - SyncPoller certificatePoller = - certificateClient.beginCreateCertificate("certificateName", policy, true, tags); - certificatePoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - - KeyVaultCertificate cert = certificatePoller.getFinalResult(); - - // Backups are good to have, if in case certificates get accidentally deleted by you. - // For long term storage, it is ideal to write the backup to a file. - String backupFilePath = "YOUR_BACKUP_FILE_PATH"; - byte[] certificateBackup = certificateClient.backupCertificate("certificateName"); - - System.out.printf("Backed up certificate with back up blob length %d", certificateBackup.length); - - writeBackupToFile(certificateBackup, backupFilePath); - - // The certificate is no longer in use, so you delete it. - SyncPoller deletedCertificatePoller = - certificateClient.beginDeleteCertificate("certificateName"); - // Deleted Certificate is accessible as soon as polling beings. - PollResponse pollResponse = deletedCertificatePoller.poll(); - - System.out.printf("Deleted certificate with name %s and recovery id %s", pollResponse.getValue().getName(), - pollResponse.getValue().getRecoveryId()); - - deletedCertificatePoller.waitForCompletion(); - - // To ensure the certificate is deleted server-side. - Thread.sleep(30000); - - // If the vault is soft-delete enabled, then you need to purge the certificate as well for permanent deletion. - certificateClient.purgeDeletedCertificateWithResponse("certificateName", new Context("key1", "value1")); - - // To ensure the certificate is purged server-side. - Thread.sleep(15000); - - // After sometime, the certificate is required again. We can use the backup value to restore it in the key - // vault. - byte[] backupFromFile = Files.readAllBytes(new File(backupFilePath).toPath()); - KeyVaultCertificate restoredCertificate = certificateClient.restoreCertificateBackup(backupFromFile); - - System.out.printf(" Restored certificate with name %s and id %s", restoredCertificate.getProperties().getName(), - restoredCertificate.getProperties().getId()); - } - - private static void writeBackupToFile(byte[] bytes, String filePath) { - try { - File file = new File(filePath); - - if (file.exists()) { - file.delete(); - } - - file.createNewFile(); - - OutputStream os = new FileOutputStream(file); - os.write(bytes); - - System.out.println("Successfully wrote backup to file."); - - // Close the file - os.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/BackupAndRestoreOperationsAsync.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/BackupAndRestoreOperationsAsync.java deleted file mode 100644 index 1629f9d2a789..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/BackupAndRestoreOperationsAsync.java +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.SubjectAlternativeNames; -import com.azure.security.keyvault.certificates.models.CertificateKeyCurveName; -import com.azure.security.keyvault.certificates.models.CertificateKeyType; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.file.Files; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -/** - * Sample demonstrates how to asynchronously backup and restore certificates in the key vault. - */ -public class BackupAndRestoreOperationsAsync { - /** - * Authenticates with the key vault and shows how to asynchronously backup and restore certificates in the key vault. - * - * @param args Unused. Arguments to the program. - * @throws IllegalArgumentException when invalid key vault endpoint is passed. - * @throws InterruptedException when the thread is interrupted in sleep mode. - * @throws IOException when writing backup to file is unsuccessful. - */ - public static void main(String[] args) throws IOException, InterruptedException, IllegalArgumentException { - /* Instantiate a CertificateAsyncClient that will be used to call the service. Notice that the client is using - default Azure credentials. For more information on this and other types of credentials, see this document: - https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable. - - To get started, you'll need a URL to an Azure Key Vault. See the README - (https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md) - for links and instructions. */ - CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildAsyncClient(); - - // Let's create a self-signed certificate valid for 1 year. If the certificate already exists in the key vault, - // then a new version of the certificate is created. - CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12") - .setSubjectAlternativeNames(new SubjectAlternativeNames().setEmails(Arrays.asList("wow@gmail.com"))) - .setKeyReusable(true) - .setKeyCurveName(CertificateKeyCurveName.P_256) - .setKeyType(CertificateKeyType.EC); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - certificateAsyncClient.beginCreateCertificate("certificateName", policy, true, tags) - .subscribe(pollResponse -> { - System.out.println("---------------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }); - - Thread.sleep(22000); - - // Backups are good to have, if in case certificates get accidentally deleted by you. - // For long term storage, it is ideal to write the backup to a file. - String backupFilePath = "YOUR_BACKUP_FILE_PATH"; - - certificateAsyncClient.backupCertificate("certificateName") - .subscribe(certificateBackupResponse -> { - writeBackupToFile(certificateBackupResponse, backupFilePath); - System.out.printf("Certificate's Backup Byte array's length %s %n", certificateBackupResponse.length); - }); - - Thread.sleep(7000); - - // The certificate is no longer in use, so you delete it. - certificateAsyncClient.beginDeleteCertificate("certificateName") - .subscribe(pollResponse -> { - System.out.println("Delete Status: " + pollResponse.getStatus().toString()); - System.out.println("Delete Certificate Name: " + pollResponse.getValue().getName()); - System.out.println("Certificate Delete Date: " + pollResponse.getValue().getDeletedOn().toString()); - }); - - // To ensure the certificate is deleted server-side. - Thread.sleep(30000); - - // If the vault is soft-delete enabled, then you need to purge the certificate as well for permanent deletion. - certificateAsyncClient.purgeDeletedCertificateWithResponse("certificateName") - .subscribe(purgeResponse -> - System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode())); - - // To ensure certificate is purged server-side. - Thread.sleep(15000); - - // After sometime, the certificate is required again. We can use the backup value to restore it in the key vault. - byte[] backupFromFile = Files.readAllBytes(new File(backupFilePath).toPath()); - - certificateAsyncClient.restoreCertificateBackup(backupFromFile) - .subscribe(certificateResponse -> System.out.printf("Restored Certificate with name %s and key id %s %n", - certificateResponse.getProperties().getName(), certificateResponse.getKeyId())); - - // To ensure the certificate is restored server-side. - Thread.sleep(15000); - } - - private static void writeBackupToFile(byte[] bytes, String filePath) { - try { - File file = new File(filePath); - - if (file.exists()) { - file.delete(); - } - - file.createNewFile(); - - OutputStream os = new FileOutputStream(file); - os.write(bytes); - - System.out.println("Successfully wrote backup to file."); - - // Close the file - os.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/CertificateAsyncClientJavaDocCodeSnippets.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/CertificateAsyncClientJavaDocCodeSnippets.java deleted file mode 100644 index aae07eaf33f3..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/CertificateAsyncClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,655 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - - -import com.azure.core.http.HttpClient; -import com.azure.core.http.policy.HttpLogDetailLevel; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.models.CertificateContact; -import com.azure.security.keyvault.certificates.models.CertificateIssuer; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.CertificateProperties; -import com.azure.security.keyvault.certificates.models.ImportCertificateOptions; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; -import com.azure.security.keyvault.certificates.models.MergeCertificateOptions; -import reactor.util.context.Context; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -/** - * This class contains code samples for generating javadocs through doclets for {@link CertificateAsyncClient} - */ -public final class CertificateAsyncClientJavaDocCodeSnippets { - private final String key1 = "key1"; - private final String key2 = "key2"; - private final String value1 = "val1"; - private final String value2 = "val2"; - - /** - * Generates code sample for creating a {@link CertificateAsyncClient} - * @return An instance of {@link CertificateAsyncClient} - */ - public CertificateAsyncClient createAsyncClientWithHttpclient() { - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.instantiation.withHttpClient - CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .httpClient(HttpClient.createDefault()) - .buildAsyncClient(); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.instantiation.withHttpClient - return certificateAsyncClient; - } - - /** - * Implementation for async CertificateAsyncClient - * @return sync CertificateAsyncClient - */ - private CertificateAsyncClient getCertificateAsyncClient() { - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.instantiation - CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() - .credential(new DefaultAzureCredentialBuilder().build()) - .vaultUrl("") - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) - .buildAsyncClient(); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.instantiation - return certificateAsyncClient; - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#getCertificatePolicy(String)} - */ - public void getCertificatePolicyCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificatePolicy#string - certificateAsyncClient.getCertificatePolicy("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(policy -> - System.out.printf("Certificate policy is returned with issuer name %s and subject name %s %n", - policy.getIssuerName(), policy.getSubject())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificatePolicy#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificatePolicyWithResponse#string - certificateAsyncClient.getCertificatePolicyWithResponse("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(policyResponse -> - System.out.printf("Certificate policy is returned with issuer name %s and subject name %s %n", - policyResponse.getValue().getIssuerName(), policyResponse.getValue().getSubject())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificatePolicyWithResponse#string - } - - - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#getCertificate(String)} - */ - public void getCertificateWithResponseCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificate#String - certificateAsyncClient.getCertificate("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificateResponse -> - System.out.printf("Certificate is returned with name %s and secretId %s %n", - certificateResponse.getProperties().getName(), certificateResponse.getSecretId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificate#String - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificateWithResponse#String - certificateAsyncClient.getCertificateWithResponse("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificateResponse -> - System.out.printf("Certificate is returned with name %s and secretId %s %n", - certificateResponse.getValue().getProperties().getName(), - certificateResponse.getValue().getSecretId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificateWithResponse#String - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificateVersionWithResponse#string-string - String certificateVersion = "6A385B124DEF4096AF1361A85B16C204"; - certificateAsyncClient.getCertificateVersionWithResponse("certificateName", certificateVersion) - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificateWithVersion -> - System.out.printf("Certificate is returned with name %s and secretId %s %n", - certificateWithVersion.getValue().getProperties().getName(), - certificateWithVersion.getValue().getSecretId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificateVersionWithResponse#string-string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificateVersion#String-String - certificateAsyncClient.getCertificateVersion("certificateName", certificateVersion) - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificateWithVersion -> - System.out.printf("Certificate is returned with name %s and secretId %s %n", - certificateWithVersion.getProperties().getName(), certificateWithVersion.getSecretId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificateVersion#String-String - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificate#CertificateProperties - certificateAsyncClient.getCertificate("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificate -> certificateAsyncClient.getCertificateVersion(certificate.getName(), - certificate.getProperties().getVersion()) - .subscribe(certificateResponse -> - System.out.printf("Certificate is returned with name %s and secretId %s %n", - certificateResponse.getProperties().getName(), certificateResponse.getSecretId()))); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificate#CertificateProperties - } - - /** - * Method to insert code snippets for - * {@link CertificateAsyncClient#beginCreateCertificate(String, CertificatePolicy, Boolean, Map)} and - * {@link CertificateAsyncClient#beginCreateCertificate(String, CertificatePolicy)}. - */ - public void createCertificateCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.beginCreateCertificate#String-CertificatePolicy-Boolean-Map - CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12"); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - certificateAsyncClient.beginCreateCertificate("certificateName", policy, true, tags) - .subscribe(pollResponse -> { - System.out.println("---------------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.beginCreateCertificate#String-CertificatePolicy-Boolean-Map - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.beginCreateCertificate#String-CertificatePolicy - CertificatePolicy certPolicy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12"); - certificateAsyncClient.beginCreateCertificate("certificateName", certPolicy) - .subscribe(pollResponse -> { - System.out.println("---------------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.beginCreateCertificate#String-CertificatePolicy - } - - /** - * Method to insert code snippets for - * {@link CertificateAsyncClient#getCertificateOperation(String)}. - */ - public void getCertificateOperation() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificateOperation#String - certificateAsyncClient.getCertificateOperation("certificateName") - .subscribe(pollResponse -> { - System.out.println("---------------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.getCertificateOperation#String - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#createIssuer(CertificateIssuer)} - */ - public void createCertificateIssuerCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.createIssuer#CertificateIssuer - CertificateIssuer issuer = new CertificateIssuer("issuerName", "providerName") - .setAccountId("keyvaultuser") - .setPassword("fakePasswordPlaceholder"); - certificateAsyncClient.createIssuer(issuer) - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(issuerResponse -> { - System.out.printf("Issuer created with %s and %s", issuerResponse.getName(), - issuerResponse.getProvider()); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.createIssuer#CertificateIssuer - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.createIssuerWithResponse#CertificateIssuer - CertificateIssuer newIssuer = new CertificateIssuer("issuerName", "providerName") - .setAccountId("keyvaultuser") - .setPassword("fakePasswordPlaceholder"); - certificateAsyncClient.createIssuerWithResponse(newIssuer) - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(issuerResponse -> { - System.out.printf("Issuer created with %s and %s", issuerResponse.getValue().getName(), - issuerResponse.getValue().getProvider()); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.createIssuerWithResponse#CertificateIssuer - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#getIssuer(String)} - */ - public void getCertificateIssuerCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.getIssuer#string - certificateAsyncClient.getIssuer("issuerName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(issuer -> { - System.out.printf("Issuer returned with %s and %s", issuer.getName(), - issuer.getProvider()); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.getIssuer#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.getIssuerWithResponse#string - certificateAsyncClient.getIssuerWithResponse("issuerName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(issuerResponse -> { - System.out.printf("Issuer returned with %s and %s", issuerResponse.getValue().getName(), - issuerResponse.getValue().getProvider()); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.getIssuerWithResponse#string - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#updateCertificateProperties(CertificateProperties)} - */ - public void updateCertificateCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.updateCertificateProperties#CertificateProperties - certificateAsyncClient.getCertificate("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificateResponseValue -> { - KeyVaultCertificate certificate = certificateResponseValue; - //Update enabled status of the certificate - certificate.getProperties().setEnabled(false); - certificateAsyncClient.updateCertificateProperties(certificate.getProperties()) - .subscribe(certificateResponse -> - System.out.printf("Certificate's enabled status %s %n", - certificateResponse.getProperties().isEnabled().toString())); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.updateCertificateProperties#CertificateProperties - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#updateIssuer(CertificateIssuer)} - */ - public void updateCertificateIssuerCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.updateIssuer#CertificateIssuer - certificateAsyncClient.getIssuer("issuerName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(issuerResponseValue -> { - CertificateIssuer issuer = issuerResponseValue; - //Update the enabled status of the issuer. - issuer.setEnabled(false); - certificateAsyncClient.updateIssuer(issuer) - .subscribe(issuerResponse -> - System.out.printf("Issuer's enabled status %s %n", - issuerResponse.isEnabled().toString())); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.updateIssuer#CertificateIssuer - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.updateIssuerWithResponse#CertificateIssuer - certificateAsyncClient.getIssuer("issuerName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(issuerResponseValue -> { - CertificateIssuer issuer = issuerResponseValue; - //Update the enabled status of the issuer. - issuer.setEnabled(false); - certificateAsyncClient.updateIssuerWithResponse(issuer) - .subscribe(issuerResponse -> - System.out.printf("Issuer's enabled status %s %n", - issuerResponse.getValue().isEnabled().toString())); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.updateIssuerWithResponse#CertificateIssuer - } - - /** - * Method to insert code snippets for - * {@link CertificateAsyncClient#updateCertificatePolicy(String, CertificatePolicy)} - */ - public void updateCertificatePolicyCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.updateCertificatePolicy#string - certificateAsyncClient.getCertificatePolicy("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificatePolicyResponseValue -> { - CertificatePolicy certificatePolicy = certificatePolicyResponseValue; - // Update transparency - certificatePolicy.setCertificateTransparent(true); - certificateAsyncClient.updateCertificatePolicy("certificateName", certificatePolicy) - .subscribe(updatedPolicy -> - System.out.printf("Certificate policy's updated transparency status %s %n", - updatedPolicy.isCertificateTransparent())); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.updateCertificatePolicy#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.updateCertificatePolicyWithResponse#string - certificateAsyncClient.getCertificatePolicy("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificatePolicyResponseValue -> { - CertificatePolicy certificatePolicy = certificatePolicyResponseValue; - // Update transparency - certificatePolicy.setCertificateTransparent(true); - certificateAsyncClient.updateCertificatePolicyWithResponse("certificateName", - certificatePolicy) - .subscribe(updatedPolicyResponse -> - System.out.printf("Certificate policy's updated transparency status %s %n", - updatedPolicyResponse.getValue().isCertificateTransparent())); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.updateCertificatePolicyWithResponse#string - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#updateCertificateProperties(CertificateProperties)} - */ - public void updateCertificateWithResponseCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.updateCertificatePropertiesWithResponse#CertificateProperties - certificateAsyncClient.getCertificate("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificateResponseValue -> { - KeyVaultCertificate certificate = certificateResponseValue; - //Update the enabled status of the certificate. - certificate.getProperties().setEnabled(false); - certificateAsyncClient.updateCertificatePropertiesWithResponse(certificate.getProperties()) - .subscribe(certificateResponse -> - System.out.printf("Certificate's enabled status %s %n", - certificateResponse.getValue().getProperties().isEnabled().toString())); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.updateCertificatePropertiesWithResponse#CertificateProperties - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#beginDeleteCertificate(String)}. - */ - public void deleteCertificateCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.beginDeleteCertificate#String - certificateAsyncClient.beginDeleteCertificate("certificateName") - .subscribe(pollResponse -> { - System.out.println("Delete Status: " + pollResponse.getStatus().toString()); - System.out.println("Delete Certificate Name: " + pollResponse.getValue().getName()); - System.out.println("Certificate Delete Date: " + pollResponse.getValue().getDeletedOn().toString()); - }); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.beginDeleteCertificate#String - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#deleteIssuer(String)} - */ - public void deleteCertificateIssuerCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteIssuerWithResponse#string - certificateAsyncClient.deleteIssuerWithResponse("issuerName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(deletedIssuerResponse -> - System.out.printf("Deleted issuer with name %s %n", deletedIssuerResponse.getValue().getName())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteIssuerWithResponse#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteIssuer#string - certificateAsyncClient.deleteIssuer("issuerName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(deletedIssuerResponse -> - System.out.printf("Deleted issuer with name %s %n", deletedIssuerResponse.getName())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteIssuer#string - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#getDeletedCertificate(String)} - */ - public void getDeletedCertificateCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.getDeletedCertificate#string - certificateAsyncClient.getDeletedCertificate("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(deletedSecretResponse -> - System.out.printf("Deleted Certificate's Recovery Id %s %n", deletedSecretResponse.getRecoveryId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.getDeletedCertificate#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.getDeletedCertificateWithResponse#string - certificateAsyncClient.getDeletedCertificateWithResponse("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(deletedSecretResponse -> - System.out.printf("Deleted Certificate's Recovery Id %s %n", - deletedSecretResponse.getValue().getRecoveryId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.getDeletedCertificateWithResponse#string - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#purgeDeletedCertificate(String)} - */ - public void purgeDeletedCertificateCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.purgeDeletedCertificate#string - certificateAsyncClient.purgeDeletedCertificate("deletedCertificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .doOnSuccess(response -> System.out.println("Successfully Purged certificate")); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.purgeDeletedCertificate#string - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#purgeDeletedCertificateWithResponse(String)} - */ - public void purgeDeletedCertificateWithResponseCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.purgeDeletedCertificateWithResponse#string - certificateAsyncClient.purgeDeletedCertificateWithResponse("deletedCertificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(purgeResponse -> - System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.purgeDeletedCertificateWithResponse#string - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#beginRecoverDeletedCertificate(String)}. - */ - public void recoverDeletedCertificateCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.certificatevault.certificates.CertificateAsyncClient.beginRecoverDeletedCertificate#String - certificateAsyncClient.beginRecoverDeletedCertificate("deletedCertificateName") - .subscribe(pollResponse -> { - System.out.println("Recovery Status: " + pollResponse.getStatus().toString()); - System.out.println("Recover Certificate Name: " + pollResponse.getValue().getName()); - System.out.println("Recover Certificate Id: " + pollResponse.getValue().getId()); - }); - // END: com.azure.security.certificatevault.certificates.CertificateAsyncClient.beginRecoverDeletedCertificate#String - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#backupCertificate(String)} - */ - public void backupCertificateCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.backupCertificate#string - certificateAsyncClient.backupCertificate("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificateBackupResponse -> - System.out.printf("Certificate's Backup Byte array's length %s %n", certificateBackupResponse.length)); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.backupCertificate#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.backupCertificateWithResponse#string - certificateAsyncClient.backupCertificateWithResponse("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificateBackupResponse -> - System.out.printf("Certificate's Backup Byte array's length %s %n", - certificateBackupResponse.getValue().length)); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.backupCertificateWithResponse#string - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#restoreCertificateBackup(byte[])} - */ - public void restoreCertificateCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.restoreCertificate#byte - byte[] certificateBackupByteArray = {}; - certificateAsyncClient.restoreCertificateBackup(certificateBackupByteArray) - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificateResponse -> System.out.printf("Restored Certificate with name %s and key id %s %n", - certificateResponse.getProperties().getName(), certificateResponse.getKeyId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.restoreCertificate#byte - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.restoreCertificateWithResponse#byte - byte[] certificateBackup = {}; - certificateAsyncClient.restoreCertificateBackup(certificateBackup) - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificateResponse -> System.out.printf("Restored Certificate with name %s and key id %s %n", - certificateResponse.getProperties().getName(), certificateResponse.getKeyId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.restoreCertificateWithResponse#byte - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#listPropertiesOfCertificates()} - */ - public void listCertificatesCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.listCertificates - certificateAsyncClient.listPropertiesOfCertificates() - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificate -> certificateAsyncClient.getCertificateVersion(certificate.getName(), - certificate.getVersion()) - .subscribe(certificateResponse -> System.out.printf("Received certificate with name %s and key id %s", - certificateResponse.getName(), certificateResponse.getKeyId()))); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.listCertificates - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#listPropertiesOfIssuers()} - */ - public void listCertificateIssuersCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.listPropertiesOfIssuers - certificateAsyncClient.listPropertiesOfIssuers() - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(issuerProperties -> certificateAsyncClient.getIssuer(issuerProperties.getName()) - .subscribe(issuerResponse -> System.out.printf("Received issuer with name %s and provider %s", - issuerResponse.getName(), issuerResponse.getProvider()))); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.listPropertiesOfIssuers - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#listDeletedCertificates()} - */ - public void listDeletedCertificatesCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.listDeletedCertificates - certificateAsyncClient.listDeletedCertificates() - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(deletedCertificateResponse -> System.out.printf("Deleted Certificate's Recovery Id %s %n", - deletedCertificateResponse.getRecoveryId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.listDeletedCertificates - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#listPropertiesOfCertificateVersions(String)} - */ - public void listCertificateVersionsCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.listCertificateVersions - certificateAsyncClient.listPropertiesOfCertificateVersions("certificateName") - .contextWrite(Context.of(key1, value1, key2, value2)) - .subscribe(certificate -> certificateAsyncClient.getCertificateVersion(certificate.getName(), - certificate.getVersion()) - .subscribe(certificateResponse -> System.out.printf("Received certificate with name %s and key id %s", - certificateResponse.getProperties().getName(), certificateResponse.getKeyId()))); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.listCertificateVersions - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#setContacts(List)} - */ - public void contactsOperationsCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.setContacts#contacts - CertificateContact contactToAdd = new CertificateContact().setName("user").setEmail("useremail@example.com"); - certificateAsyncClient.setContacts(Collections.singletonList(contactToAdd)).subscribe(contact -> - System.out.printf("Contact name %s and email %s", contact.getName(), contact.getEmail()) - ); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.setContacts#contacts - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.listContacts - certificateAsyncClient.listContacts().subscribe(contact -> - System.out.printf("Contact name %s and email %s", contact.getName(), contact.getEmail()) - ); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.listContacts - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteContacts - certificateAsyncClient.deleteContacts().subscribe(contact -> - System.out.printf("Deleted Contact name %s and email %s", contact.getName(), contact.getEmail()) - ); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteContacts - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#deleteCertificateOperation(String)} and - * {@link CertificateAsyncClient#deleteCertificateOperationWithResponse(String, com.azure.core.util.Context)} - */ - public void certificateOperationCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteCertificateOperationWithResponse#string - certificateAsyncClient.deleteCertificateOperationWithResponse("certificateName") - .subscribe(certificateOperationResponse -> System.out.printf("Deleted Certificate operation's last" - + " status %s", certificateOperationResponse.getValue().getStatus())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteCertificateOperationWithResponse#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteCertificateOperation#string - certificateAsyncClient.deleteCertificateOperation("certificateName") - .subscribe(certificateOperation -> System.out.printf("Deleted Certificate operation last status %s", - certificateOperation.getStatus())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.deleteCertificateOperation#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.cancelCertificateOperation#string - certificateAsyncClient.cancelCertificateOperation("certificateName") - .subscribe(certificateOperation -> System.out.printf("Certificate operation status %s", - certificateOperation.getStatus())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.cancelCertificateOperation#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.cancelCertificateOperationWithResponse#string - certificateAsyncClient.cancelCertificateOperationWithResponse("certificateName") - .subscribe(certificateOperationResponse -> System.out.printf("Certificate operation status %s", - certificateOperationResponse.getValue().getStatus())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.cancelCertificateOperationWithResponse#string - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#mergeCertificate(MergeCertificateOptions)} - */ - public void mergeCertificateCodeSnippets() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.mergeCertificate#config - List x509CertificatesToMerge = new ArrayList<>(); - MergeCertificateOptions config = - new MergeCertificateOptions("certificateName", x509CertificatesToMerge).setEnabled(false); - certificateAsyncClient.mergeCertificate(config) - .subscribe(certificate -> System.out.printf("Received Certificate with name %s and key id %s", - certificate.getProperties().getName(), certificate.getKeyId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.mergeCertificate#config - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.mergeCertificateWithResponse#config - List x509CertsToMerge = new ArrayList<>(); - MergeCertificateOptions mergeConfig = - new MergeCertificateOptions("certificateName", x509CertsToMerge).setEnabled(false); - certificateAsyncClient.mergeCertificateWithResponse(mergeConfig) - .subscribe(certificateResponse -> System.out.printf("Received Certificate with name %s and key id %s", - certificateResponse.getValue().getProperties().getName(), certificateResponse.getValue().getKeyId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.mergeCertificateWithResponse#config - } - - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#importCertificate(ImportCertificateOptions)} - */ - public void importCertificate() { - CertificateAsyncClient certificateAsyncClient = getCertificateAsyncClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.importCertificate#options - byte[] certificateToImport = new byte[100]; - ImportCertificateOptions config = - new ImportCertificateOptions("certificateName", certificateToImport).setEnabled(false); - certificateAsyncClient.importCertificate(config) - .subscribe(certificate -> System.out.printf("Received Certificate with name %s and key id %s", - certificate.getProperties().getName(), certificate.getKeyId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.importCertificate#options - - // BEGIN: com.azure.security.keyvault.certificates.CertificateAsyncClient.importCertificateWithResponse#options - byte[] certToImport = new byte[100]; - ImportCertificateOptions importCertificateOptions = - new ImportCertificateOptions("certificateName", certToImport).setEnabled(false); - certificateAsyncClient.importCertificateWithResponse(importCertificateOptions) - .subscribe(certificateResponse -> System.out.printf("Received Certificate with name %s and key id %s", - certificateResponse.getValue().getProperties().getName(), certificateResponse.getValue().getKeyId())); - // END: com.azure.security.keyvault.certificates.CertificateAsyncClient.importCertificateWithResponse#options - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/CertificateClientJavaDocCodeSnippets.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/CertificateClientJavaDocCodeSnippets.java deleted file mode 100644 index cd87d24625f9..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/CertificateClientJavaDocCodeSnippets.java +++ /dev/null @@ -1,663 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - - -import com.azure.core.http.policy.HttpLogDetailLevel; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.http.rest.Response; -import com.azure.core.util.Context; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollResponse; -import com.azure.core.util.polling.SyncPoller; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.models.AdministratorContact; -import com.azure.security.keyvault.certificates.models.CertificateContact; -import com.azure.security.keyvault.certificates.models.CertificateIssuer; -import com.azure.security.keyvault.certificates.models.CertificateOperation; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.CertificateProperties; -import com.azure.security.keyvault.certificates.models.DeletedCertificate; -import com.azure.security.keyvault.certificates.models.ImportCertificateOptions; -import com.azure.security.keyvault.certificates.models.IssuerProperties; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy; -import com.azure.security.keyvault.certificates.models.MergeCertificateOptions; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * This class contains code samples for generating javadocs through doclets for {@link CertificateClient} - */ -public final class CertificateClientJavaDocCodeSnippets { - private final String key1 = "key1"; - private final String key2 = "key2"; - private final String value1 = "val1"; - private final String value2 = "val2"; - - /** - * Implementation for.CertificateClient - * - * @return sync CertificateClient - */ - private CertificateClient getCertificateClient() { - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.instantiation - CertificateClient certificateClient = new CertificateClientBuilder() - .credential(new DefaultAzureCredentialBuilder().build()) - .vaultUrl("") - .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) - .buildClient(); - // END: com.azure.security.keyvault.certificates.CertificateClient.instantiation - return certificateClient; - } - - - /** - * Method to insert code snippets for {@link CertificateClient#getCertificatePolicy(String)} - */ - public void getCertificatePolicyCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificatePolicy#string - CertificatePolicy policy = certificateClient.getCertificatePolicy("certificateName"); - System.out.printf("Received policy with subject name %s%n", policy.getSubject()); - // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificatePolicy#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificatePolicyWithResponse#string - Response returnedPolicyWithResponse = certificateClient.getCertificatePolicyWithResponse( - "certificateName", new Context(key1, value1)); - System.out.printf("Received policy with subject name %s%n", - returnedPolicyWithResponse.getValue().getSubject()); - // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificatePolicyWithResponse#string - } - - - /** - * Method to insert code snippets for {@link CertificateClient#getCertificate(String)} - */ - public void getCertificateWithResponseCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificate#String - KeyVaultCertificateWithPolicy certificate = certificateClient.getCertificate("certificateName"); - System.out.printf("Received certificate with name %s and version %s and secret id %s%n", - certificate.getProperties().getName(), - certificate.getProperties().getVersion(), certificate.getSecretId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificate#String - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificateWithResponse#String-Context - Response certificateWithResponse = certificateClient - .getCertificateWithResponse("certificateName", new Context(key1, value1)); - System.out.printf("Received certificate with name %s and version %s and secret id %s%n", - certificateWithResponse.getValue().getProperties().getName(), - certificateWithResponse.getValue().getProperties().getVersion(), certificate.getSecretId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificateWithResponse#String-Context - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificateVersionWithResponse#String-String-Context - Response returnedCertificateWithResponse = certificateClient - .getCertificateVersionWithResponse("certificateName", "certificateVersion", - new Context(key1, value1)); - System.out.printf("Received certificate with name %s and version %s and secret id %s%n", - returnedCertificateWithResponse.getValue().getProperties().getName(), - returnedCertificateWithResponse.getValue().getProperties().getVersion(), - returnedCertificateWithResponse.getValue().getSecretId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificateVersionWithResponse#String-String-Context - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificateVersion#String-String - KeyVaultCertificate returnedCertificate = certificateClient.getCertificateVersion("certificateName", - "certificateVersion"); - System.out.printf("Received certificate with name %s and version %s and secret id %s%n", - returnedCertificate.getProperties().getName(), returnedCertificate.getProperties().getVersion(), - returnedCertificate.getSecretId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificateVersion#String-String - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificate#CertificateProperties - for (CertificateProperties certificateProperties : certificateClient.listPropertiesOfCertificates()) { - KeyVaultCertificate certificateWithAllProperties = certificateClient - .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); - System.out.printf("Received certificate with name %s and secret id %s%n", - certificateWithAllProperties.getProperties().getName(), certificateWithAllProperties.getSecretId()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificate#CertificateProperties - } - - /** - * Method to insert code snippets for {@link CertificateClient#beginCreateCertificate(String, CertificatePolicy, - * Boolean, Map)} and {@link CertificateClient#beginCreateCertificate(String, CertificatePolicy)}. - */ - public void createCertificateCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.beginCreateCertificate#String-CertificatePolicy-Boolean-Map - CertificatePolicy certificatePolicyPkcsSelf = new CertificatePolicy("Self", - "CN=SelfSignedJavaPkcs12"); - SyncPoller certificateSyncPoller = certificateClient - .beginCreateCertificate("certificateName", certificatePolicyPkcsSelf, true, new HashMap<>()); - certificateSyncPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - KeyVaultCertificate createdCertificate = certificateSyncPoller.getFinalResult(); - System.out.printf("Certificate created with name %s%n", createdCertificate.getName()); - // END: com.azure.security.keyvault.certificates.CertificateClient.beginCreateCertificate#String-CertificatePolicy-Boolean-Map - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.beginCreateCertificate#String-CertificatePolicy - CertificatePolicy certPolicy = new CertificatePolicy("Self", - "CN=SelfSignedJavaPkcs12"); - SyncPoller certPoller = certificateClient - .beginCreateCertificate("certificateName", certPolicy); - certPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - KeyVaultCertificate cert = certPoller.getFinalResult(); - System.out.printf("Certificate created with name %s%n", cert.getName()); - // END: com.azure.security.keyvault.certificates.CertificateClient.beginCreateCertificate#String-CertificatePolicy - } - - /** - * Method to insert code snippets for {@link CertificateClient#getCertificateOperation(String)}. - */ - public void getCertificateOperation() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getCertificateOperation#String - SyncPoller getCertPoller = certificateClient - .getCertificateOperation("certificateName"); - getCertPoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - KeyVaultCertificate cert = getCertPoller.getFinalResult(); - System.out.printf("Certificate created with name %s%n", cert.getName()); - // END: com.azure.security.keyvault.certificates.CertificateClient.getCertificateOperation#String - } - - - /** - * Method to insert code snippets for {@link CertificateClient#createIssuer(CertificateIssuer)} - */ - public void createCertificateIssuerCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.createIssuer#CertificateIssuer - CertificateIssuer issuerToCreate = new CertificateIssuer("myissuer", "myProvider") - .setAccountId("testAccount") - .setAdministratorContacts(Collections.singletonList(new AdministratorContact().setFirstName("test") - .setLastName("name").setEmail("test@example.com"))); - CertificateIssuer returnedIssuer = certificateClient.createIssuer(issuerToCreate); - System.out.printf("Created Issuer with name %s provider %s%n", returnedIssuer.getName(), - returnedIssuer.getProvider()); - // END: com.azure.security.keyvault.certificates.CertificateClient.createIssuer#CertificateIssuer - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.createIssuerWithResponse#CertificateIssuer-Context - CertificateIssuer issuer = new CertificateIssuer("issuerName", "myProvider") - .setAccountId("testAccount") - .setAdministratorContacts(Collections.singletonList(new AdministratorContact().setFirstName("test") - .setLastName("name").setEmail("test@example.com"))); - Response issuerResponse = certificateClient.createIssuerWithResponse(issuer, - new Context(key1, value1)); - System.out.printf("Created Issuer with name %s provider %s%n", issuerResponse.getValue().getName(), - issuerResponse.getValue().getProvider()); - // END: com.azure.security.keyvault.certificates.CertificateClient.createIssuerWithResponse#CertificateIssuer-Context - } - - /** - * Method to insert code snippets for {@link CertificateClient#getIssuer(String)} - */ - public void getCertificateIssuerCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getIssuer#string - CertificateIssuer returnedIssuer = certificateClient.getIssuer("issuerName"); - System.out.printf("Retrieved issuer with name %s and provider %s%n", returnedIssuer.getName(), - returnedIssuer.getProvider()); - // END: com.azure.security.keyvault.certificates.CertificateClient.getIssuer#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getIssuerWithResponse#string-context - Response issuerResponse = certificateClient.getIssuerWithResponse("issuerName", - new Context(key1, value1)); - System.out.printf("Retrieved issuer with name %s and provider %s%n", issuerResponse.getValue().getName(), - issuerResponse.getValue().getProvider()); - // END: com.azure.security.keyvault.certificates.CertificateClient.getIssuerWithResponse#string-context - } - - /** - * Method to insert code snippets for {@link CertificateClient#updateCertificateProperties(CertificateProperties)} - */ - public void updateCertificateCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.updateCertificateProperties#CertificateProperties - KeyVaultCertificate certificate = certificateClient.getCertificate("certificateName"); - // Update certificate enabled status - certificate.getProperties().setEnabled(false); - KeyVaultCertificate updatedCertificate = certificateClient.updateCertificateProperties(certificate.getProperties()); - System.out.printf("Updated Certificate with name %s and enabled status %s%n", - updatedCertificate.getProperties().getName(), updatedCertificate.getProperties().isEnabled()); - // END: com.azure.security.keyvault.certificates.CertificateClient.updateCertificateProperties#CertificateProperties - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.updateCertificatePropertiesWithResponse#CertificateProperties-Context - KeyVaultCertificate certificateToUpdate = certificateClient.getCertificate("certificateName"); - // Update certificate enabled status - certificateToUpdate.getProperties().setEnabled(false); - Response updatedCertificateResponse = certificateClient. - updateCertificatePropertiesWithResponse(certificateToUpdate.getProperties(), new Context(key1, value1)); - System.out.printf("Updated Certificate with name %s and enabled status %s%n", - updatedCertificateResponse.getValue().getProperties().getName(), - updatedCertificateResponse.getValue().getProperties().isEnabled()); - // END: com.azure.security.keyvault.certificates.CertificateClient.updateCertificatePropertiesWithResponse#CertificateProperties-Context - } - - /** - * Method to insert code snippets for {@link CertificateClient#updateIssuer(CertificateIssuer)} - */ - public void updateCertificateIssuerCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.updateIssuer#CertificateIssuer - CertificateIssuer returnedIssuer = certificateClient.getIssuer("issuerName"); - returnedIssuer.setAccountId("newAccountId"); - CertificateIssuer updatedIssuer = certificateClient.updateIssuer(returnedIssuer); - System.out.printf("Updated issuer with name %s, provider %s and account Id %s%n", updatedIssuer.getName(), - updatedIssuer.getProvider(), updatedIssuer.getAccountId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.updateIssuer#CertificateIssuer - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.updateIssuerWithResponse#CertificateIssuer-Context - CertificateIssuer issuer = certificateClient.getIssuer("issuerName"); - returnedIssuer.setAccountId("newAccountId"); - Response updatedIssuerWithResponse = certificateClient.updateIssuerWithResponse(issuer, - new Context(key1, value1)); - System.out.printf("Updated issuer with name %s, provider %s and account Id %s%n", - updatedIssuerWithResponse.getValue().getName(), - updatedIssuerWithResponse.getValue().getProvider(), - updatedIssuerWithResponse.getValue().getAccountId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.updateIssuerWithResponse#CertificateIssuer-Context - } - - /** - * Method to insert code snippets for {@link CertificateClient#updateCertificatePolicy(String, CertificatePolicy)} - */ - public void updateCertificatePolicyCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.updateCertificatePolicy#string - CertificatePolicy certificatePolicy = certificateClient.getCertificatePolicy("certificateName"); - //Update the certificate policy cert transparency property. - certificatePolicy.setCertificateTransparent(true); - CertificatePolicy updatedCertPolicy = certificateClient.updateCertificatePolicy("certificateName", - certificatePolicy); - System.out.printf("Updated Certificate Policy transparency status %s%n", - updatedCertPolicy.isCertificateTransparent()); - // END: com.azure.security.keyvault.certificates.CertificateClient.updateCertificatePolicy#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.updateCertificatePolicyWithResponse#string - CertificatePolicy certificatePolicyToUpdate = certificateClient.getCertificatePolicy("certificateName"); - //Update the certificate policy cert transparency property. - certificatePolicyToUpdate.setCertificateTransparent(true); - Response updatedCertPolicyWithResponse = certificateClient - .updateCertificatePolicyWithResponse("certificateName", certificatePolicyToUpdate, - new Context(key1, value1)); - System.out.printf("Updated Certificate Policy transparency status %s%n", updatedCertPolicyWithResponse - .getValue().isCertificateTransparent()); - // END: com.azure.security.keyvault.certificates.CertificateClient.updateCertificatePolicyWithResponse#string - } - - /** - * Method to insert code snippets for {@link CertificateClient#beginDeleteCertificate(String)}. - */ - public void deleteCertificateCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.beginDeleteCertificate#String - SyncPoller deleteCertPoller = - certificateClient.beginDeleteCertificate("certificateName"); - // Deleted Certificate is accessible as soon as polling beings. - PollResponse deleteCertPollResponse = deleteCertPoller.poll(); - System.out.printf("Deleted certificate with name %s and recovery id %s%n", - deleteCertPollResponse.getValue().getName(), deleteCertPollResponse.getValue().getRecoveryId()); - deleteCertPoller.waitForCompletion(); - // END: com.azure.security.keyvault.certificates.CertificateClient.beginDeleteCertificate#String - } - - /** - * Method to insert code snippets for {@link CertificateClient#deleteIssuer(String)} - */ - public void deleteCertificateIssuefrCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.deleteIssuerWithResponse#string-context - CertificateIssuer deletedIssuer = certificateClient.deleteIssuer("issuerName"); - System.out.printf("Deleted certificate issuer with name %s and provider id %s%n", deletedIssuer.getName(), - deletedIssuer.getProvider()); - // END: com.azure.security.keyvault.certificates.CertificateClient.deleteIssuerWithResponse#string-context - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.deleteIssuer#string - Response deletedIssuerWithResponse = certificateClient. - deleteIssuerWithResponse("issuerName", new Context(key1, value1)); - System.out.printf("Deleted certificate issuer with name %s and provider id %s%n", - deletedIssuerWithResponse.getValue().getName(), - deletedIssuerWithResponse.getValue().getProvider()); - // END: com.azure.security.keyvault.certificates.CertificateClient.deleteIssuer#string - } - - /** - * Method to insert code snippets for {@link CertificateClient#getDeletedCertificate(String)} - */ - public void getDeletedCertificateCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getDeletedCertificate#string - DeletedCertificate deletedCertificate = certificateClient.getDeletedCertificate("certificateName"); - System.out.printf("Deleted certificate with name %s and recovery id %s%n", deletedCertificate.getName(), - deletedCertificate.getRecoveryId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.getDeletedCertificate#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.getDeletedCertificateWithResponse#String-Context - Response deletedCertificateWithResponse = certificateClient - .getDeletedCertificateWithResponse("certificateName", new Context(key1, value1)); - System.out.printf("Deleted certificate with name %s and recovery id %s%n", - deletedCertificateWithResponse.getValue().getName(), - deletedCertificateWithResponse.getValue().getRecoveryId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.getDeletedCertificateWithResponse#String-Context - } - - /** - * Method to insert code snippets for {@link CertificateClient#purgeDeletedCertificateWithResponse(String, - * Context)} - */ - public void purgeDeletedCertificateCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.purgeDeletedCertificate#string - certificateClient.purgeDeletedCertificate("certificateName"); - // END: com.azure.security.keyvault.certificates.CertificateClient.purgeDeletedCertificate#string - } - - /** - * Method to insert code snippets for {@link CertificateClient#purgeDeletedCertificateWithResponse(String, - * Context)} - */ - public void purgeDeletedCertificateWithResponseCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.purgeDeletedCertificateWithResponse#string-Context - Response purgeResponse = certificateClient.purgeDeletedCertificateWithResponse("certificateName", - new Context(key1, value1)); - System.out.printf("Purged Deleted certificate with status %d%n", purgeResponse.getStatusCode()); - // END: com.azure.security.keyvault.certificates.CertificateClient.purgeDeletedCertificateWithResponse#string-Context - } - - /** - * Method to insert code snippets for {@link CertificateClient#beginRecoverDeletedCertificate(String)}. - */ - public void recoverDeletedCertificateCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.beginRecoverDeletedCertificate#String - SyncPoller recoverDeletedCertPoller = certificateClient - .beginRecoverDeletedCertificate("deletedCertificateName"); - // Recovered certificate is accessible as soon as polling beings - PollResponse recoverDeletedCertPollResponse = recoverDeletedCertPoller.poll(); - System.out.printf(" Recovered Deleted certificate with name %s and id %s%n", - recoverDeletedCertPollResponse.getValue().getProperties().getName(), - recoverDeletedCertPollResponse.getValue().getProperties().getId()); - recoverDeletedCertPoller.waitForCompletion(); - // END: com.azure.security.keyvault.certificates.CertificateClient.beginRecoverDeletedCertificate#String - } - - /** - * Method to insert code snippets for {@link CertificateClient#backupCertificate(String)} - */ - public void backupCertificateCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.backupCertificate#string - byte[] certificateBackup = certificateClient.backupCertificate("certificateName"); - System.out.printf("Backed up certificate with back up blob length %d%n", certificateBackup.length); - // END: com.azure.security.keyvault.certificates.CertificateClient.backupCertificate#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.backupCertificateWithResponse#String-Context - Response certificateBackupWithResponse = certificateClient - .backupCertificateWithResponse("certificateName", new Context(key1, value1)); - System.out.printf("Backed up certificate with back up blob length %d%n", - certificateBackupWithResponse.getValue().length); - // END: com.azure.security.keyvault.certificates.CertificateClient.backupCertificateWithResponse#String-Context - } - - /** - * Method to insert code snippets for {@link CertificateClient#restoreCertificateBackup(byte[])} - */ - public void restoreCertificateCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.restoreCertificate#byte - byte[] certificateBackupBlob = {}; - KeyVaultCertificate certificate = certificateClient.restoreCertificateBackup(certificateBackupBlob); - System.out.printf(" Restored certificate with name %s and id %s%n", - certificate.getProperties().getName(), certificate.getProperties().getId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.restoreCertificate#byte - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.restoreCertificateWithResponse#byte-Context - byte[] certificateBackupBlobArray = {}; - Response certificateResponse = certificateClient - .restoreCertificateBackupWithResponse(certificateBackupBlobArray, new Context(key1, value1)); - System.out.printf(" Restored certificate with name %s and id %s%n", - certificateResponse.getValue().getProperties().getName(), - certificateResponse.getValue().getProperties().getId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.restoreCertificateWithResponse#byte-Context - } - - /** - * Method to insert code snippets for {@link CertificateClient#listPropertiesOfCertificates()} - */ - public void listCertificatesCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listCertificates - for (CertificateProperties certificateProperties : certificateClient.listPropertiesOfCertificates()) { - KeyVaultCertificate certificateWithAllProperties = certificateClient - .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); - System.out.printf("Received certificate with name %s and secret id %s%n", - certificateWithAllProperties.getProperties().getName(), - certificateWithAllProperties.getSecretId()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.listCertificates - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listCertificates#context - for (CertificateProperties certificateProperties : certificateClient - .listPropertiesOfCertificates(true, new Context(key1, value1))) { - KeyVaultCertificate certificateWithAllProperties = certificateClient - .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); - System.out.printf("Received certificate with name %s and secret id %s%n", - certificateWithAllProperties.getProperties().getName(), - certificateWithAllProperties.getSecretId()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.listCertificates#context - } - - /** - * Method to insert code snippets for {@link CertificateClient#listPropertiesOfIssuers()} - */ - public void listCertificateIssuersCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listPropertiesOfIssuers - for (IssuerProperties issuer : certificateClient.listPropertiesOfIssuers()) { - CertificateIssuer retrievedIssuer = certificateClient.getIssuer(issuer.getName()); - System.out.printf("Received issuer with name %s and provider %s%n", retrievedIssuer.getName(), - retrievedIssuer.getProvider()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.listPropertiesOfIssuers - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listPropertiesOfIssuers#context - for (IssuerProperties issuer : certificateClient.listPropertiesOfIssuers(new Context(key1, value1))) { - CertificateIssuer retrievedIssuer = certificateClient.getIssuer(issuer.getName()); - System.out.printf("Received issuer with name %s and provider %s%n", retrievedIssuer.getName(), - retrievedIssuer.getProvider()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.listPropertiesOfIssuers#context - } - - /** - * Method to insert code snippets for {@link CertificateClient#listDeletedCertificates()} - */ - public void listDeletedCertificatesCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listDeletedCertificates - for (DeletedCertificate deletedCertificate : certificateClient.listDeletedCertificates()) { - System.out.printf("Deleted certificate's recovery Id %s%n", deletedCertificate.getRecoveryId()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.listDeletedCertificates - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listDeletedCertificates#context - for (DeletedCertificate deletedCertificate : certificateClient - .listDeletedCertificates(true, new Context(key1, value1))) { - System.out.printf("Deleted certificate's recovery Id %s%n", deletedCertificate.getRecoveryId()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.listDeletedCertificates#context - } - - /** - * Method to insert code snippets for {@link CertificateClient#listPropertiesOfCertificateVersions(String)} - */ - public void listCertificateVersionsCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listCertificateVersions - for (CertificateProperties certificateProperties : certificateClient - .listPropertiesOfCertificateVersions("certificateName")) { - KeyVaultCertificate certificateWithAllProperties = certificateClient - .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); - System.out.printf("Received certificate's version with name %s, version %s and secret id %s%n", - certificateWithAllProperties.getProperties().getName(), - certificateWithAllProperties.getProperties().getVersion(), certificateWithAllProperties.getSecretId()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.listCertificateVersions - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listCertificateVersions#context - for (CertificateProperties certificateProperties : certificateClient - .listPropertiesOfCertificateVersions("certificateName")) { - KeyVaultCertificate certificateWithAllProperties = certificateClient - .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); - System.out.printf("Received certificate's version with name %s, version %s and secret id %s%n", - certificateWithAllProperties.getProperties().getName(), - certificateWithAllProperties.getProperties().getVersion(), certificateWithAllProperties.getSecretId()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.listCertificateVersions#context - } - - /** - * Method to insert code snippets for {@link CertificateClient#setContacts(List)} - */ - public void contactsOperationsCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.setContacts#contacts - CertificateContact contactToAdd = new CertificateContact().setName("user").setEmail("useremail@example.com"); - for (CertificateContact contact : certificateClient.setContacts(Collections.singletonList(contactToAdd))) { - System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(), - contact.getEmail()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.setContacts#contacts - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.setContacts#contacts-context - CertificateContact sampleContact = new CertificateContact().setName("user").setEmail("useremail@example.com"); - for (CertificateContact contact : certificateClient.setContacts(Collections.singletonList(sampleContact), - new Context(key1, value1))) { - System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(), - contact.getEmail()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.setContacts#contacts-context - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listContacts - for (CertificateContact contact : certificateClient.listContacts()) { - System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(), - contact.getEmail()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.listContacts - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.listContacts#context - for (CertificateContact contact : certificateClient.listContacts(new Context(key1, value1))) { - System.out.printf("Added contact with name %s and email %s to key vault%n", contact.getName(), - contact.getEmail()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.listContacts#context - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.deleteContacts - for (CertificateContact contact : certificateClient.deleteContacts()) { - System.out.printf("Deleted contact with name %s and email %s from key vault%n", contact.getName(), - contact.getEmail()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.deleteContacts - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.deleteContacts#context - for (CertificateContact contact : certificateClient.deleteContacts(new Context(key1, value1))) { - System.out.printf("Deleted contact with name %s and email %s from key vault%n", contact.getName(), - contact.getEmail()); - } - // END: com.azure.security.keyvault.certificates.CertificateClient.deleteContacts#context - } - - /** - * Method to insert code snippets for {@link CertificateClient#deleteCertificateOperation(String)} (String)} and - * {@link CertificateClient#deleteCertificateOperationWithResponse(String, Context)} - */ - public void certificateOperationCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.deleteCertificateOperationWithResponse#string - CertificateOperation deletedCertificateOperation = certificateClient - .deleteCertificateOperation("certificateName"); - System.out.printf("Deleted Certificate Operation's last status %s%n", deletedCertificateOperation.getStatus()); - // END: com.azure.security.keyvault.certificates.CertificateClient.deleteCertificateOperationWithResponse#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.deleteCertificateOperation#string - Response deletedCertificateOperationWithResponse = certificateClient - .deleteCertificateOperationWithResponse("certificateName", new Context(key1, value1)); - System.out.printf("Deleted Certificate Operation's last status %s%n", - deletedCertificateOperationWithResponse.getValue().getStatus()); - // END: com.azure.security.keyvault.certificates.CertificateClient.deleteCertificateOperation#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.cancelCertificateOperation#string - CertificateOperation certificateOperation = certificateClient - .cancelCertificateOperation("certificateName"); - System.out.printf("Certificate Operation status %s%n", certificateOperation.getStatus()); - // END: com.azure.security.keyvault.certificates.CertificateClient.cancelCertificateOperation#string - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.cancelCertificateOperationWithResponse#string - Response certificateOperationWithResponse = certificateClient - .cancelCertificateOperationWithResponse("certificateName", new Context(key1, value1)); - System.out.printf("Certificate Operation status %s%n", certificateOperationWithResponse.getValue().getStatus()); - // END: com.azure.security.keyvault.certificates.CertificateClient.cancelCertificateOperationWithResponse#string - } - - /** - * Method to insert code snippets for {@link CertificateAsyncClient#mergeCertificate(MergeCertificateOptions)} - */ - public void mergeCertificateCodeSnippets() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.mergeCertificate#config - List x509CertificatesToMerge = new ArrayList<>(); - MergeCertificateOptions config = - new MergeCertificateOptions("certificateName", x509CertificatesToMerge) - .setEnabled(false); - KeyVaultCertificate mergedCertificate = certificateClient.mergeCertificate(config); - System.out.printf("Received Certificate with name %s and key id %s%n", - mergedCertificate.getProperties().getName(), mergedCertificate.getKeyId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.mergeCertificate#config - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.mergeCertificateWithResponse#config - List x509CertsToMerge = new ArrayList<>(); - MergeCertificateOptions mergeConfig = - new MergeCertificateOptions("certificateName", x509CertsToMerge) - .setEnabled(false); - Response mergedCertificateWithResponse = - certificateClient.mergeCertificateWithResponse(mergeConfig, new Context(key2, value2)); - System.out.printf("Received Certificate with name %s and key id %s%n", - mergedCertificateWithResponse.getValue().getProperties().getName(), - mergedCertificateWithResponse.getValue().getKeyId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.mergeCertificateWithResponse#config - } - - /** - * Method to insert code snippets for {@link CertificateClient#importCertificate(ImportCertificateOptions)} - */ - public void importCertificate() { - CertificateClient certificateClient = getCertificateClient(); - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.importCertificate#options - byte[] certificateToImport = new byte[100]; - ImportCertificateOptions config = - new ImportCertificateOptions("certificateName", certificateToImport).setEnabled(false); - KeyVaultCertificate importedCertificate = certificateClient.importCertificate(config); - System.out.printf("Received Certificate with name %s and key id %s%n", - importedCertificate.getProperties().getName(), importedCertificate.getKeyId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.importCertificate#options - - // BEGIN: com.azure.security.keyvault.certificates.CertificateClient.importCertificateWithResponse#options - byte[] certToImport = new byte[100]; - ImportCertificateOptions importCertificateOptions = - new ImportCertificateOptions("certificateName", certToImport).setEnabled(false); - Response importedCertificateWithResponse = - certificateClient.importCertificateWithResponse(importCertificateOptions, new Context(key2, value2)); - System.out.printf("Received Certificate with name %s and key id %s%n", - importedCertificateWithResponse.getValue().getProperties().getName(), - importedCertificateWithResponse.getValue().getKeyId()); - // END: com.azure.security.keyvault.certificates.CertificateClient.importCertificateWithResponse#options - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/HelloWorld.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/HelloWorld.java deleted file mode 100644 index 878f4de93af4..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/HelloWorld.java +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollResponse; -import com.azure.core.util.polling.SyncPoller; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.models.CertificateKeyCurveName; -import com.azure.security.keyvault.certificates.models.CertificateIssuer; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.DeletedCertificate; -import com.azure.security.keyvault.certificates.models.SubjectAlternativeNames; -import com.azure.security.keyvault.certificates.models.CertificateOperation; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; -import com.azure.security.keyvault.certificates.models.CertificateKeyType; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -/** - * Sample demonstrates how to set, get, update and delete a certificate. - */ -public class HelloWorld { - /** - * Authenticates with the key vault and shows how to set, get, update and delete a certificate in the key vault. - * - * @param args Unused. Arguments to the program. - * @throws IllegalArgumentException when invalid key vault endpoint is passed. - * @throws InterruptedException when the thread is interrupted in sleep mode. - */ - public static void main(String[] args) throws InterruptedException, IllegalArgumentException { - /* Instantiate a CertificateClient that will be used to call the service. Notice that the client is using - default Azure credentials. For more information on this and other types of credentials, see this document: - https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable. - - To get started, you'll need a URL to an Azure Key Vault. See the README - (https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md) - for links and instructions. */ - CertificateClient certificateClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); - - // Let's create a self-signed certificate valid for 1 year. If the certificate already exists in the key vault, - // then a new version of the certificate is created. - CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12") - .setSubjectAlternativeNames(new SubjectAlternativeNames().setEmails(Arrays.asList("wow@gmail.com"))) - .setKeyReusable(true) - .setKeyType(CertificateKeyType.EC) - .setKeyCurveName(CertificateKeyCurveName.P_256) - .setValidityInMonths(12); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - SyncPoller certificatePoller = - certificateClient.beginCreateCertificate("certificateName", policy, true, tags); - certificatePoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - - KeyVaultCertificate cert = certificatePoller.getFinalResult(); - - // Let's get the latest version of the certificate from the key vault. - KeyVaultCertificate certificate = certificateClient.getCertificate("certificateName"); - - System.out.printf("Certificate is returned with name %s and secret id %s \n", - certificate.getProperties().getName(), certificate.getSecretId()); - - // After some time, we need to disable the certificate temporarily, so we update the enabled status of the - // certificate. The update method can be used to update the enabled status of the certificate. - certificate.getProperties().setEnabled(false); - - KeyVaultCertificate updatedCertificate = certificateClient.updateCertificateProperties(certificate.getProperties()); - - System.out.printf("Certificate's updated enabled status is %s \n", updatedCertificate.getProperties().isEnabled()); - - // Let's create a certificate issuer. - CertificateIssuer issuer = new CertificateIssuer("myIssuer", "Test"); - CertificateIssuer myIssuer = certificateClient.createIssuer(issuer); - - System.out.printf("Issuer created with name %s and provider %s", myIssuer.getName(), myIssuer.getProvider()); - - // Let's fetch the issuer we just created from the key vault. - myIssuer = certificateClient.getIssuer("myIssuer"); - - System.out.printf("Issuer retrieved with name %s and provider %s", myIssuer.getName(), myIssuer.getProvider()); - - // Let's create a certificate signed by our issuer. - certificateClient.beginCreateCertificate("myCertificate", - new CertificatePolicy("myIssuer", "CN=SelfSignedJavaPkcs12"), true, tags) - .waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - - // Let's get the latest version of our certificate from the key vault. - KeyVaultCertificate myCert = certificateClient.getCertificate("myCertificate"); - - System.out.printf("Certificate is returned with name %s and secret id %s \n", myCert.getProperties().getName(), - myCert.getSecretId()); - - // The certificates and issuers are no longer needed, need to delete it from the key vault. - SyncPoller deletedCertificatePoller = - certificateClient.beginDeleteCertificate("certificateName"); - // Deleted certificate is accessible as soon as polling beings. - PollResponse pollResponse = deletedCertificatePoller.poll(); - - System.out.printf("Deleted certificate with name %s and recovery id %s", pollResponse.getValue().getName(), - pollResponse.getValue().getRecoveryId()); - - deletedCertificatePoller.waitForCompletion(); - - SyncPoller deletedCertPoller = - certificateClient.beginDeleteCertificate("myCertificate"); - // Deleted certificate is accessible as soon as polling beings. - PollResponse deletePollResponse = deletedCertPoller.poll(); - - System.out.printf("Deleted certificate with name %s and recovery id %s", deletePollResponse.getValue().getName(), - deletePollResponse.getValue().getRecoveryId()); - - deletedCertificatePoller.waitForCompletion(); - - CertificateIssuer deleteCertificateIssuer = certificateClient.deleteIssuer("myIssuer"); - - System.out.printf("Certificate issuer is permanently deleted with name %s and provider is %s \n", - deleteCertificateIssuer.getName(), deleteCertificateIssuer.getProvider()); - - // To ensure the certificate is deleted server-side. - Thread.sleep(30000); - - // If the key vault is soft-delete enabled, then deleted certificates need to be purged for permanent deletion. - certificateClient.purgeDeletedCertificate("certificateName"); - certificateClient.purgeDeletedCertificate("myCertificate"); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/HelloWorldAsync.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/HelloWorldAsync.java deleted file mode 100644 index a1b6c6ca1193..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/HelloWorldAsync.java +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.models.CertificateIssuer; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.SubjectAlternativeNames; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; -import com.azure.security.keyvault.certificates.models.CertificateKeyCurveName; -import com.azure.security.keyvault.certificates.models.CertificateKeyType; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -/** - * Sample demonstrates how to asynchronously set, get, update and delete a key. - */ -public class HelloWorldAsync { - /** - * Authenticates with the key vault and shows how to asynchronously set, get, update and delete a key in the key vault. - * - * @param args Unused. Arguments to the program. - * @throws IllegalArgumentException when invalid key vault endpoint is passed. - * @throws InterruptedException when the thread is interrupted in sleep mode. - */ - public static void main(String[] args) throws InterruptedException { - /* Instantiate a CertificateAsyncClient that will be used to call the service. Notice that the client is using - default Azure credentials. For more information on this and other types of credentials, see this document: - https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable. - - To get started, you'll need a URL to an Azure Key Vault. See the README - (https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md) - for links and instructions. */ - CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildAsyncClient(); - - // Let's create a self-signed certificate valid for 1 year. If the certificate already exists in the key vault, - // then a new version of the certificate is created. - CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12") - .setSubjectAlternativeNames(new SubjectAlternativeNames().setEmails(Arrays.asList("wow@gmail.com"))) - .setKeyReusable(true) - .setKeyType(CertificateKeyType.EC) - .setKeyCurveName(CertificateKeyCurveName.P_256); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - certificateAsyncClient.beginCreateCertificate("certificateName", policy, true, tags) - .subscribe(pollResponse -> { - System.out.println("---------------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }); - - Thread.sleep(22000); - - // Let's get the latest version of the certificate from the key vault. - certificateAsyncClient.getCertificate("certificateName") - .subscribe(certificateResponse -> - System.out.printf("Certificate is returned with name %s and secretId %s %n", - certificateResponse.getProperties().getName(), certificateResponse.getSecretId())); - - // After some time, we need to disable the certificate temporarily, so we update the enabled status of the - // certificate. The update method can be used to update the enabled status of the certificate. - certificateAsyncClient.getCertificate("certificateName") - .subscribe(certificateResponseValue -> { - KeyVaultCertificate certificate = certificateResponseValue; - // Update enabled status of the certificate. - certificate.getProperties().setEnabled(false); - certificateAsyncClient.updateCertificateProperties(certificate.getProperties()) - .subscribe(certificateResponse -> - System.out.printf("Certificate's enabled status %s %n", - certificateResponse.getProperties().isEnabled().toString())); - }); - - Thread.sleep(3000); - - // Let's create a certificate issuer. - certificateAsyncClient.createIssuer(new CertificateIssuer("myIssuer", "Test")) - .subscribe(issuer -> - System.out.printf("Issuer created with %s and %s", issuer.getName(), issuer.getProvider())); - - Thread.sleep(2000); - - // Let's fetch the issuer we just created from the key vault. - certificateAsyncClient.getIssuer("myIssuer") - .subscribe(issuer -> - System.out.printf("Issuer returned with %s and %s", issuer.getName(), issuer.getProvider())); - - Thread.sleep(2000); - - // Let's create a certificate signed by our issuer. - certificateAsyncClient.beginCreateCertificate("myCertificate", - new CertificatePolicy("myIssuer", "CN=IssuerSignedJavaPkcs12"), true, tags) - .subscribe(pollResponse -> { - System.out.println("---------------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }); - - Thread.sleep(22000); - - // Let's get the latest version of our certificate from the key vault. - certificateAsyncClient.getCertificate("myCertificate") - .subscribe(certificateResponse -> - System.out.printf("Certificate is returned with name %s and secretId %s %n", - certificateResponse.getProperties().getName(), certificateResponse.getSecretId())); - - Thread.sleep(2000); - - // The certificates and issuers are no longer needed, need to delete it from the key vault. - certificateAsyncClient.beginDeleteCertificate("certificateName") - .subscribe(pollResponse -> { - System.out.println("Delete Status: " + pollResponse.getStatus().toString()); - System.out.println("Delete Certificate Name: " + pollResponse.getValue().getName()); - System.out.println("Certificate Delete Date: " + pollResponse.getValue().getDeletedOn().toString()); - }); - - certificateAsyncClient.beginDeleteCertificate("myCertificate") - .subscribe(pollResponse -> { - System.out.println("Delete Status: " + pollResponse.getStatus().toString()); - System.out.println("Delete Certificate Name: " + pollResponse.getValue().getName()); - System.out.println("Certificate Delete Date: " + pollResponse.getValue().getDeletedOn().toString()); - }); - - certificateAsyncClient.deleteIssuerWithResponse("myIssuer") - .subscribe(deletedIssuerResponse -> - System.out.printf("Deleted issuer with name %s %n", deletedIssuerResponse.getValue().getName())); - - // To ensure the certificate is deleted server-side. - Thread.sleep(50000); - - // If the key vault is soft-delete enabled, then deleted certificates need to be purged for permanent deletion. - certificateAsyncClient.purgeDeletedCertificateWithResponse("certificateName") - .subscribe(purgeResponse -> - System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode())); - - certificateAsyncClient.purgeDeletedCertificateWithResponse("myCertificate") - .subscribe(purgeResponse -> - System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode())); - - Thread.sleep(4000); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ListOperations.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ListOperations.java deleted file mode 100644 index 1dae5806f5ae..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ListOperations.java +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.SyncPoller; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.models.CertificateContact; -import com.azure.security.keyvault.certificates.models.CertificateIssuer; -import com.azure.security.keyvault.certificates.models.CertificateOperation; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.CertificateProperties; -import com.azure.security.keyvault.certificates.models.IssuerProperties; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * Sample demonstrates how to perform list operation on certificates, certificate issuers and certificate contacts in the key vault. - */ -public class ListOperations { - /** - * Authenticates with the key vault and shows how to list certificates, certificate issuers and contacts in the key vault. - * - * @param args Unused. Arguments to the program. - * @throws IllegalArgumentException when invalid key vault endpoint is passed. - */ - public static void main(String[] args) throws IllegalArgumentException { - /* Instantiate a CertificateClient that will be used to call the service. Notice that the client is using - default Azure credentials. For more information on this and other types of credentials, see this document: - https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable. - - To get started, you'll need a URL to an Azure Key Vault. See the README - (https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md) - for links and instructions. */ - CertificateClient certificateClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); - - // Let's create a self-signed certificate valid for 1 year. If the certificate already exists in the key vault, - // then a new version of the certificate is created. - CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12"); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - SyncPoller certificatePoller = - certificateClient.beginCreateCertificate("certName", policy, true, tags); - certificatePoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - - KeyVaultCertificate cert = certificatePoller.getFinalResult(); - - // Let's create a certificate issuer. - CertificateIssuer issuer = new CertificateIssuer("myIssuer", "Test"); - CertificateIssuer myIssuer = certificateClient.createIssuer(issuer); - - System.out.printf("Issuer created with name %s and provider %s", myIssuer.getName(), myIssuer.getProvider()); - - // Let's create a certificate signed by our issuer. - certificateClient.beginCreateCertificate("myCertificate", - new CertificatePolicy("myIssuer", "CN=SignedJavaPkcs12"), true, tags) - .waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - - - // Let's list all the certificates in the key vault. - for (CertificateProperties certificate : certificateClient.listPropertiesOfCertificates()) { - KeyVaultCertificate certificateWithAllProperties = - certificateClient.getCertificateVersion(certificate.getName(), certificate.getVersion()); - - System.out.printf("Received certificate with name %s and secret id %s", - certificateWithAllProperties.getProperties().getName(), certificateWithAllProperties.getSecretId()); - } - - // Let's list all certificate versions of the certificate. - for (CertificateProperties certificate : certificateClient.listPropertiesOfCertificateVersions("myCertificate")) { - KeyVaultCertificate certificateWithAllProperties = - certificateClient.getCertificateVersion(certificate.getName(), certificate.getVersion()); - - System.out.printf("Received certificate with name %s and version %s", - certificateWithAllProperties.getProperties().getName(), - certificateWithAllProperties.getProperties().getVersion()); - } - - // Let's list all certificate issuers in the key vault. - for (IssuerProperties certIssuer : certificateClient.listPropertiesOfIssuers()) { - CertificateIssuer retrievedIssuer = certificateClient.getIssuer(certIssuer.getName()); - - System.out.printf("Received issuer with name %s and provider %s", retrievedIssuer.getName(), - retrievedIssuer.getProvider()); - } - - // Let's set certificate contacts on the key vault. - CertificateContact contactToAdd = new CertificateContact().setName("user").setEmail("useremail@example.com"); - for (CertificateContact contact : certificateClient.setContacts(Collections.singletonList(contactToAdd))) { - System.out.printf("Added contact with name %s and email %s to key vault", contact.getName(), - contact.getEmail()); - } - - // Let's list all certificate contacts in the key vault. - for (CertificateContact contact : certificateClient.listContacts()) { - System.out.printf("Retrieved contact with name %s and email %s from the key vault", contact.getName(), - contact.getEmail()); - } - - // Let's delete all certificate contacts in the key vault. - for (CertificateContact contact : certificateClient.deleteContacts()) { - System.out.printf("Deleted contact with name %s and email %s from key vault", contact.getName(), - contact.getEmail()); - } - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ListOperationsAsync.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ListOperationsAsync.java deleted file mode 100644 index b7302788f8da..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ListOperationsAsync.java +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.models.CertificateIssuer; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.SubjectAlternativeNames; -import com.azure.security.keyvault.certificates.models.CertificateKeyCurveName; -import com.azure.security.keyvault.certificates.models.CertificateContact; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * Sample demonstrates how to asynchronously list keys and versions of a given key in the key vault. - */ -public class ListOperationsAsync { - /** - * Authenticates with the key vault and shows how to asynchronously list keys and list versions of a specific key in the key vault. - * - * @param args Unused. Arguments to the program. - * @throws IllegalArgumentException when invalid key vault endpoint is passed. - * @throws InterruptedException when the thread is interrupted in sleep mode. - */ - public static void main(String[] args) throws InterruptedException { - /* Instantiate a CertificateAsyncClient that will be used to call the service. Notice that the client is using - default Azure credentials. For more information on this and other types of credentials, see this document: - https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable. - - To get started, you'll need a URL to an Azure Key Vault. See the README - (https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md) - for links and instructions. */ - CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildAsyncClient(); - - // Let's create a self-signed certificate valid for 1 year. If the certificate already exists in the key vault, - // then a new version of the certificate is created. - CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12") - .setSubjectAlternativeNames(new SubjectAlternativeNames().setEmails(Arrays.asList("wow@gmail.com"))) - .setKeyReusable(true) - .setKeyCurveName(CertificateKeyCurveName.P_256); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - certificateAsyncClient.beginCreateCertificate("myCertificate", policy, true, tags) - .subscribe(pollResponse -> { - System.out.println("---------------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }); - - Thread.sleep(22000); - - // Let's create a certificate issuer. - certificateAsyncClient.createIssuer(new CertificateIssuer("myIssuer", "Test")) - .subscribe(issuer -> - System.out.printf("Issuer created with %s and %s\n", issuer.getName(), issuer.getProvider())); - - Thread.sleep(2000); - - // Let's create a certificate signed by our issuer. - certificateAsyncClient.beginCreateCertificate("myCert", - new CertificatePolicy("myIssuer", "CN=IssuerSignedJavaPkcs12"), true, tags) - .subscribe(pollResponse -> { - System.out.println("---------------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }); - - Thread.sleep(22000); - - // Let's list all the certificates in the key vault. - certificateAsyncClient.listPropertiesOfCertificates() - .subscribe(certificateProperties -> - certificateAsyncClient.getCertificateVersion(certificateProperties.getName(), - certificateProperties.getVersion()) - .subscribe(certificateResponse -> - System.out.printf("Received certificate with name %s and key id %s \n", - certificateResponse.getProperties().getName(), certificateResponse.getKeyId()))); - - Thread.sleep(5000); - - // Let's list all certificate versions of the certificate. - certificateAsyncClient.listPropertiesOfCertificateVersions("myCertificate") - .subscribe(certificateProperties -> - certificateAsyncClient.getCertificateVersion(certificateProperties.getName(), - certificateProperties.getVersion()) - .subscribe(certificateResponse -> - System.out.printf("Received certificate with name %s and key id %s\n", - certificateResponse.getProperties().getName(), certificateResponse.getKeyId()))); - - Thread.sleep(5000); - - // Let's list all certificate issuers in the key vault. - certificateAsyncClient.listPropertiesOfIssuers() - .subscribe(issuerProperties -> - certificateAsyncClient.getIssuer(issuerProperties.getName()) - .subscribe(issuerResponse -> - System.out.printf("Received issuer with name %s and provider %s\n", issuerResponse.getName(), - issuerResponse.getProvider()))); - - Thread.sleep(5000); - - // Let's set certificate contacts on the Key vault. - CertificateContact contactToAdd = new CertificateContact().setName("user").setEmail("useremail@example.com"); - certificateAsyncClient.setContacts(Collections.singletonList(contactToAdd)).subscribe(contact -> - System.out.printf("Contact name %s and email %s\n", contact.getName(), contact.getEmail())); - - Thread.sleep(3000); - - // Let's list all certificate contacts in the key vault. - certificateAsyncClient.listContacts().subscribe(contact -> - System.out.printf("Contact name %s and email %s\n", contact.getName(), contact.getEmail())); - - Thread.sleep(3000); - - // Let's delete all certificate contacts in the key vault. - certificateAsyncClient.listContacts().subscribe(contact -> - System.out.printf("Deleted Contact name %s and email %s\n", contact.getName(), contact.getEmail())); - - Thread.sleep(2000); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ManagingDeletedCertificates.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ManagingDeletedCertificates.java deleted file mode 100644 index 7dda5442934c..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ManagingDeletedCertificates.java +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollResponse; -import com.azure.core.util.polling.SyncPoller; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.SubjectAlternativeNames; -import com.azure.security.keyvault.certificates.models.CertificateOperation; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy; -import com.azure.security.keyvault.certificates.models.DeletedCertificate; -import com.azure.security.keyvault.certificates.models.CertificateKeyCurveName; -import com.azure.security.keyvault.certificates.models.CertificateKeyType; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -/** - * Sample demonstrates how to list, recover and purge deleted certificates in a soft-delete enabled key vault. - */ -public class ManagingDeletedCertificates { - /** - * Authenticates with the key vault and shows how to list, recover and purge deleted certificates in a soft-delete enabled key vault. - * - * @param args Unused. Arguments to the program. - * @throws IllegalArgumentException when invalid key vault endpoint is passed. - * @throws InterruptedException when the thread is interrupted in sleep mode. - */ - public static void main(String[] args) throws IllegalArgumentException, InterruptedException { - /* NOTE: To manage deleted certificates, your key vault needs to have soft-delete enabled. Soft-delete allows - deleted certificates to be retained for a given retention period (90 days). During this period deleted - certificates can be recovered and if a certificates needs to be permanently deleted then it needs to be purged. - */ - - /* Instantiate a CertificateClient that will be used to call the service. Notice that the client is using - default Azure credentials. For more information on this and other types of credentials, see this document: - https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable. - - To get started, you'll need a URL to an Azure Key Vault. See the README - (https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md) - for links and instructions. */ - CertificateClient certificateClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); - - // Let's create a self-signed certificate valid for 1 year. If the certificate already exists in the key vault, - // then a new version of the certificate is created. - CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12") - .setSubjectAlternativeNames(new SubjectAlternativeNames().setEmails(Arrays.asList("wow@gmail.com"))) - .setKeyReusable(true) - .setKeyCurveName(CertificateKeyCurveName.P_256) - .setKeyType(CertificateKeyType.EC); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - SyncPoller certificatePoller = - certificateClient.beginCreateCertificate("certificateName", policy, true, tags); - certificatePoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - - KeyVaultCertificate cert = certificatePoller.getFinalResult(); - - // The certificate is no longer needed, need to delete it from the key vault. - SyncPoller deletedCertificatePoller = - certificateClient.beginDeleteCertificate("certificateName"); - // The deleted certificate is accessible as soon as polling beings. - PollResponse pollResponse = deletedCertificatePoller.poll(); - - System.out.printf("Deleted certificate with name %s and recovery id %s", pollResponse.getValue().getName(), - pollResponse.getValue().getRecoveryId()); - - deletedCertificatePoller.waitForCompletion(); - - // To ensure the certificate is deleted server-side. - Thread.sleep(30000); - - // We accidentally deleted the certificate. Let's recover it. - // A deleted certificate can only be recovered if the key vault is soft-delete enabled. - SyncPoller recoverCertPoller = certificateClient - .beginRecoverDeletedCertificate("certificateName"); - // A recovered certificate is accessible as soon as polling beings - PollResponse recoverPollResponse = recoverCertPoller.poll(); - - System.out.printf(" Recovered Deleted certificate with name %s and id %s", recoverPollResponse.getValue() - .getProperties().getName(), recoverPollResponse.getValue().getProperties().getId()); - recoverCertPoller.waitForCompletion(); - - // To ensure the certificate is recovered server-side. - Thread.sleep(30000); - - // The certificate is no longer needed, need to delete them from the key vault. - deletedCertificatePoller = certificateClient.beginDeleteCertificate("certificateName"); - // The deleted certificate is accessible as soon as polling beings. - PollResponse deletePollResponse = deletedCertificatePoller.poll(); - - System.out.printf("Deleted certificate with name %s and recovery id %s", deletePollResponse.getValue().getName(), - deletePollResponse.getValue().getRecoveryId()); - - deletedCertificatePoller.waitForCompletion(); - - // To ensure the certificate is deleted server-side. - Thread.sleep(30000); - - // You can list all the deleted and non-purged certificates, assuming the key vault is soft-delete enabled. - for (DeletedCertificate deletedCert : certificateClient.listDeletedCertificates()) { - System.out.printf("Deleted certificate's recovery Id %s", deletedCert.getRecoveryId()); - } - - // If the key vault is soft-delete enabled, then deleted certificates need to be purged for permanent deletion. - certificateClient.purgeDeletedCertificate("certificateName"); - - // To ensure the certificate is purged server-side. - Thread.sleep(15000); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ManagingDeletedCertificatesAsync.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ManagingDeletedCertificatesAsync.java deleted file mode 100644 index 8bd2c46adea1..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ManagingDeletedCertificatesAsync.java +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.SubjectAlternativeNames; -import com.azure.security.keyvault.certificates.models.CertificateKeyCurveName; -import com.azure.security.keyvault.certificates.models.CertificateKeyType; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -/** - * Sample demonstrates how to asynchronously list, recover and purge deleted certificates in a soft-delete enabled key vault. - */ -public class ManagingDeletedCertificatesAsync { - /** - * Authenticates with the key vault and shows how to asynchronously list, recover and purge deleted certificates in a soft-delete enabled key vault. - * - * @param args Unused. Arguments to the program. - * @throws IllegalArgumentException when invalid key vault endpoint is passed. - * @throws InterruptedException when the thread is interrupted in sleep mode. - */ - public static void main(String[] args) throws InterruptedException { - /* NOTE: To manage deleted certificates, your key vault needs to have soft-delete enabled. Soft-delete allows - deleted certificates to be retained for a given retention period (90 days). During this period deleted - certificates can be recovered and if a certificates needs to be permanently deleted then it needs to be purged. - */ - - /* Instantiate a CertificateAsyncClient that will be used to call the service. Notice that the client is using - default Azure credentials. For more information on this and other types of credentials, see this document: - https://docs.microsoft.com/java/api/overview/azure/identity-readme?view=azure-java-stable. - - To get started, you'll need a URL to an Azure Key Vault. See the README - (https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/keyvault/azure-security-keyvault-certificates/README.md) - for links and instructions. */ - CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildAsyncClient(); - - // Let's create a self-signed certificate valid for 1 year. If the certificate already exists in the key vault, - // then a new version of the certificate is created. - CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12") - .setSubjectAlternativeNames(new SubjectAlternativeNames().setEmails(Arrays.asList("wow@gmail.com"))) - .setKeyReusable(true) - .setKeyCurveName(CertificateKeyCurveName.P_256) - .setKeyType(CertificateKeyType.EC); - Map tags = new HashMap<>(); - tags.put("foo", "bar"); - - certificateAsyncClient.beginCreateCertificate("certificateName", policy, true, tags) - .subscribe(pollResponse -> { - System.out.println("---------------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }); - - Thread.sleep(22000); - - // The certificate is no longer needed, need to delete it from the key vault. - certificateAsyncClient.beginDeleteCertificate("certificateName") - .subscribe(pollResponse -> { - System.out.println("Delete Status: " + pollResponse.getStatus().toString()); - System.out.println("Delete Certificate Name: " + pollResponse.getValue().getName()); - System.out.println("Certificate Delete Date: " + pollResponse.getValue().getDeletedOn().toString()); - }); - - // To ensure the certificate is deleted server-side. - Thread.sleep(30000); - - // We accidentally deleted the certificate. Let's recover it. - // A deleted certificate can only be recovered if the key vault is soft-delete enabled. - certificateAsyncClient.beginRecoverDeletedCertificate("certificateName") - .subscribe(pollResponse -> { - System.out.println("Recovery Status: " + pollResponse.getStatus().toString()); - System.out.println("Recover Certificate Name: " + pollResponse.getValue().getName()); - System.out.println("Recover Certificate Id: " + pollResponse.getValue().getId()); - }); - - // To ensure the certificate is recovered server-side. - Thread.sleep(10000); - - // The certificate is no longer needed, need to delete it from the key vault. - certificateAsyncClient.beginDeleteCertificate("certificateName") - .subscribe(pollResponse -> { - System.out.println("Delete Status: " + pollResponse.getStatus().toString()); - System.out.println("Delete Certificate Name: " + pollResponse.getValue().getName()); - System.out.println("Certificate Delete Date: " + pollResponse.getValue().getDeletedOn().toString()); - }); - - // To ensure the certificate is deleted server-side. - Thread.sleep(30000); - - // You can list all the deleted and non-purged certificates, assuming key vault is soft-delete enabled. - certificateAsyncClient.listDeletedCertificates() - .subscribe(deletedCertificateResponse -> System.out.printf("Deleted Certificate's Recovery Id %s %n", - deletedCertificateResponse.getRecoveryId())); - - Thread.sleep(15000); - - // If the keyvault is soft-delete enabled, then deleted certificates need to be purged for permanent deletion. - certificateAsyncClient.purgeDeletedCertificateWithResponse("certificateName") - .subscribe(purgeResponse -> - System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode())); - - // To ensure the certificate is purged server-side. - Thread.sleep(15000); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ReadmeSamples.java b/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ReadmeSamples.java deleted file mode 100644 index bbf24b92e143..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/samples/java/com/azure/security/keyvault/certificates/ReadmeSamples.java +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollResponse; -import com.azure.core.util.polling.SyncPoller; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.models.CertificateOperation; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.CertificateProperties; -import com.azure.security.keyvault.certificates.models.DeletedCertificate; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy; - -@SuppressWarnings("unused") -public class ReadmeSamples { - private final CertificateClient certificateClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); - - private final CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildAsyncClient(); - - public void createCertificateClient() { - // BEGIN: readme-sample-createCertificateClient - CertificateClient certificateClient = new CertificateClientBuilder() - .vaultUrl("") - .credential(new DefaultAzureCredentialBuilder().build()) - .buildClient(); - // END: readme-sample-createCertificateClient - } - - public void createCertificate() { - // BEGIN: readme-sample-createCertificate - SyncPoller certificatePoller = - certificateClient.beginCreateCertificate("certificateName", CertificatePolicy.getDefault()); - certificatePoller.waitUntil(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED); - KeyVaultCertificate certificate = certificatePoller.getFinalResult(); - System.out.printf("Certificate created with name \"%s\"%n", certificate.getName()); - // END: readme-sample-createCertificate - } - - public void retrieveCertificate() { - // BEGIN: readme-sample-retrieveCertificate - KeyVaultCertificateWithPolicy certificate = certificateClient.getCertificate(""); - System.out.printf("Received certificate with name \"%s\", version %s and secret id %s%n", - certificate.getProperties().getName(), certificate.getProperties().getVersion(), certificate.getSecretId()); - // END: readme-sample-retrieveCertificate - } - - public void updateCertificate() { - // BEGIN: readme-sample-updateCertificate - // Get the certificate to update. - KeyVaultCertificate certificate = certificateClient.getCertificate(""); - // Update certificate enabled status. - certificate.getProperties().setEnabled(false); - KeyVaultCertificate updatedCertificate = certificateClient.updateCertificateProperties(certificate.getProperties()); - System.out.printf("Updated certificate with name \"%s\" and enabled status \"%s\"%n", - updatedCertificate.getProperties().getName(), updatedCertificate.getProperties().isEnabled()); - // END: readme-sample-updateCertificate - } - - public void deleteCertificate() { - // BEGIN: readme-sample-deleteCertificate - SyncPoller deleteCertificatePoller = - certificateClient.beginDeleteCertificate(""); - - // Deleted certificate is accessible as soon as polling beings. - PollResponse pollResponse = deleteCertificatePoller.poll(); - - // Deletion date only works for a SoftDelete-enabled Key Vault. - System.out.printf("Deleted certificate with name \"%s\" and recovery id %s", pollResponse.getValue().getName(), - pollResponse.getValue().getRecoveryId()); - - // Certificate is being deleted on server. - deleteCertificatePoller.waitForCompletion(); - // END: readme-sample-deleteCertificate - } - - public void listCertificates() { - // BEGIN: readme-sample-listCertificates - // List operations don't return the certificates with their full information. So, for each returned certificate we call - // getCertificate to get the certificate with all its properties excluding the policy. - for (CertificateProperties certificateProperties : certificateClient.listPropertiesOfCertificates()) { - KeyVaultCertificate certificateWithAllProperties = - certificateClient.getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion()); - System.out.printf("Received certificate with name \"%s\" and secret id %s", - certificateWithAllProperties.getProperties().getName(), certificateWithAllProperties.getSecretId()); - } - // END: readme-sample-listCertificates - } - - public void createCertificateAsync() { - // BEGIN: readme-sample-createCertificateAsync - // Creates a certificate using the default policy and polls on its progress. - certificateAsyncClient.beginCreateCertificate("", CertificatePolicy.getDefault()) - .subscribe(pollResponse -> { - System.out.println("---------------------------------------------------------------------------------"); - System.out.println(pollResponse.getStatus()); - System.out.println(pollResponse.getValue().getStatus()); - System.out.println(pollResponse.getValue().getStatusDetails()); - }); - // END: readme-sample-createCertificateAsync - } - - public void retrieveCertificateAsync() { - // BEGIN: readme-sample-retrieveCertificateAsync - certificateAsyncClient.getCertificate("") - .subscribe(certificateResponse -> - System.out.printf("Certificate was returned with name \"%s\" and secretId %s%n", - certificateResponse.getProperties().getName(), certificateResponse.getSecretId())); - // END: readme-sample-retrieveCertificateAsync - } - - public void updateCertificateAsync() { - // BEGIN: readme-sample-updateCertificateAsync - certificateAsyncClient.getCertificate("") - .flatMap(certificate -> { - // Update enabled status of the certificate. - certificate.getProperties().setEnabled(false); - return certificateAsyncClient.updateCertificateProperties(certificate.getProperties()); - }).subscribe(certificateResponse -> System.out.printf("Certificate's enabled status: %s%n", - certificateResponse.getProperties().isEnabled())); - // END: readme-sample-updateCertificateAsync - } - - public void deleteCertificateAsync() { - // BEGIN: readme-sample-deleteCertificateAsync - certificateAsyncClient.beginDeleteCertificate("") - .subscribe(pollResponse -> { - System.out.printf("Deletion status: %s%n", pollResponse.getStatus()); - System.out.printf("Deleted certificate name: %s%n", pollResponse.getValue().getName()); - System.out.printf("Certificate deletion date: %s%n", pollResponse.getValue().getDeletedOn()); - }); - // END: readme-sample-deleteCertificateAsync - } - - public void listCertificateAsync() { - // BEGIN: readme-sample-listCertificateAsync - // The List Certificates operation returns certificates without their full properties, so for each certificate returned - // we call `getCertificate` to get all its attributes excluding the policy. - certificateAsyncClient.listPropertiesOfCertificates() - .flatMap(certificateProperties -> certificateAsyncClient - .getCertificateVersion(certificateProperties.getName(), certificateProperties.getVersion())) - .subscribe(certificateResponse -> - System.out.printf("Received certificate with name \"%s\" and key id %s", certificateResponse.getName(), - certificateResponse.getKeyId())); - // END: readme-sample-listCertificateAsync - } - - public void troubleshooting() { - // BEGIN: readme-sample-troubleshooting - try { - certificateClient.getCertificate(""); - } catch (ResourceNotFoundException e) { - System.out.println(e.getMessage()); - } - // END: readme-sample-troubleshooting - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateAsyncClientTest.java b/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateAsyncClientTest.java deleted file mode 100644 index 73c3073c8960..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateAsyncClientTest.java +++ /dev/null @@ -1,1005 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.HttpClient; -import com.azure.core.test.http.AssertingHttpClientBuilder; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.polling.AsyncPollResponse; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollerFlux; -import com.azure.security.keyvault.certificates.implementation.KeyVaultCredentialPolicy; -import com.azure.security.keyvault.certificates.implementation.models.KeyVaultErrorException; -import com.azure.security.keyvault.certificates.models.CertificateContact; -import com.azure.security.keyvault.certificates.models.CertificateContentType; -import com.azure.security.keyvault.certificates.models.CertificateIssuer; -import com.azure.security.keyvault.certificates.models.CertificateOperation; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.DeletedCertificate; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy; -import com.azure.security.keyvault.certificates.models.MergeCertificateOptions; -import org.bouncycastle.asn1.x500.X500Name; -import org.bouncycastle.asn1.x509.AlgorithmIdentifier; -import org.bouncycastle.asn1.x509.Certificate; -import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; -import org.bouncycastle.cert.X509v3CertificateBuilder; -import org.bouncycastle.crypto.params.AsymmetricKeyParameter; -import org.bouncycastle.crypto.util.PrivateKeyFactory; -import org.bouncycastle.operator.ContentSigner; -import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder; -import org.bouncycastle.operator.DefaultSignatureAlgorithmIdentifierFinder; -import org.bouncycastle.operator.OperatorCreationException; -import org.bouncycastle.operator.bc.BcRSAContentSignerBuilder; -import org.bouncycastle.pkcs.PKCS10CertificationRequest; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.condition.DisabledForJreRange; -import org.junit.jupiter.api.condition.JRE; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; -import reactor.util.function.Tuples; - -import java.io.IOException; -import java.math.BigInteger; -import java.net.HttpURLConnection; -import java.security.GeneralSecurityException; -import java.security.PrivateKey; -import java.security.cert.X509Certificate; -import java.time.Duration; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - -public class CertificateAsyncClientTest extends CertificateClientTestBase { - private CertificateAsyncClient certificateAsyncClient; - - @Override - protected void beforeTest() { - beforeTestSetup(); - } - - private void createCertificateAsyncClient(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion, null); - } - - private void createCertificateAsyncClient(HttpClient httpClient, CertificateServiceVersion serviceVersion, - String testTenantId) { - certificateAsyncClient = getCertificateClientBuilder( - buildAsyncAssertingClient( - interceptorManager.isPlaybackMode() ? interceptorManager.getPlaybackClient() : httpClient), - testTenantId, getEndpoint(), serviceVersion).buildAsyncClient(); - } - - private HttpClient buildAsyncAssertingClient(HttpClient httpClient) { - return new AssertingHttpClientBuilder(httpClient).assertAsync().build(); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - createCertificateRunner((certificatePolicy) -> { - String certName = testResourceNamer.randomName("testCert", 25); - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certName, certificatePolicy)); - - StepVerifier.create(certPoller.last().flatMap(AsyncPollResponse::getFinalResult)).assertNext(expected -> { - assertEquals(certName, expected.getName()); - assertNotNull(expected.getProperties().getCreatedOn()); - }).verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createCertificateWithMultipleTenants(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion, testResourceNamer.randomUuid()); - - createCertificateRunner((certificatePolicy) -> { - String certName = testResourceNamer.randomName("testCert", 20); - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certName, certificatePolicy)); - - StepVerifier.create(certPoller.last().flatMap(AsyncPollResponse::getFinalResult)).assertNext(expected -> { - assertEquals(certName, expected.getName()); - assertNotNull(expected.getProperties().getCreatedOn()); - }).verifyComplete(); - }); - - KeyVaultCredentialPolicy.clearCache(); // Ensure we don't have anything cached and try again. - - createCertificateRunner((certificatePolicy) -> { - String certName = testResourceNamer.randomName("testCert", 20); - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certName, certificatePolicy)); - - StepVerifier.create(certPoller.last().flatMap(AsyncPollResponse::getFinalResult)).assertNext(expected -> { - assertEquals(certName, expected.getName()); - assertNotNull(expected.getProperties().getCreatedOn()); - }).verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createCertificateEmptyName(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.beginCreateCertificate("", CertificatePolicy.getDefault())) - .verifyErrorSatisfies( - e -> assertResponseException(e, KeyVaultErrorException.class, HttpURLConnection.HTTP_BAD_METHOD)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createCertificateNullPolicy(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier - .create(certificateAsyncClient.beginCreateCertificate(testResourceNamer.randomName("tempCert", 20), null)) - .verifyError(NullPointerException.class); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createCertificateNull(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.beginCreateCertificate(null, null)) - .verifyError(NullPointerException.class); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void updateCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - updateCertificateRunner((originalTags, updatedTags) -> { - String certName = testResourceNamer.randomName("testCert", 20); - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval(certificateAsyncClient.beginCreateCertificate(certName, - CertificatePolicy.getDefault(), true, originalTags)); - - StepVerifier - .create(certPoller.last() - .flatMap(AsyncPollResponse::getFinalResult) - .flatMap(cert -> certificateAsyncClient - .updateCertificateProperties(cert.getProperties().setTags(updatedTags)))) - .assertNext(cert -> validateMapResponse(updatedTags, cert.getProperties().getTags())) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void updateDisabledCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - updateDisabledCertificateRunner((originalTags, updatedTags) -> { - String certName = testResourceNamer.randomName("testCert", 20); - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval(certificateAsyncClient.beginCreateCertificate(certName, - CertificatePolicy.getDefault(), false, originalTags)); - - StepVerifier - .create( - certPoller.last() - .flatMap(AsyncPollResponse::getFinalResult) - .flatMap(cert -> certificateAsyncClient - .updateCertificateProperties(cert.getProperties().setTags(updatedTags)))) - .assertNext(cert -> { - validateMapResponse(updatedTags, cert.getProperties().getTags()); - assertFalse(cert.getProperties().isEnabled()); - }) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - getCertificateRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certificateName, initialPolicy)); - - StepVerifier - .create(certPoller.last() - .flatMap(AsyncPollResponse::getFinalResult) - .flatMap(expectedCert -> certificateAsyncClient.getCertificate(certificateName) - .map(returnedCert -> Tuples.of(expectedCert, returnedCert)))) - .assertNext(certTuple -> assertPolicy(certTuple.getT1().getPolicy(), certTuple.getT2().getPolicy())) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificateSpecificVersion(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - getCertificateSpecificVersionRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certificateName, initialPolicy)); - - StepVerifier - .create(certPoller.last() - .flatMap(AsyncPollResponse::getFinalResult) - .flatMap(expectedCert -> certificateAsyncClient - .getCertificateVersion(certificateName, expectedCert.getProperties().getVersion()) - .map(returnedCert -> Tuples.of(expectedCert, returnedCert)))) - .assertNext(certTuple -> assertCertificate(certTuple.getT1(), certTuple.getT2())) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.getCertificate("non-existing")) - .verifyErrorSatisfies( - e -> assertResponseException(e, ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void deleteCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - deleteCertificateRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certificateName, initialPolicy)); - - StepVerifier.create(certPoller.last() - .flatMap(AsyncPollResponse::getFinalResult) - .flatMap(ignored -> setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginDeleteCertificate(certificateName)).last() - .map(AsyncPollResponse::getValue))) - .assertNext(expectedCert -> { - assertNotNull(expectedCert.getDeletedOn()); - assertNotNull(expectedCert.getRecoveryId()); - assertNotNull(expectedCert.getScheduledPurgeDate()); - assertEquals(certificateName, expectedCert.getName()); - }) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void deleteCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.beginDeleteCertificate("non-existing")) - .verifyErrorSatisfies( - e -> assertResponseException(e, ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getDeletedCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - getDeletedCertificateRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certificateName, initialPolicy)); - - StepVerifier.create(certPoller.last() - .flatMap(AsyncPollResponse::getFinalResult) - .flatMap(ignored -> setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginDeleteCertificate(certificateName)).last() - .map(AsyncPollResponse::getValue))) - .assertNext(deletedCertificate -> { - assertNotNull(deletedCertificate.getDeletedOn()); - assertNotNull(deletedCertificate.getRecoveryId()); - assertNotNull(deletedCertificate.getScheduledPurgeDate()); - assertEquals(certificateName, deletedCertificate.getName()); - }) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getDeletedCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.getDeletedCertificate("non-existing")) - .verifyErrorSatisfies( - e -> assertResponseException(e, ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void recoverDeletedCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - recoverDeletedKeyRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certificateName, initialPolicy)); - - AtomicReference createdCertificate = new AtomicReference<>(); - - StepVerifier.create( - certPoller.last().flatMap(AsyncPollResponse::getFinalResult).flatMap(keyVaultCertificateWithPolicy -> { - createdCertificate.set(keyVaultCertificateWithPolicy); - return setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginDeleteCertificate(certificateName)).last() - .map(AsyncPollResponse::getValue); - }) - .flatMap(ignored -> setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginRecoverDeletedCertificate(certificateName)).last() - .map(AsyncPollResponse::getValue))) - .assertNext(recoveredCert -> { - assertEquals(certificateName, recoveredCert.getName()); - assertCertificate(createdCertificate.get(), recoveredCert); - }) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void recoverDeletedCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.beginRecoverDeletedCertificate("non-existing")) - .verifyErrorSatisfies( - e -> assertResponseException(e, ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void backupCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - backupCertificateRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certificateName, initialPolicy)); - - StepVerifier - .create(certPoller.last() - .flatMap(AsyncPollResponse::getFinalResult) - .flatMap(ignored -> certificateAsyncClient.backupCertificate(certificateName))) - .assertNext(backupBytes -> { - assertNotNull(backupBytes); - assertTrue(backupBytes.length > 0); - }) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void backupCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.backupCertificate("non-existing")) - .verifyErrorSatisfies( - e -> assertResponseException(e, ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void restoreCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - restoreCertificateRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certificateName, initialPolicy)); - - AtomicReference createdCertificate = new AtomicReference<>(); - AtomicReference backup = new AtomicReference<>(); - - StepVerifier.create( - certPoller.last().flatMap(AsyncPollResponse::getFinalResult).flatMap(keyVaultCertificateWithPolicy -> { - createdCertificate.set(keyVaultCertificateWithPolicy); - return certificateAsyncClient.backupCertificate(certificateName).flatMap(backupBytes -> { - backup.set(CoreUtils.clone(backupBytes)); - return Mono.just(backupBytes); - }); - })).assertNext(backupBytes -> { - assertNotNull(backupBytes); - assertTrue(backupBytes.length > 0); - }).verifyComplete(); - - StepVerifier.create( - setPlaybackPollerFluxPollInterval(certificateAsyncClient.beginDeleteCertificate(certificateName)).last() - .then(Mono.defer(() -> certificateAsyncClient.purgeDeletedCertificate(certificateName)))) - .verifyComplete(); - - sleepIfRunningAgainstService(40000); - - StepVerifier.create(certificateAsyncClient.restoreCertificateBackup(CoreUtils.clone(backup.get()))) - .assertNext(restoredCertificate -> { - assertEquals(certificateName, restoredCertificate.getName()); - assertPolicy(restoredCertificate.getPolicy(), createdCertificate.get().getPolicy()); - }) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificateOperation(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - getCertificateOperationRunner((certificateName) -> { - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certificateName, setupPolicy())); - - AtomicReference expectedCert = new AtomicReference<>(); - - StepVerifier.create( - certPoller.last().flatMap(AsyncPollResponse::getFinalResult).flatMap(keyVaultCertificateWithPolicy -> { - expectedCert.set(keyVaultCertificateWithPolicy); - return setPlaybackPollerFluxPollInterval( - certificateAsyncClient.getCertificateOperation(certificateName)).last() - .flatMap(AsyncPollResponse::getFinalResult); - })).assertNext(retrievedCert -> { - assertCertificate(expectedCert.get(), retrievedCert); - assertPolicy(expectedCert.get().getPolicy(), retrievedCert.getPolicy()); - }).verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void cancelCertificateOperation(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - cancelCertificateOperationRunner((certName) -> { - PollerFlux certPoller - = certificateAsyncClient.beginCreateCertificate(certName, CertificatePolicy.getDefault()) - .setPollInterval(Duration.ofMillis(250)); - - StepVerifier - .create(certPoller - .takeUntil( - asyncPollResponse -> asyncPollResponse.getStatus() == LongRunningOperationStatus.IN_PROGRESS) - .flatMap(AsyncPollResponse::cancelOperation)) - .assertNext(certificateOperation -> assertTrue(certificateOperation.getCancellationRequested())) - .verifyComplete(); - - StepVerifier.create(certPoller - .takeUntil(asyncPollResponse -> "cancelled".equalsIgnoreCase(asyncPollResponse.getStatus().toString())) - .map(asyncPollResponse -> asyncPollResponse.getStatus().toString()) - .zipWith(certPoller.last().flatMap(AsyncPollResponse::getFinalResult))).assertNext(tuple -> { - if ("cancelled".equalsIgnoreCase(tuple.getT1())) { - assertFalse(tuple.getT2().getPolicy().isEnabled()); - } - // Else, the operation did not reach the expected status, either because it was completed before it - // could be canceled or there was a service timing issue when attempting to cancel the operation. - }).verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void deleteCertificateOperation(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - deleteCertificateOperationRunner((certificateName) -> { - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certificateName, CertificatePolicy.getDefault())); - - StepVerifier - .create(certPoller.last() - .flatMap(AsyncPollResponse::getFinalResult) - .flatMap(ignored -> certificateAsyncClient.deleteCertificateOperation(certificateName))) - .assertNext(certificateOperation -> assertEquals("completed", certificateOperation.getStatus())) - .verifyComplete(); - - StepVerifier.create(certificateAsyncClient.deleteCertificateOperation(certificateName)) - .verifyErrorSatisfies( - e -> assertResponseException(e, ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND)); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificatePolicy(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - getCertificatePolicyRunner((certificateName) -> { - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certificateName, setupPolicy())); - - StepVerifier.create(certPoller.last().flatMap(AsyncPollResponse::getFinalResult)) - .assertNext(certificate -> assertPolicy(setupPolicy(), certificate.getPolicy())) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void updateCertificatePolicy(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - updateCertificatePolicyRunner((certificateName) -> { - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certificateName, setupPolicy())); - AtomicReference createdCert = new AtomicReference<>(); - - StepVerifier.create( - certPoller.last().flatMap(AsyncPollResponse::getFinalResult).flatMap(keyVaultCertificateWithPolicy -> { - keyVaultCertificateWithPolicy.getPolicy().setExportable(false); - createdCert.set(keyVaultCertificateWithPolicy); - return certificateAsyncClient.updateCertificatePolicy(certificateName, - keyVaultCertificateWithPolicy.getPolicy()); - })) - .assertNext(certificatePolicy -> assertPolicy(createdCert.get().getPolicy(), certificatePolicy)) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void restoreCertificateFromMalformedBackup(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - byte[] keyBackupBytes = "non-existing".getBytes(); - - StepVerifier.create(certificateAsyncClient.restoreCertificateBackup(keyBackupBytes)) - .verifyErrorSatisfies( - e -> assertResponseException(e, ResourceModifiedException.class, HttpURLConnection.HTTP_BAD_REQUEST)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void listCertificates(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - listCertificatesRunner((certificatesToList) -> { - HashSet certificates = new HashSet<>(certificatesToList); - - for (String certName : certificates) { - StepVerifier - .create(setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certName, CertificatePolicy.getDefault())).last()) - .assertNext(response -> assertNotNull(response.getValue())) - .verifyComplete(); - } - StepVerifier.create(certificateAsyncClient.listPropertiesOfCertificates().map(certificate -> { - certificates.remove(certificate.getName()); - return Mono.empty(); - }).last()).assertNext(ignore -> assertEquals(0, certificates.size())).verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void listPropertiesOfCertificates(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - listPropertiesOfCertificatesRunner((certificatesToList) -> { - HashSet certificates = new HashSet<>(certificatesToList); - - for (String certName : certificates) { - StepVerifier - .create(setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certName, CertificatePolicy.getDefault())).last()) - .assertNext(response -> assertNotNull(response.getValue())) - .verifyComplete(); - } - - StepVerifier.create(certificateAsyncClient.listPropertiesOfCertificates(false).map(certificate -> { - certificates.remove(certificate.getName()); - return Mono.empty(); - }).last()).assertNext(ignore -> assertEquals(0, certificates.size())).verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createIssuer(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - createIssuerRunner((issuer) -> StepVerifier.create(certificateAsyncClient.createIssuer(issuer)) - .assertNext(createdIssuer -> assertIssuerCreatedCorrectly(issuer, createdIssuer)) - .verifyComplete()); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createIssuerEmptyName(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.createIssuer(new CertificateIssuer("", ""))) - .verifyErrorSatisfies( - e -> assertResponseException(e, KeyVaultErrorException.class, HttpURLConnection.HTTP_BAD_METHOD)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createIssuerNullProvider(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.createIssuer(new CertificateIssuer("", null))) - .verifyErrorSatisfies( - e -> assertResponseException(e, KeyVaultErrorException.class, HttpURLConnection.HTTP_BAD_METHOD)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createIssuerNull(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.createIssuer(null)).verifyError(NullPointerException.class); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificateIssuer(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - getCertificateIssuerRunner((issuer) -> { - AtomicReference certificateIssuer = new AtomicReference<>(); - StepVerifier.create(certificateAsyncClient.createIssuer(issuer).flatMap(createdIssuer -> { - certificateIssuer.set(createdIssuer); - return certificateAsyncClient.getIssuer(issuer.getName()); - })) - .assertNext(retrievedIssuer -> assertIssuerCreatedCorrectly(certificateIssuer.get(), retrievedIssuer)) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificateIssuerNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.backupCertificate("non-existing")) - .verifyErrorSatisfies( - e -> assertResponseException(e, ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void deleteCertificateIssuer(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - deleteCertificateIssuerRunner((issuer) -> { - AtomicReference createdIssuer = new AtomicReference<>(); - StepVerifier.create(certificateAsyncClient.createIssuer(issuer).flatMap(certificateIssuer -> { - createdIssuer.set(certificateIssuer); - return certificateAsyncClient.deleteIssuer(issuer.getName()); - })) - .assertNext(deletedIssuer -> assertIssuerCreatedCorrectly(createdIssuer.get(), deletedIssuer)) - .verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void deleteCertificateIssuerNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.backupCertificate("non-existing")) - .verifyErrorSatisfies( - e -> assertResponseException(e, ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void listCertificateIssuers(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - listCertificateIssuersRunner((certificateIssuers) -> { - HashMap certificateIssuersToList = new HashMap<>(certificateIssuers); - - for (CertificateIssuer issuer : certificateIssuers.values()) { - StepVerifier.create(certificateAsyncClient.createIssuer(issuer)) - .assertNext(certificateIssuer -> assertIssuerCreatedCorrectly(issuer, certificateIssuer)) - .verifyComplete(); - } - - StepVerifier.create(certificateAsyncClient.listPropertiesOfIssuers() - .doOnNext(issuerProperties -> certificateIssuersToList.remove(issuerProperties.getName())) - .last()).assertNext(ignore -> assertEquals(0, certificateIssuersToList.size())).verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void updateIssuer(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - updateIssuerRunner((issuerToCreate, issuerToUpdate) -> StepVerifier - .create(certificateAsyncClient.createIssuer(issuerToCreate) - .flatMap(createdIssuer -> certificateAsyncClient.updateIssuer(issuerToUpdate))) - .assertNext(updatedIssuer -> assertIssuerUpdatedCorrectly(issuerToCreate, updatedIssuer)) - .verifyComplete()); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - @SuppressWarnings("ArraysAsListWithZeroOrOneArgument") - public void setContacts(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - List contacts = Arrays.asList(setupContact()); - - StepVerifier.create(certificateAsyncClient.setContacts(contacts)) - .assertNext(contact -> validateContact(setupContact(), contact)) - .verifyComplete(); - - StepVerifier.create(certificateAsyncClient.deleteContacts().then(Mono.just("complete"))) - .assertNext(input -> assertEquals("complete", input)) - .verifyComplete(); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - @SuppressWarnings("ArraysAsListWithZeroOrOneArgument") - public void listContacts(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - List contacts = Arrays.asList(setupContact()); - - StepVerifier.create(certificateAsyncClient.setContacts(contacts)) - .assertNext(contact -> validateContact(setupContact(), contact)) - .verifyComplete(); - - sleepIfRunningAgainstService(6000); - - StepVerifier.create(certificateAsyncClient.listContacts()) - .assertNext(contact -> validateContact(setupContact(), contact)) - .verifyComplete(); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - @SuppressWarnings("ArraysAsListWithZeroOrOneArgument") - public void deleteContacts(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - List contacts = Arrays.asList(setupContact()); - - StepVerifier.create(certificateAsyncClient.setContacts(contacts)) - .assertNext(contact -> validateContact(setupContact(), contact)) - .verifyComplete(); - - StepVerifier.create(certificateAsyncClient.deleteContacts()) - .assertNext(contact -> validateContact(setupContact(), contact)) - .verifyComplete(); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificateOperationNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.getCertificateOperation("non-existing")) - .verifyErrorSatisfies( - e -> assertResponseException(e, ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificatePolicyNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier.create(certificateAsyncClient.getCertificatePolicy("non-existing")) - .verifyErrorSatisfies( - e -> assertResponseException(e, ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void listCertificateVersions(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - String certName = testResourceNamer.randomName("testListCertVersion", 25); - int versionsToCreate = 5; - - for (int i = 0; i < versionsToCreate; i++) { - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certName, CertificatePolicy.getDefault())); - - StepVerifier.create(certPoller.last().flatMap(AsyncPollResponse::getFinalResult)) - .assertNext(Assertions::assertNotNull) - .verifyComplete(); - - } - - AtomicInteger createdVersions = new AtomicInteger(); - - StepVerifier - .create(certificateAsyncClient.listPropertiesOfCertificateVersions(certName).map(certificateProperties -> { - createdVersions.getAndIncrement(); - return Mono.just("complete"); - }).last()) - .assertNext(ignored -> assertEquals(versionsToCreate, createdVersions.get())) - .verifyComplete(); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void listDeletedCertificates(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - listDeletedCertificatesRunner((certificates) -> { - HashSet certificatesToDelete = new HashSet<>(certificates); - - for (String certName : certificatesToDelete) { - PollerFlux certPoller - = setPlaybackPollerFluxPollInterval( - certificateAsyncClient.beginCreateCertificate(certName, CertificatePolicy.getDefault())); - - StepVerifier.create(certPoller.last()).assertNext(Assertions::assertNotNull).verifyComplete(); - } - - for (String certName : certificates) { - PollerFlux poller - = setPlaybackPollerFluxPollInterval(certificateAsyncClient.beginDeleteCertificate(certName)); - - StepVerifier.create(poller.last()) - .assertNext(asyncPollResponse -> assertNotNull(asyncPollResponse.getValue())) - .verifyComplete(); - } - - sleepIfRunningAgainstService(30000); - - StepVerifier.create(certificateAsyncClient.listDeletedCertificates() - .doOnNext(deletedCertificate -> certificatesToDelete.remove(deletedCertificate.getName())) - .last()).assertNext(ignored -> assertEquals(0, certificatesToDelete.size())).verifyComplete(); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void importCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - importCertificateRunner((importCertificateOptions) -> StepVerifier - .create(certificateAsyncClient.importCertificate(importCertificateOptions)) - .assertNext(importedCertificate -> { - assertTrue("73b4319cdf38e0797084535d9c02fd04d4b2b2e6" - .equalsIgnoreCase(importedCertificate.getProperties().getX509ThumbprintAsString())); - assertEquals(importCertificateOptions.isEnabled(), importedCertificate.getProperties().isEnabled()); - - // Load the CER part into X509Certificate object - X509Certificate x509Certificate - = assertDoesNotThrow(() -> loadCerToX509Certificate(importedCertificate.getCer())); - - assertTrue(x509Certificate.getSubjectX500Principal() - .getName() - .contains("CN=Test,OU=Test,O=Contoso,L=Redmond,ST=WA,C=US")); - assertTrue(x509Certificate.getIssuerX500Principal() - .getName() - .contains("CN=Test,OU=Test,O=Contoso,L=Redmond,ST=WA,C=US")); - }) - .verifyComplete()); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - @DisabledForJreRange(min = JRE.JAVA_17) // Access to sun.security.* classes used here is not possible on Java 17+. - public void mergeCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - String certificateName = testResourceNamer.randomName("testCert", 25); - String issuer = "Unknown"; - String subject = "CN=MyCert"; - - StepVerifier.create(setPlaybackPollerFluxPollInterval(certificateAsyncClient.beginCreateCertificate( - certificateName, new CertificatePolicy(issuer, subject).setCertificateTransparent(false))) - .takeUntil(asyncPollResponse -> asyncPollResponse.getStatus() == LongRunningOperationStatus.IN_PROGRESS) - .map(asyncPollResponse -> { - MergeCertificateOptions mergeCertificateOptions = null; - - try { - CertificateOperation certificateOperation = asyncPollResponse.getValue(); - byte[] certificateSignRequest = certificateOperation.getCsr(); - PKCS10CertificationRequest pkcs10CertificationRequest - = new PKCS10CertificationRequest(certificateSignRequest); - byte[] certificateToMerge = FakeCredentialsForTests.FAKE_PEM_CERTIFICATE_FOR_MERGE.getBytes(); - X509Certificate x509ToMerge = loadCerToX509Certificate(certificateToMerge); - PrivateKey privateKey = loadPrivateKey("priv8.der"); - Date notBefore = new Date(); - Date notAfter = new Date(notBefore.getTime() + 60 * 86400000L); - - X500Name mergeIssuer = new X500Name(x509ToMerge.getSubjectX500Principal().getName()); - X500Name mergeSubject = pkcs10CertificationRequest.getSubject(); - AlgorithmIdentifier signatureAlgorithmIdentifier - = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA256withRSA"); - AlgorithmIdentifier digestAlgorithmIdentifier - = new DefaultDigestAlgorithmIdentifierFinder().find(signatureAlgorithmIdentifier); - AsymmetricKeyParameter asymmetricKeyParameter - = PrivateKeyFactory.createKey(privateKey.getEncoded()); - SubjectPublicKeyInfo publicKeyInfo = pkcs10CertificationRequest.getSubjectPublicKeyInfo(); - X509v3CertificateBuilder x509CertificateBuilder = new X509v3CertificateBuilder(mergeIssuer, - BigInteger.ONE, notBefore, notAfter, mergeSubject, publicKeyInfo); - - ContentSigner contentSigner - = new BcRSAContentSignerBuilder(signatureAlgorithmIdentifier, digestAlgorithmIdentifier) - .build(asymmetricKeyParameter); - - Certificate certificate = x509CertificateBuilder.build(contentSigner).toASN1Structure(); - - mergeCertificateOptions = new MergeCertificateOptions(certificateName, - Collections.singletonList(certificate.getEncoded())); - } catch (GeneralSecurityException | IOException | OperatorCreationException e) { - fail(e); - } - - return mergeCertificateOptions; - }) - .flatMap(mergeCertificateOptions -> certificateAsyncClient.mergeCertificate(mergeCertificateOptions)) - .flatMap(mergedCertificate -> setPlaybackPollerFluxPollInterval( - certificateAsyncClient.getCertificateOperation(mergedCertificate.getName()))) - .last()) - .assertNext(pollResponse -> assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, - pollResponse.getStatus())) - .verifyComplete(); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void mergeCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateAsyncClient(httpClient, serviceVersion); - - StepVerifier - .create(certificateAsyncClient.mergeCertificate(new MergeCertificateOptions( - testResourceNamer.randomName("testCert", 20), Collections.singletonList("test".getBytes())))) - .verifyErrorSatisfies( - e -> assertResponseException(e, KeyVaultErrorException.class, HttpURLConnection.HTTP_NOT_FOUND)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void importPemCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) - throws IOException { - createCertificateAsyncClient(httpClient, serviceVersion); - - importPemCertificateRunner((importCertificateOptions) -> StepVerifier - .create(certificateAsyncClient.importCertificate(importCertificateOptions)) - .assertNext(importedCertificate -> { - assertEquals(importCertificateOptions.isEnabled(), importedCertificate.getProperties().isEnabled()); - assertEquals(CertificateContentType.PEM, importedCertificate.getPolicy().getContentType()); - }) - .verifyComplete()); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientBuilderTest.java b/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientBuilderTest.java deleted file mode 100644 index 9210c0c8a635..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientBuilderTest.java +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.exception.HttpResponseException; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.policy.ExponentialBackoffOptions; -import com.azure.core.http.policy.HttpLogOptions; -import com.azure.core.http.policy.RetryOptions; -import com.azure.core.http.policy.RetryPolicy; -import com.azure.core.test.http.MockHttpResponse; -import com.azure.core.util.ClientOptions; -import com.azure.core.util.Header; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Mono; - -import java.util.Collections; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class CertificateClientBuilderTest { - private String vaultUrl; - private String certificateName; - private CertificateServiceVersion serviceVersion; - - @BeforeEach - public void setUp() { - vaultUrl = "https://key-vault-url.vault.azure.net/"; - certificateName = "TestCertificate"; - serviceVersion = CertificateServiceVersion.V7_3; - } - - @Test - public void buildSyncClientTest() { - CertificateClient certificateClient = new CertificateClientBuilder().vaultUrl(vaultUrl) - .serviceVersion(serviceVersion) - .credential(new TestUtils.TestCredential()) - .httpClient(request -> Mono.just(new MockHttpResponse(request, 200))) - .buildClient(); - - assertNotNull(certificateClient); - assertEquals(CertificateClient.class.getSimpleName(), certificateClient.getClass().getSimpleName()); - } - - @Test - public void buildSyncClientUsingDefaultApiVersionTest() { - CertificateClient certificateClient = new CertificateClientBuilder().vaultUrl(vaultUrl) - .credential(new TestUtils.TestCredential()) - .httpClient(request -> Mono.just(new MockHttpResponse(request, 200))) - .buildClient(); - - assertNotNull(certificateClient); - assertEquals(CertificateClient.class.getSimpleName(), certificateClient.getClass().getSimpleName()); - } - - @Test - public void buildAsyncClientTest() { - CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder().vaultUrl(vaultUrl) - .serviceVersion(serviceVersion) - .credential(new TestUtils.TestCredential()) - .httpClient(request -> Mono.just(new MockHttpResponse(request, 200))) - .buildAsyncClient(); - - assertNotNull(certificateAsyncClient); - assertEquals(CertificateAsyncClient.class.getSimpleName(), certificateAsyncClient.getClass().getSimpleName()); - } - - @Test - public void buildAsyncClientUsingDefaultApiVersionTest() { - CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder().vaultUrl(vaultUrl) - .credential(new TestUtils.TestCredential()) - .httpClient(request -> Mono.just(new MockHttpResponse(request, 200))) - .buildAsyncClient(); - - assertNotNull(certificateAsyncClient); - assertEquals(CertificateAsyncClient.class.getSimpleName(), certificateAsyncClient.getClass().getSimpleName()); - } - - @Test - public void emptyVaultUrlThrowsIllegalArgumentException() { - assertThrows(IllegalArgumentException.class, () -> new CertificateClientBuilder().vaultUrl("")); - } - - @Test - public void nullCredentialThrowsNullPointerException() { - assertThrows(NullPointerException.class, () -> new CertificateClientBuilder().credential(null)); - } - - @Test - public void clientOptionsIsPreferredOverLogOptions() { - CertificateClient certificateClient = new CertificateClientBuilder().vaultUrl(vaultUrl) - .credential(new TestUtils.TestCredential()) - .httpLogOptions(new HttpLogOptions().setApplicationId("anOldApplication")) - .clientOptions(new ClientOptions().setApplicationId("aNewApplication")) - .httpClient(httpRequest -> { - assertTrue(httpRequest.getHeaders().getValue(HttpHeaderName.USER_AGENT).contains("aNewApplication")); - return Mono.error(new HttpResponseException(new MockHttpResponse(httpRequest, 400))); - }) - .buildClient(); - - assertThrows(RuntimeException.class, () -> certificateClient.getCertificate(certificateName)); - } - - @Test - public void applicationIdFallsBackToLogOptions() { - CertificateClient certificateClient = new CertificateClientBuilder().vaultUrl(vaultUrl) - .credential(new TestUtils.TestCredential()) - .httpLogOptions(new HttpLogOptions().setApplicationId("anOldApplication")) - .httpClient(httpRequest -> { - assertTrue(httpRequest.getHeaders().getValue(HttpHeaderName.USER_AGENT).contains("anOldApplication")); - return Mono.error(new HttpResponseException(new MockHttpResponse(httpRequest, 400))); - }) - .buildClient(); - - assertThrows(RuntimeException.class, () -> certificateClient.getCertificate(certificateName)); - } - - @Test - public void clientOptionHeadersAreAddedLast() { - CertificateClient certificateClient = new CertificateClientBuilder().vaultUrl(vaultUrl) - .credential(new TestUtils.TestCredential()) - .clientOptions( - new ClientOptions().setHeaders(Collections.singletonList(new Header("User-Agent", "custom")))) - .httpClient(httpRequest -> { - assertEquals("custom", httpRequest.getHeaders().getValue(HttpHeaderName.USER_AGENT)); - return Mono.error(new HttpResponseException(new MockHttpResponse(httpRequest, 400))); - }) - .buildClient(); - - assertThrows(RuntimeException.class, () -> certificateClient.getCertificate(certificateName)); - } - - @Test - public void bothRetryOptionsAndRetryPolicySet() { - assertThrows(IllegalStateException.class, - () -> new CertificateClientBuilder().vaultUrl(vaultUrl) - .serviceVersion(serviceVersion) - .credential(new TestUtils.TestCredential()) - .retryOptions(new RetryOptions(new ExponentialBackoffOptions())) - .retryPolicy(new RetryPolicy()) - .httpClient(request -> Mono.just(new MockHttpResponse(request, 200))) - .buildClient()); - } - - // This tests the policy is in the right place because if it were added per retry, it would be after the credentials - // and auth would fail because we changed a signed header. - @Test - public void addPerCallPolicy() { - CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder().vaultUrl(vaultUrl) - .credential(new TestUtils.TestCredential()) - .addPolicy(new TestUtils.PerCallPolicy()) - .addPolicy(new TestUtils.PerRetryPolicy()) - .httpClient(request -> Mono.just(new MockHttpResponse(request, 200))) - .buildAsyncClient(); - - HttpPipeline pipeline = certificateAsyncClient.getHttpPipeline(); - - int retryPolicyPosition = -1, perCallPolicyPosition = -1, perRetryPolicyPosition = -1; - - for (int i = 0; i < pipeline.getPolicyCount(); i++) { - if (pipeline.getPolicy(i).getClass() == RetryPolicy.class) { - retryPolicyPosition = i; - } - - if (pipeline.getPolicy(i).getClass() == TestUtils.PerCallPolicy.class) { - perCallPolicyPosition = i; - } - - if (pipeline.getPolicy(i).getClass() == TestUtils.PerRetryPolicy.class) { - perRetryPolicyPosition = i; - } - } - - assertTrue(perCallPolicyPosition != -1); - assertTrue(perCallPolicyPosition < retryPolicyPosition); - assertTrue(retryPolicyPosition < perRetryPolicyPosition); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTest.java b/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTest.java deleted file mode 100644 index 0e5e361955fb..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTest.java +++ /dev/null @@ -1,1008 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.exception.ResourceModifiedException; -import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.http.HttpClient; -import com.azure.core.http.rest.PagedIterable; -import com.azure.core.test.http.AssertingHttpClientBuilder; -import com.azure.core.util.Context; -import com.azure.core.util.logging.ClientLogger; -import com.azure.core.util.logging.LogLevel; -import com.azure.core.util.polling.LongRunningOperationStatus; -import com.azure.core.util.polling.PollResponse; -import com.azure.core.util.polling.SyncPoller; -import com.azure.security.keyvault.certificates.implementation.KeyVaultCredentialPolicy; -import com.azure.security.keyvault.certificates.implementation.models.KeyVaultErrorException; -import com.azure.security.keyvault.certificates.models.CertificateContact; -import com.azure.security.keyvault.certificates.models.CertificateContentType; -import com.azure.security.keyvault.certificates.models.CertificateIssuer; -import com.azure.security.keyvault.certificates.models.CertificateOperation; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.CertificateProperties; -import com.azure.security.keyvault.certificates.models.DeletedCertificate; -import com.azure.security.keyvault.certificates.models.IssuerProperties; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificateWithPolicy; -import com.azure.security.keyvault.certificates.models.MergeCertificateOptions; -import org.bouncycastle.asn1.x500.X500Name; -import org.bouncycastle.asn1.x509.AlgorithmIdentifier; -import org.bouncycastle.asn1.x509.Certificate; -import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; -import org.bouncycastle.cert.X509v3CertificateBuilder; -import org.bouncycastle.crypto.params.AsymmetricKeyParameter; -import org.bouncycastle.crypto.util.PrivateKeyFactory; -import org.bouncycastle.operator.ContentSigner; -import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder; -import org.bouncycastle.operator.DefaultSignatureAlgorithmIdentifierFinder; -import org.bouncycastle.operator.OperatorCreationException; -import org.bouncycastle.operator.bc.BcRSAContentSignerBuilder; -import org.bouncycastle.pkcs.PKCS10CertificationRequest; -import org.junit.jupiter.api.condition.DisabledForJreRange; -import org.junit.jupiter.api.condition.JRE; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; - -import java.io.IOException; -import java.math.BigInteger; -import java.net.HttpURLConnection; -import java.security.GeneralSecurityException; -import java.security.PrivateKey; -import java.security.cert.X509Certificate; -import java.time.Duration; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - -public class CertificateClientTest extends CertificateClientTestBase { - private static final ClientLogger LOGGER = new ClientLogger(CertificateClientTest.class); - - private CertificateClient certificateClient; - - @Override - protected void beforeTest() { - beforeTestSetup(); - } - - private void createCertificateClient(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion, null); - } - - private void createCertificateClient(HttpClient httpClient, CertificateServiceVersion serviceVersion, - String testTenantId) { - certificateClient = getCertificateClientBuilder( - buildSyncAssertingClient( - interceptorManager.isPlaybackMode() ? interceptorManager.getPlaybackClient() : httpClient), - testTenantId, getEndpoint(), serviceVersion).buildClient(); - } - - private HttpClient buildSyncAssertingClient(HttpClient httpClient) { - return new AssertingHttpClientBuilder(httpClient).assertSync().build(); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - createCertificateRunner((certificatePolicy) -> { - String certName = testResourceNamer.randomName("testCert", 25); - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certName, certificatePolicy)); - - certPoller.waitForCompletion(); - - KeyVaultCertificateWithPolicy expected = certPoller.getFinalResult(); - - assertEquals(certName, expected.getName()); - assertNotNull(expected.getProperties().getCreatedOn()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createCertificateWithMultipleTenants(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion, testResourceNamer.randomUuid()); - - createCertificateRunner((certificatePolicy) -> { - String certName = testResourceNamer.randomName("testCert", 20); - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certName, certificatePolicy)); - - certPoller.waitForCompletion(); - - KeyVaultCertificateWithPolicy expected = certPoller.getFinalResult(); - - assertEquals(certName, expected.getName()); - assertNotNull(expected.getProperties().getCreatedOn()); - }); - - KeyVaultCredentialPolicy.clearCache(); // Ensure we don't have anything cached and try again. - - createCertificateRunner((certificatePolicy) -> { - String certName = testResourceNamer.randomName("testCert", 20); - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certName, certificatePolicy)); - - certPoller.waitForCompletion(); - - KeyVaultCertificateWithPolicy expected = certPoller.getFinalResult(); - - assertEquals(certName, expected.getName()); - assertNotNull(expected.getProperties().getCreatedOn()); - }); - } - - private void deleteAndPurgeCertificate(String certName) { - SyncPoller deletePoller - = setPlaybackSyncPollerPollInterval(certificateClient.beginDeleteCertificate(certName)); - - deletePoller.poll(); - deletePoller.waitForCompletion(); - - certificateClient.purgeDeletedCertificate(certName); - - pollOnCertificatePurge(certName); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createCertificateEmptyName(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException(() -> certificateClient.beginCreateCertificate("", CertificatePolicy.getDefault()), - KeyVaultErrorException.class, HttpURLConnection.HTTP_BAD_METHOD); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createCertificateNullPolicy(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertThrows(NullPointerException.class, - () -> certificateClient.beginCreateCertificate(testResourceNamer.randomName("tempCert", 20), null)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createCertificateNull(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertThrows(NullPointerException.class, () -> certificateClient.beginCreateCertificate(null, null)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void updateCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - updateCertificateRunner((originalTags, updatedTags) -> { - String certName = testResourceNamer.randomName("testCert", 20); - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval(certificateClient.beginCreateCertificate(certName, - CertificatePolicy.getDefault(), true, originalTags)); - - certPoller.waitForCompletion(); - - KeyVaultCertificateWithPolicy certificate = certPoller.getFinalResult(); - KeyVaultCertificate keyVaultCertificate - = certificateClient.updateCertificateProperties(certificate.getProperties().setTags(updatedTags)); - Map returnedTags = keyVaultCertificate.getProperties().getTags(); - - validateMapResponse(updatedTags, returnedTags); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void updateDisabledCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - updateDisabledCertificateRunner((originalTags, updatedTags) -> { - String certName = testResourceNamer.randomName("testCert", 20); - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval(certificateClient.beginCreateCertificate(certName, - CertificatePolicy.getDefault(), false, originalTags)); - - certPoller.waitForCompletion(); - - KeyVaultCertificateWithPolicy certificate = certPoller.getFinalResult(); - KeyVaultCertificate keyVaultCertificate - = certificateClient.updateCertificateProperties(certificate.getProperties().setTags(updatedTags)); - Map returnedTags = keyVaultCertificate.getProperties().getTags(); - - validateMapResponse(updatedTags, returnedTags); - - assertFalse(keyVaultCertificate.getProperties().isEnabled()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - getCertificateRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certificateName, initialPolicy)); - - certPoller.waitForCompletion(); - - KeyVaultCertificateWithPolicy certificate = certPoller.getFinalResult(); - KeyVaultCertificateWithPolicy getCertificate = certificateClient.getCertificate(certificateName); - - assertPolicy(certificate.getPolicy(), getCertificate.getPolicy()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificateSpecificVersion(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - getCertificateSpecificVersionRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certificateName, initialPolicy)); - - certPoller.waitForCompletion(); - - KeyVaultCertificateWithPolicy certificate = certPoller.getFinalResult(); - KeyVaultCertificate getCertificate - = certificateClient.getCertificateVersion(certificateName, certificate.getProperties().getVersion()); - - assertCertificate(certificate, getCertificate); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException(() -> certificateClient.getCertificate("non-existing"), ResourceNotFoundException.class, - HttpURLConnection.HTTP_NOT_FOUND); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void deleteCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - deleteCertificateRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certificateName, initialPolicy)); - - certPoller.waitForCompletion(); - - SyncPoller deletedKeyPoller - = setPlaybackSyncPollerPollInterval(certificateClient.beginDeleteCertificate(certificateName)); - - DeletedCertificate deletedCertificate = deletedKeyPoller.waitForCompletion().getValue(); - - assertNotNull(deletedCertificate.getDeletedOn()); - assertNotNull(deletedCertificate.getRecoveryId()); - assertNotNull(deletedCertificate.getScheduledPurgeDate()); - assertEquals(certificateName, deletedCertificate.getName()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void deleteCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException(() -> certificateClient.beginDeleteCertificate("non-existing"), - ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getDeletedCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - getDeletedCertificateRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certificateName, initialPolicy)); - - certPoller.waitForCompletion(); - - SyncPoller deletedKeyPoller - = setPlaybackSyncPollerPollInterval(certificateClient.beginDeleteCertificate(certificateName)); - - deletedKeyPoller.waitForCompletion(); - - DeletedCertificate deletedCertificate = certificateClient.getDeletedCertificate(certificateName); - - assertNotNull(deletedCertificate.getDeletedOn()); - assertNotNull(deletedCertificate.getRecoveryId()); - assertNotNull(deletedCertificate.getScheduledPurgeDate()); - assertEquals(certificateName, deletedCertificate.getName()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getDeletedCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException(() -> certificateClient.getDeletedCertificate("non-existing"), - ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void recoverDeletedCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - recoverDeletedKeyRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certificateName, initialPolicy)); - - certPoller.waitForCompletion(); - - KeyVaultCertificate createdCertificate = certPoller.getFinalResult(); - SyncPoller deletedKeyPoller - = setPlaybackSyncPollerPollInterval(certificateClient.beginDeleteCertificate(certificateName)); - - deletedKeyPoller.waitForCompletion(); - - SyncPoller recoverPoller - = setPlaybackSyncPollerPollInterval(certificateClient.beginRecoverDeletedCertificate(certificateName)); - - KeyVaultCertificate recoveredCert = recoverPoller.waitForCompletion().getValue(); - - assertEquals(certificateName, recoveredCert.getName()); - - assertCertificate(createdCertificate, recoveredCert); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void recoverDeletedCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException(() -> certificateClient.beginRecoverDeletedCertificate("non-existing"), - ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void backupCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - backupCertificateRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certificateName, initialPolicy)); - - certPoller.waitForCompletion(); - - byte[] backupBytes = (certificateClient.backupCertificate(certificateName)); - - assertNotNull(backupBytes); - assertTrue(backupBytes.length > 0); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void backupCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException(() -> certificateClient.backupCertificate("non-existing"), - ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void restoreCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - restoreCertificateRunner((certificateName) -> { - CertificatePolicy initialPolicy = setupPolicy(); - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certificateName, initialPolicy)); - - certPoller.waitForCompletion(); - - KeyVaultCertificateWithPolicy createdCert = certPoller.getFinalResult(); - byte[] backupBytes = (certificateClient.backupCertificate(certificateName)); - - assertNotNull(backupBytes); - assertTrue(backupBytes.length > 0); - - deleteAndPurgeCertificate(certificateName); - - sleepIfRunningAgainstService(40000); - - KeyVaultCertificateWithPolicy restoredCertificate = certificateClient.restoreCertificateBackup(backupBytes); - - assertEquals(certificateName, restoredCertificate.getName()); - - assertPolicy(restoredCertificate.getPolicy(), createdCert.getPolicy()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificateOperation(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - getCertificateOperationRunner((certificateName) -> { - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certificateName, setupPolicy())); - SyncPoller retrievePoller - = setPlaybackSyncPollerPollInterval(certificateClient.getCertificateOperation(certificateName)); - - retrievePoller.waitForCompletion(); - certPoller.waitForCompletion(); - - KeyVaultCertificateWithPolicy retrievedCert = retrievePoller.getFinalResult(); - KeyVaultCertificateWithPolicy expectedCert = certPoller.getFinalResult(); - - assertCertificate(expectedCert, retrievedCert); - assertPolicy(expectedCert.getPolicy(), retrievedCert.getPolicy()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void cancelCertificateOperation(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - cancelCertificateOperationRunner(certName -> { - SyncPoller certPoller - = certificateClient.beginCreateCertificate(certName, CertificatePolicy.getDefault()) - .setPollInterval(Duration.ofMillis(100)); - - certPoller.waitUntil(LongRunningOperationStatus.IN_PROGRESS); - certPoller.cancelOperation(); - - try { - certPoller.waitUntil(Duration.ofSeconds(60), LongRunningOperationStatus.fromString("cancelled", true)); - } catch (NoSuchElementException e) { - // The operation did not reach the expected status, either because it was completed before it could be - // canceled or there was a service timing issue when attempting to cancel the operation. - return; - } - - PollResponse pollResponse = certPoller.poll(); - - assertTrue(pollResponse.getValue().getCancellationRequested()); - - KeyVaultCertificateWithPolicy certificate = certPoller.getFinalResult(); - - assertFalse(certificate.getProperties().isEnabled()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void deleteCertificateOperation(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - deleteCertificateOperationRunner((certificateName) -> { - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certificateName, CertificatePolicy.getDefault())); - - certPoller.waitForCompletion(); - - CertificateOperation certificateOperation = certificateClient.deleteCertificateOperation(certificateName); - - assertEquals("completed", certificateOperation.getStatus()); - assertResponseException(() -> certificateClient.deleteCertificateOperation(certificateName), - ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificatePolicy(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - getCertificatePolicyRunner((certificateName) -> { - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certificateName, setupPolicy())); - - certPoller.waitForCompletion(); - - KeyVaultCertificateWithPolicy certificate = certPoller.getFinalResult(); - - assertPolicy(setupPolicy(), certificate.getPolicy()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void updateCertificatePolicy(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - updateCertificatePolicyRunner((certificateName) -> { - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certificateName, setupPolicy())); - - certPoller.waitForCompletion(); - - KeyVaultCertificateWithPolicy certificate = certPoller.getFinalResult(); - - certificate.getPolicy().setExportable(false); - - CertificatePolicy policy - = certificateClient.updateCertificatePolicy(certificateName, certificate.getPolicy()); - - assertPolicy(certificate.getPolicy(), policy); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void restoreCertificateFromMalformedBackup(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - byte[] keyBackupBytes = "non-existing".getBytes(); - - assertResponseException(() -> certificateClient.restoreCertificateBackup(keyBackupBytes), - ResourceModifiedException.class, HttpURLConnection.HTTP_BAD_REQUEST); - - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void listCertificates(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - listCertificatesRunner((certificatesToList) -> { - HashSet certificates = new HashSet<>(certificatesToList); - - for (String certName : certificates) { - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certName, CertificatePolicy.getDefault())); - - certPoller.waitForCompletion(); - } - - sleepIfRunningAgainstService(30000); - - for (CertificateProperties actualKey : certificateClient.listPropertiesOfCertificates()) { - certificates.remove(actualKey.getName()); - } - - assertEquals(0, certificates.size()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void listPropertiesOfCertificates(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - listPropertiesOfCertificatesRunner((certificatesToList) -> { - HashSet certificates = new HashSet<>(certificatesToList); - - for (String certName : certificates) { - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certName, CertificatePolicy.getDefault())); - - certPoller.waitForCompletion(); - } - - sleepIfRunningAgainstService(30000); - - for (CertificateProperties actualKey : certificateClient.listPropertiesOfCertificates(false, - Context.NONE)) { - certificates.remove(actualKey.getName()); - } - - assertEquals(0, certificates.size()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createIssuer(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - createIssuerRunner((issuer) -> { - CertificateIssuer createdIssuer = certificateClient.createIssuer(issuer); - - assertIssuerCreatedCorrectly(issuer, createdIssuer); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createIssuerEmptyName(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException(() -> certificateClient.createIssuer(new CertificateIssuer("", "")), - KeyVaultErrorException.class, HttpURLConnection.HTTP_BAD_METHOD); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createIssuerNullProvider(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException(() -> certificateClient.createIssuer(new CertificateIssuer("", null)), - KeyVaultErrorException.class, HttpURLConnection.HTTP_BAD_METHOD); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void createIssuerNull(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertThrows(NullPointerException.class, () -> certificateClient.createIssuer(null)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificateIssuer(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - getCertificateIssuerRunner((issuer) -> { - certificateClient.createIssuer(issuer); - CertificateIssuer retrievedIssuer = certificateClient.getIssuer(issuer.getName()); - - assertIssuerCreatedCorrectly(issuer, retrievedIssuer); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificateIssuerNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException(() -> certificateClient.backupCertificate("non-existing"), - ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void deleteCertificateIssuer(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - deleteCertificateIssuerRunner((issuer) -> { - certificateClient.createIssuer(issuer); - CertificateIssuer deletedIssuer = certificateClient.deleteIssuer(issuer.getName()); - - assertIssuerCreatedCorrectly(issuer, deletedIssuer); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void deleteCertificateIssuerNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException(() -> certificateClient.backupCertificate("non-existing"), - ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void listCertificateIssuers(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - listCertificateIssuersRunner((certificateIssuers) -> { - HashMap certificateIssuersToList = new HashMap<>(certificateIssuers); - - for (CertificateIssuer issuer : certificateIssuersToList.values()) { - CertificateIssuer certificateIssuer = certificateClient.createIssuer(issuer); - - assertIssuerCreatedCorrectly(issuer, certificateIssuer); - } - - for (IssuerProperties issuerProperties : certificateClient.listPropertiesOfIssuers()) { - certificateIssuersToList.remove(issuerProperties.getName()); - } - - assertEquals(0, certificateIssuersToList.size()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void updateIssuer(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - updateIssuerRunner((issuerToCreate, issuerToUpdate) -> { - certificateClient.createIssuer(issuerToCreate); - CertificateIssuer updatedIssuer = certificateClient.updateIssuer(issuerToUpdate); - - assertIssuerUpdatedCorrectly(issuerToCreate, updatedIssuer); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - @SuppressWarnings("ArraysAsListWithZeroOrOneArgument") - public void setContacts(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - List contacts = Arrays.asList(setupContact()); - - certificateClient.setContacts(contacts) - .forEach((retrievedContact) -> validateContact(setupContact(), retrievedContact)); - certificateClient.deleteContacts(); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - @SuppressWarnings("ArraysAsListWithZeroOrOneArgument") - public void listContacts(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - List contacts = Arrays.asList(setupContact()); - - certificateClient.setContacts(contacts) - .forEach((retrievedContact) -> validateContact(setupContact(), retrievedContact)); - - sleepIfRunningAgainstService(6000); - - certificateClient.listContacts() - .stream() - .forEach((retrievedContact) -> validateContact(setupContact(), retrievedContact)); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - @SuppressWarnings("ArraysAsListWithZeroOrOneArgument") - public void deleteContacts(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - List contacts = Arrays.asList(setupContact()); - - certificateClient.setContacts(contacts) - .forEach((retrievedContact) -> validateContact(setupContact(), retrievedContact)); - - PagedIterable certificateContacts = certificateClient.deleteContacts(); - - validateContact(setupContact(), certificateContacts.iterator().next()); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificateOperationNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException(() -> certificateClient.getCertificateOperation("non-existing").poll(), - ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void getCertificatePolicyNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException(() -> certificateClient.getCertificatePolicy("non-existing"), - ResourceNotFoundException.class, HttpURLConnection.HTTP_NOT_FOUND); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void listCertificateVersions(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - String certName = testResourceNamer.randomName("testListCertVersion", 25); - int versionsToCreate = 5; - - for (int i = 0; i < versionsToCreate; i++) { - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certName, CertificatePolicy.getDefault())); - - certPoller.waitForCompletion(); - } - - int createdVersions = 0; - - for (CertificateProperties properties : certificateClient.listPropertiesOfCertificateVersions(certName)) { - createdVersions++; - - assertEquals(properties.getName(), certName); - } - - assertEquals(versionsToCreate, createdVersions); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void listDeletedCertificates(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - listDeletedCertificatesRunner((certificates) -> { - HashSet certificatesToDelete = new HashSet<>(certificates); - - for (String certName : certificatesToDelete) { - SyncPoller certPoller - = setPlaybackSyncPollerPollInterval( - certificateClient.beginCreateCertificate(certName, CertificatePolicy.getDefault())); - - assertNotNull(certPoller.waitForCompletion().getValue()); - } - - for (String certName : certificates) { - SyncPoller poller - = setPlaybackSyncPollerPollInterval(certificateClient.beginDeleteCertificate(certName)); - - assertNotNull(poller.waitForCompletion().getValue()); - } - - sleepIfRunningAgainstService(30000); - - certificateClient.listDeletedCertificates() - .forEach(deletedCertificate -> certificatesToDelete.remove(deletedCertificate.getName())); - - assertEquals(0, certificatesToDelete.size()); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void importCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - importCertificateRunner((importCertificateOptions) -> { - KeyVaultCertificateWithPolicy importedCertificate - = certificateClient.importCertificate(importCertificateOptions); - - assertTrue("73b4319cdf38e0797084535d9c02fd04d4b2b2e6" - .equalsIgnoreCase(importedCertificate.getProperties().getX509ThumbprintAsString())); - assertEquals(importCertificateOptions.isEnabled(), importedCertificate.getProperties().isEnabled()); - - // Load the CER part into X509Certificate object - X509Certificate x509Certificate - = assertDoesNotThrow(() -> loadCerToX509Certificate(importedCertificate.getCer())); - - assertTrue(x509Certificate.getSubjectX500Principal() - .getName() - .contains("CN=Test,OU=Test,O=Contoso,L=Redmond,ST=WA,C=US")); - assertTrue(x509Certificate.getIssuerX500Principal() - .getName() - .contains("CN=Test,OU=Test,O=Contoso,L=Redmond,ST=WA,C=US")); - }); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - @DisabledForJreRange(min = JRE.JAVA_17) // Access to sun.security.* classes used here is not possible on Java 17+. - public void mergeCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - try { - createCertificateClient(httpClient, serviceVersion); - - String certificateName = testResourceNamer.randomName("testCert", 25); - String issuer = "Unknown"; - String subject = "CN=MyCert"; - SyncPoller createCertificatePoller - = setPlaybackSyncPollerPollInterval(certificateClient.beginCreateCertificate(certificateName, - new CertificatePolicy(issuer, subject).setCertificateTransparent(false))); - - createCertificatePoller.waitUntil(LongRunningOperationStatus.IN_PROGRESS); - - CertificateOperation certificateOperation = createCertificatePoller.poll().getValue(); - byte[] certificateSignRequest = certificateOperation.getCsr(); - PKCS10CertificationRequest pkcs10CertificationRequest - = new PKCS10CertificationRequest(certificateSignRequest); - byte[] certificateToMerge = FakeCredentialsForTests.FAKE_PEM_CERTIFICATE_FOR_MERGE.getBytes(); - X509Certificate x509ToMerge = loadCerToX509Certificate(certificateToMerge); - PrivateKey privateKey = loadPrivateKey("priv8.der"); - Date notBefore = new Date(); - Date notAfter = new Date(notBefore.getTime() + 60 * 86400000L); - - X500Name mergeIssuer = new X500Name(x509ToMerge.getSubjectX500Principal().getName()); - X500Name mergeSubject = pkcs10CertificationRequest.getSubject(); - AlgorithmIdentifier signatureAlgorithmIdentifier - = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA256withRSA"); - AlgorithmIdentifier digestAlgorithmIdentifier - = new DefaultDigestAlgorithmIdentifierFinder().find(signatureAlgorithmIdentifier); - AsymmetricKeyParameter asymmetricKeyParameter = PrivateKeyFactory.createKey(privateKey.getEncoded()); - SubjectPublicKeyInfo publicKeyInfo = pkcs10CertificationRequest.getSubjectPublicKeyInfo(); - X509v3CertificateBuilder x509CertificateBuilder = new X509v3CertificateBuilder(mergeIssuer, BigInteger.ONE, - notBefore, notAfter, mergeSubject, publicKeyInfo); - - ContentSigner contentSigner - = new BcRSAContentSignerBuilder(signatureAlgorithmIdentifier, digestAlgorithmIdentifier) - .build(asymmetricKeyParameter); - - Certificate certificate = x509CertificateBuilder.build(contentSigner).toASN1Structure(); - - MergeCertificateOptions mergeCertificateOptions - = new MergeCertificateOptions(certificateName, Collections.singletonList(certificate.getEncoded())); - - certificateClient.mergeCertificate(mergeCertificateOptions); - - PollResponse pollResponse = createCertificatePoller.poll(); - - assertEquals(LongRunningOperationStatus.SUCCESSFULLY_COMPLETED, pollResponse.getStatus()); - } catch (GeneralSecurityException | IOException | OperatorCreationException e) { - fail(e); - } - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void mergeCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion) { - createCertificateClient(httpClient, serviceVersion); - - assertResponseException( - () -> certificateClient.mergeCertificate(new MergeCertificateOptions( - testResourceNamer.randomName("testCert", 20), Collections.singletonList("test".getBytes()))), - KeyVaultErrorException.class, HttpURLConnection.HTTP_NOT_FOUND); - } - - @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) - @MethodSource("getTestParameters") - public void importPemCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) - throws IOException { - createCertificateClient(httpClient, serviceVersion); - - importPemCertificateRunner((importCertificateOptions) -> { - KeyVaultCertificateWithPolicy importedCertificate - = certificateClient.importCertificate(importCertificateOptions); - - assertEquals(importCertificateOptions.isEnabled(), importedCertificate.getProperties().isEnabled()); - assertEquals(CertificateContentType.PEM, importedCertificate.getPolicy().getContentType()); - }); - } - - private void pollOnCertificatePurge(String certificateName) { - int pendingPollCount = 0; - - while (pendingPollCount < 10) { - DeletedCertificate deletedCertificate = null; - - try { - deletedCertificate = certificateClient.getDeletedCertificate(certificateName); - } catch (ResourceNotFoundException ignored) { - } - - if (deletedCertificate != null) { - sleepIfRunningAgainstService(2000); - - pendingPollCount += 1; - } else { - return; - } - } - - LOGGER.log(LogLevel.VERBOSE, () -> "Deleted Certificate " + certificateName + " was not purged"); - } - -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTestBase.java b/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTestBase.java deleted file mode 100644 index 27bebe22fd1c..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTestBase.java +++ /dev/null @@ -1,667 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.credential.TokenCredential; -import com.azure.core.exception.HttpResponseException; -import com.azure.core.http.HttpClient; -import com.azure.core.http.policy.ExponentialBackoffOptions; -import com.azure.core.http.policy.FixedDelayOptions; -import com.azure.core.http.policy.RetryOptions; -import com.azure.core.test.TestProxyTestBase; -import com.azure.core.test.models.BodilessMatcher; -import com.azure.core.test.models.CustomMatcher; -import com.azure.core.test.models.TestProxyRequestMatcher; -import com.azure.core.test.models.TestProxySanitizer; -import com.azure.core.test.models.TestProxySanitizerType; -import com.azure.core.test.utils.MockTokenCredential; -import com.azure.core.test.utils.TestUtils; -import com.azure.core.util.Configuration; -import com.azure.core.util.CoreUtils; -import com.azure.identity.AzurePowerShellCredentialBuilder; -import com.azure.identity.DefaultAzureCredentialBuilder; -import com.azure.security.keyvault.certificates.implementation.KeyVaultCredentialPolicy; -import com.azure.security.keyvault.certificates.models.AdministratorContact; -import com.azure.security.keyvault.certificates.models.CertificateContact; -import com.azure.security.keyvault.certificates.models.CertificateContentType; -import com.azure.security.keyvault.certificates.models.CertificateIssuer; -import com.azure.security.keyvault.certificates.models.CertificateKeyCurveName; -import com.azure.security.keyvault.certificates.models.CertificateKeyType; -import com.azure.security.keyvault.certificates.models.CertificateKeyUsage; -import com.azure.security.keyvault.certificates.models.CertificatePolicy; -import com.azure.security.keyvault.certificates.models.CertificatePolicyAction; -import com.azure.security.keyvault.certificates.models.ImportCertificateOptions; -import com.azure.security.keyvault.certificates.models.KeyVaultCertificate; -import com.azure.security.keyvault.certificates.models.LifetimeAction; -import com.azure.security.keyvault.certificates.models.WellKnownIssuerNames; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.provider.Arguments; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.security.KeyFactory; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.PKCS8EncodedKeySpec; -import java.time.Duration; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.stream.Stream; - -import static com.azure.security.keyvault.certificates.FakeCredentialsForTests.FAKE_CERTIFICATE; -import static com.azure.security.keyvault.certificates.FakeCredentialsForTests.FAKE_PEM_CERTIFICATE; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - -public abstract class CertificateClientTestBase extends TestProxyTestBase { - static final String DISPLAY_NAME_WITH_ARGUMENTS = "{displayName} with [{arguments}]"; - private static final String AZURE_KEYVAULT_TEST_CERTIFICATE_SERVICE_VERSIONS - = "AZURE_KEYVAULT_TEST_CERTIFICATE_SERVICE_VERSIONS"; - private static final String SERVICE_VERSION_FROM_ENV - = Configuration.getGlobalConfiguration().get(AZURE_KEYVAULT_TEST_CERTIFICATE_SERVICE_VERSIONS); - private static final String AZURE_TEST_SERVICE_VERSIONS_VALUE_ALL = "ALL"; - private static final String TEST_CERTIFICATE_NAME = "testCert"; - - private static final int MAX_RETRIES = 5; - private static final RetryOptions LIVE_RETRY_OPTIONS - = new RetryOptions(new ExponentialBackoffOptions().setMaxRetries(MAX_RETRIES) - .setBaseDelay(Duration.ofSeconds(2)) - .setMaxDelay(Duration.ofSeconds(16))); - - private static final RetryOptions PLAYBACK_RETRY_OPTIONS - = new RetryOptions(new FixedDelayOptions(MAX_RETRIES, Duration.ofMillis(1))); - - void beforeTestSetup() { - KeyVaultCredentialPolicy.clearCache(); - } - - CertificateClientBuilder getCertificateClientBuilder(HttpClient httpClient, String testTenantId, String endpoint, - CertificateServiceVersion serviceVersion) { - TokenCredential credential; - - if (interceptorManager.isLiveMode()) { - credential = new AzurePowerShellCredentialBuilder().additionallyAllowedTenants("*").build(); - } else if (interceptorManager.isRecordMode()) { - credential = new DefaultAzureCredentialBuilder().additionallyAllowedTenants("*").build(); - List customSanitizers = new ArrayList<>(); - customSanitizers.add( - new TestProxySanitizer("value", "-----BEGIN PRIVATE KEY-----\\n(.+\\n)*-----END PRIVATE KEY-----\\n", - "-----BEGIN PRIVATE KEY-----\\nREDACTED\\n-----END PRIVATE KEY-----\\n", - TestProxySanitizerType.BODY_KEY)); - interceptorManager.addSanitizers(customSanitizers); - } else { - credential = new MockTokenCredential(); - - List customMatchers = new ArrayList<>(); - customMatchers.add(new BodilessMatcher()); - customMatchers.add(new CustomMatcher().setExcludedHeaders(Collections.singletonList("Authorization"))); - interceptorManager.addMatchers(customMatchers); - } - - CertificateClientBuilder builder = new CertificateClientBuilder().vaultUrl(endpoint) - .serviceVersion(serviceVersion) - .credential(credential) - .httpClient(httpClient); - - if (!interceptorManager.isLiveMode()) { - // Remove `id` and `name` sanitizers from the list of common sanitizers. - interceptorManager.removeSanitizers("AZSDK3430", "AZSDK3493"); - } - - if (interceptorManager.isPlaybackMode()) { - return builder.retryOptions(PLAYBACK_RETRY_OPTIONS); - } else { - builder.retryOptions(LIVE_RETRY_OPTIONS); - - return interceptorManager.isRecordMode() - ? builder.addPolicy(interceptorManager.getRecordPolicy()) - : builder; - } - } - - @Test - public abstract void createCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - static void createCertificateRunner(Consumer testRunner) { - final CertificatePolicy certificatePolicy = CertificatePolicy.getDefault(); - - testRunner.accept(certificatePolicy); - } - - @Test - public abstract void createCertificateEmptyName(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void createCertificateNullPolicy(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void createCertificateNull(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void updateCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - static void updateCertificateRunner(BiConsumer, Map> testRunner) { - final Map tags = new HashMap<>(); - tags.put("first tag", "first value"); - - final Map updatedTags = new HashMap<>(); - - tags.put("first tag", "first value"); - tags.put("second tag", "second value"); - - testRunner.accept(tags, updatedTags); - } - - @Test - public abstract void updateDisabledCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - static void updateDisabledCertificateRunner(BiConsumer, Map> testRunner) { - final Map tags = new HashMap<>(); - - tags.put("first tag", "first value"); - - final Map updatedTags = new HashMap<>(); - - tags.put("first tag", "first value"); - tags.put("second tag", "second value"); - - testRunner.accept(tags, updatedTags); - } - - @Test - public abstract void getCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void getCertificateRunner(Consumer testRunner) { - testRunner.accept(testResourceNamer.randomName(TEST_CERTIFICATE_NAME, 25)); - } - - @Test - public abstract void getCertificateSpecificVersion(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void getCertificateSpecificVersionRunner(Consumer testRunner) { - testRunner.accept(testResourceNamer.randomName(TEST_CERTIFICATE_NAME, 25)); - } - - @Test - public abstract void getCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void deleteCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void deleteCertificateRunner(Consumer testRunner) { - testRunner.accept(testResourceNamer.randomName(TEST_CERTIFICATE_NAME, 25)); - } - - @Test - public abstract void deleteCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void getDeletedCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void getDeletedCertificateRunner(Consumer testRunner) { - testRunner.accept(testResourceNamer.randomName(TEST_CERTIFICATE_NAME, 25)); - } - - @Test - public abstract void getDeletedCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void recoverDeletedCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void recoverDeletedKeyRunner(Consumer testRunner) { - testRunner.accept(testResourceNamer.randomName(TEST_CERTIFICATE_NAME, 25)); - } - - @Test - public abstract void recoverDeletedCertificateNotFound(HttpClient httpClient, - CertificateServiceVersion serviceVersion); - - @Test - public abstract void backupCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void backupCertificateRunner(Consumer testRunner) { - testRunner.accept(testResourceNamer.randomName(TEST_CERTIFICATE_NAME, 25)); - } - - @Test - public abstract void backupCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void restoreCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void restoreCertificateRunner(Consumer testRunner) { - testRunner.accept(testResourceNamer.randomName(TEST_CERTIFICATE_NAME, 25)); - } - - @Test - public abstract void getCertificateOperation(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void getCertificateOperationRunner(Consumer testRunner) { - testRunner.accept(testResourceNamer.randomName(TEST_CERTIFICATE_NAME, 25)); - } - - @Test - public abstract void cancelCertificateOperation(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void cancelCertificateOperationRunner(Consumer testRunner) { - testRunner.accept(testResourceNamer.randomName(TEST_CERTIFICATE_NAME, 25)); - } - - @Test - public abstract void deleteCertificateOperation(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void deleteCertificateOperationRunner(Consumer testRunner) { - testRunner.accept(testResourceNamer.randomName(TEST_CERTIFICATE_NAME, 25)); - } - - @Test - public abstract void getCertificatePolicy(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void getCertificatePolicyRunner(Consumer testRunner) { - testRunner.accept(testResourceNamer.randomName(TEST_CERTIFICATE_NAME, 25)); - } - - @Test - public abstract void updateCertificatePolicy(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void updateCertificatePolicyRunner(Consumer testRunner) { - testRunner.accept(testResourceNamer.randomName(TEST_CERTIFICATE_NAME, 25)); - } - - @Test - public abstract void restoreCertificateFromMalformedBackup(HttpClient httpClient, - CertificateServiceVersion serviceVersion); - - @Test - public abstract void listCertificates(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void listCertificatesRunner(Consumer> testRunner) { - List certificates = new ArrayList<>(); - String certificateName; - - for (int i = 0; i < 2; i++) { - certificateName = testResourceNamer.randomName("listCertKey", 25); - - certificates.add(certificateName); - } - - testRunner.accept(certificates); - } - - @Test - public abstract void listPropertiesOfCertificates(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void listPropertiesOfCertificatesRunner(Consumer> testRunner) { - List certificates = new ArrayList<>(); - String certificateName; - - for (int i = 0; i < 2; i++) { - certificateName = testResourceNamer.randomName("listCertKey", 25); - - certificates.add(certificateName); - } - - testRunner.accept(certificates); - } - - @Test - public abstract void createIssuer(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void createIssuerRunner(Consumer testRunner) { - final CertificateIssuer certificateIssuer = setupIssuer(testResourceNamer.randomName("testIssuer", 25)); - - testRunner.accept(certificateIssuer); - } - - @Test - public abstract void createIssuerNull(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void getCertificateIssuer(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void getCertificateIssuerNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void getCertificateIssuerRunner(Consumer testRunner) { - final CertificateIssuer certificateIssuer = setupIssuer(testResourceNamer.randomName("testIssuer", 25)); - - testRunner.accept(certificateIssuer); - } - - @Test - public abstract void deleteCertificateIssuer(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void deleteCertificateIssuerNotFound(HttpClient httpClient, - CertificateServiceVersion serviceVersion); - - void deleteCertificateIssuerRunner(Consumer testRunner) { - final CertificateIssuer certificateIssuer = setupIssuer(testResourceNamer.randomName("testIssuer", 25)); - - testRunner.accept(certificateIssuer); - } - - @Test - public abstract void listCertificateIssuers(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void listCertificateIssuersRunner(Consumer> testRunner) { - HashMap certificateIssuers = new HashMap<>(); - String certificateIssuerName; - - for (int i = 0; i < 10; i++) { - certificateIssuerName = testResourceNamer.randomName("listCertIssuer", 25); - - certificateIssuers.put(certificateIssuerName, setupIssuer(certificateIssuerName)); - } - - testRunner.accept(certificateIssuers); - } - - void updateIssuerRunner(BiConsumer testRunner) { - String issuerName = testResourceNamer.randomName("testIssuer", 25); - final CertificateIssuer certificateIssuer = setupIssuer(issuerName); - final CertificateIssuer issuerForUpdate = new CertificateIssuer(issuerName, "Test") - .setAdministratorContacts(Arrays.asList(new AdministratorContact().setFirstName("otherFirst") - .setLastName("otherLast") - .setEmail("otherFirst.otherLast@hotmail.com") - .setPhone("000-000-0000"))) - .setAccountId("otherIssuerAccountId") - .setEnabled(false) - .setOrganizationId("otherOrgId") - .setPassword("fakePasswordPlaceholder"); - - testRunner.accept(certificateIssuer, issuerForUpdate); - } - - @Test - public abstract void setContacts(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void listContacts(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void deleteContacts(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void getCertificateOperationNotFound(HttpClient httpClient, - CertificateServiceVersion serviceVersion); - - @Test - public abstract void getCertificatePolicyNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - static CertificateContact setupContact() { - return new CertificateContact().setName("name").setEmail("first.last@gmail.com").setPhone("000-000-0000"); - } - - static void validateContact(CertificateContact expected, CertificateContact actual) { - assertEquals(expected.getName(), actual.getName()); - assertEquals(expected.getEmail(), actual.getEmail()); - assertEquals(expected.getPhone(), actual.getPhone()); - } - - @Test - public abstract void listCertificateVersions(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void listDeletedCertificates(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void listDeletedCertificatesRunner(Consumer> testRunner) { - List certificates = new ArrayList<>(); - - for (int i = 0; i < 3; i++) { - certificates.add(testResourceNamer.randomName("listDeletedCert", 25)); - } - - testRunner.accept(certificates); - } - - @Test - public abstract void importCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - void importCertificateRunner(Consumer testRunner) { - String certificatePassword = "fakePasswordPlaceholder"; - String certificateName = testResourceNamer.randomName("importCertPkcs", 25); - HashMap tags = new HashMap<>(); - - tags.put("key", "val"); - - ImportCertificateOptions importCertificateOptions - = new ImportCertificateOptions(certificateName, Base64.getDecoder().decode(FAKE_CERTIFICATE)) - .setPassword(certificatePassword) - .setEnabled(true) - .setTags(tags); - - testRunner.accept(importCertificateOptions); - } - - @Test - public abstract void importPemCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion) - throws IOException; - - void importPemCertificateRunner(Consumer testRunner) throws IOException { - byte[] certificateContent = FAKE_PEM_CERTIFICATE.getBytes(); - - String certificateName = testResourceNamer.randomName("importCertPem", 25); - HashMap tags = new HashMap<>(); - tags.put("key", "val"); - ImportCertificateOptions importCertificateOptions - = new ImportCertificateOptions(certificateName, certificateContent) - .setPolicy(new CertificatePolicy("Self", "CN=AzureSDK").setContentType(CertificateContentType.PEM)) - .setEnabled(true) - .setTags(tags); - testRunner.accept(importCertificateOptions); - } - - @Test - public abstract void mergeCertificate(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - @Test - public abstract void mergeCertificateNotFound(HttpClient httpClient, CertificateServiceVersion serviceVersion); - - protected PrivateKey loadPrivateKey(String filename) - throws IOException, NoSuchAlgorithmException, InvalidKeySpecException { - - byte[] keyBytes = Files.readAllBytes(Paths.get("src", "test", "resources", filename)); - - PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes); - KeyFactory kf = KeyFactory.getInstance("RSA"); - - return kf.generatePrivate(spec); - } - - static CertificateIssuer setupIssuer(String issuerName) { - return new CertificateIssuer(issuerName, "Test") - .setAdministratorContacts(Collections.singletonList(new AdministratorContact().setFirstName("first") - .setLastName("last") - .setEmail("first.last@hotmail.com") - .setPhone("000-000-0000"))) - .setAccountId("issuerAccountId") - .setEnabled(true) - .setOrganizationId("orgId") - .setPassword("fakePasswordPlaceholder"); - } - - X509Certificate loadCerToX509Certificate(byte[] certificate) throws CertificateException, IOException { - assertNotNull(certificate); - - ByteArrayInputStream cerStream = new ByteArrayInputStream(certificate); - CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); - - X509Certificate x509Certificate = (X509Certificate) certificateFactory.generateCertificate(cerStream); - - cerStream.close(); - - return x509Certificate; - } - - static void assertIssuerCreatedCorrectly(CertificateIssuer expected, CertificateIssuer actual) { - assertEquals(expected.getAccountId(), actual.getAccountId()); - assertEquals(expected.isEnabled(), actual.isEnabled()); - assertNotNull(actual.getCreatedOn()); - assertNotNull(actual.getUpdatedOn()); - assertNotNull(actual.getId()); - assertTrue(actual.getId().length() > 0); - assertEquals(expected.getName(), actual.getName()); - assertEquals(expected.getOrganizationId(), actual.getOrganizationId()); - assertEquals(expected.getAdministratorContacts().size(), actual.getAdministratorContacts().size()); - } - - static void assertIssuerUpdatedCorrectly(CertificateIssuer expected, CertificateIssuer actual) { - assertNotEquals(expected.getAccountId(), actual.getAccountId()); - assertNotEquals(expected.isEnabled(), actual.isEnabled()); - assertNotNull(actual.getUpdatedOn()); - assertNotNull(actual.getCreatedOn()); - assertNotNull(actual.getId()); - assertTrue(actual.getId().length() > 0); - assertEquals(expected.getName(), actual.getName()); - assertNotEquals(expected.getOrganizationId(), actual.getOrganizationId()); - assertEquals(expected.getAdministratorContacts().size(), actual.getAdministratorContacts().size()); - } - - static CertificatePolicy setupPolicy() { - return new CertificatePolicy(WellKnownIssuerNames.SELF, "CN=default") - .setKeyUsage(CertificateKeyUsage.KEY_CERT_SIGN, CertificateKeyUsage.KEY_AGREEMENT) - .setContentType(CertificateContentType.PKCS12) - .setExportable(true) - .setKeyType(CertificateKeyType.EC) - .setCertificateTransparent(false) - .setEnabled(true) - .setKeyCurveName(CertificateKeyCurveName.P_384) - .setKeyReusable(true) - .setValidityInMonths(24) - .setLifetimeActions(new LifetimeAction(CertificatePolicyAction.AUTO_RENEW).setDaysBeforeExpiry(40)); - } - - static void assertPolicy(CertificatePolicy expected, CertificatePolicy actual) { - assertEquals(expected.getKeyType(), actual.getKeyType()); - assertEquals(expected.getContentType(), actual.getContentType()); - assertNotNull(actual.getCreatedOn()); - assertEquals(expected.getIssuerName(), actual.getIssuerName()); - assertEquals(expected.getKeyCurveName(), actual.getKeyCurveName()); - assertEquals(expected.isExportable(), actual.isExportable()); - assertEquals(expected.isCertificateTransparent(), actual.isCertificateTransparent()); - assertEquals(expected.isEnabled(), actual.isEnabled()); - assertEquals(expected.isKeyReusable(), actual.isKeyReusable()); - assertEquals(expected.getValidityInMonths(), actual.getValidityInMonths()); - assertEquals(expected.getLifetimeActions().size(), actual.getLifetimeActions().size()); - assertEquals(expected.getKeyUsage().size(), actual.getKeyUsage().size()); - } - - static void assertCertificate(KeyVaultCertificate expected, KeyVaultCertificate actual) { - assertEquals(expected.getId(), actual.getId()); - assertEquals(expected.getKeyId(), actual.getKeyId()); - assertEquals(expected.getName(), actual.getName()); - assertEquals(expected.getSecretId(), actual.getSecretId()); - assertEquals(expected.getProperties().getVersion(), actual.getProperties().getVersion()); - assertEquals(expected.getProperties().getCreatedOn(), actual.getProperties().getCreatedOn()); - assertEquals(expected.getProperties().getExpiresOn(), actual.getProperties().getExpiresOn()); - assertEquals(expected.getProperties().getRecoveryLevel(), actual.getProperties().getRecoveryLevel()); - TestUtils.assertArraysEqual(expected.getProperties().getX509Thumbprint(), - actual.getProperties().getX509Thumbprint()); - TestUtils.assertArraysEqual(expected.getCer(), actual.getCer()); - } - - public static String getEndpoint() { - return Objects.requireNonNull( - Configuration.getGlobalConfiguration().get("AZURE_KEYVAULT_ENDPOINT", "https://localhost:8080")); - } - - static void assertResponseException(Runnable exceptionThrower, - Class expectedExceptionType, int expectedStatusCode) { - try { - exceptionThrower.run(); - fail(); - } catch (HttpResponseException e) { - assertResponseException(e, expectedExceptionType, expectedStatusCode); - } - } - - static void assertResponseException(Throwable exception, - Class expectedExceptionType, int expectedStatusCode) { - assertEquals(expectedExceptionType, exception.getClass()); - assertEquals(expectedStatusCode, ((HttpResponseException) exception).getResponse().getStatusCode()); - } - - static void assertResponseException(HttpResponseException exception, - Class expectedExceptionType, int expectedStatusCode) { - assertEquals(expectedExceptionType, exception.getClass()); - assertEquals(expectedStatusCode, exception.getResponse().getStatusCode()); - } - - /** - * Returns a stream of arguments that includes all combinations of eligible {@link HttpClient HttpClients} and - * service versions that should be tested. - * - * @return A stream of HttpClient and service version combinations to test. - */ - static Stream getTestParameters() { - // When this issues is closed, the newer version of junit will have better support for cartesian product of - // arguments - https://github.com/junit-team/junit5/issues/1427 - List argumentsList = new ArrayList<>(); - - getHttpClients().forEach(httpClient -> Arrays.stream(CertificateServiceVersion.values()) - .filter(CertificateClientTestBase::shouldServiceVersionBeTested) - .forEach(serviceVersion -> argumentsList.add(Arguments.of(httpClient, serviceVersion)))); - - return argumentsList.stream(); - } - - /** - * Returns whether the given service version match the rules of test framework. - * - *
    - *
  • Using latest service version as default if no environment variable is set.
  • - *
  • If it's set to ALL, all Service versions in {@link CertificateServiceVersion} will be tested.
  • - *
  • Otherwise, Service version string should match env variable.
  • - *
- * - * Environment values currently supported are: "ALL", "${version}". - * Use comma to separate http clients want to test. - * e.g. {@code set AZURE_TEST_SERVICE_VERSIONS = V1_0, V2_0} - * - * @param serviceVersion ServiceVersion needs to check. - * - * @return Boolean indicates whether filters out the service version or not. - */ - private static boolean shouldServiceVersionBeTested(CertificateServiceVersion serviceVersion) { - if (CoreUtils.isNullOrEmpty(SERVICE_VERSION_FROM_ENV)) { - return CertificateServiceVersion.getLatest().equals(serviceVersion); - } - - if (AZURE_TEST_SERVICE_VERSIONS_VALUE_ALL.equalsIgnoreCase(SERVICE_VERSION_FROM_ENV)) { - return true; - } - - String[] configuredServiceVersionList = SERVICE_VERSION_FROM_ENV.split(","); - - return Arrays.stream(configuredServiceVersionList) - .anyMatch(configuredServiceVersion -> serviceVersion.getVersion().equals(configuredServiceVersion.trim())); - } - - static void validateMapResponse(Map expected, Map returned) { - for (String key : expected.keySet()) { - String val = returned.get(key); - String expectedVal = expected.get(key); - - assertEquals(expectedVal, val); - } - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/FakeCredentialsForTests.java b/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/FakeCredentialsForTests.java deleted file mode 100644 index 06516cb6b081..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/FakeCredentialsForTests.java +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -/** - * Fake credential shared in Tests - */ -public class FakeCredentialsForTests { - /** - * Fake certificate content - */ - public static final String FAKE_CERTIFICATE = "MIIKjwIBAzCCCkUGCSqGSIb3DQEHAaCCCjYEggoyMIIKLjCCBJoGCSqGSIb3DQEH" - + "BqCCBIswggSHAgEAMIIEgAYJKoZIhvcNAQcBMF8GCSqGSIb3DQEFDTBSMDEGCSqG" - + "SIb3DQEFDDAkBBD6J7VlngzbeYpxVxb5zbUjAgIIADAMBggqhkiG9w0CCQUAMB0G" - + "CWCGSAFlAwQBKgQQFq79Veolktn9WBVZ2b+yn4CCBBDmBdB0C7F9Lac/Kv5pjH4b" - + "RFX1HEygcQVBJQpCKq5WuR2ahBZolTfo6mlhWrB0Y/pdNe5QBERrw5PX9hghny19" - + "S0m9jmwYb2VwTigIGJAqR6Ruik3MJ1Ya57dYNXgpr3smhgYNe66Jk8sHbFiwlSU7" - + "Hsq69+1EZwwKBHerGfpMux4vWAWAIHorJgZxrXAuce+mSxDxkASe+Ud/bqq0no3q" - + "qsad60l2SgTElwpBCrMkac8bUHwOg6jOJltPRSfWjfSiqVt/14OIS5HQwUaA6ZyP" - + "sD3poTAaDu35d3Xou7f7oZlN5AeCNnoD/uQlA5d/nXEyCC/UXbXj9O+vDXKfaS7Y" - + "naUqKSOcqxCj9NRsLAJWuE06oOFxrZJu+UbcANZAUqLW6GD8D7kTgoZmakE6QxT0" - + "Q1tOtEV2/pxhAHKj3V8IiWQ2NdodigO52UcGIt8Q4awbydy6RPFMppsi8WBTXDtP" - + "bui8V4AJvtrm5jRGdW7mzJvkqeUVR/IeQ/7L5hpcr1hg1EVs43ax29VF6VmMiVKa" - + "Y3Itiqs49fet6Qburgf11AyrP9RuipJD5hQd1YmlIvpySLkxc2/PMGEsdgC4BTIz" - + "I0MszHaQPvsgKxGTdf6keV4yZSWUyEOAyFCmuynfOCwSya6Cbm74YAXXj4IdA1dY" - + "6kOgNgfTM8Tr3KmaBSNbenwAXXPVHIJacqIMRTUIQ/+be0dwsgJ5FJi0/5poYrDj" - + "XLyXT25OOTFZVAzGwVcm5hlFNQUULV7bAaJOH2ZtK3uoTHuH83FCfRSRqeOqEhZJ" - + "Z0DF2yEG2yuEHOT2OqcIYuRnl1HbGdYFgbwoa9UTMOYG8HkEgzKFTXoqmKOC38zu" - + "W+1pKLn+uiTkeyCOjAq99Mwve2fFDdQHXcSmv24ZFsiHSctzDQe9xJUBtRtm38+d" - + "GkniMuusmxBIhgMqPeG1g7tqS7OrX+r9wZieBqL3aaabXAXQbuQZ3tFyZDzWfA5w" - + "lWY0mc7rmqau70XTV90eGxUtT4IYeLuTbjVsPBYahsupEbujrkeo4kS8cp6AyIhl" - + "WLzcXYzwAnIcbQJkw6nb/JyCrz9/mASpQmKpX4syj+4wcFATwDDt4KjblAendcJw" - + "bguM4isaPCxP48hg4Tj0CLLSRNtMfXIjKltJWkhjXzQLEzcCTeWLAUzzm9mNyDOZ" - + "EVso2Y1jN6Xqdm6D1bRuHp0TsKlHdkyBwBCkFPph+fCgKrASmbgSzX8bilqzOU/r" - + "8Ql+ot6br42IPIm6Cwn6sCwdiS0chx0mr52n3Fef7Aurluu6x/xnNT+wLoURXHNe" - + "FqN0nKZBgKWRQIUKAkpK+02tN0TFtUWbHjJ0EAsNwAaSoTwqXNgEmb8JPR1BRCod" - + "kYfAnHlnvBy83IMiXMz0lDCCBYwGCSqGSIb3DQEHAaCCBX0EggV5MIIFdTCCBXEG" - + "CyqGSIb3DQEMCgECoIIFOTCCBTUwXwYJKoZIhvcNAQUNMFIwMQYJKoZIhvcNAQUM" - + "MCQEEEaqp++BjdYKmeKmJMqBDE0CAggAMAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUD" - + "BAEqBBB8PJ1Qo62GUuy2gDROrqH8BIIE0Byd3Rzee8m9fS7xEV6Z5QM86PEOyziF" - + "nzWe8WRrbTN62u9JPAfYvXeeCRdr8QKkvw8mJXUUNHYmwo56ExR/JSJu/vQIl7FN" - + "jtGzwQHQtUTNcZuAsiFrZvYq4vAI0wnwmtW/ApQCylbERyZp8DRx3fT90QTAGz9s" - + "T9RreOeN8qUj0UY6/8eD3vZJ2sG+QpHK5cv1H++ZhbfgZgR8aaupu6xXKQdTHg7P" - + "ors42O7Q40Sk/LvWVHfA2tYPr5QfeB1tyjhSnwx1wExlWb01XvRq1IkP8K4SD4Ss" - + "7Smo7SmWprzjIFcpTWXI0MS2sFIzJICxih3eUoWvRYWZk0J8H1qVq4yDke0q9ah7" - + "FdCOt2Ah7JPscb+ahGjQjNNWsfC3INSNLABxB3b3RlJLCY9D/hG5a2auDaF/0tXX" - + "UhrRfUZhW70Cc345I4hdrX9xze4kSdF5h9Uzzv2OzzFcojM/7CYG3ya2pyMn1CQH" - + "B/SY2XqweINrqVRWiBEhD1r/SJ1Sq2uvMp6WmctKKOh6JNErFabxd/GybrcYlhZO" - + "a6SnH23xpMonPzAzW43p8C41GDIizUMFvbxvkPFWBbsSJuUUoGvR6sHvKGOLs72Z" - + "D0ruInfTeZxD15NX8zd+pZDEyFWVH0sxZjOXouJr3RM28UvLu9uuIoz7+1/p3rns" - + "NX7tBV7zDspe5Tsb3t49vtO5wxdGAIAEK+5MrbvuP1w2T6aQYwF5DSzckDeZREGn" - + "GjEyTnzFRn/1FTKgfPkBUa8AIl1CbYYNebusVZSoB19+gDCH3oyzF4+Qr5mKpkEF" - + "LFbV4Sxvbk8vxNthubcuMXP+QGJA5o6jNfpvM8mGcZR8tO8J7Kq+pKv8AdtkRHuj" - + "HVuenB5sdgKR5hJB7cOqQBush+6i+yA4dFWbt1vblABGCueJYw7/czhQx4iO6JEx" - + "P2TZaFq7+SuvIdEOB7uMwnPIQFv1ukBcx8eiWspK0qsKeIpqDVwaypJLgqKEOL9U" - + "0YRXxeH1XjxBWGipvRhmo4C8NYt9Lwt1FUh9nEwjmXSapaA0zUO2pLpzy3rdIGW9" - + "gdRfKvNie0w8jwuvgzMY9t3u04MHyKQ2h1NIOXrOfZk/dOrgpUpRqG1bPhS/El1s" - + "cwZglmVX6PU4fItXFkQpR+WxQpVncOlS/e4ac3RYXAq/ch84vQ+vXRaWruNB9nSy" - + "y1d/bwJWtF1I0ZWE+nExyWdlUBp89dIrYSFw/cfwark615ROE1akA7wU68Y5K7HO" - + "99t4V9NwleGhfQ2mf94QjkfVyszYsrCBqSWhrGYTQ6JoTKquR0Xz6vZnMmUvaUK1" - + "Ddv96lmfWBSIJ/urWMSRL75jIH5bYNnx5gAyorXqEKJAtt1yGftZYUXaOOfHvXJc" - + "FOlXIGAF9EtmaPnefC9HSTmnrNSJEB9u+hiaXBzVkI2oJG/GM6aLOTdYyMDC8fXw" - + "30h0j+cp4IhoYythftmQZ1rz9oVZOZgIQJjViYwPHY2gOE/BZ+bBKjtdZ4cDYOHS" - + "9g3DrtexeLpjmWSqITa+x/KV8KWmE0FMcsDauKNVILFs607F9hqd+4azfqhtpT8Q" - + "0u84RgoVrmFIajhaNl5+06KVGCRAkmwQkxYHiY8SkuPTo4dh0/9AycqMODL5Zjh6" - + "a6MHpGSGG+WXMSUwIwYJKoZIhvcNAQkVMRYEFHO0MZzfOOB5cIRTXZwC/QTUsrLm" - + "MEEwMTANBglghkgBZQMEAgEFAAQguefMRfuN/2S1v8baZNWXyR/9lVxdKylJSNnO" + "ULN2mZ4ECN9bsOpidibOAgIIAA=="; - - public static final String FAKE_PEM_CERTIFICATE - = "-----BEGIN CERTIFICATE-----\n" + "MIIDqzCCApMCFC+MROpib4t03Wqzgkcod1lad6JtMA0GCSqGSIb3DQEBCwUAMIGR\n" - + "MQswCQYDVQQGEwJVUzELMAkGA1UECAwCV0ExEDAOBgNVBAcMB1JlZG1vbmQxEjAQ\n" - + "BgNVBAoMCU1pY3Jvc29mdDESMBAGA1UECwwJQXp1cmUgU0RLMRIwEAYDVQQDDAlB\n" - + "enVyZSBTREsxJzAlBgkqhkiG9w0BCQEWGG9wZW5zb3VyY2VAbWljcm9zb2Z0LmNv\n" - + "bTAeFw0yMDAyMTQyMzE3MTZaFw0yNTAyMTIyMzE3MTZaMIGRMQswCQYDVQQGEwJV\n" - + "UzELMAkGA1UECAwCV0ExEDAOBgNVBAcMB1JlZG1vbmQxEjAQBgNVBAoMCU1pY3Jv\n" - + "c29mdDESMBAGA1UECwwJQXp1cmUgU0RLMRIwEAYDVQQDDAlBenVyZSBTREsxJzAl\n" - + "BgkqhkiG9w0BCQEWGG9wZW5zb3VyY2VAbWljcm9zb2Z0LmNvbTCCASIwDQYJKoZI\n" - + "hvcNAQEBBQADggEPADCCAQoCggEBANwCTuK0OnFc8UytzzCIB5pUWqWCMZA8kWO1\n" - + "Es84wOVupPTZHNDWKI57prj0CB5JP2yU8BkIFjhkV/9wc2KLjKwu7xaJTwBZF/i0\n" - + "t8dPBbgiEUmK6xdbJsLXoef/XZ5AmvCKb0mimEMvL8KgeF5OHuZJuYO0zCiRNVtp\n" - + "ZYSx2R73qhgy5klDHh346qQd5T+KbsdK3DArilT86QO1GrpBWl1GPvHJ3VZ1OO33\n" - + "iFWfyEVgwdAtMAkWXH8Eh1/MpPE8WQk5X5pdVEu+RJLLrVbgr+cnlVzfirSVLRar\n" - + "KZROAB3e2x8JdSqylnar/WWK11NERdiKaZr3WxAkceuVkTsKmRkCAwEAATANBgkq\n" - + "hkiG9w0BAQsFAAOCAQEAYLfk2dBcW1mJbkVYx80ogDUy/xX3d+uuop2gZwUXuzWY\n" - + "I4uXzSEsY37/+NKzOX6PtET3X6xENDW7AuJhTuWmTGZtPB1AjiVKLIgRwugV3Ovr\n" - + "1DoPBIvS7iCHGGcsr7tAgYxiVATlIcczCxQG1KPhrrLSUDxkbiyUHpyroExHGBeC\n" - + "UflT2BIO+TZ+44aYfO7vuwpu0ajfB6Rs0s/DM+uUTWCfsVvyPenObHz5HF2vxf75\n" - + "y8pr3fYKuUvpJ45T0ZjiXyRpkBTDudU3vuYuyAP3PwO6F/ic7Rm9D1uzEI38Va+o\n" - + "6CUh4NJnpIZIBs7T+rPwhKrUuM7BEO0CL7VTh37UzA==\n" + "-----END CERTIFICATE-----\n" - + "-----BEGIN PRIVATE KEY-----\n" + "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDcAk7itDpxXPFM\n" - + "rc8wiAeaVFqlgjGQPJFjtRLPOMDlbqT02RzQ1iiOe6a49AgeST9slPAZCBY4ZFf/\n" - + "cHNii4ysLu8WiU8AWRf4tLfHTwW4IhFJiusXWybC16Hn/12eQJrwim9JophDLy/C\n" - + "oHheTh7mSbmDtMwokTVbaWWEsdke96oYMuZJQx4d+OqkHeU/im7HStwwK4pU/OkD\n" - + "tRq6QVpdRj7xyd1WdTjt94hVn8hFYMHQLTAJFlx/BIdfzKTxPFkJOV+aXVRLvkSS\n" - + "y61W4K/nJ5Vc34q0lS0WqymUTgAd3tsfCXUqspZ2q/1litdTREXYimma91sQJHHr\n" - + "lZE7CpkZAgMBAAECggEAMRfSwoO1BtbWgWXHdezkxWtNTuFebfEWAEnHiLYBVTD7\n" - + "XieUZoVjR2gQK/VIWnm9zVzutqc3Th4WBMny9WpuWX2fnEfHeSxoTPcGi1L207/G\n" - + "W8LD8tJEM/YqCrrRCR8hc8twSd4eW9+LqMJmGaUVAA4zd1BAvkyou10pahLFgEMZ\n" - + "nlYxOzz0KrniNIdQxhwfaXZYUzX5ooJYtgY74vnSOHQhepRt5HY9B7iZ6jm/3ulA\n" - + "aJnfNbQ8YDYTS0R+OGv8RXU/jLCm5+TPwx0XFwZ6vRtWwWUUxhLV77Re9GP1xIx9\n" - + "VnYm9W3RyOm/KD9keQMTWKT0bLGB8fC6kj2mvbjgAQKBgQDzh5sy7q9RA+GqprC8\n" - + "8aUmkaTMXNahPPPJoLOflJ/+QlOt6YZUIn55vmicVsvFzr9hbxdTW7aQS91iAu05\n" - + "swEyltsR0my7FXsHZnN4SBct2FimAzMLTWQr10vLLRoSR5CNpUdoXGWFOAa3LKrZ\n" - + "aPJEM1hA3h2XDfZ7Gtxjg4ypIQKBgQDnRl9pGwd83MkoxT4CiZvNbvdBg4lXlHcA\n" - + "JoZ9OfoOey+7WRsOFsMvQapXf+JlvixP0ldECXZyxifswvfmiR2oqYTeRbITderg\n" - + "mwjDjN571Ui0ls5HwCBE+/iZoNmQI5INAPqsQMXwW0rx4YNXHblsJ0qT+3yFNWOF\n" - + "m6STMH8Y+QKBgFai8JivB1nICrleMdQWF43gFIPLp2OXPpeFf0GPa1fWGtTtFifK\n" - + "WbpP/gFYc4f8pGMyVVcHcqxlAO5EYka7ovpvZqIxfRMVcj5QuVWaN/zMUcVFsBwe\n" - + "PTvHjSRL+FF2ejuaCAxdipRZOTJjRqivyDhxF72EB3zcr8pd5PfWLe1hAoGASJRO\n" - + "JvcDj4zeWDwmLLewvHTBhb7Y4DJIcjSk6jHCpr7ECQB6vB4qnO73nUQV8aYP0/EH\n" - + "z+NEV9qV9vhswd1wAFlKyFKJAxBzaI9e3becrrINghb9n4jM17lXmCbhgBmZoRkY\n" - + "kew18itERspl5HYAlc9y2SQIPOm3VNu2dza1/EkCgYEAlTMyL6arbtJJsygzVn8l\n" - + "gKHuURwp1cxf6hUuXKJ56xI/I1OZjMidZM0bYSznmK9SGNxlfNbIV8vNhQfiwR6t\n" - + "HyGypSRP+h9MS9E66boXyINaOClZqiCn0pI9aiIpl3D6EbT6e7+zKljT0XmZJduK\n" + "BkRGMfUngiT8oVyaMtZWYPM=\n" - + "-----END PRIVATE KEY-----"; - - public static final String FAKE_PEM_CERTIFICATE_FOR_MERGE - = "-----BEGIN CERTIFICATE-----\n" + "MIIDazCCAlOgAwIBAgIUYju9zymmCCF7rCaROzfZs0pNgmkwDQYJKoZIhvcNAQEL\n" - + "BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM\n" - + "GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0xOTA4MjgyMjU0MTNaFw0xOTA5\n" - + "MjcyMjU0MTNaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw\n" - + "HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggEiMA0GCSqGSIb3DQEB\n" - + "AQUAA4IBDwAwggEKAoIBAQD0YrMz5atoPmTTxLtCO69kM3E97bdjJgyAVZJS9mP3\n" - + "HQyHkFNb09eDeAAzcZLR5nYXX7yweowTWVcIe3k9+Z/tUeVrAlOVe2COaIHAUZIh\n" - + "jELq/u8257/8MqqbKXhsyrWNAVDyKndDgvbbgxNsUTbMoAe9BCL/5fzowsnPLaCI\n" - + "MCYRaQJUySbIoTmKi11hF09CFFSkL9nvfQODFyEde6JHPWrVRse2lioPLJeC9LoU\n" - + "GNNZnbqry+UbHp4vORPp6OQTqBTm1ZVWPzCuYuWUmEe27K7zghEJr/Yx0OLq9kI5\n" - + "H960CSOkdhsOTcBkORfhivSQnmOn2RnCPIEsUTzjwXNZAgMBAAGjUzBRMB0GA1Ud\n" - + "DgQWBBQIAunu6y1BmFSDfFNfTnqFggB0gzAfBgNVHSMEGDAWgBQIAunu6y1BmFSD\n" - + "fFNfTnqFggB0gzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAr\n" - + "+RM7gbqWRXnWJwE/hV/ZI2hXAhDN4RYQ4fWMJfg/E9wcLeqqRtJhXbqpJW08IZWp\n" - + "QKcWfrFcfZ3ZxVAi5Ey+iuvD2VeBf9v5RZI4c9JqswS9xG2A1x/BeGcUk1y/q9E5\n" - + "4whf5fLSJQVxK+C53yemoHPrBg8zVhLJv5SG7Uw7jcqiQvu2aHGGWPLiO7mmMPtP\n" - + "qO/I+6FjXuBpNomTqM897MY3Qzg43rpoCilpOpkRtMHknfhFxt05p+Fn73Fb60ru\n" - + "ZsFRA52lsEBxGmI0QmXGjwkUZFwQTXEDUWwId3VJxoHRZwv1gmHfwhkYt+mNWJDa\n" + "mU7AMDzlQRwGC8hpWJRT\n" - + "-----END CERTIFICATE-----\n" + "-----BEGIN RSA PRIVATE KEY-----\n" - + "MIIEpQIBAAKCAQEA9GKzM+WraD5k08S7QjuvZDNxPe23YyYMgFWSUvZj9x0Mh5BT\n" - + "W9PXg3gAM3GS0eZ2F1+8sHqME1lXCHt5Pfmf7VHlawJTlXtgjmiBwFGSIYxC6v7v\n" - + "Nue//DKqmyl4bMq1jQFQ8ip3Q4L224MTbFE2zKAHvQQi/+X86MLJzy2giDAmEWkC\n" - + "VMkmyKE5iotdYRdPQhRUpC/Z730DgxchHXuiRz1q1UbHtpYqDyyXgvS6FBjTWZ26\n" - + "q8vlGx6eLzkT6ejkE6gU5tWVVj8wrmLllJhHtuyu84IRCa/2MdDi6vZCOR/etAkj\n" - + "pHYbDk3AZDkX4Yr0kJ5jp9kZwjyBLFE848FzWQIDAQABAoIBAHrhegv5SrOy083r\n" - + "mODX0/wFJcam1dRD2HtbC6UtgNxLPfaYKmH85duUJj23uMRUJkLgf6cZJ3+/J1T7\n" - + "iN4Ru0mAKWQiGlcKX2WbxMon+dtmhGtW3n90DgPIkiJMuuGxF5Kb+9CYa7mFi4ya\n" - + "ntSTDYPcX6e6AcM8KGv9La4/2f0/hQKCN3jZbnQ/GqjnJdxrAV1KV0IMoNPpZmat\n" - + "Sa0EZ9eiR57/xAe1OxceEt0nO7hAl+jX7tFEGvaNClKG2OMgZ+oHOxI+s9jW8DyD\n" - + "wRJbd0hxUl/KXLxzyeFTBdLxB+SQtlcr4w5khyt3AvlKd4Iveqkq2FBCtfATYitt\n" - + "+Ic61IUCgYEA/j4mMdo+qokzACmGJWEquC6yNoUI5aYsHTRVvX0sLpBX7MapIEwM\n" - + "zHdvMEFBxw8rs7ll1xELW+dnbIZqj/ou43E3+PSgovdFGOA8kQlPpcIIutTEZQh7\n" - + "dlWzvAVZr0iO4xfXY2gFQot41fY4yRy8Q14ayo/VjQK4uKlnGqqlmwsCgYEA9hMc\n" - + "FIAYpit7779tKD+O4vEkMoTkIxqSAZUuOZ5qB5UaF4Y/+MIGZUnrjJlGLnoFQmsP\n" - + "CVPVMOQKV7yjg0LBadeDHEjESwHJNk0qxPSXWuXGlu01yVkqUehNumSBdnSLBmjR\n" - + "jNIxPVEmW9d6+eAzIFiTkwqM9cAuLb75DL++iasCgYEAxhqzNEE0dzl0zfmNF29B\n" - + "FEb+glDi/96dnRv8eywf0yCSAmNBwXLAvkmKD/WpRWxixyX9XrlfOntzMTMDsbBl\n" - + "/L9pt8kVqiY2Zw3C49h3gVdR6hKD/Z3AZhKdfDJHEbfd7sHTCRgykQmQXFgBI2QK\n" - + "pguboJ627atjODB3sGWrqMUCgYEA2QoJ3lsNYqM/8TpaQQGuOaSPVK+5uOyakyLN\n" - + "XqzGwGFWXiFfEz2u/m+wfpZCPIQLV4WuAYAbrb+1D6WmYwPiLESVs8DKwY2Vt3tg\n" - + "mc9SIC5CdqRKqIkoto264Qf82En6xXB2Q0qxe2+z8ZWhNfv1nDYEE9FeevNCx76F\n" - + "VCVbHXkCgYEA4+FD1q6iwl9wsAOKFVo+W044/MhKHDsyIED3YOzeRTAWRl2w/KX0\n" - + "c5ty2KecGu0cVXoAv2YUttHsuMZfm/QdosZr9UB4CR2lmzRys3LSx6QzCkZeMb/s\n" - + "QOMs6SYCPXggdXCAu9EVf5+TtYQg7aQNTTuYErlyq2g/tk3un8bHTwI=\n" + "-----END RSA PRIVATE KEY-----"; -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/KeyVaultCredentialPolicyTest.java b/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/KeyVaultCredentialPolicyTest.java deleted file mode 100644 index f9b26586cf60..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/KeyVaultCredentialPolicyTest.java +++ /dev/null @@ -1,661 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates; - -import com.azure.core.credential.AccessToken; -import com.azure.core.credential.TokenCredential; -import com.azure.core.credential.TokenRequestContext; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpHeaders; -import com.azure.core.http.HttpMethod; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.HttpPipelineBuilder; -import com.azure.core.http.HttpPipelineCallContext; -import com.azure.core.http.HttpRequest; -import com.azure.core.http.HttpResponse; -import com.azure.core.test.SyncAsyncExtension; -import com.azure.core.test.annotation.SyncAsyncTest; -import com.azure.core.test.http.MockHttpResponse; -import com.azure.core.util.Base64Util; -import com.azure.core.util.BinaryData; -import com.azure.core.util.Context; -import com.azure.security.keyvault.certificates.implementation.KeyVaultCredentialPolicy; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.parallel.Execution; -import org.junit.jupiter.api.parallel.ExecutionMode; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; - -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Random; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Function; -import java.util.stream.Stream; - -import static com.azure.core.http.HttpHeaderName.AUTHORIZATION; -import static com.azure.core.util.CoreUtils.isNullOrEmpty; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; - -@Execution(ExecutionMode.SAME_THREAD) -public class KeyVaultCredentialPolicyTest { - private static final String AUTHENTICATE_HEADER - = "Bearer authorization=\"https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd022db57\", " - + "resource=\"https://vault.azure.net\""; - private static final String AUTHENTICATE_HEADER_WITH_CLAIMS - = "Bearer realm=\"\", authorization_uri=\"https://login.microsoftonline.com/common/oauth2/authorize\", " - + "error=\"insufficient_claims\", " - + "claims=\"eyJhY2Nlc3NfdG9rZW4iOnsiYWNycyI6eyJlc3NlbnRpYWwiOnRydWUsInZhbHVlIjoiY3AxIn19fQ==\""; - private static final String DECODED_CLAIMS = "{\"access_token\":{\"acrs\":{\"essential\":true,\"value\":\"cp1\"}}}"; - private static final String BEARER = "Bearer"; - private static final String BODY = "this is a sample body"; - private static final Flux BODY_FLUX = Flux.defer( - () -> Flux.fromStream(Stream.of(BODY.split("")).map(s -> ByteBuffer.wrap(s.getBytes(StandardCharsets.UTF_8))))); - private static final String FAKE_ENCODED_CREDENTIAL - = Base64Util.encodeToString("user:fakePasswordPlaceholder".getBytes(StandardCharsets.UTF_8)); - private static final List> BASE_ASSERTIONS = Arrays.asList( - tokenRequestContext -> !tokenRequestContext.getScopes().isEmpty(), - tokenRequestContext -> !isNullOrEmpty(tokenRequestContext.getTenantId()), TokenRequestContext::isCaeEnabled); - - private HttpResponse simpleResponse; - private HttpResponse unauthorizedHttpResponseWithWrongStatusCode; - private HttpResponse unauthorizedHttpResponseWithHeader; - private HttpResponse unauthorizedHttpResponseWithoutHeader; - private HttpResponse unauthorizedHttpResponseWithHeaderAndClaims; - private HttpPipelineCallContext callContext; - private HttpPipelineCallContext differentScopeContext; - private HttpPipelineCallContext testContext; - private HttpPipelineCallContext bodyContext; - private HttpPipelineCallContext bodyFluxContext; - private TokenCredential credential; - - private static HttpPipelineCallContext createCallContext(HttpRequest request, Context context) { - AtomicReference callContextReference = new AtomicReference<>(); - - HttpPipeline callContextCreator = new HttpPipelineBuilder().policies((callContext, next) -> { - callContextReference.set(callContext); - - return next.process(); - }).httpClient(ignored -> Mono.empty()).build(); - - callContextCreator.sendSync(request, context); - - return callContextReference.get(); - } - - @BeforeEach - public void setup() { - HttpRequest request = new HttpRequest(HttpMethod.GET, "https://kvtest.vault.azure.net"); - HttpRequest requestWithDifferentScope = new HttpRequest(HttpMethod.GET, "https://mytest.azurecr.io"); - - Context bodyContextContext = new Context("KeyVaultCredentialPolicyStashedBody", BinaryData.fromString(BODY)) - .addData("KeyVaultCredentialPolicyStashedContentLength", "21"); - - Context bodyFluxContextContext = new Context("KeyVaultCredentialPolicyStashedBody", BODY_FLUX) - .addData("KeyVaultCredentialPolicyStashedContentLength", "21"); - - MockHttpResponse simpleResponse - = new MockHttpResponse(new HttpRequest(HttpMethod.GET, "https://azure.com"), 200); - - MockHttpResponse unauthorizedResponseWithWrongStatusCode - = new MockHttpResponse(new HttpRequest(HttpMethod.GET, "https://azure.com"), 500); - - MockHttpResponse unauthorizedResponseWithoutHeader - = new MockHttpResponse(new HttpRequest(HttpMethod.GET, "https://azure.com"), 401); - - MockHttpResponse unauthorizedResponseWithHeader - = new MockHttpResponse(new HttpRequest(HttpMethod.GET, "https://azure.com"), 401, - new HttpHeaders().set(HttpHeaderName.WWW_AUTHENTICATE, AUTHENTICATE_HEADER)); - - MockHttpResponse unauthorizedResponseWithHeaderAndClaims - = new MockHttpResponse(new HttpRequest(HttpMethod.GET, "https://azure.com"), 401, - new HttpHeaders().set(HttpHeaderName.WWW_AUTHENTICATE, AUTHENTICATE_HEADER_WITH_CLAIMS)); - - this.simpleResponse = simpleResponse; - this.unauthorizedHttpResponseWithWrongStatusCode = unauthorizedResponseWithWrongStatusCode; - this.unauthorizedHttpResponseWithHeader = unauthorizedResponseWithHeader; - this.unauthorizedHttpResponseWithoutHeader = unauthorizedResponseWithoutHeader; - this.unauthorizedHttpResponseWithHeaderAndClaims = unauthorizedResponseWithHeaderAndClaims; - this.callContext = createCallContext(request, Context.NONE); - this.differentScopeContext = createCallContext(requestWithDifferentScope, Context.NONE); - this.testContext = createCallContext(request, Context.NONE); - this.bodyContext = createCallContext(request, bodyContextContext); - this.bodyFluxContext = createCallContext(request, bodyFluxContextContext); - // Can't use BasicAuthenticationCredential until the following PR is merged: - // https://github.com/Azure/azure-sdk-for-java/pull/42238 - this.credential = tokenRequestContext -> Mono - .fromCallable(() -> new AccessToken(FAKE_ENCODED_CREDENTIAL, OffsetDateTime.MAX.minusYears(1))); - } - - @AfterEach - public void cleanup() { - KeyVaultCredentialPolicy.clearCache(); - } - - @SyncAsyncTest - public void onNon401ErrorResponse() { - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(this.credential, false); - - HttpPipeline pipeline = new HttpPipelineBuilder().policies(policy) - .httpClient(ignored -> Mono.just(unauthorizedHttpResponseWithWrongStatusCode)) - .build(); - - SyncAsyncExtension.execute( - () -> pipeline.sendSync(this.callContext.getHttpRequest(), this.callContext.getContext()), - () -> pipeline.send(this.callContext.getHttpRequest(), this.callContext.getContext())); - - assertNull(this.callContext.getHttpRequest().getHeaders().get(AUTHORIZATION)); - - KeyVaultCredentialPolicy.clearCache(); - } - - @SyncAsyncTest - public void on401UnauthorizedResponseWithHeader() { - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(this.credential, false); - - HttpPipeline pipeline = new HttpPipelineBuilder().policies(policy) - .httpClient(ignored -> Mono.just(unauthorizedHttpResponseWithHeader)) - .build(); - - SyncAsyncExtension.execute( - () -> pipeline.sendSync(this.callContext.getHttpRequest(), this.callContext.getContext()), - () -> pipeline.send(this.callContext.getHttpRequest(), this.callContext.getContext())); - - assertNotNull(this.callContext.getHttpRequest().getHeaders().get(AUTHORIZATION)); - - KeyVaultCredentialPolicy.clearCache(); - } - - @SyncAsyncTest - public void onChallengeCredentialPolicy() { - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(this.credential, false); - - boolean onChallenge = SyncAsyncExtension.execute( - () -> onChallengeAndClearCacheSync(policy, this.callContext, this.unauthorizedHttpResponseWithHeader), - () -> onChallengeAndClearCache(policy, this.callContext, this.unauthorizedHttpResponseWithHeader)); - - // Validate that the onChallengeSync ran successfully. - assertTrue(onChallenge); - - String tokenValue = this.callContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - assertFalse(tokenValue.isEmpty()); - assertTrue(tokenValue.startsWith(BEARER)); - } - - @Test - public void onAuthorizeRequestChallengeCachePresent() { - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(this.credential, false); - - StepVerifier.create(onChallengeAndClearCache(policy, this.callContext, unauthorizedHttpResponseWithHeader) // Challenge cache created - .then(policy.authorizeRequest(this.testContext))) // Challenge cache used - .verifyComplete(); - - String tokenValue = this.testContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - assertFalse(tokenValue.isEmpty()); - assertTrue(tokenValue.startsWith(BEARER)); - } - - @Test - public void onAuthorizeRequestChallengeCachePresentSync() { - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(this.credential, false); - - // Challenge cache created - onChallengeAndClearCacheSync(policy, this.callContext, unauthorizedHttpResponseWithHeader); - // Challenge cache used - policy.authorizeRequestSync(this.testContext); - - String tokenValue = this.testContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - assertFalse(tokenValue.isEmpty()); - assertTrue(tokenValue.startsWith(BEARER)); - } - - @Test - public void onAuthorizeRequestChallengeCachePresentWithClaims() { - MutableTestCredential testCredential = new MutableTestCredential(new ArrayList<>(BASE_ASSERTIONS)) - .addAssertion(tokenRequestContext -> tokenRequestContext.getClaims() == null); - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(testCredential, false); - - StepVerifier.create(policy.authorizeRequestOnChallenge(this.callContext, // Challenge cache created - this.unauthorizedHttpResponseWithHeader).flatMap(authorized -> { - if (authorized) { - String firstToken = this.testContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - - assertFalse(firstToken.isEmpty()); - assertTrue(firstToken.startsWith(BEARER)); - - testCredential.replaceAssertion( - tokenRequestContext -> DECODED_CLAIMS.equals(tokenRequestContext.getClaims()), 3); - - return policy.authorizeRequestOnChallenge(this.callContext, // Challenge with claims received - this.unauthorizedHttpResponseWithHeaderAndClaims).map(ignored -> firstToken); - } else { - return Mono.just(""); - } - })).assertNext(firstToken -> { - String newToken = this.testContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - - assertFalse(newToken.isEmpty()); - assertTrue(newToken.startsWith(BEARER)); - - assertNotEquals(firstToken, newToken); - }).verifyComplete(); - - KeyVaultCredentialPolicy.clearCache(); - } - - @Test - public void onAuthorizeRequestChallengeNoCachePresentWithClaims() { - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(this.credential, false); - - StepVerifier.create(policy.authorizeRequestOnChallenge(this.callContext, // Challenge cache created - this.unauthorizedHttpResponseWithHeaderAndClaims)).assertNext(result -> { - assertFalse(result); - assertNull(this.testContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION)); - }).verifyComplete(); - - KeyVaultCredentialPolicy.clearCache(); - } - - @Test - public void onAuthorizeRequestChallengeCachePresentWithClaimsSync() { - MutableTestCredential testCredential = new MutableTestCredential(new ArrayList<>(BASE_ASSERTIONS)) - .addAssertion(tokenRequestContext -> tokenRequestContext.getClaims() == null); - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(testCredential, false); - - // Challenge cache created - assertTrue(policy.authorizeRequestOnChallengeSync(this.callContext, this.unauthorizedHttpResponseWithHeader)); - - String firstToken = this.testContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - - assertFalse(firstToken.isEmpty()); - assertTrue(firstToken.startsWith(BEARER)); - - testCredential.replaceAssertion(tokenRequestContext -> DECODED_CLAIMS.equals(tokenRequestContext.getClaims()), - 3); - - // Challenge with claims received - assertTrue( - policy.authorizeRequestOnChallengeSync(this.callContext, this.unauthorizedHttpResponseWithHeaderAndClaims)); - - String newToken = this.testContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - - assertFalse(newToken.isEmpty()); - assertTrue(newToken.startsWith(BEARER)); - - assertNotEquals(firstToken, newToken); - - KeyVaultCredentialPolicy.clearCache(); - } - - @Test - public void onAuthorizeRequestChallengeNoCachePresentWithClaimsSync() { - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(this.credential, false); - - // Challenge with claims received - assertFalse( - policy.authorizeRequestOnChallengeSync(this.callContext, this.unauthorizedHttpResponseWithHeaderAndClaims)); - assertNull(this.testContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION)); - - KeyVaultCredentialPolicy.clearCache(); - } - - @SyncAsyncTest - public void onAuthorizeRequestNoCache() { - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(this.credential, false); - - // No challenge cache to use - SyncAsyncExtension.execute(() -> policy.authorizeRequestSync(this.callContext), - () -> policy.authorizeRequest(this.callContext)); - - assertNull(this.callContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION)); - } - - @SyncAsyncTest - public void testSetContentLengthHeader() { - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(this.credential, false); - - boolean onChallenge = SyncAsyncExtension.execute( - () -> onChallengeAndClearCacheSync(policy, this.bodyContext, this.unauthorizedHttpResponseWithHeader), - () -> onChallengeAndClearCache(policy, this.bodyFluxContext, this.unauthorizedHttpResponseWithHeader)); - - // Validate that the onChallengeSync ran successfully. - assertTrue(onChallenge); - - HttpHeaders headers = this.bodyFluxContext.getHttpRequest().getHeaders(); - String tokenValue = headers.getValue(AUTHORIZATION); - assertFalse(tokenValue.isEmpty()); - assertTrue(tokenValue.startsWith(BEARER)); - assertEquals("21", headers.getValue(HttpHeaderName.CONTENT_LENGTH)); - - HttpHeaders syncHeaders = this.bodyContext.getHttpRequest().getHeaders(); - String syncTokenValue = headers.getValue(AUTHORIZATION); - assertFalse(syncTokenValue.isEmpty()); - assertTrue(syncTokenValue.startsWith(BEARER)); - assertEquals("21", syncHeaders.getValue(HttpHeaderName.CONTENT_LENGTH)); - } - - @SyncAsyncTest - public void onAuthorizeRequestNoScope() { - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(this.credential, false); - - boolean onChallenge = SyncAsyncExtension.execute( - () -> onChallengeAndClearCacheSync(policy, this.callContext, this.unauthorizedHttpResponseWithoutHeader), - () -> onChallengeAndClearCache(policy, this.callContext, this.unauthorizedHttpResponseWithoutHeader)); - - assertFalse(onChallenge); - } - - @Test - public void onAuthorizeRequestDifferentScope() { - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(this.credential, false); - - assertThrows(RuntimeException.class, () -> onChallengeAndClearCacheSync(policy, this.differentScopeContext, - this.unauthorizedHttpResponseWithHeader)); - - StepVerifier - .create( - onChallengeAndClearCache(policy, this.differentScopeContext, this.unauthorizedHttpResponseWithHeader)) - .verifyErrorMessage("The challenge resource 'https://vault.azure.net/.default' does not match the " - + "requested domain. If you wish to disable this check for your client, pass 'true' to the " - + "SecretClientBuilder.disableChallengeResourceVerification() method when building it. See " - + "https://aka.ms/azsdk/blog/vault-uri for more information."); - } - - @SyncAsyncTest - public void onAuthorizeRequestDifferentScopeVerifyFalse() { - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(this.credential, true); - - boolean onChallenge = SyncAsyncExtension.execute( - () -> onChallengeAndClearCacheSync(policy, this.differentScopeContext, - this.unauthorizedHttpResponseWithHeader), - () -> onChallengeAndClearCache(policy, this.differentScopeContext, - this.unauthorizedHttpResponseWithHeader)); - - assertTrue(onChallenge); - } - - // Normal flow: 401 Unauthorized -> 200 OK -> 401 Unauthorized with claims -> 200 OK - @SyncAsyncTest - public void processMultipleResponses() { - MutableTestCredential testCredential = new MutableTestCredential(new ArrayList<>(BASE_ASSERTIONS)) - .addAssertion(tokenRequestContext -> tokenRequestContext.getClaims() == null); - HttpResponse[] responses = new HttpResponse[] { - unauthorizedHttpResponseWithHeader, - simpleResponse, - unauthorizedHttpResponseWithHeaderAndClaims, - simpleResponse }; - AtomicInteger currentResponse = new AtomicInteger(); - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(testCredential, false); - - HttpPipeline pipeline = new HttpPipelineBuilder().policies(policy) - .httpClient(ignored -> Mono.just(responses[currentResponse.getAndIncrement()])) - .build(); - - // The first request to a Key Vault endpoint without an access token will always return a 401 Unauthorized - // response with a WWW-Authenticate header containing an authentication challenge. - - HttpResponse firstResponse = SyncAsyncExtension.execute( - () -> pipeline.sendSync(this.callContext.getHttpRequest(), this.callContext.getContext()), - () -> pipeline.send(this.callContext.getHttpRequest(), this.callContext.getContext())); - - String firstToken = this.callContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - - // The first response was unauthorized and a token was set on the request. - assertNotNull(firstToken); - // On a second attempt, a successful response was received. - assertEquals(simpleResponse, firstResponse); - - testCredential.replaceAssertion(tokenRequestContext -> DECODED_CLAIMS.equals(tokenRequestContext.getClaims()), - 3); - - // On receiving an unauthorized response with claims, the token should be updated and a new attempt to make the - // original request should be made. - - HttpResponse newResponse = SyncAsyncExtension.execute( - () -> pipeline.sendSync(this.callContext.getHttpRequest(), this.callContext.getContext()), - () -> pipeline.send(this.callContext.getHttpRequest(), this.callContext.getContext())); - - String newToken = this.callContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - - // A new token was fetched using the response with claims and set on the request. - assertNotNull(newToken); - // The token was updated. - assertNotEquals(firstToken, newToken); - // A subsequent request was successful. - assertEquals(simpleResponse, newResponse); - - KeyVaultCredentialPolicy.clearCache(); - } - - // Edge case: 401 Unauthorized -> 200 OK -> 401 Unauthorized with claims -> 401 Unauthorized with claims - @SyncAsyncTest - public void processConsecutiveResponsesWithClaims() { - MutableTestCredential testCredential = new MutableTestCredential(new ArrayList<>(BASE_ASSERTIONS)) - .addAssertion(tokenRequestContext -> tokenRequestContext.getClaims() == null); - HttpResponse[] responses = new HttpResponse[] { - unauthorizedHttpResponseWithHeader, - simpleResponse, - unauthorizedHttpResponseWithHeaderAndClaims, - // If a second consecutive unauthorized response with claims is received, it shall be returned as is. - unauthorizedHttpResponseWithHeaderAndClaims, }; - AtomicInteger currentResponse = new AtomicInteger(); - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(testCredential, false); - - HttpPipeline pipeline = new HttpPipelineBuilder().policies(policy) - .httpClient(ignored -> Mono.just(responses[currentResponse.getAndIncrement()])) - .build(); - - // The first request to a Key Vault endpoint without an access token will always return a 401 Unauthorized - // response with a WWW-Authenticate header containing an authentication challenge. - - HttpResponse firstResponse = SyncAsyncExtension.execute( - () -> pipeline.sendSync(this.callContext.getHttpRequest(), this.callContext.getContext()), - () -> pipeline.send(this.callContext.getHttpRequest(), this.callContext.getContext())); - - String firstToken = this.callContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - - // The first response was unauthorized and a token was set on the request - assertNotNull(firstToken); - // On a second attempt, a successful response was received. - assertEquals(simpleResponse, firstResponse); - - testCredential.replaceAssertion(tokenRequestContext -> DECODED_CLAIMS.equals(tokenRequestContext.getClaims()), - 3); - - HttpResponse newResponse = SyncAsyncExtension.execute( - () -> pipeline.sendSync(this.callContext.getHttpRequest(), this.callContext.getContext()), - () -> pipeline.send(this.callContext.getHttpRequest(), this.callContext.getContext())); - - String newToken = this.callContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - - // A new token was fetched using the first response with claims and set on the request - assertNotEquals(firstToken, newToken); - // A subsequent request was unsuccessful. - assertEquals(unauthorizedHttpResponseWithHeaderAndClaims, newResponse); - - KeyVaultCredentialPolicy.clearCache(); - } - - // Edge case: 401 Unauthorized -> 200 OK -> 401 Unauthorized with claims -> 401 Unauthorized - @SyncAsyncTest - public void process401WithoutClaimsAfter401WithClaims() { - MutableTestCredential testCredential = new MutableTestCredential(new ArrayList<>(BASE_ASSERTIONS)) - .addAssertion(tokenRequestContext -> tokenRequestContext.getClaims() == null); - HttpResponse[] responses = new HttpResponse[] { - unauthorizedHttpResponseWithHeader, - simpleResponse, - unauthorizedHttpResponseWithHeaderAndClaims, - // If a second consecutive unauthorized response is received, it shall be returned as is. - unauthorizedHttpResponseWithHeader }; - AtomicInteger currentResponse = new AtomicInteger(); - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(testCredential, false); - - HttpPipeline pipeline = new HttpPipelineBuilder().policies(policy) - .httpClient(ignored -> Mono.just(responses[currentResponse.getAndIncrement()])) - .build(); - - // The first request to a Key Vault endpoint without an access token will always return a 401 Unauthorized - // response with a WWW-Authenticate header containing an authentication challenge. - - HttpResponse firstResponse = SyncAsyncExtension.execute( - () -> pipeline.sendSync(this.callContext.getHttpRequest(), this.callContext.getContext()), - () -> pipeline.send(this.callContext.getHttpRequest(), this.callContext.getContext())); - - String firstToken = this.callContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - - // The first response was unauthorized and a token was set on the request - assertNotNull(firstToken); - // On a second attempt, a successful response was received. - assertEquals(simpleResponse, firstResponse); - - testCredential.replaceAssertion(tokenRequestContext -> DECODED_CLAIMS.equals(tokenRequestContext.getClaims()), - 3); - - HttpResponse newResponse = SyncAsyncExtension.execute( - () -> pipeline.sendSync(this.callContext.getHttpRequest(), this.callContext.getContext()), - () -> pipeline.send(this.callContext.getHttpRequest(), this.callContext.getContext())); - - String newToken = this.callContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - - // A new token was fetched using the first response with claims and set on the request - assertNotEquals(firstToken, newToken); - // A subsequent request was unsuccessful. - assertEquals(unauthorizedHttpResponseWithHeader, newResponse); - - KeyVaultCredentialPolicy.clearCache(); - } - - // Edge case: 401 Unauthorized -> 401 Unauthorized with claims -> 200 OK - @SyncAsyncTest - public void process401WithClaimsAfter401WithoutClaims() { - MutableTestCredential testCredential = new MutableTestCredential(new ArrayList<>(BASE_ASSERTIONS)); - final String[] firstToken = new String[1]; - - testCredential.addAssertion(tokenRequestContext -> { - // This will ensure that that the first request does not contains claims, but the second does after - // receiving a 401 response with a challenge with claims. - testCredential.replaceAssertion( - anotherTokenRequestContext -> DECODED_CLAIMS.equals(anotherTokenRequestContext.getClaims()), 3); - - // We will also store the value of the first credential before it changes on a second call - firstToken[0] = Base64Util.encodeToString(testCredential.getCredential().getBytes(StandardCharsets.UTF_8)); - - assertNotNull(firstToken[0]); - - return tokenRequestContext.getClaims() == null; - }); - - HttpResponse[] responses = new HttpResponse[] { - unauthorizedHttpResponseWithHeader, - unauthorizedHttpResponseWithHeaderAndClaims, - simpleResponse }; - AtomicInteger currentResponse = new AtomicInteger(); - KeyVaultCredentialPolicy policy = new KeyVaultCredentialPolicy(testCredential, false); - - HttpPipeline pipeline = new HttpPipelineBuilder().policies(policy) - .httpClient(ignored -> Mono.just(responses[currentResponse.getAndIncrement()])) - .build(); - - // The first request to a Key Vault endpoint without an access token will always return a 401 Unauthorized - // response with a WWW-Authenticate header containing an authentication challenge. - - HttpResponse firstResponse = SyncAsyncExtension.execute( - () -> pipeline.sendSync(this.callContext.getHttpRequest(), this.callContext.getContext()), - () -> pipeline.send(this.callContext.getHttpRequest(), this.callContext.getContext())); - - String newToken = this.callContext.getHttpRequest().getHeaders().getValue(AUTHORIZATION); - - // The first unauthorized response caused a token to be set on the request, then the token was updated on a - // subsequent unauthorized response with claims. - assertNotEquals(firstToken[0], newToken); - // Finally, a successful response was received. - assertEquals(simpleResponse, firstResponse); - - KeyVaultCredentialPolicy.clearCache(); - } - - private Mono onChallengeAndClearCache(KeyVaultCredentialPolicy policy, HttpPipelineCallContext callContext, - HttpResponse unauthorizedHttpResponse) { - Mono onChallenge = policy.authorizeRequestOnChallenge(callContext, unauthorizedHttpResponse); - - KeyVaultCredentialPolicy.clearCache(); - - return onChallenge; - } - - private boolean onChallengeAndClearCacheSync(KeyVaultCredentialPolicy policy, HttpPipelineCallContext callContext, - HttpResponse unauthorizedHttpResponse) { - boolean onChallengeSync = policy.authorizeRequestOnChallengeSync(callContext, unauthorizedHttpResponse); - - KeyVaultCredentialPolicy.clearCache(); - - return onChallengeSync; - } - - private static final class MutableTestCredential implements TokenCredential { - private String credential; - private List> assertions; - - private MutableTestCredential(List> assertions) { - this.credential = new Random().toString(); - this.assertions = assertions; - } - - /** - * @throws RuntimeException if any of the assertions fail. - */ - @Override - public Mono getToken(TokenRequestContext requestContext) { - if (requestContext.isCaeEnabled() && requestContext.getClaims() != null) { - credential = new Random().toString(); - } - - String encodedCredential = Base64Util.encodeToString(credential.getBytes(StandardCharsets.UTF_8)); - - for (int i = 0; i < assertions.size(); i++) { - if (!assertions.get(i).apply(requestContext)) { - return Mono.error(new RuntimeException(String.format("Assertion number %d failed", i))); - } - } - - return Mono.fromCallable(() -> new AccessToken(encodedCredential, OffsetDateTime.MAX.minusYears(1))); - } - - private MutableTestCredential setAssertions(List> assertions) { - this.assertions = assertions; - - return this; - } - - private MutableTestCredential addAssertion(Function assertion) { - assertions.add(assertion); - - return this; - } - - private MutableTestCredential replaceAssertion(Function assertion, int index) { - assertions.set(index, assertion); - - return this; - } - - private String getCredential() { - return this.credential; - } - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/TestUtils.java b/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/TestUtils.java deleted file mode 100644 index 1777ea6568e3..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/TestUtils.java +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.security.keyvault.certificates; - -import com.azure.core.credential.AccessToken; -import com.azure.core.credential.TokenCredential; -import com.azure.core.credential.TokenRequestContext; -import com.azure.core.http.HttpHeaderName; -import com.azure.core.http.HttpPipelineCallContext; -import com.azure.core.http.HttpPipelineNextPolicy; -import com.azure.core.http.HttpPipelinePosition; -import com.azure.core.http.HttpResponse; -import com.azure.core.http.policy.HttpPipelinePolicy; -import reactor.core.publisher.Mono; - -import java.time.OffsetDateTime; - -/** - * Common test utilities. - */ -public final class TestUtils { - private static final HttpHeaderName CUSTOMER_HEADER = HttpHeaderName.fromString("Custom-Header"); - - /** - * Private constructor so this class cannot be instantiated. - */ - private TestUtils() { - } - - static class PerCallPolicy implements HttpPipelinePolicy { - @Override - public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { - context.getHttpRequest().setHeader(CUSTOMER_HEADER, "Some Value"); - return next.process(); - } - - @Override - public HttpPipelinePosition getPipelinePosition() { - return HttpPipelinePosition.PER_CALL; - } - } - - static class PerRetryPolicy implements HttpPipelinePolicy { - @Override - public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { - context.getHttpRequest().setHeader(CUSTOMER_HEADER, "Some Value"); - return next.process(); - } - } - - static class TestCredential implements TokenCredential { - @Override - public Mono getToken(TokenRequestContext request) { - return Mono.just(new AccessToken("TestAccessToken", OffsetDateTime.now().plusHours(1))); - } - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificateIdentifierTest.java b/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificateIdentifierTest.java deleted file mode 100644 index 94aa0ac85dd9..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/models/KeyVaultCertificateIdentifierTest.java +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.certificates.models; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; - -class KeyVaultCertificateIdentifierTest { - @Test - void parseWithoutVersion() { - String sourceId = "https://test-key-vault.vault.azure.net/certificates/test-certificate"; - KeyVaultCertificateIdentifier keyVaultCertificateIdentifier = new KeyVaultCertificateIdentifier(sourceId); - - assertEquals(sourceId, keyVaultCertificateIdentifier.getSourceId()); - assertEquals("https://test-key-vault.vault.azure.net", keyVaultCertificateIdentifier.getVaultUrl()); - assertEquals("test-certificate", keyVaultCertificateIdentifier.getName()); - assertNull(keyVaultCertificateIdentifier.getVersion()); - } - - @Test - void parseWithVersion() { - String sourceId = "https://test-key-vault.vault.azure.net/certificates/test-certificate/version"; - KeyVaultCertificateIdentifier keyVaultCertificateIdentifier = new KeyVaultCertificateIdentifier(sourceId); - - assertEquals(sourceId, keyVaultCertificateIdentifier.getSourceId()); - assertEquals("https://test-key-vault.vault.azure.net", keyVaultCertificateIdentifier.getVaultUrl()); - assertEquals("test-certificate", keyVaultCertificateIdentifier.getName()); - assertEquals("version", keyVaultCertificateIdentifier.getVersion()); - } - - @Test - void parseForDeletedCertificate() { - String sourceId = "https://test-key-vault.vault.azure.net/deletedcertificates/test-certificate"; - KeyVaultCertificateIdentifier keyVaultCertificateIdentifier = new KeyVaultCertificateIdentifier(sourceId); - - assertEquals(sourceId, keyVaultCertificateIdentifier.getSourceId()); - assertEquals("https://test-key-vault.vault.azure.net", keyVaultCertificateIdentifier.getVaultUrl()); - assertEquals("test-certificate", keyVaultCertificateIdentifier.getName()); - } - - @Test - void parseNullIdentifier() { - assertThrows(NullPointerException.class, () -> new KeyVaultCertificateIdentifier(null)); - } - - @Test - void parseInvalidIdentifierWithExtraSegment() { - String sourceId = "https://test-key-vault.vault.azure.net/keys/test-certificate/version/extra-segment"; - assertThrows(IllegalArgumentException.class, () -> new KeyVaultCertificateIdentifier(sourceId)); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/test/resources/priv8.der b/sdk/keyvault/azure-security-keyvault-certificates/src/test/resources/priv8.der deleted file mode 100644 index 6a81a80099bd..000000000000 Binary files a/sdk/keyvault/azure-security-keyvault-certificates/src/test/resources/priv8.der and /dev/null differ diff --git a/sdk/keyvault/azure-security-keyvault-certificates/swagger/autorest.md b/sdk/keyvault/azure-security-keyvault-certificates/swagger/autorest.md deleted file mode 100644 index 20441620ce51..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/swagger/autorest.md +++ /dev/null @@ -1,187 +0,0 @@ -# Azure Key Vault Certificates for Java - -> see https://aka.ms/autorest - - -This is the Autorest configuration file for Key Vault Certificates. - ---- -## Getting Started -To build the SDK for Key Vault Certificates, simply [Install Autorest](https://aka.ms/autorest) and -in this folder, run: - -> `autorest` - -To see additional help and options, run: - -> `autorest --help` - -### Setup -```ps -npm install -g autorest -``` - -### Generation - -```ps -cd -autorest -``` - -## Configuration - -```yaml -use: '@autorest/java@4.1.42' -output-folder: ../ -java: true -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/8af9817c15d688c941cda106758045b5deb9a069/specification/keyvault/data-plane/Microsoft.KeyVault/preview/7.6-preview.1/certificates.json -title: CertificateClient -namespace: com.azure.security.keyvault.certificates -models-subpackage: implementation.models -custom-types-subpackage: models -custom-types: AdministratorContact,CertificateContact,CertificateKeyCurveName,CertificateKeyType,CertificateKeyUsage,CertificateOperationError,CertificatePolicyAction,SubjectAlternativeNames -customization-class: src/main/java/CertificatesCustomizations.java -enable-sync-stack: true -generate-client-as-impl: true -license-header: MICROSOFT_MIT_SMALL -disable-client-builder: true -directive: - - rename-model: - from: AdministratorDetails - to: AdministratorContact - - rename-model: - from: Contact - to: CertificateContact -``` - -### AdministratorContact EmailAddress -> Email -```yaml -directive: - - from: swagger-document - where: $.definitions.AdministratorContact - transform: > - delete $.properties.email["x-ms-client-name"]; -``` - -### CertificateContact EmailAddress -> Email -```yaml -directive: - - from: swagger-document - where: $.definitions.CertificateContact - transform: > - delete $.properties.email["x-ms-client-name"]; -``` - -### Rename KeyUsageType to CertificateKeyUsage and fix enum value name -```yaml -directive: - - from: "certificates.json" - where: $.definitions - transform: > - $.CertificateKeyUsage = $.X509CertificateProperties.properties["key_usage"].items; - delete $.X509CertificateProperties.properties["key_usage"].items; - $.X509CertificateProperties.properties["key_usage"].items = { "$ref": "#/definitions/CertificateKeyUsage" }; - $.CertificateKeyUsage["x-ms-enum"].name = "CertificateKeyUsage"; - $.CertificateKeyUsage["x-ms-enum"].values = $.CertificateKeyUsage.enum.map(item => { - if (item === "cRLSign") { - return { - "name": "CrlSign", - "value": "cRLSign" - } - } - - return { - "name": item, - "value": item - } - }); -``` - -### Change CertificatePolicyAction to an extensible enum -```yaml -directive: - - from: swagger-document - where: $.definitions.Action - transform: > - $.properties["action_type"]["x-ms-enum"].modelAsString = true; -``` - -### Rename SubjectAlternativeNames upns to userPrincipalNames -```yaml -directive: - - from: swagger-document - where: $.definitions.SubjectAlternativeNames.properties - transform: > - $.upns["x-ms-client-name"] = "userPrincipalNames"; -``` - -### Rename Error to CertificateOperationError -```yaml -directive: - - from: "common.json" - where: $.definitions - transform: > - $.CertificateOperationError = $.Error; - delete $.Error; - - $.CertificateOperationError.properties.innererror["$ref"] = "#/definitions/CertificateOperationError"; - $.KeyVaultError.properties.error["$ref"] = "#/definitions/CertificateOperationError"; -``` - -```yaml -directive: - - from: swagger-document - where: $.definitions.CertificateOperation - transform: > - $.properties.error["$ref"] = "common.json#/definitions/CertificateOperationError"; -``` - -### Rename JsonWebKeyType to CertificateKeyType -```yaml -directive: - - from: "keys.json" - where: $.definitions - transform: > - $.CertificateKeyType = $.JsonWebKey.properties.kty; - $.CertificateKeyType.enum = $.CertificateKeyType.enum.filter(item => item != "oct" && item != "oct-HSM"); - $.CertificateKeyType["x-ms-enum"].name = "CertificateKeyType"; - $.CertificateKeyType["x-ms-enum"].values = $.CertificateKeyType["x-ms-enum"].values - .filter(item => item.value != "oct" && item.value != "oct-HSM") - .map(item => { - if (item.value === "EC-HSM") { - item.name = "EcHsm"; - } else if (item.value === "RSA-HSM") { - item.name = "RsaHsm"; - } - - return item; - }); - - delete $.JsonWebKey.properties.kty; - $.JsonWebKey.properties.kty = { "$ref": "#/definitions/CertificateKeyType" }; - - delete $.KeyProperties.properties.kty; - $.KeyProperties.properties.kty = { "$ref": "#/definitions/CertificateKeyType" }; - - delete $.KeyCreateParameters.properties.kty; - $.KeyCreateParameters.properties.kty = { "$ref": "#/definitions/CertificateKeyType" }; -``` - -### Rename JsonWebKeyCurveName to CertificateKeyCurveName -```yaml -directive: - - from: "keys.json" - where: $.definitions - transform: > - $.CertificateKeyCurveName = $.JsonWebKey.properties.crv; - $.CertificateKeyCurveName["x-ms-enum"].name = "CertificateKeyCurveName"; - - delete $.JsonWebKey.properties.crv; - $.JsonWebKey.properties.crv = { "$ref": "#/definitions/CertificateKeyCurveName" }; - - delete $.KeyProperties.properties.crv; - $.KeyProperties.properties.crv = { "$ref": "#/definitions/CertificateKeyCurveName" }; - - delete $.KeyCreateParameters.properties.crv; - $.KeyCreateParameters.properties.crv = { "$ref": "#/definitions/CertificateKeyCurveName" }; -``` diff --git a/sdk/keyvault/azure-security-keyvault-certificates/swagger/pom.xml b/sdk/keyvault/azure-security-keyvault-certificates/swagger/pom.xml deleted file mode 100644 index 6d0caef89228..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/swagger/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - 4.0.0 - - - com.azure - azure-code-customization-parent - 1.0.0-beta.1 - ../../../parents/azure-code-customization-parent - - - Microsoft Azure Security Key Vault Certificates code generation customization - This package contains code generation customization for Microsoft Azure Security Key Vault Certificates - - com.azure.tools - azure-security-keyvault-certificates-autorest-customization - 1.0.0-beta.1 - jar - diff --git a/sdk/keyvault/azure-security-keyvault-certificates/swagger/src/main/java/CertificatesCustomizations.java b/sdk/keyvault/azure-security-keyvault-certificates/swagger/src/main/java/CertificatesCustomizations.java deleted file mode 100644 index 1a5799d6be19..000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/swagger/src/main/java/CertificatesCustomizations.java +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -import com.azure.autorest.customization.Customization; -import com.azure.autorest.customization.LibraryCustomization; -import org.slf4j.Logger; - -public class CertificatesCustomizations extends Customization { - @Override - public void customize(LibraryCustomization libraryCustomization, Logger logger) { - libraryCustomization.getPackage("com.azure.security.keyvault.certificates.models") - .getClass("CertificateKeyCurveName") - .customizeAst(ast -> ast.getClassByName("CertificateKeyCurveName").ifPresent(clazz -> { - clazz.getFieldByName("P256K").ifPresent(field -> field.getVariable(0).setName("P_256K")); - clazz.getFieldByName("P256").ifPresent(field -> field.getVariable(0).setName("P_256")); - clazz.getFieldByName("P384").ifPresent(field -> field.getVariable(0).setName("P_384")); - clazz.getFieldByName("P521").ifPresent(field -> field.getVariable(0).setName("P_521")); - })); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/tsp-location.yaml b/sdk/keyvault/azure-security-keyvault-certificates/tsp-location.yaml new file mode 100644 index 000000000000..cbe420773045 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-certificates/tsp-location.yaml @@ -0,0 +1,5 @@ +directory: specification/keyvault/Security.KeyVault.Certificates +commit: eaed7871620fc00e56bb422d7f6a2789e44c0ea9 +repo: Azure/azure-rest-api-specs +additionalDirectories: +- specification/keyvault/Security.KeyVault.Common