This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Configuration | |
| public class EncryptionConfig { | |
| private static final String AWS_LOCALSTACK_ENDPOINT = "http://127.0.0.1:4566"; | |
| private static final String AWS_REGION = "us-east-1"; | |
| @Value("${aws.security.cache.capacity:100}") | |
| private int cacheCapacity; | |
| @Value("${aws.security.cache.maxMessages:100}") | |
| private int maxEntryMessages; | |
| @Value("${aws.security.cache.maxAge:1000}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| void saveEncryptDecrypt() { | |
| String ssn = "123-45-6789"; | |
| String phoneNumber = "(999) 999-9999"; | |
| String username = "a_user"; | |
| var customer = createCustomer(username, ssn, phoneNumber); | |
| customerService.save(customer); | |
| var found = customerService.getByName(username); | |
| assertEquals(username, found.getUsername()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HibernateDecryptListener implements PostLoadEventListener { | |
| private final BeanUtil beanUtil = BeanUtil.declaredForcedSilent; | |
| private final EncryptionService encryptionService; | |
| private final AnnotatedFieldProvider annotatedFieldProvider; | |
| @Override | |
| public void onPostLoad(PostLoadEvent event) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HibernateEncryptListener implements PreInsertEventListener, PreUpdateEventListener { | |
| private final BeanUtil beanUtil = BeanUtil.declaredForcedSilent; | |
| private final EncryptionService encryptionService; | |
| private final AnnotatedFieldProvider annotatedFieldProvider; | |
| @Override | |
| public boolean onPreInsert(PreInsertEvent event) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Entity | |
| public class Customer { | |
| @Id | |
| @GeneratedValue(generator = "uuid") | |
| @GenericGenerator(name = "uuid", strategy = "uuid2") | |
| private UUID id; | |
| private String username; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Target(ElementType.FIELD) | |
| @Retention(RetentionPolicy.RUNTIME) | |
| public @interface Encrypted { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Service | |
| public class AwsSdkEncryptionService implements EncryptionService { | |
| private final AwsCrypto crypto; | |
| private final CryptoMaterialsManager cryptoMaterialsManager; | |
| public AwsSdkEncryptionService(CryptoMaterialsManager cryptoMaterialsManager) { | |
| crypto = AwsCrypto.builder() | |
| .withCommitmentPolicy(CommitmentPolicy.RequireEncryptRequireDecrypt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Configuration | |
| public class EncryptionConfig { | |
| private static final String AWS_LOCALSTACK_ENDPOINT = "http://127.0.0.1:4566"; | |
| private static final String AWS_REGION = "us-east-1"; | |
| @Value("${aws.security.cache.capacity:100}") | |
| private int cacheCapacity; | |
| @Value("${aws.security.cache.maxMessages:100}") | |
| private int maxEntryMessages; | |
| @Value("${aws.security.cache.maxAge:1000}") |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder