Skip to content
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

adds KMS region tags #502

Merged
merged 5 commits into from
Feb 7, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kms/src/main/java/com/example/CryptFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public static byte[] encrypt(String projectId, String ringId, String keyId, byte
return encrypt(projectId, ringId, keyId, null, plaintext);
}

// [START kms_encrypt]
/**
* Encrypts the given bytes, using the specified crypto key version.
*/
Expand All @@ -95,7 +96,9 @@ public static byte[] encrypt(

return response.decodeCiphertext();
}
// [END kms_encrypt]

// [START kms_decrypt]
/**
* Decrypts the given encrypted bytes, using the specified crypto key.
*/
Expand All @@ -117,6 +120,7 @@ public static byte[] decrypt(String projectId, String ringId, String keyId, byte

return response.decodePlaintext();
}
// [END kms_decrypt]

public static void main(String[] args) throws IOException {
CryptFileCommands commands = new CryptFileCommands();
Expand Down
4 changes: 2 additions & 2 deletions kms/src/main/java/com/example/CryptFileCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ static class Args {
String ringId;
@Argument(metaVar = "keyId", required = true, index = 1, usage = "The key id")
String keyId;
@Argument(metaVar = "inFile", required = true, index = 1, usage = "The source file")
@Argument(metaVar = "inFile", required = true, index = 2, usage = "The source file")
String inFile;
@Argument(metaVar = "outFile", required = true, index = 1, usage = "The destination file")
@Argument(metaVar = "outFile", required = true, index = 3, usage = "The destination file")
String outFile;
}

Expand Down
24 changes: 24 additions & 0 deletions kms/src/main/java/com/example/Snippets.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public static CloudKMS createAuthorizedClient() throws IOException {
.build();
}

// [START kms_create_keyring]
/**
* Creates a new key ring with the given id.
*/
Expand All @@ -86,7 +87,9 @@ public static KeyRing createKeyRing(String projectId, String ringId) throws IOEx
System.out.println(keyring);
return keyring;
}
// [END kms_create_keyring]

// [START kms_create_cryptokey]
/**
* Creates a new crypto key with the given id.
*/
Expand Down Expand Up @@ -114,7 +117,9 @@ public static CryptoKey createCryptoKey(String projectId, String ringId, String
System.out.println(createdKey);
return createdKey;
}
// [END kms_create_cryptokey]

// [START kms_create_cryptokey_version]
/**
* Creates a new crypto key version for the given id.
*/
Expand All @@ -138,7 +143,9 @@ public static void createCryptoKeyVersion(

System.out.println(newVersion);
}
// [END kms_create_cryptokey_version]

// [START kms_disable_cryptokey_version]
/**
* Disables the given version of the crypto key.
*/
Expand Down Expand Up @@ -166,7 +173,9 @@ public static CryptoKeyVersion disableCryptoKeyVersion(
System.out.println(response);
return response;
}
// [END kms_disable_cryptokey_version]

// [START kms_destroy_cryptokey_version]
/**
* Marks the given version of a crypto key to be destroyed at a scheduled future point.
*/
Expand All @@ -192,7 +201,9 @@ public static CryptoKeyVersion destroyCryptoKeyVersion(
System.out.println(destroyed);
return destroyed;
}
// [END kms_destroy_cryptokey_version]

// [START kms_get_cryptokey_policy]
/**
* Retrieves the IAM policy for the given crypto key.
*/
Expand All @@ -215,7 +226,9 @@ public static Policy getCryptoKeyPolicy(String projectId, String ringId, String
System.out.println(iamPolicy.getBindings());
return iamPolicy;
}
// [END kms_get_cryptokey_policy]

// [START kms_get_keyring_policy]
/**
* Retrieves the IAM policy for the given crypto key.
*/
Expand All @@ -237,7 +250,9 @@ public static Policy getKeyRingPolicy(String projectId, String ringId) throws IO
System.out.println(iamPolicy.getBindings());
return iamPolicy;
}
// [END kms_get_keyring_policy]

// [START kms_add_member_to_cryptokey_policy]
/**
* Adds the given member to the given key, with the given role.
*
Expand Down Expand Up @@ -296,7 +311,9 @@ public static Policy addMemberToCryptoKeyPolicy(
System.out.println("Response: " + newIamPolicy);
return newIamPolicy;
}
// [END kms_add_member_to_cryptokey_policy]

// [START kms_add_member_to_keyring_policy]
/**
* Adds the given member to the given keyring, with the given role.
*
Expand Down Expand Up @@ -354,7 +371,9 @@ public static Policy addMemberToKeyRingPolicy(
System.out.println("Response: " + newIamPolicy);
return newIamPolicy;
}
// [END kms_add_member_to_keyring_policy]

// [START kms_remove_member_from_cryptokey_policy]
/**
* Removes the given member from the given policy.
*/
Expand Down Expand Up @@ -395,7 +414,9 @@ public static Policy removeMemberFromCryptoKeyPolicy(
System.out.println("Response: " + newIamPolicy);
return newIamPolicy;
}
// [END kms_remove_member_from_cryptokey_policy]

// [START kms_remove_member_from_keyring_policy]
/**
* Removes the given member from the given policy.
*/
Expand Down Expand Up @@ -431,7 +452,9 @@ public static Policy removeMemberFromKeyRingPolicy(
System.out.println("Response: " + newIamPolicy);
return newIamPolicy;
}
// [END kms_remove_member_from_keyring_policy]

// [START kms_quickstart]
/**
* Prints all the keyrings in the given project.
*/
Expand Down Expand Up @@ -461,6 +484,7 @@ public static void listKeyRings(String projectId) throws IOException {
System.out.println("No keyrings defined.");
}
}
// [END kms_quickstart]

/**
* Prints all the keys in the given key ring.
Expand Down