- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
在 WildFly 9 服务器上运行的 Java EE 应用程序中,我有一个自定义登录模块:
public class MyLoginModule extends AbstractServerLoginModule {
private Principal identity;
@Override
public boolean login() throws LoginException {
// do something
identity = new SimplePrincipal("test");
subject.getPrincipals().add(identity);
// do something else
return true;
}
@Override
public boolean logout() throws LoginException {
subject.getPrincipals().remove(identity);
return true;
}
}
login
方法按预期工作。但这与logout
方法不一样。当我从 Servlet
或 Web 服务编写类似 request.getSession(false).invalidate();
的内容时,根本就不会到达 logout
方法。
这是我的配置文件:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>customer-area</display-name>
<security-constraint>
<web-resource-collection>
<web-resource-name>restricted resources</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>*</role-name>
</security-role>
<login-config>
<auth-method>MY-AUTH</auth-method>
</login-config>
</web-app>
jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<security-domain>java:/jaas/MySecurityDomain</security-domain>
</jboss-web>
standalone.xml
<security-domain name="MySecurityDomain" cache-type="default">
<authentication>
<login-module code="mypackage.MyLoginModule" flag="required"/>
</authentication>
</security-domain>
ServletExtension
类:
public class MyServletExtension implements ServletExtension {
@Override
public void handleDeployment(final DeploymentInfo deploymentInfo, ServletContext servletContext) {
deploymentInfo.addAuthenticationMechanism("MY-AUTH", new AuthenticationMechanismFactory() {
@Override
public AuthenticationMechanism create(String mechanismName, FormParserFactory formParserFactory, Map<String, String> properties) {
return new MyAuthenticationMechanism();
}
});
}
}
AuthenticationMechanism
类:
public class MyAuthenticationMechanism implements AuthenticationMechanism {
@Override
public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange, SecurityContext securityContext) {
PasswordCredential credential = new PasswordCredential(new char[] {});
Account account = identityManager.verify("test", credential);
if (account != null) {
return AUTHENTICATED;
} else {
return NOT_AUTHENTICATED;
}
}
}
我错过了什么吗?
最佳答案
允许访问MyLoginModule.logout()
的方法是request.logout()
。我应该自己找到它!
关于java - JAAS 注销不适用于自定义登录模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40467207/
我正在尝试在 Tomcat 7 上实现一个具有领域配置的简单 JAAS 模块。我正在尝试基于以下链接实现它: http://www.byteslounge.com/tutorials/jaas-aut
我想一个使用 NTLoginModule 进行身份验证的 jaas.conf 文件示例会有所帮助。 最佳答案 我不确定那是不是你的意思,但我想你可以: SomeName { com.sun.se
我正在使用这个 Helm chart :https://github.com/helm/charts/tree/master/incubator/kafka 以及 values.yaml 中的这些覆盖
我试图弄清楚登录模块标志在 JAAS 中是如何工作的(使用 JBoss 5.1 EAP),我遇到了一个令人费解的情况,我希望有人能为我澄清一下。 对于背景,我的 login-config.xml 如下
我实现了一个通过 Web 服务访问的自定义 loginModule,并在 JPA 访问的 DB 前面检查用户名和密码。 我在 jboss 7.1 上运行它,它运行良好,但是在将它移动到 Wildfly
我想知道使用 对数据库表上的应用程序用户进行身份验证的最简单方法贾斯 . 由于带有用户名/散列密码的数据库表可能是最常见的解决方案,是否有“提供”的 LoginModule 用于这种身份验证? 最佳答
我有以下代码来运行 Java (SE) 应用程序(不在服务器上),其中应该使用运行 JAAS 身份验证的现有 JBoss 服务器(我绑定(bind)到 4.2.3)来完成登录。我从一个简单的控制台应用
我刚刚完成了本教程: http://java.sun.com/docs/books/tutorial/security/tour2/index.html 并且对 JAAS 的基本概念感到好奇...如果
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
我正在尝试设计一个 JAAS 微服务来处理多个 J2EE 应用程序的用户身份验证。目前我们有多个应用程序根据我们的 LDAP 进行身份验证并具有单独的角色系统。现在我一直在设计应用程序和身份验证后端之
我有一个带有 JAAS 的应用程序,我需要从遗留系统进行外部登录,所以我用下面的代码编写了一个 servlet,它工作正常,但是当我再次提交时,JAAS 尝试再次进行身份验证并失败,并且用户被重定向到
我正在学习 Java 安全 JCE/JAAS。我无法获得我们需要在实际 Web 应用程序中实现 JAAS 登录模块的示例。 任何人都可以指导我在我的 Web 应用程序中实现 JAAS 的位置吗?据我所
我关注了this tutorial学习JAAS。这个例子对我有用,所以我创建了自己的版本(我使用的是 Tomcat 6 和 Java 6),但我无法让它工作(帖子底部的异常)。 (由于代理,我无法将
我们有一个新编写的 JAAS 模块,想知道将 DataSource 对象的数据库连接设置放在哪里。 通常在 Tomcat 网络应用程序中,这将在“web.xml”文件中引用以指向位于“$catalin
嗨,我正在使用这个 link对于基于 Java JAAS 表单的身份验证, JAAS 登录模块的实现使用数据库(postgresql)验证用户输入的用户名和密码 在 JAAS 中,我们应该创建“jas
在 WildFly 9 服务器上运行的 Java EE 应用程序中,我有一个自定义登录模块: public class MyLoginModule extends AbstractServerLogi
我正在尝试编写我的 Costum LoginModule,以便在具有基本授权的 REST 服务中使用。为此我做了以下工作: 我编写了自己的 LoginModule,称为 QuarkLoginModul
我想知道如何结合这两个身份验证步骤: 检查 LDAP 中的用户/密码 将在数据库中找到的主体(角色)添加到主题。 LDAP 用户存储库不知道应用程序特定的角色,我不想管理应用程序数据库中的密码。所以我
我在 jboss 上有一个自定义登录模块。 ear 的 META-INF 有一个指向 login-service.xml 的 jboss-app.xml,后者包含一个指向定义自定义登录模块的 logi
我很难理解 JAAS。这一切似乎都比应有的复杂(尤其是 Sun 教程)。我需要一个简单的教程或示例,说明如何在基于 Struts + Spring + Hibernate 和自定义用户存储库的 jav
我是一名优秀的程序员,十分优秀!