Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 05 13:03
    anderius commented #233
  • Feb 23 06:00
    grapesrain opened #263
  • Feb 23 03:09
    costalopes71 commented #222
  • Feb 23 03:08
    costalopes71 commented #154
  • Feb 23 03:08
    costalopes71 commented #154
  • Feb 20 02:57
    FJiayang closed #262
  • Feb 11 10:02
    FJiayang edited #262
  • Feb 11 09:51
    FJiayang opened #262
  • Feb 10 03:48
  • Feb 10 03:35
    ulisesbocchio commented #261
  • Feb 10 03:17
    ulisesbocchio labeled #254
  • Feb 10 03:17
    ulisesbocchio commented #254
  • Feb 10 03:15
  • Feb 10 03:15

    ulisesbocchio on master

    Fix Version check in upgrade mo… Fix typo Merge pull request #233 from tk… (compare)

  • Feb 10 03:15
    ulisesbocchio closed #233
  • Feb 10 03:15
  • Feb 10 03:15

    ulisesbocchio on master

    Rename jasypt-spring-boot-start… Merge pull request #244 from fe… (compare)

  • Feb 10 03:15
    ulisesbocchio closed #244
  • Feb 10 03:12
  • Feb 10 03:12

    ulisesbocchio on master

    Fix Copy&Paste Error und docume… Merge pull request #249 from je… (compare)

