2016-05-11 12 views
1

ログインとログアウトのページで、私のSpring-MVCで別のユーザー名を使用したいと思っています。UsernamePasswordAuthenticationFilterクラスのメソッドをオーバーライドすると、春のセキュリティでエラーが表示される

私はリンクの下から研究していると私は春4.2.5使用しています:

http://www.raistudies.com/spring-security-tutorial/role-based-spring-jsp-taglibs/

が、私のクラスのいずれかがエラーを示している。

public class AjaxAuthenticationProcessingFilter extends 
UsernamePasswordAuthenticationFilter { 

    @Override 
    protected void successfulAuthentication(HttpServletRequest request, 
      HttpServletResponse response, Authentication authResult) 
      throws IOException, ServletException { 
     super.successfulAuthentication(request, response, authResult); 
    } 
} 

Eclipseの鍛えコンパイル時エラーをオンメソッド

The method successfulAuthentication(HttpServletRequest, HttpServletResponse, Authentication) of type AjaxAuthenticationProcessingFilter must override or implement a supertype method

と他のエラーは私がsuccessfulAuthenticationメソッド スーパークラスsuper.successfulAuthentication(request, response, authResult);を呼び出します。

あなたはエラーが下記の見ることができます:

The method successfulAuthentication(HttpServletRequest, HttpServletResponse, FilterChain, Authentication) in the type AbstractAuthenticationProcessingFilter is not applicable for the arguments (HttpServletRequest, HttpServletResponse, Authentication)

誰もが異なる役割を持つ別のユーザーを実装するために春のセキュリティのための任意のリンクを知っているならば、私は春-XML設定の助けを借りてお知らせください。

+0

助けのためのあなたの輸入 –

答えて

1

以下のコードを試してください。インポートを確認してください。

、主に

successfulAuthentication(HttpServletRequest request, 
      HttpServletResponse response,Authentication authResult) 

推奨されていません。

使用

successfulAuthentication(HttpServletRequest request, 
      HttpServletResponse response,FilterChain a, Authentication authResult) 

最後に、

import java.io.IOException; 

import javax.servlet.FilterChain; 
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.UsernamePasswordAuthenticationFilter; 

public class AjaxAuthenticationProcessingFilter extends 
UsernamePasswordAuthenticationFilter { 

    @Override 
    protected void successfulAuthentication(HttpServletRequest request, 
      HttpServletResponse response,FilterChain filter, Authentication authResult) 
      throws IOException, ServletException { 
     super.successfulAuthentication(request, response,filter, authResult); 

    } 

} 
+0

ありがとうを表示... –

+0

uは任意の便利を知っていれば私はまだ私の春のセキュリティアプリでいくつかのエラーを取得していますスプリングセキュリティの基礎のリンクを教えてください。 –

+0

実際に春のセキュリティのためには、春のドキュメントを参照する必要があります。セキュリティまたはoauthについて説明する特定のサイトはありません。 –

関連する問題