【问题标题】:How to Add Authentication to JSP Page on Alfresco Share如何在 Alfresco Share 上向 JSP 页面添加身份验证
【发布时间】:2012-11-06 18:57:15
【问题描述】:

因此,对于我目前正在从事的项目,在参加 Alfresco 开发人员课程之前,我们创建了一个自定义 JSP 页面,我们可以在我们的工作流程过程中调用该页面,该页面位于:C:\Alfresco\tomcat\webapps\share\custom。目前任何人都可以访问这个jsp页面。但是,当我们将位置移动到C:\Alfresco\tomcat\webapps\alfresco\jsp\custom 时,总是需要登录才能访问该页面,这对我来说似乎很奇怪。但是这里的问题是我们不想让用户同时访问 Share 和 Explorer,因此我们不打算在这里配置 SSO。我们希望只允许“经理”组的人,或“经理”组中当前登录的用户访问此页面,而它位于共享端。我们尝试将以下内容添加到

C:\Alfresco\tomcat\webapps\share\WEB-INF\web.xml文件:

<security-constraint>
        <web-resource-collection>
            <web-resource-name>All</web-resource-name>
            <url-pattern>/custom /*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
        </web-resource-collection>
        <auth-constraint>
            <role-name>Manager</role-name>
        </auth-constraint>
    </security-constraint>

但这不起作用。有人对我们如何获得所需的身份验证有任何建议吗?

谢谢

【问题讨论】:

    标签: java authentication share alfresco web.xml


    【解决方案1】:

    Share 中的身份验证由 Surf 框架控制,特别是在页面级别设置。

    JSP 页面site-index.jsp 提供了一个基于 JSP 的示例页面,该页面处理经过身份验证的用户以供您复制,但您还必须将其连接到框架中。

    为此,您需要创建类似于以下内容的页面定义

    <?xml version='1.0' encoding='UTF-8'?>
    <page>
       <title>My page</title>
       <description>What the page is for</description>
       <template-instance>my-page</template-instance>
       <authentication>user</authentication>
    </page>
    

    WEB-INF/classes/alfresco/site-data/pages/site-index.xml下添加这个文件。

    您会看到该页面引用了一个模板实例my-page,它必须在WEB-INF/classes/alfresco/site-data/template-instances 下的第二个XML 文件中声明,例如

    <?xml version='1.0' encoding='UTF-8'?>
    <template-instance>
       <template-type>my-page</template-type>
    </template-instance>
    

    模板实例 XML 文件的名称(不带 .xml 后缀)必须与页面的 &lt;template-instance&gt; 属性中指定的名称匹配。

    最后在WEB-INF/classes/alfresco/site-data/template-types下创建一个模板类型文件my-page.xml(此名称必须与模板实例文件中的&lt;template-type&gt;属性匹配),例如

    <?xml version="1.0" encoding="UTF-8"?>
    <template-type>
            <title>Site index landing page template type</title>
            <description>Site index landing page JSP Template Type</description>
    
            <!-- Define the rendering processors for this template type -->
            <processor mode="view">
                    <id>jsp</id>
                    <jsp-path>/my-page.jsp</jsp-path>
            </processor>
    
    </template-type>
    

    文件my-page.jsp 将包含您的JSP 代码。正如我提到的,以核心文件site-index.jsp 为例。

    当您完成所有这些工作后,您应该将您的自定义打包到一个 AMP 文件中。您可以根据自己的喜好使用 Ant 或 Maven 来执行此操作。

    【讨论】:

      猜你喜欢
      • 2020-09-19
      • 2013-04-04
      • 1970-01-01
      • 2021-06-20
      • 2017-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多