Java WILDFLY-JAAS不工作-未识别SecurityDomain
我试图在wildfly中设置一个安全域,但无法识别我的设置,它会转到一个受保护的页面,而不会传递到登录页面 web.xml:Java WILDFLY-JAAS不工作-未识别SecurityDomain,java,jaas,wildfly,Java,Jaas,Wildfly,我试图在wildfly中设置一个安全域,但无法识别我的设置,它会转到一个受保护的页面,而不会传递到登录页面 web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="ht
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>faces/offersList.xhtml</welcome-file>
</welcome-file-list>
<security-constraint>
<display-name>applicant</display-name>
<web-resource-collection>
<web-resource-name>applicant</web-resource-name>
<description/>
<url-pattern>/faces/registed/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description/>
<role-name>Applicant</role-name>
</auth-constraint>
<user-data-constraint>
<description/>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>jBossJaasMysqlRealmApp</realm-name>
<form-login-config>
<form-login-page>/faces/login.xhtml</form-login-page>
<form-error-page>/faces/error.xhtml</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description/>
<role-name>Applicant</role-name>
</security-role>
<error-page>
<!-- Missing login -->
<error-code>401</error-code>
<location>/faces/error.xhtml</location>
</error-page>
<error-page>
<!-- Forbidden directory listing -->
<error-code>403</error-code>
<location>/faces/template.xhtml</location>
</error-page>
<error-page>
<!-- Uncaught exception -->
<error-code>500</error-code>
<location>/faces/error.xhtml</location>
</error-page>
<error-page>
<!-- Unsupported servlet method -->
<error-code>503</error-code>
<location>/faces/error.xhtml</location>
</error-page>
<error-page>
<!-- Not found -->
<error-code>404</error-code>
<location>/faces/error.xhtml</location>
</error-page>
</web-app>
jboss-web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee">
<security-domain>jBossJaasMysqlRealmApp</security-domain>
<context-root>/publicPositionPlataform</context-root>
</jboss-web>
在WILDFLY配置中,我有如下独立完整配置:
<security-domain name="jBossJaasMysqlRealmApp">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:jboss/datasources/positionsdb"/>
<module-option name="principalsQuery" value="select password from applicant where username = ?"/>
<module-option name="rolesName" value="select groupname, 'Roles' from grouphasapplicant where groupname = ?"/>
<module-option name="hashAlgorithm" value="SHA-256"/>
<module-option name="hashEncoding" value="hex"/>
<module-option name="unauthenticatedIdentity" value="guest"/>
</login-module>
<login-module code="RoleMapping" flag="required">
<module-option name="rolesProperties" value="file:${jboss.server.config.dir}/app.properties"/>
<module-option name="replaceRole" value="false"/>
</login-module>
</authentication>
</security-domain>
在jboss web.xml中尝试java:/jaas/jBossJaasMysqlRealmApp。共享数据源、web.xml和login.xhtml文件,以获得清晰性。。。
<security-domain name="jBossJaasMysqlRealmApp">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:jboss/datasources/positionsdb"/>
<module-option name="principalsQuery" value="select password from applicant where username = ?"/>
<module-option name="rolesName" value="select groupname, 'Roles' from grouphasapplicant where groupname = ?"/>
<module-option name="hashAlgorithm" value="SHA-256"/>
<module-option name="hashEncoding" value="hex"/>
<module-option name="unauthenticatedIdentity" value="guest"/>
</login-module>
<login-module code="RoleMapping" flag="required">
<module-option name="rolesProperties" value="file:${jboss.server.config.dir}/app.properties"/>
<module-option name="replaceRole" value="false"/>
</login-module>
</authentication>
</security-domain>