jp.terasoluna.fw.web.thin
クラス AuthenticationControlFilter

java.lang.Object
  上位を拡張 jp.terasoluna.fw.web.thin.AbstractControlFilter<AuthenticationController>
      上位を拡張 jp.terasoluna.fw.web.thin.AuthenticationControlFilter
すべての実装されたインタフェース:
javax.servlet.Filter

public class AuthenticationControlFilter
extends AbstractControlFilter<AuthenticationController>

ログオン済みかどうかのチェックを行う。

このクラスではブラウザからのリクエストに対するフィルタ処理を、 Bean定義ファイルで指定された任意のAuthenticationController インスタンスにログオン済みかどうかのチェック処理を委譲する。

ログオンチェック機能

ログオンが必要なパスへのアクセスがあった場合は、 ユーザがログオン済みか どうかを判別し、ログオン済みではなかった場合、 UnauthenticatedExceptionをスローする。

使用方法

この機能を使用するには デプロイメントディスクリプタ(web.xml)と Bean定義ファイルに以下のように設定する。 このとき、Bean定義ファイルに定義するid属性が、 sampleAuthenticationControllerである<bean>要素の class属性には、AuthenticationControllerインタフェースを 実装したクラスを設定する。

デプロイメントディスクリプタ(web.xml)
 <filter>
   <filter-name>
     authenticationControlFilter
   </filter-name>
   <filter-class>
     jp.terasoluna.fw.web.thin.AuthenticationControlFilter
   </filter-class>
   <init-param>
     <param-name>controller</param-name>
     <param-value>
       "sampleAuthenticationController"
     </param-value>
   </init-param>
 </filter>
 
 <filter-mapping>
   <filter-name>authenticationControlFilter</filter-name>
   <url-pattern>/*</url-pattern>
 </filter-mapping>
 
 <error-page>
   <exception-type>
     jp.terasoluna.fw.web.thin.UnauthenticationException
   </exception-type>
   <location>/unauthenticatedError.jsp</location>
 </error-page>
 
 
Bean定義ファイル
 <bean id="sampleAuthenticationController"
       class="jp.terasoluna…SampleAuthenticationController"/>
 
なお、Bean定義ファイルに定義する<bean>要素のid属性をデフォルト値である "authenticationController"に設定する場合には、デプロイメントディスクリプタ (web.xml)内の<filter>要素から<init-param>要素を省略することが できる。

関連項目:
AuthenticationController, BlockageControlFilter, BlockageController, ServerBlockageControlFilter, ServerBlockageController

フィールドの概要
private static java.lang.Class AUTHENTICATION_CONTROLLER_CLASS
          ログオン済みチェック処理を委譲するコントローラクラス。
private static java.lang.String AUTHENTICATION_CONTROLLER_ERROR
          オーセンティケーションコントローラの生成失敗を示すエラーコード。
static java.lang.String AUTHENTICATION_THRU_KEY
          リクエストがフィルタを通過したことを示すリクエスト属性のキー。
protected static AuthenticationController controller
          AuthenticationControllerインスタンス。
static java.lang.String DEFAULT_AUTHENTICATION_BEAN_ID
          DIコンテナからコントローラーの実装クラスを取得するための <bean>要素のid属性に使用されるデフォルトid。
private static org.apache.commons.logging.Log log
          ログクラス。
 
クラス jp.terasoluna.fw.web.thin.AbstractControlFilter から継承されたフィールド
config
 
コンストラクタの概要
AuthenticationControlFilter()
           
 
メソッドの概要
 void doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain)
          ログオン済みチェックを行う。
static AuthenticationController getAuthenticationController()
          AuthenticationControllerインスタンスを戻す。
protected  java.lang.Class getControllerClass()
          アクセス制御を行うクラスが実装すべきインタフェースを返す。
 java.lang.String getDefaultControllerBeanId()
          DIコンテナからコントローラを取得する際のデフォルトのidを返す。
protected  java.lang.String getErrorCode()
          コントローラの生成失敗を示すエラーコードを返す。
 void init(javax.servlet.FilterConfig config)
          フィルタがサービス開始状態になる際に、コンテナによって呼び出される。
 
クラス jp.terasoluna.fw.web.thin.AbstractControlFilter から継承されたメソッド
destroy, getController, setConfig
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

AUTHENTICATION_THRU_KEY

public static final java.lang.String AUTHENTICATION_THRU_KEY
リクエストがフィルタを通過したことを示すリクエスト属性のキー。

関連項目:
定数フィールド値

DEFAULT_AUTHENTICATION_BEAN_ID

public static final java.lang.String DEFAULT_AUTHENTICATION_BEAN_ID
DIコンテナからコントローラーの実装クラスを取得するための <bean>要素のid属性に使用されるデフォルトid。

関連項目:
定数フィールド値

AUTHENTICATION_CONTROLLER_ERROR

private static final java.lang.String AUTHENTICATION_CONTROLLER_ERROR
オーセンティケーションコントローラの生成失敗を示すエラーコード。

関連項目:
定数フィールド値

AUTHENTICATION_CONTROLLER_CLASS

private static final java.lang.Class AUTHENTICATION_CONTROLLER_CLASS
ログオン済みチェック処理を委譲するコントローラクラス。


log

private static org.apache.commons.logging.Log log
ログクラス。


controller

protected static AuthenticationController controller
AuthenticationControllerインスタンス。

コンストラクタの詳細

AuthenticationControlFilter

public AuthenticationControlFilter()
メソッドの詳細

getAuthenticationController

public static AuthenticationController getAuthenticationController()
AuthenticationControllerインスタンスを戻す。

戻り値:
このフィルタに設定されているAuthenticationControllerインスタンス

init

public void init(javax.servlet.FilterConfig config)
          throws javax.servlet.ServletException
フィルタがサービス開始状態になる際に、コンテナによって呼び出される。 コンテナは、Filterをインスタンス化した後に、initメソッドを 1 回だけ呼び出す。
Filterにフィルタ処理作業を実行するように要求するには、 init メソッドが正常に 終了していなければならない。 initメソッドが 次のいずれかの状態の場合、コンテナは Filterをサービス状態にできない。

定義:
インタフェース javax.servlet.Filter 内の init
オーバーライド:
クラス AbstractControlFilter<AuthenticationController> 内の init
パラメータ:
config - FilterConfigインスタンス。
例外:
javax.servlet.ServletException - 初期化異常時にスローされる例外。
関連項目:
Filter.init(javax.servlet.FilterConfig), AbstractControlFilter

doFilter

public void doFilter(javax.servlet.ServletRequest req,
                     javax.servlet.ServletResponse res,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
ログオン済みチェックを行う。

定義:
インタフェース javax.servlet.Filter 内の doFilter
定義:
クラス AbstractControlFilter<AuthenticationController> 内の doFilter
パラメータ:
req - HTTPリクエスト
res - HTTPレスポンス
chain - フィルタチェーン
例外:
java.io.IOException - I/Oエラー
javax.servlet.ServletException - サーブレット例外
関連項目:
Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)

getControllerClass

protected java.lang.Class getControllerClass()
アクセス制御を行うクラスが実装すべきインタフェースを返す。

定義:
クラス AbstractControlFilter<AuthenticationController> 内の getControllerClass
戻り値:
このフィルタで使用するコントローラのクラス

getErrorCode

protected java.lang.String getErrorCode()
コントローラの生成失敗を示すエラーコードを返す。

定義:
クラス AbstractControlFilter<AuthenticationController> 内の getErrorCode
戻り値:
エラーコード

getDefaultControllerBeanId

public java.lang.String getDefaultControllerBeanId()
DIコンテナからコントローラを取得する際のデフォルトのidを返す。

定義:
クラス AbstractControlFilter<AuthenticationController> 内の getDefaultControllerBeanId
戻り値:
デフォルトのid属性値