WebSphere Application Server Network Deployment, Version 6.0.x     Operating Systems: AIX, HP-UX, Linux, Solaris, Windows

Example: Getting the Caller Subject from the Thread

The Caller subject (or "received subject") contains the user authentication information used in the call for this request. This subject is returned after issuing the WSSubject.getCallerSubject() API to prevent replacing existing objects. The subject is marked read-only. This API can be used to get access to the WSCredential (documented in the Javadoc information) so that you can put or set data in the hashmap within the credential.

Most data within the subject is not propagated downstream to another server. Only the credential token within the WSCredential is propagated downstream (and a new caller subject generated).

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
}

Requirement: You need the following Java 2 Security permissions to execute this API: permission javax.security.auth.AuthPermission "wssecurity.getCallerSubject;".




Reference topic    

Terms of Use | Feedback

Last updated: Mar 17, 2005 4:28:29 AM CST
http://publib.boulder.ibm.com/infocenter/ws60help/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/rsec_getcaller.html

© Copyright IBM Corporation 2002, 2005. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)