Java RESTful web应用程序用户名和密码的安全性驻留在数据库中?

Java RESTful web应用程序用户名和密码的安全性驻留在数据库中?,java,rest,jersey-2.0,Java,Rest,Jersey 2.0,我想为我的Web应用程序提供安全性。我已经为 基本身份验证。但现在我想提供用户界面来添加用户、权限 选择用户。我谷歌它很多,但没有想法。请有人帮我做到这一点。任何文档,文章也对我有帮助 基本身份验证描述符:- <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns

我想为我的Web应用程序提供安全性。我已经为 基本身份验证。但现在我想提供用户界面来添加用户、权限 选择用户。我谷歌它很多,但没有想法。请有人帮我做到这一点。任何文档,文章也对我有帮助

基本身份验证描述符:-

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>JerseyAuthentication</display-name>
<welcome-file-list>
    <welcome-file>login.html</welcome-file>
</welcome-file-list>
<servlet>
    <servlet-name>Application</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>org.student.resource</param-value>
    </init-param>
    <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Application</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>admin</web-resource-name>
        <url-pattern>/admin/*</url-pattern>
        <url-pattern>/user/*</url-pattern>
        <url-pattern>/others/*</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
        <http-method>PUT</http-method>
        <http-method>DELETE</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
  </security-constraint>
   <security-constraint>
    <web-resource-collection>
        <web-resource-name>user</web-resource-name>
        <url-pattern>/user/*</url-pattern>
        <http-method>GET</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>user</role-name>
    </auth-constraint>
</security-constraint>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>others</web-resource-name>
        <url-pattern>/others/*</url-pattern>
        <http-method>GET</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>others</role-name>
    </auth-constraint>
</security-constraint>
<login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>my-default-realm</realm-name>
</login-config>
<security-role>
    <role-name>admin</role-name>
</security-role>
<security-role>
    <role-name>user</role-name>
</security-role>
<security-role>
    <role-name>others</role-name>
</security-role>
</web-app>

球衣认证
login.html
应用
org.glassfish.jersey.servlet.ServletContainer
jersey.config.server.provider.packages
org.student.resource
jersey.config.server.provider.classnames
org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature
1.
应用
/*
管理
/管理员/*
/使用者/*
/其他/*
得到
邮递
放
删除
管理
用户
/使用者/*
得到
用户
其他
/其他/*
得到
其他
基本的
我的默认领域
管理
用户
其他
tomcat-users.xml:-

 <tomcat-users >
  <user username="Murugesan" password="secret" roles="admin" />
  <user username="peeskillet"  password="superSecret" roles="user"  />
 </tomcat-users>


在中,我解释了tomcat用户(或UserDatabaseRealm)不应用于生产。它不能在运行时更新。我还链接了关于如何创建其他类型的领域的文档,比如JDBC领域,它实际上保存到数据库中。你应该回顾一下这个链接。。。。在中,我解释了tomcat用户(或UserDatabaseRealm)不应该用于生产。它不能在运行时更新。我还链接了关于如何创建其他类型的领域的文档,比如JDBC领域,它实际上保存到数据库中。你应该回顾一下这个链接。。。。而且,您永远不应该存储未加密/未加密的密码。