【问题标题】:Issue With Jboss Basic AutenticationJboss 基本身份验证问题
【发布时间】: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)

请告诉我我的配置有什么问题。

【问题讨论】:

    标签: java jboss


    【解决方案1】:

    导致异常的方法试图访问一个空对象。查看 UsernamePasswordHashUtil.java here 的源代码,“realm”为空。

    您可能需要进行额外的配置才能使其正常工作。 例如,在您的 web.xml 中添加以下行:

    <login-config>
       <auth-method>BASIC</auth-method>
       <realm-name>ApplicationRealm</realm-name>
    </login-config>
    

    然后像解释here一样将用户添加到ApplicationRealm

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-22
      • 2018-12-20
      • 2021-05-17
      • 2010-11-24
      • 2013-05-16
      • 2011-10-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多