クラス SimpleUrlAuthenticationFailureHandler
java.lang.ObjectSE
org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler
- 実装されたすべてのインターフェース:
AuthenticationFailureHandler
- 既知の直属サブクラス
ExceptionMappingAuthenticationFailureHandler
public class SimpleUrlAuthenticationFailureHandler
extends ObjectSE
implements AuthenticationFailureHandler
AuthenticationFailureHandler は、 onAuthenticationFailure メソッドが呼び出されたときに
defaultFailureUrl
プロパティの値へのリダイレクトを実行します。プロパティが設定されていない場合、失敗の原因となった AuthenticationException からのエラーメッセージとともに、401 レスポンスがクライアントに送信されます。useForward
プロパティが設定されている場合、リダイレクトではなく、宛先に対して RequestDispatcher.forward
呼び出しが行われます。
- 導入:
- 3.0
フィールドサマリー
フィールドコンストラクターのサマリー
コンストラクターメソッドのサマリー
修飾子と型メソッド説明protected RedirectStrategy
protected boolean
protected boolean
void
onAuthenticationFailure
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, AuthenticationException exception) 設定されている場合、defaultFailureUrl
へのリダイレクトまたは転送を実行します。それ以外の場合は、401 エラーコードを返します。protected final void
saveException
(jakarta.servlet.http.HttpServletRequest request, AuthenticationException exception) ビューのレンダリングで使用するためにAuthenticationException
をキャッシュします。void
setAllowSessionCreation
(boolean allowSessionCreation) void
setDefaultFailureUrl
(StringSE defaultFailureUrl) 失敗の宛先として使用される URL。void
setRedirectStrategy
(RedirectStrategy redirectStrategy) ターゲット URL にリダイレクトするときの動作をオーバーライドできます。void
setUseForward
(boolean forwardToDestination) true に設定されている場合、リダイレクトではなく、失敗した宛先 URL への転送を実行します。
フィールドの詳細
logger
protected final org.apache.commons.logging.Log logger
コンストラクターの詳細
SimpleUrlAuthenticationFailureHandler
public SimpleUrlAuthenticationFailureHandler()SimpleUrlAuthenticationFailureHandler
メソッドの詳細
onAuthenticationFailure
public void onAuthenticationFailure(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, AuthenticationException exception) throws IOExceptionSE, jakarta.servlet.ServletException 設定されている場合、defaultFailureUrl
へのリダイレクトまたは転送を実行します。それ以外の場合は、401 エラーコードを返します。リダイレクトまたは転送する場合、
saveException
が呼び出され、例外をキャッシュしてターゲットビューで使用します。- 次で指定:
- インターフェース
AuthenticationFailureHandler
のonAuthenticationFailure
- パラメーター:
request
- 認証試行が発生したリクエスト。response
- レスポンス。exception
- 認証リクエストを拒否するためにスローされた例外。- 例外:
IOExceptionSE
jakarta.servlet.ServletException
saveException
protected final void saveException(jakarta.servlet.http.HttpServletRequest request, AuthenticationException exception) ビューのレンダリングで使用するためにAuthenticationException
をキャッシュします。forwardToDestination
が true に設定されている場合、リクエストスコープが使用されます。それ以外の場合は、セッションに例外を格納しようとします。セッションがなく、allowSessionCreation
がtrue
の場合、セッションが作成されます。そうでない場合、例外は保存されません。setDefaultFailureUrl
失敗の宛先として使用される URL。- パラメーター:
defaultFailureUrl
- 障害 URL、たとえば "/loginFailed.jsp"。
isUseForward
protected boolean isUseForward()setUseForward
public void setUseForward(boolean forwardToDestination) true に設定されている場合、リダイレクトではなく、失敗した宛先 URL への転送を実行します。デフォルトは false です。setRedirectStrategy
ターゲット URL にリダイレクトするときの動作をオーバーライドできます。getRedirectStrategy
isAllowSessionCreation
protected boolean isAllowSessionCreation()setAllowSessionCreation
public void setAllowSessionCreation(boolean allowSessionCreation)