private EncryptionMaterialsProvider decryptProvider()

in sdk1/src/main/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/store/MetaStore.java [360:383]


  private EncryptionMaterialsProvider decryptProvider(final Map<String, AttributeValue> item) {
    final Map<String, AttributeValue> plaintext = getPlainText(item);

    final String type = plaintext.get(MATERIAL_TYPE_VERSION).getS();
    final SecretKey encryptionKey;
    final SecretKey integrityKey;
    // This switch statement is to make future extensibility easier and more obvious
    switch (type) {
      case "0": // Only currently supported type
        encryptionKey =
            new SecretKeySpec(
                plaintext.get(ENCRYPTION_KEY_FIELD).getB().array(),
                plaintext.get(ENCRYPTION_ALGORITHM_FIELD).getS());
        integrityKey =
            new SecretKeySpec(
                plaintext.get(INTEGRITY_KEY_FIELD).getB().array(),
                plaintext.get(INTEGRITY_ALGORITHM_FIELD).getS());
        break;
      default:
        throw new IllegalStateException("Unsupported material type: " + type);
    }
    return new WrappedMaterialsProvider(
        encryptionKey, encryptionKey, integrityKey, buildDescription(plaintext));
  }