All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ulisesbocchio.jasyptspringboot.configuration.EnableEncryptablePropertiesConfiguration Maven / Gradle / Ivy

The newest version!
package com.ulisesbocchio.jasyptspringboot.configuration;

import com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter;
import lombok.extern.slf4j.Slf4j;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.config.StringPBEConfig;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertySource;

/**
 * 

Configuration class that registers a {@link org.springframework.beans.factory.config.BeanFactoryPostProcessor} that wraps all {@link org.springframework.core.env.PropertySource} defined in the {@link org.springframework.core.env.Environment} * with {@link com.ulisesbocchio.jasyptspringboot.wrapper.EncryptablePropertySourceWrapper} and defines a default {@link org.jasypt.encryption.StringEncryptor} for decrypting properties * that can be configured through the same properties it wraps.

*

The {@link org.jasypt.encryption.StringEncryptor} bean is only defined when no other * bean of type {@link org.jasypt.encryption.StringEncryptor} is present in the Application Context, thus allowing for custom definition if required.

*

The default {@link org.jasypt.encryption.StringEncryptor} can be configured through the following properties:

* * * * * * * * * * * * * * * * * * * * * * * * * * * *
KeyRequiredDefault Value
jasypt.encryptor.passwordTrue -
jasypt.encryptor.algorithmFalsePBEWITHHMACSHA512ANDAES_256
jasypt.encryptor.keyObtentionIterationsFalse1000
jasypt.encryptor.poolSizeFalse1
jasypt.encryptor.providerNameFalseSunJCE
jasypt.encryptor.saltGeneratorClassnameFalseorg.jasypt.salt.RandomSaltGenerator
jasypt.encryptor.ivGeneratorClassnameFalseorg.jasypt.iv.RandomIvGenerator
jasypt.encryptor.stringOutputTypeFalsebase64
* *

For mor information about the configuration properties

* * @author Ulises Bocchio * @see StringPBEConfig * @version $Id: $Id */ @Configuration @Import({EncryptablePropertyResolverConfiguration.class, CachingConfiguration.class}) @Slf4j public class EnableEncryptablePropertiesConfiguration { /** *

enableEncryptablePropertySourcesPostProcessor.

* * @param environment a {@link org.springframework.core.env.ConfigurableEnvironment} object * @param converter a {@link com.ulisesbocchio.jasyptspringboot.EncryptablePropertySourceConverter} object * @return a {@link com.ulisesbocchio.jasyptspringboot.configuration.EnableEncryptablePropertiesBeanFactoryPostProcessor} object */ @Bean public static EnableEncryptablePropertiesBeanFactoryPostProcessor enableEncryptablePropertySourcesPostProcessor(final ConfigurableEnvironment environment, EncryptablePropertySourceConverter converter) { return new EnableEncryptablePropertiesBeanFactoryPostProcessor(environment, converter); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy