【问题标题】:Jasypt org.jasypt.exceptions.EncryptionOperationNotPossibleExceptionJasypt org.jasypt.exceptions.EncryptionOperationNotPossibleException
【发布时间】:2019-03-02 23:38:24
【问题描述】:

我试图在我的 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);
            }

这里是例外

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]

【问题讨论】:

  • 您使用的是哪个 jasypt 版本?根据版本,您可能还需要为您的 SimpleStringPBEConfig 提供 ivGenerator。

标签: java spring-boot jasypt


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-10
    • 2017-01-01
    • 2021-07-22
    • 1970-01-01
    • 2021-07-14
    • 1970-01-01
    • 2017-01-07
    • 2013-07-22
    相关资源
    最近更新 更多