简体   繁体   English

JAAS错误:登录失败

[英]JAAS Error: Login failed

i'm building some restful webservices and try to secure them by using JAAS. 我正在构建一些宁静的Web服务,并尝试通过使用JAAS保护它们。

but i get the following error: 但我得到以下错误:

 javax.servlet.ServletException: Login failed

I created a realm with the following attributes: 我创建了一个具有以下属性的领域:

JAAS-Context: jdbcDigestRealm
DIGEST-Algorithm: SHA-512
Encoding: Hex
password encryption: none

I try to log in by using HttpServletRequest: 我尝试使用HttpServletRequest登录:

request.login(email, password); //email = test@test.tld, password=<SHA512HEX('testPasswprd')>

Here is the StackTrace: 这是StackTrace:

WARNING:   WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: null
SEVERE:   javax.servlet.ServletException: Login failed
at org.apache.catalina.authenticator.AuthenticatorBase.doLogin(AuthenticatorBase.java:959)
at org.apache.catalina.authenticator.AuthenticatorBase.login(AuthenticatorBase.java:939)
at org.apache.catalina.connector.Request.login(Request.java:2245)
at org.apache.catalina.connector.Request.login(Request.java:2224)
at org.apache.catalina.connector.RequestFacade.login(RequestFacade.java:1113)

Do you have some ideas? 你有什么主意吗?


EDIT: 编辑:

Sometimes I get a NullPointerException at 有时我在以下地方收到NullPointerException

request.login(email, password); //both variables and request are set.


WARNING:   StandardWrapperValve[de.AuthTest.core.ApplicationConfig]: Servlet.service() for servlet de.AuthTest.core.ApplicationConfig threw exception
java.lang.NullPointerException
at org.apache.catalina.connector.Request.login(Request.java:2229)
at org.apache.catalina.connector.Request.login(Request.java:2224)
at org.apache.catalina.connector.RequestFacade.login(RequestFacade.java:1113)

This tutorial was tested in Glassfish 4.0 with Java EE 7 application: 本教程已在带有Java EE 7应用程序的Glassfish 4.0中进行了测试:

  1. Expand the Security node. 展开“安全性”节点。
  2. Expand the Realms node. 展开“领域”节点。
  3. Select the File node. 选择“文件”节点。
  4. On the Edit Realm page, click Manage Users. 在“编辑领域”页面上,单击“管理用户”。
  5. On the File Users page, click New. 在“文件用户”页面上,单击“新建”。
  6. In the User ID field, type a User ID. 在“用户ID”字段中,键入一个用户ID。
  7. In the Group List field, type TutorialUser. 在“组列表”字段中,键入TutorialUser。
  8. In the New Password and Confirm New Password fields, type a password. 在新密码和确认新密码字段中,输入密码。
  9. Click OK. 单击确定。

Then set up Default Principal to Role Mapping on the GlassFish Server: 然后在GlassFish服务器上将默认主体设置为角色映射:

  1. From the Administration Console, expand the Configurations node, then expand the server-config node. 在管理控制台中,展开“配置”节点,然后展开“服务器配置”节点。
  2. Select the Security node. 选择“安全性”节点。
  3. Select the Default Principal to Role Mapping Enabled check box. 选择默认主体到角色映射已启用复选框。
  4. Click Save 点击保存

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM