【发布时间】:2014-06-16 19:39:08
【问题描述】:
在完整版的 Websphere 中,您可以定义 JAAS 身份验证条目。 这些条目具有唯一的 ID、用户名和密码。通常这些绑定到 WAS 中的其他配置条目,例如 DataSource 配置。
但有时您需要通过 API 直接从应用程序代码访问 J2C 记录。 这里有几篇文章解释了如何在 WAS 中进行操作。 通常你做的是:
LoginContext loginContext = new LoginContext("DefaultPrincipalMapping", callbackHandler);
loginContext.login();
它确实通过 JCA API 在 WAS 中工作,但在 Websphere Liberty Profile 中却不行。 有什么方法可以访问 Websphere Liberty Profile 中的 J2C AuthData? 为此目的在 server.xml 中设置 J2C 所需的最低配置是什么?
我们有类似的东西:
<featureManager>
<feature>appSecurity-2.0</feature>
</featureManager>
<authData id="someAppCredentials" user="someUser" password="some Password"/>
<jaasLoginContextEntry id="DefaultPrincipalMapping" name="DefaultPrincipalMapping" loginModuleRef="userNameAndPassword"/>
但显然这还不够,因为 WLP 抛出:javax.security.auth.login.LoginException: No LoginModules configured for DefaultPrincipalMapping 如果你尝试做 loginContext.login()。
【问题讨论】:
-
如果您在这里没有得到答案,您可能想在developer.ibm.com/answers/?community=wasdev 询问 WLP 开发团队就在那里,他们反应非常迅速。
标签: jaas websphere-8 websphere-liberty jca