Giter Site home page Giter Site logo

Comments (3)

wilemo avatar wilemo commented on May 23, 2024

I did it:

private static final String ENVIRONMENT_VALUE_PREFIX = "systemEnvironment[";
private static final String ENVIRONMENT_VALUE_SUFFIX = "]";

    @Bean
    public static StringEncryptor stringEncryptor(final Environment environment) {
        PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
        SimpleStringPBEConfig config = new SimpleStringPBEConfig();
        config.setPassword(getEnvProperty(getRequiredProperty(environment, "jasypt.encryptor.password")));
        config.setAlgorithm(getProperty(environment, "jasypt.encryptor.algorithm", "PBEWithMD5AndDES"));
        config.setKeyObtentionIterations(getProperty(environment, "jasypt.encryptor.keyObtentionIterations", "1000"));
        config.setPoolSize(getProperty(environment, "jasypt.encryptor.poolSize", "1"));
        // according Jasypt documentation, if no provider name is explicitly set, the default JVM provider will be used.
        config.setProviderName(getProperty(environment, "jasypt.encryptor.providerName", null));
        config.setSaltGeneratorClassName(getProperty(environment, "jasypt.encryptor.saltGeneratorClassname", "org.jasypt.salt.RandomSaltGenerator"));
        config.setStringOutputType(getProperty(environment, "jasypt.encryptor.stringOutputType", "base64"));
        encryptor.setConfig(config);
        return encryptor;
    }

    private static String getEnvProperty(String value) {
        final String trimmedValue = value.trim();
        if (trimmedValue.startsWith(ENVIRONMENT_VALUE_PREFIX) &&
                trimmedValue.endsWith(ENVIRONMENT_VALUE_SUFFIX)) {
            return System.getenv(value.substring(ENVIRONMENT_VALUE_PREFIX.length(),
                    (value.length() - ENVIRONMENT_VALUE_SUFFIX.length())));
        }
        return value;
    }

from jasypt-spring-boot.

wilemo avatar wilemo commented on May 23, 2024

org.springframework.context.annotation.ConfigurationClassEnhancer.intercept:350 - @bean method EnableEncryptablePropertySourcesConfiguration.enableEncryptablePropertySourcesPostProcessor is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as @Autowired, @resource and @PostConstruct within the method's declaring @configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see @bean javadoc for complete details.

from jasypt-spring-boot.

ulisesbocchio avatar ulisesbocchio commented on May 23, 2024

The method is in fact static, not sure why spring keeps showing the warning.

from jasypt-spring-boot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.