java - Jasypt org.jasypt.exceptions.EncryptionOperationNotPossibleException

标签 java spring-boot jasypt

我尝试在我的 Jasypt 中使用 3DES,但遇到异常。

但是当我使用默认算法时它工作正常

这是代码 -

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

这是一个异常(exception)

org.jasypt.exceptions.EncryptionOperationNotPossibleException: null
    at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:1055) ~[jasypt-1.9.2.jar:na]
    at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725) ~[jasypt-1.9.2.jar:na]
    at org.jasypt.encryption.pbe.PooledPBEStringEncryptor.decrypt(PooledPBEStringEncryptor.java:498) ~[jasypt-1.9.2.jar:na]
    at com.platform.core.config.PlatformEncryptionConfiguration$MyEncryptablePropertyResolver.resolvePropertyValue(PlatformEncryptionConfiguration.java:51) ~[classes/:na]
    at com.ulisesbocchio.jasyptspringboot.resolver.DefaultLazyPropertyResolver.resolvePropertyValue(DefaultLazyPropertyResolver.java:41) ~[jasypt-spring-boot-2.0.0.jar:na]
    at com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource.getProperty(EncryptablePropertySource.java:16) ~[jasypt-spring-boot-2.0.0.jar:na]
    at com.ulisesbocchio.jasyptspringboot.wrapper.EncryptableMapPropertySourceWrapper.getProperty(EncryptableMapPropertySourceWrapper.java:29) ~[jasypt-spring-boot-2.0.0.jar:na]
    at org.springframework.core.env.CompositePropertySource.getProperty(CompositePropertySource.java:59) ~[spring-core-4.3.11.RELEASE.jar:4.3.11.RELEASE]
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener$ExtendedDefaultPropertySource.getProperty(BootstrapApplicationListener.java:430) ~[spring-cloud-context-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource.getProperty(EncryptablePropertySource.java:13) ~[jasypt-spring-boot-2.0.0.jar:na]
    at com.ulisesbocchio.jasyptspringboot.wrapper.EncryptableMapPropertySourceWrapper.getProperty(EncryptableMapPropertySourceWrapper.java:29) ~[jasypt-spring-boot-2.0.0.jar:na]
    at org.springframework.boot.bind.PropertySourcesPropertyValues.getEnumerableProperty(PropertySourcesPropertyValues.java:165) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
    at org.springframework.boot.bind.PropertySourcesPropertyValues.processEnumerablePropertySource(PropertySourcesPropertyValues.java:148) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
    at org.springframework.boot.bind.PropertySourcesPropertyValues.processPropertySource(PropertySourcesPropertyValues.java:127) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
    at org.springframework.boot.bind.PropertySourcesPropertyValues.<init>(PropertySourcesPropertyValues.java:117) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
    at org.springframework.boot.bind.PropertySourcesPropertyValues.<init>(PropertySourcesPropertyValues.java:78) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
    at org.springframework.boot.bind.PropertySourcesPropertyValues.<init>(PropertySourcesPropertyValues.java:66) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
    at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.getFirstNonLoopbackHostInfo(HostInfoEnvironmentPostProcessor.java:47) ~[spring-cloud-commons-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.cloud.client.HostInfoEnvironmentPostProcessor.postProcessEnvironment(HostInfoEnvironmentPostProcessor.java:34) ~[spring-cloud-commons-1.3.0.RELEASE.jar:1.3.0.RELEASE]
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:182) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:168) ~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE]

最佳答案

如果您使用的是 TripleDES,请确保您已为 JDK 安装了 Java 加密扩展。 http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

关于java - Jasypt org.jasypt.exceptions.EncryptionOperationNotPossibleException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51223921/

相关文章:

java - 保存可跨越的字符串?

java - 如何在 Spring Boot 应用程序中动态忽略 LAZY 类型?

spring-boot - 无法使用 jasypt 和 spring boot 解密错误

java - 并行化列表时 Spark 抛出 ArrayIndexOutOfBoundsException

Java-执行流程

java - Spring Boot 下 Undertow/Wildfly 上的文件上传和可接受的错误处理

mysql - Grails Jasypt 插件 Column maxsize 总是为 mysql 创建 varchar 而不是 text

java - 在 jasypt 中扩展 EncryptablePropertyPlaceholderConfigurer

java - 更改用户配置文件 chrome selenium webdriver

spring-boot - Apache Camel 中的持久重试