JAAS のシステム・ログイン構成用のカスタム・ログイン・モジュールの開発
WebSphere® Application Server には、システム・ログインを構成する、複数の Java™ Authentication and Authorization Service (JAAS) のプラグイン・ポイントがあります。 WebSphere Application Server では、システム・ログイン構成を使って、受信される要求、発信される要求、および内部サーバー・ログインを認証します。
このタスクについて
- WEB_INBOUND
- RMI_OUTBOUND
- RMI_INBOUND
- DEFAULT
手順
- Web 要求を WEB_INBOUND ログイン構成で認証します。
WEB_INBOUND ログイン構成は Web 要求を認証します。
WEB_INBOUND 構成とその関連のコールバックについて詳しくは、Java Authentication and Authorization Service 用のシステム・ログイン構成エントリー設定の『RMI_INBOUND、WEB_INBOUND、DEFAULT』を参照してください。
図 1 は、WEB_INBOUND ログイン構成に渡される初期情報でサブジェクトを作成する トラスト・アソシエーション・インターセプター (TAI) を使用した構成の例です。 トラスト・アソシエーション・インターセプターが構成されていない場合、 認証プロセスは、図 1 で結合されているすべてのログイン・モジュールで構成される WEB_INBOUND システム・ログイン構成に 直接移動します。図 1 は、カスタム・ログイン・モジュールにプラグインできる場所、 および ltpaLoginModule ログイン・モジュールと wsMapDefaultInboundLoginModule ログイン・モジュールが必要とされる場所を示しています。図 1. WEB_INBOUND ログイン構成 - アウトバウンド要求を RMI_OUTBOUND ログイン構成で処理します。
RMI_OUTBOUND ログイ ン構成は、アウトバウンド要求を処理するためのプラグ・ポイントです。 WebSphere Application Server はこのプラグ・ポイントを使用して、渡された呼び出しサブジェクトに基づいてダウンストリームに送信されるシリアライズ情報および、他のセキュリティー・コンテキスト情報 (伝搬トークンなど) を作成します。 カスタム・ログイン・モジュールはこのプラグ・ポイントを使用して、その識別を変更することができます。 詳しくは、異なるターゲット・レルムへのアウトバウンド ID マッピングの構成を参照してください。 図 2 では、カスタム・ログイン・モジュールに接続できる場所、 および wsMapCSIv2OutboundLoginModule ログイン・モジュールが必要とされる場所を示しています。
図 2. RMI_OUTBOUND ログイン構成RMI_OUTBOUND ログイン構成とその関連のコールバックについて詳しくは、 Java Authentication and Authorization Service 用のシステム・ログイン構成エントリー設定の『RMI_OUTBOUND』を参照してください。
- エンタープライズ Bean 要求のインバウンド認証を、RMI_INBOUND ログイン構成で処理します。
RMI_INBOUND ログイン 構成は、エンタープライズ Bean 要求のインバウンド認証を処理するプラグ・ポイントです。 WebSphere Application Server は、初期ログインまたは伝搬ログインのいずれかにこのプラグ・ポイントを使用します。 これら 2 つのログイン・タイプについて詳しくは、セキュリティー属性の伝搬を参照してください。 伝搬ログイン時に、このプラグ・ポイントは、アップストリーム・サーバーから受信する情報を デシリアライズするために使用されます。 カスタム・ログイン・モジュールは、このプラグ・ポイントを使用して ID を変更したり、 カスタム・トークンを処理したり、カスタム・オブジェクトをサブジェクトに追加します。 図 3 で参照されている Hashtable オブジェクトを使用した ID の変更について詳しくは、 インバウンド ID マッピングの構成を参照してください。 図 3 では、カスタム・ログイン・モジュールにプラグインできる場所、 および ltpaLoginModule ログイン・モジュールおよび wsMapDefaultInboundLoginModule ログイン・モジュールが 必要とされる場所を示しています。
図 3. RMI_INBOUND ログイン構成RMI_INBOUND ログイン構成とその関連のコールバックに関する詳細については、Java Authentication and Authorization Service 用のシステム・ログイン構成エントリー設定の『RMI_INBOUND、WEB_INBOUND、DEFAULT』を参照してください。
- その他のすべてのタイプの認証要求を DEFAULT ログイン構成で処理します。 DEFAULT ログイン構成
DEFAULT ログイン構成は、 管理 SOAP 要求およびサーバー ID の内部認証を含む、他のタイプの認証要求をすべて処理するプラグ・ポイントです。 伝搬ログインは、通常、このプラグ・ポイントでは行われません。
DEFAULT ログイン構成とその関連の コールバックについて詳しくは、Java Authentication and Authorization Service 用のシステム・ログイン構成エントリー設定の『RMI_INBOUND、WEB_INBOUND、DEFAULT』を参照してください。
- ログイン構成を、特定の情報がいつ表示され、
どのようにその情報を使用するかがわかるようなロジックで作成します。 ログイン・モジュールの書き込みWebSphere Application Server アプリケーション・ログイン構成またはシステム・ログイン構成にプラグインするログイン・モジュールを書き込む場合は、http://java.sun.com/products/jaas の、JAAS プログラミング・モデルを参照してください。JAAS プログラミング・モデルは、JAAS に関する基本的な情報を提供します。 ただし、WebSphere Application Server 環境でログイン・モジュールを書き込む前に、以下のセクションをお読みください。
- 使用できるコールバック
- 共有状態変数
- 初期ログインと伝搬ログイン
- カスタム・ログイン・モジュールのサンプル
使用可能なコールバック
各ログイン構成は、ログイン構成によって認識されるコールバックを文書化する必要があります。 ただし、コールバックは必ずしも常にパス済みデータではありません。 ログイン構成には、特定の情報がいつ現れ、 どのようにその情報を使用するかがわかるようなロジックが含まれている必要があります。 例えば、前述のあらかじめ構成された 4 つのシステム・ログイン構成すべてに接続することができる カスタム・ログイン・モジュールを書き込む場合は、要求を認証するために 3 つのコールバックが提示されます。 その他のコールバックは、伝搬、ログイン構成での他の情報の使用可能化など、その他の理由で提示されます。
ログイン情報は以下のような組み合わせで表示されます。- ユーザー名 (NameCallback) とパスワード (PasswordCallback)
- この情報は一般的な認証の組み合わせです。
- ユーザー名 (NameCallback) のみ
- この情報は、ID アサーション、トラスト・アソシエーション・インターセプター (TAI) ログイン、 および認証ログインに使用されます。
- トークン (WSCredTokenCallbackImpl)
- この情報は Lightweight Third Party Authentication (LTPA) のトークン検証に使用されます。
- 伝搬トークン・リスト (WSTokenHolderCallback)
- この情報は伝搬ログインに使用されます。
最初の 3 つの組み合わせは一般的な認証に使用されます。 しかし、最初の 3 つの情報の組み合わせの 1 つ以外にも WSTokenHolderCallback コールバックが存在する場合には、そのログインは伝搬ログインと呼ばれます。 伝搬ログインとは、一部のセキュリティー属性が、別のサーバーからそのサーバーに伝搬することを指します。 認証情報の検証が正常に終わった場合は、各サーバーはこれらのセキュリティー属性を再使用します。 WSTokenHolderCallback コールバックが、 フル・ログインに十分な属性を有していない場合もあります。 WSTokenHolderCallback コールバックの requiresLogin メソッドを確認して、 新規ログインが必要かどうかを判断します。requiresLogin メソッドによって戻された情報はいつでも無視できますが、 その結果、情報が重複する場合があります。次のリストには、 システム・ログイン構成に存在する可能性のあるコールバックが含まれています。 このリストには、コールバック名およびその責任の説明が含まれています。- callbacks[0] = new javax.security.auth.callback.NameCallback("Username: ");
- このコールバック・ハンドラーはログインのユーザー名を収集します。 結果は基本認証ログイン・ユーザー名 (ユーザー名とパスワード) の場合も、ID アサーション・ログイン・ユーザー名の場合もあります。
- callbacks[1] = new javax.security.auth.callback.PasswordCallback("Password: ", false);
- このコールバック・ハンドラーはログインのパスワードを収集します。
- callbacks[2] = new com.ibm.websphere.security.auth.callback.WSCredTokenCallbackImpl("Credential Token:");
- このコールバック・ハンドラーは、ログインのための Lightweight Third Party Authentication (LTPA) のトークン、 あるいは他の種類のトークンを収集します。このコールバック・ハンドラーは、通常は、 ユーザー名とパスワードがない場合に存在します。
- callbacks[3] = new com.ibm.wsspi.security.auth.callback.WSTokenHolderCallback("Authz Token List:");
- このコールバック・ハンドラーは、入力データとして Common Secure Interoperability Version 2 (CSIv2) 許可トークンを使用して、 WSOpaqueTokenHelper.createTokenHolderListFromOpaqueToken API の呼び出しから戻された、 TokenHolder オブジェクトの ArrayList を収集します。
- callbacks[4] = new com.ibm.websphere.security.auth.callback.WSServletRequestCallback("HttpServletRequest:" );
- このコールバック・ハンドラーは HTTP サーブレット要求オブジェクトがある場合、これを収集します。 このコールバック・ハンドラーによって、ログイン・モジュールは、 ログインで使用される HTTP 要求の情報を取得することができます。 また、コールバック・ハンドラーは WEB_INBOUND ログイン構成からのみ表示されます。
- callbacks[5] = new com.ibm.websphere.security.auth.callback.WSServletResponseCallback("HttpServletResponse:");
- このコールバック・ハンドラーは HTTP サーブレット応答オブジェクトがある場合、これを収集します。 このコールバック・ハンドラーにより、ログイン・モジュールは、 ログインの結果として HTTP 応答に情報を入れることができます。 この例としては、SingleSignonCookie Cookie をこの応答に追加する状態があります。 このコールバック・ハンドラーは WEB_INBOUND ログイン構成からのみ表示されます。
- callbacks[6] = new com.ibm.websphere.security.auth.callback.WSAppContextCallback("ApplicationContextCallback:");
- このコールバック・ハンドラーは、ログイン中に使用される Web アプリケーション・コンテキストを収集します。このコールバック・ハンドラーは HashMap オブジェクトで構成されます。このオブジェクトには、 アプリケーション名と、リダイレクト Web アドレス (存在する場合) が含まれています。このコールバック・ハンドラーは、 WEB_INBOUND ログイン構成からのみ表示されます。
- callbacks[7] = new WSRealmNameCallbackImpl("Realm Name:", default_realm);
- このコールバック・ハンドラーはログイン情報のレルム名を収集します。 レルム情報は、常に指定されるとは限りません。 レルム情報が指定されていない場合は、それが現在のレルムであると想定します。
- callbacks[8] = new WSX509CertificateChainCallback("X509Certificate[]:");
- このコールバック・ハンドラーは、ログイン・ソースが Secure Sockets Layer (SSL) クライアント認証からの X509Certificate の場合に、SSL で検証された証明書を含みます。 ltpaLoginModule は、バージョン 6.1 より前の WebSphere Application Server のリリースと同じマッピング関数を呼び出します。 ただし、関数がログインに渡されると、カスタム・ログイン・モジュールが、カスタマイズした方法で証明書をマップできるようになります。 次に、Hashtable ログインが行われます。 Hashtable ログインについて詳しくは、インバウンド ID マッピングの構成を参照してください。
- ログイン・フェーズ中にログイン・モジュール間で情報を共有するために、共有状態の変数を使用します。 WebSphere Application Server がログイン中に作成するオブジェクトにアクセスするには、次の共有状態変数を参照します。 この変数は、以下のログイン・モジュール内で設定されます: ltpaLoginModule、swamLoginModule、および wsMapDefaultInboundLoginModule。
- 共有状態変数
- com.ibm.wsspi.security.auth.callback.Constants.WSPRINCIPAL_KEY
- 目的
- com.ibm.websphere.security.auth.WSPrincipal のオブジェクトを指定します。 アプリケーション・プログラミング・インターフェース (API) の使用法については、WebSphere Application Server API の資料を参照してください。 この 共有状態変数は、読み取り専用です。カスタム・ログイン・モジュールの共有状態内でこの変数を設定しないでください。
- 変数が設定されているログイン・モジュール
- ltpaLoginModule、swamLoginModule および wsMapDefaultInboundLoginModule
- 共有状態変数
- com.ibm.wsspi.security.auth.callback.Constants.WSCREDENTIAL_KEY
- 目的
- com.ibm.websphere.security.cred.WSCredential のオブジェクトを指定します。 API の使用法については、WebSphere Application Server API の資料を参照してください。 この共有状態変数は、読み取り専用です。カスタム・ログイン・モジュールの共有状態内でこの変数を設定しないでください。
- 変数が設定されているログイン・モジュール
- wsMapDefaultInboundLoginModule
- 共有状態変数
- com.ibm.wsspi.security.auth.callback.Constants.WSAUTHZTOKEN_KEY
- 目的
- デフォルトの com.ibm.wsspi.security.token.AuthorizationToken のオブジェクトを指定します。 ログイン・モジュールがこのオブジェクトを使用すると、 wsMapDefaultInboundLoginModule ログイン・モジュールの後にプラグインされたカスタム属性を設定することができます。 ここで設定された情報はダウンストリームに伝搬され、 アプリケーションで利用できるようになります。API の使用法については、WebSphere Application Server API の資料を参照してください。
初期ログインと伝搬ログイン
前述したように、以下の理由でログインが初期ログインと見なされることがあります。- 認証情報が WebSphere Application Server に初めて表示される場合。
- ログイン情報はサーバーから受信されますがセキュリティー属性は伝搬されないため、この情報はユーザー・レジストリーから収集されなければなりません。
WSTokenHolderCallback コールバックが存在し、そこに送信側サーバーからの、WebSphere Application Server ランタイムに必要なすべての必須オブジェクトを再作成するのに十分な情報が含まれている場合、他のログインは伝搬ログインと見なされます。 WebSphere Application Server ランタイムの情報が十分ある場合は、サブジェクトに追加する可能性がある情報は、直前のログインから存在していたと考えられます。 オブジェクトが存在するかどうかを確認するには、 WSTokenHolderCallback コールバックにある ArrayList オブジェクトにアクセスし、 このリストを検索して、各 TokenHolder getName メソッドを参照します。 この検索を使用して、WebSphere Application Server がこのログイン中にご使用のカスタム・オブジェクトをデシリアライズしているかどうかを判別します。 デシリアライゼーション後にカスタム・オブジェクトを追加するように設定されているサブジェクトを見つけるために、 ランタイムが名前の最後に追加情報を追加する可能性があるため、 ストリングの startsWith メソッドを使用して getName メソッドから戻されるクラス名を確認してください。
- login() メソッドをコーディングして、十分な情報が揃った時点を判別します。
以下のコード断片をユーザーの login() メソッドに使用して、 十分な情報が揃った時点を判別することができます。 他の例については、インバウンド ID マッピングの構成を参照してください。
// This is a hint provided by WebSphere Application Server that // sufficient propagation information does not exist and, therefore, // a login is required to provide the sufficient information. In this // situation, a Hashtable login might be used. boolean requiresLogin = ((com.ibm.wsspi.security.auth.callback. WSTokenHolderCallback) callbacks[1]).requiresLogin(); if (requiresLogin) { // Check to see if your object exists in the TokenHolder list, if not, add it. java.util.ArrayList authzTokenList = ((WSTokenHolderCallback) callbacks[6]). getTokenHolderList();boolean found = false; if (authzTokenList != null) { Iterator tokenListIterator = authzTokenList.iterator(); while (tokenListIterator.hasNext()) { com.ibm.wsspi.security.token.TokenHolder th = (com.ibm.wsspi.security.token. TokenHolder) tokenListIterator.next(); if (th != null && th.getName().startsWith("com.acme.myCustomClass")) { found=true; break; } } if (!found) { // go ahead and add your custom object. } } } else { // This code indicates that sufficient propagation information is present. // User registry calls are not needed by WebSphere Application Server to // create a valid Subject. This code might be a no-op in your login module. }
カスタム・ログイン・モジュールのサンプル
次のサンプルを使っていくつかのコールバックや共有状態変数の使い方についての知識を得ることができます。
{ // Defines your login module variables com.ibm.wsspi.security.token.AuthenticationToken customAuthzToken = null; com.ibm.wsspi.security.token.AuthenticationToken defaultAuthzToken = null; com.ibm.websphere.security.cred.WSCredential credential = null; com.ibm.websphere.security.auth.WSPrincipal principal = null; private javax.security.auth.Subject _subject; private javax.security.auth.callback.CallbackHandler _callbackHandler; private java.util.Map _sharedState; private java.util.Map _options; public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { _subject = subject; _callbackHandler = callbackHandler; _sharedState = sharedState; _options = options; } public boolean login() throws LoginException { boolean succeeded = true; // Gets the CALLBACK information javax.security.auth.callback.Callback callbacks[] = new javax.security. auth.callback.Callback[7]; callbacks[0] = new javax.security.auth.callback.NameCallback( "Username: "); callbacks[1] = new javax.security.auth.callback.PasswordCallback( "Password: ", false); callbacks[2] = new com.ibm.websphere.security.auth.callback. WSCredTokenCallbackImpl ("Credential Token: "); callbacks[3] = new com.ibm.wsspi.security.auth.callback. WSServletRequestCallback ("HttpServletRequest: "); callbacks[4] = new com.ibm.wsspi.security.auth.callback. WSServletResponseCallback ("HttpServletResponse: "); callbacks[5] = new com.ibm.wsspi.security.auth.callback. WSAppContextCallback ("ApplicationContextCallback: "); callbacks[6] = new com.ibm.wsspi.security.auth.callback. WSTokenHolderCallback ("Authz Token List: "); try { callbackHandler.handle(callbacks); } catch (Exception e) { // Handles exceptions throw new WSLoginFailedException (e.getMessage(), e); } // Sees which callbacks contain information uid = ((NameCallback) callbacks[0]).getName(); char password[] = ((PasswordCallback) callbacks[1]).getPassword(); byte[] credToken = ((WSCredTokenCallbackImpl) callbacks[2]).getCredToken(); javax.servlet.http.HttpServletRequest request = ((WSServletRequestCallback) callbacks[3]).getHttpServletRequest(); javax.servlet.http.HttpServletResponse response = ((WSServletResponseCallback) callbacks[4]).getHttpServletResponse(); java.util.Map appContext = ((WSAppContextCallback) callbacks[5]).getContext(); java.util.List authzTokenList = ((WSTokenHolderCallback) callbacks[6]).getTokenHolderList(); // Gets the SHARED STATE information principal = (WSPrincipal) _sharedState.get(com.ibm.wsspi.security. auth.callback.Constants.WSPRINCIPAL_KEY); credential = (WSCredential) _sharedState.get(com.ibm.wsspi.security. auth.callback.Constants.WSCREDENTIAL_KEY); defaultAuthzToken = (AuthorizationToken) _sharedState.get(com.ibm. wsspi.security.auth.callback.Constants.WSAUTHZTOKEN_KEY); // What you tend to do with this information depends upon the scenario // that you are trying to accomplish. This example demonstrates how to // access various different information: // - Determine if a login is initial versus propagation // - Deserialize a custom authorization token (For more information, see // セキュリティー属性の伝搬 // - Add a new custom authorization token (For more information, see // セキュリティー属性の伝搬 // - Look for a WSCredential and read attributes, if found. // - Look for a WSPrincipal and read attributes, if found. // - Look for a default AuthorizationToken and add attributes, if found. // - Read the header attributes from the HttpServletRequest, if found. // - Add an attribute to the HttpServletResponse, if found. // - Get the Web application name from the appContext, if found. // - Determines if a login is initial versus propagation. This is most // useful when login module is first. boolean requiresLogin = ((WSTokenHolderCallback) callbacks[6]).requiresLogin(); // initial login - asserts privilege attributes based on user identity if (requiresLogin) { // If you are validating a token from another server, there is an // application programming interface (API) to get the uniqueID from it. if (credToken != null && uid == null) { try { String uniqueID = WSSecurityPropagationHelper. validateLTPAToken(credToken); String realm = WSSecurityPropagationHelper.getRealmFromUniqueID (uniqueID); // Now set it to the UID so you can use that to either map or // login with. uid = WSSecurityPropagationHelper.getUserFromUniqueID (uniqueID); } catch (Exception e) { // handle exception } } // Adds a Hashtable to shared state. // Note: You can perform custom mapping on the NameCallback value returned // to change the identity based upon your own mapping rules. uid = mapUser (uid); // Gets the default InitialContext for this server. javax.naming.InitialContext ctx = new javax.naming.InitialContext(); // Gets the local UserRegistry object. com.ibm.websphere.security.UserRegistry reg = (com.ibm.websphere.security. UserRegistry) ctx.lookup("UserRegistry"); // Gets the user registry uniqueID based on the uid specified in the // NameCallback. String uniqueid = reg.getUniqueUserId(uid); uid = WSSecurityPropagationHelper.getUserFromUniqueID (uniqueID); // Gets the display name from the user registry based on the uniqueID. String securityName = reg.getUserSecurityName(uid); // Gets the groups associated with this uniqueID. java.util.List groupList = reg.getUniqueGroupIds(uid); // Creates the java.util.Hashtable with the information you gathered from // the UserRegistry. java.util.Hashtable hashtable = new java.util.Hashtable(); hashtable.put(com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_UNIQUEID, uniqueid); hashtable.put(com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_SECURITYNAME, securityName); hashtable.put(com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_GROUPS, groupList); // Adds a cache key that is used as part of the lookup mechanism for // the created Subject. The cache key can be an Object, but should // implement the toString() method. Make sure the cacheKey contains // enough information to scope it to the user and any additional // attributes that you use. If you do not specify this property the // Subject is scoped to the WSCREDENTIAL_UNIQUEID returned, by default. hashtable.put(com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_CACHE_KEY, "myCustomAttribute" + uniqueid); // Adds the hashtable to the sharedState of the Subject. _sharedState.put(com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_PROPERTIES_KEY,hashtable); } // propagation login - process propagated tokens else { // - Deserializes a custom authorization token. For more information, see // セキュリティー属性の伝搬. // This can be done at any login module plug in point (first, // middle, or last). if (authzTokenList != null) { // Iterates through the list looking for your custom token for (int i=0; i<authzTokenList.size(); i++) { TokenHolder tokenHolder = (TokenHolder)authzTokenList.get(i); // Looks for the name and version of your custom AuthorizationToken // implementation if (tokenHolder.getName().equals("com.ibm.websphere.security.token. CustomAuthorizationTokenImpl") && tokenHolder.getVersion() == 1) { // Passes the bytes into your custom AuthorizationToken constructor // to deserialize customAuthzToken = new com.ibm.websphere.security.token. CustomAuthorizationTokenImpl(tokenHolder.getBytes()); } } } // - Adds a new custom authorization token (For more information, // see セキュリティー属性の伝搬) // This can be done at any login module plug in point (first, middle, // or last). else { // Gets the PRINCIPAL from the default AuthenticationToken. This must // match all of the tokens. defaultAuthToken = (com.ibm.wsspi.security.token.AuthenticationToken) sharedState.get(com.ibm.wsspi.security.auth.callback.Constants. WSAUTHTOKEN_KEY); String principal = defaultAuthToken.getPrincipal(); // Adds a new custom authorization token. This is an initial login. // Pass the principal into the constructor customAuthzToken = new com.ibm.websphere.security.token. CustomAuthorizationTokenImpl(principal); // Adds any initial attributes if (customAuthzToken != null) { customAuthzToken.addAttribute("key1", "value1"); customAuthzToken.addAttribute("key1", "value2"); customAuthzToken.addAttribute("key2", "value1"); customAuthzToken.addAttribute("key3", "something different"); } } } // - Looks for a WSCredential and read attributes, if found. // This is most useful when plugged in as the last login module. if (credential != null) { try { // Reads some data from the credential String securityName = credential.getSecurityName(); java.util.ArrayList = credential.getGroupIds(); } catch (Exception e) { // Handles exceptions throw new WSLoginFailedException (e.getMessage(), e); } } // - Looks for a WSPrincipal and read attributes, if found. // This is most useful when plugged as the last login module. if (principal != null) { try { // Reads some data from the principal String principalName = principal.getName(); } catch (Exception e) { // Handles exceptions throw new WSLoginFailedException (e.getMessage(), e); } } // - Looks for a default AuthorizationToken and add attributes, if found. // This is most useful when plugged in as the last login module. if (defaultAuthzToken != null) { try { // Reads some data from the defaultAuthzToken String[] myCustomValue = defaultAuthzToken.getAttributes ("myKey"); // Adds some data if not present in the defaultAuthzToken if (myCustomValue == null) defaultAuthzToken.addAttribute ("myKey", "myCustomData"); } catch (Exception e) { // Handles exceptions throw new WSLoginFailedException (e.getMessage(), e); } } // - Reads the header attributes from the HttpServletRequest, if found. // This can be done at any login module plug in point (first, middle, // or last). if (request != null) { java.util.Enumeration headerEnum = request.getHeaders(); while (headerEnum.hasMoreElements()) { System.out.println ("Header element: " + (String)headerEnum.nextElement()); } } // - Adds an attribute to the HttpServletResponse, if found // This can be done at any login module plug in point (first, middle, // or last). if (response != null) { response.addHeader ("myKey", "myValue"); } // - Gets the Web application name from the appContext, if found // This can be done at any login module plug in point (first, middle, // or last). if (appContext != null) { String appName = (String) appContext.get(com.ibm.wsspi.security.auth. callback.Constants.WEB_APP_NAME); } return succeeded; } public boolean commit() throws LoginException { boolean succeeded = true; // Add any objects here that you have created and belong in the // Subject. Make sure the objects are not already added. If you added // any sharedState variables, remove them before you exit. If the abort() // method gets called, make sure you cleanup anything added to the // Subject here. if (customAuthzToken != null) { // Sets the customAuthzToken token into the Subject try { // Do this in a doPrivileged code block so that application code // does not need to add additional permissions java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() { public Object run() { try { // Adds the custom authorization token if it is not // null and not already in the Subject if ((customAuthzTokenPriv != null) && (!_subject.getPrivateCredentials().contains(customAuthzTokenPriv))) { _subject.getPrivateCredentials().add(customAuthzTokenPriv); } } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } return null; } }); } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } } return succeeded; } public boolean abort() throws LoginException { boolean succeeded = true; // Makes sure to remove all objects that have already been added (both into the // Subject and shared state). if (customAuthzToken != null) { // remove the customAuthzToken token from the Subject try { final AuthorizationToken customAuthzTokenPriv = customAuthzToken; // Do this in a doPrivileged block so that application code does not need // to add additional permissions java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() { public Object run() { try { // Removes the custom authorization token if it is not // null and not already in the Subject if ((customAuthzTokenPriv != null) && (_subject.getPrivateCredentials(). contains(customAuthzTokenPriv))) { _subject.getPrivateCredentials(). remove(customAuthzTokenPriv); } } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } return null; } }); } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } } return succeeded; } public boolean logout() throws LoginException { boolean succeeded = true; // Makes sure to remove all objects that have already been added // (both into the Subject and shared state). if (customAuthzToken != null) { // Removes the customAuthzToken token from the Subject try { final AuthorizationToken customAuthzTokenPriv = customAuthzToken; // Do this in a doPrivileged code block so that application code does // not need to add additional permissions java.security.AccessController.doPrivileged(new java.security. PrivilegedAction() { public Object run() { try { // Removes the custom authorization token if it is not null and not // already in the Subject if ((customAuthzTokenPriv != null) && (_subject. getPrivateCredentials(). contains(customAuthzTokenPriv))) { _subject.getPrivateCredentials().remove(customAuthzTokenPriv); } } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } return null; } }); } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } } return succeeded; } }
- カスタム・ログイン・モジュールのシステム・ログインを構成します。
システム・ログイン構成のカスタム・ログイン・モジュールを開発したら、管理コンソールまたは wsadmin ユーティリティーを使用して、システム・ログインを構成できます。 管理コンソールを使用してシステム・ログインを構成するには、「セキュリティー」>「グローバル・セキュリティー」とクリックします。 「Java 認証・承認サービス」の下の「システム・ログイン」をクリックします。 システム・ログイン構成のための wsadmin ユーティリティーの使い方について詳しくは、サーバー・サイドの Java Authentication and Authorization Service の認証およびログイン構成のカスタマイズを参照してください。 また、システム・ログイン・モジュールの情報を得るため、および新たなログイン・モジュールの追加を判断するためにも、この文書を参照してください。
サブトピック
Java Authentication and Authorization Service によるアプリケーション・ログインのカスタマイズ
Java Authentication and Authorization Service (JAAS) を使用して、アプリケーションのログインをカスタマイズできます。


http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tsec_jaascustlogmod
ファイル名:tsec_jaascustlogmod.html