package com.jasamedika.medifirst2000.util;

import com.ulisesbocchio.jasyptspringboot.annotation.EncryptablePropertySource;
import com.ulisesbocchio.jasyptspringboot.annotation.EncryptablePropertySources;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author salmanoe
 * @version 1.0.0
 * @since 23/01/2024
 */
@Configuration
@EncryptablePropertySources({@EncryptablePropertySource("classpath:jdbc.bridging.properties"),
        @EncryptablePropertySource("classpath:jdbc.cssd.properties"),
        @EncryptablePropertySource("classpath:jdbc.development.properties"),
        @EncryptablePropertySource("classpath:jdbc.ip3rs.properties"),
        @EncryptablePropertySource("classpath:jdbc.it.properties"),
        @EncryptablePropertySource("classpath:jdbc.k3kl.properties"),
        @EncryptablePropertySource("classpath:jdbc.laundry.properties"),
        @EncryptablePropertySource("classpath:jdbc.localhost.properties"),
        @EncryptablePropertySource("classpath:jdbc.mirroring.properties"),
        @EncryptablePropertySource("classpath:jdbc.pelayanan.properties"),
        @EncryptablePropertySource("classpath:jdbc.sdm.properties"),
        @EncryptablePropertySource("classpath:jdbc.web.properties")})
public class JasyptConfig {
    @Bean
    public StringEncryptor jasyptStringEncryptor() {
        String password = System.getProperty("jasypt.encryptor.password");
        PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
        SimpleStringPBEConfig config = new SimpleStringPBEConfig();
        config.setPassword(password);
        return encryptor;
    }
}
