WebSphere Application Server Network Deployment, Version 6.0.x   Operating Systems: AIX, HP-UX, Linux, Solaris, Windows
             [TIP: Focusing the table of contents and search results]

Example: Getting the RunAs subject from the thread

The RunAs subject or invocation subject contains the user authentication information for the RunAs mode set in the application deployment descriptor for this method.

The RunAs subject (or invocation subject) contains the user authentication information for the RunAs mode set in the application deployment descriptor for this method. This subject is marked read-only when returned from the WSSubject.getRunAsSubject application programming interface (API) to prevent replacing existing objects. You can use this API to get access to the WSCredential credential, which is documented in the API documentation, 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 credential is propagated downstream and a new Caller subject is generated.
try
{
	javax.security.auth.Subject runas_subject;
	com.ibm.websphere.security.cred.WSCredential runas_cred;
	
	runas_subject = com.ibm.websphere.security.auth.WSSubject.getRunAsSubject();

	if (runas_subject != null)
	{
		runas_cred = runas_subject.getPublicCredentials(
                com.ibm.websphere.security.cred.WSCredential.class).iterator().next();
		String RUNASDATA = (String) runas_cred.get ("MYKEY");
		System.out.println("My data from the RunAs credential is:  " + RUNASDATA );
	}
}
catch (WSSecurityException e)
{
	// log error
}
catch (Exception e)
{
	// log error
}

Requirements: You need the Java 2 security permissions to run this API: permission javax.security.auth.AuthPermission "wssecurity.getRunAsSubject;".




Related tasks
Customizing application login with Java Authentication and Authorization Service
Related reference
Customization of a server-side Java Authentication and Authorization Service authentication and login configuration
Reference topic    

Terms of Use | Feedback

Last updated: Mar 8, 2007 8:14:28 PM CST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/rsec_getrunas.html

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