diff -rcN gsession-2.4.1-org/WEB-INF/plugin/cas/build.xml gsession-2.4.1-cas/WEB-INF/plugin/cas/build.xml *** gsession-2.4.1-org/WEB-INF/plugin/cas/build.xml Thu Jan 1 09:00:00 1970 --- gsession-2.4.1-cas/WEB-INF/plugin/cas/build.xml Sat Aug 1 22:58:56 2009 *************** *** 0 **** --- 1,99 ---- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -rcN gsession-2.4.1-org/WEB-INF/plugin/cas/jsp/cas.jsp gsession-2.4.1-cas/WEB-INF/plugin/cas/jsp/cas.jsp *** gsession-2.4.1-org/WEB-INF/plugin/cas/jsp/cas.jsp Thu Jan 1 09:00:00 1970 --- gsession-2.4.1-cas/WEB-INF/plugin/cas/jsp/cas.jsp Sun Aug 2 01:20:37 2009 *************** *** 0 **** --- 1,37 ---- + <%@ page pageEncoding="Windows-31J" + contentType="text/html; charset=UTF-8"%> + <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> + <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> + <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> + <%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested" %> + + + + + [GroupSession] HelloWorld + + + + + + + + <%@ include file="/WEB-INF/plugin/common/jsp/header001.jsp" %> + + + + + + + + +
+

CAS USER : <%= request.getRemoteUser() %>

