呼び出し元サブジェクト (または「受信サブジェクト」) には、 この要求への呼び出しで使用されるユーザー認証情報が含まれます。このサブジェクトは、 既存のオブジェクトが置き換えられないように、WSSubject.getCallerSubject アプリケーション・プログラミング・インターフェース (API) の 発行後に戻されます。このサブジェクトは読み取り専用とマークされています。この API を使用すると、 WSCredential クレデンシャルにアクセスできるので、クレデンシャル内の hashmap にデータを書き込んだり設定したり することができます。
try
{
javax.security.auth.Subject caller_subject;
com.ibm.websphere.security.cred.WSCredential caller_cred;
caller_subject = com.ibm.websphere.security.auth.WSSubject.getCallerSubject();
if (caller_subject != null)
{
caller_cred = caller_subject.getPublicCredentials(com.ibm.websphere.security.cred.WSCredential.class).iterator().next();
String CALLERDATA = (String) caller_cred.get ("MYKEY");
System.out.println("My data from the Caller credential is: " + CALLERDATA);
}
}
catch (WSSecurityException e)
{
// log error
}
catch (Exception e)
{
// log error
}
要件: この API を実行するには、次のような Java 2 セキュリティー権限が必要です。 permission javax.security.auth.AuthPermission "wssecurity.getCallerSubject;"