Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Applied APIView suggestion for KV Admin. #22381

Merged
merged 4 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Release History

## 4.0.0 (2021-06-17)
- Initial release of `KeyVaultAccessControlClient` and `KeyVaultAccessControlAsyncClient` to managed role assignments and definitions for Managed HSM.
- Initial release of `KeyVaultAccessControlClient` and `KeyVaultAccessControlAsyncClient` to manage role assignments and definitions for Managed HSM.
- Initial release of `KeyVaultBackupClient` and `KeyVaultBackupAsyncClient` to backup and restore Managed HSM.

### Features Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ public static KeyVaultRoleScope fromString(String name) {
*
* @param url A string representing a URL containing the name of the scope to look for.
* @return The corresponding {@link KeyVaultRoleScope}.
* @throws MalformedURLException If the given {@link String URL String} is malformed.
* @throws IllegalArgumentException If the given {@link String URL String} is malformed.
*/
public static KeyVaultRoleScope fromUrl(String url) throws MalformedURLException {
return fromString(new URL(url).getPath(), KeyVaultRoleScope.class);
public static KeyVaultRoleScope fromUrl(String url) {
try {
return fromString(new URL(url).getPath(), KeyVaultRoleScope.class);
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;

Expand All @@ -16,6 +17,7 @@
*/
@Immutable
public final class KeyVaultCertificateIdentifier {
private final ClientLogger logger = new ClientLogger(KeyVaultCertificateIdentifier.class);
private final String sourceId, vaultUrl, name, version;

/**
Expand All @@ -37,7 +39,7 @@ public final class KeyVaultCertificateIdentifier {
*/
public KeyVaultCertificateIdentifier(String sourceId) {
if (sourceId == null) {
throw new NullPointerException("'sourceId' cannot be null");
throw logger.logExceptionAsError(new NullPointerException("'sourceId' cannot be null"));
}

try {
Expand All @@ -47,15 +49,17 @@ public KeyVaultCertificateIdentifier(String sourceId) {

// More or less segments in the URI than expected.
if (pathSegments.length != 3 && pathSegments.length != 4) {
throw new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.");
throw logger.logExceptionAsError(
new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier."));
}

this.sourceId = sourceId;
this.vaultUrl = String.format("%s://%s", url.getProtocol(), url.getHost());
this.name = pathSegments[2];
this.version = pathSegments.length == 4 ? pathSegments[3] : null;
} catch (MalformedURLException e) {
throw new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e);
throw logger.logExceptionAsError(
new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.security.keyvault.keys.models;

import com.azure.core.annotation.Immutable;
import com.azure.core.util.logging.ClientLogger;
import com.azure.security.keyvault.keys.KeyAsyncClient;
import com.azure.security.keyvault.keys.KeyClient;

Expand All @@ -16,6 +17,7 @@
*/
@Immutable
public final class KeyVaultKeyIdentifier {
private final ClientLogger logger = new ClientLogger(KeyVaultKeyIdentifier.class);
private final String sourceId, vaultUrl, name, version;

/**
Expand All @@ -37,7 +39,7 @@ public final class KeyVaultKeyIdentifier {
*/
public KeyVaultKeyIdentifier(String sourceId) {
if (sourceId == null) {
throw new NullPointerException("'sourceId' cannot be null.");
throw logger.logExceptionAsError(new NullPointerException("'sourceId' cannot be null."));
}

try {
Expand All @@ -47,15 +49,17 @@ public KeyVaultKeyIdentifier(String sourceId) {

// More or less segments in the URI than expected.
if (pathSegments.length != 3 && pathSegments.length != 4) {
throw new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.");
throw logger.logExceptionAsError(
new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier."));
}

this.sourceId = sourceId;
this.vaultUrl = String.format("%s://%s", url.getProtocol(), url.getHost());
this.name = pathSegments[2];
this.version = pathSegments.length == 4 ? pathSegments[3] : null;
} catch (MalformedURLException e) {
throw new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e);
throw logger.logExceptionAsError(
new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package com.azure.security.keyvault.secrets.models;

import com.azure.core.annotation.Immutable;
import com.azure.core.util.logging.ClientLogger;
import com.azure.security.keyvault.secrets.SecretAsyncClient;
import com.azure.security.keyvault.secrets.SecretClient;

Expand All @@ -16,6 +17,7 @@
*/
@Immutable
public final class KeyVaultSecretIdentifier {
private final ClientLogger logger = new ClientLogger(KeyVaultSecretIdentifier.class);
private final String sourceId, vaultUrl, name, version;

/**
Expand All @@ -37,7 +39,7 @@ public final class KeyVaultSecretIdentifier {
*/
public KeyVaultSecretIdentifier(String sourceId) {
if (sourceId == null) {
throw new NullPointerException("'sourceId' cannot be null.");
throw logger.logExceptionAsError(new NullPointerException("'sourceId' cannot be null."));
}

try {
Expand All @@ -47,15 +49,17 @@ public KeyVaultSecretIdentifier(String sourceId) {

// More or less segments in the URI than expected.
if (pathSegments.length != 3 && pathSegments.length != 4) {
throw new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.");
throw logger.logExceptionAsError(
new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier."));
}

this.sourceId = sourceId;
this.vaultUrl = String.format("%s://%s", url.getProtocol(), url.getHost());
this.name = pathSegments[2];
this.version = pathSegments.length == 4 ? pathSegments[3] : null;
} catch (MalformedURLException e) {
throw new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e);
throw logger.logExceptionAsError(
new IllegalArgumentException("'sourceId' is not a valid Key Vault identifier.", e));
}
}

Expand Down