Skip to content

Commit d8b01b5

Browse files
chore(Examples): Update attribute names for some examples (#212)
1 parent 7b1ffbd commit d8b01b5

File tree

39 files changed

+234
-682
lines changed

39 files changed

+234
-682
lines changed

.github/workflows/ci_examples_java.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,5 @@ jobs:
109109
# Run simple examples
110110
gradle -p runtimes/java/DynamoDbEncryption test
111111
# Run migration examples
112-
gradle -p runtimes/java/Migration/AWSDBE test
113-
gradle -p runtimes/java/Migration/DDBEC test
112+
gradle -p runtimes/java/Migration/DDBECToAWSDBE test
114113

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
@@ -53,9 +53,9 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
5353
final Map<String, CryptoAction> attributeActionsOnEncrypt = new HashMap<>();
5454
attributeActionsOnEncrypt.put("partition_key", CryptoAction.SIGN_ONLY); // Our partition attribute must be SIGN_ONLY
5555
attributeActionsOnEncrypt.put("sort_key", CryptoAction.SIGN_ONLY); // Our sort attribute must be SIGN_ONLY
56-
attributeActionsOnEncrypt.put("data_to_encrypt", CryptoAction.ENCRYPT_AND_SIGN);
57-
attributeActionsOnEncrypt.put("data_to_sign", CryptoAction.SIGN_ONLY);
58-
attributeActionsOnEncrypt.put(":data_to_ignore", CryptoAction.DO_NOTHING);
56+
attributeActionsOnEncrypt.put("attribute1", CryptoAction.ENCRYPT_AND_SIGN);
57+
attributeActionsOnEncrypt.put("attribute2", CryptoAction.SIGN_ONLY);
58+
attributeActionsOnEncrypt.put(":attribute3", CryptoAction.DO_NOTHING);
5959

6060
// 3. Configure which attributes we expect to be included in the signature
6161
// when reading items. There are two options for configuring this:
@@ -132,9 +132,9 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
132132
final HashMap<String, AttributeValue> item = new HashMap<>();
133133
item.put("partition_key", AttributeValue.builder().s("BasicPutGetExample").build());
134134
item.put("sort_key", AttributeValue.builder().n("0").build());
135-
item.put("data_to_encrypt", AttributeValue.builder().s("encrypt and sign me!").build());
136-
item.put("data_to_sign", AttributeValue.builder().s("sign me!").build());
137-
item.put(":data_to_ignore", AttributeValue.builder().s("ignore me!").build());
135+
item.put("attribute1", AttributeValue.builder().s("encrypt and sign me!").build());
136+
item.put("attribute2", AttributeValue.builder().s("sign me!").build());
137+
item.put(":attribute3", AttributeValue.builder().s("ignore me!").build());
138138

139139
final PutItemRequest putRequest = PutItemRequest.builder()
140140
.tableName(ddbTableName)
@@ -163,7 +163,7 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
163163
// Demonstrate that GetItem succeeded and returned the decrypted item
164164
assert 200 == getResponse.sdkHttpResponse().statusCode();
165165
final Map<String, AttributeValue> returnedItem = getResponse.item();
166-
assert returnedItem.get("data_to_encrypt").s().equals("encrypt and sign me!");
166+
assert returnedItem.get("attribute1").s().equals("encrypt and sign me!");
167167

168168
}
169169

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
137137
final SimpleClass item = new SimpleClass();
138138
item.setPartitionKey("EnhancedPutGetExample");
139139
item.setSortKey(0);
140-
item.setEncryptAndSign("encrypt and sign me!");
141-
item.setSignOnly("sign me!");
142-
item.setDoNothing("ignore me!");
140+
item.setAttribute1("encrypt and sign me!");
141+
item.setAttribute2("sign me!");
142+
item.setAttribute3("ignore me!");
143143

144144
table.putItem(item);
145145

@@ -154,7 +154,7 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
154154
(GetItemEnhancedRequest.Builder requestBuilder) -> requestBuilder.key(key));
155155

156156
// Demonstrate we get the original item back
157-
assert result.getEncryptAndSign().equals("encrypt and sign me!");
157+
assert result.getAttribute1().equals("encrypt and sign me!");
158158
}
159159

