Skip to content

Instantly share code, notes, and snippets.

View algorythmist's full-sized avatar

Dimitri Papaioannou algorythmist

View GitHub Profile

$a_n(x)\frac{d^n y}{dx^n} +\ldots+a_1(x)\frac{dy}{dx} +a_0(x)y = f(x)$

@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}")
@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());
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) {
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) {
@Entity
public class Customer {
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
private UUID id;
private String username;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Encrypted {
}
@Service
public class AwsSdkEncryptionService implements EncryptionService {
private final AwsCrypto crypto;
private final CryptoMaterialsManager cryptoMaterialsManager;
public AwsSdkEncryptionService(CryptoMaterialsManager cryptoMaterialsManager) {
crypto = AwsCrypto.builder()
.withCommitmentPolicy(CommitmentPolicy.RequireEncryptRequireDecrypt)
@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.