Using InMemoryDaoImpl in spring security
I am trying to implement custom filter , authentication provider to authenticate users directly from requests . However I am getting the following the exception .
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'signedRequestAuthenticationProvider' defined in ServletContext resource [/WEB-INF/applicationContext.xml]:
Cannot resolve reference to bean 'org.springframework.security.core.userdetails.memory.InMemoryDaoImpl'
while setting bean
property 'userDetailsService'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.security.core.userdetails.memory.InMemoryDaoImpl'
is defined at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
My application context is
<bean id="signedRequestAuthenticationProvider" class="src.SignedUsernamePasswordAuthenticationProvider">
<property name="userDetailsService" ref="org.springframework.security.core.userdetails.memory.InMemoryDaoImpl"/>
</bean>
My security.xml reads
<http auto-config="true" use-expressions="tr开发者_运维问答ue">
<intercept-url pattern="/login*" access="hasRole('ROLE_ANONYMOUS')"/>
<intercept-url pattern="/*" access="hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')"/>
<form-login login-page="/login.jsp"/>
<custom-filter ref="requestHeaderFilter" before="FORM_LOGIN_FILTER"/>
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider ref="signedRequestAuthenticationProvider"/>
<authentication-provider>
<user-service>
<user authorities="ROLE_USER" name="guest" password="guest"/>
<user authorities="ROLE_ADMIN" name="vinoth" password="vinoth"/>
</user-service>
</authentication-provider>
</authentication-manager>
Am I missing something ?
org.springframework.security.core.userdetails.memory.InMemoryDaoImpl
is not a bean identifier, therefore you can't use it in ref
attribute. You need to introduce identifier explicitly with id
:
<bean id="signedRequestAuthenticationProvider" class="src.SignedUsernamePasswordAuthenticationProvider">
<property name="userDetailsService" ref="userService"/>
</bean>
<authentication-manager alias="authenticationManager">
<authentication-provider ref="signedRequestAuthenticationProvider"/>
<authentication-provider>
<user-service id = "userService">
<user authorities="ROLE_USER" name="guest" password="guest"/>
<user authorities="ROLE_ADMIN" name="vinoth" password="vinoth"/>
</user-service>
</authentication-provider>
</authentication-manager>
精彩评论