Skip to content

Commit

Permalink
fixing checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
samvaity committed Jul 23, 2019
1 parent ff28b53 commit 23a60d0
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ public Response<Key> createEcKeyWithResponse(EcKeyCreateOptions ecKeyCreateOptio
*
* <p><strong>Code Samples</strong></p>
* <p>Imports a new key into key vault. Prints out the details of the imported key.</p>
* {@codesnippet com.azure.keyvault.keys.keyclient.importKey#string-JsonWebKey}
* <pre>
* Key importedKey = keyClient.importKey("keyName", jsonWebKeyToImport);
* System.out.printf("Key is imported with name %s and id %s \n", importedKey.name(), importedKey.id());
* </pre>
*
* @param name The name for the imported key.
* @param keyMaterial The Json web key being imported.
Expand All @@ -250,7 +253,14 @@ public Key importKey(String name, JsonWebKey keyMaterial) {
*
* <p><strong>Code Samples</strong></p>
* <p>Imports a new key into key vault. Prints out the details of the imported key.</p>
* {@codesnippet com.azure.keyvault.keys.keyclient.importKey#keyImportOptions}
* <pre>
* 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());
* </pre>
*
* @param keyImportOptions The key import configuration object containing information about the json web key being imported.
* @throws NullPointerException if {@code keyImportOptions} is {@code null}.
Expand All @@ -272,7 +282,14 @@ public Key importKey(KeyImportOptions keyImportOptions) {
*
* <p><strong>Code Samples</strong></p>
* <p>Imports a new key into key vault. Prints out the details of the imported key.</p>
* {@codesnippet com.azure.keyvault.keys.keyclient.importKeyWithResponse#keyImportOptions-Context}
* <pre>
* 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());
* </pre>
*
* @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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)}
*/
Expand Down Expand Up @@ -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)}
*/
Expand Down

0 comments on commit 23a60d0

Please sign in to comment.