【发布时间】:2016-04-16 21:40:35
【问题描述】:
这是我的安全 xml 文件。
spring-security.xml
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd">
<http auto-config="true">
<intercept-url pattern="/user**" access="ROLE_USER" />
<intercept-url pattern="/admin**" access="ROLE_ADMIN" />
<form-login
always-use-default-target="true"
login-page="/login"
default-target-url="/welcome"
login-processing-url="/checkUser"
authentication-failure-url="/login?error"
username-parameter="username"
authentication-success-handler-ref="authenticationSuccessHandler"
password-parameter="password" />
<logout logout-url="/login?logout" />
<csrf/>
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="user" password="123456" authorities="ROLE_USER" />
<user name="admin" password="123456" authorities="ROLE_ADMIN" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
这是我的 CustomAuthenticationSuccessHandler 类,这个类从 AuthenticationSuccessHandler 接口实现。
CustomAuthenticationSuccessHandler
package com.mehman.puyment.security;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
public class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
System.out.println("!***********************************************!");
}
}
【问题讨论】:
-
发布堆栈跟踪...
标签: java spring spring-mvc spring-security