Jakarta ee Websphere。不使用密码对web应用程序的用户进行身份验证
我是WebSphereAS的新手。开始学习JAAS。需要编写登录模块,该模块无需输入密码即可对用户进行身份验证。还希望从外部存储(如数据库)获取所有角色 编写了登录模块。按照最初的要求将其添加到WEB_INBOUND中。标记为可选的其他登录模块 下一个问题是:Jakarta ee Websphere。不使用密码对web应用程序的用户进行身份验证,jakarta-ee,web-applications,websphere,jaas,Jakarta Ee,Web Applications,Websphere,Jaas,我是WebSphereAS的新手。开始学习JAAS。需要编写登录模块,该模块无需输入密码即可对用户进行身份验证。还希望从外部存储(如数据库)获取所有角色 编写了登录模块。按照最初的要求将其添加到WEB_INBOUND中。标记为可选的其他登录模块 下一个问题是: 基本验证弹出窗口总是第一次出现。如果我的登录模块未指定用户,则希望使用此命令 如果其他登录模块未标记为可选,则不会调用提交方法。我能用这个做什么 用户未按我重新认证的方式进行身份验证。为什么?我该怎么修 如何在登录模块中为用户添加查询到的
//imports
public class SimpleModule implements LoginModule {
private Subject subject;
private CallbackHandler callbackHandler;
private Map<String, ?> sharedState;
public void initialize(Subject subject, CallbackHandler callbackHandler,
Map<String, ?> sharedState, Map<String, ?> options) {
this.subject = subject;
this.callbackHandler = callbackHandler;
this.sharedState = sharedState;
}
public boolean login() throws LoginException {
System.out.println("login called");
return true;
}
public boolean commit() throws LoginException {
System.out.println("Commit called");
// set username
WSPrincipal wsPrincipalImpl = new WSPrincipalImpl("user");
subject.getPrincipals().add(wsPrincipalImpl);
return true;
}
public boolean abort() throws LoginException {
return true;
}
public boolean logout() throws LoginException {
return true;
}
}
//导入
公共类SimpleModule实现LoginModule{
私人主体;
私有CallbackHandler CallbackHandler;
私有地图共享状态;
public void initialize(主题、CallbackHandler、CallbackHandler、,
地图共享状态,地图选项){
this.subject=主语;
this.callbackHandler=callbackHandler;
this.sharedState=sharedState;
}
public boolean login()引发LoginException{
System.out.println(“登录名”);
返回true;
}
public boolean commit()引发LoginException{
System.out.println(“提交调用”);
//设置用户名
WSPrincipal wsPrincipalImpl=新的wsPrincipalImpl(“用户”);
subject.getPrincipals().add(wsPrincipalImpl);
返回true;
}
public boolean abort()引发LoginException{
返回true;
}
public boolean logout()引发LoginException{
返回true;
}
}
web.xml列表:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<security-constraint>
<display-name>Constraint</display-name>
<web-resource-collection>
<web-resource-name>secrets</web-resource-name>
<description />
<url-pattern>/page.html</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user-role</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>user-role</role-name>
</security-role>
</web-app>
30
index.html
约束
秘密
/page.html
用户角色
用户角色
我建议您切换到TAI而不是LoginModule。与LoginModule相比,WAS安全基础架构的编写、配置和集成要容易得多。@Gas您似乎是对的。谢谢