简体   繁体   中英

Why Am I Getting an IllegalStateException While Adding Bcrypt to my Spring-Security.XML file?

I have implemented bCrypt encoding on a small app I am doing. Currently, I can create a user, and encrypt the password. Prior to encryption, I could have the user login with their email address, and a plain text password stored in the DB. Now I am getting a 404 error when I simply run the application out of Eclipse.

The error only started occurring after I added the following line in my spring-security.xml file

        <password-encoder ref="encoder" />  

The error I am seeing in the console is the following.

Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder] to required type [org.springframework.security.authentication.encoding.PasswordEncoder] for property 'passwordEncoder': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)

Here is how I have Bcrypt implemented in my XML.

 <authentication-manager alias="authenticationManager">
    <authentication-provider>
    <password-encoder ref="encoder" />  
        <jdbc-user-service data-source-ref="dataSource"
            users-by-username-query="
            SELECT email as username, passwordConfig as password, active as enabled 
            FROM Employee
            WHERE email=?"
            authorities-by-username-query="
            SELECT email as username, role 
            FROM EmployeeLEFT OUTER JOIN Roles 
            ON Employee.RoleID=Roles.roleId 
            WHERE email=?" />
    </authentication-provider>
</authentication-manager>

<beans:bean id="encoder" 
class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder">
<beans:constructor-arg name="strength" value="11" />

Here are my spring libraries.

antlr-2.7.6.jar
aopalliance-1.0.jar
com.springsource.org.aopalliance-1.0.0.jar
commons-beanutils-1.9.2.jar
commons-collections-3.2.1.jar
commons-digester-2.0.jar
commons-fileupload-1.3.1.jar
commons-io-2.4.jar
commons-logging-1.1.1.jar
dom4j-1.6.1.jar
hibernate3.jar
hibernate-jpa-2.0-api-1.0.0.Final.jar
hibernate-validator-4.2.0.Final.jar
javassist-3.12.0.GA.jar
javax.servlet.jar
jbcrypt-0.3m.jar
jcl-over-slf4j-1.5.8.jar
jstl-1.2.jar
jta-1.1.jar
mail-1.4.7.jar
org.springframework.aop-3.0.5.RELEASE.jar
org.springframework.asm-3.0.5.RELEASE.jar
org.springframework.aspects-3.0.5.RELEASE.jar
org.springframework.beans-3.0.5.RELEASE.jar
org.springframework.context.support-3.0.5.RELEASE.jar
org.springframework.context-3.0.5.RELEASE.jar
org.springframework.core-3.0.5.RELEASE.jar
org.springframework.expression-3.0.5.RELEASE.jar
org.springframework.instrument.tomcat-3.0.5.RELEASE.jar
org.springframework.instrument-3.0.5.RELEASE.jar
org.springframework.jdbc-3.0.5.RELEASE.jar
org.springframework.jms-3.0.5.RELEASE.jar
org.springframework.orm-3.0.5.RELEASE.jar
org.springframework.oxm-3.0.5.RELEASE.jar
org.springframework.test-3.0.5.RELEASE.jar
org.springframework.transaction-3.0.5.RELEASE.jar
org.springframework.web.portlet-3.0.5.RELEASE.jar
org.springframework.web.servlet-3.0.5.RELEASE.jar
org.springframework.web.struts-3.0.5.RELEASE.jar
org.springframework.web-3.0.5.RELEASE.jar
slf4j-api-1.6.1.jar
slf4j-nop-1.6.1.jar
spring-beans-2.5.6.jar
spring-context-2.5.6.jar
spring-core-2.5.6.jar
spring-security-acl-3.0.5.RELEASE.jar
spring-security-aspects-3.0.5.RELEASE.jar
spring-security-cas-client-3.0.5.RELEASE.jar
spring-security-config-3.0.5.RELEASE.jar
spring-security-core-3.0.5.RELEASE.jar
spring-security-crypto-3.1.1.RELEASE.jar
spring-security-ldap-3.0.5.RELEASE.jar
spring-security-openid-3.0.5.RELEASE.jar
spring-security-taglibs-3.0.5.RELEASE.jar
spring-security-web-3.0.5.RELEASE.jar
spring-web-2.5.6.jar
spring-webmvc-portlet-2.5.6.jar
sqljdbc4.jar
tiles-api-2.2.2.jar
tiles-core-2.2.2.jar
tiles-jsp-2.2.2.jar
tiles-servlet-2.2.2.jar
tiles-template-2.2.2.jar
validation-api-1.0.0.GA.jar

我将版本更新为Spring Framework 3.2.7,现在该错误消失了。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM