JAAS のスレッドの RunAs サブジェクトのオーバーライド
Java™ Authentication and Authorization Service (JAAS) のアプリケーション・プログラミング・インターフェース (API) で提供されている機能を拡張するには、RunAs サブジェクトまたは呼び出しサブジェクトに、この実行スレッド上のアウトバウンド要求に使用される別の有効なエントリーを設定します。
始める前に
- permission javax.security.auth.AuthPermission "wssecurity.getRunAsSubject"
- permission javax.security.auth.AuthPermission "wssecurity.getCallerSubject"
- permission javax.security.auth.AuthPermission "wssecurity.setRunAsSubject"
このタスクについて
この拡張機能により、WSSubject.doAs メソッドを使用して サブジェクトをリモート・アクションに関連付けるかどうかにかかわらず、 このスレッド上のすべてのリモート呼び出しに対するサブジェクトの関連付けが柔軟に行えるようになります。
アプリケーション開発者は、WSSubject.doAs メソッドを使用して、JAAS サブジェクトを設定できます。このサブジェクトは、JAAS ログイン・モジュールによって、WebSphere® Application Server ランタイムが指定のアクションを実行する際に使用する、アクティブ・セキュリティー ID として認証されます。
WSSubject.doAs は、sync-to-thread に対して構成されたコンポーネント内で呼び出されたときのみスレッド ID と同期します。
アプリケーションの「Synch to OS Thread Allowed」オプションと併用する場合、
この ID は、そのアクションの有効範囲に対応するオペレーティング・システムのスレッド上に設定されます。
手順
例
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 }