我正在尝试在wildfly中设置一个安全域,但是没有识别我的设置,它会转到受保护的页面,而不会转到登录页面。
TABLES:
'groups' table,
@Column(name = "groupname")
private String groupname;
'applicant' table,
@Id
private Integer id;
@Basic(optional = false)
@NotNull
@Column(name = "username")
private String username;
'groupshasapplicant' table,
@Id
private Integer id;
@Size(max = 255)
@Column(name = "username")
private String username;
@Column(name = "groupname")
private String groupname;
的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="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>
答案 0 :(得分:0)
在jboss-web.xml中尝试java:/ jaas / jBossJaasMysqlRealmApp。