The RunAs subject (or invocation subject) contains the user authentication information for the RunAs mode set in the application deployment descriptor for this method.
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 following Java 2 Security permissions to run this API: permission javax.security.auth.AuthPermission "wssecurity.getRunAsSubject;".
Related concepts
Programmatic login