クラス ChannelProcessingFilter

java.lang.ObjectSE
org.springframework.web.filter.GenericFilterBean
org.springframework.security.web.access.channel.ChannelProcessingFilter
実装されたすべてのインターフェース:
jakarta.servlet.Filterorg.springframework.beans.factory.Awareorg.springframework.beans.factory.BeanNameAwareorg.springframework.beans.factory.DisposableBeanorg.springframework.beans.factory.InitializingBeanorg.springframework.context.EnvironmentAwareorg.springframework.core.env.EnvironmentCapableorg.springframework.web.context.ServletContextAware

public class ChannelProcessingFilter extends org.springframework.web.filter.GenericFilterBean
Web リクエストが必要なチャネルを介して確実に配信されるようにします。

内部的に FilterInvocation を使用してリクエストを表し、FilterInvocationSecurityMetadataSource を使用して適用される属性を検索できるようにします。

実際のチャネルセキュリティの決定と必要なアクションを構成済みの ChannelDecisionManager に委譲します。レスポンスが ChannelDecisionManager によってコミットされた場合、フィルターチェーンは続行されません。

最も一般的な使用箇所は、リクエストが HTTPS を介して行われるようにすることです。この場合、ChannelDecisionManagerImplSecureChannelProcessor および InsecureChannelProcessor で構成されます。典型的な構成は


 <bean id="channelProcessingFilter" class="org.springframework.security.web.access.channel.ChannelProcessingFilter">
   <property name="channelDecisionManager" ref="channelDecisionManager"/>
   <property name="securityMetadataSource">
     <security:filter-security-metadata-source request-matcher="regex">
       <security:intercept-url pattern="\A/secure/.*\Z" access="REQUIRES_SECURE_CHANNEL"/>
       <security:intercept-url pattern="\A/login.jsp.*\Z" access="REQUIRES_SECURE_CHANNEL"/>
       <security:intercept-url pattern="\A/.*\Z" access="ANY_CHANNEL"/>
     </security:filter-security-metadata-source>
   </property>
 </bean>

 <bean id="channelDecisionManager" class="org.springframework.security.web.access.channel.ChannelDecisionManagerImpl">
   <property name="channelProcessors">
     <list>
     <ref bean="secureChannelProcessor"/>
     <ref bean="insecureChannelProcessor"/>
     </list>
   </property>
 </bean>

 <bean id="secureChannelProcessor"
   class="org.springframework.security.web.access.channel.SecureChannelProcessor"/>
 <bean id="insecureChannelProcessor"
   class="org.springframework.security.web.access.channel.InsecureChannelProcessor"/>

 
これにより、ログインフォームと /secure パスへのアクセスはすべて HTTPS 経由で行われます。
  • コンストラクターの詳細

    • ChannelProcessingFilter

      public ChannelProcessingFilter()
  • メソッドの詳細

    • afterPropertiesSet

      public void afterPropertiesSet()
      次で指定:
      インターフェース org.springframework.beans.factory.InitializingBeanafterPropertiesSet 
      オーバーライド:
      クラス org.springframework.web.filter.GenericFilterBeanafterPropertiesSet 
    • 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
    • getChannelDecisionManager

      protected ChannelDecisionManager getChannelDecisionManager()
    • getSecurityMetadataSource

      protected FilterInvocationSecurityMetadataSource getSecurityMetadataSource()
    • setChannelDecisionManager

      public void setChannelDecisionManager(ChannelDecisionManager channelDecisionManager)
    • setSecurityMetadataSource

      public void setSecurityMetadataSource(FilterInvocationSecurityMetadataSource filterInvocationSecurityMetadataSource)