Skip to content

Commit

Permalink
Remove references to deprecated class CryptoKeyName. (#2427)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzlier-gcp authored Mar 18, 2020
1 parent 9cab04b commit 8186869
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions kms/src/main/java/com/example/CryptFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.example;

import com.google.cloud.kms.v1.CryptoKeyName;
import com.google.cloud.kms.v1.CryptoKeyPathName;
import com.google.cloud.kms.v1.DecryptResponse;
import com.google.cloud.kms.v1.EncryptResponse;
import com.google.cloud.kms.v1.KeyManagementServiceClient;
Expand All @@ -41,7 +41,7 @@ public static byte[] encrypt(
try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {

// The resource name of the cryptoKey
String resourceName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId);
String resourceName = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId);

// Encrypt the plaintext with Cloud KMS.
EncryptResponse response = client.encrypt(resourceName, ByteString.copyFrom(plaintext));
Expand All @@ -65,7 +65,7 @@ public static byte[] decrypt(
try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {

// The resource name of the cryptoKey
String resourceName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId);
String resourceName = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId);

// Decrypt the ciphertext with Cloud KMS.
DecryptResponse response = client.decrypt(resourceName, ByteString.copyFrom(ciphertext));
Expand Down
14 changes: 7 additions & 7 deletions kms/src/main/java/com/example/Snippets.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.google.cloud.kms.v1.CryptoKey;
import com.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose;
import com.google.cloud.kms.v1.CryptoKeyName;
import com.google.cloud.kms.v1.CryptoKeyPathName;
import com.google.cloud.kms.v1.CryptoKeyVersion;
import com.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState;
import com.google.cloud.kms.v1.CryptoKeyVersionName;
Expand Down Expand Up @@ -103,7 +103,7 @@ public static CryptoKeyVersion createCryptoKeyVersion(
try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {

// The resource name of the cryptoKey
String cryptoKey = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId);
String cryptoKey = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId);

CryptoKeyVersion version = CryptoKeyVersion.newBuilder().build();

Expand Down Expand Up @@ -243,7 +243,7 @@ public static Policy getCryptoKeyPolicy(
try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {

// The resource name of the cryptoKey version
String keyName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId);
String keyName = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId);

// Get the current IAM policy and add the new account to it.
Policy iamPolicy = client.getIamPolicy(keyName);
Expand Down Expand Up @@ -302,7 +302,7 @@ public static Policy addMemberToCryptoKeyPolicy(
try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {

// The resource name of the cryptoKey version
String keyName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId);
String keyName = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId);

// Get the current IAM policy
Policy iamPolicy = client.getIamPolicy(keyName);
Expand Down Expand Up @@ -392,7 +392,7 @@ public static Policy removeMemberFromCryptoKeyPolicy(
try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {

// The resource name of the cryptoKey version
String keyName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId);
String keyName = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId);

// Get the current IAM policy
Policy iamPolicy = client.getIamPolicy(keyName);
Expand Down Expand Up @@ -531,7 +531,7 @@ public static List<CryptoKeyVersion> listCryptoKeyVersions(
try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {

// The resource name of the CryptoKey to search.
String parent = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId);
String parent = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId);

// Retrieve a paginated list of CryptoKeyVersions
ListCryptoKeyVersionsPagedResponse response = client.listCryptoKeyVersions(parent);
Expand All @@ -557,7 +557,7 @@ public static CryptoKey setPrimaryVersion(String projectId, String locationId, S
try (KeyManagementServiceClient client = KeyManagementServiceClient.create()) {

// The resource name of the CryptoKey to update.
String resourceName = CryptoKeyName.format(projectId, locationId, keyRingId, cryptoKeyId);
String resourceName = CryptoKeyPathName.format(projectId, locationId, keyRingId, cryptoKeyId);

// Update the primary CryptoKey version
CryptoKey key = client.updateCryptoKeyPrimaryVersion(resourceName, versionId);
Expand Down

0 comments on commit 8186869

Please sign in to comment.