From 23a60d064f68d9dc3dc3a3a639037ada841e63da Mon Sep 17 00:00:00 2001 From: Sameeksha Vaity Date: Mon, 22 Jul 2019 14:42:40 -0700 Subject: [PATCH] fixing checkstyle --- .../security/keyvault/keys/KeyClient.java | 23 +++- .../KeyAsyncClientJavaDocCodeSnippets.java | 101 ++++++++++-------- .../keys/KeyClientJavaDocCodeSnippets.java | 50 ++------- 3 files changed, 82 insertions(+), 92 deletions(-) diff --git a/sdk/keyvault/azure-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClient.java b/sdk/keyvault/azure-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClient.java index e42dd09be0bac..9aeca4ebda733 100644 --- a/sdk/keyvault/azure-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClient.java +++ b/sdk/keyvault/azure-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClient.java @@ -228,7 +228,10 @@ public Response createEcKeyWithResponse(EcKeyCreateOptions ecKeyCreateOptio * *

Code Samples

*

Imports a new key into key vault. Prints out the details of the imported key.

- * {@codesnippet com.azure.keyvault.keys.keyclient.importKey#string-JsonWebKey} + *
+     * Key importedKey = keyClient.importKey("keyName", jsonWebKeyToImport);
+     * System.out.printf("Key is imported with name %s and id %s \n", importedKey.name(), importedKey.id());
+     * 
* * @param name The name for the imported key. * @param keyMaterial The Json web key being imported. @@ -250,7 +253,14 @@ public Key importKey(String name, JsonWebKey keyMaterial) { * *

Code Samples

*

Imports a new key into key vault. Prints out the details of the imported key.

- * {@codesnippet com.azure.keyvault.keys.keyclient.importKey#keyImportOptions} + *
+     * KeyImportOptions keyImportOptions = new KeyImportOptions("keyName", jsonWebKeyToImport)
+     *   .hsm(true)
+     *   .expires(OffsetDateTime.now().plusDays(60));
+     *
+     * Key importedKey = keyClient.importKey(keyImportOptions);
+     * System.out.printf("Key is imported with name %s and id %s \n", importedKey.name(), importedKey.id());
+     * 
* * @param keyImportOptions The key import configuration object containing information about the json web key being imported. * @throws NullPointerException if {@code keyImportOptions} is {@code null}. @@ -272,7 +282,14 @@ public Key importKey(KeyImportOptions keyImportOptions) { * *

Code Samples

*

Imports a new key into key vault. Prints out the details of the imported key.

- * {@codesnippet com.azure.keyvault.keys.keyclient.importKeyWithResponse#keyImportOptions-Context} + *
+     * KeyImportOptions keyImportOptions = new KeyImportOptions("keyName", jsonWebKeyToImport)
+     *   .hsm(true)
+     *   .expires(OffsetDateTime.now().plusDays(60));
+     *
+     * Key importedKey = keyClient.importKey(keyImportOptions, new Context(key1, value1)).value();
+     * System.out.printf("Key is imported with name %s and id %s \n", importedKey.name(), importedKey.id());
+     * 
* * @param keyImportOptions The key import configuration object containing information about the json web key being imported. * @param context Additional context that is passed through the Http pipeline during the service call. diff --git a/sdk/keyvault/azure-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/KeyAsyncClientJavaDocCodeSnippets.java b/sdk/keyvault/azure-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/KeyAsyncClientJavaDocCodeSnippets.java index bed44c3157fd8..995e3236e25e7 100644 --- a/sdk/keyvault/azure-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/KeyAsyncClientJavaDocCodeSnippets.java +++ b/sdk/keyvault/azure-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/KeyAsyncClientJavaDocCodeSnippets.java @@ -7,12 +7,14 @@ import com.azure.core.http.HttpClient; import com.azure.core.http.HttpPipeline; import com.azure.core.http.policy.HttpLogDetailLevel; -import com.azure.core.http.rest.Response; -import com.azure.core.http.rest.VoidResponse; import com.azure.core.test.models.RecordedData; import com.azure.core.test.policy.RecordNetworkCallPolicy; import com.azure.identity.credential.DefaultAzureCredential; -import com.azure.security.keyvault.keys.models.*; +import com.azure.security.keyvault.keys.models.EcKeyCreateOptions; +import com.azure.security.keyvault.keys.models.Key; +import com.azure.security.keyvault.keys.models.KeyBase; +import com.azure.security.keyvault.keys.models.KeyCreateOptions; +import com.azure.security.keyvault.keys.models.RsaKeyCreateOptions; import com.azure.security.keyvault.keys.models.webkey.KeyCurveName; import com.azure.security.keyvault.keys.models.webkey.KeyOperation; import com.azure.security.keyvault.keys.models.webkey.KeyType; @@ -89,7 +91,7 @@ public void createKey() { keyAsyncClient.createKey("keyName", KeyType.EC) .subscriberContext(Context.of(key1, value1, key2, value2)) .subscribe(keyResponse -> - System.out.printf("Key is created with name %s and id %s \n", keyResponse.name(), keyResponse.id())); + System.out.printf("Key is created with name %s and id %s \n", keyResponse.name(), keyResponse.id())); // END: com.azure.security.keyvault.keys.async.keyclient.createKey#string-keyType // BEGIN: com.azure.security.keyvault.keys.async.keyclient.createKey#keyCreateOptions @@ -99,7 +101,7 @@ public void createKey() { keyAsyncClient.createKey(keyCreateOptions) .subscriberContext(Context.of(key1, value1, key2, value2)) .subscribe(keyResponse -> - System.out.printf("Key is created with name %s and id %s \n", keyResponse.name(), keyResponse.id())); + System.out.printf("Key is created with name %s and id %s \n", keyResponse.name(), keyResponse.id())); // END: com.azure.security.keyvault.keys.async.keyclient.createKey#keyCreateOptions // BEGIN: com.azure.security.keyvault.keys.async.keyclient.createRsaKey#RsaKeyCreateOptions @@ -187,8 +189,8 @@ public void createKeyWithResponses() { keyAsyncClient.createEcKeyWithResponse(ecKeyCreateOptions) .subscriberContext(Context.of(key1, value1, key2, value2)) .subscribe(keyResponse -> - System.out.printf("Key is created with name %s and id %s \n", keyResponse.value().name(), - keyResponse.value().id())); + System.out.printf("Key is created with name %s and id %s \n", keyResponse.value().name(), + keyResponse.value().id())); // END: com.azure.security.keyvault.keys.async.keyclient.createEcKeyWithResponse#EcKeyCreateOptions } @@ -260,29 +262,31 @@ public void updateKeyWithResponseSnippets() { KeyAsyncClient keyAsyncClient = createAsyncClient(); // BEGIN: com.azure.security.keyvault.keys.async.keyclient.updateKeyWithResponse#KeyBase-keyOperations - keyAsyncClient.getKeyWithResponse("keyName").subscribe(keyResponse -> { - Key key = keyResponse.value(); - //Update the not before time of the key. - key.notBefore(OffsetDateTime.now().plusDays(50)); - keyAsyncClient.updateKeyWithResponse(key, KeyOperation.ENCRYPT, KeyOperation.DECRYPT) - .subscriberContext(Context.of(key1, value1, key2, value2)) - .subscribe(updatedKeyResponse -> - System.out.printf("Key's updated not before time %s \n", - updatedKeyResponse.value().notBefore().toString())); - }); + keyAsyncClient.getKeyWithResponse("keyName") + .subscribe(keyResponse -> { + Key key = keyResponse.value(); + //Update the not before time of the key. + key.notBefore(OffsetDateTime.now().plusDays(50)); + keyAsyncClient.updateKeyWithResponse(key, KeyOperation.ENCRYPT, KeyOperation.DECRYPT) + .subscriberContext(Context.of(key1, value1, key2, value2)) + .subscribe(updatedKeyResponse -> + System.out.printf("Key's updated not before time %s \n", + updatedKeyResponse.value().notBefore().toString())); + }); // END: com.azure.security.keyvault.keys.async.keyclient.updateKeyWithResponse#KeyBase-keyOperations // BEGIN: com.azure.security.keyvault.keys.async.keyclient.updateKeyWithResponse#KeyBase - keyAsyncClient.getKeyWithResponse("keyName").subscribe(keyResponse -> { - Key key = keyResponse.value(); - //Update the not before time of the key. - key.notBefore(OffsetDateTime.now().plusDays(50)); - keyAsyncClient.updateKeyWithResponse(key) - .subscriberContext(Context.of(key1, value1, key2, value2)) - .subscribe(updatedKeyResponse -> - System.out.printf("Key's updated not before time %s \n", - updatedKeyResponse.value().notBefore().toString())); - }); + keyAsyncClient.getKeyWithResponse("keyName") + .subscribe(keyResponse -> { + Key key = keyResponse.value(); + //Update the not before time of the key. + key.notBefore(OffsetDateTime.now().plusDays(50)); + keyAsyncClient.updateKeyWithResponse(key) + .subscriberContext(Context.of(key1, value1, key2, value2)) + .subscribe(updatedKeyResponse -> + System.out.printf("Key's updated not before time %s \n", + updatedKeyResponse.value().notBefore().toString())); + }); // END: com.azure.security.keyvault.keys.async.keyclient.updateKeyWithResponse#KeyBase } @@ -293,25 +297,29 @@ public void updateKeySnippets() { KeyAsyncClient keyAsyncClient = createAsyncClient(); // BEGIN: com.azure.security.keyvault.keys.async.keyclient.updateKey#KeyBase-keyOperations - keyAsyncClient.getKey("keyName").subscribe(keyResponse -> { - //Update the not before time of the key. - keyResponse.notBefore(OffsetDateTime.now().plusDays(50)); - keyAsyncClient.updateKey(keyResponse, KeyOperation.ENCRYPT, KeyOperation.DECRYPT) - .subscriberContext(Context.of(key1, value1, key2, value2)) - .subscribe(updatedKeyResponse -> - System.out.printf("Key's updated not before time %s \n", updatedKeyResponse.notBefore().toString())); - }); + keyAsyncClient.getKey("keyName") + .subscribe(keyResponse -> { + //Update the not before time of the key. + keyResponse.notBefore(OffsetDateTime.now().plusDays(50)); + keyAsyncClient.updateKey(keyResponse, KeyOperation.ENCRYPT, KeyOperation.DECRYPT) + .subscriberContext(Context.of(key1, value1, key2, value2)) + .subscribe(updatedKeyResponse -> + System.out.printf("Key's updated not before time %s \n", + updatedKeyResponse.notBefore().toString())); + }); // END: com.azure.security.keyvault.keys.async.keyclient.updateKey#KeyBase-keyOperations // BEGIN: com.azure.security.keyvault.keys.async.keyclient.updateKey#KeyBase - keyAsyncClient.getKey("keyName").subscribe(keyResponse -> { - //Update the not before time of the key. - keyResponse.notBefore(OffsetDateTime.now().plusDays(50)); - keyAsyncClient.updateKey(keyResponse) - .subscriberContext(Context.of(key1, value1, key2, value2)) - .subscribe(updatedKeyResponse -> - System.out.printf("Key's updated not before time %s \n", updatedKeyResponse.notBefore().toString())); - }); + keyAsyncClient.getKey("keyName") + .subscribe(keyResponse -> { + //Update the not before time of the key. + keyResponse.notBefore(OffsetDateTime.now().plusDays(50)); + keyAsyncClient.updateKey(keyResponse) + .subscriberContext(Context.of(key1, value1, key2, value2)) + .subscribe(updatedKeyResponse -> + System.out.printf("Key's updated not before time %s \n", + updatedKeyResponse.notBefore().toString())); + }); // END: com.azure.security.keyvault.keys.async.keyclient.updateKey#KeyBase } @@ -454,10 +462,11 @@ public void listKeySnippets() { */ public void listDeletedKeysSnippets() { KeyAsyncClient keyAsyncClient = createAsyncClient(); + // BEGIN: com.azure.security.keyvault.keys.async.keyclient.listDeletedKeys - keyAsyncClient.listDeletedKeys() - .subscriberContext(Context.of(key1, value1, key2, value2)) - .subscribe(deletedKey -> System.out.printf("Deleted key's recovery Id %s", deletedKey.recoveryId())); + keyAsyncClient.listDeletedKeys() + .subscriberContext(Context.of(key1, value1, key2, value2)) + .subscribe(deletedKey -> System.out.printf("Deleted key's recovery Id %s", deletedKey.recoveryId())); // END: com.azure.security.keyvault.keys.async.keyclient.listDeletedKeys } diff --git a/sdk/keyvault/azure-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/KeyClientJavaDocCodeSnippets.java b/sdk/keyvault/azure-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/KeyClientJavaDocCodeSnippets.java index 6782433b7b53a..001bb76cb3741 100644 --- a/sdk/keyvault/azure-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/KeyClientJavaDocCodeSnippets.java +++ b/sdk/keyvault/azure-keyvault-keys/src/samples/java/com/azure/security/keyvault/keys/KeyClientJavaDocCodeSnippets.java @@ -4,16 +4,17 @@ package com.azure.security.keyvault.keys; import com.azure.core.credentials.TokenCredential; -import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpPipeline; -import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.VoidResponse; -import com.azure.core.test.models.RecordedData; -import com.azure.core.test.policy.RecordNetworkCallPolicy; import com.azure.core.util.Context; import com.azure.identity.credential.DefaultAzureCredential; -import com.azure.security.keyvault.keys.models.*; +import com.azure.security.keyvault.keys.models.DeletedKey; +import com.azure.security.keyvault.keys.models.EcKeyCreateOptions; +import com.azure.security.keyvault.keys.models.Key; +import com.azure.security.keyvault.keys.models.KeyBase; +import com.azure.security.keyvault.keys.models.KeyCreateOptions; +import com.azure.security.keyvault.keys.models.KeyImportOptions; +import com.azure.security.keyvault.keys.models.RsaKeyCreateOptions; import com.azure.security.keyvault.keys.models.webkey.KeyCurveName; import com.azure.security.keyvault.keys.models.webkey.KeyOperation; import com.azure.security.keyvault.keys.models.webkey.KeyType; @@ -83,29 +84,6 @@ public void createKey() { } - /** - * Generates a code sample for using {@link KeyClient#importKey(KeyImportOptions)} - */ - public void importKeySnippets() { - // BEGIN: com.azure.keyvault.keys.keyclient.importKey#keyImportOptions - // JsonWebKey jsonWebKeyToImport; - // KeyImportOptions keyImportOptions = new KeyImportOptions("keyName", jsonWebKeyToImport) - // .hsm(true) - // .expires(OffsetDateTime.now().plusYears(1)); - // Key importedKey = keyClient.importKey(ecKeyCreateOptions); - // System.out.printf("Key is created with name %s and id %s \n", importedKey.name(), importedKey.id()); - // END: com.azure.keyvault.keys.keyclient.importKey#keyImportOptions - - // BEGIN: com.azure.keyvault.keys.keyclient.importKey#string-JsonWebKey - // JsonWebKey jsonWebKeyToImport; - // KeyImportOptions keyImportOptions = new KeyImportOptions("keyName", jsonWebKeyToImport) - // .hsm(true) - // .expires(OffsetDateTime.now().plusYears(1)); - // Key importedKey = keyClient.importKey(ecKeyCreateOptions); - // System.out.printf("Key is created with name %s and id %s \n", importedKey.name(), importedKey.id()); - // END: com.azure.keyvault.keys.keyclient.importKey#string-JsonWebKey - } - /** * Generates a code sample for using {@link KeyClient#deleteKey(String)} */ @@ -161,20 +139,6 @@ public void createKeyWithResponses() { // END: com.azure.keyvault.keys.keyclient.createEcKeyWithResponse#keyOptions } - /** - * Generates a code sample for using {@link KeyClient#importKeyWithResponse(KeyImportOptions, Context)} - */ - public void importKeyWithResponseSnippets() { - // BEGIN: com.azure.keyvault.keys.keyclient.importKeyWithResponse#keyImportOptions-Context - // JsonWebKey jsonWebKeyToImport; - // KeyImportOptions keyImportOptions = new KeyImportOptions("keyName", jsonWebKeyToImport) - // .hsm(true) - // .expires(OffsetDateTime.now().plusYears(1)); - // Key importedKey = keyClient.importKey(ecKeyCreateOptions); - // System.out.printf("Key is created with name %s and id %s \n", importedKey.name(), importedKey.id()); - // END: com.azure.keyvault.keys.keyclient.importKeyWithResponse#keyImportOptions-Context - } - /** * Generates a code sample for using {@link KeyClient#getKeyWithResponse(String, String, Context)} */