レジストリーの相互作用のない UsernameToken 呼び出し元構成の構成

WebSphere® レジストリーにアクセスすることなく、呼び出し元構成を使用して UsernameToken を認証するために、UsernameToken コンシューマーの認証メソッドを置き換え、呼び出し側が別の JAAS ログイン構成を使用するように構成することができます。

このタスクについて

この情報は、Java API for XML Web Services (JAX-WS) にのみ適用されます。

デフォルトでは、JAX-WS Web サービス・セキュリティーの UsernameToken コンシューマーの UNTConsumeLoginModule は、常に WebSphere レジストリーに対してトークン内に含まれているユーザー名とパスワードを検証します。GenericSecurityTokenFactory が提供する SPI を使用して、この認証メソッドを独自のものに置き換えることができます。詳しくは、「スタックされた JAAS ログイン・モジュールを使用した UsernameToken コンシューマーの認証メソッドの置き換え」を参照してください。

呼び出し元構成がサービス・プロバイダーの WS-Security 制約に追加される場合、UsernameToken に含まれているユーザー名とパスワードも、WebSphere レジストリーと照らし合わせて検証されます。ユーザー名とパスワードが指定された場合は、ユーザー名とパスワードの両方が WebSphere レジストリーと照らし合わせて検証されます。ユーザー名のみが指定された場合は、ユーザー名がWebSphere レジストリー内に存在している必要があります。以下の例に示すように、これらの検証は wss.caller Java™ Authentication and Authorization Service (JAAS) 構成スタックの一部である com.ibm.ws.security.server.lm.ltpaLoginModule モジュールで発生します。

com.ibm.ws.wssecurity.impl.auth.module.PreCallerLoginModule
com.ibm.ws.wssecurity.impl.auth.module.UNTCallerLoginModule
...
com.ibm.ws.wssecurity.impl.auth.module.WSWSSLoginModule
com.ibm.ws.security.server.lm.ltpaLoginModule
com.ibm.ws.security.server.lm.wsMapDefaultInboundLoginModule

WebSphere WS-Security ランタイムは、ログイン・モジュール ltpaLoginModule および wsMapDefaultInboundLoginModule が含まれていない呼び出し元の JAAS 構成の使用をサポートしていません。

WebSphere レジストリーにアクセスすることなく、呼び出し元構成で UsernameToken を使用するには、UNTConsumeLoginModule および ltpaLoginModule モジュールがレジストリーにアクセスできないようにして、代替モジュールを指定する必要があります。

手順

  1. UNTConsumeLoginModule モジュールがレジストリーにアクセスできないようにするには、UsernameToken コンシューマーの認証メソッドを置き換えてください。詳しくは、twbs_replace_authmethod_usernametoken.htmlを参照してください。
  2. com.ibm.ws.wssecurity.impl.auth.module.WSWSSLoginModule の上にスタックする JAAS ログイン・モジュールを開発します。 以下の例は、JAAS ログイン・モジュールのサンプル・コードを示しています。
    package test.tokens;
    
    import java.util.Map;
    import java.util.Hashtable;
    
    import javax.security.auth.Subject;
    import javax.security.auth.callback.CallbackHandler;
    import javax.security.auth.login.LoginException;
    import javax.security.auth.spi.LoginModule;
    import com.ibm.websphere.wssecurity.wssapi.token.UsernameToken;
    import com.ibm.websphere.wssecurity.wssapi.token.SecurityToken;
    import com.ibm.wsspi.security.token.AttributeNameConstants;
    
    public class MyAuthLoginModule implements LoginModule {
    
      private Map<String, ?> _sharedState;
    
      	public void initialize(Subject subject, CallbackHandler callbackHandler, 
                             Map<String, ?> sharedState, Map<String, ?> options) {
    
        this._sharedState = sharedState;
      }
    
      public boolean login() throws LoginException {
        //For the sake of readability, this login module does not
        //protect against all NPE's
    
    		String username = null;
    	  
    	// get the caller token
    		SecurityToken callerIdentityToken = (SecurityToken)this._sharedState.get(
    	    com.ibm.wsspi.wssecurity.core.Constants.WSSECURITY_CALLER_IDENTITY);
    
    		// if its a UsernameToken, get the username
    		if (callerIdentityToken instanceof UsernameToken) {
    	  	  username = ((UsernameToken)callerIdentityToken).getUsername();
    	}
    	if (username == null) {
    	  	  throw new LoginException("Unable to obtain username");
    	}
    
    		Hashtable customProperties = (Hashtable)_sharedState.get(AttributeNameConstants.WSCREDENTIAL_PROPERTIES_KEY);
    	if (customProperties == null) {
    	  	  customProperties = new Hashtable();
    	}
    
    		// setting the UNIQUEID makes ltpaLoginModule skip the registry check	  
    		// Default realm is used here, but any trusted realm can be used
       String uid = "defaultWIMFileBasedRealm/" + username;
       customProperties.put(AttributeNameConstants.WSCREDENTIAL_UNIQUEID, uid)
     //implement the rest of the methods required by the
     //LoginModule interface
    }
  3. 新規 JAAS ログイン構成を作成します。
    1. 管理コンソールで、「セキュリティー」 > 「グローバル・セキュリティー」に移動します。
    2. 「認証」で、「Java 認証・承認サービス」 > 「システム・ログイン」に移動します。
    3. 「新規」をクリックし、「別名」の下でtest.auth.unt と指定します。
    4. JAAS ログイン・モジュールを追加します。 表示されている順序で、以下のログイン・モジュールを追加する必要があります。
      • com.ibm.ws.wssecurity.impl.auth.module.PreCallerLoginModule
      • com.ibm.ws.wssecurity.impl.auth.module.UNTCallerLoginModule
      • test.tokens.MyAuthLoginModule
        重要: このモジュールの名前は、開発した JAAS ログイン・モジュールと一致しなければなりません。
      • com.ibm.ws.wssecurity.impl.auth.module.WSWSSLoginModule
      • com.ibm.ws.security.server.lm.ltpaLoginModule
      • com.ibm.ws.security.server.lm.wsMapDefaultInboundLoginModule
      各ログイン・モジュールで、以下のようにします。
      1. JAAS ログイン・モジュールの下で「新規」をクリックします。
      2. モジュール・クラス名の下で、ログイン・モジュールの名前を入力します。
      3. test.tokens.MyAuthLoginModule の場合のみ、「ログイン・モジュール・プロキシーを使用」を選択します。
      4. 「OK」をクリックします。
    5. 「OK」 をクリックしてから、「保存」をクリックします。
  4. 呼び出し元で新規 JAAS 構成を使用するように構成します。
    1. 管理コンソールで、変更するバインディング構成を開きます。
    2. 「WS-Security」 > 「呼び出し元」を選択します。
    3. 変更する呼び出し元構成を選択します。
    4. JAAS ログインの下で、test.auth.unt を選択します。
    5. 「OK」 をクリックしてから、「保存」をクリックします。
  5. アプリケーション・サーバーを再始動して JAAS 構成の変更を適用します。
  6. サービスをテストします。

トピックのタイプを示すアイコン タスク・トピック



タイム・スタンプ・アイコン 最終更新: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twbs_config_wssec_caller_no_reg
ファイル名:twbs_config_wssec_caller_no_reg.html