java - 如何使用安全约束将用户重定向到特定页面?

标签 java html xml login-control security-constraint

我有 2 个组 ts_admin 和 ts_users。在登录页面,管理员登录后应直接进入管理 View ,用户进入用户 View 。我不确定该怎么做,我需要帮助。我已经加载了一个包含安全约束的 XML 页面,也许我们可以从那一点进一步采取它。

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

<security-constraint>
    <display-name>timesheet user permission</display-name>
    <web-resource-collection>
        <web-resource-name>timesheet_user_resources</web-resource-name>
        <url-pattern>/index.html</url-pattern>
        <url-pattern>/</url-pattern>
        <url-pattern>/rs/*</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
        <http-method>PUT</http-method>
        <http-method>DELETE</http-method>
        <http-method>OPTIONS</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>ts_users</role-name>
    </auth-constraint>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

<security-role>
    <role-name>ts_users</role-name>
</security-role>
<security-role>
    <role-name>ts_admins</role-name>
</security-role>

<security-constraint>
    <display-name>timesheet admin permissions</display-name>
    <web-resource-collection>
        <web-resource-name>timesheet_admin_resources</web-resource-name>
        <url-pattern>/rs/*</url-pattern>

        <url-pattern>/indexAdmin.html</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
        <http-method>PUT</http-method>
        <http-method>DELETE</http-method>
        <http-method>OPTIONS</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>ts_admins</role-name>
    </auth-constraint>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>MyRealm</realm-name>

    <form-login-config id="FormLoginConfig_1">
        <form-login-page>/login.html</form-login-page>
        <form-error-page>/error.html</form-error-page>
    </form-login-config>
</login-config>

最佳答案

加载的 XML 文件已设置好,不需要任何更改。我在 index 和 indexAdmin 页面上都创建了链接以便于交换,我还使用 ng-show 仅在系统将一个人验证为管理员时才显示链接。然后在JS页面添加$scope.isAdmin = data.data.admin;

关于java - 如何使用安全约束将用户重定向到特定页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41932967/

相关文章:

javascript - 如何在服务器端接收td元素的数据

java - JAX-B 将字符串映射到 JAXBElement<String>

java - JOOQ 代码生成器跳过包含 JsonNode 字段的类

java - 如何清除 picasso 的缓存?

java - 将 MongoTemplate 传递给自定义存储库实现

java - 为什么Java编译器不理解这个变量总是被初始化?

javascript - Angular -js :ng-model not working with searchable dropdown

html - 为什么 text-decoration 会停止基于子元素定位的继承?

java - Android 上 DOM API 的替代方案?

xml - XSLT 将重复元素拆分为单独的组,同时保留同级元素