Do not use WSPrincipal.getCredential()

This rule flags the following deprecated method:

This method is deprecated in WebSphere Application Server Version 5.1

You should use the com.ibm.websphere.security.auth.WSSubject.getRunAsSubject() or the com.ibm.websphere.security.auth.WSSubject.getCallerSubject() method instead.

The following example shows how the automated fix replaces the legacy WSPrincipal.getCredential() with the recommended WSSubject.getCallerSubject() :

com.ibm.websphere.security.cred.WSCredential credential = null;
try {
    javax.security.auth.Subject subject = com.ibm.websphere.security.auth.WSSubject.getCallerSubject();
    if (subject != null) {
        credential = subject.getPublicCredentials(WSCredential.class).iterator().next();
    }
} catch (Exception e) {
    e.printStackTrace(); // Consider proper logging
}
return credential;

This rule has an automated fix to update the namespace value. Copy the custom configuration to your application build file to enable the fix automation.

For additional class information, see: