Skip to content

Commit

Permalink
Keyvault Updates (Azure#4062)
Browse files Browse the repository at this point in the history
Keyvault Config + Logging + Iterable + Tests Updates + Samples updates + README Updates
  • Loading branch information
g2vinay authored and sima-zhu committed Jun 29, 2019
1 parent 28860df commit f170c05
Show file tree
Hide file tree
Showing 125 changed files with 3,066 additions and 2,553 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,11 @@
<!-- Jackson property setter method is private -->
<Match>
<Or>
<Class name="com.azure.keyvault.models.DeletedSecret"/>
<Class name="com.azure.keyvault.models.SecretBase"/>
<Class name="com.azure.keyvault.keys.models.DeletedKey"/>
<Class name="com.azure.keyvault.keys.models.Key"/>
<Class name="com.azure.keyvault.keys.models.KeyBase"/>
<Class name="com.azure.security.keyvault.secrets.models.DeletedSecret"/>
<Class name="com.azure.security.keyvault.secrets.models.SecretBase"/>
<Class name="com.azure.security.keyvault.keys.models.DeletedKey"/>
<Class name="com.azure.security.keyvault.keys.models.Key"/>
<Class name="com.azure.security.keyvault.keys.models.KeyBase"/>
</Or>
<Bug pattern="UPM_UNCALLED_PRIVATE_METHOD"/>
</Match>
Expand All @@ -450,19 +450,19 @@

<!-- Field initialized by jackson property annotation -->
<Match>
<Class name="com.azure.keyvault.keys.models.webkey.JsonWebKey"/>
<Class name="com.azure.security.keyvault.keys.models.webkey.JsonWebKey"/>
<Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
</Match>

<!-- Bytes array are designed to return null if it is null -->
<Match>
<Or>
<And>
<Class name="com.azure.keyvault.keys.models.webkey.Base64UrlJsonDeserializer"/>
<Class name="com.azure.security.keyvault.keys.models.webkey.Base64UrlJsonDeserializer"/>
<Method name="deserialize" />
</And>
<And>
<Class name="com.azure.keyvault.keys.models.webkey.ByteExtensions"/>
<Class name="com.azure.security.keyvault.keys.models.webkey.ByteExtensions"/>
<Method name="clone" />
</And>
</Or>
Expand Down
5 changes: 3 additions & 2 deletions eng/jacoco-test-coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

<properties>
<azure-messaging-eventhubs.version>5.0.0-preview.1</azure-messaging-eventhubs.version>
<azure-keyvault.version>4.0.0-preview.1</azure-keyvault.version>
</properties>

<distributionManagement>
Expand Down Expand Up @@ -63,12 +64,12 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-keyvault-keys</artifactId>
<version>${version}</version>
<version>${azure-keyvault.version}</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-keyvault-secrets</artifactId>
<version>${version}</version>
<version>${azure-keyvault.version}</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
Expand Down
326 changes: 326 additions & 0 deletions keyvault/client/keys/README.md

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions keyvault/client/keys/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
<parent>
<artifactId>azure-keyvault-parent</artifactId>
<groupId>com.azure</groupId>
<version>1.0.0-SNAPSHOT</version>
<version>4.0.0-preview.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>

<groupId>com.azure</groupId>
<artifactId>azure-keyvault-keys</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>4.0.0-preview.1</version>

<name>azure-keyvault-keys</name>
<url>https://github.com/Azure/azure-sdk-for-java</url>
Expand All @@ -38,8 +39,8 @@
</dependency>

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>

<dependency>
Expand All @@ -60,6 +61,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

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

class AzureKeyVaultConfiguration {
//TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

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

import com.azure.core.implementation.util.ImplUtils;
import com.azure.core.util.configuration.Configuration;
import com.azure.core.credentials.TokenCredential;
import com.azure.core.http.HttpClient;
Expand All @@ -13,6 +14,7 @@
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.policy.UserAgentPolicy;
import com.azure.core.util.configuration.ConfigurationManager;

import java.net.MalformedURLException;
import java.net.URL;
Expand All @@ -29,7 +31,7 @@
* <pre>
* KeyAsyncClient.builder()
* .endpoint("https://myvault.vault.azure.net/")
* .credential(keyVaultAsyncCredential)
* .credential(new DefaultAzureCredential())
* .build();
* </pre>
*
Expand All @@ -38,7 +40,7 @@
* <pre>
* KeyAsyncClient secretAsyncClient = KeyAsyncClient.builder()
* .endpoint("https://myvault.vault.azure.net/")
* .credential(keyVaultAsyncCredential)
* .credential(new DefaultAzureCredential())
* .httpLogDetailLevel(HttpLogDetailLevel.BODY_AND_HEADERS)
* .addPolicy(customPolicyOne)
* .addPolicy(customPolicyTwo)
Expand All @@ -65,6 +67,7 @@ public final class KeyAsyncClientBuilder {
private HttpClient httpClient;
private HttpLogDetailLevel httpLogDetailLevel;
private RetryPolicy retryPolicy;
private Configuration configuration;

KeyAsyncClientBuilder() {
retryPolicy = new RetryPolicy();
Expand All @@ -87,8 +90,10 @@ public final class KeyAsyncClientBuilder {
* {@link KeyAsyncClientBuilder#endpoint(String)} have not been set.
*/
public KeyAsyncClient build() {
Configuration buildConfiguration = (configuration == null) ? ConfigurationManager.getConfiguration().clone() : configuration;
URL buildEndpoint = getBuildEndpoint(buildConfiguration);

if (endpoint == null) {
if (buildEndpoint == null) {
throw new IllegalStateException(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED));
}

Expand All @@ -102,7 +107,7 @@ public KeyAsyncClient build() {

// Closest to API goes first, closest to wire goes last.
final List<HttpPipelinePolicy> policies = new ArrayList<>();
policies.add(new UserAgentPolicy(AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, new Configuration()));
policies.add(new UserAgentPolicy(AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, buildConfiguration));
policies.add(retryPolicy);
policies.add(new BearerTokenAuthenticationPolicy(credential, KeyAsyncClient.KEY_VAULT_SCOPE));
policies.addAll(this.policies);
Expand Down Expand Up @@ -201,4 +206,35 @@ public KeyAsyncClientBuilder 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 ConfigurationManager#getConfiguration() global
* configuration store}, use {@link Configuration#NONE} to bypass using configuration settings during construction.
*
* @param configuration The configuration store used to
* @return The updated KeyAsyncClientBuilder object.
*/
public KeyAsyncClientBuilder configuration(Configuration configuration) {
this.configuration = configuration;
return this;
}

private URL getBuildEndpoint(Configuration configuration) {
if (endpoint != null) {
return endpoint;
}

String configEndpoint = configuration.get("AZURE_KEYVAULT_ENDPOINT");
if (ImplUtils.isNullOrEmpty(configEndpoint)) {
return null;
}

try {
return new URL(configEndpoint);
} catch (MalformedURLException ex) {
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

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

import com.azure.core.implementation.Base64Url;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Loading

0 comments on commit f170c05

Please sign in to comment.