Java SpringPwdeCrypter如何从spring框架调用它,如下所示
我的beans spring XML配置文件中有以下内容。在这里,他们试图在运行时从属性文件中获取密码,并通过调用扩展SpringFactoryBean的类“SpringPwdeCrypterUtil”来解密密码 问题:在他们提到的带有用户和密码的属性文件中。但是密码是解密的,下面的配置会将其解密。我想知道他们(现有的prod应用程序)是如何生成密码(decrypyted)并将其放入文本文件中的 bean.xmlJava SpringPwdeCrypter如何从spring框架调用它,如下所示,java,spring,spring-mvc,jdbc,Java,Spring,Spring Mvc,Jdbc,我的beans spring XML配置文件中有以下内容。在这里,他们试图在运行时从属性文件中获取密码,并通过调用扩展SpringFactoryBean的类“SpringPwdeCrypterUtil”来解密密码 问题:在他们提到的带有用户和密码的属性文件中。但是密码是解密的,下面的配置会将其解密。我想知道他们(现有的prod应用程序)是如何生成密码(decrypyted)并将其放入文本文件中的 bean.xml <property name="password">
<property name="password">
<bean class="com.cname.SpringPwdDecrypterUtil">
<property name="password">
<value>${db.password}</value>
</property>
</bean>
</property>
你为什么认为它能保护你?我不认为它能保护你。它的设计使我能够使用spring生成加密密码。但是,根据base16 alogrithm,他们是否有其他方式加密密码?
package com.cname;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.FactoryBean;
public class SpringPwdDecrypterUtil
implements FactoryBean
{
private String password = null;
private String key = null;
public void setPassword(String password) {
this.password = password;
}
public void setKey(String key) {
this.key = key;
}
public Object getObject() {
if (StringUtils.isNotEmpty(this.key)) {
return CryptoUtils.decryptAndEncodeBase64(this.key, this.password);
}
return CryptoUtils.decryptAndEncodeBase64(this.password);
}
public Class getObjectType() {
return String.class;
}
public boolean isSingleton() {
return true;
}
}