+ +
+ + <%@ include file="/WEB-INF/plugin/common/jsp/footer001.jsp" %> + +
+ +
\ No newline at end of file diff -rcN gsession-2.4.1-org/WEB-INF/plugin/cas/plugin.xml gsession-2.4.1-cas/WEB-INF/plugin/cas/plugin.xml *** gsession-2.4.1-org/WEB-INF/plugin/cas/plugin.xml Thu Jan 1 09:00:00 1970 --- gsession-2.4.1-cas/WEB-INF/plugin/cas/plugin.xml Sun Aug 2 01:30:12 2009 *************** *** 0 **** --- 1,33 ---- + + + + + + + cas + + + + CASプラグイン + + + + CASプラグインです。 + + + + + + false + + + ../cas/login.do + + + + + + false + + + \ No newline at end of file diff -rcN gsession-2.4.1-org/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/CASAction.java gsession-2.4.1-cas/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/CASAction.java *** gsession-2.4.1-org/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/CASAction.java Thu Jan 1 09:00:00 1970 --- gsession-2.4.1-cas/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/CASAction.java Sun Aug 2 01:27:21 2009 *************** *** 0 **** --- 1,86 ---- + package jp.ac.kumamoto_u.cc; + + import java.sql.Connection; + import javax.servlet.http.HttpServletRequest; + import javax.servlet.http.HttpServletResponse; + import jp.groupsession.v2.struts.AbstractGsAction; + import org.apache.struts.action.ActionForm; + import org.apache.struts.action.ActionForward; + import org.apache.struts.action.ActionMapping; + + import jp.groupsession.v2.cmn.login.ILogin; + import jp.groupsession.v2.cmn.login.LoginModel; + import jp.groupsession.v2.cmn.login.LoginResultModel; + + /** + *
[機 能] HelloWorldのアクションクラス + *
[解 説] + *
[備 考] + * + * @author JTS + */ + public class CASAction extends AbstractGsAction { + + /** + *

セッションが確立されていない状態でのアクセスを許可するのか判定を行う。 + * @param req リクエスト + * @param form アクションフォーム + * @return true:許可する,false:許可しない + */ + public boolean canNoSessionAccess(HttpServletRequest req, ActionForm form) { + return true; + } + + /** + *
[機 能] アクションを実行する + *
[解 説] + *
[備 考] + * @param map ActionMapping + * @param form ActionForm + * @param req HttpServletRequest + * @param res HttpServletResponse + * @param con DB Connection + * @return ActionForward + * @throws Exception 実行時例外 + */ + public ActionForward executeAction(ActionMapping map, + ActionForm form, + HttpServletRequest req, + HttpServletResponse res, + Connection con) + throws Exception { + + //System.err.println("CASAction begin."); + + //ログイン処理に必要な情報を設定する + LoginModel loginModel = new LoginModel(); + loginModel.setCon(con); + loginModel.setReq(req); + loginModel.setMap(map); + loginModel.setPluginConfig(getPluginConfig()); + + //ログイン処理を行う + ILogin loginBiz = new GSRemoteUserLoginBiz(); + LoginResultModel resultModel = loginBiz.login(loginModel); + + //System.err.println("resultModel="+resultModel); + + //ログイン処理に失敗 かつ ActionErrorsが設定されている場合 + if (!resultModel.isResult() && resultModel.getErrors() != null) { + addErrors(req, resultModel.getErrors()); + + //System.err.println("forward="+resultModel.getForward()); + + return resultModel.getForward(); + } + + //System.err.println("CASAction end."); + + //セッション確立済みの場合はメインページへ遷移する + if (isSession(req)) { + return map.findForward("top"); + } + + return map.getInputForward(); + } + } \ No newline at end of file diff -rcN gsession-2.4.1-org/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/CASForm.java gsession-2.4.1-cas/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/CASForm.java *** gsession-2.4.1-org/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/CASForm.java Thu Jan 1 09:00:00 1970 --- gsession-2.4.1-cas/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/CASForm.java Sat Aug 1 22:51:42 2009 *************** *** 0 **** --- 1,14 ---- + package jp.ac.kumamoto_u.cc; + + import jp.groupsession.v2.struts.AbstractGsForm; + + /** + *
[讖 閭ス] HelloWorld縺ョ繝輔か繝シ繝繧ッ繝ゥ繧ケ + *
[隗」 隱ャ] + *
[蛯 閠ゾ + * + * @author JTS + */ + public class CASForm extends AbstractGsForm { + } + \ No newline at end of file diff -rcN gsession-2.4.1-org/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/GSRemoteUserLoginBiz.java gsession-2.4.1-cas/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/GSRemoteUserLoginBiz.java *** gsession-2.4.1-org/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/GSRemoteUserLoginBiz.java Thu Jan 1 09:00:00 1970 --- gsession-2.4.1-cas/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/GSRemoteUserLoginBiz.java Sun Aug 2 01:21:53 2009 *************** *** 0 **** --- 1,287 ---- + package jp.ac.kumamoto_u.cc; + + import java.sql.Connection; + import java.sql.SQLException; + + import javax.servlet.http.HttpServletRequest; + import javax.servlet.http.HttpSession; + + import jp.co.sjts.util.NullDefault; + import jp.co.sjts.util.date.UDate; + import jp.co.sjts.util.date.UDateUtil; + import jp.co.sjts.util.jdbc.JDBCUtil; + import jp.co.sjts.util.struts.StrutsUtil; + import jp.groupsession.v2.cmn.GSConst; + import jp.groupsession.v2.cmn.GSConstCommon; + import jp.groupsession.v2.cmn.ILoginLogoutListener; + import jp.groupsession.v2.cmn.LoginLogoutListenerUtil; + import jp.groupsession.v2.cmn.biz.CommonBiz; + import jp.groupsession.v2.cmn.dao.AuthDao; + import jp.groupsession.v2.cmn.dao.BaseUserModel; + import jp.groupsession.v2.cmn.dao.GroupDao; + import jp.groupsession.v2.cmn.dao.base.CmnLoginHistoryDao; + import jp.groupsession.v2.cmn.dao.base.CmnPswdConfDao; + import jp.groupsession.v2.cmn.dao.base.CmnUsrmDao; + import jp.groupsession.v2.cmn.dao.base.CmnUsrmInfDao; + import jp.groupsession.v2.cmn.login.ILogin; + import jp.groupsession.v2.cmn.login.LoginModel; + import jp.groupsession.v2.cmn.login.LoginResultModel; + import jp.groupsession.v2.cmn.model.base.CmnLoginHistoryModel; + import jp.groupsession.v2.cmn.model.base.CmnPswdConfModel; + import jp.groupsession.v2.cmn.model.base.CmnUsrmInfModel; + import jp.groupsession.v2.cmn.model.base.CmnUsrmModel; + import jp.groupsession.v2.usr.GSConstUser; + import jp.groupsession.v2.usr.GSPassword; + + import org.apache.commons.logging.Log; + import org.apache.commons.logging.LogFactory; + import org.apache.struts.action.ActionErrors; + import org.apache.struts.action.ActionForward; + import org.apache.struts.action.ActionMapping; + import org.apache.struts.action.ActionMessage; + + import jp.ac.kumamoto_u.cc.RemoteUserAuthDao; + + /** + *
[機 能] ログイン処理インターフェースの実装クラス + *
[解 説] 通常のログイン処理を行う + *
[備 考] + * + * @author JTS + */ + public class GSRemoteUserLoginBiz implements ILogin { + + /** Logging インスタンス */ + private static Log log__ = LogFactory.getLog(GSRemoteUserLoginBiz.class); + + /** + *
[機 能] ログイン処理を行う + *
[解 説] + *
[備 考] + * @param model ログイン処理に使用する各情報 + * @return forward + * @throws Exception ログイン処理時に例外発生 + */ + public LoginResultModel login(LoginModel model) throws Exception { + + LoginResultModel resultModel = new LoginResultModel(); + + ActionForward forward = null; + Connection con = model.getCon(); + HttpServletRequest req = model.getReq(); + String loginId = req.getRemoteUser(); + ActionMapping map = model.getMap(); + + //ユーザ情報取得 + RemoteUserAuthDao adao = new RemoteUserAuthDao(con); + BaseUserModel smodel = null; + try { + smodel = adao.selectLogin(loginId); + } catch (SQLException e) { + log__.error("SQL実行エラー:ログイン処理の実行に失敗", e); + throw e; + } + + //該当ユーザなし + if (smodel == null) { + ActionErrors errors = new ActionErrors(); + ActionMessage msg = new ActionMessage("error.auth.notfound.idpass"); + StrutsUtil.addMessage(errors, msg, "error.auth.notfound.idpass"); + resultModel.setErrors(errors); + resultModel.setForward(map.getInputForward()); + return resultModel; + } + + //管理者判定 + GroupDao gdao = new GroupDao(con); + if (gdao.isBelongAdmin(smodel.getUsrsid())) { + //管理者 + smodel.setAdminFlg(true); + } else { + //一般 + smodel.setAdminFlg(false); + } + + //前回ログイン時間を取得する。 + CmnUsrmInfDao cidao = new CmnUsrmInfDao(con); + CmnUsrmInfModel uinfModel = cidao.select(smodel.getUsrsid()); + UDate lsttime = null; + if (uinfModel != null) { + lsttime = uinfModel.getUsiLtlgin(); + } + if (lsttime != null) { + String strSdate = + UDateUtil.getSlashYYMD(lsttime) + + " " + + UDateUtil.getSeparateHMS(lsttime); + smodel.setLstLogintime(strSdate); + } + + //セッション確立 + _setSession(req, smodel, con); + + boolean commitFlg = false; + try { + + int usrSid = smodel.getUsrsid(); + UDate now = new UDate(); + + //ログイン履歴に登録 + CmnLoginHistoryModel hismodel = new CmnLoginHistoryModel(); + hismodel.setUsrSid(smodel.getUsrsid()); + hismodel.setClhTerminal(GSConstCommon.TERMINAL_KBN_PC); + hismodel.setClhIp(NullDefault.getString(req.getRemoteAddr(), "")); + hismodel.setClhCar(GSConstCommon.CAR_KBN_PC); + hismodel.setClhUid(null); + hismodel.setClhAuid(usrSid); + hismodel.setClhAdate(now); + hismodel.setClhEuid(usrSid); + hismodel.setClhEdate(now); + + CmnLoginHistoryDao hisDao = new CmnLoginHistoryDao(con); + hisDao.insert(hismodel); + + CmnUsrmInfModel ltmodel = new CmnUsrmInfModel(); + ltmodel.setUsrSid(usrSid); + ltmodel.setUsiLtlgin(now); + ltmodel.setUsiEdate(now); + ltmodel.setUsiEuid(usrSid); + + //最終ログイン時間を更新 + adao.updateLastLoginTime(ltmodel); + commitFlg = true; + + } catch (SQLException e) { + log__.error("ログイン時間の更新に失敗", e); + throw e; + } finally { + if (commitFlg) { + con.commit(); + } else { + JDBCUtil.rollback(con); + } + } + + commitFlg = false; + try { + //ログイン、ログアウトリスナー取得 + log__.debug("ログインリスナー doLogin()開始"); + ILoginLogoutListener[] lis = + LoginLogoutListenerUtil.getLoginLogoutListeners(model.getPluginConfig()); + //各プラグインリスナーを呼び出し + for (int i = 0; i < lis.length; i++) { + lis[i].doLogin(con, smodel.getUsrsid()); + } + commitFlg = true; + log__.debug("ログインリスナー doLogin()終了"); + } catch (ClassNotFoundException e) { + log__.error("リスナー起動に失敗しました。", e); + } catch (IllegalAccessException e) { + log__.error("リスナー起動に失敗しました。", e); + } catch (InstantiationException e) { + log__.error("リスナー起動に失敗しました。", e); + } catch (SQLException e) { + log__.error("リスナー起動に失敗しました。", e); + } finally { + if (commitFlg) { + con.commit(); + } else { + JDBCUtil.rollback(con); + } + } + + //遷移先 + forward = map.findForward("frame"); + + // パスワードの有効チェック + CmnUsrmDao cudao = new CmnUsrmDao(con); + CmnUsrmModel usrModel = cudao.select(smodel.getUsrsid()); + + if (usrModel != null) { + log__.debug("パスワード変更区分 = " + usrModel.getUsrPswdKbn()); + + // パスワード変更区分チェック + if (usrModel.getUsrPswdKbn() == GSConstUser.PSWD_UPDATE_ON) { + forward = map.findForward("pswdUpdate"); + // パスワード有効期限チェック + } else { + // パスワード更新時間の取得 + UDate pwEdate = usrModel.getUsrPswdEdate(); + UDate now = new UDate(); + // パスワード有効日数の取得 + CmnPswdConfDao pwdao = new CmnPswdConfDao(con); + CmnPswdConfModel pwModel = pwdao.select(); + + int limit = -1; + + if (pwModel != null) { + limit = pwModel.getPwcLimitDay(); + } + if (limit != -1) { + pwEdate.addDay(limit); + + log__.debug("パスワード有効期限日 = " + pwEdate); + log__.debug("現在日 = " + now); + + if (now.compare(now, pwEdate) != UDate.LARGE) { + forward = map.findForward("pswdLimit"); + } + } + } + } + + resultModel.setResult(true); + resultModel.setForward(forward); + + return resultModel; + } + + /** + *
[機 能] パスワード変更の可否を返す + *
[解 説] + *
[備 考] + * @return true:変更可能 false:変更不可 + */ + public boolean canChangePassword() { + return true; + } + + /** + *
[機 能] パスワードのフォーマットを行う + *
[解 説] データベースに登録時はこのメソッドでフォーマットした + *
パスワードが使用される + *
[備 考] + * @param password パスワード + * @return パスワード + */ + public String formatPassword(String password) { + return password; + } + + /** + *
[機 能] セッションを確立する + *
[解 説] + *
[備 考] + * @param req リクエスト + * @param smodel ユーザ情報 + * @param con コネクション + * @throws SQLException SQL実行例外 + */ + protected void _setSession(HttpServletRequest req, + BaseUserModel smodel, Connection con) + throws SQLException { + + //セッション情報を削除 + HttpSession session = req.getSession(false); + if (session != null) { + session.invalidate(); + } + + session = req.getSession(true); + session.setAttribute(GSConst.SESSION_KEY, smodel); + //セッションの有効時間設定 + CommonBiz cmnBiz = new CommonBiz(); + session.setMaxInactiveInterval(cmnBiz.getSessionTime(con)); + + } + } \ No newline at end of file diff -rcN gsession-2.4.1-org/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/RemoteUserAuthDao.java gsession-2.4.1-cas/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/RemoteUserAuthDao.java *** gsession-2.4.1-org/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/RemoteUserAuthDao.java Thu Jan 1 09:00:00 1970 --- gsession-2.4.1-cas/WEB-INF/plugin/cas/src/jp/ac/kumamoto_u/cc/RemoteUserAuthDao.java Sun Aug 2 00:42:55 2009 *************** *** 0 **** --- 1,96 ---- + package jp.ac.kumamoto_u.cc; + + import java.sql.Connection; + import java.sql.PreparedStatement; + import java.sql.ResultSet; + import java.sql.SQLException; + + import jp.co.sjts.util.dao.AbstractDao; + import jp.co.sjts.util.jdbc.JDBCUtil; + import jp.co.sjts.util.jdbc.SqlBuffer; + import jp.groupsession.v2.cmn.model.base.CmnUsrmInfModel; + import jp.groupsession.v2.usr.GSConstUser; + import jp.groupsession.v2.cmn.dao.AuthDao; + import jp.groupsession.v2.cmn.dao.BaseUserModel; + import jp.groupsession.v2.cmn.dao.UserSearchDao; + + import org.apache.commons.logging.Log; + import org.apache.commons.logging.LogFactory; + + /** + *

ユーザ認証関係Dao + * @author JTS + */ + public class RemoteUserAuthDao extends AuthDao { + /** Logging インスタンス */ + private static Log log__ = LogFactory.getLog(RemoteUserAuthDao.class); + + /** + *

デフォルトコンストラクタ + */ + public RemoteUserAuthDao() { + } + + /** + *

デフォルトコンストラクタ + * @param con DBコネクション + */ + public RemoteUserAuthDao(Connection con) { + super(con); + } + + /** + *

ログイン + * @param lgid ユーザID(ログインID) + * @param pswd パスワード(暗号化前の状態) + * @throws SQLException SQL実行例外 + * @return 削除件数 + */ + public BaseUserModel selectLogin(String lgid) throws SQLException { + + PreparedStatement pstmt = null; + ResultSet rs = null; + Connection con = null; + BaseUserModel ret = null; + con = getCon(); + + try { + //SQL文 + SqlBuffer sql = new SqlBuffer(); + sql.addSql(" select"); + sql.addSql(" CMN_USRM.USR_SID,"); + sql.addSql(" CMN_USRM_INF.USI_SEI,"); + sql.addSql(" CMN_USRM_INF.USI_MEI"); + sql.addSql(" from"); + sql.addSql(" CMN_USRM,"); + sql.addSql(" CMN_USRM_INF"); + sql.addSql(" where"); + sql.addSql(" CMN_USRM.USR_LGID=?"); + sql.addSql(" and"); + sql.addSql(" CMN_USRM.USR_SID=CMN_USRM_INF.USR_SID"); + sql.addSql(" and"); + sql.addSql(" CMN_USRM.USR_JKBN=?"); + + pstmt = con.prepareStatement(sql.toSqlString()); + sql.addValue(lgid); + sql.addValue(GSConstUser.USER_JTKBN_ACTIVE); + + log__.info(sql.toLogString()); + sql.setParameter(pstmt); + rs = pstmt.executeQuery(); + if (rs.next()) { + ret = UserSearchDao.getBaseUserModelFromRs(rs); + ret.setLgid(lgid); + } else { + ret = null; + } + } catch (SQLException e) { + throw e; + } finally { + JDBCUtil.closeResultSet(rs); + JDBCUtil.closeStatement(pstmt); + } + return ret; + } + + } diff -rcN gsession-2.4.1-org/WEB-INF/plugin/cas/struts_config.xml gsession-2.4.1-cas/WEB-INF/plugin/cas/struts_config.xml *** gsession-2.4.1-org/WEB-INF/plugin/cas/struts_config.xml Thu Jan 1 09:00:00 1970 --- gsession-2.4.1-cas/WEB-INF/plugin/cas/struts_config.xml Sun Aug 2 01:30:03 2009 *************** *** 0 **** --- 1,38 ---- + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -rcN gsession-2.4.1-org/WEB-INF/web.xml gsession-2.4.1-cas/WEB-INF/web.xml *** gsession-2.4.1-org/WEB-INF/web.xml Wed Jul 29 14:01:36 2009 --- gsession-2.4.1-cas/WEB-INF/web.xml Sun Aug 2 00:04:45 2009 *************** *** 84,87 **** --> ! \ No newline at end of file --- 84,113 ---- --> ! ! CAS Filter ! edu.yale.its.tp.cas.client.filter.CASFilter ! ! edu.yale.its.tp.cas.client.filter.loginUrl ! https://cas.company.co.jp/cas/login ! ! ! edu.yale.its.tp.cas.client.filter.validateUrl ! https://cas.company.co.jp/cas/serviceValidate ! ! ! edu.yale.its.tp.cas.client.filter.serverName ! gsession.company.co.jp:80 ! ! ! edu.yale.its.tp.cas.client.filter.wrapRequest ! true ! ! ! ! ! CAS Filter ! /cas/* ! ! ! diff -rcN gsession-2.4.1-org/build.xml gsession-2.4.1-cas/build.xml *** gsession-2.4.1-org/build.xml Wed Jul 29 14:01:30 2009 --- gsession-2.4.1-cas/build.xml Sat Aug 1 23:09:01 2009 *************** *** 41,46 **** --- 41,47 ---- + *************** *** 504,511 **** ! ! ! ! ! ! ! ! ! ! ! ! ! !