Ryan Dawson
@ryandawsonuk
Previous comments in tickets on sourceforge indicate they were targetting may for a release. Think they're just running behind.
Ulises Bocchio
@ulisesbocchio
Ok thanks, good to know
BBK-PiJ-2016-11
@BBK-PiJ-2016-11
hey @ulisesbocchio, first of all -- thanks for the work put into the package so far -- is there any way to look for encryptable properties recursively in the resources directory? currently it's only picking up application.properties. I've got some other .properties files stored in directories under the resources dir..
Comven
@Comven
@EncryptablePropertySources({@EncryptablePropertySource("classpath:encrypted.properties"),
@EncryptablePropertySource("classpath:encrypted2.properties")})
BBK-PiJ-2016-11
@BBK-PiJ-2016-11
any change of some sort of wildcard being used here?
chance*
I'd like the app to be able to look inside the resources directory and all subdirectories for .properties files
without needing to specify individual property files as they might be different depending on the deployment
Ulises Bocchio
@ulisesbocchio
hey @BBK-PiJ-2016-11 the plugin decorates any existing property sources in the environment
it doesn't really look for any files
it uses whatever is loaded by Spring by default and any other property sources you may have loaded
Ulises Bocchio
@ulisesbocchio
you could do something like this @BBK-PiJ-2016-11 :
    @Bean
    public PropertySource allPropertiesSource() throws Exception {
        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        Resource[] resources = resolver.getResources("classpath*:*.properties");
        PropertySourceLoader loader = new PropertiesPropertySourceLoader();
        Function<Resource, PropertySource> toSource = resource -> {
            try {
                return loader.load(resource.getFilename(), resource).get(0);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        };
        Function<List<PropertySource>, PropertySource> collector = sources -> {
            CompositePropertySource ps = new CompositePropertySource("all properties");
            sources.forEach(ps::addPropertySource);
            return ps;
        };
        return Arrays.stream(resources).map(toSource).collect(Collectors.collectingAndThen(Collectors.toList(), collector));
    }
BBK-PiJ-2016-11
@BBK-PiJ-2016-11
thanks @ulisesbocchio, appreciate it! I'll give this a try today and let you know how I got on. =)
Ghost
@ghost~5b08154ed73408ce4f9ab57b
Hi can anyone please help, while I am loading my configration file while bootstraping my application, apllication is not starting and I am not getting any clue of error in logs

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;

import com.ulisesbocchio.jasyptspringboot.EncryptablePropertyDetector;
import com.ulisesbocchio.jasyptspringboot.EncryptablePropertyResolver;
import com.ulisesbocchio.jasyptspringboot.annotation.EncryptablePropertySource;
import com.ulisesbocchio.jasyptspringboot.annotation.EncryptablePropertySources;

/**

  • @author Ravat
    /

@Configuration
@EncryptablePropertySources({ @EncryptablePropertySource("classpath:platform-encrypted.properties") })
public class PlatformEncryptionConfiguration {

@Bean(name = "encryptablePropertyDetector")
public EncryptablePropertyDetector encryptablePropertyDetector() {
    return new MyEncryptablePropertyDetector();
}

@Bean(name="encryptablePropertyResolver")
EncryptablePropertyResolver encryptablePropertyResolver() {
    return new MyEncryptablePropertyResolver();
}

private class MyEncryptablePropertyDetector implements EncryptablePropertyDetector {
    @Override
    public boolean isEncrypted(String value) {
        if (value != null) {
            return value.startsWith("3DES@");
        }
        return false;
    }

    @Override
    public String unwrapEncryptedValue(String value) {
        return value.substring("3DES@".length());
    }
}

private class MyEncryptablePropertyResolver implements EncryptablePropertyResolver {


    private final PooledPBEStringEncryptor encryptor;

    public MyEncryptablePropertyResolver() {
        this.encryptor = new PooledPBEStringEncryptor();
        SimpleStringPBEConfig config = new SimpleStringPBEConfig();
        config.setPasswordCharArray("password".toCharArray());
        config.setAlgorithm("3DES");
        config.setKeyObtentionIterations("1000");
        config.setPoolSize(1);
        config.setProviderName("SunJCE");
        config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
        config.setStringOutputType("base64");
        encryptor.setConfig(config);
    }

    @Override
    public String resolvePropertyValue(String value) {
        if (value != null && value.startsWith("{cipher}")) {
            return encryptor.decrypt(value.substring("{cipher}".length()));
        }
        return value;
    }
}

}

in spring.factories -> org.springframework.cloud.bootstrap.BootstrapConfiguration=\

<packg>.PlatformEncryptionConfiguration.class

here are some logs
12:38:52.095 [main] DEBUG com.ulisesbocchio.jasyptspringboot.environment.StandardEncryptableEnvironment - Replacing PropertySource 'systemEnvironment' with 'systemEnvironment'
12:38:52.122 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Creating CGLIB proxy: target source is SingletonTargetSource for target object [org.springframework.core.env.MutablePropertySources@5a4aa2f2]
12:38:52.229 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: public void org.springframework.core.env.MutablePropertySources.addFirst(org.springframework.core.env.PropertySource)
12:38:52.229 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: public void org.springframework.core.env.MutablePropertySources.addLast(org.springframework.core.env.PropertySource)
12:38:52.229 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: public void org.springframework.core.env.MutablePropertySources.addBefore(java.lang.String,org.springframework.core.env.PropertySource)
12:38:52.229 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: public void org.springframework.core.env.MutablePropertySources.addAfter(java.lang.String,org.springframework.core.env.PropertySource)
12:38:52.229 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: public int org.springframework.core.env.MutablePropertySources.precedenceOf(org.springframework.core.env.PropertySource)
12:38:52.230 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: protected void org.springframework.core.env.MutablePropertySources.assertLegalRelativeAddition(java.lang.String,org.springframework.core.env.PropertySource)
12:38:52.230 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: protected void org.springframework.core.env.MutablePropertySources.removeIfPresent(org.springframework.core.env.PropertySource)
12:38:52.230 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: public org.springframework.core.env.PropertySource org.springframework.core.env.MutablePropertySources.remove(java.lang.String)
12:38:52.230 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: public org.springframework.core.env.PropertySource org.springframework.core.env.MutablePropertySources.get(java.lang.String)
12:38:52.230 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: public java.lang.String org.springframework.core.env.MutablePropertySources.toString()
12:38:52.230 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: public void org.springframework.core.env.MutablePropertySources.replace(java.lang.String,org.springframework.core.env.PropertySource)
12:38:52.230 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: public boolean org.springframework.core.env.MutablePropertySources.contains(java.lang.String)
12:38:52.230 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: public int org.springframework.core.env.MutablePropertySources.size()
12:38:52.230 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Unable to apply any optimizations to advised method: public java.util.Iterator org.springframework.core.env.MutablePropertySources.iterator()
12:38:52.230 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Found 'equals' method: public boolean java.lang.Object.equals(java.lang.Object)
12:38:52.230 [main] DEBUG org.springframework.aop.framework.CglibAopProxy - Found 'hashCode' method:
Ulises Bocchio
@ulisesbocchio
@Ravattailor I don’t see a full stack trace of the error. Can you please open an issue on github?
Ghost
@ghost~5b08154ed73408ce4f9ab57b
Sure
Ghost
@ghost~5b08154ed73408ce4f9ab57b
@ulisesbocchio , I have the reset branch and tried again after that I didn't get same Issue again
but have some doubt related to 3DES.
can you please help me on this
Daniyar Yeralin
@yeralin

Hey, guys may I ask for help?

I added com.github.ulisesbocchio:jasypt-spring-boot-starter:1.17 to Spring Boot app. I encrypted MySQL password with test, and added this JVM arg -Djasypt.encryptor.password=test.

I start my Spring Boot app, see following logs:

2018-10-12 12:30:05 INFO  EnableEncryptablePropertiesBeanFactoryPostProcessor:48 - Post-processing PropertySource instances
2018-10-12 12:30:05 INFO  EncryptablePropertySourceConverter:38 - Converting PropertySource bootstrap [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper
2018-10-12 12:30:05 INFO  EncryptablePropertySourceConverter:38 - Converting PropertySource servletConfigInitParams [org.springframework.core.env.PropertySource$StubPropertySource] to EncryptablePropertySourceWrapper
2018-10-12 12:30:05 INFO  EncryptablePropertySourceConverter:38 - Converting PropertySource servletContextInitParams [org.springframework.core.env.PropertySource$StubPropertySource] to EncryptablePropertySourceWrapper
2018-10-12 12:30:05 INFO  EncryptablePropertySourceConverter:38 - Converting PropertySource jndiProperties [org.springframework.jndi.JndiPropertySource] to EncryptablePropertySourceWrapper
2018-10-12 12:30:05 INFO  EncryptablePropertySourceConverter:38 - Converting PropertySource systemProperties [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper
2018-10-12 12:30:05 INFO  EncryptablePropertySourceConverter:38 - Converting PropertySource systemEnvironment [org.springframework.core.env.SystemEnvironmentPropertySource] to EncryptableMapPropertySourceWrapper
2018-10-12 12:30:05 INFO  EncryptablePropertySourceConverter:38 - Converting PropertySource random [org.springframework.boot.context.config.RandomValuePropertySource] to EncryptablePropertySourceWrapper
2018-10-12 12:30:05 INFO  EncryptablePropertySourceConverter:38 - Converting PropertySource springCloudClientHostInfo [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper
2018-10-12 12:30:05 INFO  EncryptablePropertySourceConverter:38 - Converting PropertySource defaultProperties [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper

But when I try to resolve my MySQL pwd:

@Value("${spring.datasource.password}")
private String password;

It never decrypts it, it is resolved as ENC(...) instead of decrypted password.

I'm very close, and I feel like I'm missing something

Daniyar Yeralin
@yeralin

resolved by upgrading to 1.18
BenEfrati
@BenEfrati
Hi, I have a problem when using jasypt and spring cloud
Inside logback.xml file I'm using springProperty.
In bootstrap phase, the property resolved (from bootstrap.yml), but after fetching configuration from config server, the property not resolved, result in <propertyName>_IS_UNDEFINED.
I think the problem is in jasypt-spring boot since the problem occurs only when adding jasypt-spring-boot-starter as a dependency.
Attached sample project:
https://github.com/BenEfrati/jasypt-logback-error/files/3168889/jasypt-logback-error.zip
BenEfrati
@BenEfrati
image
BenEfrati
@BenEfrati

Adding


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

to this sample and adding to application.yml


management:
  endpoints:
    web:
      exposure:
        include: "*"

now go to http://localhost:8080/actuator/env
as you can see, the property spring.application.name resolved from bootstrap.yml

Tomasz Siwiec
@TomaszSiwiec
Hello, is it possible to use Jasypt with spring-boot 2.1.5? If not , when we can except compatibility with that version?
Ulises Bocchio
@ulisesbocchio
I think it should be possible @TomaszSiwiec
Tomasz Siwiec
@TomaszSiwiec
When can we except official version for spring-boot 2.1.5?
Ganesh Kumar
@tmpganesh_twitter
@ulisesbocchio I’m using spring boot 1.5 + jasypt 1.12 + hikariCP. When I use EnableEncryptableProperties in main class, properties are not binding to bean, when I remove the annotation, it works. When I debug the app, I could properties are converted to EncryptableMapPropertySourceWrapper object, but properties are not binding to actual config class. Any help?
Ulises Bocchio
@ulisesbocchio
What’s hikariCP?
murali474
@murali474
hi ,
I am currently using jasypt-springboot 2.0 version to secure my db pwd. But the problem is i am getting confused which alogithm i should choose for production purpose.
Note: I am using PBEWithMD5AndDES algorithm now.
And the other question is do i need to write custom bean configuration to set provider name and other details for production purpose?
faizahmad1057
@faizahmad1057

Could anyone please help to resolve this issue.
I am getting below when I am Starting Springboot or doing Run As SpringBoot

Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : com.ulisesbocchio.jasyptspringboot.configuration.EnableEncryptablePropertiesBeanFactoryPostProcessor
at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:450)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:429)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:420)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:270)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:249)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.cisco.sbg.ces.configservice.ConfigserviceApplication.main(ConfigserviceApplication.java:16)
Caused by: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.ulisesbocchio.jasyptspringboot.configuration.EnableEncryptablePropertiesBeanFactoryPostProcessor.<clinit>(EnableEncryptablePropertiesBeanFactoryPostProcessor.java:35)

D3jank
@D3jank
When using spring functions with kafka and jasypt. The following function auto starts Looking up function 'configPropsSingleton' with acceptedOutputTypes: []. Can that be disabled?
RobWilkinsonUK
@RobWilkinsonUK
I am really struggling to use "jasypt-spring-boot-starter". I have tried debugging for over a week and not gotten anywhere. No matter what I try it does not replace the encrypted variable in a Spring Datasource. What is the best way/place to seek help/advice, please?
Ulises Bocchio
@ulisesbocchio
Hi @RobWilkinsonUK
do you get any errors? Have checked the samples repo?
Can you share a poc repo where your issue manifests?
RobWilkinsonUK
@RobWilkinsonUK

Hi Ulises: Many thanks for responding. I appreciate it. I don't get any errors other than that the password on my datasource is the encoded password. I have checked the samples.

poc repo? Forgive me. I don't know what that is. Do you mean the Pom.xml? How do I share through this chat. I apologise for not being versed in this.

I just went back to the plain jasypt example and will have to revert if you are willing to work with me.

RobWilkinsonUK
@RobWilkinsonUK

After a great deal of huffing and puffing , and at least two weeks, I got it to work. My comments are as follows:-

  1. The readme comments completely mislead me. When you state "Simply adding the starter jar jasypt-spring-boot-starter to your classpath if using @SpringBootApplication or @EnableAutoConfiguration will enable encryptable properties across the entire Spring Environment". That turned out not to be true.

Only after following the lines that were actually commented out in your sample did I get it to work.:
new SpringApplicationBuilder()
//.environment(new StandardEncryptableEnvironment())
.sources(DBH2DemoApplication.class)
.run(args);

The .environment(new StandardEncryptableEnvironment() was the key.

I still get a warning in red as follows. Do you know what this is referring to?
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils (file:/C:/Users/Rob%20Wilkinson/.m2/repository/org/springframework/spring-core/5.2.9.RELEASE/spring-core-5.2.9.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Ulises Bocchio
@ulisesbocchio
I see
While that’s true, all you need is the starter jar for most regular scenarios, look at the docs for the StandardEncryptableEnvironment. There are a few cases where the Spring BeanFactory post processor approach used by default cannot intercept properties. You’re probably in one of those cases
By poc I mean proof of concept. Basically a working repo with an app where the problem happens and I don’t have to build it myself but I can troubleshoot
RobWilkinsonUK
@RobWilkinsonUK

Hi Ulises: I wanted to take a moment to thank you for your fine work and your patience. While you did not give me a solution you did cause me to do so more work which lead me to my solution.

I don't know what I could have been doing that would have resulted in a non-regular scenario. I had a DataSource bean in an XML file that had variables that were encoded.

I am happy to spend some time trying to put a POC on Github but it will take some time for me. Additionally it will require MySQl to fully test.

Anyway, once again thank you.