Java Authentication and Authorization Service (JAAS) のアプリケーション・プロ グラミング・インターフェース (API) で提供されている機能を拡張するためには、RunAs サブジェクトまたは呼び出しサブジェクトに、 この実行スレッド上のアウトバウンド要求に使用される別の有効なエントリーを設定します。
try
{
javax.security.auth.Subject runas_subject, caller_subject;
runas_subject = com.ibm.websphere.security.auth.WSSubject.getRunAsSubject();
caller_subject = com.ibm.websphere.security.auth.WSSubject.getCallerSubject();
// set a new RunAs subject for the thread, overriding the one declaratively set
com.ibm.websphere.security.auth.WSSubject.setRunAsSubject(caller_subject);
// do some remote calls
// restore back to the previous runAsSubject
com.ibm.websphere.security.auth.WSSubject.setRunAsSubject(runas_subject);
}
catch (WSSecurityException e)
{
// log error
}
catch (Exception e)
{
// log error
}
アプリケーション開発者は、WSSubject.doAs メソッドを
使用して、JAAS サブジェクトを設定できます。
このサブジェクトは、JAAS ログイン・モジュールによって、WebSphere
Application Server ランタイムが
指定のアクションを実行する際に使用する、
アクティブ・セキュリティー ID として認証されます。
WSSubject.doAs は、sync-to-thread に対して構成されたコンポーネント内で呼び出されたときのみスレッド ID と同期します。
アプリケーションの「Synch to OS Thread Allowed」オプションと併用する場合、
この ID は、そのアクションの有効範囲に対応するオペレーティング・システムのスレッド上に設定されます。