Skip to content

Commit bf13cd6

Browse files
authored
chore: Fix nits in examples (#215)
1 parent d816e96 commit bf13cd6

File tree

11 files changed

+44
-44
lines changed

11 files changed

+44
-44
lines changed

Examples/runtimes/java/DynamoDbEncryption/src/main/java/software/amazon/cryptography/examples/BasicPutGetExample.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,17 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
8585
//
8686
// For this example, we have designed our DynamoDb table such that any attribute name with
8787
// the ":" prefix should be considered unauthenticated.
88-
final String unauthAttrPrefix = ":";
88+
final String unsignAttrPrefix = ":";
8989

90-
// 3. Create the DynamoDb Encryption configuration for the table we will be writing to.
90+
// 4. Create the DynamoDb Encryption configuration for the table we will be writing to.
9191
final Map<String, DynamoDbTableEncryptionConfig> tableConfigs = new HashMap<>();
9292
final DynamoDbTableEncryptionConfig config = DynamoDbTableEncryptionConfig.builder()
9393
.logicalTableName(ddbTableName)
9494
.partitionKeyName("partition_key")
9595
.sortKeyName("sort_key")
9696
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
9797
.keyring(kmsKeyring)
98-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
98+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
9999
// Specifying an algorithm suite is not required,
100100
// but is done here to demonstrate how to do so.
101101
// We suggest using the
@@ -109,22 +109,22 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
109109
.build();
110110
tableConfigs.put(ddbTableName, config);
111111

112-
// 4. Create the DynamoDb Encryption Interceptor
112+
// 5. Create the DynamoDb Encryption Interceptor
113113
DynamoDbEncryptionInterceptor encryptionInterceptor = DynamoDbEncryptionInterceptor.builder()
114114
.config(DynamoDbTablesEncryptionConfig.builder()
115115
.tableEncryptionConfigs(tableConfigs)
116116
.build())
117117
.build();
118118

119-
// 5. Create a new AWS SDK DynamoDb client using the DynamoDb Encryption Interceptor above
119+
// 6. Create a new AWS SDK DynamoDb client using the DynamoDb Encryption Interceptor above
120120
final DynamoDbClient ddb = DynamoDbClient.builder()
121121
.overrideConfiguration(
122122
ClientOverrideConfiguration.builder()
123123
.addExecutionInterceptor(encryptionInterceptor)
124124
.build())
125125
.build();
126126

127-
// 6. Put an item into our table using the above client.
127+
// 7. Put an item into our table using the above client.
128128
// Before the item gets sent to DynamoDb, it will be encrypted
129129
// client-side, according to our configuration.
130130
final HashMap<String, AttributeValue> item = new HashMap<>();
@@ -144,7 +144,7 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
144144
// Demonstrate that PutItem succeeded
145145
assert 200 == putResponse.sdkHttpResponse().statusCode();
146146

147-
// 7. Get the item back from our table using the same client.
147+
// 8. Get the item back from our table using the same client.
148148
// The client will decrypt the item client-side, and return
149149
// back the original item.
150150
final HashMap<String, AttributeValue> keyToGet = new HashMap<>();

Examples/runtimes/java/DynamoDbEncryption/src/main/java/software/amazon/cryptography/examples/clientsupplier/ClientSupplierExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static void ClientSupplierPutItemGetItem(String ddbTableName, String keyA
107107
//
108108
// For this example, we currently authenticate all attributes. To make it easier to
109109
// add unauthenticated attributes in the future, we define a prefix ":" for such attributes.
110-
final String unauthAttrPrefix = ":";
110+
final String unsignAttrPrefix = ":";
111111

112112
// 4. Create the DynamoDb Encryption configuration for the table we will be writing to.
113113
final Map<String, DynamoDbTableEncryptionConfig> tableConfigs = new HashMap<>();
@@ -117,7 +117,7 @@ public static void ClientSupplierPutItemGetItem(String ddbTableName, String keyA
117117
.sortKeyName("sort_key")
118118
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
119119
.keyring(mrkKeyringWithClientSupplier)
120-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
120+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
121121
.build();
122122
tableConfigs.put(ddbTableName, config);
123123

@@ -208,7 +208,7 @@ public static void ClientSupplierPutItemGetItem(String ddbTableName, String keyA
208208
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
209209
// Provide discovery keyring here
210210
.keyring(mrkDiscoveryClientSupplierKeyring)
211-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
211+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
212212
.build();
213213
onlyReplicaKeyTableConfigs.put(ddbTableName, onlyReplicaKeyConfig);
214214

Examples/runtimes/java/DynamoDbEncryption/src/main/java/software/amazon/cryptography/examples/enhanced/EnhancedPutGetExample.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
8484
//
8585
// For this example, we have designed our DynamoDb table such that any attribute name with
8686
// the ":" prefix should be considered unauthenticated.
87-
final String unauthAttrPrefix = ":";
87+
final String unsignAttrPrefix = ":";
8888

89-
// 3. Create the DynamoDb Encryption configuration for the table we will be writing to,
89+
// 4. Create the DynamoDb Encryption configuration for the table we will be writing to,
9090
final Map<String, DynamoDbEnhancedTableEncryptionConfig> tableConfigs = new HashMap<>();
9191
tableConfigs.put(ddbTableName,
9292
DynamoDbEnhancedTableEncryptionConfig.builder()
9393
.logicalTableName(ddbTableName)
9494
.keyring(kmsKeyring)
95-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
95+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
9696
.schemaOnEncrypt(tableSchema)
9797
// Specifying an algorithm suite is not required,
9898
// but is done here to demonstrate how to do so.
@@ -106,30 +106,30 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
106106
DBEAlgorithmSuiteId.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384_SYMSIG_HMAC_SHA384)
107107
.build());
108108

109-
// 4. Create the DynamoDb Encryption Interceptor, using the DynamoDbEnhancedClientEncryption helper
110-
final DynamoDbEncryptionInterceptor interceptor =
109+
// 5. Create the DynamoDb Encryption Interceptor, using the DynamoDbEnhancedClientEncryption helper
110+
final DynamoDbEncryptionInterceptor encryptionInterceptor =
111111
DynamoDbEnhancedClientEncryption.CreateDynamoDbEncryptionInterceptor(
112112
CreateDynamoDbEncryptionInterceptorInput.builder()
113113
.tableEncryptionConfigs(tableConfigs)
114114
.build()
115115
);
116116

117-
// 5. Create a new AWS SDK DynamoDb client using the DynamoDb Encryption Interceptor above
117+
// 6. Create a new AWS SDK DynamoDb client using the DynamoDb Encryption Interceptor above
118118
final DynamoDbClient ddb = DynamoDbClient.builder()
119119
.overrideConfiguration(
120120
ClientOverrideConfiguration.builder()
121-
.addExecutionInterceptor(interceptor)
121+
.addExecutionInterceptor(encryptionInterceptor)
122122
.build())
123123
.build();
124124

125-
// 6. Create the DynamoDbEnhancedClient using the AWS SDK Client created above,
125+
// 7. Create the DynamoDbEnhancedClient using the AWS SDK Client created above,
126126
// and create a Table with your modelled class
127127
final DynamoDbEnhancedClient enhancedClient = DynamoDbEnhancedClient.builder()
128128
.dynamoDbClient(ddb)
129129
.build();
130130
final DynamoDbTable<SimpleClass> table = enhancedClient.table(ddbTableName, tableSchema);
131131

132-
// 7. Put an item into your table using the DynamoDb Enhanced Client.
132+
// 8. Put an item into your table using the DynamoDb Enhanced Client.
133133
// The item will be encrypted client-side according to your
134134
// configuration above before it is sent to DynamoDb.
135135
final SimpleClass item = new SimpleClass();
@@ -141,7 +141,7 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
141141

142142
table.putItem(item);
143143

144-
// 8. Get the item back from the table using the DynamoDb Enhanced Client.
144+
// 9. Get the item back from the table using the DynamoDb Enhanced Client.
145145
// The item will be decrypted client-side, and you will get back the
146146
// original item.
147147
final Key key = Key.builder()

Examples/runtimes/java/DynamoDbEncryption/src/main/java/software/amazon/cryptography/examples/itemencryptor/ItemEncryptDecryptExample.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,16 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
8989
//
9090
// For this example, we have designed our DynamoDb table such that any attribute name with
9191
// the ":" prefix should be considered unauthenticated.
92-
final String unauthAttrPrefix = ":";
92+
final String unsignAttrPrefix = ":";
9393

94-
// 3. Create the configuration for the DynamoDb Item Encryptor
94+
// 4. Create the configuration for the DynamoDb Item Encryptor
9595
final DynamoDbItemEncryptorConfig config = DynamoDbItemEncryptorConfig.builder()
9696
.logicalTableName(ddbTableName)
9797
.partitionKeyName("partition_key")
9898
.sortKeyName("sort_key")
9999
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
100100
.keyring(kmsKeyring)
101-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
101+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
102102
// Specifying an algorithm suite is not required,
103103
// but is done here to demonstrate how to do so.
104104
// We suggest using the
@@ -111,12 +111,12 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
111111
DBEAlgorithmSuiteId.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY_ECDSA_P384_SYMSIG_HMAC_SHA384)
112112
.build();
113113

114-
// 4. Create the DynamoDb Item Encryptor
114+
// 5. Create the DynamoDb Item Encryptor
115115
final DynamoDbItemEncryptor itemEncryptor = DynamoDbItemEncryptor.builder()
116116
.DynamoDbItemEncryptorConfig(config)
117117
.build();
118118

119-
// 5. Directly encrypt a DynamoDb item using the DynamoDb Item Encryptor
119+
// 6. Directly encrypt a DynamoDb item using the DynamoDb Item Encryptor
120120
final Map<String, AttributeValue> originalItem = new HashMap<>();
121121
originalItem.put("partition_key", AttributeValue.builder().s("ItemEncryptDecryptExample").build());
122122
originalItem.put("sort_key", AttributeValue.builder().n("0").build());
@@ -135,7 +135,7 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
135135
assert encryptedItem.get("sort_key").n().equals("0");
136136
assert encryptedItem.get("attribute1").b() != null;
137137

138-
// 6. Directly decrypt the encrypted item using the DynamoDb Item Encryptor
138+
// 7. Directly decrypt the encrypted item using the DynamoDb Item Encryptor
139139
final Map<String, AttributeValue> decryptedItem = itemEncryptor.DecryptItem(
140140
DecryptItemInput.builder()
141141
.encryptedItem(encryptedItem)

Examples/runtimes/java/DynamoDbEncryption/src/main/java/software/amazon/cryptography/examples/keyring/HierarchicalKeyringExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public static void HierarchicalKeyringGetItemPutItem(
156156
//
157157
// For this example, we currently authenticate all attributes. To make it easier to
158158
// add unauthenticated attributes in the future, we define a prefix ":" for such attributes.
159-
final String unauthAttrPrefix = ":";
159+
final String unsignAttrPrefix = ":";
160160

161161
// 6. Create the DynamoDb Encryption configuration for the table we will be writing to.
162162
final Map<String, DynamoDbTableEncryptionConfig> tableConfigs = new HashMap<>();
@@ -166,7 +166,7 @@ public static void HierarchicalKeyringGetItemPutItem(
166166
.sortKeyName("sort_key")
167167
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
168168
.keyring(hierarchicalKeyring)
169-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
169+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
170170
.build();
171171
tableConfigs.put(ddbTableName, config);
172172

Examples/runtimes/java/DynamoDbEncryption/src/main/java/software/amazon/cryptography/examples/keyring/KmsRsaKeyringExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static void KmsRsaKeyringGetItemPutItem(String ddbTableName, String rsaKe
137137
//
138138
// For this example, we currently authenticate all attributes. To make it easier to
139139
// add unauthenticated attributes in the future, we define a prefix ":" for such attributes.
140-
final String unauthAttrPrefix = ":";
140+
final String unsignAttrPrefix = ":";
141141

142142
// 5. Create the DynamoDb Encryption configuration for the table we will be writing to.
143143
// Note: To use the KMS RSA keyring, your table config must specify an algorithmSuite
@@ -149,7 +149,7 @@ public static void KmsRsaKeyringGetItemPutItem(String ddbTableName, String rsaKe
149149
.sortKeyName("sort_key")
150150
.attributeActionsOnEncrypt(attributeActions)
151151
.keyring(awsKmsRsaKeyring)
152-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
152+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
153153
// Specify algorithmSuite without asymmetric signing here
154154
// As of v3.0.0, the only supported algorithmSuite without asymmetric signing is
155155
// ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY_SYMSIG_HMAC_SHA384.

Examples/runtimes/java/DynamoDbEncryption/src/main/java/software/amazon/cryptography/examples/keyring/MrkDiscoveryMultiKeyringExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static void MultiMrkDiscoveryKeyringGetItemPutItem(String ddbTableName, S
104104
//
105105
// For this example, we currently authenticate all attributes. To make it easier to
106106
// add unauthenticated attributes in the future, we define a prefix ":" for such attributes.
107-
final String unauthAttrPrefix = ":";
107+
final String unsignAttrPrefix = ":";
108108

109109
// 4. Create the DynamoDb Encryption configuration for the table we will be writing to.
110110
final Map<String, DynamoDbTableEncryptionConfig> tableConfigs = new HashMap<>();
@@ -114,7 +114,7 @@ public static void MultiMrkDiscoveryKeyringGetItemPutItem(String ddbTableName, S
114114
.sortKeyName("sort_key")
115115
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
116116
.keyring(encryptKeyring)
117-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
117+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
118118
.build();
119119
tableConfigs.put(ddbTableName, config);
120120

@@ -184,7 +184,7 @@ public static void MultiMrkDiscoveryKeyringGetItemPutItem(String ddbTableName, S
184184
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
185185
// Add decrypt keyring here
186186
.keyring(decryptKeyring)
187-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
187+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
188188
.build();
189189
tableConfigsForDecrypt.put(ddbTableName, configForDecrypt);
190190

Examples/runtimes/java/DynamoDbEncryption/src/main/java/software/amazon/cryptography/examples/keyring/MultiKeyringExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static void MultiKeyringGetItemPutItem(String ddbTableName, String keyArn
136136
//
137137
// For this example, we currently authenticate all attributes. To make it easier to
138138
// add unauthenticated attributes in the future, we define a prefix ":" for such attributes.
139-
final String unauthAttrPrefix = ":";
139+
final String unsignAttrPrefix = ":";
140140

141141
// 6. Create the DynamoDb Encryption configuration for the table we will be writing to.
142142
// Note that this example creates one config/client combination for PUT, and another
@@ -151,7 +151,7 @@ public static void MultiKeyringGetItemPutItem(String ddbTableName, String keyArn
151151
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
152152
// Multi-keyring is added here
153153
.keyring(multiKeyring)
154-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
154+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
155155
.build();
156156
tableConfigs.put(ddbTableName, config);
157157

@@ -221,7 +221,7 @@ public static void MultiKeyringGetItemPutItem(String ddbTableName, String keyArn
221221
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
222222
// Raw AES keyring is added here
223223
.keyring(rawAesKeyring)
224-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
224+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
225225
.build();
226226
onlyAesKeyringTableConfigs.put(ddbTableName, onlyAesKeyringConfig);
227227

Examples/runtimes/java/DynamoDbEncryption/src/main/java/software/amazon/cryptography/examples/keyring/MultiMrkKeyringExample.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static void MultiMrkKeyringGetItemPutItem(String ddbTableName, String mrk
128128
//
129129
// For this example, we currently authenticate all attributes. To make it easier to
130130
// add unauthenticated attributes in the future, we define a prefix ":" for such attributes.
131-
final String unauthAttrPrefix = ":";
131+
final String unsignAttrPrefix = ":";
132132

133133
// 4. Create the DynamoDb Encryption configuration for the table we will be writing to.
134134
final Map<String, DynamoDbTableEncryptionConfig> tableConfigs = new HashMap<>();
@@ -138,7 +138,7 @@ public static void MultiMrkKeyringGetItemPutItem(String ddbTableName, String mrk
138138
.sortKeyName("sort_key")
139139
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
140140
.keyring(awsKmsMrkMultiKeyring)
141-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
141+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
142142
.build();
143143
tableConfigs.put(ddbTableName, config);
144144

@@ -221,7 +221,7 @@ public static void MultiMrkKeyringGetItemPutItem(String ddbTableName, String mrk
221221
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
222222
// Only replica keyring added here
223223
.keyring(onlyReplicaKeyMrkMultiKeyring)
224-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
224+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
225225
.build();
226226
onlyReplicaKeyTableConfigs.put(ddbTableName, onlyReplicaKeyConfig);
227227

@@ -277,7 +277,7 @@ public static void MultiMrkKeyringGetItemPutItem(String ddbTableName, String mrk
277277
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
278278
// Only single-region key keyring added here
279279
.keyring(onlySrkKeyring)
280-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
280+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
281281
.build();
282282
onlySrkTableConfigs.put(ddbTableName, onlySrkConfig);
283283

Examples/runtimes/java/DynamoDbEncryption/src/main/java/software/amazon/cryptography/examples/keyring/RawAesKeyringExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static void RawAesKeyringGetItemPutItem(String ddbTableName, ByteBuffer a
103103
//
104104
// For this example, we currently authenticate all attributes. To make it easier to
105105
// add unauthenticated attributes in the future, we define a prefix ":" for such attributes.
106-
final String unauthAttrPrefix = ":";
106+
final String unsignAttrPrefix = ":";
107107

108108
// 4. Create the DynamoDb Encryption configuration for the table we will be writing to.
109109
final Map<String, DynamoDbTableEncryptionConfig> tableConfigs = new HashMap<>();
@@ -113,7 +113,7 @@ public static void RawAesKeyringGetItemPutItem(String ddbTableName, ByteBuffer a
113113
.sortKeyName("sort_key")
114114
.attributeActionsOnEncrypt(attributeActionsOnEncrypt)
115115
.keyring(rawAesKeyring)
116-
.allowedUnsignedAttributePrefix(unauthAttrPrefix)
116+
.allowedUnsignedAttributePrefix(unsignAttrPrefix)
117117
.build();
118118
tableConfigs.put(ddbTableName, config);
119119

0 commit comments

Comments
 (0)