|
3 | 3 |
|
4 | 4 | package com.amazonaws.encryptionsdk;
|
5 | 5 |
|
6 |
| -import com.amazonaws.encryptionsdk.CryptoAlgorithm; |
7 |
| - |
8 | 6 | public enum CommitmentPolicy {
|
9 |
| - ForbidEncryptAllowDecrypt, |
10 |
| - RequireEncryptAllowDecrypt, |
11 |
| - RequireEncryptRequireDecrypt; |
| 7 | + ForbidEncryptAllowDecrypt, |
| 8 | + RequireEncryptAllowDecrypt, |
| 9 | + RequireEncryptRequireDecrypt; |
12 | 10 |
|
13 |
| - public boolean algorithmAllowedForEncrypt(CryptoAlgorithm algorithm) { |
14 |
| - switch (this) { |
15 |
| - case ForbidEncryptAllowDecrypt: |
16 |
| - return !algorithm.isCommitting(); |
17 |
| - case RequireEncryptAllowDecrypt: |
18 |
| - case RequireEncryptRequireDecrypt: |
19 |
| - return algorithm.isCommitting(); |
20 |
| - default: |
21 |
| - throw new UnsupportedOperationException("Support for commitment policy " + this + " not yet built."); |
22 |
| - } |
| 11 | + public boolean algorithmAllowedForEncrypt(CryptoAlgorithm algorithm) { |
| 12 | + switch (this) { |
| 13 | + case ForbidEncryptAllowDecrypt: |
| 14 | + return !algorithm.isCommitting(); |
| 15 | + case RequireEncryptAllowDecrypt: |
| 16 | + case RequireEncryptRequireDecrypt: |
| 17 | + return algorithm.isCommitting(); |
| 18 | + default: |
| 19 | + throw new UnsupportedOperationException( |
| 20 | + "Support for commitment policy " + this + " not yet built."); |
23 | 21 | }
|
| 22 | + } |
24 | 23 |
|
25 |
| - public boolean algorithmAllowedForDecrypt(CryptoAlgorithm algorithm) { |
26 |
| - switch (this) { |
27 |
| - case ForbidEncryptAllowDecrypt: |
28 |
| - case RequireEncryptAllowDecrypt: |
29 |
| - return true; |
30 |
| - case RequireEncryptRequireDecrypt: |
31 |
| - return algorithm.isCommitting(); |
32 |
| - default: |
33 |
| - throw new UnsupportedOperationException("Support for commitment policy " + this + " not yet built."); |
34 |
| - } |
| 24 | + public boolean algorithmAllowedForDecrypt(CryptoAlgorithm algorithm) { |
| 25 | + switch (this) { |
| 26 | + case ForbidEncryptAllowDecrypt: |
| 27 | + case RequireEncryptAllowDecrypt: |
| 28 | + return true; |
| 29 | + case RequireEncryptRequireDecrypt: |
| 30 | + return algorithm.isCommitting(); |
| 31 | + default: |
| 32 | + throw new UnsupportedOperationException( |
| 33 | + "Support for commitment policy " + this + " not yet built."); |
35 | 34 | }
|
| 35 | + } |
36 | 36 | }
|
0 commit comments