ulisesbocchio / jasypt-spring-boot

Jasypt integration for Spring boot
MIT License
2.91k stars 522 forks source link

Failed to execute goal com.github.ulisesbocchio:jasypt-maven-plugin:3.0.3:decrypt,EncryptionOperationNotPossibleException #232

Closed DamonK closed 3 years ago

DamonK commented 4 years ago

My pom.xml plugins is:

<plugin>
                <groupId>com.github.ulisesbocchio</groupId>
                <artifactId>jasypt-maven-plugin</artifactId>
                <version>3.0.3</version>
</plugin>

My recurring problem execution steps:

  1. encrypt application.properties to be encrypted is as follows, aaaa=DEC(justfortest) excute jasypt:encrypt command,
    mvn jasypt:encrypt -Djasypt.encryptor.password="zasfasasdasd"

    after encryption is,

    aaaa=ENC(vFdk9FtEEFNxCEA+ODyp8TE/w0qS6niegXTSNG6uYIjQv5cmY4acr5L7rY+k1U+y)
  2. decrypt application.properties excute jasypt:decrypt command,
mvn jasypt:decrypt -Djasypt.encryptor.password="zasfasasdasd" -X 

then error occur,

[ERROR] Failed to execute goal com.github.ulisesbocchio:jasypt-maven-plugin:3.0.3:decrypt (default-cli) on project system-service: Error Decrypting: null: EncryptionOperationNotPossibleException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.ulisesbocchio:jasypt-maven-plugin:3.0.3:decrypt (default-cli) on project system-service: Error Decrypting: null
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error Decrypting: null
    at com.ulisesbocchio.jasyptmavenplugin.mojo.DecryptMojo.run (DecryptMojo.java:29)
    at com.ulisesbocchio.jasyptmavenplugin.mojo.AbstractFileJasyptMojo.run (AbstractFileJasyptMojo.java:32)
    at com.ulisesbocchio.jasyptmavenplugin.mojo.AbstractJasyptMojo.execute (AbstractJasyptMojo.java:66)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.jasypt.exceptions.EncryptionOperationNotPossibleException
    at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt (StandardPBEByteEncryptor.java:1054)
    at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt (StandardPBEStringEncryptor.java:738)
    at org.jasypt.encryption.pbe.PooledPBEStringEncryptor.decrypt (PooledPBEStringEncryptor.java:511)
    at com.ulisesbocchio.jasyptspringboot.encryptor.DefaultLazyEncryptor.decrypt (DefaultLazyEncryptor.java:57)
    at com.ulisesbocchio.jasyptmavenplugin.encrypt.EncryptionService.replaceAll (EncryptionService.java:63)
    at com.ulisesbocchio.jasyptmavenplugin.encrypt.EncryptionService.decrypt (EncryptionService.java:79)
    at com.ulisesbocchio.jasyptmavenplugin.mojo.DecryptMojo.run (DecryptMojo.java:26)
    at com.ulisesbocchio.jasyptmavenplugin.mojo.AbstractFileJasyptMojo.run (AbstractFileJasyptMojo.java:32)
    at com.ulisesbocchio.jasyptmavenplugin.mojo.AbstractJasyptMojo.execute (AbstractJasyptMojo.java:66)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
  1. excute jasypt:decrypt-value
    mvn jasypt:decrypt-value -Djasypt.encryptor.password="zasfasasdasd" -Djasypt.plugin.value="vFdk9FtEEFNxCEA+ODyp8TE/w0qS6niegXTSNG6uYIjQv5cmY4acr5L7rY+k1U+y"

    result log :

    [INFO] Decrypting value vFdk9FtEEFNxCEA+ODyp8TE/w0qS6niegXTSNG6uYIjQv5cmY4acr5L7rY+k1U+y
    [INFO] String Encryptor custom Bean not found with name 'jasyptStringEncryptor'. Initializing Default String Encryptor
    [INFO] Encryptor config not found for property jasypt.encryptor.algorithm, using default value: PBEWITHHMACSHA512ANDAES_256
    [INFO] Encryptor config not found for property jasypt.encryptor.key-obtention-iterations, using default value: 1000
    [INFO] Encryptor config not found for property jasypt.encryptor.pool-size, using default value: 1
    [INFO] Encryptor config not found for property jasypt.encryptor.provider-name, using default value: null
    [INFO] Encryptor config not found for property jasypt.encryptor.provider-class-name, using default value: null
    [INFO] Encryptor config not found for property jasypt.encryptor.salt-generator-classname, using default value: org.jasypt.salt.RandomSaltGenerator
    [INFO] Encryptor config not found for property jasypt.encryptor.iv-generator-classname, using default value: org.jasypt.iv.RandomIvGenerator
    [INFO] Encryptor config not found for property jasypt.encryptor.string-output-type, using default value: base64
    [INFO] 
    justfortest

    it works!

so, why has that happened?

rupert-madden-abbott commented 4 years ago

Are you using a multi-module project? If so this might be a duplicate of https://github.com/ulisesbocchio/jasypt-spring-boot/issues/234 and there is a workaround in the last comment.

DamonK commented 4 years ago

Are you using a multi-module project? If so this might be a duplicate of #234 and there is a workaround in the last comment.

Yeah, It is a multi-module project.

ulisesbocchio commented 3 years ago

@rupert-madden-abbott have you looked into this? Should I keep this open?