サーブレットおよび EJB の仕様書には、認証の条件 (つまり、ロールベースのセキュリティによるアクセス コントロール) の概要が記載されていますが、ベンダ固有の認証メカニズムも認められています。JRun バージョン 3.0 には、サーブレット/JSP および EJB についてさまざまな認証メカニズムが用意されていましたが、重複するユーザ/ロールの定義または各メカニズムへのカスタマイズされた拡張子を維持する必要がありました。JRun バージョン 3.1 は、シングル サインオンと呼ばれる統合された認証メカニズムを特長としています。
J2EE セキュリティの条件および用語の詳細については、『Java 2 Platform Enterprise Edition Specification, v1.2』を参照してください。補足情報については、サーブレット2.2 の仕様書および EJB 1.1 の仕様書を参照してください。
|
メモ この説明を読む前に、Web アプリケーションの認証についての知識を持っている必要 があります。詳細については、『JRun によるアプリケーションの開発』の「Web アプ リケーション認証」を参照してください。また、EJB 認証についての知識を持っている 必要があります。詳細については、JRun EJB サンプルを参照してください。 |
JRun バージョン 3.1 のセキュリティ アーキテクチャにはほとんど下位互換性があります。そのため、現在の認証方法を維持することも、現在のアーキテクチャに移行することもできます。
JRun バージョン 3.1 の既定の Web および EJB 認証仕様には、シングル サインオン機能が実装されています。この機能を使用するには、次のタスクを実行します。
allaire.jrun.security.PropertyFileAuthentication クラス (Windows) または jrunpasswd ユーティリティ (UNIX) を使用して deploy.properties ファイル内に以前に定義されていたユーザを users.properties ファイルに移動します。これらのツールによって、ユーザおよび暗号化されたパスワードが users.properties に追加されます。詳細については、『JRun によるアプリケーションの開発』を参照してください。EJB 認証またはサーブレット/JSP 認証をカスタマイズしていた場合は、ユーザ ストアの実行時保守の必要性を検討し、必要に応じて実行時シングル サインオンを実装します。実行時シングル サインオンについては、"動的なユーザの追加および削除"を参照してください。
JRun 3.1 シングル サインオンによる影響を完全に理解するには、JRun 3.0 で提供されていた 2 つの部分からなる認証メカニズムを理解する必要があります。次の説明では、これらの異なる 2 つのメカニズムの概要について説明します。
UserBean、RoleBean、および LoginSessionBean EJB を拡張することによってこのメカニズムをカスタマイズできました。次の表は、JRun 3.0 サーブレット エンジンの認証およびロールベースのセキュリティの概要を示します。
次の図は、JRun 3.0 サーブレット エンジン内での既定の認証を示します。
次の一覧は、JRun 3.0 サーブレットおよび JSP セキュリティ コンポーネントの詳しい説明を示します。
login-config 要素には、ユーザ名およびパスワードが読み込まれる方法を指定するサブ要素が含まれています。security-constraint 要素には、保護するリソースと、これらのリソースにアクセスできるロールを指定するサブ要素が含まれています。次の web.xml スニペットはこれらの要素を示します。
... <login-config> <auth-method>FORM</auth-method> <form-login-config> <form-login-page>/loginpage.htm</form-login-page> <form-error-page>/loginerror.htm</form-error-page> </form-login-config> </login-config> ... <security-constraint> <web-resource-collection> <web-resource-name>Financial Reports</web-resource-name> <url-pattern>/financials/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>manager</role-name> </auth-constraint> </security-constraint> ...
ResourceAuthenticator) および認証実装クラス (既定は PropertyFileAuthentication) が確立されます。次のスニペットはこれらのプロパティを示します。...
webapp.ResourceAuthenticator=authentication
...
authentication.class=allaire.jrun.servlet.ResourceAuthenticator
...
authentication.service=propfile
authentication.propfile.class=allaire.jrun.security.PropertyFileAuth
entication
authentication.propfile.filename={jrun.rootdir}/lib/users.properties
...
PropertyFileAuthentication (既定の認証実装クラス) によって使用されます。次のスニペットはこれらのプロパティを示します。... group.all=* role.user=all role.users=all user.randyn=raNztUnCaeccI user.clare=clZCPw38r6yH2 ...
PropertyFileAuthentication (またはサイト固有の認証実装クラス) 内のメソッドを呼び出してユーザを認証します。ResourceAuthenticator によって呼び出されます。このクラスには、ResourceAuthenticator によって呼び出されるメソッドを定義するAuthenticationInterface インターフェイスが実装されています。また、関連付けられているテキスト ファイルをプログラムによって更新できるAuthenticationManager インターフェイスも実装されています。次の表は、JRun 3.0 EJB エンジンでの認証およびロールベースのセキュリティの概要を示します。
次の図は、JRun 3.0 EJB エンジン内での既定の認証を示します。
次の一覧は、JRun 3.0 EJB セキュリティ コンポーネントの詳しい説明を示します。
security-role および method-permission 要素にはロールと、ロールがアクセス可能なメソッドを指定します。次の ejb-jar.xml スニペットはこれらの要素を示します。
...
<assembly-descriptor>
<security-role>
<role-name>spender</role-name>
</security-role>
<security-role>
<role-name>saver</role-name>
</security-role>
<security-role>
<role-name>all</role-name>
</security-role>
<method-permission>
<role-name>spender</role-name>
<method>
<ejb-name>sample1a.BalanceHome</ejb-name>
<method-name>spend</method-name>
</method>
</method-permission>
...
UserBean および RoleBean は、このファイル内のプロパティによって定義されたユーザおよびロールにアクセスします。 次のスニペットはこれらのプロパティを示します。...
ejipt.userHomeName=default.UserHome
ejipt.roleHomeName=default.RoleHome
ejipt.loginSessionHomeName=default.LoginSessionHome
...
ejipt.users=spender1:pass;spender2:pass;saver1:pass;saver2:pass;
chief:pass
ejipt.roles=spender:spender1,spender2,chief;saver:saver1,saver2,
chief
...
UserBean.checkPassword メソッドを呼び出すことによってパスワードを確認します。パスワードが有効な場合、LoginSessionBean は UserManager.login メソッドを呼び出します。LoginSessionBean によって呼び出される checkPassword などのユーザ保守メソッドが指定されます。この EJB を使用して、UserHome インターフェイス内で定義される create メソッドによって新しいユーザを作成することもできます。addMember や isMember などのロール保守メソッドが指定されます。この EJB を使用して、RoleHome インターフェイス内で定義される create メソッドによって新しいロールを作成することもできます。UserManager を拡張して、サイト固有のユーザおよびロール ストアを実装できます。拡張方法の詳細については、文書のホーム ページから入手可能な UserManager JavaDocs を参照してください。JRun 3.1 の シングル サインオン機能を利用すると、以前はサーブレットと JSP でしか使用できなかった認証実装クラスを EJB コンポーネントでも使用できます。既定では、このことは user.properties ファイル内で EJB ユーザを定義することを意味します。JRun バージョン 3.0 の Web アプリケーション認証に対して行った拡張は、JRun バージョン 3.1 EJB 認証に自動的に適用されます。
次の表は、JRun 3.1 での認証およびロールベースのセキュリティの概要を示します。
次の一覧は、JRun 3.1 サーブレットおよび JSP セキュリティ コンポーネントの詳しい説明を示します。
login-config 要素には、ユーザ名およびパスワードが読み込まれる方法を指定するサブ要素が含まれています。security-constraint 要素には、保護するリソースと、これらのリソースにアクセスできるロールを指定するサブ要素が含まれています。これらの要素の例については、"JRun 3.0 でのサーブレットおよび JSP 認証"を参照してください。
security-role および method-permission 要素にはロールと、ロールがアクセス可能なメソッドを指定します。これらの要素の例については、"JRun 3.0 での EJB 認証"を参照してください。JRunAuthenticator) および認証実装クラス (既定は PropertyFileAuthentication) が確立されます。次のスニペットはこれらのプロパティを示します。...
webapp.ResourceAuthenticator=authentication
...
jrunauth.class=allaire.jrun.servlet.JRunAuthenticator
...
jrunauth.service=propfile
jrunauth.propfile.class=allaire.jrun.security.PropertyFileAuthentica
tion
jrunauth.propfile.filename={jrun.rootdir}/lib/users.properties
...
PropertyFileAuthentication (既定の認証実装クラス) によって使用されます。次のスニペットはこれらのプロパティを示します。... group.all=* role.user=all role.users=all role.spender=spender1,spender2,chief role.saver=saver1,saver2,chief user.randyn=raNztUnCaeccI user.clare=clZCPw38r6yH2 user.spender1=chpP1JdC4Xpqg user.spender2=chpP1JdC4Xpqg user.saver1=chpP1JdC4Xpqg user.saver2=chpP1JdC4Xpqg user.chief=chpP1JdC4Xpqg ...
JRunAuthenticator は web.xml および ejb-jar.xml ファイルから設定を読み込み、PropertyFileAuthentication (またはサイト固有の認証実装クラス) 内のメソッドを呼び出してユーザを認証します。JRunAuthenticator は UserBean、RoleBean、および LoginSessinBean も使用しますが、拡張はできません。JRunAuthenticator によって呼び出されます。このクラスには JRunAuthenticator によって呼び出されるメソッドを定義する AuthenticationInterface インターフェイスが実装されています。また、ユーザ レポジトリをプログラムによって更新できる AuthenticationManager インターフェイスも実装されています。
EJB エンジンでは UserManager と UserBean、RoleBean、および LoginSessionBean EJB も使用されます。これらの違いは次のとおりです。
allaire.ejipt.ejbeans パッケージではなく allaire.jrun.ejbeans パッケージ内にあります。
allaire.jrun.ejbeans パッケージ内で EJB を拡張することはできません。UserBean は認証実装クラス (既定では PropertyFileAuthentication) を介してユーザにアクセスすることによって UserManager ユーザ リストを初期化します。allaire.ejipt.ejbeans パッケージ内の EJB を使用します。
サーブレットまたは JSP 認証をカスタマイズしていた場合は、その認証が EJB と連動する必要があります。UserBean、RoleBean、および LoginSessionBean を使用して EJB スタンドアロン認証をカスタマイズした場合は、カスタマイズした EJB スタンドアロン認証ロジックを JRun 認証フレームワーク内に実装する必要があります。このトピックの情報については、『JRun によるアプリケーションの開発』と
http://www.allaire.com/handlers/index.cfm?ID=17555&Method=Full にある JRun 開発者センター (JRun DevCenter) を参照してください。
JRun バージョン 3.0 では、ユーザをユーザ ストアに追加した場合、新しいユーザを認識させるために JRun を再起動する必要がありました。JRun バージョン 3.1 ではユーザの追加および削除を動的に行うことができます。この機能は実行時シングル サインオンとも呼ばれています。
|
メモ この機能は、JRun 3.1 の既定である |
実行時シングル サインオンは EjiptAuthenticationManager クラスによって実装されます。カスタマイズした認証実装クラス内でこの機能を有効にするには、次の手順を実行してください。
allaire.jrun.security.AuthenticationManagerクラス を実装します。public class MyAuthentication implements AuthenticationInterface,
AuthenticationManager {
...
EjiptAuthenticationManager および ServiceContext の変数を追加します。EjiptAuthenticationManager ejiptAuth = null; ServiceContext serviceContext;
ServiceContext に渡される init メソッドをコーディングします。public void init(ServiceContext serviceContext)
init メソッドでは、渡された ServiceContext を使用して EjiptAuthenticationManager のインスタンスを作成します。ejiptAuth = new EjiptAuthenticationManager(serviceContext);
AuthenticationManager インターフェイスからメソッドを認証実装クラスに追加します。boolean isUser(String user)
boolean isUserInGroup(String user, String role)boolean isUserInRole(String user, String group)boolean addUser(String user, String password) throws IOExceptionboolean addUser(String user, String password, String[] group,
String[] role) throws IOExceptionboolean changePassword(String user, String oldPassword, String
newPassword) throws IOExceptionboolean removeUser(String user) throws IOExceptionEnumeration getUserList()Enumeration getGroupList()Enumeration getGroupMembers(Object group)Enumeration getRoleList()Enumeration getRoleMembers(Object role)boolean addGroup(String group, String[] users, String[] roles)
throws IOExceptionboolean addToGroup(String user, String[] group) throws
IOExceptionboolean removeFromGroup(String user, String[] group) throws
IOExceptionboolean removeGroup(String group) throws IOExceptionboolean addRole(String role, String[] groups, String[] users)
throws IOExceptionboolean addToRole(String user, String[] role) throws IOExceptionboolean removeFromRole(String user, String[] role) throws
IOExceptionboolean removeRole(String role) throws IOExceptionadd* および remove* メソッド内では、JRun 実行時システム上でアクションを実行する EjiptAuthenticationManager 内の同等のメソッドを呼び出します。AuthenticationManager メソッドを実行します (オプション)。AuthenticationManager と EjiptAuthenticationManager JavaDocs を参照してください。