AuthenticateStore実装サービス jp.ossc.nimbus.service.aop.interceptor.servlet.DatabaseAuthenticateStoreService

jp.ossc.nimbus.service.aop.interceptor.servlet.DatabaseAuthenticateStoreServiceは、認証情報をデータベースに永続化するAuthenticateStore実装サービスです。

このサービスは、複合的なサービスで、以下のサービスを下位サービスとして使用します。

下位サービスインタフェース用途
jp.ossc.nimbus.service.connection.ConnectionFactoryJDBCのコネクションを生成する。
jp.ossc.nimbus.service.connection.PersistentManagerデータベースとJavaオブジェクトを相互交換する。

以下に簡単なサービス定義を示します。

  1. <?xml version="1.0" encoding="Shift_JIS"?>
  2. <!DOCTYPE server PUBLIC
  3. "-//Nimbus//DTD Nimbus 1.0//JA"
  4. "http://nimbus.sourceforge.jp/dtd/nimbus-service_1_0.dtd">
  5. <server>
  6. <manager>
  7. <!-- 認証されているかを検証するInterceptorサービス -->
  8. <service name="AuthenticateInterceptor"
  9. code="jp.ossc.nimbus.service.aop.interceptor.servlet.AuthenticateInterceptorService">
  10. <attribute name="AuthenticatedInfoMapping">
  11. Header(RequestHeader).UserID=Header(AuthenticatedInfo).UserID
  12. Header(RequestHeader).Ticket=Header(AuthenticatedInfo).Ticket
  13. </attribute>
  14. <attribute name="LoginPath">/login.bf</attribute>
  15. <attribute name="LogoutPath">/logout.bf</attribute>
  16. <!-- 認証情報を永続化するAuthenticateStoreサービスのサービス名を設定する -->
  17. <attribute name="AuthenticateStoreServiceName">#AuthenticateStore</attribute>
  18. <depends>AuthenticateStore</depends>
  19. </service>
  20. <!-- 認証情報をデータベースに永続化するAuthenticateStoreサービス -->
  21. <service name="AuthenticateStore"
  22. code="jp.ossc.nimbus.service.aop.interceptor.servlet.DatabaseAuthenticateStoreService">
  23. <!-- JDBCコネクションを生成するConnectionFactoryサービスのサービス名を設定する -->
  24. <attribute name="ConnectionFactoryServiceName">#ConnectionFactory</attribute>
  25. <!-- データベースとJavaオブジェクトの交換を行うPersistentManagerサービスのサービス名を設定する -->
  26. <attribute name="PersistentManagerServiceName">#PersistentManager</attribute>
  27. <!-- 認証情報を格納するオブジェクトのテンプレートを設定する -->
  28. <attribute name="AuthenticatedInfoTemplate">
  29. <object code="jp.ossc.nimbus.beans.dataset.DataSet">
  30. <attribute name="HeaderSchema(AuthenticatedInfo)">
  31. :UserID,java.lang.String
  32. :Ticket,java.lang.String
  33. </attribute>
  34. </object>
  35. </attribute>
  36. <!-- 認証情報を永続化する時に、データベースに存在するかを確認するクエリを設定する -->
  37. <attribute name="SelectQueryOnCreateUser">
  38. select count(1) from USER_SESSION where USERID=?&lt;-{Header(AuthenticatedInfo).UserID} and AUTHTIME is not NULL
  39. </attribute>
  40. <!-- 認証情報を永続化する時に、データベースに書き込むクエリを設定する -->
  41. <attribute name="InsertQuery">
  42. insert into USER_SESSION (USERID, TICKET, AUTHTIME) values (?&lt;-{Header(AuthenticatedInfo).UserID}, ?&lt;-{Header(AuthenticatedInfo).Ticket}, NOW())
  43. </attribute>
  44. <!-- 認証情報を永続化する時に、データベースを更新するクエリを設定する -->
  45. <attribute name="UpdateQueryOnCreate">
  46. update USER_AUTH set TICKET=?&lt;-{Header(AuthenticatedInfo).Ticket}, AUTHTIME=NOW() where USERID=?&lt;-{Header(AuthenticatedInfo).UserID}
  47. </attribute>
  48. <!-- 認証情報を活性化する時に、データベースから読み込むクエリを設定する -->
  49. <attribute name="SelectQueryOnFindUser">
  50. select USERID-&gt;{Header(AuthenticatedInfo).UserID}, TICKET-&gt;{Header(AuthenticatedInfo).Ticket} from USER_AUTH where USERID=?&lt;-{Header(AuthenticatedInfo).UserID}
  51. </attribute>
  52. <!-- 認証情報を活性化する時に、データベースを更新するクエリを設定する -->
  53. <attribute name="UpdateQueryOnActivate">
  54. update USER_AUTH set AUTHTIME=NOW() where USERID=?&lt;-{Header(AuthenticatedInfo).UserID}
  55. </attribute>
  56. <!-- 認証情報を非活性化する時に、データベースを更新するクエリを設定する -->
  57. <attribute name="UpdateQueryOnDeactivate">
  58. update USER_AUTH set AUTHTIME=NULL where USERID=?&lt;-{Header(AuthenticatedInfo).UserID}
  59. </attribute>
  60. <!-- 認証情報を削除する時に、データベースから削除するクエリを設定する -->
  61. <attribute name="DeleteQuery">
  62. delete from USER_AUTH where USERID=?&lt;-{Header(AuthenticatedInfo).UserID}
  63. </attribute>
  64. <depends>ConnectionFactory</depends>
  65. <depends>PersistentManager</depends>
  66. </service>
  67. <!-- JDBCドライバ経由でConnectionを取得するConnectionFactoryサービス -->
  68. <service name="ConnectionFactory"
  69. code="jp.ossc.nimbus.service.connection.JDBCConnectionFactoryService">
  70. <attribute name="DriverName">org.hsqldb.jdbcDriver</attribute>
  71. <attribute name="ConnectionURL">jdbc:hsqldb:./localDB</attribute>
  72. <attribute name="UserName">sa</attribute>
  73. <attribute name="Password"></attribute>
  74. </service>
  75. <!-- データベースとJavaオブジェクトの交換を行うPersistentManagerサービス -->
  76. <service name="PersistentManager"
  77. code="jp.ossc.nimbus.service.connection.DefaultPersistentManagerService"/>
  78. </manager>
  79. </server>


アスペクト指向/Interceptor/servlet/AuthenticateInterceptorService