我不明白如何使用密码的哈希而不是开放密码。当我从我的 MS SQL 数据库中获取开放密码时,一切正常。
standalone.xml:
<security-domain name="SD" cache-type="default">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="<jndi>"/>
<module-option name="principalsQuery" value="select <open_pass> from <table> where <username> = ?"/>
<module-option name="rolesQuery" value="select <role>, 'Roles' from <table> where <username> = ?"/>
</login-module>
</authentication>
</security-domain>
web.xml
:
<security-constraint>
<display-name>General</display-name>
<web-resource-collection>
<web-resource-name>/</web-resource-name>
<description/>
<url-pattern>/</url-pattern>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>administrators</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<security-role>
<description/>
<role-name>administrators</role-name>
</security-role>
但是当我尝试使用以下内容时:
<security-domain name="SD" cache-type="default">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="<jndi>"/>
<module-option name="principalsQuery" value="select <pass_hash> from <table> where <username> = ?"/>
<module-option name="rolesQuery" value="select <role>, 'Roles' from <table> where <username> = ?"/>
<module-option name="hashAlgorithm" value="SHA-1"/>
<module-option name="hashEncoding" value="base64"/>
</login-module>
</authentication>
</security-domain>
Login failure: javax.security.auth.login.FailedLoginException: Password Incorrect/Password Required
即使输入正确的密码也能获得。pass_hash
字段varbinary(64)
在数据库中有类型。
我错过了什么?