nimbus (1.2.4) | 2018-01-25 20:02 |
nimbus-sample (1.2.4) | 2018-01-26 17:06 |
jp.ossc.nimbus.service.aop.interceptor.servlet.DatabaseAuthenticateStoreServiceは、認証情報をデータベースに永続化するAuthenticateStore実装サービスです。
このサービスは、複合的なサービスで、以下のサービスを下位サービスとして使用します。
下位サービスインタフェース | 用途 |
jp.ossc.nimbus.service.connection.ConnectionFactory | JDBCのコネクションを生成する。 |
jp.ossc.nimbus.service.connection.PersistentManager | データベースとJavaオブジェクトを相互交換する。 |
以下に簡単なサービス定義を示します。
- <?xml version="1.0" encoding="Shift_JIS"?>
- <!DOCTYPE server PUBLIC
- "-//Nimbus//DTD Nimbus 1.0//JA"
- "http://nimbus.sourceforge.jp/dtd/nimbus-service_1_0.dtd">
- <server>
- <manager>
- <!-- 認証されているかを検証するInterceptorサービス -->
- <service name="AuthenticateInterceptor"
- code="jp.ossc.nimbus.service.aop.interceptor.servlet.AuthenticateInterceptorService">
- <attribute name="AuthenticatedInfoMapping">
- Header(RequestHeader).UserID=Header(AuthenticatedInfo).UserID
- Header(RequestHeader).Ticket=Header(AuthenticatedInfo).Ticket
- </attribute>
- <attribute name="LoginPath">/login.bf</attribute>
- <attribute name="LogoutPath">/logout.bf</attribute>
- <!-- 認証情報を永続化するAuthenticateStoreサービスのサービス名を設定する -->
- <attribute name="AuthenticateStoreServiceName">#AuthenticateStore</attribute>
- <depends>AuthenticateStore</depends>
- </service>
- <!-- 認証情報をデータベースに永続化するAuthenticateStoreサービス -->
- <service name="AuthenticateStore"
- code="jp.ossc.nimbus.service.aop.interceptor.servlet.DatabaseAuthenticateStoreService">
- <!-- JDBCコネクションを生成するConnectionFactoryサービスのサービス名を設定する -->
- <attribute name="ConnectionFactoryServiceName">#ConnectionFactory</attribute>
- <!-- データベースとJavaオブジェクトの交換を行うPersistentManagerサービスのサービス名を設定する -->
- <attribute name="PersistentManagerServiceName">#PersistentManager</attribute>
- <!-- 認証情報を格納するオブジェクトのテンプレートを設定する -->
- <attribute name="AuthenticatedInfoTemplate">
- <object code="jp.ossc.nimbus.beans.dataset.DataSet">
- <attribute name="HeaderSchema(AuthenticatedInfo)">
- :UserID,java.lang.String
- :Ticket,java.lang.String
- </attribute>
- </object>
- </attribute>
- <!-- 認証情報を永続化する時に、データベースに存在するかを確認するクエリを設定する -->
- <attribute name="SelectQueryOnCreateUser">
- select count(1) from USER_SESSION where USERID=?<-{Header(AuthenticatedInfo).UserID} and AUTHTIME is not NULL
- </attribute>
- <!-- 認証情報を永続化する時に、データベースに書き込むクエリを設定する -->
- <attribute name="InsertQuery">
- insert into USER_SESSION (USERID, TICKET, AUTHTIME) values (?<-{Header(AuthenticatedInfo).UserID}, ?<-{Header(AuthenticatedInfo).Ticket}, NOW())
- </attribute>
- <!-- 認証情報を永続化する時に、データベースを更新するクエリを設定する -->
- <attribute name="UpdateQueryOnCreate">
- update USER_AUTH set TICKET=?<-{Header(AuthenticatedInfo).Ticket}, AUTHTIME=NOW() where USERID=?<-{Header(AuthenticatedInfo).UserID}
- </attribute>
- <!-- 認証情報を活性化する時に、データベースから読み込むクエリを設定する -->
- <attribute name="SelectQueryOnFindUser">
- select USERID->{Header(AuthenticatedInfo).UserID}, TICKET->{Header(AuthenticatedInfo).Ticket} from USER_AUTH where USERID=?<-{Header(AuthenticatedInfo).UserID}
- </attribute>
- <!-- 認証情報を活性化する時に、データベースを更新するクエリを設定する -->
- <attribute name="UpdateQueryOnActivate">
- update USER_AUTH set AUTHTIME=NOW() where USERID=?<-{Header(AuthenticatedInfo).UserID}
- </attribute>
- <!-- 認証情報を非活性化する時に、データベースを更新するクエリを設定する -->
- <attribute name="UpdateQueryOnDeactivate">
- update USER_AUTH set AUTHTIME=NULL where USERID=?<-{Header(AuthenticatedInfo).UserID}
- </attribute>
- <!-- 認証情報を削除する時に、データベースから削除するクエリを設定する -->
- <attribute name="DeleteQuery">
- delete from USER_AUTH where USERID=?<-{Header(AuthenticatedInfo).UserID}
- </attribute>
- <depends>ConnectionFactory</depends>
- <depends>PersistentManager</depends>
- </service>
- <!-- JDBCドライバ経由でConnectionを取得するConnectionFactoryサービス -->
- <service name="ConnectionFactory"
- code="jp.ossc.nimbus.service.connection.JDBCConnectionFactoryService">
- <attribute name="DriverName">org.hsqldb.jdbcDriver</attribute>
- <attribute name="ConnectionURL">jdbc:hsqldb:./localDB</attribute>
- <attribute name="UserName">sa</attribute>
- <attribute name="Password"></attribute>
- </service>
- <!-- データベースとJavaオブジェクトの交換を行うPersistentManagerサービス -->
- <service name="PersistentManager"
- code="jp.ossc.nimbus.service.connection.DefaultPersistentManagerService"/>
- </manager>
- </server>