クラス SecurityContextHolderAwareRequestFilter
- 実装されたすべてのインターフェース:
jakarta.servlet.Filter
、org.springframework.beans.factory.Aware
、org.springframework.beans.factory.BeanNameAware
、org.springframework.beans.factory.DisposableBean
、org.springframework.beans.factory.InitializingBean
、org.springframework.context.EnvironmentAware
、org.springframework.core.env.EnvironmentCapable
、org.springframework.web.context.ServletContextAware
ServletRequest
に、サーブレット API セキュリティメソッドを実装するリクエストラッパーを設定する Filter
。SecurityContextHolderAwareRequestWrapper
は、以下の追加メソッドを提供するように拡張されています。
HttpServletRequest.authenticate(HttpServletResponse)
- ユーザーが認証されているかどうかを判断し、認証されていない場合はユーザーをログインページに送信します。setAuthenticationEntryPoint(AuthenticationEntryPoint)
を参照してください。HttpServletRequest.login(String, String)
- ユーザーがAuthenticationManager
を使用して認証できるようにします。setAuthenticationManager(AuthenticationManager)
を参照してください。HttpServletRequest.logout()
- ユーザーが Spring Security で構成されたLogoutHandler
を使用してログアウトできるようにします。setLogoutHandlers(List)
を参照してください。AsyncContext.start(Runnable)
-AsyncContext.start(Runnable)
を呼び出したスレッドで見つかったSecurityContextHolder
からSecurityContext
を、Runnable
SE を処理するスレッドに自動的にコピーします。
フィールドサマリー
クラス org.springframework.web.filter.GenericFilterBean から継承されたフィールド
logger
コンストラクターのサマリー
メソッドのサマリー
修飾子と型メソッド説明void
void
doFilter
(jakarta.servlet.ServletRequest req, jakarta.servlet.ServletResponse res, jakarta.servlet.FilterChain chain) void
setAuthenticationEntryPoint
(AuthenticationEntryPoint authenticationEntryPoint) HttpServletRequest
を Servlet 3 API と統合するときに使用するAuthenticationEntryPoint
を設定します。void
setAuthenticationManager
(AuthenticationManager authenticationManager) HttpServletRequest
を Servlet 3 API と統合するときに使用するAuthenticationManager
を設定します。void
setLogoutHandlers
(ListSE<LogoutHandler> logoutHandlers) HttpServletRequest
を Servlet 3 API と統合するときに使用するLogoutHandler
を設定します。void
setRolePrefix
(StringSE rolePrefix) void
setSecurityContextHolderStrategy
(SecurityContextHolderStrategy securityContextHolderStrategy) 使用するSecurityContextHolderStrategy
を設定します。void
setSecurityContextRepository
(SecurityContextRepository securityContextRepository) 使用するSecurityContextRepository
を設定します。void
setTrustResolver
(AuthenticationTrustResolver trustResolver) 使用するAuthenticationTrustResolver
を設定します。クラス org.springframework.web.filter.GenericFilterBean から継承されたメソッド
addRequiredProperty, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
コンストラクターの詳細
SecurityContextHolderAwareRequestFilter
public SecurityContextHolderAwareRequestFilter()
メソッドの詳細
setSecurityContextRepository
使用するSecurityContextRepository
を設定します。デフォルトではHttpSessionSecurityContextRepository
を使用します。- パラメーター:
securityContextRepository
- 使用するSecurityContextRepository
。- 導入:
- 6.0
setSecurityContextHolderStrategy
public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) 使用するSecurityContextHolderStrategy
を設定します。デフォルトのアクションは、SecurityContextHolder
に格納されているSecurityContextHolderStrategy
を使用することです。- 導入:
- 5.8
setRolePrefix
setAuthenticationEntryPoint
HttpServletRequest
を Servlet 3 API と統合するときに使用するAuthenticationEntryPoint
を設定します。具体的には、HttpServletRequest.authenticate(HttpServletResponse)
が呼び出され、ユーザーが認証されていない場合に使用されます。値が null(デフォルト)の場合、
HttpServletRequest.authenticate(HttpServletResponse)
を呼び出してもデフォルトのコンテナーの動作が保持されます。- パラメーター:
authenticationEntryPoint
- ユーザーが認証されていない場合にHttpServletRequest.authenticate(HttpServletResponse)
を呼び出すときに使用するAuthenticationEntryPoint
setAuthenticationManager
HttpServletRequest
を Servlet 3 API と統合するときに使用するAuthenticationManager
を設定します。具体的には、HttpServletRequest.login(String, String)
が呼び出されてユーザーが認証されているかどうかを判別するときに使用されます。値が null(デフォルト)の場合、
HttpServletRequest.login(String, String)
を呼び出したときのデフォルトのコンテナー動作が保持されます。- パラメーター:
authenticationManager
-HttpServletRequest.login(String, String)
を呼び出すときに使用するAuthenticationManager
setLogoutHandlers
HttpServletRequest
を Servlet 3 API と統合するときに使用するLogoutHandler
を設定します。具体的には、ユーザーをログアウトさせるためにHttpServletRequest.logout()
が呼び出されたときに使用されます。LogoutHandler
がHttpServletResponse
(予想)をコミットしない限り、ユーザーはレスポンスの処理を担当します。値が null(デフォルト)の場合、
HttpServletRequest.logout()
を呼び出したときのデフォルトのコンテナー動作が保持されます。- パラメーター:
logoutHandlers
-HttpServletRequest.logout()
を呼び出すときのList<LogoutHandler>
doFilter
public void doFilter(jakarta.servlet.ServletRequest req, jakarta.servlet.ServletResponse res, jakarta.servlet.FilterChain chain) throws IOExceptionSE, jakarta.servlet.ServletException - 例外:
IOExceptionSE
jakarta.servlet.ServletException
afterPropertiesSet
public void afterPropertiesSet() throws jakarta.servlet.ServletException- 次で指定:
- インターフェース
org.springframework.beans.factory.InitializingBean
のafterPropertiesSet
- オーバーライド:
- クラス
org.springframework.web.filter.GenericFilterBean
のafterPropertiesSet
- 例外:
jakarta.servlet.ServletException
setTrustResolver
使用するAuthenticationTrustResolver
を設定します。デフォルトはAuthenticationTrustResolverImpl
です。- パラメーター:
trustResolver
- 使用するAuthenticationTrustResolver
。null にはできません。