我想要的只是一个简单的记住我。我读http://static.springsource.org/spring-security/site/docs/3.0.x/reference/remember-me.html简单的春天<记住我/> ...请帮助
我迄今所做的:
- 创建了自己的
UserDetailsService
与休眠/ JPA工作。 我的impl。不考虑任何记得,我的东西 - 考虑配置通过appContext
<security:remember-me key="89dqj219dn910lsAc12" user-service-ref="jpaUserDetailsService" token-validity-seconds="864000"/>
- 经过,该Cookie
SPRING_SECURITY_REMEMBER_ME_COOKIE
是真正建立 - 登录到安全的网站,当我重新启动我的浏览器,它的工作原理
,我不断收到一个错误:
org.springframework.security.access.AccessDeniedException:访问被拒绝 认证对象的字符串:org.springframework.security.authentication.Rem emberMeAuthenticationToken @ 9ab72a70:负责人:[email protected]:用户名:myad;密码保护];启用:true; AccountNonExpired:true; credentialsNonExpired:true; AccountNonLocked:true;个人信息:65537; ;证书:[PROTECTED];已验证:true;详细信息:org.sprin[email protected]957e:RemoteIpAddress:127.0.0.1; SessionId:null;授予的权限:ROLE_ADMIN,ROLE_USER
这里是我的secContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<security:global-method-security pre-post-annotations="enabled">
</security:global-method-security>
<security:http use-expressions="true" access-denied-page="/accessDenied">
<security:form-login
login-page="/login"
login-processing-url="/loginProcess"
default-target-url="/intro"
authentication-failure-url="/login?login_error=1"
/>
<security:logout
logout-url="/logout"
logout-success-url="/logoutSuccess"/>
<security:intercept-url pattern="/**" access="permitAll"/>
<security:intercept-url pattern="/login" access="permitAll"/>
<security:intercept-url pattern="/styles/**" access="permitAll"/>
<security:intercept-url pattern="/scripts/**" access="permitAll"/>
<security:remember-me key="89dqj219dn910lsAc12" user-service-ref="jpaUserDetailsService"
token-validity-seconds="864000"/>
</security:http>
<security:authentication-manager alias="authenticationManager">
<security:authentication-provider user-service-ref="jpaUserDetailsService">
<security:password-encoder hash="sha">
</security:password-encoder>
</security:authentication-provider>
</security:authentication-manager>
<bean id="rememberMeFilter" class=
"org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter">
<property name="rememberMeServices" ref="rememberMeServices"/>
<property name="authenticationManager" ref="authenticationManager"/>
</bean>
<bean id="rememberMeServices" class=
"org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices">
<property name="userDetailsService" ref="jpaUserDetailsService"/>
<property name="key" value="89dqj219dn910lsAc12"/>
</bean>
<bean id="rememberMeAuthenticationProvider" class=
"org.springframework.security.authentication.RememberMeAuthenticationProvider">
<property name="key" value="89dqj219dn910lsAc12"/>
</bean>
</beans>
最后一些调试跟踪
03:45:14.598 [[email protected]] DEBUG o.s.w.b.a.s.HandlerMethodInvoker - Invoking request handler method: public java.lang.String de.myapp.controller.bstController.showbstpage(java.lang.String,javax.servlet.http.HttpServletResponse)
03:45:14.598 [[email protected]] DEBUG o.s.s.a.i.a.MethodSecurityInterceptor - Secure object: ReflectiveMethodInvocation: public java.lang.String de.myapp.controller.bstController.showbstpage(java.lang.String,javax.servlet.http.HttpServletResponse); target is of class [de.myapp.controller.bstController]; Attributes: [[authorize: 'isFullyAuthenticated() and #username == principal.username', filter: 'null', filterTarget: 'null']]
03:45:14.598 [[email protected]] DEBUG o.s.s.a.i.a.MethodSecurityInterceptor - Previously Authenticated: org.spring[email protected]9ab72a70: Principal: [email protected]: Username: myad; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; PersonalInformation: 65537; ; Credentials: [PROTECTED]; Authenticated: true; Details: org.sprin[email protected]957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: ROLE_ADMIN, ROLE_USER
03:45:14.599 [[email protected]] DEBUG o.s.c.c.s.GenericConversionService - Converting value false of [TypeDescriptor java.lang.Boolean] to [TypeDescriptor java.lang.Boolean]
03:45:14.599 [[email protected]] TRACE o.s.c.c.s.GenericConversionService - Matched cached converter NO_OP
03:45:14.599 [[email protected]tp-10131947-7] DEBUG o.s.c.c.s.GenericConversionService - Converted to false
03:45:14.599 [[email protected]] DEBUG o.s.s.access.vote.AffirmativeBased - Voter: org.springframewor[email protected]a866a9, returned: -1
03:45:14.599 [[email protected]] DEBUG o.s.s.access.vote.AffirmativeBased - Voter: [email protected], returned: 0
03:45:14.599 [[email protected]] DEBUG o.s.s.access.vote.AffirmativeBased - Voter: [email protected]d6f, returned: 0
我真的不知道从哪里继续调试。我错过了什么?我是否必须创建自己的记住我的实现?
我真的欣赏演示泉记得,我的默认实现工作示例应用程序...
-------- ----------编辑 -
我刚编译并运行springsecurity本身的记忆我参考应用程序:spring-security\samples\tutorial
帐户应用程序和联系人应用程序。其实我有完全一样的问题?!?。我已经尝试过Firefox,Opera和ie ...我破碎了...