クラス DelegatingMissingAuthorityAccessDeniedHandler
java.lang.ObjectSE
org.springframework.security.web.access.DelegatingMissingAuthorityAccessDeniedHandler
- 実装されているすべてのインターフェース:
AccessDeniedHandler
public final class DelegatingMissingAuthorityAccessDeniedHandler
extends ObjectSE
implements AccessDeniedHandler
An
AccessDeniedHandler that adapts AuthenticationEntryPoint s based on missing GrantedAuthority s. These authorities are specified in an AuthorityAuthorizationDecision inside an AuthorizationDeniedException .This is helpful in adaptive authentication scenarios where an AuthorizationManager indicates additional authorities needed to access a given resource.
For example, if an AuthorizationManager states that to access the home page, the user needs the FACTOR_OTT authority, then this handler can be configured in the following way to redirect to the one-time-token login page:
AccessDeniedHandler handler = DelegatingMissingAuthorityAccessDeniedHandler.builder() .addEntryPointFor(new LoginUrlAuthenticationEntryPoint("/login"), GrantedAuthorities.FACTOR_OTT_AUTHORITY) .addEntryPointFor(new MyCustomEntryPoint(), GrantedAuthorities.FACTOR_PASSWORD_AUTHORITY) .build(); ネストされたクラスの要約
ネストされたクラス修飾子と型クラス説明static final classA builder for configuring the set of authority/entry-point pairsメソッドのサマリー
修飾子と型メソッド説明builder()voidhandle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, AccessDeniedException denied) アクセス拒否エラーを処理します。voidsetDefaultAccessDeniedHandler(AccessDeniedHandler defaultAccessDeniedHandler) Use thisAccessDeniedHandlerforAccessDeniedExceptions that this handler doesn't support.voidsetRequestCache(RequestCache requestCache) Use thisRequestCacheto remember the current request.
メソッドの詳細
handle
public void handle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, AccessDeniedException denied) throws IOExceptionSE, jakarta.servlet.ServletException インターフェースからコピーされた説明:AccessDeniedHandlerアクセス拒否エラーを処理します。- 次で指定:
- インターフェース
AccessDeniedHandlerのhandle - パラメーター:
request-AccessDeniedExceptionが発生したリクエストresponse- ユーザーエージェントに障害を通知できるようにするためdenied- 呼び出しの原因となった例外- 例外:
IOExceptionSE- IOException が発生した場合jakarta.servlet.ServletException- ServletException の場合
setDefaultAccessDeniedHandler
Use thisAccessDeniedHandlerforAccessDeniedExceptions that this handler doesn't support. By default, this usesAccessDeniedHandlerImpl。- パラメーター:
defaultAccessDeniedHandler- 使用するデフォルトのAccessDeniedHandler
setRequestCache
Use thisRequestCacheto remember the current request.Uses
NullRequestCacheby default- パラメーター:
requestCache- 使用するRequestCache
builder