|
7 | 7 | import software.amazon.encryption.s3.materials.KmsKeyring; |
8 | 8 | import software.amazon.encryption.s3.materials.PartialRsaKeyPair; |
9 | 9 | import software.amazon.encryption.s3.materials.RsaKeyring; |
10 | | -import software.amazon.encryption.s3.model.CommitmentPolicy; |
11 | 10 | import software.amazon.encryption.s3.model.CreateClientInput; |
12 | 11 | import software.amazon.encryption.s3.model.CreateClientOutput; |
13 | 12 | import software.amazon.encryption.s3.model.EncryptionAlgorithm; |
|
26 | 25 | import java.util.Map; |
27 | 26 | import java.util.UUID; |
28 | 27 |
|
| 28 | +import static software.amazon.encryption.s3.CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT; |
| 29 | +import static software.amazon.encryption.s3.CommitmentPolicy.REQUIRE_ENCRYPT_ALLOW_DECRYPT; |
29 | 30 | import static software.amazon.encryption.s3.CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT; |
30 | 31 | import static software.amazon.encryption.s3.model.EncryptionAlgorithm.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY; |
31 | 32 |
|
@@ -95,7 +96,7 @@ public CreateClientOutput createClient(CreateClientInput input, RequestContext c |
95 | 96 |
|
96 | 97 | // Configure commitment policy if provided (FireEgg feature) |
97 | 98 | if (input.getConfig().getCommitmentPolicy() != null) { |
98 | | - CommitmentPolicy policy = getCommitmentPolicy(input); |
| 99 | + software.amazon.encryption.s3.CommitmentPolicy policy = getCommitmentPolicy(input); |
99 | 100 | clientBuilder.commitmentPolicy(policy); |
100 | 101 | } |
101 | 102 |
|
@@ -123,30 +124,26 @@ public CreateClientOutput createClient(CreateClientInput input, RequestContext c |
123 | 124 | } |
124 | 125 |
|
125 | 126 | private static AlgorithmSuite getAlgorithmSuite(CreateClientInput input) { |
126 | | - AlgorithmSuite algorithm; |
127 | 127 | if (input.getConfig().getEncryptionAlgorithm().equals(EncryptionAlgorithm.ALG_AES_256_CBC_IV16_NO_KDF)) { |
128 | | - algorithm = AlgorithmSuite.ALG_AES_256_CBC_IV16_NO_KDF; |
| 128 | + return AlgorithmSuite.ALG_AES_256_CBC_IV16_NO_KDF; |
129 | 129 | } else if (input.getConfig().getEncryptionAlgorithm().equals(EncryptionAlgorithm.ALG_AES_256_GCM_IV12_TAG16_NO_KDF)) { |
130 | | - algorithm = AlgorithmSuite.ALG_AES_256_GCM_IV12_TAG16_NO_KDF; |
| 130 | + return AlgorithmSuite.ALG_AES_256_GCM_IV12_TAG16_NO_KDF; |
131 | 131 | } else if (input.getConfig().getEncryptionAlgorithm().equals(ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY)) { |
132 | | - algorithm = AlgorithmSuite.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY; |
| 132 | + return AlgorithmSuite.ALG_AES_256_GCM_HKDF_SHA512_COMMIT_KEY; |
133 | 133 | } else { |
134 | 134 | throw new RuntimeException("Unknown encryption algorithm: " + input.getConfig().getEncryptionAlgorithm()); |
135 | 135 | } |
136 | | - return algorithm; |
137 | 136 | } |
138 | 137 |
|
139 | | - private static CommitmentPolicy getCommitmentPolicy(CreateClientInput input) { |
140 | | - CommitmentPolicy policy; |
| 138 | + private static software.amazon.encryption.s3.CommitmentPolicy getCommitmentPolicy(CreateClientInput input) { |
141 | 139 | if (input.getConfig().getCommitmentPolicy().equals(software.amazon.encryption.s3.model.CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT)) { |
142 | | - policy = CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT; |
| 140 | + return FORBID_ENCRYPT_ALLOW_DECRYPT; |
143 | 141 | } else if (input.getConfig().getCommitmentPolicy().equals(software.amazon.encryption.s3.model.CommitmentPolicy.REQUIRE_ENCRYPT_ALLOW_DECRYPT)) { |
144 | | - policy = CommitmentPolicy.REQUIRE_ENCRYPT_ALLOW_DECRYPT; |
| 142 | + return REQUIRE_ENCRYPT_ALLOW_DECRYPT; |
145 | 143 | } else if (input.getConfig().getCommitmentPolicy().equals(software.amazon.encryption.s3.model.CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT)) { |
146 | | - policy = REQUIRE_ENCRYPT_REQUIRE_DECRYPT; |
| 144 | + return REQUIRE_ENCRYPT_REQUIRE_DECRYPT; |
147 | 145 | } else { |
148 | 146 | throw new RuntimeException("Unknown commitment policy: " + input.getConfig().getCommitmentPolicy()); |
149 | 147 | } |
150 | | - return policy; |
151 | 148 | } |
152 | 149 | } |
0 commit comments