クラス SecurityContextHolderAwareRequestWrapper

java.lang.ObjectSE
jakarta.servlet.ServletRequestWrapper
jakarta.servlet.http.HttpServletRequestWrapper
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper
実装されたすべてのインターフェース:
jakarta.servlet.http.HttpServletRequestjakarta.servlet.ServletRequest

public class SecurityContextHolderAwareRequestWrapper extends jakarta.servlet.http.HttpServletRequestWrapper
Spring Security-aware HttpServletRequestWrapperSecurityContext -defined Authentication オブジェクトを使用してサーブレット API のセキュリティメソッドを実装します。
関連事項:
  • フィールドサマリー

    インターフェース jakarta.servlet.http.HttpServletRequest から継承されたフィールド

    BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
  • コンストラクターのサマリー

    コンストラクター
    コンストラクター
    説明
    SecurityContextHolderAwareRequestWrapper(jakarta.servlet.http.HttpServletRequest request, StringSE rolePrefix)
    AuthenticationTrustResolverImpl で新しいインスタンスを作成します。
    SecurityContextHolderAwareRequestWrapper(jakarta.servlet.http.HttpServletRequest request, AuthenticationTrustResolver trustResolver, StringSE rolePrefix)
    新しいインスタンスを作成します
  • メソッドのサマリー

    修飾子と型
    メソッド
    説明
    SecurityContextHolder から取得したプリンシパルの名前を返します。
    Authentication (Principal のサブクラス)、または使用できない場合は null を返します。
    boolean
    正確に一致する GrantedAuthority.getAuthority() を簡単に検索します。
    void
    使用する SecurityContextHolderStrategy を設定します。

    クラス jakarta.servlet.http.HttpServletRequestWrapper から継承されたメソッド

    authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getTrailerFields, isRequestedSessionIdFromCookie, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, login, logout, newPushBuilder, upgrade

    クラス jakarta.servlet.ServletRequestWrapper から継承されたメソッド

    getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsync

    クラス java.lang.ObjectSE から継承されたメソッド

    clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, wait, waitSE, waitSE

    インターフェース jakarta.servlet.ServletRequest から継承されたメソッド

    getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
  • コンストラクターの詳細

    • SecurityContextHolderAwareRequestWrapper

      public SecurityContextHolderAwareRequestWrapper(jakarta.servlet.http.HttpServletRequest request, StringSE rolePrefix)
      AuthenticationTrustResolverImpl で新しいインスタンスを作成します。
      パラメーター:
      request -
      rolePrefix -
    • SecurityContextHolderAwareRequestWrapper

      public SecurityContextHolderAwareRequestWrapper(jakarta.servlet.http.HttpServletRequest request, AuthenticationTrustResolver trustResolver, StringSE rolePrefix)
      新しいインスタンスを作成します
      パラメーター:
      request - 元の HttpServletRequest
      trustResolver - 使用する AuthenticationTrustResolver。null にはできません。
      rolePrefix - isUserInRole(String) に追加する接頭辞。接頭辞がない場合は null。
  • メソッドの詳細

    • getRemoteUser

      public StringSE getRemoteUser()
      SecurityContextHolder から取得したプリンシパルの名前を返します。String ベースと UserDetails ベースの両方のプリンシパルを適切に処理します。
      次で指定:
      インターフェース jakarta.servlet.http.HttpServletRequestgetRemoteUser 
      オーバーライド:
      クラス jakarta.servlet.http.HttpServletRequestWrappergetRemoteUser 
      戻り値:
      ユーザー名または使用できない場合は null 
    • getUserPrincipal

      public PrincipalSE getUserPrincipal()
      Authentication (Principal のサブクラス)、または使用できない場合は null を返します。
      次で指定:
      インターフェース jakarta.servlet.http.HttpServletRequestgetUserPrincipal 
      オーバーライド:
      クラス jakarta.servlet.http.HttpServletRequestWrappergetUserPrincipal 
      戻り値:
      Authentication または null
    • isUserInRole

      public boolean isUserInRole(StringSE role)
      正確に一致する GrantedAuthority.getAuthority() を簡単に検索します。

      SecurityContextHolder に nullprincipal および / または GrantedAuthority[] オブジェクトを含む Authentication が含まれている場合、常に false を返します。

      次で指定:
      インターフェース jakarta.servlet.http.HttpServletRequestisUserInRole 
      オーバーライド:
      クラス jakarta.servlet.http.HttpServletRequestWrapperisUserInRole 
      パラメーター:
      role - チェックする GrantedAuthorityString 表現
      戻り値:
      正確な(大文字と小文字を区別する)一致する付与された権限が見つかった場合は true、それ以外の場合は false 
    • toString

      public StringSE toString()
      オーバーライド:
      クラス ObjectSEtoString 
    • setSecurityContextHolderStrategy

      public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy)
      使用する SecurityContextHolderStrategy を設定します。デフォルトのアクションは、SecurityContextHolder に格納されている SecurityContextHolderStrategy を使用することです。
      導入:
      5.8