diff --git a/sdk/keyvault/azure-security-keyvault-keys/CHANGELOG.md b/sdk/keyvault/azure-security-keyvault-keys/CHANGELOG.md index 33b6c64814c5a..7ca9149c085a1 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/CHANGELOG.md +++ b/sdk/keyvault/azure-security-keyvault-keys/CHANGELOG.md @@ -5,6 +5,8 @@ ### Features Added ### Breaking Changes +- Changed `getRandomBytes` operations in `KeyClient` and `KeyAsyncClient` to return `byte[]` instead of `RandomBytes`. +- Removed the `RandomBytes` class. ### Bugs Fixed diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java index a216341f23509..888d63947be0a 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyAsyncClient.java @@ -2052,7 +2052,7 @@ public Mono releaseKey(String name, String version, String tar * @param version The version of the key to retrieve. If this is empty or {@code null}, this call is equivalent to * calling {@link KeyAsyncClient#releaseKey(String, String)}, with the latest key version being released. * @param targetAttestationToken The attestation assertion for the target of the key release. - * @param options Additional {@link ReleaseKeyOptions options} for releasing a {@link KeyVaultKey key}. + * @param releaseKeyOptions Additional {@link ReleaseKeyOptions options} for releasing a {@link KeyVaultKey key}. * * @return A {@link Mono} containing the {@link Response HTTP response} for this operation and the * {@link ReleaseKeyResult} containing the released key. @@ -2063,17 +2063,17 @@ public Mono releaseKey(String name, String version, String tar @ServiceMethod(returns = ReturnType.SINGLE) public Mono> releaseKeyWithResponse(String name, String version, String targetAttestationToken, - ReleaseKeyOptions options) { + ReleaseKeyOptions releaseKeyOptions) { try { return withContext(context -> - releaseKeyWithResponse(name, version, targetAttestationToken, options, context)); + releaseKeyWithResponse(name, version, targetAttestationToken, releaseKeyOptions, context)); } catch (RuntimeException e) { return monoError(logger, e); } } Mono> releaseKeyWithResponse(String name, String version, String targetAttestationToken, - ReleaseKeyOptions options, Context context) { + ReleaseKeyOptions releaseKeyOptions, Context context) { try { if (CoreUtils.isNullOrEmpty(name)) { return monoError(logger, new IllegalArgumentException("'name' cannot be null or empty")); @@ -2084,12 +2084,12 @@ Mono> releaseKeyWithResponse(String name, String vers new IllegalArgumentException("'targetAttestationToken' cannot be null or empty")); } - options = options == null ? new ReleaseKeyOptions() : options; + releaseKeyOptions = releaseKeyOptions == null ? new ReleaseKeyOptions() : releaseKeyOptions; KeyReleaseParameters keyReleaseParameters = new KeyReleaseParameters() .setTargetAttestationToken(targetAttestationToken) - .setAlgorithm(options.getAlgorithm()) - .setNonce(options.getNonce()); + .setAlgorithm(releaseKeyOptions.getAlgorithm()) + .setNonce(releaseKeyOptions.getNonce()); return service.release(vaultUrl, name, version, keyServiceVersion.getVersion(), keyReleaseParameters, "application/json", context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) @@ -2200,7 +2200,7 @@ Mono> rotateKeyWithResponse(String name, Context context) * * * - * @param name The name of the {@link KeyVaultKey key}. + * @param keyName The name of the {@link KeyVaultKey key}. * * @return A {@link Mono} containing the {@link KeyRotationPolicy} for the key. * @@ -2208,9 +2208,9 @@ Mono> rotateKeyWithResponse(String name, Context context) * @throws ResourceNotFoundException If the {@link KeyVaultKey key} for the provided {@code name} does not exist. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getKeyRotationPolicy(String name) { + public Mono getKeyRotationPolicy(String keyName) { try { - return getKeyRotationPolicyWithResponse(name).flatMap(FluxUtil::toMono); + return getKeyRotationPolicyWithResponse(keyName).flatMap(FluxUtil::toMono); } catch (RuntimeException e) { return monoError(logger, e); } @@ -2234,7 +2234,7 @@ public Mono getKeyRotationPolicy(String name) { * * * - * @param name The name of the {@link KeyVaultKey key}. + * @param keyName The name of the {@link KeyVaultKey key}. * * @return A {@link Mono} containing the {@link Response HTTP response} for this operation and the * {@link KeyRotationPolicy} for the key. @@ -2243,24 +2243,24 @@ public Mono getKeyRotationPolicy(String name) { * @throws ResourceNotFoundException If the {@link KeyVaultKey key} for the provided {@code name} does not exist. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getKeyRotationPolicyWithResponse(String name) { + public Mono> getKeyRotationPolicyWithResponse(String keyName) { try { - return withContext(context -> getKeyRotationPolicyWithResponse(name, context)); + return withContext(context -> getKeyRotationPolicyWithResponse(keyName, context)); } catch (RuntimeException e) { return monoError(logger, e); } } - Mono> getKeyRotationPolicyWithResponse(String name, Context context) { + Mono> getKeyRotationPolicyWithResponse(String keyName, Context context) { try { - if (CoreUtils.isNullOrEmpty(name)) { - return monoError(logger, new IllegalArgumentException("'name' cannot be null or empty")); + if (CoreUtils.isNullOrEmpty(keyName)) { + return monoError(logger, new IllegalArgumentException("'keyName' cannot be null or empty")); } - return service.getKeyRotationPolicy(vaultUrl, name, keyServiceVersion.getVersion(), "application/json", + return service.getKeyRotationPolicy(vaultUrl, keyName, keyServiceVersion.getVersion(), "application/json", context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.verbose("Retrieving key rotation policy for key with name.", name)) - .doOnSuccess(response -> logger.verbose("Retrieved key rotation policy for key with name.", name)) + .doOnRequest(ignored -> logger.verbose("Retrieving key rotation policy for key with name.", keyName)) + .doOnSuccess(response -> logger.verbose("Retrieved key rotation policy for key with name.", keyName)) .doOnError(error -> logger.warning("Failed to retrieve key rotation policy - {}", error)); } catch (RuntimeException e) { return monoError(logger, e); @@ -2296,7 +2296,7 @@ Mono> getKeyRotationPolicyWithResponse(String name, * * * - * @param name The name of the {@link KeyVaultKey key}. + * @param keyName The name of the {@link KeyVaultKey key}. * @param keyRotationPolicy The {@link KeyRotationPolicy} for the key. * * @return A {@link Mono} containing the {@link KeyRotationPolicy} for the key. @@ -2305,9 +2305,9 @@ Mono> getKeyRotationPolicyWithResponse(String name, * @throws ResourceNotFoundException If the {@link KeyVaultKey key} for the provided {@code name} does not exist. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono updateKeyRotationPolicy(String name, KeyRotationPolicy keyRotationPolicy) { + public Mono updateKeyRotationPolicy(String keyName, KeyRotationPolicy keyRotationPolicy) { try { - return updateKeyRotationPolicyWithResponse(name, keyRotationPolicy).flatMap(FluxUtil::toMono); + return updateKeyRotationPolicyWithResponse(keyName, keyRotationPolicy).flatMap(FluxUtil::toMono); } catch (RuntimeException e) { return monoError(logger, e); } @@ -2344,7 +2344,7 @@ public Mono updateKeyRotationPolicy(String name, KeyRotationP * * * - * @param name The name of the {@link KeyVaultKey key}. + * @param keyName The name of the {@link KeyVaultKey key}. * @param keyRotationPolicy The {@link KeyRotationPolicy} for the key. * * @return A {@link Mono} containing the {@link Response HTTP response} for this operation and the @@ -2354,25 +2354,28 @@ public Mono updateKeyRotationPolicy(String name, KeyRotationP * @throws ResourceNotFoundException If the {@link KeyVaultKey key} for the provided {@code name} does not exist. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> updateKeyRotationPolicyWithResponse(String name, KeyRotationPolicy keyRotationPolicy) { + public Mono> updateKeyRotationPolicyWithResponse(String keyName, + KeyRotationPolicy keyRotationPolicy) { try { return withContext(context -> - updateKeyRotationPolicyWithResponse(name, keyRotationPolicy, context)); + updateKeyRotationPolicyWithResponse(keyName, keyRotationPolicy, context)); } catch (RuntimeException e) { return monoError(logger, e); } } - Mono> updateKeyRotationPolicyWithResponse(String name, KeyRotationPolicy keyRotationPolicy, Context context) { + Mono> updateKeyRotationPolicyWithResponse(String keyName, + KeyRotationPolicy keyRotationPolicy, + Context context) { try { - if (CoreUtils.isNullOrEmpty(name)) { - return monoError(logger, new IllegalArgumentException("'name' cannot be null or empty")); + if (CoreUtils.isNullOrEmpty(keyName)) { + return monoError(logger, new IllegalArgumentException("'keyName' cannot be null or empty")); } - return service.updateKeyRotationPolicy(vaultUrl, name, keyServiceVersion.getVersion(), keyRotationPolicy, + return service.updateKeyRotationPolicy(vaultUrl, keyName, keyServiceVersion.getVersion(), keyRotationPolicy, "application/json", context.addData(AZ_TRACING_NAMESPACE_KEY, KEYVAULT_TRACING_NAMESPACE_VALUE)) - .doOnRequest(ignored -> logger.verbose("Updating key rotation policy for key with name.", name)) - .doOnSuccess(response -> logger.verbose("Updated key rotation policy for key with name.", name)) + .doOnRequest(ignored -> logger.verbose("Updating key rotation policy for key with name.", keyName)) + .doOnSuccess(response -> logger.verbose("Updated key rotation policy for key with name.", keyName)) .doOnError(error -> logger.warning("Failed to retrieve key rotation policy - {}", error)); } catch (RuntimeException e) { return monoError(logger, e); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClient.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClient.java index fe9938efd78e0..36579412df490 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClient.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClient.java @@ -1571,7 +1571,7 @@ public ReleaseKeyResult releaseKey(String name, String version, String targetAtt * is equivalent to calling {@link KeyAsyncClient#releaseKey(String, String)}, with the latest key version being * released. * @param targetAttestationToken The attestation assertion for the target of the key release. - * @param options Additional {@link ReleaseKeyOptions options} for releasing a {@link KeyVaultKey key}. + * @param releaseKeyOptions Additional {@link ReleaseKeyOptions options} for releasing a {@link KeyVaultKey key}. * @param context Additional {@link Context} that is passed through the {@link HttpPipeline} during the service * call. * @@ -1583,8 +1583,8 @@ public ReleaseKeyResult releaseKey(String name, String version, String targetAtt */ @ServiceMethod(returns = ReturnType.SINGLE) public Response releaseKeyWithResponse(String name, String version, String targetAttestationToken, - ReleaseKeyOptions options, Context context) { - return client.releaseKeyWithResponse(name, version, targetAttestationToken, options, context).block(); + ReleaseKeyOptions releaseKeyOptions, Context context) { + return client.releaseKeyWithResponse(name, version, targetAttestationToken, releaseKeyOptions, context).block(); } /** @@ -1663,7 +1663,7 @@ public Response rotateKeyWithResponse(String name, Context context) * * * - * @param name The name of the {@link KeyVaultKey key}. + * @param keyName The name of the {@link KeyVaultKey key}. * * @return The {@link KeyRotationPolicy} for the {@link KeyVaultKey key}. * @@ -1671,8 +1671,8 @@ public Response rotateKeyWithResponse(String name, Context context) * @throws ResourceNotFoundException If the {@link KeyVaultKey key} for the provided {@code name} does not exist. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyRotationPolicy getKeyRotationPolicy(String name) { - return client.getKeyRotationPolicy(name).block(); + public KeyRotationPolicy getKeyRotationPolicy(String keyName) { + return client.getKeyRotationPolicy(keyName).block(); } /** @@ -1692,7 +1692,7 @@ public KeyRotationPolicy getKeyRotationPolicy(String name) { * * * - * @param name The name of the {@link KeyVaultKey key}. + * @param keyName The name of the {@link KeyVaultKey key}. * @param context Additional {@link Context} that is passed through the {@link HttpPipeline} during the service * call. * @@ -1703,8 +1703,8 @@ public KeyRotationPolicy getKeyRotationPolicy(String name) { * @throws ResourceNotFoundException If the {@link KeyVaultKey key} for the provided {@code name} does not exist. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getKeyRotationPolicyWithResponse(String name, Context context) { - return client.getKeyRotationPolicyWithResponse(name, context).block(); + public Response getKeyRotationPolicyWithResponse(String keyName, Context context) { + return client.getKeyRotationPolicyWithResponse(keyName, context).block(); } /** @@ -1736,7 +1736,7 @@ public Response getKeyRotationPolicyWithResponse(String name, * * * - * @param name The name of the {@link KeyVaultKey key}. + * @param keyName The name of the {@link KeyVaultKey key}. * @param keyRotationPolicy The {@link KeyRotationPolicy} for the ke{@link KeyVaultKey key}y. * * @return The {@link KeyRotationPolicy} for the {@link KeyVaultKey key}. @@ -1745,8 +1745,8 @@ public Response getKeyRotationPolicyWithResponse(String name, * @throws ResourceNotFoundException If the {@link KeyVaultKey key} for the provided {@code name} does not exist. */ @ServiceMethod(returns = ReturnType.SINGLE) - public KeyRotationPolicy updateKeyRotationPolicy(String name, KeyRotationPolicy keyRotationPolicy) { - return client.updateKeyRotationPolicy(name, keyRotationPolicy).block(); + public KeyRotationPolicy updateKeyRotationPolicy(String keyName, KeyRotationPolicy keyRotationPolicy) { + return client.updateKeyRotationPolicy(keyName, keyRotationPolicy).block(); } /** @@ -1779,7 +1779,7 @@ public KeyRotationPolicy updateKeyRotationPolicy(String name, KeyRotationPolicy * * * - * @param name The name of the {@link KeyVaultKey key}. + * @param keyName The name of the {@link KeyVaultKey key}. * @param keyRotationPolicy The {@link KeyRotationPolicy} for the key. * @param context Additional {@link Context} that is passed through the {@link HttpPipeline} during the service * call. @@ -1791,7 +1791,9 @@ public KeyRotationPolicy updateKeyRotationPolicy(String name, KeyRotationPolicy * @throws ResourceNotFoundException If the {@link KeyVaultKey key} for the provided {@code name} does not exist. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response updateKeyRotationPolicyWithResponse(String name, KeyRotationPolicy keyRotationPolicy, Context context) { - return client.updateKeyRotationPolicyWithResponse(name, keyRotationPolicy, context).block(); + public Response updateKeyRotationPolicyWithResponse(String keyName, + KeyRotationPolicy keyRotationPolicy, + Context context) { + return client.updateKeyRotationPolicyWithResponse(keyName, keyRotationPolicy, context).block(); } } diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/CreateEcKeyOptions.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/CreateEcKeyOptions.java index f4d59e192fdf0..c60845ed06251 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/CreateEcKeyOptions.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/CreateEcKeyOptions.java @@ -155,6 +155,7 @@ public CreateEcKeyOptions setEnabled(Boolean enabled) { * * @return The updated {@link CreateEcKeyOptions} object. */ + @Override public CreateEcKeyOptions setExportable(Boolean exportable) { super.setExportable(exportable); @@ -168,6 +169,7 @@ public CreateEcKeyOptions setExportable(Boolean exportable) { * * @return The updated {@link CreateEcKeyOptions} object. */ + @Override public CreateEcKeyOptions setReleasePolicy(KeyReleasePolicy releasePolicy) { super.setReleasePolicy(releasePolicy); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/CreateOctKeyOptions.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/CreateOctKeyOptions.java index 42a6ae863e1a1..ca73c9196e1bd 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/CreateOctKeyOptions.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/CreateOctKeyOptions.java @@ -141,6 +141,7 @@ public CreateOctKeyOptions setTags(Map tags) { * * @return The updated {@link CreateOctKeyOptions} object. */ + @Override public CreateOctKeyOptions setEnabled(Boolean enabled) { super.setEnabled(enabled); @@ -154,6 +155,7 @@ public CreateOctKeyOptions setEnabled(Boolean enabled) { * * @return The updated {@link CreateOctKeyOptions} object. */ + @Override public CreateOctKeyOptions setExportable(Boolean exportable) { super.setExportable(exportable); @@ -167,6 +169,7 @@ public CreateOctKeyOptions setExportable(Boolean exportable) { * * @return The updated {@link CreateOctKeyOptions} object. */ + @Override public CreateOctKeyOptions setReleasePolicy(KeyReleasePolicy releasePolicy) { super.setReleasePolicy(releasePolicy); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/CreateRsaKeyOptions.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/CreateRsaKeyOptions.java index 1ab9939f703d1..0e7d1a3fbe5c4 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/CreateRsaKeyOptions.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/CreateRsaKeyOptions.java @@ -169,6 +169,7 @@ public CreateRsaKeyOptions setTags(Map tags) { * * @return The updated {@link CreateRsaKeyOptions} object. */ + @Override public CreateRsaKeyOptions setEnabled(Boolean enabled) { super.setEnabled(enabled); @@ -182,6 +183,7 @@ public CreateRsaKeyOptions setEnabled(Boolean enabled) { * * @return The updated {@link CreateRsaKeyOptions} object. */ + @Override public CreateRsaKeyOptions setExportable(Boolean exportable) { super.setExportable(exportable); @@ -195,6 +197,7 @@ public CreateRsaKeyOptions setExportable(Boolean exportable) { * * @return The updated {@link CreateRsaKeyOptions} object. */ + @Override public CreateRsaKeyOptions setReleasePolicy(KeyReleasePolicy releasePolicy) { super.setReleasePolicy(releasePolicy); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/RandomBytes.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/RandomBytes.java deleted file mode 100644 index 1d7e191945d32..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/RandomBytes.java +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -package com.azure.security.keyvault.keys.models; - -import com.azure.core.annotation.Immutable; -import com.azure.security.keyvault.keys.KeyAsyncClient; -import com.azure.security.keyvault.keys.KeyClient; -import com.azure.security.keyvault.keys.implementation.ByteExtensions; - -/** - * A class containing random bytes obtained by calling {@link KeyClient#getRandomBytes(int)} or - * {@link KeyAsyncClient#getRandomBytes(int)}. - */ -@Immutable -public class RandomBytes { - /* - * The random bytes. - */ - private final byte[] bytes; - - /** - * Creates and instance of {@link RandomBytes}. - * - * @param bytes The random bytes. - */ - public RandomBytes(byte[] bytes) { - this.bytes = ByteExtensions.clone(bytes); - } - - /** - * Get the random bytes. - * - * @return The random bytes. - */ - public byte[] getBytes() { - return ByteExtensions.clone(this.bytes); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/ReleaseKeyOptions.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/ReleaseKeyOptions.java index e3adc86fff57e..dc99d4d9b86aa 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/ReleaseKeyOptions.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/models/ReleaseKeyOptions.java @@ -3,10 +3,13 @@ package com.azure.security.keyvault.keys.models; +import com.azure.core.annotation.Fluent; + /** * Represents the configurable options to release a key. */ -public class ReleaseKeyOptions { +@Fluent +public final class ReleaseKeyOptions { /* * A client provided nonce for freshness. */ @@ -15,7 +18,7 @@ public class ReleaseKeyOptions { /* * The encryption algorithm to use to protected the exported key material */ - private KeyExportEncryptionAlgorithm encryptionAlgorithm; + private KeyExportEncryptionAlgorithm algorithm; /** * Get a client provided nonce for freshness. @@ -45,18 +48,18 @@ public ReleaseKeyOptions setNonce(String nonce) { * @return The encryption algorithm to use to protected the exported key material. */ public KeyExportEncryptionAlgorithm getAlgorithm() { - return this.encryptionAlgorithm; + return this.algorithm; } /** * Set the encryption algorithm to use to protected the exported key material. * - * @param encryptionAlgorithm The encryption algorithm to use to protected the exported key material. + * @param algorithm The encryption algorithm to use to protected the exported key material. * * @return The updated {@link ReleaseKeyOptions} object. */ - public ReleaseKeyOptions setAlgorithm(KeyExportEncryptionAlgorithm encryptionAlgorithm) { - this.encryptionAlgorithm = encryptionAlgorithm; + public ReleaseKeyOptions setAlgorithm(KeyExportEncryptionAlgorithm algorithm) { + this.algorithm = algorithm; return this; }