【问题标题】:Can't map roles to groups using ibm-application-bnd.xml无法使用 ibm-application-bnd.xml 将角色映射到组
【发布时间】:2015-07-19 13:00:18
【问题描述】:

我正在尝试使用 ibm-application-bnd.xml 映射用户组。将其放入 META-INF 文件夹。在尝试访问安全页面时获取下一条消息:

[08.05.15 17:42:21:242 MSK] 00000084 WebCollaborat A   SECJ0129E: ... GET в null:/loginmodule/date/, Authorization failed, Not granted any of the required roles: user-role

当我尝试使用 ibm 控制台配置它时,它可以工作。所有配置 WAS 都写入 ibm-application-bnd.xmi 而不是 ibm-application-bnd.xml。

我做错了什么? 将 Websphere AS 8.5.5 与 Java 1.6 一起使用

ibm-application-bnd.xml:

<?xml version="1.0" encoding="UTF-8"?>
<application-bnd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://websphere.ibm.com/dxml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-bnd_1_2.xsd"
      xmlns="http://websphere.ibm.com/xml/ns/javaee" version="1.2">
      <security-role name="user-role">
            <group name="user-group" />
      </security-role>
</application-bnd>

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
      <session-config>
            <session-timeout>30</session-timeout>
      </session-config>
      <welcome-file-list>
            <welcome-file>index.html</welcome-file>
      </welcome-file-list>

      <security-constraint>
            <display-name>Constraint</display-name>
            <web-resource-collection>
                  <web-resource-name>secrets</web-resource-name>
                  <description />
                  <url-pattern>/date/*</url-pattern>
            </web-resource-collection>
            <auth-constraint>
                  <role-name>user-role</role-name>
            </auth-constraint>
      </security-constraint>

      <security-role>
            <role-name>user-role</role-name>
      </security-role>

      <servlet>
            <servlet-name>date</servlet-name>
            <servlet-class>ru.servlet.TimeServlet</servlet-class>
      </servlet>
      <servlet-mapping>
            <servlet-name>date</servlet-name>
            <url-pattern>/date/*</url-pattern>
      </servlet-mapping>
</web-app>

【问题讨论】:

    标签: websphere jaas user-roles


    【解决方案1】:

    我不得不更改耳朵 POM maven-ear-plugin 中的版本。因为默认它会生成一个 1.3 application.xml,所以 Websphere 服务器只需要一个 ibm-application-bnd.xmi 文件而不是一个 ibm-application-bnd.xml 文件

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ear-plugin</artifactId>
    <configuration>
        <version>6</version>
        <security>
            <security-role>
                <role-name>manager</role-name>
            </security-role>
        </security>
        <modules>
            <webModule>
                <groupId>${project.groupId}</groupId>
                <artifactId>my-war</artifactId>
                <contextRoot>/my-app</contextRoot>
            </webModule>
        </modules>
    </configuration>
    

    感谢bkail

    【讨论】:

    • 这确实是我的问题的原因。检查在 ear 项目的目标目录中生成的 application.xml 很有帮助。顺便说一句,我还了解到您可以通过管理控制台导出 ear,如果您手动应用安全角色,它将显示它正在使用的 bnd.xml 或 .xmi 文件。
    【解决方案2】:

    WebSphere Application Server 仅将 XML 用于 EE 5+,并且该决定是基于每个部署描述符做出的。如果正在使用 ibm-application-bnd.xmi,那么我怀疑您的 application.xml 的 version="1.4" 或更低,所以在更新到 EE 5 XML 标头后重试(删除 doctype,添加 xmlns,添加 xmlns:xsi ,添加xsi:schemaLocation,更新版本属性)。

    【讨论】:

    • 你拯救了我的一天。将 maven-ear-plugin 的 POM 中的版本更改为 6 就可以了。查看答案
    猜你喜欢
    • 2016-05-31
    • 1970-01-01
    • 2015-06-14
    • 2017-11-29
    • 1970-01-01
    • 2021-07-25
    • 2017-07-27
    • 1970-01-01
    • 2020-07-14
    相关资源
    最近更新 更多