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

[Key Vault] Added TSP configuration for Key Vault Keys #43418

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
Expand Up @@ -3,6 +3,7 @@
<!-- This file is generated by the /eng/scripts/linting_suppression_generator.py script. -->

<suppressions>
<suppress files="com.azure.security.keyvault.keys.implementation.KeyClientImpl.java" checks="JavaDocFormatting" />
<suppress files="com.azure.security.keyvault.keys.implementation.KeyVaultCredentialPolicy.java" checks="JavadocMethodCheck" />
<suppress files="com.azure.security.keyvault.keys.cryptography.implementation.CryptographyClientImpl.java" checks="MissingJavadocMethodCheck" />
<suppress files="com.azure.security.keyvault.keys.cryptography.implementation.CryptographyUtils.java" checks="MissingJavadocMethodCheck" />
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public final class KeyClientBuilder implements TokenCredentialTrait<KeyClientBui
private static final String CLIENT_VERSION;

static {
Map<String, String> properties = CoreUtils.getProperties("azure-key-vault-keys.properties");
Map<String, String> properties = CoreUtils.getProperties("azure-security-keyvault-keys.properties");
CLIENT_NAME = properties.getOrDefault("name", "UnknownName");
CLIENT_VERSION = properties.getOrDefault("version", "UnknownVersion");
}
Expand Down Expand Up @@ -188,7 +188,7 @@ private KeyClientImpl buildInnerClient() {
KeyServiceVersion serviceVersion = version != null ? version : KeyServiceVersion.getLatest();

if (pipeline != null) {
return new KeyClientImpl(pipeline, serviceVersion.getVersion());
return new KeyClientImpl(pipeline, vaultUrl, serviceVersion);
}

if (credential == null) {
Expand Down Expand Up @@ -234,7 +234,7 @@ private KeyClientImpl buildInnerClient() {
.clientOptions(localClientOptions)
.build();

return new KeyClientImpl(pipeline, serviceVersion.getVersion());
return new KeyClientImpl(pipeline, vaultUrl, serviceVersion);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public final class CryptographyClientBuilder implements TokenCredentialTrait<Cry
private boolean isKeyCachingDisabled = false;

static {
Map<String, String> properties = CoreUtils.getProperties("azure-key-vault-keys.properties");
Map<String, String> properties = CoreUtils.getProperties("azure-security-keyvault-keys.properties");
CLIENT_NAME = properties.getOrDefault("name", "UnknownName");
CLIENT_VERSION = properties.getOrDefault("version", "UnknownVersion");
}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
package com.azure.security.keyvault.keys.implementation;

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.RequestOptions;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.security.keyvault.keys.KeyServiceVersion;
import com.azure.security.keyvault.keys.cryptography.CryptographyClientBuilder;
import com.azure.security.keyvault.keys.cryptography.CryptographyServiceVersion;
import com.azure.security.keyvault.keys.implementation.models.KeyVaultErrorException;

import java.io.IOException;
import java.net.MalformedURLException;
Expand All @@ -31,6 +29,8 @@
public final class KeyVaultKeysUtils {
private static final ClientLogger LOGGER = new ClientLogger(KeyVaultKeysUtils.class);

public static final RequestOptions EMPTY_OPTIONS = new RequestOptions();

/**
* Creates a {@link CryptographyClientBuilder} based on the values passed from a Keys service client.
*
Expand Down Expand Up @@ -78,35 +78,19 @@ private static String generateKeyId(String keyName, String keyVersion, String va
}

/**
* Calls a supplier and maps any {@link KeyVaultErrorException} to an {@link HttpResponseException}.
* Calls a supplier and maps any {@link HttpResponseException} to an {@link HttpResponseException}.
*
* @param <T> The type of the result of the supplier.
* @param call The supplier to call.
* @param exceptionMapper The function to map a {@link KeyVaultErrorException} to an {@link HttpResponseException}.
* @param exceptionMapper The function to map a {@link HttpResponseException} to an {@link HttpResponseException}.
* @return The result of the supplier.
*/
public static <T> T callWithMappedException(Supplier<T> call,
Function<KeyVaultErrorException, HttpResponseException> exceptionMapper) {
Function<HttpResponseException, HttpResponseException> exceptionMapper) {
try {
return call.get();
} catch (KeyVaultErrorException ex) {
throw exceptionMapper.apply(ex);
}
}

/**
* Maps a {@link KeyVaultErrorException} to an {@link HttpResponseException} for get key operations.
*
* @param ex The {@link KeyVaultErrorException} to map.
* @return The {@link HttpResponseException} that maps from the {@link KeyVaultErrorException}.
*/
public static HttpResponseException mapGetKeyException(KeyVaultErrorException ex) {
if (ex.getResponse().getStatusCode() == 403) {
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;
} catch (HttpResponseException e) {
throw exceptionMapper.apply(e);
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.security.keyvault.keys.implementation.models;

import com.azure.core.annotation.Generated;
import com.azure.core.annotation.Immutable;
import com.azure.core.util.Base64Url;
import com.azure.json.JsonReader;
Expand All @@ -20,19 +21,22 @@ public final class BackupKeyResult implements JsonSerializable<BackupKeyResult>
/*
* The backup blob containing the backed up key.
*/
@Generated
private Base64Url value;

/**
* Creates an instance of BackupKeyResult class.
*/
public BackupKeyResult() {
@Generated
private BackupKeyResult() {
}

/**
* Get the value property: The backup blob containing the backed up key.
*
* @return the value value.
*/
@Generated
public byte[] getValue() {
if (this.value == null) {
return null;
Expand All @@ -43,6 +47,7 @@ public byte[] getValue() {
/**
* {@inheritDoc}
*/
@Generated
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
Expand All @@ -57,6 +62,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
* pointing to JSON null.
* @throws IOException If an error occurs while reading the BackupKeyResult.
*/
@Generated
public static BackupKeyResult fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
BackupKeyResult deserializedBackupKeyResult = new BackupKeyResult();
Expand Down
Loading
Loading