ユーザー認証とセッション
セッション使用可否の設定 wisdom_config.xml
wisdom_config.xmlの設定
セッションの使用可否はサーブレット単位に行いないます。設定にはwisdom_config.xmlの設定が必要です。
例) wisdom_config.xmlのサンプル
<wisdom_config>
    <servletRuntimeConfig className='wisdom.core.runtime.RunTimeServlet' enablesSession="true">
    <authenticate required="true" authType="form" authClass="sitool.web.AuthenticateImpl"/>
    ・・・・
</wisdom_config>
要素<servletRuntimeConfig>の属性「enablesSession」
この値がtrueになっていると、セッションが使用可能になります。
要素<authenticate>の属性「required」、「authType」、「authClass」
requiredの値がtrueになっていると、認証が必要になります。authTypeの値には"form"、あるいは"basic"の値が設定でき、basicの場合はHTTP BASIC認証が使用されます。authClassの値には後述のwisdom.core.application.IAuthenticateインタフェースの実装クラスの名前を指定します。
※enablesSession="true"で、authenticate required="false"の場合はユーザーは匿名としてセッション情報が作成されます。(この部分はまだ実装されていません。)
認証のための共通インターフェースの実装
wisdom.core.application.IAuthenticateインターフェースの実装
widsom上で認証ロジックを行うクラスはwisdom.core.application.IAuthenticateインタフェースを実装する必要があります。実行時にはDBへ接続するためのIRequestHandler、入力されたユーザーID、パスワードが引数で渡されるので任意の認証ロジックを実装し、認証されたユーザーに対してwisdom.core.session.UserSessionFactoryクラスを使用してセッション情報を作成してください。認証に失敗した場合、wisdom.core.runtime.AuthenticateExceptionを送出してください。(この例外をキャッチし、ログイン画面へ遷移するようにwisdomを設定します。)
例)IAuthenticateを実装したtutorial.AutenticateImplクラス
package tutorial;
import java.sql.*;
import javax.servlet.http.*;
import wisdom.core.CoreMessageGenerator;
import wisdom.core.Message;
import wisdom.core.application.IAuthenticate;
import wisdom.core.application.IRequestHandler;
import wisdom.core.application.IUserSession;
import wisdom.core.runtime.AuthenticateException;
import wisdom.core.session.UserSessionFactory;

public class AuthenticateImpl implements IAuthenticate {

public static final String sql = "SELECT PASSWORD,USERNAME FROM user WHERE USERID = ? FETCH FIRST 1 ROW ONLY";
    /**
    * ユーザー認証を行います。
    * @param user ユーザーID
    * @param password パスワード
    * @exception 実行に送出される例外。
    */
    public void authenticate(IRequestHandler rh, String user, String password) throws Exception {
        if (user != null && user.length() > 10) {                         // ユーザIDが11桁以上入力
            throw new AuthenticateException(CoreMessageGenerator.getInstance().getMessage("WAE0010"));
        }
        String code = "";
        boolean isValidUser = false;
        PreparedStatement ps = rh.getConnection(this).prepareStatement(sql);
        ps.setString(1, user);
        ResultSet rs = ps.executeQuery();

        String password_ = null;
        String userName = null;
        String deptId = null;
        if (rs.next()) {
            password_ = rs.getString(1).trim();
            userName = rs.getString(2).trim();
            if (password.equals(password_)) {                      // パスワードが一致
                IUserSession us = UserSessionFactory.create(rh, user );
                isValidUser = true;                             // 認証OK
            }  else  code = "WAE0020";                          // パスワードが不一致
        } else  code = "WAE0010";                               // ユーザ見つからない
        rs.close();
        ps.close();
        if (!isValidUser) throw new AuthenticateException(CoreMessageGenerator.getInstance().getMessage(code));
    }
}
セッション情報へのアクセス
wisdom.core.application.IRequestHandlerインターフェースの使用
セッションが使用可能設定され、認証が済んでいる場合、セッション情報へは、wisdom.core.application.IRequestHandlerのメソッドを使用してアクセスを行うことができます。
※詳細はjavadocを参照してください。
wisdom.core.application.IUserSessionインターフェースの使用
JSP上ではセッション情報へは、wisdom.core.application.IUserSessionを使用してセッション情報へアクセスします。JSP上でのIUserSessionの使用を参照してください。
4. ログイン画面を表示するための設定
wisdom_config.xmlの設定
以下のように、
wisdom.core.tuntime.AuthenticateException、wisdom.core.session.SessionTimeOutedExceptionが発生した場合、ログイン画面へ遷移するよう設定します。

<wisdom_config>
    <servletRuntimeConfig className='wisdom.core.runtime.RunTimeServlet' enablesSession="true">
        <authenticate required="true" authType="form" authClass="sitool.web.AuthenticateImpl"/>
        <allowedMethods post="true" get="true"/>
        <commandFileName name="runtime-command.xml"/>
        <exception className='ProhibitMethodExceoption' page='error.jsp'/>
        <exception className='wisdom.core.runtime.ReqidNotFoundException' page='/error.jsp'/>
        <exception className='wisdom.core.runtime.AuthenticateException' page='/login.jsp'/>
        <exception className='wisdom.core.session.SessionTimeOutedException' page='/login.jsp'/>
      ・・・・・