protected void populateKmsEcFromEc()

in sdk1/src/main/java/com/amazonaws/services/dynamodbv2/datamodeling/encryption/providers/DirectKmsMaterialProvider.java [280:314]


  protected void populateKmsEcFromEc(EncryptionContext context, Map<String, String> kmsEc) {
    final String hashKeyName = context.getHashKeyName();
    if (hashKeyName != null) {
      final AttributeValue hashKey = context.getAttributeValues().get(hashKeyName);
      if (hashKey.getN() != null) {
        kmsEc.put(hashKeyName, hashKey.getN());
      } else if (hashKey.getS() != null) {
        kmsEc.put(hashKeyName, hashKey.getS());
      } else if (hashKey.getB() != null) {
        kmsEc.put(hashKeyName, Base64.encodeToString(toArray(hashKey.getB())));
      } else {
        throw new UnsupportedOperationException(
            "DirectKmsMaterialProvider only supports String, Number, and Binary HashKeys");
      }
    }
    final String rangeKeyName = context.getRangeKeyName();
    if (rangeKeyName != null) {
      final AttributeValue rangeKey = context.getAttributeValues().get(rangeKeyName);
      if (rangeKey.getN() != null) {
        kmsEc.put(rangeKeyName, rangeKey.getN());
      } else if (rangeKey.getS() != null) {
        kmsEc.put(rangeKeyName, rangeKey.getS());
      } else if (rangeKey.getB() != null) {
        kmsEc.put(rangeKeyName, Base64.encodeToString(toArray(rangeKey.getB())));
      } else {
        throw new UnsupportedOperationException(
            "DirectKmsMaterialProvider only supports String, Number, and Binary RangeKeys");
      }
    }

    final String tableName = context.getTableName();
    if (tableName != null) {
      kmsEc.put(TABLE_NAME_EC_KEY, tableName);
    }
  }