diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/AttributeEncryptorTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/AttributeEncryptorTest.java index d5688128..e784f922 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/AttributeEncryptorTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/AttributeEncryptorTest.java @@ -14,31 +14,6 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -import java.nio.ByteBuffer; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.NoSuchAlgorithmException; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - import com.amazonaws.services.dynamodbv2.datamodeling.AttributeTransformer.Parameters; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.EncryptionMaterialsProvider; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.SymmetricStaticProvider; @@ -58,6 +33,29 @@ import com.amazonaws.services.dynamodbv2.testing.types.UntouchedWithNewAttribute; import com.amazonaws.services.dynamodbv2.testing.types.UntouchedWithUnknownAttributeAnnotation; import com.amazonaws.services.dynamodbv2.testing.types.UntouchedWithUnknownAttributeAnnotationWithNewAttribute; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; +import java.nio.ByteBuffer; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; public class AttributeEncryptorTest { private static final String RANGE_KEY = "rangeKey"; @@ -84,14 +82,14 @@ public static void setUpClass() throws Exception { @Before public void setUp() throws Exception { prov = new SymmetricStaticProvider(encryptionKey, macKey, - Collections. emptyMap()); + Collections.emptyMap()); encryptor = new AttributeEncryptor(prov); attribs = new HashMap(); attribs.put("intValue", new AttributeValue().withN("123")); attribs.put("stringValue", new AttributeValue().withS("Hello world!")); attribs.put("byteArrayValue", - new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3, 4, 5 }))); + new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5}))); attribs.put("stringSet", new AttributeValue().withSS("Goodbye", "Cruel", "World", "?")); attribs.put("intSet", new AttributeValue().withNS("1", "200", "10", "15", "0")); attribs.put(HASH_KEY, new AttributeValue().withN("5")); @@ -132,7 +130,7 @@ public void fullEncryption() { @Test(expected = DynamoDBMappingException.class) public void rejectsPartialUpdate() { Parameters params = FakeParameters.getInstance(BaseClass.class, attribs, null, - TABLE_NAME, HASH_KEY, RANGE_KEY, true); + TABLE_NAME, HASH_KEY, RANGE_KEY, true); encryptor.transform(params); } @@ -187,7 +185,7 @@ public void signedOnly() { @Test public void signedOnlyNullCryptoKey() { - prov = new SymmetricStaticProvider(null, macKey, Collections. emptyMap()); + prov = new SymmetricStaticProvider(null, macKey, Collections.emptyMap()); encryptor = new AttributeEncryptor(prov); Parameters params = FakeParameters.getInstance(SignOnly.class, attribs, null, TABLE_NAME, HASH_KEY, RANGE_KEY); @@ -235,7 +233,7 @@ public void RsaSignedOnly() throws NoSuchAlgorithmException { rsaGen.initialize(2048, Utils.getRng()); KeyPair sigPair = rsaGen.generateKeyPair(); encryptor = new AttributeEncryptor(new SymmetricStaticProvider(encryptionKey, sigPair, - Collections. emptyMap())); + Collections.emptyMap())); Parameters params = FakeParameters.getInstance(SignOnly.class, attribs, null, TABLE_NAME, HASH_KEY, RANGE_KEY); @@ -261,7 +259,7 @@ public void RsaSignedOnlyBadSignature() throws NoSuchAlgorithmException { rsaGen.initialize(2048, Utils.getRng()); KeyPair sigPair = rsaGen.generateKeyPair(); encryptor = new AttributeEncryptor(new SymmetricStaticProvider(encryptionKey, sigPair, - Collections. emptyMap())); + Collections.emptyMap())); Parameters params = FakeParameters.getInstance(SignOnly.class, attribs, null, TABLE_NAME, HASH_KEY, RANGE_KEY); Map encryptedAttributes = encryptor.transform(params); @@ -321,7 +319,7 @@ public void mixedBadSignature() { @Test(expected = DynamoDBMappingException.class) public void tableNameRespected() { Parameters params = FakeParameters.getInstance(BaseClass.class, attribs, null, "firstTable", - HASH_KEY, RANGE_KEY); + HASH_KEY, RANGE_KEY); Map encryptedAttributes = encryptor.transform(params); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); params = FakeParameters.getInstance(BaseClass.class, encryptedAttributes, null, "secondTable", @@ -332,7 +330,7 @@ public void tableNameRespected() { @Test public void tableNameOverridden() { Parameters params = FakeParameters.getInstance(TableOverride.class, attribs, null, "firstTable", - HASH_KEY, RANGE_KEY); + HASH_KEY, RANGE_KEY); Map encryptedAttributes = encryptor.transform(params); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); params = FakeParameters.getInstance(TableOverride.class, encryptedAttributes, null, "secondTable", @@ -341,7 +339,7 @@ public void tableNameOverridden() { Map decryptedAttributes = encryptor.untransform(params); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); } - + @Test(expected = DynamoDBMappingException.class) public void testUnknownAttributeFails() { Map attributes = new HashMap<>(attribs); @@ -403,7 +401,7 @@ public void testSignOnlyWithUnknownAttributeAnnotation() { Map decryptedAttributes = encryptor.untransform(params); assertThat(decryptedAttributes, AttrMatcher.match(attributes)); } - + @Test(expected = DynamoDBMappingException.class) public void testSignOnlyWithUnknownAttributeAnnotationBadSignature() { Map attributes = new HashMap<>(attribs); @@ -436,7 +434,7 @@ public void testEncryptWithUnknownAttributeAnnotation() { Map decryptedAttributes = encryptor.untransform(params); assertThat(decryptedAttributes, AttrMatcher.match(attributes)); } - + @Test(expected = DynamoDBMappingException.class) public void testEncryptWithUnknownAttributeAnnotationBadSignature() { Map attributes = new HashMap<>(attribs); diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/TransformerHolisticTests.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/TransformerHolisticTests.java index 25e10781..e0e2f763 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/TransformerHolisticTests.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/TransformerHolisticTests.java @@ -14,35 +14,6 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.nio.ByteBuffer; -import java.security.GeneralSecurityException; -import java.security.KeyFactory; -import java.security.KeyPair; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.spec.PKCS8EncodedKeySpec; -import java.security.spec.X509EncodedKeySpec; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; - -import com.amazonaws.ClientConfiguration; -import com.amazonaws.services.dynamodbv2.model.ConditionalCheckFailedException; -import org.junit.Before; -import org.junit.Test; - -import com.amazonaws.services.dynamodbv2.local.embedded.DynamoDBEmbedded; import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig.SaveBehavior; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DynamoDBEncryptor; @@ -53,10 +24,12 @@ import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.WrappedMaterialsProvider; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.store.MetaStore; import com.amazonaws.services.dynamodbv2.datamodeling.internal.AttributeValueMarshaller; +import com.amazonaws.services.dynamodbv2.local.embedded.DynamoDBEmbedded; import com.amazonaws.services.dynamodbv2.model.AttributeAction; import com.amazonaws.services.dynamodbv2.model.AttributeDefinition; import com.amazonaws.services.dynamodbv2.model.AttributeValue; import com.amazonaws.services.dynamodbv2.model.AttributeValueUpdate; +import com.amazonaws.services.dynamodbv2.model.ConditionalCheckFailedException; import com.amazonaws.services.dynamodbv2.model.CreateTableRequest; import com.amazonaws.services.dynamodbv2.model.KeySchemaElement; import com.amazonaws.services.dynamodbv2.model.KeyType; @@ -73,12 +46,36 @@ import com.amazonaws.services.dynamodbv2.testing.types.SignOnly; import com.amazonaws.services.dynamodbv2.testing.types.Untouched; import com.amazonaws.util.Base64; +import org.junit.Before; +import org.junit.Test; + +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.nio.ByteBuffer; +import java.security.GeneralSecurityException; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; public class TransformerHolisticTests { - private static final SecretKey aesKey = new SecretKeySpec(new byte[] { 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, "AES"); - private static final SecretKey hmacKey = new SecretKeySpec(new byte[] { 0, - 1, 2, 3, 4, 5, 6, 7 }, "HmacSHA256"); + private static final SecretKey aesKey = new SecretKeySpec(new byte[]{0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, "AES"); + private static final SecretKey hmacKey = new SecretKeySpec(new byte[]{0, + 1, 2, 3, 4, 5, 6, 7}, "HmacSHA256"); private static final String rsaEncPub = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtiNSLSvT9cExXOcD0dGZ" + "9DFEMHw8895gAZcCdSppDrxbD7XgZiQYTlgt058i5fS+l11guAUJtKt5sZ2u8Fx0" + "K9pxMdlczGtvQJdx/LQETEnLnfzAijvHisJ8h6dQOVczM7t01KIkS24QZElyO+kY" @@ -127,7 +124,7 @@ public class TransformerHolisticTests { private static final Mixed MIXED_TEST_VALUE = new Mixed(); private static final SignOnly SIGNED_TEST_VALUE = new SignOnly(); private static final Untouched UNTOUCHED_TEST_VALUE = new Untouched(); - + private static final BaseClass ENCRYPTED_TEST_VALUE_2 = new BaseClass(); private static final Mixed MIXED_TEST_VALUE_2 = new Mixed(); private static final SignOnly SIGNED_TEST_VALUE_2 = new SignOnly(); @@ -155,7 +152,7 @@ public class TransformerHolisticTests { ENCRYPTED_TEST_VALUE.setVersion(0); ENCRYPTED_TEST_VALUE.setIntValue(123); ENCRYPTED_TEST_VALUE.setStringValue("Hello world!"); - ENCRYPTED_TEST_VALUE.setByteArrayValue(new byte[] { 0, 1, 2, 3, 4, 5 }); + ENCRYPTED_TEST_VALUE.setByteArrayValue(new byte[]{0, 1, 2, 3, 4, 5}); ENCRYPTED_TEST_VALUE.setStringSet(new HashSet(Arrays.asList( "Goodbye", "Cruel", "World", "?"))); ENCRYPTED_TEST_VALUE.setIntSet(new HashSet(Arrays.asList(1, @@ -166,7 +163,7 @@ public class TransformerHolisticTests { MIXED_TEST_VALUE.setVersion(0); MIXED_TEST_VALUE.setIntValue(123); MIXED_TEST_VALUE.setStringValue("Hello world!"); - MIXED_TEST_VALUE.setByteArrayValue(new byte[] { 0, 1, 2, 3, 4, 5 }); + MIXED_TEST_VALUE.setByteArrayValue(new byte[]{0, 1, 2, 3, 4, 5}); MIXED_TEST_VALUE.setStringSet(new HashSet(Arrays.asList( "Goodbye", "Cruel", "World", "?"))); MIXED_TEST_VALUE.setIntSet(new HashSet(Arrays.asList(1, 200, @@ -177,7 +174,7 @@ public class TransformerHolisticTests { SIGNED_TEST_VALUE.setVersion(0); SIGNED_TEST_VALUE.setIntValue(123); SIGNED_TEST_VALUE.setStringValue("Hello world!"); - SIGNED_TEST_VALUE.setByteArrayValue(new byte[] { 0, 1, 2, 3, 4, 5 }); + SIGNED_TEST_VALUE.setByteArrayValue(new byte[]{0, 1, 2, 3, 4, 5}); SIGNED_TEST_VALUE.setStringSet(new HashSet(Arrays.asList( "Goodbye", "Cruel", "World", "?"))); SIGNED_TEST_VALUE.setIntSet(new HashSet(Arrays.asList(1, 200, @@ -188,19 +185,19 @@ public class TransformerHolisticTests { UNTOUCHED_TEST_VALUE.setVersion(0); UNTOUCHED_TEST_VALUE.setIntValue(123); UNTOUCHED_TEST_VALUE.setStringValue("Hello world!"); - UNTOUCHED_TEST_VALUE.setByteArrayValue(new byte[] { 0, 1, 2, 3, 4, 5 }); + UNTOUCHED_TEST_VALUE.setByteArrayValue(new byte[]{0, 1, 2, 3, 4, 5}); UNTOUCHED_TEST_VALUE.setStringSet(new HashSet(Arrays.asList( "Goodbye", "Cruel", "World", "?"))); UNTOUCHED_TEST_VALUE.setIntSet(new HashSet(Arrays.asList(1, 200, 10, 15, 0))); - + // Now storing doubles ENCRYPTED_TEST_VALUE_2.setHashKey(5); ENCRYPTED_TEST_VALUE_2.setRangeKey(7); ENCRYPTED_TEST_VALUE_2.setVersion(0); ENCRYPTED_TEST_VALUE_2.setIntValue(123); ENCRYPTED_TEST_VALUE_2.setStringValue("Hello world!"); - ENCRYPTED_TEST_VALUE_2.setByteArrayValue(new byte[] { 0, 1, 2, 3, 4, 5 }); + ENCRYPTED_TEST_VALUE_2.setByteArrayValue(new byte[]{0, 1, 2, 3, 4, 5}); ENCRYPTED_TEST_VALUE_2.setStringSet(new HashSet(Arrays.asList( "Goodbye", "Cruel", "World", "?"))); ENCRYPTED_TEST_VALUE_2.setIntSet(new HashSet(Arrays.asList(1, @@ -214,7 +211,7 @@ public class TransformerHolisticTests { MIXED_TEST_VALUE_2.setVersion(0); MIXED_TEST_VALUE_2.setIntValue(123); MIXED_TEST_VALUE_2.setStringValue("Hello world!"); - MIXED_TEST_VALUE_2.setByteArrayValue(new byte[] { 0, 1, 2, 3, 4, 5 }); + MIXED_TEST_VALUE_2.setByteArrayValue(new byte[]{0, 1, 2, 3, 4, 5}); MIXED_TEST_VALUE_2.setStringSet(new HashSet(Arrays.asList( "Goodbye", "Cruel", "World", "?"))); MIXED_TEST_VALUE_2.setIntSet(new HashSet(Arrays.asList(1, 200, @@ -222,13 +219,13 @@ public class TransformerHolisticTests { MIXED_TEST_VALUE_2.setDoubleValue(15); MIXED_TEST_VALUE_2.setDoubleSet( new HashSet(Arrays.asList(15.0D, 7.6D, -3D, -34.2D, 0.0D))); - + SIGNED_TEST_VALUE_2.setHashKey(8); SIGNED_TEST_VALUE_2.setRangeKey(10); SIGNED_TEST_VALUE_2.setVersion(0); SIGNED_TEST_VALUE_2.setIntValue(123); SIGNED_TEST_VALUE_2.setStringValue("Hello world!"); - SIGNED_TEST_VALUE_2.setByteArrayValue(new byte[] { 0, 1, 2, 3, 4, 5 }); + SIGNED_TEST_VALUE_2.setByteArrayValue(new byte[]{0, 1, 2, 3, 4, 5}); SIGNED_TEST_VALUE_2.setStringSet(new HashSet(Arrays.asList( "Goodbye", "Cruel", "World", "?"))); SIGNED_TEST_VALUE_2.setIntSet(new HashSet(Arrays.asList(1, 200, @@ -236,13 +233,13 @@ public class TransformerHolisticTests { SIGNED_TEST_VALUE_2.setDoubleValue(15); SIGNED_TEST_VALUE_2.setDoubleSet( new HashSet(Arrays.asList(15.0D, 7.6D, -3D, -34.2D, 0.0D))); - + UNTOUCHED_TEST_VALUE_2.setHashKey(7); UNTOUCHED_TEST_VALUE_2.setRangeKey(9); UNTOUCHED_TEST_VALUE_2.setVersion(0); UNTOUCHED_TEST_VALUE_2.setIntValue(123); UNTOUCHED_TEST_VALUE_2.setStringValue("Hello world!"); - UNTOUCHED_TEST_VALUE_2.setByteArrayValue(new byte[] { 0, 1, 2, 3, 4, 5 }); + UNTOUCHED_TEST_VALUE_2.setByteArrayValue(new byte[]{0, 1, 2, 3, 4, 5}); UNTOUCHED_TEST_VALUE_2.setStringSet(new HashSet(Arrays.asList( "Goodbye", "Cruel", "World", "?"))); UNTOUCHED_TEST_VALUE_2.setIntSet(new HashSet(Arrays.asList(1, @@ -250,31 +247,31 @@ public class TransformerHolisticTests { UNTOUCHED_TEST_VALUE_2.setDoubleValue(15); UNTOUCHED_TEST_VALUE_2.setDoubleSet( new HashSet(Arrays.asList(15.0D, 7.6D, -3D, -34.2D, 0.0D))); - + } @Before public void setUp() { client = DynamoDBEmbedded.create(); - + ArrayList attrDef = new ArrayList(); attrDef.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType(ScalarAttributeType.N)); attrDef.add(new AttributeDefinition().withAttributeName("rangeKey").withAttributeType(ScalarAttributeType.N)); - + ArrayList keySchema = new ArrayList(); keySchema.add(new KeySchemaElement().withAttributeName("hashKey").withKeyType(KeyType.HASH)); keySchema.add(new KeySchemaElement().withAttributeName("rangeKey").withKeyType(KeyType.RANGE)); - + client.createTable(new CreateTableRequest().withTableName("TableName") .withAttributeDefinitions(attrDef) .withKeySchema(keySchema) .withProvisionedThroughput(new ProvisionedThroughput(100L, 100L))); - + attrDef = new ArrayList(); attrDef.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType(ScalarAttributeType.S)); keySchema = new ArrayList(); keySchema.add(new KeySchemaElement().withAttributeName("hashKey").withKeyType(KeyType.HASH)); - + client.createTable(new CreateTableRequest().withTableName("HashKeyOnly") .withAttributeDefinitions(attrDef) .withKeySchema(keySchema) @@ -283,7 +280,7 @@ public void setUp() { attrDef = new ArrayList(); attrDef.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType(ScalarAttributeType.B)); attrDef.add(new AttributeDefinition().withAttributeName("rangeKey").withAttributeType(ScalarAttributeType.N)); - + keySchema = new ArrayList(); keySchema.add(new KeySchemaElement().withAttributeName("hashKey").withKeyType(KeyType.HASH)); keySchema.add(new KeySchemaElement().withAttributeName("rangeKey").withKeyType(KeyType.RANGE)); @@ -317,13 +314,13 @@ public void simpleSaveLoad() { Mixed result = mapper.load(Mixed.class, 0, 15); assertEquals(obj, result); - + result.setStringValue("Foo"); mapper.save(result); - + Mixed result2 = mapper.load(Mixed.class, 0, 15); assertEquals(result, result2); - + mapper.delete(result); assertNull(mapper.load(Mixed.class, 0, 15)); } @@ -338,9 +335,9 @@ public void simpleSaveLoad() { @Test public void optimisticLockingTest() { DynamoDBMapper mapper = new DynamoDBMapper(client, - DynamoDBMapperConfig.builder() - .withSaveBehavior(SaveBehavior.PUT).build(), - new AttributeEncryptor(symProv)); + DynamoDBMapperConfig.builder() + .withSaveBehavior(SaveBehavior.PUT).build(), + new AttributeEncryptor(symProv)); DynamoDBMapper clobberMapper = new DynamoDBMapper(client, CLOBBER_CONFIG, new AttributeEncryptor(symProv)); /* @@ -411,10 +408,10 @@ public void leadingAndTrailingZeros() { obj.setDoubleValue(15); obj.setDoubleSet( new HashSet(Arrays.asList(15.0D, 7.6D, -3D, -34.2D, 0.0D))); - + mapper.save(obj); - + // TODO: Update the mock to handle this appropriately. // DynamoDb discards leading and trailing zeros from numbers Map key = new HashMap(); @@ -424,25 +421,25 @@ public void leadingAndTrailingZeros() { attributeUpdates.put("doubleValue", new AttributeValueUpdate(new AttributeValue().withN("15"), AttributeAction.PUT)); UpdateItemRequest update = new UpdateItemRequest("TableName", key, attributeUpdates); client.updateItem(update); - - + + Mixed result = mapper.load(Mixed.class, 0, 15); assertEquals(obj, result); - + result.setStringValue("Foo"); mapper.save(result); - + Mixed result2 = mapper.load(Mixed.class, 0, 15); assertEquals(result, result2); - + mapper.delete(result); assertNull(mapper.load(Mixed.class, 0, 15)); } - + @Test public void simpleSaveLoadAsym() { DynamoDBMapper mapper = new DynamoDBMapper(client, CLOBBER_CONFIG, new AttributeEncryptor(asymProv)); - + BaseClass obj = new BaseClass(); obj.setHashKey(0); obj.setRangeKey(15); @@ -458,13 +455,13 @@ public void simpleSaveLoadAsym() { BaseClass result = mapper.load(BaseClass.class, 0, 15); assertEquals(obj, result); - + result.setStringValue("Foo"); mapper.save(result); - + BaseClass result2 = mapper.load(BaseClass.class, 0, 15); assertEquals(result, result2); - + mapper.delete(result); assertNull(mapper.load(BaseClass.class, 0, 15)); } @@ -473,7 +470,7 @@ public void simpleSaveLoadAsym() { public void simpleSaveLoadHashOnly() { DynamoDBMapper mapper = new DynamoDBMapper(client, CLOBBER_CONFIG, new AttributeEncryptor( symProv)); - + HashKeyOnly obj = new HashKeyOnly(""); obj.setHashKey("Foo"); @@ -481,7 +478,7 @@ public void simpleSaveLoadHashOnly() { HashKeyOnly result = mapper.load(HashKeyOnly.class, "Foo"); assertEquals(obj, result); - + mapper.delete(obj); assertNull(mapper.load(BaseClass.class, 0, 15)); } @@ -490,7 +487,7 @@ public void simpleSaveLoadHashOnly() { public void simpleSaveLoadKeysOnly() { DynamoDBMapper mapper = new DynamoDBMapper(client, CLOBBER_CONFIG, new AttributeEncryptor( asymProv)); - + KeysOnly obj = new KeysOnly(); obj.setHashKey(0); obj.setRangeKey(15); @@ -499,29 +496,29 @@ public void simpleSaveLoadKeysOnly() { KeysOnly result = mapper.load(KeysOnly.class, 0, 15); assertEquals(obj, result); - + mapper.delete(obj); assertNull(mapper.load(BaseClass.class, 0, 15)); } -// @Test + // @Test public void generateStandardAsymData() { generateStandardData(asymProv); } -// @Test + // @Test public void generateStandardSymData() { generateStandardData(symProv); } -// @Test + // @Test public void generateStandardSymWrappedData() { generateStandardData(symWrappedProv); } -// @Test + // @Test public void generateStandardMetastoreData() { - generateStandardData(mrProv); + generateStandardData(mrProv); } public void generateStandardData(EncryptionMaterialsProvider prov) { @@ -548,7 +545,7 @@ public void generateStandardData(EncryptionMaterialsProvider prov) { dumpTables(); } - + // First released version of code. Likely no actual data stored this way @Test public void testV0SymCompatibility() { @@ -577,7 +574,7 @@ public void testV0FixedWrappingTransformSymCompatibility() { insertV0FixedWrappingTransformSymData(client); assertVersionCompatibility(mapper); } - + @Test public void testV0FixedWrappingTransformAsymCompatibility() { DynamoDBMapper mapper = new DynamoDBMapper(client, @@ -601,7 +598,7 @@ public void testV0FixedDoubleSymCompatibility() { insertV0FixedDoubleSymData(client); assertVersionCompatibility_2(mapper); } - + @Test public void testV0FixedDoubleAsymCompatibility() { DynamoDBMapper mapper = new DynamoDBMapper(client, @@ -656,7 +653,7 @@ private void assertVersionCompatibility(DynamoDBMapper mapper) { assertEquals(x, obj.getRangeKey()); } } - + private void assertVersionCompatibility_2(DynamoDBMapper mapper) { assertEquals(UNTOUCHED_TEST_VALUE_2, mapper.load( UNTOUCHED_TEST_VALUE_2.getClass(), @@ -721,7 +718,7 @@ private void dumpTables() { } } - + private void insertV0SymData(AmazonDynamoDB ddb) { Map item = new HashMap(); item.put("*amzn-ddb-map-sig*", @@ -1135,7 +1132,7 @@ private void insertV0AsymData(AmazonDynamoDB ddb) { private void insertV0FixedWrappingTransformSymData(AmazonDynamoDB ddb) { Map item = new HashMap(); - + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgiZXCp3s7VEMYdf01YEWqMlXOBHv3+e8gKbECrPUW47I=")); item.put("hashKey", b642Av("AHMAAAADQmFy")); item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAAyAAAAAAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); @@ -1267,10 +1264,10 @@ private void insertV0FixedWrappingTransformSymData(AmazonDynamoDB ddb) { ddb.putItem(new PutItemRequest("TableName", item)); item.clear(); } - + private void insertV0FixedWrappingTransformAsymData(AmazonDynamoDB ddb) { Map item = new HashMap(); - + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAEASNpX+4QUwYC+yMsNiQQcYTXiYWWqnkR02KLn1VRH0YLx1wEuFJiOhhqD4a4AhiorExenoP2HHkZdZMJpGGGU9NbupQIr2SeKvV/dkEXrCADvVaaB5O6xIhsN638f9ibknZLEhUt+XAgGDzhPedKwPBr4ZC0UnQCasedHqb9CGXYMCB8P8URbllcJRayM5mf/bv4vfBW7t9uUTd2p6wsiDNG542pw9unP5+/74mZewfgbbp6bp+8KECVLjwTny24LHdSS7XGRb1uJcZsapnhDDamjctjc1jsaaWk2WWUf2YSp/mGNWgk9+m/St/cRwwVr9wjcGpcMld7QDHEEJQmNxg==")); item.put("hashKey", b642Av("AHMAAAADQmFy")); item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAInAAAAAAAAABdhbXpuLWRkYi1tYXAtc2lnbmluZ0FsZwAAAA1TSEEyNTZ3aXRoUlNBAAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAFWFtem4tZGRiLW1hcC1zeW0tbW9kZQAAABEvQ0JDL1BLQ1M1UGFkZGluZwAAABBhbXpuLWRkYi1lbnYta2V5AAABWHFremNPOXl3MlpwUlh5U1pRQ2Jra1BxKzkyakJIZ2hpUmh2Q3hQTS8yNGVjdW83SFdvL2FDRHl1NTZ6eFJ5UkhiVkNnTUw5V2tua1dBTWhOL1UxMFJjOUhKQzlmd0pYM0h0cUVxVXl0T3NqZjRzUlhRWElKZmNoTjRKNFlYNHROQ3pZT3EzWE1BcUxCUng2L3ZkbFp3QUVCSURLVnJQWkZVcHEyZlVVYkNNeCtxSWV3NGJwWVRsVmhteC93MlZ1d2JldHRTT3huckxiOGZINCs4VGpGZ29MMlgrSnk5MERUV3EwNTdoVStDbUx3RjVxazJKaVRuenpSOFY4S1lVOUJTNXJydlBDcmd2N1g1S2QxYlc3akd4dlE5dk05cFI1TysrQ3dQUCtKVE9YbGNFMXluRXpRSFd3d3EvSG9RalJBaXRjaDFINDd0WUJPU3pPSHNYUUZGUT09AAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAJVJTQS9FQ0IvT0FFUFdpdGhTSEEtMjU2QW5kTUdGMVBhZGRpbmc=")); @@ -1402,7 +1399,7 @@ private void insertV0FixedWrappingTransformAsymData(AmazonDynamoDB ddb) { ddb.putItem(new PutItemRequest("TableName", item)); item.clear(); } - + private void insertV0FixedDoubleAsymData(AmazonDynamoDB ddb) { Map item = new HashMap(); item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); @@ -1742,300 +1739,300 @@ private void insertV0FixedDoubleSymData(AmazonDynamoDB ddb) { } private void insertV0FixedWrappingTransformSymWrappedData(final AmazonDynamoDB ddb) { - Map item = new HashMap(); - item.put("hashKey", b642Av("AHMAAAADQmFy")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAODNvNHkzTTB3UUFCRXl1UXN0SFVQUGF1NkpPMUhiNk1OWGxXQW5aWDhYdmFYTlUwNUluTFUxZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgiZXCp3s7VEMYdf01YEWqMlXOBHv3+e8gKbECrPUW47I=")); - ddb.putItem(new PutItemRequest("HashKeyOnly", item)); - item.clear(); - - item.put("hashKey", b642Av("AHMAAAADQmF6")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAODlZdEVSWXVDT3A4MHlKVnJOYytYREFoaVN6UHdlRnNJQk1YRXMxSEQ2eGdvdmYveldabmMrQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgzh74eH/yJQFzkm5mq52iFAlSDpXAFe3ZP2nv7X/xY1w=")); - ddb.putItem(new PutItemRequest("HashKeyOnly", item)); - item.clear(); - - item.put("hashKey", b642Av("AHMAAAADRm9v")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOEw2YkExbWszYTZxek1YNUkyMkYyYzRvU0FmZ2VZdCtjQmtFYndDTzhYUzlkL0ZqV20wekpZUT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgHR5P6kozMSqqs+rnDMaCiymH8++OwEVzx2Y13ZMp5P8=")); - ddb.putItem(new PutItemRequest("HashKeyOnly", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMQ==")); - item.put("hashKey", b642Av("AG4AAAABMQ==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOEpKNDk2UGRpcDViOHlldTVxbEE0STNOUjFTVHdtZEd2REJwQWowNXprUmN0OFh6T3E1TmRJZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgyT2ehLcx/a609Ez6laLkTAqCtp0IYzzKV8Amv8jdQMw=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMg==")); - item.put("hashKey", b642Av("AG4AAAABMQ==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOHNVQzNEekp5Tk1tZ3ZUSE1EVnh2Sng1OCtDT1h0UStwRzR4ZlVQL0pJTkRHOGI1M00wOFRBZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgYAai32/7MVrGjSzgcVxkFDqU+G9HcmuiNSWZHcnvfjg=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMw==")); - item.put("hashKey", b642Av("AG4AAAABMQ==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOEZGdjVQNjAxZzF0eXhoaDhxQmlCdDB1d2JoODlRaDdyeTcxL2lJdWxvSWNvQzFBV3JHczhtdz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAg0iwjbBLCdtSosmDTDYzKxu3Q5qda0Ok9q3VbIJczBV0=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMQ==")); - item.put("hashKey", b642Av("AG4AAAABNQ==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOHJ3OU5qdU53dkhENTZPTmlqWC9nbUlGZ051ZDk3OS94QXhlaTVjbmdJbmxhajdpSVg0RDdadz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgGl1jMNLZl/B70Hz2B4K4K46kir+hE6AeX8azZfFi8GA=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABNw==")); - item.put("hashKey", b642Av("AG4AAAABNQ==")); - item.put("stringValue", b642Av("AGIAAAAwMyVrAzOuKFS+hAiVq0jlmIJcwMP2w62LdWChncBN0q0HMB3WpADYK2BF1q+oQP83")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOHlUK09JWlpaWkE5VmU0dTdwRE1zNG9TUVZTNlFYZEFmQjZkVjlMMUg4QzBrRXliQ0Nad0JRQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("intSet", b642Av("AGIAAABA0iLxGtvyDaUNXY1iYwcDlZX3zIs+QOMsBQ+RbX6YlAgFdMK/k57OXPH3jMIptzkNAKNWFea+NAz+AXFd2jPC8w==")); - item.put("doubleSet", b642Av("AGIAAABA0nazy+tnY85GZpSANJzBLXZHPKzCvN4ggpopjujfAOO37wDi6zrSwhurLpjFIJGR27pn5azaroZWYA8GLfiGIw==")); - item.put("byteArrayValue", b642Av("AGIAAAAgw9sfXioZCE9luCt4qiOixyRJVlJ6zbTwFoFg0wQNJbA=")); - item.put("stringSet", b642Av("AGIAAABA8057NGIAJADqX/KzkjZl7XzFMI/6j7vAbp5F83tZjOQhguhp8hheXAzcsrCmM6sME1oGEmJEran4Svs1qT5ChA==")); - item.put("intValue", b642Av("AGIAAAAgLFHv7oLor2SoKypi/gubI0IsipoLd/I20qPr2wHOgOs=")); - item.put("doubleValue", b642Av("AGIAAAAguq8MBbPKDskxhyJ6VCmd9EC6+tD3EuiqhgFUpxckzdk=")); - item.put("version", b642Av("AG4AAAABMQ==")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgFhpaX3jXqz+Pg4QETqcNBULC+OBOTkux2BFGCdnr5PY=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAACMTA=")); - item.put("hashKey", b642Av("AG4AAAABOA==")); - item.put("stringValue", b642Av("AHMAAAAMSGVsbG8gd29ybGQh")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAODRhOGRFc01ybDR6ODlVM1RkOWh4L0J2cms4cVZEODlOaklkMnU0d2NGSnBxbUVkc1lka2ZXZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("intSet", b642Av("AE4AAAAFAAAAATAAAAABMQAAAAIxMAAAAAIxNQAAAAMyMDA=")); - item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); - item.put("byteArrayValue", b642Av("AGIAAAAGAAECAwQF")); - item.put("stringSet", b642Av("AFMAAAAEAAAAAT8AAAAFQ3J1ZWwAAAAHR29vZGJ5ZQAAAAVXb3JsZA==")); - item.put("intValue", b642Av("AG4AAAADMTIz")); - item.put("doubleValue", b642Av("AG4AAAACMTU=")); - item.put("version", b642Av("AG4AAAABMQ==")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAg5NHNzCBtZcVAUlz1ymLB7Ta+1n3VjffLj5WniFA9afo=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMw==")); - item.put("hashKey", b642Av("AG4AAAABNw==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOE55eTdqK3FkNEJMNzV2MTlnRHdHVHdtTGgrbmlMaER0cjdaL3ZZMVFmQTFEQmE5Y0JGdzIxdz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgcSTe0npOBBtsxSN4F9mLF2WTyCN1+1owsVoGkYumiZQ=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABOQ==")); - item.put("hashKey", b642Av("AG4AAAABNw==")); - item.put("stringValue", b642Av("AHMAAAAMSGVsbG8gd29ybGQh")); - item.put("intSet", b642Av("AE4AAAAFAAAAATAAAAABMQAAAAIxMAAAAAIxNQAAAAMyMDA=")); - item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); - item.put("byteArrayValue", b642Av("AGIAAAAGAAECAwQF")); - item.put("stringSet", b642Av("AFMAAAAEAAAAAT8AAAAFQ3J1ZWwAAAAHR29vZGJ5ZQAAAAVXb3JsZA==")); - item.put("intValue", b642Av("AG4AAAADMTIz")); - item.put("doubleValue", b642Av("AG4AAAACMTU=")); - item.put("version", b642Av("AG4AAAABMQ==")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMQ==")); - item.put("hashKey", b642Av("AG4AAAABMA==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGcrY1NpV2I3eWZYZ2pQS2gzOVM0anBZZWFNeEhHRG90c2JCOG5sQkp3ei9vclBRQzhOZFNxdz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAglBLoUXuc8TgsJJlItgBh6PJ1YVk52nvQE9aErEB8jK8=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMg==")); - item.put("hashKey", b642Av("AG4AAAABMA==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOHlKa2M4OW9HNEpoajhyazlEQnpVeEQ1cForN1Q4Z2pQUEU1TE9uVDhvd2tJWDJ6bGFpdUJKQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgcjd91WBBFWPnrJxIJ2p2hnXFVCemgYw0HqRWcnoQcq4=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMw==")); - item.put("hashKey", b642Av("AG4AAAABMA==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOG9kQ2hPVmtiYkN3S3V3VHYrVjYvelNwcnZIUWVhWlpqaDZvU3JzMHV4T255bFQzSUZ0TjVVZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAguXZKvYmUgZEOunUJctXpkvqhrgUoK1eLi8JpvlRozTI=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMg==")); - item.put("hashKey", b642Av("AG4AAAABNg==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOEJLV0Z2T0hRVUxCMTcxTW56dkQrVVYyMVpmTUxhSXl4QjB3ekdZbStzY2VFd2pNekgxTFhVQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAg66Vz0G8nOQzlvIpImXSkl+nmCpTYeRy8mAF4qgGgMw0=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABOA==")); - item.put("stringValue", b642Av("AHMAAAAMSGVsbG8gd29ybGQh")); - item.put("hashKey", b642Av("AG4AAAABNg==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOEdncWp2Q3JaYzhZL2RrMGxmQlk5K09tbWNXUWIvbjVYMW01YTNBcElZb3JLVzU0RVhRYTgrZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); - item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); - item.put("intSet", b642Av("AGIAAABAeBhcgBr8TocxVsTw8tJtcAK2VKFOkoZlWBUusFNtKbTulghzdpT3iTMqIJB86ViXXguO43XqMZWs1U3G/IaF+g==")); - item.put("byteArrayValue", b642Av("AGIAAAAgY3ciZfN54gf86a4mxRfon9CgzQkNIxrtWV8s6tg/6G0=")); - item.put("intValue", b642Av("AG4AAAADMTIz")); - item.put("stringSet", b642Av("AGIAAABARhykbS8bqGEd2LEGtLV0S6Pj+4KjuVc15ExkUmlCKlClAgNpukA5Tp0FjU/XL0Qli4v6apZaraKgBC1l4YlRDg==")); - item.put("doubleValue", b642Av("AG4AAAACMTU=")); - item.put("version", b642Av("AG4AAAABMQ==")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgmC10Qiw1c/P8Bab4SaP3kmsPMBVfOZKjZ3SgvXyd3Vg=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); + Map item = new HashMap(); + item.put("hashKey", b642Av("AHMAAAADQmFy")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAODNvNHkzTTB3UUFCRXl1UXN0SFVQUGF1NkpPMUhiNk1OWGxXQW5aWDhYdmFYTlUwNUluTFUxZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgiZXCp3s7VEMYdf01YEWqMlXOBHv3+e8gKbECrPUW47I=")); + ddb.putItem(new PutItemRequest("HashKeyOnly", item)); + item.clear(); + + item.put("hashKey", b642Av("AHMAAAADQmF6")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAODlZdEVSWXVDT3A4MHlKVnJOYytYREFoaVN6UHdlRnNJQk1YRXMxSEQ2eGdvdmYveldabmMrQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgzh74eH/yJQFzkm5mq52iFAlSDpXAFe3ZP2nv7X/xY1w=")); + ddb.putItem(new PutItemRequest("HashKeyOnly", item)); + item.clear(); + + item.put("hashKey", b642Av("AHMAAAADRm9v")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOEw2YkExbWszYTZxek1YNUkyMkYyYzRvU0FmZ2VZdCtjQmtFYndDTzhYUzlkL0ZqV20wekpZUT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgHR5P6kozMSqqs+rnDMaCiymH8++OwEVzx2Y13ZMp5P8=")); + ddb.putItem(new PutItemRequest("HashKeyOnly", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMQ==")); + item.put("hashKey", b642Av("AG4AAAABMQ==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOEpKNDk2UGRpcDViOHlldTVxbEE0STNOUjFTVHdtZEd2REJwQWowNXprUmN0OFh6T3E1TmRJZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgyT2ehLcx/a609Ez6laLkTAqCtp0IYzzKV8Amv8jdQMw=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMg==")); + item.put("hashKey", b642Av("AG4AAAABMQ==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOHNVQzNEekp5Tk1tZ3ZUSE1EVnh2Sng1OCtDT1h0UStwRzR4ZlVQL0pJTkRHOGI1M00wOFRBZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgYAai32/7MVrGjSzgcVxkFDqU+G9HcmuiNSWZHcnvfjg=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMw==")); + item.put("hashKey", b642Av("AG4AAAABMQ==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOEZGdjVQNjAxZzF0eXhoaDhxQmlCdDB1d2JoODlRaDdyeTcxL2lJdWxvSWNvQzFBV3JHczhtdz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAg0iwjbBLCdtSosmDTDYzKxu3Q5qda0Ok9q3VbIJczBV0=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMQ==")); + item.put("hashKey", b642Av("AG4AAAABNQ==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOHJ3OU5qdU53dkhENTZPTmlqWC9nbUlGZ051ZDk3OS94QXhlaTVjbmdJbmxhajdpSVg0RDdadz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgGl1jMNLZl/B70Hz2B4K4K46kir+hE6AeX8azZfFi8GA=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABNw==")); + item.put("hashKey", b642Av("AG4AAAABNQ==")); + item.put("stringValue", b642Av("AGIAAAAwMyVrAzOuKFS+hAiVq0jlmIJcwMP2w62LdWChncBN0q0HMB3WpADYK2BF1q+oQP83")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOHlUK09JWlpaWkE5VmU0dTdwRE1zNG9TUVZTNlFYZEFmQjZkVjlMMUg4QzBrRXliQ0Nad0JRQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("intSet", b642Av("AGIAAABA0iLxGtvyDaUNXY1iYwcDlZX3zIs+QOMsBQ+RbX6YlAgFdMK/k57OXPH3jMIptzkNAKNWFea+NAz+AXFd2jPC8w==")); + item.put("doubleSet", b642Av("AGIAAABA0nazy+tnY85GZpSANJzBLXZHPKzCvN4ggpopjujfAOO37wDi6zrSwhurLpjFIJGR27pn5azaroZWYA8GLfiGIw==")); + item.put("byteArrayValue", b642Av("AGIAAAAgw9sfXioZCE9luCt4qiOixyRJVlJ6zbTwFoFg0wQNJbA=")); + item.put("stringSet", b642Av("AGIAAABA8057NGIAJADqX/KzkjZl7XzFMI/6j7vAbp5F83tZjOQhguhp8hheXAzcsrCmM6sME1oGEmJEran4Svs1qT5ChA==")); + item.put("intValue", b642Av("AGIAAAAgLFHv7oLor2SoKypi/gubI0IsipoLd/I20qPr2wHOgOs=")); + item.put("doubleValue", b642Av("AGIAAAAguq8MBbPKDskxhyJ6VCmd9EC6+tD3EuiqhgFUpxckzdk=")); + item.put("version", b642Av("AG4AAAABMQ==")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgFhpaX3jXqz+Pg4QETqcNBULC+OBOTkux2BFGCdnr5PY=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAACMTA=")); + item.put("hashKey", b642Av("AG4AAAABOA==")); + item.put("stringValue", b642Av("AHMAAAAMSGVsbG8gd29ybGQh")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAODRhOGRFc01ybDR6ODlVM1RkOWh4L0J2cms4cVZEODlOaklkMnU0d2NGSnBxbUVkc1lka2ZXZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("intSet", b642Av("AE4AAAAFAAAAATAAAAABMQAAAAIxMAAAAAIxNQAAAAMyMDA=")); + item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); + item.put("byteArrayValue", b642Av("AGIAAAAGAAECAwQF")); + item.put("stringSet", b642Av("AFMAAAAEAAAAAT8AAAAFQ3J1ZWwAAAAHR29vZGJ5ZQAAAAVXb3JsZA==")); + item.put("intValue", b642Av("AG4AAAADMTIz")); + item.put("doubleValue", b642Av("AG4AAAACMTU=")); + item.put("version", b642Av("AG4AAAABMQ==")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAg5NHNzCBtZcVAUlz1ymLB7Ta+1n3VjffLj5WniFA9afo=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMw==")); + item.put("hashKey", b642Av("AG4AAAABNw==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOE55eTdqK3FkNEJMNzV2MTlnRHdHVHdtTGgrbmlMaER0cjdaL3ZZMVFmQTFEQmE5Y0JGdzIxdz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgcSTe0npOBBtsxSN4F9mLF2WTyCN1+1owsVoGkYumiZQ=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABOQ==")); + item.put("hashKey", b642Av("AG4AAAABNw==")); + item.put("stringValue", b642Av("AHMAAAAMSGVsbG8gd29ybGQh")); + item.put("intSet", b642Av("AE4AAAAFAAAAATAAAAABMQAAAAIxMAAAAAIxNQAAAAMyMDA=")); + item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); + item.put("byteArrayValue", b642Av("AGIAAAAGAAECAwQF")); + item.put("stringSet", b642Av("AFMAAAAEAAAAAT8AAAAFQ3J1ZWwAAAAHR29vZGJ5ZQAAAAVXb3JsZA==")); + item.put("intValue", b642Av("AG4AAAADMTIz")); + item.put("doubleValue", b642Av("AG4AAAACMTU=")); + item.put("version", b642Av("AG4AAAABMQ==")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMQ==")); + item.put("hashKey", b642Av("AG4AAAABMA==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGcrY1NpV2I3eWZYZ2pQS2gzOVM0anBZZWFNeEhHRG90c2JCOG5sQkp3ei9vclBRQzhOZFNxdz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAglBLoUXuc8TgsJJlItgBh6PJ1YVk52nvQE9aErEB8jK8=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMg==")); + item.put("hashKey", b642Av("AG4AAAABMA==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOHlKa2M4OW9HNEpoajhyazlEQnpVeEQ1cForN1Q4Z2pQUEU1TE9uVDhvd2tJWDJ6bGFpdUJKQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgcjd91WBBFWPnrJxIJ2p2hnXFVCemgYw0HqRWcnoQcq4=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMw==")); + item.put("hashKey", b642Av("AG4AAAABMA==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOG9kQ2hPVmtiYkN3S3V3VHYrVjYvelNwcnZIUWVhWlpqaDZvU3JzMHV4T255bFQzSUZ0TjVVZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAguXZKvYmUgZEOunUJctXpkvqhrgUoK1eLi8JpvlRozTI=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMg==")); + item.put("hashKey", b642Av("AG4AAAABNg==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOEJLV0Z2T0hRVUxCMTcxTW56dkQrVVYyMVpmTUxhSXl4QjB3ekdZbStzY2VFd2pNekgxTFhVQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAg66Vz0G8nOQzlvIpImXSkl+nmCpTYeRy8mAF4qgGgMw0=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABOA==")); + item.put("stringValue", b642Av("AHMAAAAMSGVsbG8gd29ybGQh")); + item.put("hashKey", b642Av("AG4AAAABNg==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAC9AAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOEdncWp2Q3JaYzhZL2RrMGxmQlk5K09tbWNXUWIvbjVYMW01YTNBcElZb3JLVzU0RVhRYTgrZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEWFtem4tZGRiLXdyYXAtYWxnAAAAB0FFU1dyYXAAAAAVYW16bi1kZGItbWFwLXN5bS1tb2RlAAAAES9DQkMvUEtDUzVQYWRkaW5n")); + item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); + item.put("intSet", b642Av("AGIAAABAeBhcgBr8TocxVsTw8tJtcAK2VKFOkoZlWBUusFNtKbTulghzdpT3iTMqIJB86ViXXguO43XqMZWs1U3G/IaF+g==")); + item.put("byteArrayValue", b642Av("AGIAAAAgY3ciZfN54gf86a4mxRfon9CgzQkNIxrtWV8s6tg/6G0=")); + item.put("intValue", b642Av("AG4AAAADMTIz")); + item.put("stringSet", b642Av("AGIAAABARhykbS8bqGEd2LEGtLV0S6Pj+4KjuVc15ExkUmlCKlClAgNpukA5Tp0FjU/XL0Qli4v6apZaraKgBC1l4YlRDg==")); + item.put("doubleValue", b642Av("AG4AAAACMTU=")); + item.put("version", b642Av("AG4AAAABMQ==")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgmC10Qiw1c/P8Bab4SaP3kmsPMBVfOZKjZ3SgvXyd3Vg=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); } private void insertV0MetastoreData(AmazonDynamoDB ddb) { - Map item = new HashMap<>(); - - item.put("hashKey", b642Av("AHMAAAADQmFy")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGR5Y1YrQW42bUVFVzJLK3RjVE1EQWw2MUNRSzNPZ2hpQ2Z2YTBYeGFVaU9odWJnRDhMelFwdz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgiBDp77rZmalAcIlg0htWCjJ0BcYgMdPgzJj8fie5Ai0=")); - ddb.putItem(new PutItemRequest("HashKeyOnly", item)); - item.clear(); - - item.put("hashKey", b642Av("AHMAAAADQmF6")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAODlPZG50TUIwbHpoMUtKNHlYZXhrNXZsWVF4RUlWRDJZRWVybHlQNThXWkg1OUtxelM2MUIvdz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgNo2a+yFlcr1phtcCGNXKfcUrfyMtPdihhh7UPWQNLog=")); - ddb.putItem(new PutItemRequest("HashKeyOnly", item)); - item.clear(); - - item.put("hashKey", b642Av("AHMAAAADRm9v")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGtUMFY2bklwSHh2WTZ6bjMycHJHd0NJVFJRb1NyR3BsWGtoTlcxdUJZWnA2QVFUSURiT3dVUT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgfy9BE3X7MyBJCQLvCN8TNUTf/zJvKEQQOdf9VhJbWdU=")); - ddb.putItem(new PutItemRequest("HashKeyOnly", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMQ==")); - item.put("hashKey", b642Av("AG4AAAABMQ==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAODJLUkJKQlBxbEFEM0ZYL2RiSjhlRHFoL2NvdVZhUnJUZmpISE0rWFRtbS9xYThybHZ3Rkw1UT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgQv9omCLGhrq2cxeP+elq4UgbloK03bV+knv8uE9P7Mw=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMg==")); - item.put("hashKey", b642Av("AG4AAAABMQ==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOHZyckFUOHhzOTJJNlpMdVFtcGs2SDR2RTJ6WlljMVRjZkNXb2VUVXdPcVN3K29Gb0JTWFlQUT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgtgkdLHwtDS/NzFDFLQR8GQLsw4LURQMB/8yBoD4kKSI=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMw==")); - item.put("hashKey", b642Av("AG4AAAABMQ==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOENTT0dQcXZZM0d5QUJSZTB1MXVTLzR4ZGtQRlRSQlh0M3dkSGJ2bXoveUNCcEk3bGY3Qit1dz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgUPLAdN9KAJNJRZzAtfpaloOYNa+gCVXg1diT6CGSqrU=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMQ==")); - item.put("hashKey", b642Av("AG4AAAABNQ==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOG1WcldlSy9CYkxsSDlnY0Zvb1Fjb0I4V082anlSa0hRT2NqN0NaZjFzMUk0RWRuV0NGai9CQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgDY8cXYd+66/OeHT+dOOh4FnJgwD4mMj/0EOZZdlrDGU=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABNw==")); - item.put("stringValue", b642Av("AGIAAAAwjmiBDtOhOzwPbKbPx15zZ+HeW0ElgRnRiGykEvmvpFux0U/LJQFRQ9KncAWd4nJM")); - item.put("hashKey", b642Av("AG4AAAABNQ==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGNaYlhrb0ZDLzZjVzlpNWNBanViTHdZaW1vNE9SdlUxQjZOSWRpRHovc1BsMUQwU1F2ajhWQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("doubleSet", b642Av("AGIAAABAS4kDtlVOu6tLMGoBhqD8oDGY8WnnUnZ6gN2E0TLmTn6+rJeFBQ3R0NfJtsXtx8pKKOZRG7z5nkJqVCXWA0YEtg==")); - item.put("intSet", b642Av("AGIAAABAuU3x6fQO9kF37qXb+KdB50EvDsAQSr7JEkKFo76XSF3q1jRNuXTvNL1MmCagMicOn8hGXWf3uXr3l/jeMXXTxw==")); - item.put("byteArrayValue", b642Av("AGIAAAAg1v7mQNUIJrvRrBqSBP8Ges17M8ylNfERqjAhpBtmtEg=")); - item.put("stringSet", b642Av("AGIAAABAMSooPgKThBmQfGl+MZ0PcPhwCWpykLn5VIYK8y17sa7S9HPC+ZZaXSZWAeEIe9tCsazs/GhYPNAk+J9+Ehr83A==")); - item.put("intValue", b642Av("AGIAAAAgFLAPKKtgQS0xyDmVtg8TM8NsK5Zt7HSPorfyxIzw920=")); - item.put("doubleValue", b642Av("AGIAAAAgIKFrRJV/QQ6bN880QRBKXR/K84kwc5O8cAFduodO5dU=")); - item.put("version", b642Av("AG4AAAABMQ==")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgzZEKidI2XCh5bvadadW99btbRcOVSuavthxLMEIN86c=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAACMTA=")); - item.put("stringValue", b642Av("AHMAAAAMSGVsbG8gd29ybGQh")); - item.put("hashKey", b642Av("AG4AAAABOA==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAODlqNDlhRG51M1hBNVE0M0xxMDMvaTF3eUIzbHdSbng4eDNEK29JamM3Qlpxbno5VmhoRHc2Zz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); - item.put("intSet", b642Av("AE4AAAAFAAAAATAAAAABMQAAAAIxMAAAAAIxNQAAAAMyMDA=")); - item.put("byteArrayValue", b642Av("AGIAAAAGAAECAwQF")); - item.put("stringSet", b642Av("AFMAAAAEAAAAAT8AAAAFQ3J1ZWwAAAAHR29vZGJ5ZQAAAAVXb3JsZA==")); - item.put("intValue", b642Av("AG4AAAADMTIz")); - item.put("doubleValue", b642Av("AG4AAAACMTU=")); - item.put("version", b642Av("AG4AAAABMQ==")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgTUBX7q3xvSd+K/nMBdipsX+6nTyt+htT/qJUK5sPos0=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMw==")); - item.put("hashKey", b642Av("AG4AAAABNw==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOHA3N1pGSEh5Wk5qZXErWDdHdHhsRkNzZDVqemhTSFVQVFc1V3YzU0xPaHFFdzQzUmJEdUVOUT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgc4AE+L/ysYL+maoJmXJkaMeJ3Chh1Ed8KQA148yZK6M=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABOQ==")); - item.put("stringValue", b642Av("AHMAAAAMSGVsbG8gd29ybGQh")); - item.put("hashKey", b642Av("AG4AAAABNw==")); - item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); - item.put("intSet", b642Av("AE4AAAAFAAAAATAAAAABMQAAAAIxMAAAAAIxNQAAAAMyMDA=")); - item.put("byteArrayValue", b642Av("AGIAAAAGAAECAwQF")); - item.put("stringSet", b642Av("AFMAAAAEAAAAAT8AAAAFQ3J1ZWwAAAAHR29vZGJ5ZQAAAAVXb3JsZA==")); - item.put("intValue", b642Av("AG4AAAADMTIz")); - item.put("doubleValue", b642Av("AG4AAAACMTU=")); - item.put("version", b642Av("AG4AAAABMQ==")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMQ==")); - item.put("hashKey", b642Av("AG4AAAABMA==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOFI3eGxEWmZCTTRoMWhaa0EreldTQ0VNV3ZCVnV2Vm03Z25wVnlmTVBRMW5hYi9KQWhiRUs3UT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgRU3MCwYYxRFxZT7GmHBG7j+pgK14aMfEIsmrbgB8+Wk=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMg==")); - item.put("hashKey", b642Av("AG4AAAABMA==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGkxcGFYZUtNRXlTTDFDOUdwaS9QWFVDMk15ZHdUeUxKTGQ3RXNIeWUrazJrRWlxTnBRdFZnZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAg5gNtdXLSncuZDK3EvpFos08QRhOsOnKDVNR9jogw/Bk=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMw==")); - item.put("hashKey", b642Av("AG4AAAABMA==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGxCdUFkQ0pYSk9yVS9JelM4TEV1RlFoWDhnVVVCMG5jZDNxZ0FUQ0xjMjVrYTE0RFRTVjNKQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAg6zpNDAHNoQUzrP6YE6g47Y7CDom04EWXUTGuhPU7Wd8=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABMg==")); - item.put("hashKey", b642Av("AG4AAAABNg==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOFdsRU5LNlNmY096R3owYTRwL2RyRHF5REo4LzJ0REJ0WTRRL0wxdUpRc1lYeldRQ2pUcExkQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgtvX4UthmBwymnAZ7CuTpJdLTASr1lRj1MvRwAesjtMM=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("rangeKey", b642Av("AG4AAAABOA==")); - item.put("stringValue", b642Av("AHMAAAAMSGVsbG8gd29ybGQh")); - item.put("hashKey", b642Av("AG4AAAABNg==")); - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGpyLzI2c1V1NW5udlQwcmVzY0NPWEhXTHZwZzlySjNkeURSVHQxRFFMcnAvTG9STkRyNk5EQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); - item.put("intSet", b642Av("AGIAAABAUBGZEIoWzYKTFCsFoZYXzRUJsNuy3xr64nCwsL14lZNk62Aff5n3+ETtWm8U9E3PMOp9LozkDwZcnzs0rnYIeA==")); - item.put("byteArrayValue", b642Av("AGIAAAAgl9wQf/r6vivuTCvIz0Jeqd80xPII30sf317fED7Xrrs=")); - item.put("intValue", b642Av("AG4AAAADMTIz")); - item.put("stringSet", b642Av("AGIAAABAAijuavOYfNvcle2WbG8I2a4W1af+UPxhKguG3YMW5E6MoXsdO5ddSAifAPbVLmv92VyJnx/o817m1IOSs+LccA==")); - item.put("doubleValue", b642Av("AG4AAAACMTU=")); - item.put("version", b642Av("AG4AAAABMQ==")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgpzB3S616mcP6HQrkeaUYdV5Qo2UYWF6p04GZhSzcpV8=")); - ddb.putItem(new PutItemRequest("TableName", item)); - item.clear(); - - item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAAyAAAAAAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); - item.put("t", b642Av("AGIAAAAgeJcKzY3SHwBIhXdfxeYWd9UE5yX+RxaPJQ7L2TdgDxs=")); - item.put("V", b642Av("AG4AAAABMA==")); - item.put("encAlg", b642Av("AGIAAAAgXJilRkdsIP0bqzvqutJc8AC8YhY1YApJCgTLXgAqtwU=")); - item.put("enc", b642Av("AGIAAABADvDUW2Ao1YWp7uxxEL+mv5uqHCrSNIDR18CgBD8XHCuNlBPC6GXxk9YnFmv3kgVDlMdEo0wE79zRoETB7GmjcA==")); - item.put("intAlg", b642Av("AGIAAAAwI//7G2LUrAQ2EwQGQr7ZIKyXl1AlGeB+kfvZGmCj6wShZpMKPXjyBF/9RvIz3clQ")); - item.put("N", b642Av("AHMAAAAMbWF0ZXJpYWxOYW1l")); - item.put("int", b642Av("AGIAAABAzFha4J4gPaiwhjiQs47L0bTf4WSNemVAxKJJnBnujl7OajvO7ZW3zehGJlaai4tCLxTwoLPI+Ig/a+zCdau4iw==")); - item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgaklO+h7kSUjXEt6pBA03G4wiIU20XKT/sP+rKSeNAKc=")); - ddb.putItem(new PutItemRequest("metastore", item)); - item.clear(); + Map item = new HashMap<>(); + + item.put("hashKey", b642Av("AHMAAAADQmFy")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGR5Y1YrQW42bUVFVzJLK3RjVE1EQWw2MUNRSzNPZ2hpQ2Z2YTBYeGFVaU9odWJnRDhMelFwdz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgiBDp77rZmalAcIlg0htWCjJ0BcYgMdPgzJj8fie5Ai0=")); + ddb.putItem(new PutItemRequest("HashKeyOnly", item)); + item.clear(); + + item.put("hashKey", b642Av("AHMAAAADQmF6")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAODlPZG50TUIwbHpoMUtKNHlYZXhrNXZsWVF4RUlWRDJZRWVybHlQNThXWkg1OUtxelM2MUIvdz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgNo2a+yFlcr1phtcCGNXKfcUrfyMtPdihhh7UPWQNLog=")); + ddb.putItem(new PutItemRequest("HashKeyOnly", item)); + item.clear(); + + item.put("hashKey", b642Av("AHMAAAADRm9v")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGtUMFY2bklwSHh2WTZ6bjMycHJHd0NJVFJRb1NyR3BsWGtoTlcxdUJZWnA2QVFUSURiT3dVUT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgfy9BE3X7MyBJCQLvCN8TNUTf/zJvKEQQOdf9VhJbWdU=")); + ddb.putItem(new PutItemRequest("HashKeyOnly", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMQ==")); + item.put("hashKey", b642Av("AG4AAAABMQ==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAODJLUkJKQlBxbEFEM0ZYL2RiSjhlRHFoL2NvdVZhUnJUZmpISE0rWFRtbS9xYThybHZ3Rkw1UT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgQv9omCLGhrq2cxeP+elq4UgbloK03bV+knv8uE9P7Mw=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMg==")); + item.put("hashKey", b642Av("AG4AAAABMQ==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOHZyckFUOHhzOTJJNlpMdVFtcGs2SDR2RTJ6WlljMVRjZkNXb2VUVXdPcVN3K29Gb0JTWFlQUT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgtgkdLHwtDS/NzFDFLQR8GQLsw4LURQMB/8yBoD4kKSI=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMw==")); + item.put("hashKey", b642Av("AG4AAAABMQ==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOENTT0dQcXZZM0d5QUJSZTB1MXVTLzR4ZGtQRlRSQlh0M3dkSGJ2bXoveUNCcEk3bGY3Qit1dz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgUPLAdN9KAJNJRZzAtfpaloOYNa+gCVXg1diT6CGSqrU=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMQ==")); + item.put("hashKey", b642Av("AG4AAAABNQ==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOG1WcldlSy9CYkxsSDlnY0Zvb1Fjb0I4V082anlSa0hRT2NqN0NaZjFzMUk0RWRuV0NGai9CQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgDY8cXYd+66/OeHT+dOOh4FnJgwD4mMj/0EOZZdlrDGU=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABNw==")); + item.put("stringValue", b642Av("AGIAAAAwjmiBDtOhOzwPbKbPx15zZ+HeW0ElgRnRiGykEvmvpFux0U/LJQFRQ9KncAWd4nJM")); + item.put("hashKey", b642Av("AG4AAAABNQ==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGNaYlhrb0ZDLzZjVzlpNWNBanViTHdZaW1vNE9SdlUxQjZOSWRpRHovc1BsMUQwU1F2ajhWQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("doubleSet", b642Av("AGIAAABAS4kDtlVOu6tLMGoBhqD8oDGY8WnnUnZ6gN2E0TLmTn6+rJeFBQ3R0NfJtsXtx8pKKOZRG7z5nkJqVCXWA0YEtg==")); + item.put("intSet", b642Av("AGIAAABAuU3x6fQO9kF37qXb+KdB50EvDsAQSr7JEkKFo76XSF3q1jRNuXTvNL1MmCagMicOn8hGXWf3uXr3l/jeMXXTxw==")); + item.put("byteArrayValue", b642Av("AGIAAAAg1v7mQNUIJrvRrBqSBP8Ges17M8ylNfERqjAhpBtmtEg=")); + item.put("stringSet", b642Av("AGIAAABAMSooPgKThBmQfGl+MZ0PcPhwCWpykLn5VIYK8y17sa7S9HPC+ZZaXSZWAeEIe9tCsazs/GhYPNAk+J9+Ehr83A==")); + item.put("intValue", b642Av("AGIAAAAgFLAPKKtgQS0xyDmVtg8TM8NsK5Zt7HSPorfyxIzw920=")); + item.put("doubleValue", b642Av("AGIAAAAgIKFrRJV/QQ6bN880QRBKXR/K84kwc5O8cAFduodO5dU=")); + item.put("version", b642Av("AG4AAAABMQ==")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgzZEKidI2XCh5bvadadW99btbRcOVSuavthxLMEIN86c=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAACMTA=")); + item.put("stringValue", b642Av("AHMAAAAMSGVsbG8gd29ybGQh")); + item.put("hashKey", b642Av("AG4AAAABOA==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAODlqNDlhRG51M1hBNVE0M0xxMDMvaTF3eUIzbHdSbng4eDNEK29JamM3Qlpxbno5VmhoRHc2Zz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); + item.put("intSet", b642Av("AE4AAAAFAAAAATAAAAABMQAAAAIxMAAAAAIxNQAAAAMyMDA=")); + item.put("byteArrayValue", b642Av("AGIAAAAGAAECAwQF")); + item.put("stringSet", b642Av("AFMAAAAEAAAAAT8AAAAFQ3J1ZWwAAAAHR29vZGJ5ZQAAAAVXb3JsZA==")); + item.put("intValue", b642Av("AG4AAAADMTIz")); + item.put("doubleValue", b642Av("AG4AAAACMTU=")); + item.put("version", b642Av("AG4AAAABMQ==")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgTUBX7q3xvSd+K/nMBdipsX+6nTyt+htT/qJUK5sPos0=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMw==")); + item.put("hashKey", b642Av("AG4AAAABNw==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOHA3N1pGSEh5Wk5qZXErWDdHdHhsRkNzZDVqemhTSFVQVFc1V3YzU0xPaHFFdzQzUmJEdUVOUT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgc4AE+L/ysYL+maoJmXJkaMeJ3Chh1Ed8KQA148yZK6M=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABOQ==")); + item.put("stringValue", b642Av("AHMAAAAMSGVsbG8gd29ybGQh")); + item.put("hashKey", b642Av("AG4AAAABNw==")); + item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); + item.put("intSet", b642Av("AE4AAAAFAAAAATAAAAABMQAAAAIxMAAAAAIxNQAAAAMyMDA=")); + item.put("byteArrayValue", b642Av("AGIAAAAGAAECAwQF")); + item.put("stringSet", b642Av("AFMAAAAEAAAAAT8AAAAFQ3J1ZWwAAAAHR29vZGJ5ZQAAAAVXb3JsZA==")); + item.put("intValue", b642Av("AG4AAAADMTIz")); + item.put("doubleValue", b642Av("AG4AAAACMTU=")); + item.put("version", b642Av("AG4AAAABMQ==")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMQ==")); + item.put("hashKey", b642Av("AG4AAAABMA==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOFI3eGxEWmZCTTRoMWhaa0EreldTQ0VNV3ZCVnV2Vm03Z25wVnlmTVBRMW5hYi9KQWhiRUs3UT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgRU3MCwYYxRFxZT7GmHBG7j+pgK14aMfEIsmrbgB8+Wk=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMg==")); + item.put("hashKey", b642Av("AG4AAAABMA==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGkxcGFYZUtNRXlTTDFDOUdwaS9QWFVDMk15ZHdUeUxKTGQ3RXNIeWUrazJrRWlxTnBRdFZnZz09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAg5gNtdXLSncuZDK3EvpFos08QRhOsOnKDVNR9jogw/Bk=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMw==")); + item.put("hashKey", b642Av("AG4AAAABMA==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGxCdUFkQ0pYSk9yVS9JelM4TEV1RlFoWDhnVVVCMG5jZDNxZ0FUQ0xjMjVrYTE0RFRTVjNKQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAg6zpNDAHNoQUzrP6YE6g47Y7CDom04EWXUTGuhPU7Wd8=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABMg==")); + item.put("hashKey", b642Av("AG4AAAABNg==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOFdsRU5LNlNmY096R3owYTRwL2RyRHF5REo4LzJ0REJ0WTRRL0wxdUpRc1lYeldRQ2pUcExkQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgtvX4UthmBwymnAZ7CuTpJdLTASr1lRj1MvRwAesjtMM=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("rangeKey", b642Av("AG4AAAABOA==")); + item.put("stringValue", b642Av("AHMAAAAMSGVsbG8gd29ybGQh")); + item.put("hashKey", b642Av("AG4AAAABNg==")); + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAADjAAAAAAAAABBhbXpuLWRkYi1lbnYta2V5AAAAOGpyLzI2c1V1NW5udlQwcmVzY0NPWEhXTHZwZzlySjNkeURSVHQxRFFMcnAvTG9STkRyNk5EQT09AAAAEGFtem4tZGRiLWVudi1hbGcAAAADQUVTAAAAEGFtem4tZGRiLW1ldGEtaWQAAAAObWF0ZXJpYWxOYW1lIzAAAAARYW16bi1kZGItd3JhcC1hbGcAAAAHQUVTV3JhcAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("doubleSet", b642Av("AE4AAAAFAAAAAi0zAAAABS0zNC4yAAAAATAAAAACMTUAAAADNy42")); + item.put("intSet", b642Av("AGIAAABAUBGZEIoWzYKTFCsFoZYXzRUJsNuy3xr64nCwsL14lZNk62Aff5n3+ETtWm8U9E3PMOp9LozkDwZcnzs0rnYIeA==")); + item.put("byteArrayValue", b642Av("AGIAAAAgl9wQf/r6vivuTCvIz0Jeqd80xPII30sf317fED7Xrrs=")); + item.put("intValue", b642Av("AG4AAAADMTIz")); + item.put("stringSet", b642Av("AGIAAABAAijuavOYfNvcle2WbG8I2a4W1af+UPxhKguG3YMW5E6MoXsdO5ddSAifAPbVLmv92VyJnx/o817m1IOSs+LccA==")); + item.put("doubleValue", b642Av("AG4AAAACMTU=")); + item.put("version", b642Av("AG4AAAABMQ==")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgpzB3S616mcP6HQrkeaUYdV5Qo2UYWF6p04GZhSzcpV8=")); + ddb.putItem(new PutItemRequest("TableName", item)); + item.clear(); + + item.put("*amzn-ddb-map-desc*", b642Av("AGIAAAAyAAAAAAAAABVhbXpuLWRkYi1tYXAtc3ltLW1vZGUAAAARL0NCQy9QS0NTNVBhZGRpbmc=")); + item.put("t", b642Av("AGIAAAAgeJcKzY3SHwBIhXdfxeYWd9UE5yX+RxaPJQ7L2TdgDxs=")); + item.put("V", b642Av("AG4AAAABMA==")); + item.put("encAlg", b642Av("AGIAAAAgXJilRkdsIP0bqzvqutJc8AC8YhY1YApJCgTLXgAqtwU=")); + item.put("enc", b642Av("AGIAAABADvDUW2Ao1YWp7uxxEL+mv5uqHCrSNIDR18CgBD8XHCuNlBPC6GXxk9YnFmv3kgVDlMdEo0wE79zRoETB7GmjcA==")); + item.put("intAlg", b642Av("AGIAAAAwI//7G2LUrAQ2EwQGQr7ZIKyXl1AlGeB+kfvZGmCj6wShZpMKPXjyBF/9RvIz3clQ")); + item.put("N", b642Av("AHMAAAAMbWF0ZXJpYWxOYW1l")); + item.put("int", b642Av("AGIAAABAzFha4J4gPaiwhjiQs47L0bTf4WSNemVAxKJJnBnujl7OajvO7ZW3zehGJlaai4tCLxTwoLPI+Ig/a+zCdau4iw==")); + item.put("*amzn-ddb-map-sig*", b642Av("AGIAAAAgaklO+h7kSUjXEt6pBA03G4wiIU20XKT/sP+rKSeNAKc=")); + ddb.putItem(new PutItemRequest("metastore", item)); + item.clear(); } private static AttributeValue b642Av(String b64) { diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DelegatedEncryptionTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DelegatedEncryptionTest.java index 6dede8dd..59e2063c 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DelegatedEncryptionTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DelegatedEncryptionTest.java @@ -14,12 +14,18 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling.encryption; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.EncryptionMaterialsProvider; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.SymmetricStaticProvider; +import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; +import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import com.amazonaws.services.dynamodbv2.testing.AttrMatcher; +import com.amazonaws.services.dynamodbv2.testing.TestDelegatedKey; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.crypto.spec.SecretKeySpec; import java.nio.ByteBuffer; import java.security.GeneralSecurityException; import java.security.KeyPair; @@ -32,56 +38,48 @@ import java.util.Map; import java.util.Set; -import javax.crypto.spec.SecretKeySpec; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.EncryptionMaterialsProvider; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.SymmetricStaticProvider; -import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; -import com.amazonaws.services.dynamodbv2.model.AttributeValue; -import com.amazonaws.services.dynamodbv2.testing.AttrMatcher; -import com.amazonaws.services.dynamodbv2.testing.TestDelegatedKey; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; public class DelegatedEncryptionTest { private static SecretKeySpec rawEncryptionKey; private static SecretKeySpec rawMacKey; private static DelegatedKey encryptionKey; private static DelegatedKey macKey; - + private EncryptionMaterialsProvider prov; private DynamoDBEncryptor encryptor; private Map attribs; private EncryptionContext context; - + @BeforeClass public static void setupClass() throws Exception { rawEncryptionKey = new SecretKeySpec(Utils.getRandom(32), "AES"); encryptionKey = new TestDelegatedKey(rawEncryptionKey); - + rawMacKey = new SecretKeySpec(Utils.getRandom(32), "HmacSHA256"); macKey = new TestDelegatedKey(rawMacKey); } - + @Before public void setUp() throws Exception { prov = new SymmetricStaticProvider(encryptionKey, macKey, - Collections. emptyMap()); + Collections.emptyMap()); encryptor = DynamoDBEncryptor.getInstance(prov, "encryptor-"); - + attribs = new HashMap(); attribs.put("intValue", new AttributeValue().withN("123")); attribs.put("stringValue", new AttributeValue().withS("Hello world!")); - attribs.put("byteArrayValue", new AttributeValue().withB(ByteBuffer.wrap(new byte[] {0, 1, 2, 3, 4, 5}))); + attribs.put("byteArrayValue", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5}))); attribs.put("stringSet", new AttributeValue().withSS("Goodbye", "Cruel", "World", "?")); attribs.put("intSet", new AttributeValue().withNS("1", "200", "10", "15", "0")); attribs.put("hashKey", new AttributeValue().withN("5")); attribs.put("rangeKey", new AttributeValue().withN("7")); attribs.put("version", new AttributeValue().withN("0")); - + context = new EncryptionContext.Builder() .withTableName("TableName") .withHashKeyName("hashKey") @@ -102,28 +100,28 @@ public void testSetMaterialDescriptionFieldName() { encryptor.setMaterialDescriptionFieldName("A different value"); assertEquals("A different value", encryptor.getMaterialDescriptionFieldName()); } - + @Test public void fullEncryption() throws GeneralSecurityException { - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(Collections.unmodifiableMap(attribs), context, "hashKey", "rangeKey", "version"); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); Map decryptedAttributes = encryptor.decryptAllFieldsExcept(Collections.unmodifiableMap(encryptedAttributes), context, "hashKey", "rangeKey", "version"); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); - + // Make sure keys and version are not encrypted assertAttrEquals(attribs.get("hashKey"), encryptedAttributes.get("hashKey")); assertAttrEquals(attribs.get("rangeKey"), encryptedAttributes.get("rangeKey")); assertAttrEquals(attribs.get("version"), encryptedAttributes.get("version")); - + // Make sure String has been encrypted (we'll assume the others are correct as well) assertTrue(encryptedAttributes.containsKey("stringValue")); assertNull(encryptedAttributes.get("stringValue").getS()); assertNotNull(encryptedAttributes.get("stringValue").getB()); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void fullEncryptionBadSignature() throws GeneralSecurityException { Map encryptedAttributes = encryptor.encryptAllFieldsExcept(Collections.unmodifiableMap(attribs), context, "hashKey", "rangeKey", "version"); @@ -131,8 +129,8 @@ public void fullEncryptionBadSignature() throws GeneralSecurityException { encryptedAttributes.get("hashKey").setN("666"); encryptor.decryptAllFieldsExcept(Collections.unmodifiableMap(encryptedAttributes), context, "hashKey", "rangeKey", "version"); } - - @Test(expected=IllegalArgumentException.class) + + @Test(expected = IllegalArgumentException.class) public void badVersionNumber() throws GeneralSecurityException { Map encryptedAttributes = encryptor.encryptAllFieldsExcept(Collections.unmodifiableMap(attribs), context, "hashKey", "rangeKey", "version"); @@ -143,101 +141,101 @@ public void badVersionNumber() throws GeneralSecurityException { encryptedAttributes.put(encryptor.getMaterialDescriptionFieldName(), new AttributeValue().withB(ByteBuffer.wrap(rawArray))); encryptor.decryptAllFieldsExcept(Collections.unmodifiableMap(encryptedAttributes), context, "hashKey", "rangeKey", "version"); } - + @Test public void signedOnly() throws GeneralSecurityException { - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); Map decryptedAttributes = encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); - + // Make sure keys and version are not encrypted assertAttrEquals(attribs.get("hashKey"), encryptedAttributes.get("hashKey")); assertAttrEquals(attribs.get("rangeKey"), encryptedAttributes.get("rangeKey")); assertAttrEquals(attribs.get("version"), encryptedAttributes.get("version")); - + // Make sure String has not been encrypted (we'll assume the others are correct as well) assertAttrEquals(attribs.get("stringValue"), encryptedAttributes.get("stringValue")); } - + @Test public void signedOnlyNullCryptoKey() throws GeneralSecurityException { prov = new SymmetricStaticProvider(null, macKey, Collections.emptyMap()); encryptor = DynamoDBEncryptor.getInstance(prov, "encryptor-"); - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); Map decryptedAttributes = encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); - + // Make sure keys and version are not encrypted assertAttrEquals(attribs.get("hashKey"), encryptedAttributes.get("hashKey")); assertAttrEquals(attribs.get("rangeKey"), encryptedAttributes.get("rangeKey")); assertAttrEquals(attribs.get("version"), encryptedAttributes.get("version")); - + // Make sure String has not been encrypted (we'll assume the others are correct as well) assertAttrEquals(attribs.get("stringValue"), encryptedAttributes.get("stringValue")); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void signedOnlyBadSignature() throws GeneralSecurityException { - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); encryptedAttributes.get("hashKey").setN("666"); encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void signedOnlyNoSignature() throws GeneralSecurityException { - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); encryptedAttributes.remove(encryptor.getSignatureFieldName()); encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); } - + @Test public void RsaSignedOnly() throws GeneralSecurityException { KeyPairGenerator rsaGen = KeyPairGenerator.getInstance("RSA"); rsaGen.initialize(2048, Utils.getRng()); KeyPair sigPair = rsaGen.generateKeyPair(); encryptor = DynamoDBEncryptor.getInstance( - new SymmetricStaticProvider(encryptionKey, sigPair, - Collections. emptyMap()), "encryptor-"); - + new SymmetricStaticProvider(encryptionKey, sigPair, + Collections.emptyMap()), "encryptor-"); + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); - Map decryptedAttributes = + Map decryptedAttributes = encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); - + // Make sure keys and version are not encrypted assertAttrEquals(attribs.get("hashKey"), encryptedAttributes.get("hashKey")); assertAttrEquals(attribs.get("rangeKey"), encryptedAttributes.get("rangeKey")); assertAttrEquals(attribs.get("version"), encryptedAttributes.get("version")); - + // Make sure String has not been encrypted (we'll assume the others are correct as well) assertAttrEquals(attribs.get("stringValue"), encryptedAttributes.get("stringValue")); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void RsaSignedOnlyBadSignature() throws GeneralSecurityException { KeyPairGenerator rsaGen = KeyPairGenerator.getInstance("RSA"); rsaGen.initialize(2048, Utils.getRng()); KeyPair sigPair = rsaGen.generateKeyPair(); encryptor = DynamoDBEncryptor.getInstance( - new SymmetricStaticProvider(encryptionKey, sigPair, - Collections. emptyMap()), "encryptor-"); - + new SymmetricStaticProvider(encryptionKey, sigPair, + Collections.emptyMap()), "encryptor-"); + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); encryptedAttributes.get("hashKey").setN("666"); encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); } - + private void assertAttrEquals(AttributeValue o1, AttributeValue o2) { Assert.assertEquals(o1.getB(), o2.getB()); assertSetsEqual(o1.getBS(), o2.getBS()); @@ -246,7 +244,7 @@ private void assertAttrEquals(AttributeValue o1, AttributeValue o2) { Assert.assertEquals(o1.getS(), o2.getS()); assertSetsEqual(o1.getSS(), o2.getSS()); } - + private void assertSetsEqual(Collection c1, Collection c2) { Assert.assertFalse(c1 == null ^ c2 == null); if (c1 != null) { diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DelegatedEnvelopeEncryptionTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DelegatedEnvelopeEncryptionTest.java index cc21c0f1..ba1f1428 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DelegatedEnvelopeEncryptionTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DelegatedEnvelopeEncryptionTest.java @@ -14,12 +14,19 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling.encryption; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.EncryptionMaterialsProvider; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.SymmetricStaticProvider; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.WrappedMaterialsProvider; +import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; +import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import com.amazonaws.services.dynamodbv2.testing.AttrMatcher; +import com.amazonaws.services.dynamodbv2.testing.TestDelegatedKey; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.crypto.spec.SecretKeySpec; import java.nio.ByteBuffer; import java.security.GeneralSecurityException; import java.security.KeyPair; @@ -32,32 +39,23 @@ import java.util.Map; import java.util.Set; -import javax.crypto.spec.SecretKeySpec; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.EncryptionMaterialsProvider; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.SymmetricStaticProvider; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.WrappedMaterialsProvider; -import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; -import com.amazonaws.services.dynamodbv2.model.AttributeValue; -import com.amazonaws.services.dynamodbv2.testing.AttrMatcher; -import com.amazonaws.services.dynamodbv2.testing.TestDelegatedKey; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; public class DelegatedEnvelopeEncryptionTest { private static SecretKeySpec rawEncryptionKey; private static SecretKeySpec rawMacKey; private static DelegatedKey encryptionKey; private static DelegatedKey macKey; - + private EncryptionMaterialsProvider prov; private DynamoDBEncryptor encryptor; private Map attribs; private EncryptionContext context; - + @BeforeClass public static void setupClass() throws Exception { rawEncryptionKey = new SecretKeySpec(Utils.getRandom(32), "AES"); @@ -66,27 +64,27 @@ public static void setupClass() throws Exception { rawMacKey = new SecretKeySpec(Utils.getRandom(32), "HmacSHA256"); macKey = new TestDelegatedKey(rawMacKey); } - + @Before public void setUp() throws Exception { prov = new WrappedMaterialsProvider(encryptionKey, encryptionKey, macKey, Collections.emptyMap()); encryptor = DynamoDBEncryptor.getInstance(prov, "encryptor-"); - + attribs = new HashMap(); attribs.put("intValue", new AttributeValue().withN("123")); attribs.put("stringValue", new AttributeValue().withS("Hello world!")); - attribs.put("byteArrayValue", new AttributeValue().withB(ByteBuffer.wrap(new byte[] {0, 1, 2, 3, 4, 5}))); + attribs.put("byteArrayValue", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5}))); attribs.put("stringSet", new AttributeValue().withSS("Goodbye", "Cruel", "World", "?")); attribs.put("intSet", new AttributeValue().withNS("1", "200", "10", "15", "0")); attribs.put("hashKey", new AttributeValue().withN("5")); attribs.put("rangeKey", new AttributeValue().withN("7")); attribs.put("version", new AttributeValue().withN("0")); - + context = new EncryptionContext.Builder() - .withTableName("TableName") - .withHashKeyName("hashKey") - .withRangeKeyName("rangeKey") - .build(); + .withTableName("TableName") + .withHashKeyName("hashKey") + .withRangeKeyName("rangeKey") + .build(); } @Test @@ -102,28 +100,28 @@ public void testSetMaterialDescriptionFieldName() { encryptor.setMaterialDescriptionFieldName("A different value"); assertEquals("A different value", encryptor.getMaterialDescriptionFieldName()); } - + @Test public void fullEncryption() throws GeneralSecurityException { - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(Collections.unmodifiableMap(attribs), context, "hashKey", "rangeKey", "version"); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); Map decryptedAttributes = encryptor.decryptAllFieldsExcept(Collections.unmodifiableMap(encryptedAttributes), context, "hashKey", "rangeKey", "version"); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); - + // Make sure keys and version are not encrypted assertAttrEquals(attribs.get("hashKey"), encryptedAttributes.get("hashKey")); assertAttrEquals(attribs.get("rangeKey"), encryptedAttributes.get("rangeKey")); assertAttrEquals(attribs.get("version"), encryptedAttributes.get("version")); - + // Make sure String has been encrypted (we'll assume the others are correct as well) assertTrue(encryptedAttributes.containsKey("stringValue")); assertNull(encryptedAttributes.get("stringValue").getS()); assertNotNull(encryptedAttributes.get("stringValue").getB()); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void fullEncryptionBadSignature() throws GeneralSecurityException { Map encryptedAttributes = encryptor.encryptAllFieldsExcept(Collections.unmodifiableMap(attribs), context, "hashKey", "rangeKey", "version"); @@ -131,8 +129,8 @@ public void fullEncryptionBadSignature() throws GeneralSecurityException { encryptedAttributes.get("hashKey").setN("666"); encryptor.decryptAllFieldsExcept(Collections.unmodifiableMap(encryptedAttributes), context, "hashKey", "rangeKey", "version"); } - - @Test(expected=IllegalArgumentException.class) + + @Test(expected = IllegalArgumentException.class) public void badVersionNumber() throws GeneralSecurityException { Map encryptedAttributes = encryptor.encryptAllFieldsExcept(Collections.unmodifiableMap(attribs), context, "hashKey", "rangeKey", "version"); @@ -143,101 +141,101 @@ public void badVersionNumber() throws GeneralSecurityException { encryptedAttributes.put(encryptor.getMaterialDescriptionFieldName(), new AttributeValue().withB(ByteBuffer.wrap(rawArray))); encryptor.decryptAllFieldsExcept(Collections.unmodifiableMap(encryptedAttributes), context, "hashKey", "rangeKey", "version"); } - + @Test public void signedOnly() throws GeneralSecurityException { - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); Map decryptedAttributes = encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); - + // Make sure keys and version are not encrypted assertAttrEquals(attribs.get("hashKey"), encryptedAttributes.get("hashKey")); assertAttrEquals(attribs.get("rangeKey"), encryptedAttributes.get("rangeKey")); assertAttrEquals(attribs.get("version"), encryptedAttributes.get("version")); - + // Make sure String has not been encrypted (we'll assume the others are correct as well) assertAttrEquals(attribs.get("stringValue"), encryptedAttributes.get("stringValue")); } - + @Test public void signedOnlyNullCryptoKey() throws GeneralSecurityException { prov = new SymmetricStaticProvider(null, macKey, Collections.emptyMap()); encryptor = DynamoDBEncryptor.getInstance(prov, "encryptor-"); - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); Map decryptedAttributes = encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); - + // Make sure keys and version are not encrypted assertAttrEquals(attribs.get("hashKey"), encryptedAttributes.get("hashKey")); assertAttrEquals(attribs.get("rangeKey"), encryptedAttributes.get("rangeKey")); assertAttrEquals(attribs.get("version"), encryptedAttributes.get("version")); - + // Make sure String has not been encrypted (we'll assume the others are correct as well) assertAttrEquals(attribs.get("stringValue"), encryptedAttributes.get("stringValue")); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void signedOnlyBadSignature() throws GeneralSecurityException { - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); encryptedAttributes.get("hashKey").setN("666"); encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void signedOnlyNoSignature() throws GeneralSecurityException { - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); encryptedAttributes.remove(encryptor.getSignatureFieldName()); encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); } - + @Test public void RsaSignedOnly() throws GeneralSecurityException { KeyPairGenerator rsaGen = KeyPairGenerator.getInstance("RSA"); rsaGen.initialize(2048, Utils.getRng()); KeyPair sigPair = rsaGen.generateKeyPair(); encryptor = DynamoDBEncryptor.getInstance( - new SymmetricStaticProvider(encryptionKey, sigPair, - Collections. emptyMap()), "encryptor-"); - + new SymmetricStaticProvider(encryptionKey, sigPair, + Collections.emptyMap()), "encryptor-"); + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); - Map decryptedAttributes = + Map decryptedAttributes = encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); - + // Make sure keys and version are not encrypted assertAttrEquals(attribs.get("hashKey"), encryptedAttributes.get("hashKey")); assertAttrEquals(attribs.get("rangeKey"), encryptedAttributes.get("rangeKey")); assertAttrEquals(attribs.get("version"), encryptedAttributes.get("version")); - + // Make sure String has not been encrypted (we'll assume the others are correct as well) assertAttrEquals(attribs.get("stringValue"), encryptedAttributes.get("stringValue")); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void RsaSignedOnlyBadSignature() throws GeneralSecurityException { KeyPairGenerator rsaGen = KeyPairGenerator.getInstance("RSA"); rsaGen.initialize(2048, Utils.getRng()); KeyPair sigPair = rsaGen.generateKeyPair(); encryptor = DynamoDBEncryptor.getInstance( - new SymmetricStaticProvider(encryptionKey, sigPair, - Collections. emptyMap()), "encryptor-"); - + new SymmetricStaticProvider(encryptionKey, sigPair, + Collections.emptyMap()), "encryptor-"); + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); encryptedAttributes.get("hashKey").setN("666"); encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); } - + private void assertAttrEquals(AttributeValue o1, AttributeValue o2) { Assert.assertEquals(o1.getB(), o2.getB()); assertSetsEqual(o1.getBS(), o2.getBS()); @@ -246,7 +244,7 @@ private void assertAttrEquals(AttributeValue o1, AttributeValue o2) { Assert.assertEquals(o1.getS(), o2.getS()); assertSetsEqual(o1.getSS(), o2.getSS()); } - + private void assertSetsEqual(Collection c1, Collection c2) { Assert.assertFalse(c1 == null ^ c2 == null); if (c1 != null) { diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DynamoDBEncryptorTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DynamoDBEncryptorTest.java index 4a33d36a..67e432e1 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DynamoDBEncryptorTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DynamoDBEncryptorTest.java @@ -14,16 +14,23 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling.encryption; -import static com.amazonaws.services.dynamodbv2.datamodeling.encryption.utils.EncryptionContextOperators.overrideEncryptionContextTableName; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.DecryptionMaterials; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.EncryptionMaterialsProvider; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.SymmetricStaticProvider; +import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; +import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import com.amazonaws.services.dynamodbv2.testing.AttrMatcher; +import org.bouncycastle.jce.ECNamedCurveTable; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.bouncycastle.jce.spec.ECParameterSpec; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; import java.lang.reflect.Method; import java.nio.ByteBuffer; import java.security.GeneralSecurityException; @@ -43,29 +50,20 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; - -import org.bouncycastle.jce.ECNamedCurveTable; -import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.bouncycastle.jce.spec.ECParameterSpec; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.DecryptionMaterials; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.EncryptionMaterialsProvider; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.SymmetricStaticProvider; -import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; -import com.amazonaws.services.dynamodbv2.model.AttributeValue; -import com.amazonaws.services.dynamodbv2.testing.AttrMatcher; +import static com.amazonaws.services.dynamodbv2.datamodeling.encryption.utils.EncryptionContextOperators.overrideEncryptionContextTableName; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; public class DynamoDBEncryptorTest { private static SecretKey encryptionKey; private static SecretKey macKey; - + private InstrumentedEncryptionMaterialsProvider prov; private DynamoDBEncryptor encryptor; private Map attribs; @@ -77,23 +75,23 @@ public static void setUpClass() throws Exception { KeyGenerator aesGen = KeyGenerator.getInstance("AES"); aesGen.init(128, Utils.getRng()); encryptionKey = aesGen.generateKey(); - + KeyGenerator macGen = KeyGenerator.getInstance("HmacSHA256"); macGen.init(256, Utils.getRng()); macKey = macGen.generateKey(); } - + @Before public void setUp() throws Exception { prov = new InstrumentedEncryptionMaterialsProvider( - new SymmetricStaticProvider(encryptionKey, macKey, - Collections. emptyMap())); + new SymmetricStaticProvider(encryptionKey, macKey, + Collections.emptyMap())); encryptor = DynamoDBEncryptor.getInstance(prov, "encryptor-"); - + attribs = new HashMap(); attribs.put("intValue", new AttributeValue().withN("123")); attribs.put("stringValue", new AttributeValue().withS("Hello world!")); - attribs.put("byteArrayValue", new AttributeValue().withB(ByteBuffer.wrap(new byte[] {0, 1, 2, 3, 4, 5}))); + attribs.put("byteArrayValue", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5}))); attribs.put("stringSet", new AttributeValue().withSS("Goodbye", "Cruel", "World", "?")); attribs.put("intSet", new AttributeValue().withNS("1", "200", "10", "15", "0")); attribs.put("hashKey", new AttributeValue().withN("5")); @@ -129,10 +127,10 @@ public void setUp() throws Exception { context = new EncryptionContext.Builder() - .withTableName("TableName") - .withHashKeyName("hashKey") - .withRangeKeyName("rangeKey") - .build(); + .withTableName("TableName") + .withHashKeyName("hashKey") + .withRangeKeyName("rangeKey") + .build(); } @Test @@ -148,7 +146,7 @@ public void testSetMaterialDescriptionFieldName() { encryptor.setMaterialDescriptionFieldName("A different value"); assertEquals("A different value", encryptor.getMaterialDescriptionFieldName()); } - + @Test public void fullEncryption() throws GeneralSecurityException { Map encryptedAttributes = @@ -170,7 +168,7 @@ public void fullEncryption() throws GeneralSecurityException { assertNotNull(encryptedAttributes.get("stringValue").getB()); // Make sure we're calling the proper getEncryptionMaterials method - assertEquals("Wrong getEncryptionMaterials() called", + assertEquals("Wrong getEncryptionMaterials() called", 1, prov.getCallCount("getEncryptionMaterials(EncryptionContext context)")); } @@ -184,7 +182,7 @@ public void ensureEncryptedAttributesUnmodified() throws GeneralSecurityExceptio assertEquals(encryptedString, encryptedAttributes.toString()); } - @Test(expected=SignatureException.class) + @Test(expected = SignatureException.class) public void fullEncryptionBadSignature() throws GeneralSecurityException { Map encryptedAttributes = encryptor.encryptAllFieldsExcept(Collections.unmodifiableMap(attribs), context, "hashKey", "rangeKey", "version"); @@ -192,8 +190,8 @@ public void fullEncryptionBadSignature() throws GeneralSecurityException { encryptedAttributes.get("hashKey").setN("666"); encryptor.decryptAllFieldsExcept(Collections.unmodifiableMap(encryptedAttributes), context, "hashKey", "rangeKey", "version"); } - - @Test(expected=IllegalArgumentException.class) + + @Test(expected = IllegalArgumentException.class) public void badVersionNumber() throws GeneralSecurityException { Map encryptedAttributes = encryptor.encryptAllFieldsExcept(Collections.unmodifiableMap(attribs), context, "hashKey", "rangeKey", "version"); @@ -204,96 +202,96 @@ public void badVersionNumber() throws GeneralSecurityException { encryptedAttributes.put(encryptor.getMaterialDescriptionFieldName(), new AttributeValue().withB(ByteBuffer.wrap(rawArray))); encryptor.decryptAllFieldsExcept(Collections.unmodifiableMap(encryptedAttributes), context, "hashKey", "rangeKey", "version"); } - + @Test public void signedOnly() throws GeneralSecurityException { - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); Map decryptedAttributes = encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); - + // Make sure keys and version are not encrypted assertAttrEquals(attribs.get("hashKey"), encryptedAttributes.get("hashKey")); assertAttrEquals(attribs.get("rangeKey"), encryptedAttributes.get("rangeKey")); assertAttrEquals(attribs.get("version"), encryptedAttributes.get("version")); - + // Make sure String has not been encrypted (we'll assume the others are correct as well) assertAttrEquals(attribs.get("stringValue"), encryptedAttributes.get("stringValue")); } - + @Test public void signedOnlyNullCryptoKey() throws GeneralSecurityException { prov = new InstrumentedEncryptionMaterialsProvider( new SymmetricStaticProvider(null, macKey, Collections.emptyMap())); encryptor = DynamoDBEncryptor.getInstance(prov, "encryptor-"); - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); Map decryptedAttributes = encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); - + // Make sure keys and version are not encrypted assertAttrEquals(attribs.get("hashKey"), encryptedAttributes.get("hashKey")); assertAttrEquals(attribs.get("rangeKey"), encryptedAttributes.get("rangeKey")); assertAttrEquals(attribs.get("version"), encryptedAttributes.get("version")); - + // Make sure String has not been encrypted (we'll assume the others are correct as well) assertAttrEquals(attribs.get("stringValue"), encryptedAttributes.get("stringValue")); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void signedOnlyBadSignature() throws GeneralSecurityException { - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); encryptedAttributes.get("hashKey").setN("666"); encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void signedOnlyNoSignature() throws GeneralSecurityException { - Map encryptedAttributes = + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); encryptedAttributes.remove(encryptor.getSignatureFieldName()); encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); } - + @Test public void RsaSignedOnly() throws GeneralSecurityException { KeyPairGenerator rsaGen = KeyPairGenerator.getInstance("RSA"); rsaGen.initialize(2048, Utils.getRng()); KeyPair sigPair = rsaGen.generateKeyPair(); encryptor = DynamoDBEncryptor.getInstance( - new SymmetricStaticProvider(encryptionKey, sigPair, - Collections. emptyMap()), "encryptor-"); - + new SymmetricStaticProvider(encryptionKey, sigPair, + Collections.emptyMap()), "encryptor-"); + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); - Map decryptedAttributes = + Map decryptedAttributes = encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); - + // Make sure keys and version are not encrypted assertAttrEquals(attribs.get("hashKey"), encryptedAttributes.get("hashKey")); assertAttrEquals(attribs.get("rangeKey"), encryptedAttributes.get("rangeKey")); assertAttrEquals(attribs.get("version"), encryptedAttributes.get("version")); - + // Make sure String has not been encrypted (we'll assume the others are correct as well) assertAttrEquals(attribs.get("stringValue"), encryptedAttributes.get("stringValue")); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void RsaSignedOnlyBadSignature() throws GeneralSecurityException { KeyPairGenerator rsaGen = KeyPairGenerator.getInstance("RSA"); rsaGen.initialize(2048, Utils.getRng()); KeyPair sigPair = rsaGen.generateKeyPair(); encryptor = DynamoDBEncryptor.getInstance( - new SymmetricStaticProvider(encryptionKey, sigPair, - Collections. emptyMap()), "encryptor-"); - + new SymmetricStaticProvider(encryptionKey, sigPair, + Collections.emptyMap()), "encryptor-"); + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); encryptedAttributes.get("hashKey").setN("666"); @@ -302,6 +300,7 @@ public void RsaSignedOnlyBadSignature() throws GeneralSecurityException { /** * Tests that no exception is thrown when the encryption context override operator is null + * * @throws GeneralSecurityException */ @Test @@ -313,6 +312,7 @@ public void testNullEncryptionContextOperator() throws GeneralSecurityException /** * Tests decrypt and encrypt with an encryption context override operator + * * @throws GeneralSecurityException */ @Test @@ -329,6 +329,7 @@ public void testTableNameOverriddenEncryptionContextOperator() throws GeneralSec /** * Tests encrypt with an encryption context override operator, and a second encryptor without an override + * * @throws GeneralSecurityException */ @Test @@ -348,6 +349,7 @@ public void testTableNameOverriddenEncryptionContextOperatorWithSecondEncryptor( /** * Tests encrypt with an encryption context override operator, and a second encryptor without an override + * * @throws GeneralSecurityException */ @Test(expected = SignatureException.class) @@ -368,23 +370,23 @@ public void testTableNameOverriddenEncryptionContextOperatorWithSecondEncryptorB public void EcdsaSignedOnly() throws GeneralSecurityException { encryptor = DynamoDBEncryptor.getInstance(getMaterialProviderwithECDSA()); - + Map encryptedAttributes = encryptor.encryptAllFieldsExcept(attribs, context, attribs.keySet().toArray(new String[0])); assertThat(encryptedAttributes, AttrMatcher.invert(attribs)); - Map decryptedAttributes = + Map decryptedAttributes = encryptor.decryptAllFieldsExcept(encryptedAttributes, context, attribs.keySet().toArray(new String[0])); assertThat(decryptedAttributes, AttrMatcher.match(attribs)); - + // Make sure keys and version are not encrypted assertAttrEquals(attribs.get("hashKey"), encryptedAttributes.get("hashKey")); assertAttrEquals(attribs.get("rangeKey"), encryptedAttributes.get("rangeKey")); assertAttrEquals(attribs.get("version"), encryptedAttributes.get("version")); - + // Make sure String has not been encrypted (we'll assume the others are correct as well) assertAttrEquals(attribs.get("stringValue"), encryptedAttributes.get("stringValue")); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void EcdsaSignedOnlyBadSignature() throws GeneralSecurityException { encryptor = DynamoDBEncryptor.getInstance(getMaterialProviderwithECDSA()); @@ -397,14 +399,14 @@ public void EcdsaSignedOnlyBadSignature() throws GeneralSecurityException { @Test public void toByteArray() throws ReflectiveOperationException { - final byte[] expected = new byte[] {0, 1, 2, 3, 4, 5}; + final byte[] expected = new byte[]{0, 1, 2, 3, 4, 5}; assertToByteArray("Wrap", expected, ByteBuffer.wrap(expected)); assertToByteArray("Wrap-RO", expected, ByteBuffer.wrap(expected).asReadOnlyBuffer()); - assertToByteArray("Wrap-Truncated-Sliced", expected, ByteBuffer.wrap(new byte[] {0, 1, 2, 3, 4, 5, 6}, 0, 6).slice()); - assertToByteArray("Wrap-Offset-Sliced", expected, ByteBuffer.wrap(new byte[] {6, 0, 1, 2, 3, 4, 5, 6}, 1, 6).slice()); - assertToByteArray("Wrap-Truncated", expected, ByteBuffer.wrap(new byte[] {0, 1, 2, 3, 4, 5, 6}, 0, 6)); - assertToByteArray("Wrap-Offset", expected, ByteBuffer.wrap(new byte[] {6, 0, 1, 2, 3, 4, 5, 6}, 1, 6)); + assertToByteArray("Wrap-Truncated-Sliced", expected, ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5, 6}, 0, 6).slice()); + assertToByteArray("Wrap-Offset-Sliced", expected, ByteBuffer.wrap(new byte[]{6, 0, 1, 2, 3, 4, 5, 6}, 1, 6).slice()); + assertToByteArray("Wrap-Truncated", expected, ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5, 6}, 0, 6)); + assertToByteArray("Wrap-Offset", expected, ByteBuffer.wrap(new byte[]{6, 0, 1, 2, 3, 4, 5, 6}, 1, 6)); ByteBuffer buff = ByteBuffer.allocate(expected.length + 10); buff.put(expected); @@ -437,7 +439,7 @@ private void assertAttrEquals(AttributeValue o1, AttributeValue o2) { Assert.assertEquals(o1.getS(), o2.getS()); assertSetsEqual(o1.getSS(), o2.getSS()); } - + private void assertSetsEqual(Collection c1, Collection c2) { Assert.assertFalse(c1 == null ^ c2 == null); if (c1 != null) { @@ -447,26 +449,26 @@ private void assertSetsEqual(Collection c1, Collection c2) { } } - private EncryptionMaterialsProvider getMaterialProviderwithECDSA() - throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, NoSuchProviderException { - Security.addProvider(new BouncyCastleProvider()); - ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("secp384r1"); - KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC"); - g.initialize(ecSpec, Utils.getRng()); - KeyPair keypair = g.generateKeyPair(); - Map description = new HashMap(); - description.put(DynamoDBEncryptor.DEFAULT_SIGNING_ALGORITHM_HEADER, "SHA384withECDSA"); - return new SymmetricStaticProvider(null, keypair, description); + private EncryptionMaterialsProvider getMaterialProviderwithECDSA() + throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, NoSuchProviderException { + Security.addProvider(new BouncyCastleProvider()); + ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("secp384r1"); + KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC"); + g.initialize(ecSpec, Utils.getRng()); + KeyPair keypair = g.generateKeyPair(); + Map description = new HashMap(); + description.put(DynamoDBEncryptor.DEFAULT_SIGNING_ALGORITHM_HEADER, "SHA384withECDSA"); + return new SymmetricStaticProvider(null, keypair, description); } private static final class InstrumentedEncryptionMaterialsProvider implements EncryptionMaterialsProvider { private final EncryptionMaterialsProvider delegate; private final ConcurrentHashMap calls = new ConcurrentHashMap<>(); - + public InstrumentedEncryptionMaterialsProvider(EncryptionMaterialsProvider delegate) { this.delegate = delegate; } - + @Override public DecryptionMaterials getDecryptionMaterials(EncryptionContext context) { incrementMethodCount("getDecryptionMaterials()"); @@ -484,7 +486,7 @@ public void refresh() { incrementMethodCount("refresh()"); delegate.refresh(); } - + public int getCallCount(String method) { AtomicInteger count = calls.get(method); if (count != null) { @@ -493,12 +495,12 @@ public int getCallCount(String method) { return 0; } } - + @SuppressWarnings("unused") public void resetCallCounts() { calls.clear(); } - + private void incrementMethodCount(String method) { AtomicInteger oldValue = calls.putIfAbsent(method, new AtomicInteger(1)); if (oldValue != null) { diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DynamoDBSignerTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DynamoDBSignerTest.java index 44fc1e38..b39a4427 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DynamoDBSignerTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/DynamoDBSignerTest.java @@ -14,6 +14,16 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling.encryption; +import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; +import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import org.bouncycastle.jce.ECNamedCurveTable; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.bouncycastle.jce.spec.ECParameterSpec; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import javax.crypto.KeyGenerator; import java.nio.ByteBuffer; import java.security.GeneralSecurityException; import java.security.Key; @@ -26,18 +36,6 @@ import java.util.Map; import java.util.Set; -import javax.crypto.KeyGenerator; - -import org.bouncycastle.jce.ECNamedCurveTable; -import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.bouncycastle.jce.spec.ECParameterSpec; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; -import com.amazonaws.services.dynamodbv2.model.AttributeValue; - public class DynamoDBSignerTest { // These use the Key type (rather than PublicKey, PrivateKey, and SecretKey) // to test the routing logic within the signer. @@ -48,21 +46,21 @@ public class DynamoDBSignerTest { private DynamoDBSigner signerEcdsa; private static Key pubKeyEcdsa; private static Key privKeyEcdsa; - + @BeforeClass public static void setUpClass() throws Exception { - + //RSA key generation KeyPairGenerator rsaGen = KeyPairGenerator.getInstance("RSA"); rsaGen.initialize(2048, Utils.getRng()); KeyPair sigPair = rsaGen.generateKeyPair(); pubKeyRsa = sigPair.getPublic(); privKeyRsa = sigPair.getPrivate(); - + KeyGenerator macGen = KeyGenerator.getInstance("HmacSHA256"); macGen.init(256, Utils.getRng()); macKey = macGen.generateKey(); - + Security.addProvider(new BouncyCastleProvider()); ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("secp384r1"); KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC"); @@ -70,9 +68,9 @@ public static void setUpClass() throws Exception { KeyPair keypair = g.generateKeyPair(); pubKeyEcdsa = keypair.getPublic(); privKeyEcdsa = keypair.getPrivate(); - + } - + @Before public void setUp() { signerRsa = DynamoDBSigner.getInstance("SHA256withRSA", Utils.getRng()); @@ -83,15 +81,15 @@ public void setUp() { public void mac() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], macKey); - + signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[0], macKey, ByteBuffer.wrap(signature)); } @@ -99,339 +97,339 @@ public void mac() throws GeneralSecurityException { public void macLists() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withSS("Value1", "Value2", "Value3")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withNS("100", "200", "300")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withBS(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}), - ByteBuffer.wrap(new byte[] { 3, 2, 1}))); + itemAttributes.put("Key3", new AttributeValue().withBS(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}), + ByteBuffer.wrap(new byte[]{3, 2, 1}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], macKey); - + signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[0], macKey, ByteBuffer.wrap(signature)); } - + @Test public void macListsUnsorted() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withSS("Value3", "Value1", "Value2")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withNS("100", "300", "200")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withBS(ByteBuffer.wrap(new byte[] { 3, 2, 1}), - ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withBS(ByteBuffer.wrap(new byte[]{3, 2, 1}), + ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], macKey); - + Map scrambledAttributes = new HashMap(); scrambledAttributes.put("Key1", new AttributeValue().withSS("Value1", "Value2", "Value3")); scrambledAttributes.put("Key2", new AttributeValue().withNS("100", "200", "300")); - scrambledAttributes.put("Key3", new AttributeValue().withBS(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}), - ByteBuffer.wrap(new byte[] { 3, 2, 1}))); + scrambledAttributes.put("Key3", new AttributeValue().withBS(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}), + ByteBuffer.wrap(new byte[]{3, 2, 1}))); signerRsa.verifySignature(scrambledAttributes, attributeFlags, new byte[0], macKey, ByteBuffer.wrap(signature)); } - + @Test public void macNoAdMatchesEmptyAd() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, null, macKey); - + signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[0], macKey, ByteBuffer.wrap(signature)); } - + @Test public void macWithIgnoredChange() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); itemAttributes.put("Key4", new AttributeValue().withS("Ignored Value")); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], macKey); - - + + itemAttributes.put("Key4", new AttributeValue().withS("New Ignored Value")); signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[0], macKey, ByteBuffer.wrap(signature)); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void macChangedValue() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], macKey); - + itemAttributes.get("Key2").setN("99"); signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[0], macKey, ByteBuffer.wrap(signature)); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void macChangedFlag() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], macKey); - + attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN)); signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[0], macKey, ByteBuffer.wrap(signature)); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void macChangedAssociatedData() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); - byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[] {3, 2, 1}, macKey); - - signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[] {1, 2, 3}, macKey, ByteBuffer.wrap(signature)); + byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[]{3, 2, 1}, macKey); + + signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[]{1, 2, 3}, macKey, ByteBuffer.wrap(signature)); } - + @Test public void sig() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], privKeyRsa); - + signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[0], pubKeyRsa, ByteBuffer.wrap(signature)); } - + @Test public void sigWithReadOnlySignature() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], privKeyRsa); - + signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[0], pubKeyRsa, ByteBuffer.wrap(signature).asReadOnlyBuffer()); } - + @Test public void sigNoAdMatchesEmptyAd() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, null, privKeyRsa); - + signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[0], pubKeyRsa, ByteBuffer.wrap(signature)); } - + @Test public void sigWithIgnoredChange() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); itemAttributes.put("Key4", new AttributeValue().withS("Ignored Value")); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], privKeyRsa); - + itemAttributes.put("Key4", new AttributeValue().withS("New Ignored Value")); signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[0], pubKeyRsa, ByteBuffer.wrap(signature)); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void sigChangedValue() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], privKeyRsa); - + itemAttributes.get("Key2").setN("99"); signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[0], pubKeyRsa, ByteBuffer.wrap(signature)); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void sigChangedFlag() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], privKeyRsa); - + attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN)); signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[0], pubKeyRsa, ByteBuffer.wrap(signature)); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void sigChangedAssociatedData() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN, EncryptionFlags.ENCRYPT)); byte[] signature = signerRsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], privKeyRsa); - - signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[] {1, 2, 3}, pubKeyRsa, ByteBuffer.wrap(signature)); + + signerRsa.verifySignature(itemAttributes, attributeFlags, new byte[]{1, 2, 3}, pubKeyRsa, ByteBuffer.wrap(signature)); } - + @Test public void sigEcdsa() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN)); byte[] signature = signerEcdsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], privKeyEcdsa); - + signerEcdsa.verifySignature(itemAttributes, attributeFlags, new byte[0], pubKeyEcdsa, ByteBuffer.wrap(signature)); } - + @Test public void sigEcdsaWithReadOnlySignature() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN)); byte[] signature = signerEcdsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], privKeyEcdsa); - + signerEcdsa.verifySignature(itemAttributes, attributeFlags, new byte[0], pubKeyEcdsa, ByteBuffer.wrap(signature).asReadOnlyBuffer()); } - + @Test public void sigEcdsaNoAdMatchesEmptyAd() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN)); byte[] signature = signerEcdsa.calculateSignature(itemAttributes, attributeFlags, null, privKeyEcdsa); - + signerEcdsa.verifySignature(itemAttributes, attributeFlags, new byte[0], pubKeyEcdsa, ByteBuffer.wrap(signature)); } - + @Test public void sigEcdsaWithIgnoredChange() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key4", new AttributeValue().withS("Ignored Value")); byte[] signature = signerEcdsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], privKeyEcdsa); - + itemAttributes.put("Key4", new AttributeValue().withS("New Ignored Value")); signerEcdsa.verifySignature(itemAttributes, attributeFlags, new byte[0], pubKeyEcdsa, ByteBuffer.wrap(signature)); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void sigEcdsaChangedValue() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN)); byte[] signature = signerEcdsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], privKeyEcdsa); - + itemAttributes.get("Key2").setN("99"); signerEcdsa.verifySignature(itemAttributes, attributeFlags, new byte[0], pubKeyEcdsa, ByteBuffer.wrap(signature)); } - - @Test(expected=SignatureException.class) + + @Test(expected = SignatureException.class) public void sigEcdsaChangedAssociatedData() throws GeneralSecurityException { Map itemAttributes = new HashMap(); Map> attributeFlags = new HashMap>(); - + itemAttributes.put("Key1", new AttributeValue().withS("Value1")); attributeFlags.put("Key1", EnumSet.of(EncryptionFlags.SIGN)); itemAttributes.put("Key2", new AttributeValue().withN("100")); attributeFlags.put("Key2", EnumSet.of(EncryptionFlags.SIGN)); - itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[] { 0, 1, 2, 3}))); + itemAttributes.put("Key3", new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}))); attributeFlags.put("Key3", EnumSet.of(EncryptionFlags.SIGN)); byte[] signature = signerEcdsa.calculateSignature(itemAttributes, attributeFlags, new byte[0], privKeyEcdsa); - - signerEcdsa.verifySignature(itemAttributes, attributeFlags, new byte[] {1, 2, 3}, pubKeyEcdsa, ByteBuffer.wrap(signature)); + + signerEcdsa.verifySignature(itemAttributes, attributeFlags, new byte[]{1, 2, 3}, pubKeyEcdsa, ByteBuffer.wrap(signature)); } } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/materials/AsymmetricRawMaterialsTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/materials/AsymmetricRawMaterialsTest.java index 3420365d..bf735079 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/materials/AsymmetricRawMaterialsTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/materials/AsymmetricRawMaterialsTest.java @@ -14,9 +14,12 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; import java.security.GeneralSecurityException; import java.security.KeyPair; import java.security.KeyPairGenerator; @@ -25,12 +28,8 @@ import java.util.HashMap; import java.util.Map; -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; public class AsymmetricRawMaterialsTest { private static SecureRandom rnd; @@ -38,7 +37,7 @@ public class AsymmetricRawMaterialsTest { private static SecretKey macKey; private static KeyPair sigPair; private Map description; - + @BeforeClass public static void setUpClass() throws NoSuchAlgorithmException { rnd = new SecureRandom(); @@ -46,18 +45,18 @@ public static void setUpClass() throws NoSuchAlgorithmException { rsaGen.initialize(2048, rnd); encryptionPair = rsaGen.generateKeyPair(); sigPair = rsaGen.generateKeyPair(); - + KeyGenerator macGen = KeyGenerator.getInstance("HmacSHA256"); macGen.init(256, rnd); macKey = macGen.generateKey(); } - + @Before public void setUp() { description = new HashMap(); description.put("TestKey", "test value"); } - + @Test public void macNoDescription() throws GeneralSecurityException { AsymmetricRawMaterials matEncryption = new AsymmetricRawMaterials(encryptionPair, macKey); @@ -67,7 +66,7 @@ public void macNoDescription() throws GeneralSecurityException { SecretKey envelopeKey = matEncryption.getEncryptionKey(); assertEquals(envelopeKey, matEncryption.getDecryptionKey()); - + AsymmetricRawMaterials matDecryption = new AsymmetricRawMaterials(encryptionPair, macKey, matEncryption.getMaterialDescription()); assertEquals(macKey, matDecryption.getSigningKey()); assertEquals(macKey, matDecryption.getVerificationKey()); @@ -85,7 +84,7 @@ public void macWithDescription() throws GeneralSecurityException { SecretKey envelopeKey = matEncryption.getEncryptionKey(); assertEquals(envelopeKey, matEncryption.getDecryptionKey()); - + AsymmetricRawMaterials matDecryption = new AsymmetricRawMaterials(encryptionPair, macKey, matEncryption.getMaterialDescription()); assertEquals(macKey, matDecryption.getSigningKey()); assertEquals(macKey, matDecryption.getVerificationKey()); @@ -93,7 +92,7 @@ public void macWithDescription() throws GeneralSecurityException { assertEquals(envelopeKey, matDecryption.getDecryptionKey()); assertEquals("test value", matDecryption.getMaterialDescription().get("TestKey")); } - + @Test public void sigNoDescription() throws GeneralSecurityException { AsymmetricRawMaterials matEncryption = new AsymmetricRawMaterials(encryptionPair, sigPair); @@ -103,7 +102,7 @@ public void sigNoDescription() throws GeneralSecurityException { SecretKey envelopeKey = matEncryption.getEncryptionKey(); assertEquals(envelopeKey, matEncryption.getDecryptionKey()); - + AsymmetricRawMaterials matDecryption = new AsymmetricRawMaterials(encryptionPair, sigPair, matEncryption.getMaterialDescription()); assertEquals(sigPair.getPrivate(), matDecryption.getSigningKey()); assertEquals(sigPair.getPublic(), matDecryption.getVerificationKey()); @@ -121,7 +120,7 @@ public void sigWithDescription() throws GeneralSecurityException { SecretKey envelopeKey = matEncryption.getEncryptionKey(); assertEquals(envelopeKey, matEncryption.getDecryptionKey()); - + AsymmetricRawMaterials matDecryption = new AsymmetricRawMaterials(encryptionPair, sigPair, matEncryption.getMaterialDescription()); assertEquals(sigPair.getPrivate(), matDecryption.getSigningKey()); assertEquals(sigPair.getPublic(), matDecryption.getVerificationKey()); diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/materials/SymmetricRawMaterialsTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/materials/SymmetricRawMaterialsTest.java index e10d8f18..f0792044 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/materials/SymmetricRawMaterialsTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/materials/SymmetricRawMaterialsTest.java @@ -14,9 +14,12 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; @@ -24,12 +27,8 @@ import java.util.HashMap; import java.util.Map; -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class SymmetricRawMaterialsTest { private static SecretKey encryptionKey; @@ -37,29 +36,29 @@ public class SymmetricRawMaterialsTest { private static KeyPair sigPair; private static SecureRandom rnd; private Map description; - + @BeforeClass public static void setUpClass() throws NoSuchAlgorithmException { rnd = new SecureRandom(); KeyPairGenerator rsaGen = KeyPairGenerator.getInstance("RSA"); rsaGen.initialize(2048, rnd); sigPair = rsaGen.generateKeyPair(); - + KeyGenerator aesGen = KeyGenerator.getInstance("AES"); aesGen.init(128, rnd); encryptionKey = aesGen.generateKey(); - + KeyGenerator macGen = KeyGenerator.getInstance("HmacSHA256"); macGen.init(256, rnd); macKey = macGen.generateKey(); } - + @Before public void setUp() { description = new HashMap(); description.put("TestKey", "test value"); } - + @Test public void macNoDescription() throws NoSuchAlgorithmException { SymmetricRawMaterials mat = new SymmetricRawMaterials(encryptionKey, macKey); @@ -69,7 +68,7 @@ public void macNoDescription() throws NoSuchAlgorithmException { assertEquals(macKey, mat.getVerificationKey()); assertTrue(mat.getMaterialDescription().isEmpty()); } - + @Test public void macWithDescription() throws NoSuchAlgorithmException { SymmetricRawMaterials mat = new SymmetricRawMaterials(encryptionKey, macKey, description); @@ -90,7 +89,7 @@ public void sigNoDescription() throws NoSuchAlgorithmException { assertEquals(sigPair.getPublic(), mat.getVerificationKey()); assertTrue(mat.getMaterialDescription().isEmpty()); } - + @Test public void sigWithDescription() throws NoSuchAlgorithmException { SymmetricRawMaterials mat = new SymmetricRawMaterials(encryptionKey, sigPair, description); diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/AsymmetricStaticProviderTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/AsymmetricStaticProviderTest.java index 87c9bd59..6c02b8fe 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/AsymmetricStaticProviderTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/AsymmetricStaticProviderTest.java @@ -14,10 +14,17 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.EncryptionContext; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.DecryptionMaterials; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.WrappedRawMaterials; +import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; import java.security.GeneralSecurityException; import java.security.KeyPair; import java.security.KeyPairGenerator; @@ -25,18 +32,9 @@ import java.util.HashMap; import java.util.Map; -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.EncryptionContext; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.DecryptionMaterials; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.WrappedRawMaterials; -import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; public class AsymmetricStaticProviderTest { private static KeyPair encryptionPair; @@ -44,19 +42,19 @@ public class AsymmetricStaticProviderTest { private static KeyPair sigPair; private Map description; private EncryptionContext ctx; - + @BeforeClass public static void setUpClass() throws Exception { KeyPairGenerator rsaGen = KeyPairGenerator.getInstance("RSA"); rsaGen.initialize(2048, Utils.getRng()); sigPair = rsaGen.generateKeyPair(); encryptionPair = rsaGen.generateKeyPair(); - + KeyGenerator macGen = KeyGenerator.getInstance("HmacSHA256"); macGen.init(256, Utils.getRng()); macKey = macGen.generateKey(); } - + @Before public void setUp() { description = new HashMap(); @@ -67,148 +65,148 @@ public void setUp() { @Test public void simpleMac() throws GeneralSecurityException { - AsymmetricStaticProvider prov = new AsymmetricStaticProvider(encryptionPair, macKey, Collections. emptyMap()); + AsymmetricStaticProvider prov = new AsymmetricStaticProvider(encryptionPair, macKey, Collections.emptyMap()); EncryptionMaterials eMat = prov.getEncryptionMaterials(ctx); SecretKey encryptionKey = eMat.getEncryptionKey(); assertNotNull(encryptionKey); assertEquals(macKey, eMat.getSigningKey()); - + DecryptionMaterials dMat = prov.getDecryptionMaterials(ctx(eMat)); assertEquals(encryptionKey, dMat.getDecryptionKey()); assertEquals(macKey, dMat.getVerificationKey()); } - + @Test public void simpleSig() throws GeneralSecurityException { - AsymmetricStaticProvider prov = new AsymmetricStaticProvider(encryptionPair, sigPair, Collections. emptyMap()); + AsymmetricStaticProvider prov = new AsymmetricStaticProvider(encryptionPair, sigPair, Collections.emptyMap()); EncryptionMaterials eMat = prov.getEncryptionMaterials(ctx); SecretKey encryptionKey = eMat.getEncryptionKey(); assertNotNull(encryptionKey); assertEquals(sigPair.getPrivate(), eMat.getSigningKey()); - + DecryptionMaterials dMat = prov.getDecryptionMaterials(ctx(eMat)); assertEquals(encryptionKey, dMat.getDecryptionKey()); assertEquals(sigPair.getPublic(), dMat.getVerificationKey()); } - + @Test public void randomEnvelopeKeys() throws GeneralSecurityException { - AsymmetricStaticProvider prov = new AsymmetricStaticProvider(encryptionPair, macKey, Collections. emptyMap()); + AsymmetricStaticProvider prov = new AsymmetricStaticProvider(encryptionPair, macKey, Collections.emptyMap()); EncryptionMaterials eMat = prov.getEncryptionMaterials(ctx); SecretKey encryptionKey = eMat.getEncryptionKey(); assertNotNull(encryptionKey); assertEquals(macKey, eMat.getSigningKey()); - + EncryptionMaterials eMat2 = prov.getEncryptionMaterials(ctx); SecretKey encryptionKey2 = eMat2.getEncryptionKey(); assertEquals(macKey, eMat.getSigningKey()); - + assertFalse("Envelope keys must be different", encryptionKey.equals(encryptionKey2)); } - + @Test public void testRefresh() { // This does nothing, make sure we don't throw and exception. AsymmetricStaticProvider prov = new AsymmetricStaticProvider(encryptionPair, macKey, description); prov.refresh(); } - + // Following tests should be moved the WrappedRawMaterialsTests when that is created @Test public void explicitWrappingAlgorithmPkcs1() throws GeneralSecurityException { Map desc = new HashMap(); desc.put(WrappedRawMaterials.KEY_WRAPPING_ALGORITHM, "RSA/ECB/PKCS1Padding"); - + AsymmetricStaticProvider prov = new AsymmetricStaticProvider(encryptionPair, sigPair, desc); - + EncryptionMaterials eMat = prov.getEncryptionMaterials(ctx); SecretKey encryptionKey = eMat.getEncryptionKey(); assertNotNull(encryptionKey); assertEquals(sigPair.getPrivate(), eMat.getSigningKey()); - + DecryptionMaterials dMat = prov.getDecryptionMaterials(ctx(eMat)); assertEquals("RSA/ECB/PKCS1Padding", eMat.getMaterialDescription().get(WrappedRawMaterials.KEY_WRAPPING_ALGORITHM)); assertEquals(encryptionKey, dMat.getDecryptionKey()); assertEquals(sigPair.getPublic(), dMat.getVerificationKey()); } - + @Test public void explicitWrappingAlgorithmPkcs2() throws GeneralSecurityException { Map desc = new HashMap(); desc.put(WrappedRawMaterials.KEY_WRAPPING_ALGORITHM, "RSA/ECB/OAEPWithSHA-256AndMGF1Padding"); - + AsymmetricStaticProvider prov = new AsymmetricStaticProvider(encryptionPair, sigPair, desc); - + EncryptionMaterials eMat = prov.getEncryptionMaterials(ctx); SecretKey encryptionKey = eMat.getEncryptionKey(); assertNotNull(encryptionKey); assertEquals(sigPair.getPrivate(), eMat.getSigningKey()); - + DecryptionMaterials dMat = prov.getDecryptionMaterials(ctx(eMat)); assertEquals("RSA/ECB/OAEPWithSHA-256AndMGF1Padding", eMat.getMaterialDescription().get(WrappedRawMaterials.KEY_WRAPPING_ALGORITHM)); assertEquals(encryptionKey, dMat.getDecryptionKey()); assertEquals(sigPair.getPublic(), dMat.getVerificationKey()); } - + @Test public void explicitContentKeyAlgorithm() throws GeneralSecurityException { Map desc = new HashMap(); desc.put(WrappedRawMaterials.CONTENT_KEY_ALGORITHM, "AES"); - + AsymmetricStaticProvider prov = new AsymmetricStaticProvider(encryptionPair, sigPair, desc); - + EncryptionMaterials eMat = prov.getEncryptionMaterials(ctx); SecretKey encryptionKey = eMat.getEncryptionKey(); assertNotNull(encryptionKey); assertEquals(sigPair.getPrivate(), eMat.getSigningKey()); - + DecryptionMaterials dMat = prov.getDecryptionMaterials(ctx(eMat)); assertEquals("AES", eMat.getMaterialDescription().get(WrappedRawMaterials.CONTENT_KEY_ALGORITHM)); assertEquals(encryptionKey, dMat.getDecryptionKey()); assertEquals(sigPair.getPublic(), dMat.getVerificationKey()); } - + @Test public void explicitContentKeyLength128() throws GeneralSecurityException { Map desc = new HashMap(); desc.put(WrappedRawMaterials.CONTENT_KEY_ALGORITHM, "AES/128"); - + AsymmetricStaticProvider prov = new AsymmetricStaticProvider(encryptionPair, sigPair, desc); - + EncryptionMaterials eMat = prov.getEncryptionMaterials(ctx); SecretKey encryptionKey = eMat.getEncryptionKey(); assertNotNull(encryptionKey); assertEquals(16, encryptionKey.getEncoded().length); // 128 Bits assertEquals(sigPair.getPrivate(), eMat.getSigningKey()); - + DecryptionMaterials dMat = prov.getDecryptionMaterials(ctx(eMat)); assertEquals("AES", eMat.getMaterialDescription().get(WrappedRawMaterials.CONTENT_KEY_ALGORITHM)); assertEquals(encryptionKey, dMat.getDecryptionKey()); assertEquals(sigPair.getPublic(), dMat.getVerificationKey()); } - + @Test public void explicitContentKeyLength256() throws GeneralSecurityException { Map desc = new HashMap(); desc.put(WrappedRawMaterials.CONTENT_KEY_ALGORITHM, "AES/256"); - + AsymmetricStaticProvider prov = new AsymmetricStaticProvider(encryptionPair, sigPair, desc); - + EncryptionMaterials eMat = prov.getEncryptionMaterials(ctx); SecretKey encryptionKey = eMat.getEncryptionKey(); assertNotNull(encryptionKey); assertEquals(32, encryptionKey.getEncoded().length); // 256 Bits assertEquals(sigPair.getPrivate(), eMat.getSigningKey()); - + DecryptionMaterials dMat = prov.getDecryptionMaterials(ctx(eMat)); assertEquals("AES", eMat.getMaterialDescription().get(WrappedRawMaterials.CONTENT_KEY_ALGORITHM)); assertEquals(encryptionKey, dMat.getDecryptionKey()); assertEquals(sigPair.getPublic(), dMat.getVerificationKey()); } - + private static EncryptionContext ctx(EncryptionMaterials mat) { return new EncryptionContext.Builder() .withMaterialDescription(mat.getMaterialDescription()).build(); diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/DirectKmsMaterialProviderTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/DirectKmsMaterialProviderTest.java index 26016567..98df75dc 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/DirectKmsMaterialProviderTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/DirectKmsMaterialProviderTest.java @@ -1,25 +1,32 @@ /* * Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers; -import static com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.WrappedRawMaterials.CONTENT_KEY_ALGORITHM; -import static com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.WrappedRawMaterials.ENVELOPE_KEY; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.EncryptionContext; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.DecryptionMaterials; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.WrappedRawMaterials; +import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import com.amazonaws.services.dynamodbv2.testing.FakeKMS; +import com.amazonaws.services.kms.AWSKMS; +import com.amazonaws.services.kms.model.GenerateDataKeyRequest; +import com.amazonaws.services.kms.model.GenerateDataKeyResult; +import com.amazonaws.util.Base64; +import org.junit.Before; +import org.junit.Test; +import javax.crypto.SecretKey; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; @@ -29,25 +36,11 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; -import javax.crypto.SecretKey; - -import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException; -import com.amazonaws.services.kms.AWSKMS; -import com.amazonaws.services.kms.AbstractAWSKMS; -import com.amazonaws.services.kms.model.DecryptRequest; -import com.amazonaws.services.kms.model.DecryptResult; -import com.amazonaws.services.kms.model.GenerateDataKeyRequest; -import com.amazonaws.services.kms.model.GenerateDataKeyResult; -import org.junit.Before; -import org.junit.Test; - -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.EncryptionContext; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.DecryptionMaterials; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.WrappedRawMaterials; -import com.amazonaws.services.dynamodbv2.model.AttributeValue; -import com.amazonaws.services.dynamodbv2.testing.FakeKMS; -import com.amazonaws.util.Base64; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class DirectKmsMaterialProviderTest { private FakeKMS kms; @@ -329,7 +322,8 @@ public void missingEncryptionKeyId() throws GeneralSecurityException { public void generateDataKeyIsCalledWith256NumberOfBits() { final AtomicBoolean gdkCalled = new AtomicBoolean(false); AWSKMS kmsSpy = new FakeKMS() { - @Override public GenerateDataKeyResult generateDataKey(GenerateDataKeyRequest r) { + @Override + public GenerateDataKeyResult generateDataKey(GenerateDataKeyRequest r) { gdkCalled.set(true); assertEquals((Integer) 32, r.getNumberOfBytes()); assertNull(r.getKeySpec()); diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/KeyStoreMaterialsProviderTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/KeyStoreMaterialsProviderTest.java index 02df87b4..b07788b8 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/KeyStoreMaterialsProviderTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/KeyStoreMaterialsProviderTest.java @@ -14,11 +14,17 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.EncryptionContext; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.DecryptionMaterials; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; +import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; +import com.amazonaws.util.Base64; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; import java.io.ByteArrayInputStream; import java.security.KeyFactory; import java.security.KeyStore; @@ -33,105 +39,97 @@ import java.util.HashMap; import java.util.Map; -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.EncryptionContext; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.DecryptionMaterials; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; -import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; -import com.amazonaws.util.Base64; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; public class KeyStoreMaterialsProviderTest { - private static final String certPem = - "MIIDbTCCAlWgAwIBAgIJANdRvzVsW1CIMA0GCSqGSIb3DQEBBQUAME0xCzAJBgNV" + - "BAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMQwwCgYDVQQKDANBV1MxGzAZBgNV" + - "BAMMEktleVN0b3JlIFRlc3QgQ2VydDAeFw0xMzA1MDgyMzMyMjBaFw0xMzA2MDcy" + - "MzMyMjBaME0xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMQwwCgYD" + - "VQQKDANBV1MxGzAZBgNVBAMMEktleVN0b3JlIFRlc3QgQ2VydDCCASIwDQYJKoZI" + - "hvcNAQEBBQADggEPADCCAQoCggEBAJ8+umOX8x/Ma4OZishtYpcA676bwK5KScf3" + - "w+YGM37L12KTdnOyieiGtRW8p0fS0YvnhmVTvaky09I33bH+qy9gliuNL2QkyMxp" + - "uu1IwkTKKuB67CaKT6osYJLFxV/OwHcaZnTszzDgbAVg/Z+8IZxhPgxMzMa+7nDn" + - "hEm9Jd+EONq3PnRagnFeLNbMIePprdJzXHyNNiZKRRGQ/Mo9rr7mqMLSKnFNsmzB" + - "OIfeZM8nXeg+cvlmtXl72obwnGGw2ksJfaxTPm4eEhzRoAgkbjPPLHbwiJlc+GwF" + - "i8kh0Y3vQTj/gOFE4nzipkm7ux1lsGHNRVpVDWpjNd8Fl9JFELkCAwEAAaNQME4w" + - "HQYDVR0OBBYEFM0oGUuFAWlLXZaMXoJgGZxWqfOxMB8GA1UdIwQYMBaAFM0oGUuF" + - "AWlLXZaMXoJgGZxWqfOxMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB" + - "AAXCsXeC8ZRxovP0Wc6C5qv3d7dtgJJVzHwoIRt2YR3yScBa1XI40GKT80jP3MYH" + - "8xMu3mBQtcYrgRKZBy4GpHAyxoFTnPcuzq5Fg7dw7fx4E4OKIbWOahdxwtbVxQfZ" + - "UHnGG88Z0bq2twj7dALGyJhUDdiccckJGmJPOFMzjqsvoAu0n/p7eS6y5WZ5ewqw" + - "p7VwYOP3N9wVV7Podmkh1os+eCcp9GoFf0MHBMFXi2Ps2azKx8wHRIA5D1MZv/Va" + - "4L4/oTBKCjORpFlP7EhMksHBYnjqXLDP6awPMAgQNYB5J9zX6GfJsAgly3t4Rjr5" + - "cLuNYBmRuByFGo+SOdrj6D8="; - private static final String keyPem = - "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCfPrpjl/MfzGuD" + - "mYrIbWKXAOu+m8CuSknH98PmBjN+y9dik3ZzsonohrUVvKdH0tGL54ZlU72pMtPS" + - "N92x/qsvYJYrjS9kJMjMabrtSMJEyirgeuwmik+qLGCSxcVfzsB3GmZ07M8w4GwF" + - "YP2fvCGcYT4MTMzGvu5w54RJvSXfhDjatz50WoJxXizWzCHj6a3Sc1x8jTYmSkUR" + - "kPzKPa6+5qjC0ipxTbJswTiH3mTPJ13oPnL5ZrV5e9qG8JxhsNpLCX2sUz5uHhIc" + - "0aAIJG4zzyx28IiZXPhsBYvJIdGN70E4/4DhROJ84qZJu7sdZbBhzUVaVQ1qYzXf" + - "BZfSRRC5AgMBAAECggEBAJMwx9eGe5LIwBfDtCPN93LbxwtHq7FtuQS8XrYexTpN" + - "76eN5c7LF+11lauh1HzuwAEw32iJHqVl9aQ5PxFm85O3ExbuSP+ngHJwx/bLacVr" + - "mHYlKGH3Net1WU5Qvz7vO7bbEBjDSj9DMJVIMSWUHv0MZO25jw2lLX/ufrgpvPf7" + - "KXSgXg/8uV7PbnTbBDNlg02u8eOc+IbH4O8XDKAhD+YQ8AE3pxtopJbb912U/cJs" + - "Y0hQ01zbkWYH7wL9BeQmR7+TEjjtr/IInNjnXmaOmSX867/rTSTuozaVrl1Ce7r8" + - "EmUDg9ZLZeKfoNYovMy08wnxWVX2J+WnNDjNiSOm+IECgYEA0v3jtGrOnKbd0d9E" + - "dbyIuhjgnwp+UsgALIiBeJYjhFS9NcWgs+02q/0ztqOK7g088KBBQOmiA+frLIVb" + - "uNCt/3jF6kJvHYkHMZ0eBEstxjVSM2UcxzJ6ceHZ68pmrru74382TewVosxccNy0" + - "glsUWNN0t5KQDcetaycRYg50MmcCgYEAwTb8klpNyQE8AWxVQlbOIEV24iarXxex" + - "7HynIg9lSeTzquZOXjp0m5omQ04psil2gZ08xjiudG+Dm7QKgYQcxQYUtZPQe15K" + - "m+2hQM0jA7tRfM1NAZHoTmUlYhzRNX6GWAqQXOgjOqBocT4ySBXRaSQq9zuZu36s" + - "fI17knap798CgYArDa2yOf0xEAfBdJqmn7MSrlLfgSenwrHuZGhu78wNi7EUUOBq" + - "9qOqUr+DrDmEO+VMgJbwJPxvaZqeehPuUX6/26gfFjFQSI7UO+hNHf4YLPc6D47g" + - "wtcjd9+c8q8jRqGfWWz+V4dOsf7G9PJMi0NKoNN3RgvpE+66J72vUZ26TwKBgEUq" + - "DdfGA7pEetp3kT2iHT9oHlpuRUJRFRv2s015/WQqVR+EOeF5Q2zADZpiTIK+XPGg" + - "+7Rpbem4UYBXPruGM1ZECv3E4AiJhGO0+Nhdln8reswWIc7CEEqf4nXwouNnW2gA" + - "wBTB9Hp0GW8QOKedR80/aTH/X9TCT7R2YRnY6JQ5AoGBAKjgPySgrNDhlJkW7jXR" + - "WiGpjGSAFPT9NMTvEHDo7oLTQ8AcYzcGQ7ISMRdVXR6GJOlFVsH4NLwuHGtcMTPK" + - "zoHbPHJyOn1SgC5tARD/1vm5CsG2hATRpWRQCTJFg5VRJ4R7Pz+HuxY4SoABcPQd" + - "K+MP8GlGqTldC6NaB1s7KuAX"; - + private static final String certPem = + "MIIDbTCCAlWgAwIBAgIJANdRvzVsW1CIMA0GCSqGSIb3DQEBBQUAME0xCzAJBgNV" + + "BAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMQwwCgYDVQQKDANBV1MxGzAZBgNV" + + "BAMMEktleVN0b3JlIFRlc3QgQ2VydDAeFw0xMzA1MDgyMzMyMjBaFw0xMzA2MDcy" + + "MzMyMjBaME0xCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMQwwCgYD" + + "VQQKDANBV1MxGzAZBgNVBAMMEktleVN0b3JlIFRlc3QgQ2VydDCCASIwDQYJKoZI" + + "hvcNAQEBBQADggEPADCCAQoCggEBAJ8+umOX8x/Ma4OZishtYpcA676bwK5KScf3" + + "w+YGM37L12KTdnOyieiGtRW8p0fS0YvnhmVTvaky09I33bH+qy9gliuNL2QkyMxp" + + "uu1IwkTKKuB67CaKT6osYJLFxV/OwHcaZnTszzDgbAVg/Z+8IZxhPgxMzMa+7nDn" + + "hEm9Jd+EONq3PnRagnFeLNbMIePprdJzXHyNNiZKRRGQ/Mo9rr7mqMLSKnFNsmzB" + + "OIfeZM8nXeg+cvlmtXl72obwnGGw2ksJfaxTPm4eEhzRoAgkbjPPLHbwiJlc+GwF" + + "i8kh0Y3vQTj/gOFE4nzipkm7ux1lsGHNRVpVDWpjNd8Fl9JFELkCAwEAAaNQME4w" + + "HQYDVR0OBBYEFM0oGUuFAWlLXZaMXoJgGZxWqfOxMB8GA1UdIwQYMBaAFM0oGUuF" + + "AWlLXZaMXoJgGZxWqfOxMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB" + + "AAXCsXeC8ZRxovP0Wc6C5qv3d7dtgJJVzHwoIRt2YR3yScBa1XI40GKT80jP3MYH" + + "8xMu3mBQtcYrgRKZBy4GpHAyxoFTnPcuzq5Fg7dw7fx4E4OKIbWOahdxwtbVxQfZ" + + "UHnGG88Z0bq2twj7dALGyJhUDdiccckJGmJPOFMzjqsvoAu0n/p7eS6y5WZ5ewqw" + + "p7VwYOP3N9wVV7Podmkh1os+eCcp9GoFf0MHBMFXi2Ps2azKx8wHRIA5D1MZv/Va" + + "4L4/oTBKCjORpFlP7EhMksHBYnjqXLDP6awPMAgQNYB5J9zX6GfJsAgly3t4Rjr5" + + "cLuNYBmRuByFGo+SOdrj6D8="; + private static final String keyPem = + "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCfPrpjl/MfzGuD" + + "mYrIbWKXAOu+m8CuSknH98PmBjN+y9dik3ZzsonohrUVvKdH0tGL54ZlU72pMtPS" + + "N92x/qsvYJYrjS9kJMjMabrtSMJEyirgeuwmik+qLGCSxcVfzsB3GmZ07M8w4GwF" + + "YP2fvCGcYT4MTMzGvu5w54RJvSXfhDjatz50WoJxXizWzCHj6a3Sc1x8jTYmSkUR" + + "kPzKPa6+5qjC0ipxTbJswTiH3mTPJ13oPnL5ZrV5e9qG8JxhsNpLCX2sUz5uHhIc" + + "0aAIJG4zzyx28IiZXPhsBYvJIdGN70E4/4DhROJ84qZJu7sdZbBhzUVaVQ1qYzXf" + + "BZfSRRC5AgMBAAECggEBAJMwx9eGe5LIwBfDtCPN93LbxwtHq7FtuQS8XrYexTpN" + + "76eN5c7LF+11lauh1HzuwAEw32iJHqVl9aQ5PxFm85O3ExbuSP+ngHJwx/bLacVr" + + "mHYlKGH3Net1WU5Qvz7vO7bbEBjDSj9DMJVIMSWUHv0MZO25jw2lLX/ufrgpvPf7" + + "KXSgXg/8uV7PbnTbBDNlg02u8eOc+IbH4O8XDKAhD+YQ8AE3pxtopJbb912U/cJs" + + "Y0hQ01zbkWYH7wL9BeQmR7+TEjjtr/IInNjnXmaOmSX867/rTSTuozaVrl1Ce7r8" + + "EmUDg9ZLZeKfoNYovMy08wnxWVX2J+WnNDjNiSOm+IECgYEA0v3jtGrOnKbd0d9E" + + "dbyIuhjgnwp+UsgALIiBeJYjhFS9NcWgs+02q/0ztqOK7g088KBBQOmiA+frLIVb" + + "uNCt/3jF6kJvHYkHMZ0eBEstxjVSM2UcxzJ6ceHZ68pmrru74382TewVosxccNy0" + + "glsUWNN0t5KQDcetaycRYg50MmcCgYEAwTb8klpNyQE8AWxVQlbOIEV24iarXxex" + + "7HynIg9lSeTzquZOXjp0m5omQ04psil2gZ08xjiudG+Dm7QKgYQcxQYUtZPQe15K" + + "m+2hQM0jA7tRfM1NAZHoTmUlYhzRNX6GWAqQXOgjOqBocT4ySBXRaSQq9zuZu36s" + + "fI17knap798CgYArDa2yOf0xEAfBdJqmn7MSrlLfgSenwrHuZGhu78wNi7EUUOBq" + + "9qOqUr+DrDmEO+VMgJbwJPxvaZqeehPuUX6/26gfFjFQSI7UO+hNHf4YLPc6D47g" + + "wtcjd9+c8q8jRqGfWWz+V4dOsf7G9PJMi0NKoNN3RgvpE+66J72vUZ26TwKBgEUq" + + "DdfGA7pEetp3kT2iHT9oHlpuRUJRFRv2s015/WQqVR+EOeF5Q2zADZpiTIK+XPGg" + + "+7Rpbem4UYBXPruGM1ZECv3E4AiJhGO0+Nhdln8reswWIc7CEEqf4nXwouNnW2gA" + + "wBTB9Hp0GW8QOKedR80/aTH/X9TCT7R2YRnY6JQ5AoGBAKjgPySgrNDhlJkW7jXR" + + "WiGpjGSAFPT9NMTvEHDo7oLTQ8AcYzcGQ7ISMRdVXR6GJOlFVsH4NLwuHGtcMTPK" + + "zoHbPHJyOn1SgC5tARD/1vm5CsG2hATRpWRQCTJFg5VRJ4R7Pz+HuxY4SoABcPQd" + + "K+MP8GlGqTldC6NaB1s7KuAX"; + private static SecretKey encryptionKey; private static SecretKey macKey; private static KeyStore keyStore; private static final String password = "Password"; private static final PasswordProtection passwordProtection = new PasswordProtection(password.toCharArray()); - + private Map description; private EncryptionContext ctx; private static PrivateKey privateKey; private static Certificate certificate; - + @BeforeClass public static void setUpBeforeClass() throws Exception { - + KeyGenerator macGen = KeyGenerator.getInstance("HmacSHA256"); macGen.init(256, Utils.getRng()); macKey = macGen.generateKey(); - + KeyGenerator aesGen = KeyGenerator.getInstance("AES"); aesGen.init(128, Utils.getRng()); encryptionKey = aesGen.generateKey(); - + keyStore = KeyStore.getInstance("jceks"); keyStore.load(null, password.toCharArray()); - + KeyFactory kf = KeyFactory.getInstance("RSA"); PKCS8EncodedKeySpec rsaSpec = new PKCS8EncodedKeySpec(Base64.decode(keyPem)); privateKey = kf.generatePrivate(rsaSpec); CertificateFactory cf = CertificateFactory.getInstance("X509"); certificate = cf.generateCertificate(new ByteArrayInputStream(Base64.decode(certPem))); - - + + keyStore.setEntry("enc", new SecretKeyEntry(encryptionKey), passwordProtection); keyStore.setEntry("sig", new SecretKeyEntry(macKey), passwordProtection); - keyStore.setEntry("enc-a", new PrivateKeyEntry(privateKey, new Certificate[] {certificate}), passwordProtection); - keyStore.setEntry("sig-a", new PrivateKeyEntry(privateKey, new Certificate[] {certificate}), passwordProtection); + keyStore.setEntry("enc-a", new PrivateKeyEntry(privateKey, new Certificate[]{certificate}), passwordProtection); + keyStore.setEntry("sig-a", new PrivateKeyEntry(privateKey, new Certificate[]{certificate}), passwordProtection); keyStore.setCertificateEntry("trustedCert", certificate); } @@ -150,11 +148,11 @@ public void simpleSymMac() throws Exception { EncryptionMaterials encryptionMaterials = prov.getEncryptionMaterials(ctx); assertEquals(encryptionKey, encryptionMaterials.getEncryptionKey()); assertEquals(macKey, encryptionMaterials.getSigningKey()); - + assertEquals(encryptionKey, prov.getDecryptionMaterials(ctx(encryptionMaterials)).getDecryptionKey()); assertEquals(macKey, prov.getDecryptionMaterials(ctx(encryptionMaterials)).getVerificationKey()); } - + @Test @SuppressWarnings("unchecked") public void simpleSymSig() throws Exception { @@ -162,7 +160,7 @@ public void simpleSymSig() throws Exception { EncryptionMaterials encryptionMaterials = prov.getEncryptionMaterials(ctx); assertEquals(encryptionKey, encryptionMaterials.getEncryptionKey()); assertEquals(privateKey, encryptionMaterials.getSigningKey()); - + assertEquals(encryptionKey, prov.getDecryptionMaterials(ctx(encryptionMaterials)).getDecryptionKey()); assertEquals(certificate.getPublicKey(), prov.getDecryptionMaterials(ctx(encryptionMaterials)).getVerificationKey()); } @@ -173,11 +171,11 @@ public void equalSymDescMac() throws Exception { EncryptionMaterials encryptionMaterials = prov.getEncryptionMaterials(ctx); assertEquals(encryptionKey, encryptionMaterials.getEncryptionKey()); assertEquals(macKey, encryptionMaterials.getSigningKey()); - + assertEquals(encryptionKey, prov.getDecryptionMaterials(ctx(encryptionMaterials)).getDecryptionKey()); assertEquals(macKey, prov.getDecryptionMaterials(ctx(encryptionMaterials)).getVerificationKey()); } - + @Test public void superSetSymDescMac() throws Exception { KeyStoreMaterialsProvider prov = new KeyStoreMaterialsProvider(keyStore, "enc", "sig", passwordProtection, passwordProtection, description); @@ -186,11 +184,11 @@ public void superSetSymDescMac() throws Exception { assertEquals(macKey, encryptionMaterials.getSigningKey()); Map tmpDesc = new HashMap(encryptionMaterials.getMaterialDescription()); tmpDesc.put("randomValue", "random"); - + assertEquals(encryptionKey, prov.getDecryptionMaterials(ctx(tmpDesc)).getDecryptionKey()); assertEquals(macKey, prov.getDecryptionMaterials(ctx(tmpDesc)).getVerificationKey()); } - + @Test @SuppressWarnings("unchecked") public void subSetSymDescMac() throws Exception { @@ -198,11 +196,11 @@ public void subSetSymDescMac() throws Exception { EncryptionMaterials encryptionMaterials = prov.getEncryptionMaterials(ctx); assertEquals(encryptionKey, encryptionMaterials.getEncryptionKey()); assertEquals(macKey, encryptionMaterials.getSigningKey()); - + assertNull(prov.getDecryptionMaterials(ctx(Collections.EMPTY_MAP))); } - - + + @Test public void noMatchSymDescMac() throws Exception { KeyStoreMaterialsProvider prov = new KeyStoreMaterialsProvider(keyStore, "enc", "sig", passwordProtection, passwordProtection, description); @@ -211,17 +209,17 @@ public void noMatchSymDescMac() throws Exception { assertEquals(macKey, encryptionMaterials.getSigningKey()); Map tmpDesc = new HashMap(); tmpDesc.put("randomValue", "random"); - + assertNull(prov.getDecryptionMaterials(ctx(tmpDesc))); } - + @Test public void testRefresh() throws Exception { // Mostly make sure we don't throw an exception KeyStoreMaterialsProvider prov = new KeyStoreMaterialsProvider(keyStore, "enc", "sig", passwordProtection, passwordProtection, description); prov.refresh(); } - + @Test public void asymSimpleMac() throws Exception { KeyStoreMaterialsProvider prov = new KeyStoreMaterialsProvider(keyStore, "enc-a", "sig", passwordProtection, passwordProtection, description); @@ -229,12 +227,12 @@ public void asymSimpleMac() throws Exception { SecretKey encryptionKey = eMat.getEncryptionKey(); assertNotNull(encryptionKey); assertEquals(macKey, eMat.getSigningKey()); - + DecryptionMaterials dMat = prov.getDecryptionMaterials(ctx(eMat)); assertEquals(encryptionKey, dMat.getDecryptionKey()); assertEquals(macKey, dMat.getVerificationKey()); } - + @Test public void asymSimpleSig() throws Exception { KeyStoreMaterialsProvider prov = new KeyStoreMaterialsProvider(keyStore, "enc-a", "sig-a", passwordProtection, passwordProtection, description); @@ -242,12 +240,12 @@ public void asymSimpleSig() throws Exception { SecretKey encryptionKey = eMat.getEncryptionKey(); assertNotNull(encryptionKey); assertEquals(privateKey, eMat.getSigningKey()); - + DecryptionMaterials dMat = prov.getDecryptionMaterials(ctx(eMat)); assertEquals(encryptionKey, dMat.getDecryptionKey()); assertEquals(certificate.getPublicKey(), dMat.getVerificationKey()); } - + @Test public void asymSigVerifyOnly() throws Exception { KeyStoreMaterialsProvider prov = new KeyStoreMaterialsProvider(keyStore, "enc-a", "trustedCert", passwordProtection, null, description); @@ -255,12 +253,12 @@ public void asymSigVerifyOnly() throws Exception { SecretKey encryptionKey = eMat.getEncryptionKey(); assertNotNull(encryptionKey); assertNull(eMat.getSigningKey()); - + DecryptionMaterials dMat = prov.getDecryptionMaterials(ctx(eMat)); assertEquals(encryptionKey, dMat.getDecryptionKey()); assertEquals(certificate.getPublicKey(), dMat.getVerificationKey()); } - + @Test public void asymSigEncryptOnly() throws Exception { KeyStoreMaterialsProvider prov = new KeyStoreMaterialsProvider(keyStore, "trustedCert", "sig-a", null, passwordProtection, description); @@ -268,7 +266,7 @@ public void asymSigEncryptOnly() throws Exception { SecretKey encryptionKey = eMat.getEncryptionKey(); assertNotNull(encryptionKey); assertEquals(privateKey, eMat.getSigningKey()); - + try { prov.getDecryptionMaterials(ctx(eMat)); fail("Expected exception"); @@ -276,11 +274,11 @@ public void asymSigEncryptOnly() throws Exception { assertEquals("No private decryption key provided.", ex.getMessage()); } } - + private static EncryptionContext ctx(EncryptionMaterials mat) { return ctx(mat.getMaterialDescription()); } - + private static EncryptionContext ctx(Map desc) { return new EncryptionContext.Builder() .withMaterialDescription(desc).build(); diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/MostRecentProviderTests.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/MostRecentProviderTests.java index 2ebe2fed..b7b3c136 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/MostRecentProviderTests.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/MostRecentProviderTests.java @@ -1,58 +1,53 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; - -import org.junit.Before; -import org.junit.Test; - -import com.amazonaws.services.dynamodbv2.local.embedded.DynamoDBEmbedded; import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DynamoDBEncryptor; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.EncryptionContext; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.DecryptionMaterials; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.EncryptionMaterialsProvider; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.MostRecentProvider; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.SymmetricStaticProvider; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.store.MetaStore; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.store.ProviderStore; +import com.amazonaws.services.dynamodbv2.local.embedded.DynamoDBEmbedded; import com.amazonaws.services.dynamodbv2.model.AttributeValue; import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; +import org.junit.Before; +import org.junit.Test; + +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class MostRecentProviderTests { private static final String TABLE_NAME = "keystoreTable"; private static final String MATERIAL_NAME = "material"; private static final String MATERIAL_PARAM = "materialName"; - private static final SecretKey AES_KEY = new SecretKeySpec(new byte[] { 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, "AES"); - private static final SecretKey HMAC_KEY = new SecretKeySpec(new byte[] { 0, - 1, 2, 3, 4, 5, 6, 7 }, "HmacSHA256"); + private static final SecretKey AES_KEY = new SecretKeySpec(new byte[]{0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, "AES"); + private static final SecretKey HMAC_KEY = new SecretKeySpec(new byte[]{0, + 1, 2, 3, 4, 5, 6, 7}, "HmacSHA256"); private static final EncryptionMaterialsProvider BASE_PROVIDER = new SymmetricStaticProvider(AES_KEY, HMAC_KEY); private static final DynamoDBEncryptor ENCRYPTOR = DynamoDBEncryptor.getInstance(BASE_PROVIDER); @@ -500,18 +495,18 @@ public void twoVersionsWithTwoMaterialsWithRefresh() throws InterruptedException private static EncryptionContext ctx(final Map attr) { return new EncryptionContext.Builder() - .withAttributeValues(attr).build(); + .withAttributeValues(attr).build(); } private static EncryptionContext ctx(final EncryptionMaterials mat, Map attr) { return new EncryptionContext.Builder() - .withAttributeValues(attr) - .withMaterialDescription(mat.getMaterialDescription()).build(); + .withAttributeValues(attr) + .withMaterialDescription(mat.getMaterialDescription()).build(); } private static EncryptionContext ctx(final EncryptionMaterials mat) { return new EncryptionContext.Builder() - .withMaterialDescription(mat.getMaterialDescription()).build(); + .withMaterialDescription(mat.getMaterialDescription()).build(); } private static class ExtendedProvider extends MostRecentProvider { @@ -532,27 +527,27 @@ protected String getMaterialName(final EncryptionContext context) { @SuppressWarnings("unchecked") private static T instrument(final T obj, final Class clazz, final Map map) { - return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[] { clazz }, + return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz}, new InvocationHandler() { - private final Object lock = new Object(); - - @Override - public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { - synchronized (lock) { - try { - final Integer oldCount = map.get(method.getName()); - if (oldCount != null) { - map.put(method.getName(), oldCount + 1); - } else { - map.put(method.getName(), 1); + private final Object lock = new Object(); + + @Override + public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { + synchronized (lock) { + try { + final Integer oldCount = map.get(method.getName()); + if (oldCount != null) { + map.put(method.getName(), oldCount + 1); + } else { + map.put(method.getName(), 1); + } + return method.invoke(obj, args); + } catch (final InvocationTargetException ex) { + throw ex.getCause(); + } } - return method.invoke(obj, args); - } catch (final InvocationTargetException ex) { - throw ex.getCause(); } } - } - } - ); + ); } } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/SymmetricStaticProviderTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/SymmetricStaticProviderTest.java index 044a6daf..a85f8a06 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/SymmetricStaticProviderTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/SymmetricStaticProviderTest.java @@ -14,26 +14,24 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.EncryptionContext; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; +import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.EncryptionContext; -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; -import com.amazonaws.services.dynamodbv2.datamodeling.internal.Utils; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class SymmetricStaticProviderTest { private static SecretKey encryptionKey; @@ -41,22 +39,22 @@ public class SymmetricStaticProviderTest { private static KeyPair sigPair; private Map description; private EncryptionContext ctx; - + @BeforeClass public static void setUpClass() throws Exception { KeyPairGenerator rsaGen = KeyPairGenerator.getInstance("RSA"); rsaGen.initialize(2048, Utils.getRng()); sigPair = rsaGen.generateKeyPair(); - + KeyGenerator macGen = KeyGenerator.getInstance("HmacSHA256"); macGen.init(256, Utils.getRng()); macKey = macGen.generateKey(); - + KeyGenerator aesGen = KeyGenerator.getInstance("AES"); aesGen.init(128, Utils.getRng()); encryptionKey = aesGen.generateKey(); } - + @Before public void setUp() { description = new HashMap(); @@ -68,44 +66,44 @@ public void setUp() { @Test public void simpleMac() { SymmetricStaticProvider prov = new SymmetricStaticProvider( - encryptionKey, macKey, Collections. emptyMap()); + encryptionKey, macKey, Collections.emptyMap()); assertEquals(encryptionKey, prov.getEncryptionMaterials(ctx).getEncryptionKey()); assertEquals(macKey, prov.getEncryptionMaterials(ctx).getSigningKey()); - + assertEquals( - encryptionKey, - prov.getDecryptionMaterials(ctx(Collections. emptyMap())) - .getDecryptionKey()); + encryptionKey, + prov.getDecryptionMaterials(ctx(Collections.emptyMap())) + .getDecryptionKey()); assertEquals( - macKey, - prov.getDecryptionMaterials(ctx(Collections. emptyMap())) - .getVerificationKey()); + macKey, + prov.getDecryptionMaterials(ctx(Collections.emptyMap())) + .getVerificationKey()); } @Test public void simpleSig() { - SymmetricStaticProvider prov = new SymmetricStaticProvider(encryptionKey, sigPair, Collections. emptyMap()); + SymmetricStaticProvider prov = new SymmetricStaticProvider(encryptionKey, sigPair, Collections.emptyMap()); assertEquals(encryptionKey, prov.getEncryptionMaterials(ctx).getEncryptionKey()); assertEquals(sigPair.getPrivate(), prov.getEncryptionMaterials(ctx).getSigningKey()); - - assertEquals(encryptionKey, prov.getDecryptionMaterials(ctx(Collections. emptyMap())).getDecryptionKey()); + + assertEquals(encryptionKey, prov.getDecryptionMaterials(ctx(Collections.emptyMap())).getDecryptionKey()); assertEquals( - sigPair.getPublic(), - prov.getDecryptionMaterials(ctx(Collections. emptyMap())) - .getVerificationKey()); + sigPair.getPublic(), + prov.getDecryptionMaterials(ctx(Collections.emptyMap())) + .getVerificationKey()); } - + @Test public void equalDescMac() { - + SymmetricStaticProvider prov = new SymmetricStaticProvider(encryptionKey, macKey, description); assertEquals(encryptionKey, prov.getEncryptionMaterials(ctx).getEncryptionKey()); assertEquals(macKey, prov.getEncryptionMaterials(ctx).getSigningKey()); assertTrue(prov.getEncryptionMaterials(ctx).getMaterialDescription().entrySet().containsAll(description.entrySet())); - + assertEquals(encryptionKey, prov.getDecryptionMaterials(ctx(description)).getDecryptionKey()); assertEquals(macKey, prov.getDecryptionMaterials(ctx(description)).getVerificationKey()); - + } @Test @@ -114,37 +112,37 @@ public void supersetDescMac() { assertEquals(encryptionKey, prov.getEncryptionMaterials(ctx).getEncryptionKey()); assertEquals(macKey, prov.getEncryptionMaterials(ctx).getSigningKey()); assertTrue(prov.getEncryptionMaterials(ctx).getMaterialDescription().entrySet().containsAll(description.entrySet())); - + Map superSet = new HashMap(description); superSet.put("NewValue", "super!"); - + assertEquals(encryptionKey, prov.getDecryptionMaterials(ctx(superSet)).getDecryptionKey()); - assertEquals(macKey, prov.getDecryptionMaterials(ctx(superSet)).getVerificationKey()); + assertEquals(macKey, prov.getDecryptionMaterials(ctx(superSet)).getVerificationKey()); } - + @Test public void subsetDescMac() { SymmetricStaticProvider prov = new SymmetricStaticProvider(encryptionKey, macKey, description); assertEquals(encryptionKey, prov.getEncryptionMaterials(ctx).getEncryptionKey()); assertEquals(macKey, prov.getEncryptionMaterials(ctx).getSigningKey()); assertTrue(prov.getEncryptionMaterials(ctx).getMaterialDescription().entrySet().containsAll(description.entrySet())); - - assertNull(prov.getDecryptionMaterials(ctx(Collections. emptyMap()))); + + assertNull(prov.getDecryptionMaterials(ctx(Collections.emptyMap()))); } - + @Test public void noMatchDescMac() { SymmetricStaticProvider prov = new SymmetricStaticProvider(encryptionKey, macKey, description); assertEquals(encryptionKey, prov.getEncryptionMaterials(ctx).getEncryptionKey()); assertEquals(macKey, prov.getEncryptionMaterials(ctx).getSigningKey()); assertTrue(prov.getEncryptionMaterials(ctx).getMaterialDescription().entrySet().containsAll(description.entrySet())); - + Map noMatch = new HashMap(); noMatch.put("NewValue", "no match!"); - + assertNull(prov.getDecryptionMaterials(ctx(noMatch))); } - + @Test public void testRefresh() { // This does nothing, make sure we don't throw and exception. @@ -156,7 +154,7 @@ public void testRefresh() { private static EncryptionContext ctx(EncryptionMaterials mat) { return ctx(mat.getMaterialDescription()); } - + private static EncryptionContext ctx(Map desc) { return new EncryptionContext.Builder() .withMaterialDescription(desc).build(); diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/store/MetaStoreTests.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/store/MetaStoreTests.java index f1960fc1..d000e5dd 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/store/MetaStoreTests.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/store/MetaStoreTests.java @@ -1,33 +1,17 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.store; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; - -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; - -import org.junit.Before; -import org.junit.Test; - -import com.amazonaws.services.dynamodbv2.local.embedded.DynamoDBEmbedded; import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DynamoDBEncryptor; @@ -36,20 +20,34 @@ import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.EncryptionMaterialsProvider; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.SymmetricStaticProvider; +import com.amazonaws.services.dynamodbv2.local.embedded.DynamoDBEmbedded; import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput; +import org.junit.Before; +import org.junit.Test; + +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; public class MetaStoreTests { private static final String SOURCE_TABLE_NAME = "keystoreTable"; private static final String DESTINATION_TABLE_NAME = "keystoreDestinationTable"; private static final String MATERIAL_NAME = "material"; - private static final SecretKey AES_KEY = new SecretKeySpec(new byte[] { 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, "AES"); - private static final SecretKey TARGET_AES_KEY = new SecretKeySpec(new byte[] { 0, - 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 }, "AES"); - private static final SecretKey HMAC_KEY = new SecretKeySpec(new byte[] { 0, - 1, 2, 3, 4, 5, 6, 7 }, "HmacSHA256"); - private static final SecretKey TARGET_HMAC_KEY = new SecretKeySpec(new byte[] { 0, - 2, 4, 6, 8, 10, 12, 14 }, "HmacSHA256"); + private static final SecretKey AES_KEY = new SecretKeySpec(new byte[]{0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, "AES"); + private static final SecretKey TARGET_AES_KEY = new SecretKeySpec(new byte[]{0, + 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30}, "AES"); + private static final SecretKey HMAC_KEY = new SecretKeySpec(new byte[]{0, + 1, 2, 3, 4, 5, 6, 7}, "HmacSHA256"); + private static final SecretKey TARGET_HMAC_KEY = new SecretKeySpec(new byte[]{0, + 2, 4, 6, 8, 10, 12, 14}, "HmacSHA256"); private static final EncryptionMaterialsProvider BASE_PROVIDER = new SymmetricStaticProvider(AES_KEY, HMAC_KEY); private static final EncryptionMaterialsProvider TARGET_BASE_PROVIDER = new SymmetricStaticProvider(TARGET_AES_KEY, TARGET_HMAC_KEY); private static final DynamoDBEncryptor ENCRYPTOR = DynamoDBEncryptor.getInstance(BASE_PROVIDER); @@ -228,14 +226,14 @@ public void newProviderCollision() throws InterruptedException { assertEquals(eMat.getSigningKey(), dMat.getVerificationKey()); } - @Test(expected=IndexOutOfBoundsException.class) + @Test(expected = IndexOutOfBoundsException.class) public void invalidVersion() { store.getProvider(MATERIAL_NAME, 1000); } private static EncryptionContext ctx(final EncryptionMaterials mat) { return new EncryptionContext.Builder() - .withMaterialDescription(mat.getMaterialDescription()).build(); + .withMaterialDescription(mat.getMaterialDescription()).build(); } private class SlowNewProvider extends Thread { @@ -261,21 +259,21 @@ public void run() { @SuppressWarnings("unchecked") private static T synchronize(final T obj, final Class clazz) { - return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[] { clazz }, + return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz}, new InvocationHandler() { - private final Object lock = new Object(); - - @Override - public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { - synchronized (lock) { - try { - return method.invoke(obj, args); - } catch (final InvocationTargetException ex) { - throw ex.getCause(); + private final Object lock = new Object(); + + @Override + public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable { + synchronized (lock) { + try { + return method.invoke(obj, args); + } catch (final InvocationTargetException ex) { + throw ex.getCause(); + } + } } } - } - } - ); + ); } } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/utils/EncryptionContextOperatorsTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/utils/EncryptionContextOperatorsTest.java index 1e4323bc..e7cb03e8 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/utils/EncryptionContextOperatorsTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/utils/EncryptionContextOperatorsTest.java @@ -9,7 +9,7 @@ import static com.amazonaws.services.dynamodbv2.datamodeling.encryption.utils.EncryptionContextOperators.overrideEncryptionContextTableName; import static com.amazonaws.services.dynamodbv2.datamodeling.encryption.utils.EncryptionContextOperators.overrideEncryptionContextTableNameUsingMap; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class EncryptionContextOperatorsTest { diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/AttributeValueMarshallerTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/AttributeValueMarshallerTest.java index 1ce1401a..fa9fc687 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/AttributeValueMarshallerTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/AttributeValueMarshallerTest.java @@ -14,8 +14,10 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling.internal; -import static com.amazonaws.services.dynamodbv2.datamodeling.internal.AttributeValueMarshaller.marshall; -import static com.amazonaws.services.dynamodbv2.datamodeling.internal.AttributeValueMarshaller.unmarshall; +import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import com.amazonaws.util.Base64; +import org.junit.Assert; +import org.junit.Test; import java.nio.ByteBuffer; import java.util.Arrays; @@ -28,40 +30,37 @@ import java.util.Map; import java.util.Set; -import org.junit.Assert; -import org.junit.Test; - -import com.amazonaws.services.dynamodbv2.model.AttributeValue; -import com.amazonaws.util.Base64; +import static com.amazonaws.services.dynamodbv2.datamodeling.internal.AttributeValueMarshaller.marshall; +import static com.amazonaws.services.dynamodbv2.datamodeling.internal.AttributeValueMarshaller.unmarshall; public class AttributeValueMarshallerTest { - @Test(expected=IllegalArgumentException.class) + @Test(expected = IllegalArgumentException.class) public void testEmpty() { AttributeValue av = new AttributeValue(); marshall(av); } - + @Test public void testNumber() { AttributeValue av = new AttributeValue().withN("1337"); assertEquals(av, unmarshall(marshall(av))); } - + @Test public void testString() { AttributeValue av = new AttributeValue().withS("1337"); assertEquals(av, unmarshall(marshall(av))); } - + @Test public void testByteBuffer() { - AttributeValue av = new AttributeValue().withB(ByteBuffer.wrap(new byte[] {0, 1, 2, 3, 4, 5})); + AttributeValue av = new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5})); assertEquals(av, unmarshall(marshall(av))); } // We can't use straight .equals for comparison because Attribute Values represents Sets // as Lists and so incorrectly does an ordered comparison - + @Test public void testNumberS() { AttributeValue av = new AttributeValue().withNS(Collections.unmodifiableList(Arrays.asList("1337", "1", "5"))); @@ -83,7 +82,7 @@ public void testStringS() { AttributeValue av = new AttributeValue().withSS(Collections.unmodifiableList(Arrays.asList("Bob", "Ann", "5"))); assertEquals(av, unmarshall(marshall(av))); } - + @Test public void testStringSOrdering() { AttributeValue av1 = new AttributeValue().withSS(Collections.unmodifiableList(Arrays.asList("Bob", "Ann", "5"))); @@ -97,20 +96,20 @@ public void testStringSOrdering() { @Test public void testByteBufferS() { AttributeValue av = new AttributeValue().withBS(Collections.unmodifiableList( - Arrays.asList(ByteBuffer.wrap(new byte[] {0, 1, 2, 3, 4, 5}), - ByteBuffer.wrap(new byte[] {5, 4, 3, 2, 1, 0, 0, 0, 5, 6, 7})))); + Arrays.asList(ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5}), + ByteBuffer.wrap(new byte[]{5, 4, 3, 2, 1, 0, 0, 0, 5, 6, 7})))); assertEquals(av, unmarshall(marshall(av))); } @Test public void testByteBufferSOrdering() { AttributeValue av1 = new AttributeValue().withBS(Collections.unmodifiableList( - Arrays.asList(ByteBuffer.wrap(new byte[] {0, 1, 2, 3, 4, 5}), - ByteBuffer.wrap(new byte[] {5, 4, 3, 2, 1, 0, 0, 0, 5, 6, 7})))); + Arrays.asList(ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5}), + ByteBuffer.wrap(new byte[]{5, 4, 3, 2, 1, 0, 0, 0, 5, 6, 7})))); AttributeValue av2 = new AttributeValue().withBS(Collections.unmodifiableList( - Arrays.asList(ByteBuffer.wrap(new byte[] {5, 4, 3, 2, 1, 0, 0, 0, 5, 6, 7}), - ByteBuffer.wrap(new byte[] {0, 1, 2, 3, 4, 5}) - ))); + Arrays.asList(ByteBuffer.wrap(new byte[]{5, 4, 3, 2, 1, 0, 0, 0, 5, 6, 7}), + ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5}) + ))); assertEquals(av1, av2); ByteBuffer buff1 = marshall(av1); @@ -149,7 +148,7 @@ public void testEmptyList() { @Test public void testListOfString() { - AttributeValue av = new AttributeValue().withL(new AttributeValue().withS("StringValue") ); + AttributeValue av = new AttributeValue().withL(new AttributeValue().withS("StringValue")); assertEquals(av, unmarshall(marshall(av))); } @@ -169,13 +168,13 @@ public void testListWithNull() { new AttributeValue().withN("1000"), new AttributeValue().withBOOL(Boolean.TRUE), null); - + try { marshall(av); Assert.fail("Unexpected success"); } catch (final NullPointerException npe) { Assert.assertEquals("Encountered null list entry value while marshalling attribute value {L: [{S: StringValue,}, {N: 1000,}, {BOOL: true}, null],}", - npe.getMessage()); + npe.getMessage()); } } @@ -214,14 +213,14 @@ public void testComplexList() { @Test public void testEmptyMap() { - Map map = new HashMap(); + Map map = new HashMap(); AttributeValue av = new AttributeValue().withM(map); assertEquals(av, unmarshall(marshall(av))); } @Test public void testSimpleMap() { - Map map = new HashMap(); + Map map = new HashMap(); map.put("KeyValue", new AttributeValue().withS("ValueValue")); AttributeValue av = new AttributeValue().withM(map); assertEquals(av, unmarshall(marshall(av))); @@ -229,18 +228,18 @@ public void testSimpleMap() { @Test public void testSimpleMapWithNull() { - final Map map = new HashMap(); + final Map map = new HashMap(); map.put("KeyValue", new AttributeValue().withS("ValueValue")); map.put("NullKeyValue", null); - + final AttributeValue av = new AttributeValue().withM(map); - + try { marshall(av); Assert.fail("Unexpected success"); } catch (final NullPointerException npe) { Assert.assertEquals("Encountered null map value for key NullKeyValue while marshalling attribute value {M: {KeyValue={S: ValueValue,}, NullKeyValue=null},}", - npe.getMessage()); + npe.getMessage()); } } @@ -307,7 +306,7 @@ private static AttributeValue buildComplexAttributeValue() { new AttributeValue().withNULL(Boolean.TRUE), new AttributeValue().withL(new AttributeValue().withBOOL(Boolean.FALSE)), new AttributeValue().withM(floydMap) - ); + ); List nestedList = Arrays.asList( new AttributeValue().withN("5"), @@ -315,7 +314,7 @@ private static AttributeValue buildComplexAttributeValue() { new AttributeValue().withN("3"), new AttributeValue().withN("2"), new AttributeValue().withN("1") - ); + ); Map nestedMap = new HashMap(); nestedMap.put("True", new AttributeValue().withBOOL(Boolean.TRUE)); nestedMap.put("List", new AttributeValue().withL(nestedList)); @@ -326,11 +325,11 @@ private static AttributeValue buildComplexAttributeValue() { List innerList = Arrays.asList( new AttributeValue().withS("ComplexList"), new AttributeValue().withN("5"), - new AttributeValue().withB(ByteBuffer.wrap(new byte[] {0, 1, 2, 3, 4, 5})), + new AttributeValue().withB(ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5})), new AttributeValue().withL(floydList), new AttributeValue().withNULL(Boolean.TRUE), new AttributeValue().withM(nestedMap) - ); + ); AttributeValue av = new AttributeValue(); av.addMEntry("SingleMap", new AttributeValue().withM( diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/ByteBufferInputStreamTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/ByteBufferInputStreamTest.java index 1c8c0b0b..1015423c 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/ByteBufferInputStreamTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/ByteBufferInputStreamTest.java @@ -14,17 +14,17 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling.internal; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import org.junit.Test; import java.io.IOException; import java.nio.ByteBuffer; -import org.junit.Test; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; public class ByteBufferInputStreamTest { - + @Test public void testRead() throws IOException { ByteBufferInputStream bis = new ByteBufferInputStream(ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9})); @@ -40,23 +40,23 @@ public void testRead() throws IOException { public void testReadByteArray() throws IOException { ByteBufferInputStream bis = new ByteBufferInputStream(ByteBuffer.wrap(new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9})); assertEquals(10, bis.available()); - + byte[] buff = new byte[4]; int len = bis.read(buff); assertEquals(4, len); assertEquals(6, bis.available()); - assertArrayEquals(new byte[] {0, 1, 2, 3}, buff); - + assertArrayEquals(new byte[]{0, 1, 2, 3}, buff); + len = bis.read(buff); assertEquals(4, len); assertEquals(2, bis.available()); - assertArrayEquals(new byte[] {4, 5, 6, 7}, buff); + assertArrayEquals(new byte[]{4, 5, 6, 7}, buff); len = bis.read(buff); assertEquals(2, len); assertEquals(0, bis.available()); - assertArrayEquals(new byte[] {8, 9, 6, 7}, buff); + assertArrayEquals(new byte[]{8, 9, 6, 7}, buff); bis.close(); } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/HkdfTests.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/HkdfTests.java index b4cfc3d2..0ffe8cdf 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/HkdfTests.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/HkdfTests.java @@ -1,23 +1,23 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.datamodeling.internal; -import static org.junit.Assert.*; - import org.junit.Test; +import static org.junit.Assert.assertArrayEquals; + public class HkdfTests { - private static final testCase[] testCases = new testCase[] { + private static final testCase[] testCases = new testCase[]{ new testCase( "HmacSHA256", fromCHex("\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b" @@ -105,7 +105,7 @@ public class HkdfTests { null, new byte[0], fromHex("2C91117204D745F3500D636A62F64F0A" + "B3BAE548AA53D423B0D1F27EBBA6F5E5" - + "673A081D70CCE7ACFC48")) }; + + "673A081D70CCE7ACFC48"))}; @Test public void rfc5869Tests() throws Exception { @@ -125,14 +125,14 @@ public void nullTests() throws Exception { Hkdf kdf = Hkdf.getInstance(trial.algo); kdf.init(trial.ikm, trial.salt); // Just ensuring no exceptions are thrown - kdf.deriveKey((String)null, 16); - kdf.deriveKey((byte[]) null, 16); + kdf.deriveKey((String) null, 16); + kdf.deriveKey((byte[]) null, 16); } - + @Test public void defaultSalt() throws Exception { // Tests all the different ways to get the default salt - + testCase trial = testCases[0]; Hkdf kdf1 = Hkdf.getInstance(trial.algo); kdf1.init(trial.ikm, null); @@ -142,12 +142,12 @@ public void defaultSalt() throws Exception { kdf3.init(trial.ikm); Hkdf kdf4 = Hkdf.getInstance(trial.algo); kdf4.init(trial.ikm, new byte[32]); - + byte[] key1 = kdf1.deriveKey("Test", 16); byte[] key2 = kdf2.deriveKey("Test", 16); byte[] key3 = kdf3.deriveKey("Test", 16); byte[] key4 = kdf4.deriveKey("Test", 16); - + assertArrayEquals(key1, key2); assertArrayEquals(key1, key3); assertArrayEquals(key1, key4); @@ -179,7 +179,7 @@ private static class testCase { public final byte[] expected; public testCase(String algo, byte[] ikm, byte[] salt, byte[] info, - byte[] expected) { + byte[] expected) { super(); this.algo = algo; this.ikm = ikm; diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/LRUCacheTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/LRUCacheTest.java index 9b91a43a..49b58e4d 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/LRUCacheTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/datamodeling/internal/LRUCacheTest.java @@ -12,15 +12,15 @@ */ package com.amazonaws.services.dynamodbv2.datamodeling.internal; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.junit.Test; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class LRUCacheTest { @Test diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/BinaryAttributeByteArrayTestClass.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/BinaryAttributeByteArrayTestClass.java index 874baae6..032717cd 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/BinaryAttributeByteArrayTestClass.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/BinaryAttributeByteArrayTestClass.java @@ -1,23 +1,23 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.mapper.encryption; -import java.util.Set; - import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; +import java.util.Set; + /** * Test domain class with byte[] attribute, byte[] set and a string key */ @@ -67,27 +67,27 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if ( this == obj ) + if (this == obj) return true; - if ( obj == null ) + if (obj == null) return false; - if ( getClass() != obj.getClass() ) + if (getClass() != obj.getClass()) return false; BinaryAttributeByteArrayTestClass other = (BinaryAttributeByteArrayTestClass) obj; - if ( key == null ) { - if ( other.key != null ) + if (key == null) { + if (other.key != null) return false; - } else if ( !key.equals(other.key) ) + } else if (!key.equals(other.key)) return false; - if ( binaryAttribute == null ) { - if ( other.binaryAttribute != null ) + if (binaryAttribute == null) { + if (other.binaryAttribute != null) return false; - } else if ( !binaryAttribute.equals(other.binaryAttribute) ) + } else if (!binaryAttribute.equals(other.binaryAttribute)) return false; - if ( binarySetAttribute == null ) { - if ( other.binarySetAttribute != null ) + if (binarySetAttribute == null) { + if (other.binarySetAttribute != null) return false; - } else if ( !binarySetAttribute.equals(other.binarySetAttribute) ) + } else if (!binarySetAttribute.equals(other.binarySetAttribute)) return false; return true; } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/BinaryAttributeByteBufferTestClass.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/BinaryAttributeByteBufferTestClass.java index 8832d458..5ad9f32d 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/BinaryAttributeByteBufferTestClass.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/BinaryAttributeByteBufferTestClass.java @@ -1,24 +1,24 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.mapper.encryption; -import java.nio.ByteBuffer; -import java.util.Set; - import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; +import java.nio.ByteBuffer; +import java.util.Set; + /** * Test domain class with byteBuffer attribute, byteBuffer set and a string key */ @@ -68,27 +68,27 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if ( this == obj ) + if (this == obj) return true; - if ( obj == null ) + if (obj == null) return false; - if ( getClass() != obj.getClass() ) + if (getClass() != obj.getClass()) return false; BinaryAttributeByteBufferTestClass other = (BinaryAttributeByteBufferTestClass) obj; - if ( key == null ) { - if ( other.key != null ) + if (key == null) { + if (other.key != null) return false; - } else if ( !key.equals(other.key) ) + } else if (!key.equals(other.key)) return false; - if ( binaryAttribute == null ) { - if ( other.binaryAttribute != null ) + if (binaryAttribute == null) { + if (other.binaryAttribute != null) return false; - } else if ( !binaryAttribute.equals(other.binaryAttribute) ) + } else if (!binaryAttribute.equals(other.binaryAttribute)) return false; - if ( binarySetAttribute == null ) { - if ( other.binarySetAttribute != null ) + if (binarySetAttribute == null) { + if (other.binarySetAttribute != null) return false; - } else if ( !binarySetAttribute.equals(other.binarySetAttribute) ) + } else if (!binarySetAttribute.equals(other.binarySetAttribute)) return false; return true; } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/CrossSDKVerificationTestClass.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/CrossSDKVerificationTestClass.java index 13e9a3b1..c5693bb3 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/CrossSDKVerificationTestClass.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/CrossSDKVerificationTestClass.java @@ -1,29 +1,29 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.mapper.encryption; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Calendar; -import java.util.Date; -import java.util.Set; - import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBVersionAttribute; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DoNotEncrypt; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Calendar; +import java.util.Date; +import java.util.Set; + /** * Exhaustive exercise of DynamoDB domain mapping, exercising every supported * data type. @@ -299,137 +299,137 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if ( this == obj ) + if (this == obj) return true; - if ( obj == null ) + if (obj == null) return false; - if ( getClass() != obj.getClass() ) + if (getClass() != obj.getClass()) return false; CrossSDKVerificationTestClass other = (CrossSDKVerificationTestClass) obj; - if ( bigDecimalAttribute == null ) { - if ( other.bigDecimalAttribute != null ) + if (bigDecimalAttribute == null) { + if (other.bigDecimalAttribute != null) return false; - } else if ( !bigDecimalAttribute.equals(other.bigDecimalAttribute) ) + } else if (!bigDecimalAttribute.equals(other.bigDecimalAttribute)) return false; - if ( bigDecimalSetAttribute == null ) { - if ( other.bigDecimalSetAttribute != null ) + if (bigDecimalSetAttribute == null) { + if (other.bigDecimalSetAttribute != null) return false; - } else if ( !bigDecimalSetAttribute.equals(other.bigDecimalSetAttribute) ) + } else if (!bigDecimalSetAttribute.equals(other.bigDecimalSetAttribute)) return false; - if ( bigIntegerAttribute == null ) { - if ( other.bigIntegerAttribute != null ) + if (bigIntegerAttribute == null) { + if (other.bigIntegerAttribute != null) return false; - } else if ( !bigIntegerAttribute.equals(other.bigIntegerAttribute) ) + } else if (!bigIntegerAttribute.equals(other.bigIntegerAttribute)) return false; - if ( bigIntegerSetAttribute == null ) { - if ( other.bigIntegerSetAttribute != null ) + if (bigIntegerSetAttribute == null) { + if (other.bigIntegerSetAttribute != null) return false; - } else if ( !bigIntegerSetAttribute.equals(other.bigIntegerSetAttribute) ) + } else if (!bigIntegerSetAttribute.equals(other.bigIntegerSetAttribute)) return false; - if ( booleanAttribute == null ) { - if ( other.booleanAttribute != null ) + if (booleanAttribute == null) { + if (other.booleanAttribute != null) return false; - } else if ( !booleanAttribute.equals(other.booleanAttribute) ) + } else if (!booleanAttribute.equals(other.booleanAttribute)) return false; - if ( booleanSetAttribute == null ) { - if ( other.booleanSetAttribute != null ) + if (booleanSetAttribute == null) { + if (other.booleanSetAttribute != null) return false; - } else if ( !booleanSetAttribute.equals(other.booleanSetAttribute) ) + } else if (!booleanSetAttribute.equals(other.booleanSetAttribute)) return false; - if ( byteAttribute == null ) { - if ( other.byteAttribute != null ) + if (byteAttribute == null) { + if (other.byteAttribute != null) return false; - } else if ( !byteAttribute.equals(other.byteAttribute) ) + } else if (!byteAttribute.equals(other.byteAttribute)) return false; - if ( byteSetAttribute == null ) { - if ( other.byteSetAttribute != null ) + if (byteSetAttribute == null) { + if (other.byteSetAttribute != null) return false; - } else if ( !byteSetAttribute.equals(other.byteSetAttribute) ) + } else if (!byteSetAttribute.equals(other.byteSetAttribute)) return false; - if ( calendarAttribute == null ) { - if ( other.calendarAttribute != null ) + if (calendarAttribute == null) { + if (other.calendarAttribute != null) return false; - } else if ( !calendarAttribute.equals(other.calendarAttribute) ) + } else if (!calendarAttribute.equals(other.calendarAttribute)) return false; - if ( calendarSetAttribute == null ) { - if ( other.calendarSetAttribute != null ) + if (calendarSetAttribute == null) { + if (other.calendarSetAttribute != null) return false; - } else if ( !calendarSetAttribute.equals(other.calendarSetAttribute) ) + } else if (!calendarSetAttribute.equals(other.calendarSetAttribute)) return false; - if ( dateAttribute == null ) { - if ( other.dateAttribute != null ) + if (dateAttribute == null) { + if (other.dateAttribute != null) return false; - } else if ( !dateAttribute.equals(other.dateAttribute) ) + } else if (!dateAttribute.equals(other.dateAttribute)) return false; - if ( dateSetAttribute == null ) { - if ( other.dateSetAttribute != null ) + if (dateSetAttribute == null) { + if (other.dateSetAttribute != null) return false; - } else if ( !dateSetAttribute.equals(other.dateSetAttribute) ) + } else if (!dateSetAttribute.equals(other.dateSetAttribute)) return false; - if ( doubleAttribute == null ) { - if ( other.doubleAttribute != null ) + if (doubleAttribute == null) { + if (other.doubleAttribute != null) return false; - } else if ( !doubleAttribute.equals(other.doubleAttribute) ) + } else if (!doubleAttribute.equals(other.doubleAttribute)) return false; - if ( doubleSetAttribute == null ) { - if ( other.doubleSetAttribute != null ) + if (doubleSetAttribute == null) { + if (other.doubleSetAttribute != null) return false; - } else if ( !doubleSetAttribute.equals(other.doubleSetAttribute) ) + } else if (!doubleSetAttribute.equals(other.doubleSetAttribute)) return false; - if ( floatAttribute == null ) { - if ( other.floatAttribute != null ) + if (floatAttribute == null) { + if (other.floatAttribute != null) return false; - } else if ( !floatAttribute.equals(other.floatAttribute) ) + } else if (!floatAttribute.equals(other.floatAttribute)) return false; - if ( floatSetAttribute == null ) { - if ( other.floatSetAttribute != null ) + if (floatSetAttribute == null) { + if (other.floatSetAttribute != null) return false; - } else if ( !floatSetAttribute.equals(other.floatSetAttribute) ) + } else if (!floatSetAttribute.equals(other.floatSetAttribute)) return false; - if ( integerAttribute == null ) { - if ( other.integerAttribute != null ) + if (integerAttribute == null) { + if (other.integerAttribute != null) return false; - } else if ( !integerAttribute.equals(other.integerAttribute) ) + } else if (!integerAttribute.equals(other.integerAttribute)) return false; - if ( integerSetAttribute == null ) { - if ( other.integerSetAttribute != null ) + if (integerSetAttribute == null) { + if (other.integerSetAttribute != null) return false; - } else if ( !integerSetAttribute.equals(other.integerSetAttribute) ) + } else if (!integerSetAttribute.equals(other.integerSetAttribute)) return false; - if ( key == null ) { - if ( other.key != null ) + if (key == null) { + if (other.key != null) return false; - } else if ( !key.equals(other.key) ) + } else if (!key.equals(other.key)) return false; - if ( lastUpdater == null ) { - if ( other.lastUpdater != null ) + if (lastUpdater == null) { + if (other.lastUpdater != null) return false; - } else if ( !lastUpdater.equals(other.lastUpdater) ) + } else if (!lastUpdater.equals(other.lastUpdater)) return false; - if ( longAttribute == null ) { - if ( other.longAttribute != null ) + if (longAttribute == null) { + if (other.longAttribute != null) return false; - } else if ( !longAttribute.equals(other.longAttribute) ) + } else if (!longAttribute.equals(other.longAttribute)) return false; - if ( longSetAttribute == null ) { - if ( other.longSetAttribute != null ) + if (longSetAttribute == null) { + if (other.longSetAttribute != null) return false; - } else if ( !longSetAttribute.equals(other.longSetAttribute) ) + } else if (!longSetAttribute.equals(other.longSetAttribute)) return false; - if ( rangeKey == null ) { - if ( other.rangeKey != null ) + if (rangeKey == null) { + if (other.rangeKey != null) return false; - } else if ( !rangeKey.equals(other.rangeKey) ) + } else if (!rangeKey.equals(other.rangeKey)) return false; - if ( stringSetAttribute == null ) { - if ( other.stringSetAttribute != null ) + if (stringSetAttribute == null) { + if (other.stringSetAttribute != null) return false; - } else if ( !stringSetAttribute.equals(other.stringSetAttribute) ) + } else if (!stringSetAttribute.equals(other.stringSetAttribute)) return false; - if ( version == null ) { - if ( other.version != null ) + if (version == null) { + if (other.version != null) return false; - } else if ( !version.equals(other.version) ) + } else if (!version.equals(other.version)) return false; return true; } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/IndexRangeKeyTestClass.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/IndexRangeKeyTestClass.java index 78d04578..ac63f6b0 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/IndexRangeKeyTestClass.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/IndexRangeKeyTestClass.java @@ -1,11 +1,11 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. @@ -55,9 +55,9 @@ public void setRangeKey(double rangeKey) { } @DoNotEncrypt - @DynamoDBIndexRangeKey ( - localSecondaryIndexName = "index_foo", - attributeName = "indexFooRangeKey" + @DynamoDBIndexRangeKey( + localSecondaryIndexName = "index_foo", + attributeName = "indexFooRangeKey" ) public Double getIndexFooRangeKeyWithFakeName() { return indexFooRangeKey; @@ -66,10 +66,10 @@ public Double getIndexFooRangeKeyWithFakeName() { public void setIndexFooRangeKeyWithFakeName(Double indexFooRangeKey) { this.indexFooRangeKey = indexFooRangeKey; } - + @DoNotEncrypt - @DynamoDBIndexRangeKey ( - localSecondaryIndexName = "index_bar" + @DynamoDBIndexRangeKey( + localSecondaryIndexName = "index_bar" ) public Double getIndexBarRangeKey() { return indexBarRangeKey; @@ -78,10 +78,10 @@ public Double getIndexBarRangeKey() { public void setIndexBarRangeKey(Double indexBarRangeKey) { this.indexBarRangeKey = indexBarRangeKey; } - + @DoNotEncrypt - @DynamoDBIndexRangeKey ( - localSecondaryIndexNames = {"index_foo_copy", "index_bar_copy"} + @DynamoDBIndexRangeKey( + localSecondaryIndexNames = {"index_foo_copy", "index_bar_copy"} ) public Double getMultipleIndexRangeKey() { return multipleIndexRangeKey; @@ -139,35 +139,35 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if ( this == obj ) + if (this == obj) return true; - if ( obj == null ) + if (obj == null) return false; - if ( getClass() != obj.getClass() ) + if (getClass() != obj.getClass()) return false; IndexRangeKeyTestClass other = (IndexRangeKeyTestClass) obj; - if ( fooAttribute == null ) { - if ( other.fooAttribute != null ) + if (fooAttribute == null) { + if (other.fooAttribute != null) return false; - } else if ( !fooAttribute.equals(other.fooAttribute) ) + } else if (!fooAttribute.equals(other.fooAttribute)) return false; - if ( barAttribute == null ) { - if ( other.barAttribute != null ) + if (barAttribute == null) { + if (other.barAttribute != null) return false; - } else if ( !barAttribute.equals(other.barAttribute) ) + } else if (!barAttribute.equals(other.barAttribute)) return false; - if ( key != other.key ) + if (key != other.key) return false; - if ( Double.doubleToLongBits(rangeKey) != Double.doubleToLongBits(other.rangeKey) ) + if (Double.doubleToLongBits(rangeKey) != Double.doubleToLongBits(other.rangeKey)) return false; - if ( Double.doubleToLongBits(indexFooRangeKey) != Double.doubleToLongBits(other.indexFooRangeKey) ) + if (Double.doubleToLongBits(indexFooRangeKey) != Double.doubleToLongBits(other.indexFooRangeKey)) return false; - if ( Double.doubleToLongBits(indexBarRangeKey) != Double.doubleToLongBits(other.indexBarRangeKey) ) + if (Double.doubleToLongBits(indexBarRangeKey) != Double.doubleToLongBits(other.indexBarRangeKey)) return false; - if ( version == null ) { - if ( other.version != null ) + if (version == null) { + if (other.version != null) return false; - } else if ( !version.equals(other.version) ) + } else if (!version.equals(other.version)) return false; return true; } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/MapperQueryExpressionCryptoTest.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/MapperQueryExpressionCryptoTest.java index dec7c8e4..7cb4aaea 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/MapperQueryExpressionCryptoTest.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/MapperQueryExpressionCryptoTest.java @@ -1,28 +1,17 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.mapper.encryption; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.junit.BeforeClass; -import org.junit.Test; - import com.amazonaws.services.dynamodbv2.AmazonDynamoDB; import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; @@ -38,6 +27,16 @@ import com.amazonaws.services.dynamodbv2.model.Condition; import com.amazonaws.services.dynamodbv2.model.QueryRequest; import com.amazonaws.util.ImmutableMapParameter; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * Unit test for the private method DynamoDBMapper#createQueryRequestFromExpression @@ -64,17 +63,17 @@ public static void setUp() throws SecurityException, NoSuchMethodException { public final class HashOnlyClass { @DynamoDBHashKey - @DynamoDBIndexHashKey ( + @DynamoDBIndexHashKey( globalSecondaryIndexNames = "GSI-primary-hash" ) private String primaryHashKey; - @DynamoDBIndexHashKey ( + @DynamoDBIndexHashKey( globalSecondaryIndexNames = {"GSI-index-hash-1", "GSI-index-hash-2"} ) private String indexHashKey; - @DynamoDBIndexHashKey ( + @DynamoDBIndexHashKey( globalSecondaryIndexNames = {"GSI-another-index-hash"} ) private String anotherIndexHashKey; @@ -110,7 +109,9 @@ public void setAnotherIndexHashKey(String anotherIndexHashKey) { } } - /** Tests different scenarios of hash-only query **/ + /** + * Tests different scenarios of hash-only query + **/ @Test public void testHashConditionOnly() { // Primary hash only @@ -122,7 +123,7 @@ public void testHashConditionOnly() { assertEquals("primaryHashKey", queryRequest.getKeyConditions().keySet().iterator().next()); assertEquals( new Condition().withAttributeValueList(new AttributeValue("foo")) - .withComparisonOperator(ComparisonOperator.EQ), + .withComparisonOperator(ComparisonOperator.EQ), queryRequest.getKeyConditions().get("primaryHashKey")); assertNull(queryRequest.getIndexName()); @@ -136,20 +137,20 @@ public void testHashConditionOnly() { assertEquals("primaryHashKey", queryRequest.getKeyConditions().keySet().iterator().next()); assertEquals( new Condition().withAttributeValueList(new AttributeValue("foo")) - .withComparisonOperator(ComparisonOperator.EQ), + .withComparisonOperator(ComparisonOperator.EQ), queryRequest.getKeyConditions().get("primaryHashKey")); assertEquals("GSI-primary-hash", queryRequest.getIndexName()); // Primary hash query takes higher priority then index hash query queryRequest = testCreateQueryRequestFromExpression( - HashOnlyClass.class, - new DynamoDBQueryExpression() - .withHashKeyValues(new HashOnlyClass("foo", "bar", null))); + HashOnlyClass.class, + new DynamoDBQueryExpression() + .withHashKeyValues(new HashOnlyClass("foo", "bar", null))); assertTrue(queryRequest.getKeyConditions().size() == 1); assertEquals("primaryHashKey", queryRequest.getKeyConditions().keySet().iterator().next()); assertEquals( new Condition().withAttributeValueList(new AttributeValue("foo")) - .withComparisonOperator(ComparisonOperator.EQ), + .withComparisonOperator(ComparisonOperator.EQ), queryRequest.getKeyConditions().get("primaryHashKey")); assertNull(queryRequest.getIndexName()); @@ -177,7 +178,7 @@ public void testHashConditionOnly() { assertEquals("indexHashKey", queryRequest.getKeyConditions().keySet().iterator().next()); assertEquals( new Condition().withAttributeValueList(new AttributeValue("bar")) - .withComparisonOperator(ComparisonOperator.EQ), + .withComparisonOperator(ComparisonOperator.EQ), queryRequest.getKeyConditions().get("indexHashKey")); assertEquals("GSI-index-hash-1", queryRequest.getIndexName()); @@ -187,7 +188,7 @@ public void testHashConditionOnly() { new DynamoDBQueryExpression() .withHashKeyValues(new HashOnlyClass("foo", "bar", null)) .withIndexName("some fake gsi"), - "No hash key condition is applicable to the specified index"); + "No hash key condition is applicable to the specified index"); // No hash key condition specified queryRequest = testCreateQueryRequestFromExpression( @@ -211,7 +212,7 @@ public HashRangeClass(String primaryHashKey, String indexHashKey) { } @DynamoDBHashKey - @DynamoDBIndexHashKey ( + @DynamoDBIndexHashKey( globalSecondaryIndexNames = { "GSI-primary-hash-index-range-1", "GSI-primary-hash-index-range-2"} @@ -224,7 +225,7 @@ public void setPrimaryHashKey(String primaryHashKey) { this.primaryHashKey = primaryHashKey; } - @DynamoDBIndexHashKey ( + @DynamoDBIndexHashKey( globalSecondaryIndexNames = { "GSI-index-hash-primary-range", "GSI-index-hash-index-range-1", @@ -239,7 +240,7 @@ public void setIndexHashKey(String indexHashKey) { } @DynamoDBRangeKey - @DynamoDBIndexRangeKey ( + @DynamoDBIndexRangeKey( globalSecondaryIndexNames = {"GSI-index-hash-primary-range"}, localSecondaryIndexName = "LSI-primary-range" ) @@ -251,7 +252,7 @@ public void setPrimaryRangeKey(String primaryRangeKey) { this.primaryRangeKey = primaryRangeKey; } - @DynamoDBIndexRangeKey ( + @DynamoDBIndexRangeKey( globalSecondaryIndexNames = { "GSI-primary-hash-index-range-1", "GSI-index-hash-index-range-1", @@ -266,7 +267,7 @@ public void setIndexRangeKey(String indexRangeKey) { this.indexRangeKey = indexRangeKey; } - @DynamoDBIndexRangeKey ( + @DynamoDBIndexRangeKey( localSecondaryIndexName = "LSI-index-range-3", globalSecondaryIndexName = "GSI-primary-hash-index-range-2" ) @@ -279,7 +280,9 @@ public void setAnotherIndexRangeKey(String anotherIndexRangeKey) { } } - /** Tests hash + range query **/ + /** + * Tests hash + range query + **/ @Test public void testHashAndRangeCondition() { // Primary hash + primary range @@ -292,7 +295,7 @@ public void testHashAndRangeCondition() { assertTrue(queryRequest.getKeyConditions().containsKey("primaryHashKey")); assertEquals( new Condition().withAttributeValueList(new AttributeValue("foo")) - .withComparisonOperator(ComparisonOperator.EQ), + .withComparisonOperator(ComparisonOperator.EQ), queryRequest.getKeyConditions().get("primaryHashKey")); assertTrue(queryRequest.getKeyConditions().containsKey("primaryRangeKey")); assertEquals(RANGE_KEY_CONDITION, queryRequest.getKeyConditions().get("primaryRangeKey")); @@ -309,7 +312,7 @@ public void testHashAndRangeCondition() { assertTrue(queryRequest.getKeyConditions().containsKey("primaryHashKey")); assertEquals( new Condition().withAttributeValueList(new AttributeValue("foo")) - .withComparisonOperator(ComparisonOperator.EQ), + .withComparisonOperator(ComparisonOperator.EQ), queryRequest.getKeyConditions().get("primaryHashKey")); assertTrue(queryRequest.getKeyConditions().containsKey("primaryRangeKey")); assertEquals(RANGE_KEY_CONDITION, queryRequest.getKeyConditions().get("primaryRangeKey")); @@ -325,7 +328,7 @@ public void testHashAndRangeCondition() { assertTrue(queryRequest.getKeyConditions().containsKey("primaryHashKey")); assertEquals( new Condition().withAttributeValueList(new AttributeValue("foo")) - .withComparisonOperator(ComparisonOperator.EQ), + .withComparisonOperator(ComparisonOperator.EQ), queryRequest.getKeyConditions().get("primaryHashKey")); assertTrue(queryRequest.getKeyConditions().containsKey("indexRangeKey")); assertEquals(RANGE_KEY_CONDITION, queryRequest.getKeyConditions().get("indexRangeKey")); @@ -342,7 +345,7 @@ public void testHashAndRangeCondition() { assertTrue(queryRequest.getKeyConditions().containsKey("primaryHashKey")); assertEquals( new Condition().withAttributeValueList(new AttributeValue("foo")) - .withComparisonOperator(ComparisonOperator.EQ), + .withComparisonOperator(ComparisonOperator.EQ), queryRequest.getKeyConditions().get("primaryHashKey")); assertTrue(queryRequest.getKeyConditions().containsKey("indexRangeKey")); assertEquals(RANGE_KEY_CONDITION, queryRequest.getKeyConditions().get("indexRangeKey")); @@ -376,7 +379,7 @@ public void testHashAndRangeCondition() { assertTrue(queryRequest.getKeyConditions().containsKey("indexHashKey")); assertEquals( new Condition().withAttributeValueList(new AttributeValue("foo")) - .withComparisonOperator(ComparisonOperator.EQ), + .withComparisonOperator(ComparisonOperator.EQ), queryRequest.getKeyConditions().get("indexHashKey")); assertTrue(queryRequest.getKeyConditions().containsKey("primaryRangeKey")); assertEquals(RANGE_KEY_CONDITION, queryRequest.getKeyConditions().get("primaryRangeKey")); @@ -401,7 +404,7 @@ public void testHashAndRangeCondition() { assertTrue(queryRequest.getKeyConditions().containsKey("indexHashKey")); assertEquals( new Condition().withAttributeValueList(new AttributeValue("foo")) - .withComparisonOperator(ComparisonOperator.EQ), + .withComparisonOperator(ComparisonOperator.EQ), queryRequest.getKeyConditions().get("indexHashKey")); assertTrue(queryRequest.getKeyConditions().containsKey("indexRangeKey")); assertEquals(RANGE_KEY_CONDITION, queryRequest.getKeyConditions().get("indexRangeKey")); @@ -440,37 +443,40 @@ public final class LSIRangeKeyTestClass { private String primaryHashKey; private String primaryRangeKey; private String lsiRangeKey; - + public LSIRangeKeyTestClass(String primaryHashKey, String primaryRangeKey) { this.primaryHashKey = primaryHashKey; this.primaryRangeKey = primaryRangeKey; } - + @DynamoDBHashKey public String getPrimaryHashKey() { return primaryHashKey; } + public void setPrimaryHashKey(String primaryHashKey) { this.primaryHashKey = primaryHashKey; } - + @DynamoDBRangeKey public String getPrimaryRangeKey() { return primaryRangeKey; } + public void setPrimaryRangeKey(String primaryRangeKey) { this.primaryRangeKey = primaryRangeKey; } - + @DynamoDBIndexRangeKey(localSecondaryIndexName = "LSI") public String getLsiRangeKey() { return lsiRangeKey; } + public void setLsiRangeKey(String lsiRangeKey) { this.lsiRangeKey = lsiRangeKey; } } - + @Test public void testHashOnlyQueryOnHashRangeTable() { // Primary hash only query on a Hash+Range table @@ -481,7 +487,7 @@ public void testHashOnlyQueryOnHashRangeTable() { assertTrue(queryRequest.getKeyConditions().size() == 1); assertTrue(queryRequest.getKeyConditions().containsKey("primaryHashKey")); assertNull(queryRequest.getIndexName()); - + // Hash+Range query on a LSI queryRequest = testCreateQueryRequestFromExpression( LSIRangeKeyTestClass.class, @@ -493,7 +499,7 @@ public void testHashOnlyQueryOnHashRangeTable() { assertTrue(queryRequest.getKeyConditions().containsKey("primaryHashKey")); assertTrue(queryRequest.getKeyConditions().containsKey("lsiRangeKey")); assertEquals("LSI", queryRequest.getIndexName()); - + // Hash-only query on a LSI queryRequest = testCreateQueryRequestFromExpression( LSIRangeKeyTestClass.class, @@ -523,7 +529,7 @@ private static QueryRequest testCreateQueryRequestFromExpression( } catch (InvocationTargetException ite) { if (expectedErrorMessage != null) { assertTrue("Exception message [" + ite.getCause().getMessage() + "] does not contain " + - "the expected message [" + expectedErrorMessage + "].", + "the expected message [" + expectedErrorMessage + "].", ite.getCause().getMessage().contains(expectedErrorMessage)); } else { ite.getCause().printStackTrace(); diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/NoSuchTableTestClass.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/NoSuchTableTestClass.java index 698a2532..9512d7eb 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/NoSuchTableTestClass.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/NoSuchTableTestClass.java @@ -1,11 +1,11 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/NumberAttributeTestClass.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/NumberAttributeTestClass.java index af2a7477..4b37a2ef 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/NumberAttributeTestClass.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/NumberAttributeTestClass.java @@ -1,28 +1,28 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.mapper.encryption; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Calendar; -import java.util.Date; - import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGeneratedKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBIgnore; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Calendar; +import java.util.Date; + /** * Simple domain class with numeric attributes */ @@ -245,91 +245,91 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if ( this == obj ) + if (this == obj) return true; - if ( obj == null ) + if (obj == null) return false; - if ( getClass() != obj.getClass() ) + if (getClass() != obj.getClass()) return false; NumberAttributeTestClass other = (NumberAttributeTestClass) obj; - if ( bigDecimalAttribute == null ) { - if ( other.bigDecimalAttribute != null ) + if (bigDecimalAttribute == null) { + if (other.bigDecimalAttribute != null) return false; - } else if ( !bigDecimalAttribute.equals(other.bigDecimalAttribute) ) + } else if (!bigDecimalAttribute.equals(other.bigDecimalAttribute)) return false; - if ( bigIntegerAttribute == null ) { - if ( other.bigIntegerAttribute != null ) + if (bigIntegerAttribute == null) { + if (other.bigIntegerAttribute != null) return false; - } else if ( !bigIntegerAttribute.equals(other.bigIntegerAttribute) ) + } else if (!bigIntegerAttribute.equals(other.bigIntegerAttribute)) return false; - if ( booleanAttribute != other.booleanAttribute ) + if (booleanAttribute != other.booleanAttribute) return false; - if ( booleanObjectAttribute == null ) { - if ( other.booleanObjectAttribute != null ) + if (booleanObjectAttribute == null) { + if (other.booleanObjectAttribute != null) return false; - } else if ( !booleanObjectAttribute.equals(other.booleanObjectAttribute) ) + } else if (!booleanObjectAttribute.equals(other.booleanObjectAttribute)) return false; - if ( byteAttribute != other.byteAttribute ) + if (byteAttribute != other.byteAttribute) return false; - if ( byteObjectAttribute == null ) { - if ( other.byteObjectAttribute != null ) + if (byteObjectAttribute == null) { + if (other.byteObjectAttribute != null) return false; - } else if ( !byteObjectAttribute.equals(other.byteObjectAttribute) ) + } else if (!byteObjectAttribute.equals(other.byteObjectAttribute)) return false; - if ( calendarAttribute == null ) { - if ( other.calendarAttribute != null ) + if (calendarAttribute == null) { + if (other.calendarAttribute != null) return false; - } else if ( !calendarAttribute.equals(other.calendarAttribute) ) + } else if (!calendarAttribute.equals(other.calendarAttribute)) return false; - if ( dateAttribute == null ) { - if ( other.dateAttribute != null ) + if (dateAttribute == null) { + if (other.dateAttribute != null) return false; - } else if ( !dateAttribute.equals(other.dateAttribute) ) + } else if (!dateAttribute.equals(other.dateAttribute)) return false; - if ( Double.doubleToLongBits(doubleAttribute) != Double.doubleToLongBits(other.doubleAttribute) ) + if (Double.doubleToLongBits(doubleAttribute) != Double.doubleToLongBits(other.doubleAttribute)) return false; - if ( doubleObjectAttribute == null ) { - if ( other.doubleObjectAttribute != null ) + if (doubleObjectAttribute == null) { + if (other.doubleObjectAttribute != null) return false; - } else if ( !doubleObjectAttribute.equals(other.doubleObjectAttribute) ) + } else if (!doubleObjectAttribute.equals(other.doubleObjectAttribute)) return false; - if ( Float.floatToIntBits(floatAttribute) != Float.floatToIntBits(other.floatAttribute) ) + if (Float.floatToIntBits(floatAttribute) != Float.floatToIntBits(other.floatAttribute)) return false; - if ( floatObjectAttribute == null ) { - if ( other.floatObjectAttribute != null ) + if (floatObjectAttribute == null) { + if (other.floatObjectAttribute != null) return false; - } else if ( !floatObjectAttribute.equals(other.floatObjectAttribute) ) + } else if (!floatObjectAttribute.equals(other.floatObjectAttribute)) return false; - if ( ignored == null ) { - if ( other.ignored != null ) + if (ignored == null) { + if (other.ignored != null) return false; - } else if ( !ignored.equals(other.ignored) ) + } else if (!ignored.equals(other.ignored)) return false; - if ( intAttribute != other.intAttribute ) + if (intAttribute != other.intAttribute) return false; - if ( integerAttribute == null ) { - if ( other.integerAttribute != null ) + if (integerAttribute == null) { + if (other.integerAttribute != null) return false; - } else if ( !integerAttribute.equals(other.integerAttribute) ) + } else if (!integerAttribute.equals(other.integerAttribute)) return false; - if ( key == null ) { - if ( other.key != null ) + if (key == null) { + if (other.key != null) return false; - } else if ( !key.equals(other.key) ) + } else if (!key.equals(other.key)) return false; - if ( longAttribute != other.longAttribute ) + if (longAttribute != other.longAttribute) return false; - if ( longObjectAttribute == null ) { - if ( other.longObjectAttribute != null ) + if (longObjectAttribute == null) { + if (other.longObjectAttribute != null) return false; - } else if ( !longObjectAttribute.equals(other.longObjectAttribute) ) + } else if (!longObjectAttribute.equals(other.longObjectAttribute)) return false; - if ( shortAttribute != other.shortAttribute ) + if (shortAttribute != other.shortAttribute) return false; - if ( shortObjectAttribute == null ) { - if ( other.shortObjectAttribute != null ) + if (shortObjectAttribute == null) { + if (other.shortObjectAttribute != null) return false; - } else if ( !shortObjectAttribute.equals(other.shortObjectAttribute) ) + } else if (!shortObjectAttribute.equals(other.shortObjectAttribute)) return false; return true; } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/NumberSetAttributeTestClass.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/NumberSetAttributeTestClass.java index 1f5b78a5..6dcf18af 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/NumberSetAttributeTestClass.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/NumberSetAttributeTestClass.java @@ -1,27 +1,27 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.mapper.encryption; +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute; +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; + import java.math.BigDecimal; import java.math.BigInteger; import java.util.Calendar; import java.util.Date; import java.util.Set; -import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute; -import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; -import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; - /** * Simple domain class with numeric attributes */ @@ -159,67 +159,67 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if ( this == obj ) + if (this == obj) return true; - if ( obj == null ) + if (obj == null) return false; - if ( getClass() != obj.getClass() ) + if (getClass() != obj.getClass()) return false; NumberSetAttributeTestClass other = (NumberSetAttributeTestClass) obj; - if ( bigDecimalAttribute == null ) { - if ( other.bigDecimalAttribute != null ) + if (bigDecimalAttribute == null) { + if (other.bigDecimalAttribute != null) return false; - } else if ( !bigDecimalAttribute.equals(other.bigDecimalAttribute) ) + } else if (!bigDecimalAttribute.equals(other.bigDecimalAttribute)) return false; - if ( bigIntegerAttribute == null ) { - if ( other.bigIntegerAttribute != null ) + if (bigIntegerAttribute == null) { + if (other.bigIntegerAttribute != null) return false; - } else if ( !bigIntegerAttribute.equals(other.bigIntegerAttribute) ) + } else if (!bigIntegerAttribute.equals(other.bigIntegerAttribute)) return false; - if ( booleanAttribute == null ) { - if ( other.booleanAttribute != null ) + if (booleanAttribute == null) { + if (other.booleanAttribute != null) return false; - } else if ( !booleanAttribute.equals(other.booleanAttribute) ) + } else if (!booleanAttribute.equals(other.booleanAttribute)) return false; - if ( byteObjectAttribute == null ) { - if ( other.byteObjectAttribute != null ) + if (byteObjectAttribute == null) { + if (other.byteObjectAttribute != null) return false; - } else if ( !byteObjectAttribute.equals(other.byteObjectAttribute) ) + } else if (!byteObjectAttribute.equals(other.byteObjectAttribute)) return false; - if ( calendarAttribute == null ) { - if ( other.calendarAttribute != null ) + if (calendarAttribute == null) { + if (other.calendarAttribute != null) return false; - } else if ( !calendarAttribute.equals(other.calendarAttribute) ) + } else if (!calendarAttribute.equals(other.calendarAttribute)) return false; - if ( dateAttribute == null ) { - if ( other.dateAttribute != null ) + if (dateAttribute == null) { + if (other.dateAttribute != null) return false; - } else if ( !dateAttribute.equals(other.dateAttribute) ) + } else if (!dateAttribute.equals(other.dateAttribute)) return false; - if ( doubleObjectAttribute == null ) { - if ( other.doubleObjectAttribute != null ) + if (doubleObjectAttribute == null) { + if (other.doubleObjectAttribute != null) return false; - } else if ( !doubleObjectAttribute.equals(other.doubleObjectAttribute) ) + } else if (!doubleObjectAttribute.equals(other.doubleObjectAttribute)) return false; - if ( floatObjectAttribute == null ) { - if ( other.floatObjectAttribute != null ) + if (floatObjectAttribute == null) { + if (other.floatObjectAttribute != null) return false; - } else if ( !floatObjectAttribute.equals(other.floatObjectAttribute) ) + } else if (!floatObjectAttribute.equals(other.floatObjectAttribute)) return false; - if ( integerAttribute == null ) { - if ( other.integerAttribute != null ) + if (integerAttribute == null) { + if (other.integerAttribute != null) return false; - } else if ( !integerAttribute.equals(other.integerAttribute) ) + } else if (!integerAttribute.equals(other.integerAttribute)) return false; - if ( key == null ) { - if ( other.key != null ) + if (key == null) { + if (other.key != null) return false; - } else if ( !key.equals(other.key) ) + } else if (!key.equals(other.key)) return false; - if ( longObjectAttribute == null ) { - if ( other.longObjectAttribute != null ) + if (longObjectAttribute == null) { + if (other.longObjectAttribute != null) return false; - } else if ( !longObjectAttribute.equals(other.longObjectAttribute) ) + } else if (!longObjectAttribute.equals(other.longObjectAttribute)) return false; return true; } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/RangeKeyTestClass.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/RangeKeyTestClass.java index 2be975e1..d24fc14f 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/RangeKeyTestClass.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/RangeKeyTestClass.java @@ -1,20 +1,17 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.mapper.encryption; -import java.math.BigDecimal; -import java.util.Set; - import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey; @@ -22,6 +19,9 @@ import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBVersionAttribute; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DoNotEncrypt; +import java.math.BigDecimal; +import java.util.Set; + /** * Comprehensive domain class */ @@ -120,41 +120,41 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if ( this == obj ) + if (this == obj) return true; - if ( obj == null ) + if (obj == null) return false; - if ( getClass() != obj.getClass() ) + if (getClass() != obj.getClass()) return false; RangeKeyTestClass other = (RangeKeyTestClass) obj; - if ( bigDecimalAttribute == null ) { - if ( other.bigDecimalAttribute != null ) + if (bigDecimalAttribute == null) { + if (other.bigDecimalAttribute != null) return false; - } else if ( !bigDecimalAttribute.equals(other.bigDecimalAttribute) ) + } else if (!bigDecimalAttribute.equals(other.bigDecimalAttribute)) return false; - if ( integerSetAttribute == null ) { - if ( other.integerSetAttribute != null ) + if (integerSetAttribute == null) { + if (other.integerSetAttribute != null) return false; - } else if ( !integerSetAttribute.equals(other.integerSetAttribute) ) + } else if (!integerSetAttribute.equals(other.integerSetAttribute)) return false; - if ( key != other.key ) + if (key != other.key) return false; - if ( Double.doubleToLongBits(rangeKey) != Double.doubleToLongBits(other.rangeKey) ) + if (Double.doubleToLongBits(rangeKey) != Double.doubleToLongBits(other.rangeKey)) return false; - if ( stringAttribute == null ) { - if ( other.stringAttribute != null ) + if (stringAttribute == null) { + if (other.stringAttribute != null) return false; - } else if ( !stringAttribute.equals(other.stringAttribute) ) + } else if (!stringAttribute.equals(other.stringAttribute)) return false; - if ( stringSetAttribute == null ) { - if ( other.stringSetAttribute != null ) + if (stringSetAttribute == null) { + if (other.stringSetAttribute != null) return false; - } else if ( !stringSetAttribute.equals(other.stringSetAttribute) ) + } else if (!stringSetAttribute.equals(other.stringSetAttribute)) return false; - if ( version == null ) { - if ( other.version != null ) + if (version == null) { + if (other.version != null) return false; - } else if ( !version.equals(other.version) ) + } else if (!version.equals(other.version)) return false; return true; } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/StringAttributeTestClass.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/StringAttributeTestClass.java index 32df3ffb..5112ebb5 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/StringAttributeTestClass.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/StringAttributeTestClass.java @@ -1,11 +1,11 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. @@ -65,27 +65,27 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if ( this == obj ) + if (this == obj) return true; - if ( obj == null ) + if (obj == null) return false; - if ( getClass() != obj.getClass() ) + if (getClass() != obj.getClass()) return false; StringAttributeTestClass other = (StringAttributeTestClass) obj; - if ( key == null ) { - if ( other.key != null ) + if (key == null) { + if (other.key != null) return false; - } else if ( !key.equals(other.key) ) + } else if (!key.equals(other.key)) return false; - if ( renamedAttribute == null ) { - if ( other.renamedAttribute != null ) + if (renamedAttribute == null) { + if (other.renamedAttribute != null) return false; - } else if ( !renamedAttribute.equals(other.renamedAttribute) ) + } else if (!renamedAttribute.equals(other.renamedAttribute)) return false; - if ( stringAttribute == null ) { - if ( other.stringAttribute != null ) + if (stringAttribute == null) { + if (other.stringAttribute != null) return false; - } else if ( !stringAttribute.equals(other.stringAttribute) ) + } else if (!stringAttribute.equals(other.stringAttribute)) return false; return true; } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/StringSetAttributeTestClass.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/StringSetAttributeTestClass.java index ca980de6..653ff8f7 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/StringSetAttributeTestClass.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/StringSetAttributeTestClass.java @@ -1,23 +1,23 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.mapper.encryption; -import java.util.Set; - import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; +import java.util.Set; + /** * Test domain class with a string set attribute and a string key */ @@ -67,27 +67,27 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if ( this == obj ) + if (this == obj) return true; - if ( obj == null ) + if (obj == null) return false; - if ( getClass() != obj.getClass() ) + if (getClass() != obj.getClass()) return false; StringSetAttributeTestClass other = (StringSetAttributeTestClass) obj; - if ( StringSetAttributeRenamed == null ) { - if ( other.StringSetAttributeRenamed != null ) + if (StringSetAttributeRenamed == null) { + if (other.StringSetAttributeRenamed != null) return false; - } else if ( !StringSetAttributeRenamed.equals(other.StringSetAttributeRenamed) ) + } else if (!StringSetAttributeRenamed.equals(other.StringSetAttributeRenamed)) return false; - if ( key == null ) { - if ( other.key != null ) + if (key == null) { + if (other.key != null) return false; - } else if ( !key.equals(other.key) ) + } else if (!key.equals(other.key)) return false; - if ( stringSetAttribute == null ) { - if ( other.stringSetAttribute != null ) + if (stringSetAttribute == null) { + if (other.stringSetAttribute != null) return false; - } else if ( !stringSetAttribute.equals(other.stringSetAttribute) ) + } else if (!stringSetAttribute.equals(other.stringSetAttribute)) return false; return true; } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/TestDynamoDBMapperFactory.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/TestDynamoDBMapperFactory.java index 6cb928bd..cd4a306b 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/TestDynamoDBMapperFactory.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/TestDynamoDBMapperFactory.java @@ -1,11 +1,11 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. @@ -20,13 +20,13 @@ public class TestDynamoDBMapperFactory { public static DynamoDBMapper createDynamoDBMapper(AmazonDynamoDB dynamo) { return new DynamoDBMapper(dynamo, - DynamoDBMapperConfig.DEFAULT, + DynamoDBMapperConfig.DEFAULT, new AttributeEncryptor(new TestEncryptionMaterialsProvider())); } public static DynamoDBMapper createDynamoDBMapper(AmazonDynamoDB dynamo, DynamoDBMapperConfig config) { return new DynamoDBMapper(dynamo, - config, + config, new AttributeEncryptor(new TestEncryptionMaterialsProvider())); } } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/TestEncryptionMaterialsProvider.java b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/TestEncryptionMaterialsProvider.java index b35e7063..1e00831d 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/TestEncryptionMaterialsProvider.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/mapper/encryption/TestEncryptionMaterialsProvider.java @@ -1,29 +1,28 @@ /* * Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * + * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at - * + * * http://aws.amazon.com/apache2.0 - * + * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ package com.amazonaws.services.dynamodbv2.mapper.encryption; -import java.security.Key; -import java.util.Map; - -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; - import com.amazonaws.services.dynamodbv2.datamodeling.encryption.EncryptionContext; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.DecryptionMaterials; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.materials.EncryptionMaterials; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.providers.EncryptionMaterialsProvider; import com.amazonaws.util.StringMapBuilder; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import java.security.Key; +import java.util.Map; + public class TestEncryptionMaterialsProvider implements EncryptionMaterialsProvider { private final EncryptionMaterials em = new EncryptionMaterials() { @Override @@ -41,9 +40,9 @@ public Key getSigningKey() { return new SecretKeySpec(new byte[32], "HmacSHA256"); } }; - + private final DecryptionMaterials dm = new DecryptionMaterials() { - + @Override public Map getMaterialDescription() { return new StringMapBuilder("id", "test").build(); @@ -59,7 +58,7 @@ public Key getVerificationKey() { return new SecretKeySpec(new byte[32], "HmacSHA256"); } }; - + @Override public DecryptionMaterials getDecryptionMaterials(EncryptionContext context) { return dm; diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/AttrMatcher.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/AttrMatcher.java index 1b332b1c..efb333ac 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/AttrMatcher.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/AttrMatcher.java @@ -14,28 +14,27 @@ */ package com.amazonaws.services.dynamodbv2.testing; +import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; + import java.util.Collection; import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; - -import com.amazonaws.services.dynamodbv2.model.AttributeValue; - public class AttrMatcher extends BaseMatcher> { private final Map expected; private final boolean invert; - + public static AttrMatcher invert(Map expected) { return new AttrMatcher(expected, true); } - + public static AttrMatcher match(Map expected) { return new AttrMatcher(expected, false); } - + public AttrMatcher(Map expected, boolean invert) { this.expected = expected; this.invert = invert; @@ -44,11 +43,11 @@ public AttrMatcher(Map expected, boolean invert) { @Override public boolean matches(Object item) { @SuppressWarnings("unchecked") - Map actual = (Map)item; + Map actual = (Map) item; if (!expected.keySet().equals(actual.keySet())) { return invert; } - for (String key: expected.keySet()) { + for (String key : expected.keySet()) { AttributeValue e = expected.get(key); AttributeValue a = actual.get(key); if (!attrEquals(a, e)) { @@ -96,27 +95,28 @@ public static boolean attrEquals(AttributeValue e, AttributeValue a) { } return true; } - + @Override - public void describeTo(Description description) { } - + public void describeTo(Description description) { + } + private static boolean isEqual(Object o1, Object o2) { - if(o1 == null ^ o2 == null) { + if (o1 == null ^ o2 == null) { return false; } if (o1 == o2) return true; return o1.equals(o2); } - + private static boolean isSetEqual(Collection c1, Collection c2) { - if(c1 == null ^ c2 == null) { + if (c1 == null ^ c2 == null) { return false; } if (c1 != null) { Set s1 = new HashSet(c1); Set s2 = new HashSet(c2); - if(!s1.equals(s2)) { + if (!s1.equals(s2)) { return false; } } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/AttributeValueMatcher.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/AttributeValueMatcher.java index 8da1f26e..91507701 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/AttributeValueMatcher.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/AttributeValueMatcher.java @@ -14,42 +14,42 @@ */ package com.amazonaws.services.dynamodbv2.testing; +import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; + import java.math.BigDecimal; import java.util.Collection; import java.util.HashSet; import java.util.Set; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; - -import com.amazonaws.services.dynamodbv2.model.AttributeValue; - public class AttributeValueMatcher extends BaseMatcher { private final AttributeValue expected; private final boolean invert; - + public static AttributeValueMatcher invert(AttributeValue expected) { return new AttributeValueMatcher(expected, true); } - + public static AttributeValueMatcher match(AttributeValue expected) { return new AttributeValueMatcher(expected, false); } - + public AttributeValueMatcher(AttributeValue expected, boolean invert) { this.expected = expected; this.invert = invert; } - + @Override public boolean matches(Object item) { - AttributeValue other = (AttributeValue)item; + AttributeValue other = (AttributeValue) item; return invert ^ attrEquals(expected, other); } @Override - public void describeTo(Description description) { } - + public void describeTo(Description description) { + } + public static boolean attrEquals(AttributeValue e, AttributeValue a) { if (!isEqual(e.getB(), a.getB()) || !isNumberEqual(e.getN(), a.getN()) || @@ -61,9 +61,9 @@ public static boolean attrEquals(AttributeValue e, AttributeValue a) { } return true; } - + private static boolean isNumberEqual(String o1, String o2) { - if(o1 == null ^ o2 == null) { + if (o1 == null ^ o2 == null) { return false; } if (o1 == o2) @@ -72,18 +72,18 @@ private static boolean isNumberEqual(String o1, String o2) { BigDecimal d2 = new BigDecimal(o2); return d1.equals(d2); } - + private static boolean isEqual(Object o1, Object o2) { - if(o1 == null ^ o2 == null) { + if (o1 == null ^ o2 == null) { return false; } if (o1 == o2) return true; return o1.equals(o2); } - + private static boolean isNumberEqual(Collection c1, Collection c2) { - if(c1 == null ^ c2 == null) { + if (c1 == null ^ c2 == null) { return false; } if (c1 != null) { @@ -95,21 +95,21 @@ private static boolean isNumberEqual(Collection c1, Collection c for (String s : c2) { s2.add(new BigDecimal(s)); } - if(!s1.equals(s2)) { + if (!s1.equals(s2)) { return false; } } return true; } - + private static boolean isEqual(Collection c1, Collection c2) { - if(c1 == null ^ c2 == null) { + if (c1 == null ^ c2 == null) { return false; } if (c1 != null) { Set s1 = new HashSet(c1); Set s2 = new HashSet(c2); - if(!s1.equals(s2)) { + if (!s1.equals(s2)) { return false; } } diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/DdbRecordMatcher.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/DdbRecordMatcher.java index 9c82cc98..d2e1b2cb 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/DdbRecordMatcher.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/DdbRecordMatcher.java @@ -14,25 +14,24 @@ */ package com.amazonaws.services.dynamodbv2.testing; -import java.util.Map; - +import com.amazonaws.services.dynamodbv2.model.AttributeValue; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; -import com.amazonaws.services.dynamodbv2.model.AttributeValue; +import java.util.Map; public class DdbRecordMatcher extends BaseMatcher> { private final Map expected; private final boolean invert; - + public static DdbRecordMatcher invert(Map expected) { return new DdbRecordMatcher(expected, true); } - + public static DdbRecordMatcher match(Map expected) { return new DdbRecordMatcher(expected, false); } - + public DdbRecordMatcher(Map expected, boolean invert) { this.expected = expected; this.invert = invert; @@ -41,11 +40,11 @@ public DdbRecordMatcher(Map expected, boolean invert) { @Override public boolean matches(Object item) { @SuppressWarnings("unchecked") - Map actual = (Map)item; + Map actual = (Map) item; if (!expected.keySet().equals(actual.keySet())) { return invert; } - for (String key: expected.keySet()) { + for (String key : expected.keySet()) { AttributeValue e = expected.get(key); AttributeValue a = actual.get(key); if (!AttributeValueMatcher.attrEquals(a, e)) { @@ -56,7 +55,8 @@ public boolean matches(Object item) { } @Override - public void describeTo(Description description) { } - + public void describeTo(Description description) { + } + } \ No newline at end of file diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/FakeParameters.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/FakeParameters.java index e82c2472..d2ca224d 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/FakeParameters.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/FakeParameters.java @@ -14,16 +14,16 @@ */ package com.amazonaws.services.dynamodbv2.testing; +import com.amazonaws.services.dynamodbv2.datamodeling.AttributeTransformer; +import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; +import com.amazonaws.services.dynamodbv2.model.AttributeValue; + import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Collections; import java.util.Map; -import com.amazonaws.services.dynamodbv2.datamodeling.AttributeTransformer; -import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; -import com.amazonaws.services.dynamodbv2.model.AttributeValue; - public class FakeParameters { public static AttributeTransformer.Parameters getInstance(Class clazz, Map attribs, DynamoDBMapperConfig config, String tableName, @@ -32,8 +32,8 @@ public static AttributeTransformer.Parameters getInstance(Class clazz, } public static AttributeTransformer.Parameters getInstance(Class clazz, - Map attribs, DynamoDBMapperConfig config, String tableName, - String hashKeyName, String rangeKeyName, boolean isPartialUpdate) { + Map attribs, DynamoDBMapperConfig config, String tableName, + String hashKeyName, String rangeKeyName, boolean isPartialUpdate) { // We use this relatively insane proxy setup so that modifications to the Parameters // interface doesn't break our tests (unless it actually impacts our code). @@ -42,7 +42,7 @@ public static AttributeTransformer.Parameters getInstance(Class clazz, @SuppressWarnings("unchecked") AttributeTransformer.Parameters proxyObject = (AttributeTransformer.Parameters) Proxy .newProxyInstance(AttributeTransformer.class.getClassLoader(), - new Class[] { AttributeTransformer.Parameters.class }, + new Class[]{AttributeTransformer.Parameters.class}, new ParametersInvocationHandler(fakeParams)); return proxyObject; } @@ -74,8 +74,8 @@ public Object invoke(Object obj, Method method, Object[] args) throws Throwable private final boolean isPartialUpdate; private FakeParameters(Class clazz, Map attribs, - DynamoDBMapperConfig config, String tableName, String hashKeyName, String rangeKeyName, - boolean isPartialUpdate) { + DynamoDBMapperConfig config, String tableName, String hashKeyName, String rangeKeyName, + boolean isPartialUpdate) { super(); this.clazz = clazz; this.attrs = Collections.unmodifiableMap(attribs); diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/TestDelegatedKey.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/TestDelegatedKey.java index 5f19ad64..bcde3bb2 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/TestDelegatedKey.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/TestDelegatedKey.java @@ -14,12 +14,7 @@ */ package com.amazonaws.services.dynamodbv2.testing; -import java.security.GeneralSecurityException; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; +import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DelegatedKey; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; @@ -28,14 +23,18 @@ import javax.crypto.NoSuchPaddingException; import javax.crypto.ShortBufferException; import javax.crypto.spec.IvParameterSpec; - -import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DelegatedKey; +import java.security.GeneralSecurityException; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; public class TestDelegatedKey implements DelegatedKey { private static final long serialVersionUID = 1L; private final Key realKey; - + public TestDelegatedKey(Key key) { this.realKey = key; } @@ -94,7 +93,7 @@ public byte[] wrap(Key key, byte[] additionalAssociatedData, String algorithm) t @Override public Key unwrap(byte[] wrappedKey, String wrappedKeyAlgorithm, int wrappedKeyType, - byte[] additionalAssociatedData, String algorithm) throws NoSuchAlgorithmException, NoSuchPaddingException, + byte[] additionalAssociatedData, String algorithm) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException { Cipher cipher = Cipher.getInstance(extractAlgorithm(algorithm)); cipher.init(Cipher.UNWRAP_MODE, realKey); @@ -117,7 +116,7 @@ public boolean verify(byte[] dataToSign, byte[] signature, String algorithm) { return false; } } - + private String extractAlgorithm(String alg) { if (alg.startsWith(getAlgorithm())) { return alg.substring(10); diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/BaseClass.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/BaseClass.java index 91e10dae..1533b07a 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/BaseClass.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/BaseClass.java @@ -14,14 +14,14 @@ */ package com.amazonaws.services.dynamodbv2.testing.types; -import java.util.Arrays; -import java.util.Set; - import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBVersionAttribute; +import java.util.Arrays; +import java.util.Set; + @DynamoDBTable(tableName = "TableName") public class BaseClass { @Override @@ -42,6 +42,7 @@ public int hashCode() { + ((doubleSet == null) ? 0 : doubleSet.hashCode()); return result; } + @Override public boolean equals(Object obj) { if (this == obj) @@ -81,6 +82,7 @@ public boolean equals(Object obj) { return false; return true; } + private int hashKey; private int rangeKey; private String stringValue; @@ -96,66 +98,85 @@ public boolean equals(Object obj) { public int getHashKey() { return hashKey; } + public void setHashKey(int hashKey) { this.hashKey = hashKey; } - + @DynamoDBRangeKey public int getRangeKey() { return rangeKey; } + public void setRangeKey(int rangeKey) { this.rangeKey = rangeKey; } + public String getStringValue() { return stringValue; } + public void setStringValue(String stringValue) { this.stringValue = stringValue; } + public int getIntValue() { return intValue; } + public void setIntValue(int intValue) { this.intValue = intValue; } + public byte[] getByteArrayValue() { return byteArrayValue; } + public void setByteArrayValue(byte[] byteArrayValue) { this.byteArrayValue = byteArrayValue; } + public Set getStringSet() { return stringSet; } + public void setStringSet(Set stringSet) { this.stringSet = stringSet; } + public Set getIntSet() { return intSet; } + public void setIntSet(Set intSet) { this.intSet = intSet; } + public Set getDoubleSet() { return doubleSet; } + public void setDoubleSet(Set doubleSet) { this.doubleSet = doubleSet; } + public double getDoubleValue() { return doubleValue; } + public void setDoubleValue(double doubleValue) { this.doubleValue = doubleValue; } + @DynamoDBVersionAttribute public Integer getVersion() { return version; } + public void setVersion(Integer version) { this.version = version; } + @Override public String toString() { return "BaseClass [hashKey=" + hashKey + ", rangeKey=" + rangeKey diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/BaseClassWithUnknownAttributeAnnotation.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/BaseClassWithUnknownAttributeAnnotation.java index bdc60818..2df054ca 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/BaseClassWithUnknownAttributeAnnotation.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/BaseClassWithUnknownAttributeAnnotation.java @@ -17,4 +17,5 @@ import com.amazonaws.services.dynamodbv2.datamodeling.encryption.HandleUnknownAttributes; @HandleUnknownAttributes -public class BaseClassWithUnknownAttributeAnnotation extends BaseClass {} +public class BaseClassWithUnknownAttributeAnnotation extends BaseClass { +} diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/HashKeyOnly.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/HashKeyOnly.java index 3000a2ee..05b83903 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/HashKeyOnly.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/HashKeyOnly.java @@ -17,18 +17,18 @@ import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; -@DynamoDBTable(tableName="HashKeyOnly") +@DynamoDBTable(tableName = "HashKeyOnly") public class HashKeyOnly { private String hashKey; - + public HashKeyOnly() { - + } - + public HashKeyOnly(String hashKey) { this.hashKey = hashKey; } - + @DynamoDBHashKey public String getHashKey() { return hashKey; diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/KeysOnly.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/KeysOnly.java index 576f43a9..510eb5b3 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/KeysOnly.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/KeysOnly.java @@ -18,35 +18,37 @@ import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBRangeKey; import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable; -@DynamoDBTable(tableName="TableName") +@DynamoDBTable(tableName = "TableName") public class KeysOnly { private int hashKey; private int rangeKey; - + public KeysOnly() { } - + public KeysOnly(int hashKey, int rangeKey) { this.hashKey = hashKey; this.rangeKey = rangeKey; } - + @DynamoDBRangeKey public int getRangeKey() { return rangeKey; } + public void setRangeKey(int rangeKey) { this.rangeKey = rangeKey; } - + @DynamoDBHashKey public int getHashKey() { return hashKey; } + public void setHashKey(int hashKey) { this.hashKey = hashKey; } - + @Override public int hashCode() { final int prime = 31; @@ -55,6 +57,7 @@ public int hashCode() { result = prime * result + rangeKey; return result; } + @Override public boolean equals(Object obj) { if (this == obj) diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/Mixed.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/Mixed.java index a9f64882..d5d769a1 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/Mixed.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/Mixed.java @@ -14,30 +14,30 @@ */ package com.amazonaws.services.dynamodbv2.testing.types; -import java.util.Set; - import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DoNotEncrypt; import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DoNotTouch; +import java.util.Set; + public class Mixed extends BaseClass { @Override @DoNotEncrypt public String getStringValue() { return super.getStringValue(); } - + @Override @DoNotEncrypt public double getDoubleValue() { return super.getDoubleValue(); } - + @Override @DoNotEncrypt public Set getDoubleSet() { return super.getDoubleSet(); } - + @Override @DoNotTouch public int getIntValue() { diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/SignOnly.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/SignOnly.java index 35c33938..db5c50ec 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/SignOnly.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/SignOnly.java @@ -17,4 +17,5 @@ import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DoNotEncrypt; @DoNotEncrypt -public class SignOnly extends BaseClass {} \ No newline at end of file +public class SignOnly extends BaseClass { +} \ No newline at end of file diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/SignOnlyWithUnknownAttributeAnnotation.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/SignOnlyWithUnknownAttributeAnnotation.java index 373a7d35..538c0387 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/SignOnlyWithUnknownAttributeAnnotation.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/SignOnlyWithUnknownAttributeAnnotation.java @@ -19,4 +19,5 @@ @DoNotEncrypt @HandleUnknownAttributes -public class SignOnlyWithUnknownAttributeAnnotation extends BaseClass {} +public class SignOnlyWithUnknownAttributeAnnotation extends BaseClass { +} diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/TableOverride.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/TableOverride.java index f9e6bfa7..24897829 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/TableOverride.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/TableOverride.java @@ -17,4 +17,5 @@ import com.amazonaws.services.dynamodbv2.datamodeling.encryption.TableAadOverride; @TableAadOverride(tableName = "Override") -public class TableOverride extends BaseClass {} +public class TableOverride extends BaseClass { +} diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/Untouched.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/Untouched.java index 6cbcfe7c..e08f09f2 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/Untouched.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/Untouched.java @@ -17,4 +17,5 @@ import com.amazonaws.services.dynamodbv2.datamodeling.encryption.DoNotTouch; @DoNotTouch -public class Untouched extends BaseClass {} \ No newline at end of file +public class Untouched extends BaseClass { +} \ No newline at end of file diff --git a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/UntouchedWithUnknownAttributeAnnotation.java b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/UntouchedWithUnknownAttributeAnnotation.java index c2728bb4..47ba5681 100644 --- a/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/UntouchedWithUnknownAttributeAnnotation.java +++ b/src/test/java/com/amazonaws/services/dynamodbv2/testing/types/UntouchedWithUnknownAttributeAnnotation.java @@ -19,4 +19,5 @@ @DoNotTouch @HandleUnknownAttributes -public class UntouchedWithUnknownAttributeAnnotation extends BaseClass {} \ No newline at end of file +public class UntouchedWithUnknownAttributeAnnotation extends BaseClass { +} \ No newline at end of file diff --git a/src/test/java/log4j.properties b/src/test/java/log4j.properties index ad0e4b0a..1bc93d35 100644 --- a/src/test/java/log4j.properties +++ b/src/test/java/log4j.properties @@ -1,13 +1,10 @@ log4j.rootLogger=INFO, A1 log4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout - # Print the date in ISO 8601 format log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n - # Adjust to see more / less logging #log4j.logger.httpclient.wire=TRACE log4j.logger.com.amazonaws=DEBUG - # HttpClient 4 Wire Logging # log4j.logger.org.apache.http.wire=DEBUG \ No newline at end of file