我是WebSphere Liberty个人资料的新手。我正在研发17.0.0.4版本。我想要实现的是为应用程序定制JAAS登录设置。该应用程序在WebSphere 8.5上运行良好。
我已经从IBM知识中心查看了很多相关链接,但是使用JAAS自定义登录或使用JAAS自定义登录获得了结果,但不是两者都在一起。使用WebSphere 8.5,我们有层次结构来决定哪种身份验证机制在哪里,但如果我设置了自定义JAAS身份验证机制,那么我无法登录到WebSphere Liberty AdminCenter,如果我配置server.xml,那么它不认证我的应用程序的用户(因为它旨在通过JAAS获取身份验证用户)。
这是我的server.xml文件。
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>adminCenter-1.0</feature>
<feature>ssl-1.0</feature>
<feature>webProfile-7.0</feature>
<feature>appSecurity-2.0</feature>
</featureManager>
<keyStore id="defaultKeyStore" password="WASLiberty" />
<!-- Admin Center username/password -->
<!--<quickStartSecurity userName="admin" userPassword="admin123" />-->
<!-- Define an Administrator and non-Administrator -->
<basicRegistry id="basic">
<user name="admin" password="{xor}PjsyNjFubWw=" /> <!-- Encoded version of "admin123" -->
<user name="nonadmin" password="nonadmin123" />
</basicRegistry>
<!-- Assign 'admin' to Administrator -->
<administrator-role>
<user>admin</user>
</administrator-role>
<!-- JNDI Connection configuration -->
<dataSource id="MY_CUSTOM_DS" jndiName="jdbc/MY_CUSTOM_DS">
<jdbcDriver libraryRef="sqlserverjdbc"/>
<properties.microsoft.sqlserver databaseName="mydb"
serverName="localhost" portNumber="1433"
user="sa" password="root" />
</dataSource>
<!-- JDBC Driver file location -->
<library id="sqlserverjdbc">
<file name="${wlp.install.dir}/lib/sqljdbc4.jar"/>
</library>
<library id="MyLoginModuleLib">
<fileset dir="${wlp.install.dir}/lib" includes="custom_auth.jar"/>
</library>
<!-- JAAS Login Module for web application -->
<jaasLoginModule id="myCustom"
className="com.kana.auth.websphere.MyLoginModule"
controlFlag="REQUIRED" libraryRef="MyLoginModuleLib">
<options myOption1="value1" myOption2="value2"/>
</jaasLoginModule>
<!-- JAAS Login Context -->
<jaasLoginContextEntry id="system.WEB_INBOUND" name="system.WEB_INBOUND"
loginModuleRef="myCustom, hashtable, userNameAndPassword, certificate, token" />
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint id="defaultHttpEndpoint"
host="*"
httpPort="9080"
httpsPort="9443" />
<webApplication contextRoot="mywebapp" location="mywebapp.war" />
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
<!-- Enable remote file access -->
<remoteFileAccess>
<writeDir>${server.config.dir}</writeDir>
</remoteFileAccess>
</server>
任何人都可以指出我犯错的地方吗?
答案 0 :(得分:1)
如果您使用的是自定义JAAS登录模块,那么您的自定义JAAS登录模块需要忽略管理中心身份验证,并让默认登录模块处理它。 更好的选择是使用自定义TAI来处理应用程序身份验证,并让默认登录模块处理管理中心身份验证。
此致 Ut Le
答案 1 :(得分:0)
非常感谢 Ut Le 提供解决方案。
从日志文件中发现根本原因是ClassNotFound异常。它没有我从<jaasLoginModule>
指向的类。后来发现我指的是不在那个位置的jar文件。所以这是我为配置做的一个愚蠢的错误。