【发布时间】:2015-07-31 04:56:12
【问题描述】:
您好,我已将我的应用程序配置为在 Jboss7 上进行基本身份验证,如下所示。
在 Jboss 的standalone.xml 中添加安全域,如下所示。
<security-domain name="BasicAuthWebAppPolicy" cache-type="default">
<authentication>
<login-module code="RealmUsersRoles" flag="required">
<module-option name="usersProperties" value="basicSecurityWebApp-users.properties"/>
<module-option name="rolesProperties" value="basicSecurityWebApp-roles.properties"/>
</login-module>
</authentication>
</security-domain>
在 web.xml 文件中,我有如下配置。
<security-constraint>
<web-resource-collection>
<web-resource-name>MySecureResources</web-resource-name>
<description>Some Description</description>
<url-pattern>/secured/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>TestRole</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<security-role>
<role-name>TestRole</role-name>
</security-role>
我的 jboss-web.xml 有内容。
<?xml version="1.0"?>
<!DOCTYPE jboss-web PUBLIC
"-//JBoss//DTD Web Application 5.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
<jboss-web>
<security-domain>java:/jaas/BasicAuthWebAppPolicy</security-domain>
<context-root>/basicSecurityWebApp</context-root>
</jboss-web>
我还在路径 WEB-INF/classes 中添加了属性文件。 用户文件包含 TestUserOne=TestPassword,角色文件包含 TestUserOne=TestRole 当我输入用户名和密码时,我在 jboss 日志中收到以下错误。
0:18:07,162 错误 [org.jboss.security.authentication.JBossCachedAuthenticationMnager] (http--127.0.0.1-8080-1) 登录失败: javax.security.auth.login.LoginE 接收: java.lang.NullPointerException 在 org.jboss.sasl.util.UsernamePasswordHashUtil.stringToByte(UsernamePaswordHashUtil.java:86) 在 org.jboss.sasl.util.UsernamePasswordHashUtil.generateHashedURP(UsernaePasswordHashUtil.java:131)
请告诉我我的配置有什么问题。
【问题讨论】: