请勿使用 WSPrincipal.getCredential( )

此规则会标记以下不推荐的方法:

该方法在 WebSphere Application Server 版本 5.1

您应该使用 com.ibm.websphere.security.auth.WSSubject.getRunAsSubject() com.ibm.websphere.security.auth.WSSubject.getCallerSubject() 方法。

下面的示例显示了自动修复如何将 传统的 WSPrincipal.getCredential( ) 替换为推荐的 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(); // 考虑正确的日志记录 } return credential;

此规则具有用于更新名称空间值的自动修订。 将定制配置复制到应用程序构建文件以启用修订自动化。

有关更多类信息,请参阅: