Common Object Request Broker Architecture (CORBA) プログラマチック・ログインの Java Authentication and Authorization Service (JAAS) へのマイグレーション

このトピックは、CORBA ベースのプログラマチック・ログイン API を用いたプログラマチック・ログインの実行方法の例として使用します。

始める前に

[AIX Solaris HP-UX Linux Windows][IBM i]ここでは、非推奨の Common Object Request Broker Architecture (CORBA) プログラマチック・ログイン API、および JAAS の提供する 代替手段について概説します。WebSphere® Application Server は、Java™ Authentication and Authorization Service (JAAS) をプログラマチック・ログインのアプリケーション・プログラミング・インターフェース (API) として完全にサポートします。 JAAS サポートの詳細については、 Java Authentication and Authorization Service のプログラマチック・ログインの構成およびJava Authentication and Authorization Service によるプログラマチック・ログインの開発を参照してください。

[z/OS]Common Object Request Broker Architecture (CORBA) アプリケーション・プログラミング・インターフェース (API) は、WebSphere Application Server for z/OS® 環境ではサポートされません。 別の WebSphere Application Server 製品から WebSphere Application Server for z/OS へ移植するアプリケーションがある場合、セキュリティー API は、バージョン 6.0.x では非推奨であることに注意してください。 これらのアプリケーションを WebSphere Application Server for z/OS バージョン 8.0 で 使用する場合、Java 認証・承認サービス (JAAS) へのマイグレーションが必要です。

次のリストに示すのは、非推奨の CORBA プログラマチック・ログイン API です。
  • [AIX Solaris HP-UX Linux Windows][z/OS]${user.install.root}/installedApps/sampleApp.ear/default_app.war/WEB-INF/classes/LoginHelper.java
  • [AIX Solaris HP-UX Linux Windows][z/OS]${user.install.root}/installedApps/sampleApp.ear/default_app.war/WEB-INF/classes/ServerSideAuthenticator.java
  • [IBM i]profile_root/installedApps/sampleApp.ear/default_app.war/WEB-INF/classes/ServerSideAuthenticator.java.
  • [AIX Solaris HP-UX Linux Windows][IBM i]org.omg.SecurityLevel2.Credentials。 この API は製品に組み込まれていますが、API の使用は推奨されていません。

WebSphere Application Server で提供される API は、標準 JAAS API と標準 JAAS インターフェースの製品実装の組み合わせです。

[z/OS]WebSphere Application Server for z/OS で提供されるサポート API は、標準 JAAS API と、一部のマイナーな拡張機能を含む標準 JAAS インターフェースの製品実装の組み合わせです。

