我正在构建一些宁静的Web服务并尝试使用JAAS来保护它们。
但是我收到以下错误:
javax.servlet.ServletException: Login failed
我创建了一个具有以下属性的领域:
JAAS-Context: jdbcDigestRealm
DIGEST-Algorithm: SHA-512
Encoding: Hex
password encryption: none
我尝试使用HttpServletRequest登录:
request.login(email, password); //email = test@test.tld, password=<SHA512HEX('testPasswprd')>
这是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)
你有什么想法吗?
编辑:
有时我在
处得到NullPointerExceptionrequest.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)
答案 0 :(得分:0)
This tutorial在Glassfish 4.0中使用Java EE 7应用程序进行了测试:
然后在GlassFish Server上将Default Principal设置为Role Mapping: