-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Remove hard-coded version and name from clients #6557
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
Changes from all commits
0a27f41
76078dc
cd06b80
a0dfff8
f3e2274
5e8feeb
fb02039
74e3fa3
9db258c
910db97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| name=${project.artifactId} | ||
| version=${project.version} |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| name=${project.artifactId} | ||
| version=${project.version} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| credentials_required=Azure Key Vault credentials are required. | ||
| vault_endpoint_required=Azure Key Vault endpoint url is required. | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,10 @@ | |
| import com.azure.core.annotation.ServiceClientBuilder; | ||
| import com.azure.core.http.policy.HttpPolicyProviders; | ||
| import com.azure.core.util.Configuration; | ||
| import com.azure.core.util.CoreUtils; | ||
| import com.azure.core.util.UserAgentProperties; | ||
| import com.azure.core.util.logging.ClientLogger; | ||
| import com.azure.security.keyvault.keys.implementation.KeyVaultCredentialPolicy; | ||
| import com.azure.security.keyvault.keys.implementation.AzureKeyVaultConfiguration; | ||
| import com.azure.security.keyvault.keys.models.JsonWebKey; | ||
|
|
||
| import java.util.ArrayList; | ||
|
|
@@ -63,7 +64,10 @@ | |
| @ServiceClientBuilder(serviceClients = CryptographyClient.class) | ||
| public final class CryptographyClientBuilder { | ||
| final List<HttpPipelinePolicy> policies; | ||
| final UserAgentProperties properties; | ||
| private final ClientLogger logger = new ClientLogger(CryptographyClientBuilder.class); | ||
| // This is properties file's name. | ||
| private static final String AZURE_KEY_VAULT_KEYS = "azure-key-vault-keys.properties"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does these file name need to be documented in README or documentation so user know about these names ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The version is internal use stuff. README is for public to use. I don't think it needs to put in README. What do you think? Or I can leave a comment above the line.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Users don't need to know about this file. |
||
| private TokenCredential credential; | ||
| private HttpPipeline pipeline; | ||
| private JsonWebKey jsonWebKey; | ||
|
|
@@ -81,6 +85,7 @@ public CryptographyClientBuilder() { | |
| retryPolicy = new RetryPolicy(); | ||
| httpLogOptions = new HttpLogOptions(); | ||
| policies = new ArrayList<>(); | ||
| properties = CoreUtils.getUserAgentProperties(AZURE_KEY_VAULT_KEYS); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -153,8 +158,8 @@ HttpPipeline setupPipeline() { | |
|
|
||
| // Closest to API goes first, closest to wire goes last. | ||
| final List<HttpPipelinePolicy> policies = new ArrayList<>(); | ||
| policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, | ||
| buildConfiguration)); | ||
| policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), properties.getName(), | ||
| properties.getVersion(), buildConfiguration)); | ||
| HttpPolicyProviders.addBeforeRetryPolicies(policies); | ||
| policies.add(retryPolicy); | ||
| policies.add(new KeyVaultCredentialPolicy(credential)); | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| name=${project.artifactId} | ||
| version=${project.version} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.security.keyvault.keys; | ||
|
|
||
| import com.azure.core.util.CoreUtils; | ||
| import com.azure.core.util.UserAgentProperties; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| public class KeyVaultKeysUserAgentPropertiesTest { | ||
|
|
||
| @Test | ||
| public void testAzureConfiguration() { | ||
| UserAgentProperties properties = CoreUtils.getUserAgentProperties("azure-key-vault-keys.properties"); | ||
| assertFalse(properties.getName().matches("UnknownName")); | ||
| assertTrue(properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*")); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.