Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@

/**
* Encrypts all non-key fields prior to storing them in DynamoDB.
* <em>This must be used with @{link SaveBehavior#PUT} or @{link SaveBehavior#CLOBBER}. Use of
* any other @{code SaveBehavior} can result in data-corruption.</em>
* <em>This must be used with @{link SaveBehavior#PUT} or @{link SaveBehavior#CLOBBER}.</em>
*
* @author Greg Rubin
*/
Expand Down Expand Up @@ -77,7 +76,8 @@ public Map<String, AttributeValue> transform(final Parameters<?> parameters) {
// unmodified fields. Thus, upon untransform, the signature verification will fail as it won't cover all
// expected fields.
if (parameters.isPartialUpdate()) {
LOG.error("Use of AttributeEncryptor without SaveBehavior.PUT or SaveBehavior.CLOBBER is an error " +
throw new DynamoDBMappingException(
"Use of AttributeEncryptor without SaveBehavior.PUT or SaveBehavior.CLOBBER is an error " +
"and can result in data-corruption. This occured while trying to save " +
parameters.getModelClass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ public void fullEncryption() {
assertNotNull(encryptedAttributes.get("stringValue").getB());
}

@Test(expected = DynamoDBMappingException.class)
public void rejectsPartialUpdate() {
Parameters<BaseClass> params = FakeParameters.getInstance(BaseClass.class, attribs, null,
TABLE_NAME, HASH_KEY, RANGE_KEY, true);
encryptor.transform(params);
}

@Test(expected = DynamoDBMappingException.class)
public void fullEncryptionBadSignature() {
Parameters<BaseClass> params = FakeParameters.getInstance(BaseClass.class, attribs, null,
Expand Down