次に示すのは要約のみです。 詳しくは、ご使用のプラットフォーム用の JAAS 資料 (http://www.ibm.com/developerworks/java/jdk/security/) を参照してください。

  • プログラマチック・ログイン API は、以下のとおりです。
    • javax.security.auth.login.LoginContext
    • javax.security.auth.callback.CallbackHandler interface: WebSphere Application Server 製品は、javax.security.auth.callback.CallbackHandler インターフェースの以下の実装を提供します。
      com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl
      アプリケーションが、基本認証データ (ユーザー ID、パスワード、 およびセキュリティー・レルム) またはトークン・データを製品ログイン・モジュールにプッシュするときに、 非プロンプトの CallbackHandler ハンドラーを提供します。この API は、 サーバー・サイド・ログインの場合に推奨されます。
      [AIX Solaris HP-UX Linux Windows][IBM i]com.ibm.websphere.security.auth.callback.WSGUICallbackHandlerImpl
      [AIX Solaris HP-UX Linux Windows][IBM i]基本認証データ (ユーザー ID、パスワード、およびセキュリティー・レルム) を 集めるためのログイン・プロンプト CallbackHandler ハンドラーを提供します。この API は、クライアント・サイド・ログインの場合に推奨されます。

      この API がサーバー・サイドで使用されると、サーバーからの入力は妨害されます。

      com.ibm.websphere.security.auth.callback.WSStdinCallbackHandlerImpl
      基本認証データ (ユーザー ID、パスワード、およびセキュリティー・レルム) を集めるための 標準入力ログイン・プロンプト CallbackHandler ハンドラーを提供します。この API は、クライアント・サイド・ログインの場合に推奨されます。
      注: この API がサーバー・サイドで使用されると、サーバーからの入力は妨害されます。
    • javax.security.auth.callback.Callback インターフェースは、以下のとおりです。
      javax.security.auth.callback.NameCallback
      ユーザー名を LoginModules インターフェースに渡すために JAAS によって提供されます。
      javax.security.auth.callback.PasswordCallback
      パスワードを LoginModules インターフェースに渡すために JAAS によって提供されます。
      com.ibm.websphere.security.auth.callback.WSCredTokenCallbackImpl
      トークン・ベースのログインを行うため、製品により提供されます。この API により、アプリケーションはトークン・バイト配列を LoginModules インターフェースに渡すことができます。
    • javax.security.auth.spi.LoginModule interface

      WebSphere Application Server は、クライアントおよびサーバー・サイド・ログインに LoginModules 実装を提供します。詳しくは、 Java Authentication and Authorization Service のプログラマチック・ログインの構成を参照してください。

  • javax.security.Subject は、以下のとおりです。
    [AIX Solaris HP-UX Linux Windows][IBM i]com.ibm.websphere.security.auth.WSSubject
    [AIX Solaris HP-UX Linux Windows][IBM i]製品によって提供される拡張機能であり、javax.security.Subject 内のクレデンシャルを使用して リモート J2EE リソースを呼び出します。
    [z/OS]com.ibm.websphere.security.auth.WSSubject
    [z/OS]製品によって提供される拡張機能であり、javax.security.Subject 内のクレデンシャルを使用して リモート J2EE リソースを呼び出します。

    アプリケーションは、WebSphere Application Server ログイン・モジュールの明示的な呼び出しにより生成されるサブジェクトを使用して、J2EE リソース・アクセスの WSSubject.doAs メソッドを呼び出す必要があります。

    com.ibm.websphere.security.cred.WSCredential
    WebSphere Application Server LoginModules インターフェースを使用して JAAS ログインが成功した後、com.ibm.websphere.security.cred.WSCredential クレデンシャルが作成されてサブジェクト内に保管されます。
    com.ibm.websphere.security.auth.WSPrincipal
    認証済みプリンシパルであり、作成された後、WebSphere Application Server LoginModules インターフェースによって認証される Subject 内に保管されます。

手順

  1. [AIX Solaris HP-UX Linux Windows][IBM i]CORBA ベースのプログラマチック・ログイン API を用いたプログラマチック・ログインの実行方法として、 以下の例を使用します。 CORBA ベースのプログラマチック・ログイン API は、JAAS ログインに置き換えられました。
    注: 以下の例で使用されている LoginHelper アプリケーション・プログラミング・インターフェース (API) は、WebSphere Application Server バージョン 9.0 では推奨されていません。また将来のリリースでは除去される予定です。 次のステップで示している JAAS プログラマチック・ログイン API の使用が推奨されています。
    public class TestClient {
    ...
    private void performLogin() {
    // Get the ID and password of the user.
    String userid = customGetUserid();
    String password = customGetPassword();
    
    // Create a new security context to hold authentication data.
    LoginHelper loginHelper = new LoginHelper();
    try {
    // Provide the ID and password of the user for authentication.
    org.omg.SecurityLevel2.Credentials credentials = 
    loginHelper.login(userid, password);
    
    // Use the new credentials for all future invocations.
    loginHelper.setInvocationCredentials(credentials);
    // Retrieve the name of the user from the credentials
    // so we can tell the user that login succeeded.
    
    String username = loginHelper.getUserName(credentials);
    System.out.println("Security context set for user: "+username);
    } catch (org.omg.SecurityLevel2.LoginFailed e) {
    // Handle the LoginFailed exception.
    }
    }
    ...
    }
  2. 以下の例を使用して、 CORBA ベースのプログラマチック・ログイン API を JAAS プログラマチック・ログイン API にマイグレーションします。

    以下の例では、アプリケーション・コードに、必須の Java 2 セキュリティー権限が与えられているものと想定します。 詳しくは、Java Authentication and Authorization Service のプログラマチック・ログインの構成アプリケーション開発用のシステム・リソースおよび API (Java 2 セキュリティー) の保護、 および http://www.ibm.com/developerworks/java/jdk/security/ にある、JAAS の資料を参照してください。

    public class TestClient {
    ...
    private void performLogin() {
    // Create a new JAAS LoginContext.
    javax.security.auth.login.LoginContext lc = null;
    
    try {
    // Use GUI prompt to gather the BasicAuth data.
    lc = new javax.security.auth.login.LoginContext("WSLogin",
    new com.ibm.websphere.security.auth.callback.WSGUICallbackHandlerImpl());
    
    // create a LoginContext and specify a CallbackHandler implementation
    // CallbackHandler implementation determine how authentication data is collected
    // in this case, the authentication date is collected by  login prompt
    //   and pass to the authentication mechanism implemented by the LoginModule.
    } catch (javax.security.auth.login.LoginException e) {
    System.err.println("ERROR: failed to instantiate a LoginContext and the exception: " 
    + e.getMessage());
    e.printStackTrace();
    
    // may be javax.security.auth.AuthPermission "createLoginContext" is not granted
    //   to the application, or the JAAS Login Configuration is not defined.
    }
    
    if (lc != null)
    try {
    lc.login();  // perform login
    javax.security.auth.Subject s = lc.getSubject();
    // get the authenticated subject
    
    // Invoke a J2EE resources using the authenticated subject
    com.ibm.websphere.security.auth.WSSubject.doAs(s,
    new java.security.PrivilegedAction() {
    public Object run() {
    try {
    bankAccount.deposit(100.00);  // where bankAccount is an protected EJB
    } catch (Exception e) {
    System.out.println("ERROR: error while accessing EJB resource, exception: " 
    + e.getMessage());
    e.printStackTrace();
    }
    return null;
    }
    }
    );
    
    // Retrieve the name of the principal from the Subject
    // so we can tell the user that login succeeded,
    // should only be one WSPrincipal.
    java.util.Set ps =
    s.getPrincipals(com.ibm.websphere.security.auth.WSPrincipal.class);
    java.util.Iterator it = ps.iterator();
    while (it.hasNext()) {
    com.ibm.websphere.security.auth.WSPrincipal p =
    (com.ibm.websphere.security.auth.WSPrincipal) it.next();
    System.out.println("Principal: " + p.getName());
    }
    } catch (javax.security.auth.login.LoginException e) {
    System.err.println("ERROR: login failed with exception: " + e.getMessage());
    e.printStackTrace();
    
    // login failed, might want to provide relogin logic
    }
    }
    ...
    }

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



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