Java WildFly Swarm中的JAAS认证
我正在开发一个小型网站,在后端使用angular前端和JAX-RS REST服务。 我想保护所有页面和REST服务,这样只有经过身份验证的用户才能访问页面和REST服务。我使用WildFly Swarm作为我的应用服务器,并希望将用户和角色存储在自定义(MySQL)数据库中。 我以前只使用过JSF和WebSphere application server,我使用过Windows Active Directory进行身份验证,所以我在这里迷路了,没有找到任何关于我应该做什么的相关教程或文章 以下是我到目前为止所做的 web.xml:Java WildFly Swarm中的JAAS认证,java,authentication,jakarta-ee,jaas,wildfly-swarm,Java,Authentication,Jakarta Ee,Jaas,Wildfly Swarm,我正在开发一个小型网站,在后端使用angular前端和JAX-RS REST服务。 我想保护所有页面和REST服务,这样只有经过身份验证的用户才能访问页面和REST服务。我使用WildFly Swarm作为我的应用服务器,并希望将用户和角色存储在自定义(MySQL)数据库中。 我以前只使用过JSF和WebSphere application server,我使用过Windows Active Directory进行身份验证,所以我在这里迷路了,没有找到任何关于我应该做什么的相关教程或文章 以下是
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>My Web App</display-name>
<security-constraint>
<web-resource-collection>
<web-resource-name>Admin Resource</web-resource-name>
<url-pattern>/administration/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>User Resource</web-resource-name>
<url-pattern>/pages/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>../login.html</form-login-page>
<form-error-page>../login-failed.html</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>admin</role-name>
</security-role>
<security-role>
<role-name>user</role-name>
</security-role>
</web-app>
我有两个问题:
response.sendRedirect("j_security_check?j_username=" + username + "&j_password=" + password);
response.sendRedirect("j_security_check?j_username=" + username + "&j_password=" + password);