-->

无法使用jasypt DB登录(Unable to login DB using jasypt)

2019-10-28 19:19发布

嗨,我在我的春节,启动应用程序中使用下面的Maven的依赖。

<dependency>
    <groupId>com.github.ulisesbocchio</groupId>
    <artifactId>jasypt-spring-boot-starter</artifactId>
    <version>1.16</version>
</dependency>

我使用下面的命令来加密我的数据库密码。

encrypt input="test" password=test algorithm=PBEWithMD5AndDES

在我的application.properties,我有如下特性,

spring.datasource.url=jdbc:sqlserver://localhost:1234;database=TEST_DB
spring.datasource.username=test
spring.datasource.password=ENC(OPdJ9jOw7tbJR+MlptpCHg==)
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.poolName=SpringBootHikariCP
spring.datasource.maximumPoolSize=50
spring.datasource.minimumIdle=30
spring.datasource.maxLifetime=2000000
spring.datasource.connectionTimeout=30000
spring.datasource.idleTimeout=30000
spring.datasource.pool-prepared-statements=true
spring.datasource.max-open-prepared-statements=250

在我的应用程序代码中,我能够得到spring.datasource.password属性的解密值。 但是当我使用JDBCTemplate ,我收到例外以下。

编辑:

误加错堆栈跟踪。 下面是正确的。 由于3次不成功的尝试,密码过期得到。

[ERROR] 2018-09-03 04:50:45.578 [https-jsse-nio-8092-exec-9] util -  LOG  : Class :Controller|| Method :process || org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'test'. ClientConnectionId:ba0abe4d-014a-42d3-b39e-ec1efc0e7131
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:394)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:474)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:484)
at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:494)
at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:500)
at com.test.dao.AppDaoImpl.generateQuery(AppDaoImpl.java:77)
at com.test.dao.AppDaoImpl$$FastClassBySpringCGLIB$$5d4e5540.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
at com.test.dao.AppDaoImpl$$EnhancerBySpringCGLIB$$eb86c18b.generateQuery(<generated>)

它是不是能够登录到数据库。 下面是我AppDaoImpl.java

    @Repository
public class AppDaoImpl implements AppDao {

    @Autowired
    JdbcTemplate jdbcTemplate;

    @Override
    public Integer generateQuery(String id) throws ImpsException {
        return jdbcTemplate.update(QueryConst.SQL_INSERT_QUERY, id);
    }
    }

jasypt之前,我只是自动装配我的JdbcTemplate,一切工作正常。 现在,它是无法登录。

PS:我正在我的应用

-Djasypt.encryptor.password=test -Djasypt.encryptor.algorithm=PBEWithMD5AndDES

Answer 1:

从消息Reason: The password of the account has expired. 其明确表示,密码已经过期。

登录到SQL服务器的系统管理员。 更改密码别的东西。 确保强制执行的密码策略是关闭的,然后更改密码回原始密码。

要么

右键点击“用户名”和去属性

您可以找到“强制密码过期”上登录属性窗口,这就需要将选中。



文章来源: Unable to login DB using jasypt