在 JAAS 登录模块之间传递 SAML 令牌
SAMLGenerateLoginModule 可以用于从应用程序的 JAAS 登录模块中初始化的共享状态对象获取应用程序生成的 SAML 令牌。此外,还可以使用 GenericIssuedTokenGenerateLoginModule 从共享状态中获取应用程序生成的 SAML 令牌。有关更多信息,请参阅“使用堆栈化 JAAS 登录模块来生成并使用 SAML 令牌”主题。
关于此任务
以下过程描述使用此功能所需的设置。
过程
- 以 JAAS 登录模块的初始化方法将共享状态对象保存到类变量。
import com.ibm.websphere.wssecurity.wssapi.token.SecurityToken; import com.ibm.websphere.wssecurity.wssapi.token.SAMLToken; import com.ibm.wsspi.wssecurity.core.Constants; public class myLoginModule implements LoginModule { ... private Map _sharedState; ... public void initialize(Subject subject, CallbackHandle rcallbackHandler, Map<String, ?> sharedState, Map<String, ?> options) { ... this._sharedState = sharedState; ... }
- 通过使用下列一种方法,将应用程序生成的 SAML 令牌置于 sharedState 对象上:
- 创建 SecurityToken 的阵列列表,并将应用程序生成的 SAMLToken 作为唯一条目置于此列表中。WS-Security 运行时会在列表中循环并仅使用第一个匹配项。
- 将 ArrayList 对象置于具有以下键的 _sharedState 对象中:com.ibm.wsspi.wssecurity.core.Constants.WSSECURITY_TOKEN_TO_BE_INSERTED。
com.ibm.wsspi.wssecurity.core.Constants. WSSECURITY_TOKEN_TO_BE_INSERTED public boolean login() throws LoginException { ... SAMLToken mySamlToken=someSAMLToken; ArrayList<SecurityToken> tokenList = new ArrayList<SecurityToken>(); tokenList.add(mySamlToken); _sharedState.put( Constants.WSSECURITY_TOKEN_TO_BE_INSERTED, tokenList); ... }
- 使用 GenericSecurityTokenFactory.putGeneratorTokenToSharedState
方法将 SAML 令牌置于 _sharedState 对象上。
import com.ibm.websphere.wssecurity.wssapi.token.GenericSecurityTokenFactory; public boolean login() throws LoginException { ... SAMLToken mySamlToken=someSAMLToken; GenericSecurityTokenFactory factory = GenericSecurityTokenFactory.getInstance(); factory.putGeneratorTokenToSharedState(this._sharedState, mySamlToken); ... }


http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twbs_pass_samltoken
文件名:twbs_pass_samltoken.html