2011-03-27 52 views

回答

0

通過爲AbstractAuthenticationProcessingFilter的文檔閱讀(根據你剛纔的問題,我想這是您的自定義過濾器擴展的類),其接收的HttpServletRequest和HttpServletResponse作爲參數,以實現抽象方法是attemptAuthentication,:

Parameters: 
    request - from which to extract parameters and perform the authentication 
    response - the response, which may be needed if the implementation has to do a redirect as part of a multi-stage authentication process (such as OpenID). 
1

這不是一個真正的Spring Security特有的問題,因爲您可能只是實現了javax.servlet.Filter接口。在這種情況下,您所用的方法:

public void doFilter (ServletRequest request, ServletResponse response, 
    FilterChain chain) throws IOException, ServletException; 

您可以再鑄造ServletRequestHttpServletRequest如果你需要特定的HTTP數據(通常是必需的):

import javax.servlet.http.HttpServletRequest; 
// ... 
HttpServletRequest httpRequest = (HttpServletRequest) request; 
String xml = httpRequest.getParameter("xml"); 

如果你是擴展其中一個標準的Spring Security過濾器,確保你看看你正在擴展的過濾器的源代碼!他們中的許多人已經覆蓋doFilter,並期望你會覆蓋另一種方法來增強他們的行爲。

相關問題