160160
public static void main(final String[] args) {

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public class SimpleClass {
1616

1717
private String partitionKey;
1818
private int sortKey;
19-
private String encryptAndSign;
20-
private String doNothing;
21-
private String signOnly;
19+
private String attribute1;
20+
private String attribute2;
21+
private String attribute3;
2222

2323
@DynamoDbPartitionKey
2424
@DynamoDbAttribute(value = "partition_key")
@@ -40,31 +40,31 @@ public void setSortKey(int sortKey) {
4040
this.sortKey = sortKey;
4141
}
4242

43-
public String getEncryptAndSign() {
44-
return this.encryptAndSign;
43+
public String getAttribute1() {
44+
return this.attribute1;
4545
}
4646

47-
public void setEncryptAndSign(String encryptAndSign) {
48-
this.encryptAndSign = encryptAndSign;
47+
public void setAttribute1(String attribute1) {
48+
this.attribute1 = attribute1;
4949
}
5050

5151
@DynamoDbEncryptionSignOnly
52-
public String getSignOnly() {
53-
return this.signOnly;
52+
public String getAttribute2() {
53+
return this.attribute2;
5454
}
5555

56-
public void setSignOnly(String signOnly) {
57-
this.signOnly = signOnly;
56+
public void setAttribute2(String attribute2) {
57+
this.attribute2 = attribute2;
5858
}
5959

6060
@DynamoDbEncryptionDoNothing
61-
public String getDoNothing() {
62-
return this.doNothing;
61+
public String getAttribute3() {
62+
return this.attribute3;
6363
}
6464

65-
@DynamoDbAttribute(value = ":do_nothing")
66-
public void setDoNothing(String doNothing) {
67-
this.doNothing = doNothing;
65+
@DynamoDbAttribute(value = ":attribute3")
66+
public void setAttribute3(String attribute3) {
67+
this.attribute3 = attribute3;
6868
}
6969
}
7070

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
5757
final Map<String, CryptoAction> attributeActionsOnEncrypt = new HashMap<>();
5858
attributeActionsOnEncrypt.put("partition_key", CryptoAction.SIGN_ONLY); // Our partition attribute must be SIGN_ONLY
5959
attributeActionsOnEncrypt.put("sort_key", CryptoAction.SIGN_ONLY); // Our sort attribute must be SIGN_ONLY
60-
attributeActionsOnEncrypt.put("data_to_encrypt", CryptoAction.ENCRYPT_AND_SIGN);
61-
attributeActionsOnEncrypt.put("data_to_sign", CryptoAction.SIGN_ONLY);
62-
attributeActionsOnEncrypt.put(":data_to_ignore", CryptoAction.DO_NOTHING);
60+
attributeActionsOnEncrypt.put("attribute1", CryptoAction.ENCRYPT_AND_SIGN);
61+
attributeActionsOnEncrypt.put("attribute2", CryptoAction.SIGN_ONLY);
62+
attributeActionsOnEncrypt.put(":attribute3", CryptoAction.DO_NOTHING);
6363

6464
// 3. Configure which attributes we expect to be included in the signature
6565
// when reading items. There are two options for configuring this:
@@ -122,9 +122,9 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
122122
final Map<String, AttributeValue> originalItem = new HashMap<>();
123123
originalItem.put("partition_key", AttributeValue.builder().s("ItemEncryptDecryptExample").build());
124124
originalItem.put("sort_key", AttributeValue.builder().n("0").build());
125-
originalItem.put("data_to_encrypt", AttributeValue.builder().s("encrypt and sign me!").build());
126-
originalItem.put("data_to_sign", AttributeValue.builder().s("sign me!").build());
127-
originalItem.put(":data_to_ignore", AttributeValue.builder().s("ignore me!").build());
125+
originalItem.put("attribute1", AttributeValue.builder().s("encrypt and sign me!").build());
126+
originalItem.put("attribute2", AttributeValue.builder().s("sign me!").build());
127+
originalItem.put(":attribute3", AttributeValue.builder().s("ignore me!").build());
128128

129129
final Map<String, AttributeValue> encryptedItem = itemEncryptor.EncryptItem(
130130
EncryptItemInput.builder()
@@ -135,7 +135,7 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
135135
// Demonstrate that the item has been encrypted
136136
assert encryptedItem.get("partition_key").s().equals("ItemEncryptDecryptExample");
137137
assert encryptedItem.get("sort_key").n().equals("0");
138-
assert encryptedItem.get("data_to_encrypt").b() != null;
138+
assert encryptedItem.get("attribute1").b() != null;
139139

140140
// 6. Directly decrypt the encrypted item using the DynamoDb Item Encryptor
141141
final Map<String, AttributeValue> decryptedItem = itemEncryptor.DecryptItem(
@@ -147,7 +147,7 @@ public static void PutItemGetItem(String kmsKeyId, String ddbTableName) {
147147
// Demonstrate that GetItem succeeded and returned the decrypted item
148148
assert decryptedItem.get("partition_key").s().equals("ItemEncryptDecryptExample");
149149
assert decryptedItem.get("sort_key").n().equals("0");
150-
assert decryptedItem.get("data_to_encrypt").s().equals("encrypt and sign me!");
150+
assert decryptedItem.get("attribute1").s().equals("encrypt and sign me!");
151151
}
152152

153153
public static void main(final String[] args) {

Examples/runtimes/java/Migration/AWSDBE/src/test/java/software/aws/cryptography/examples/migration/TestMigrationExampleStep1.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

Examples/runtimes/java/Migration/AWSDBE/src/test/java/software/aws/cryptography/examples/migration/TestMigrationExampleStep2.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

Examples/runtimes/java/Migration/AWSDBE/src/test/java/software/aws/cryptography/examples/migration/TestMigrationExampleStep3.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

Examples/runtimes/java/Migration/DDBEC/.gitattributes

Lines changed: 0 additions & 9 deletions
This file was deleted.

Examples/runtimes/java/Migration/DDBEC/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)