如何在Alfresco共享上向JSP页面添加身份验证



所以对于我目前正在从事的项目,在参加Alfresco开发人员课程之前,我们创建了一个自定义的JSP页面,我们在工作流程过程中调用该页面位于:C:Alfrescotomcatwebappssharecustom。目前任何人都可以访问此 jsp 页面。但是,当我们 将位置移动到C:Alfrescotomcatwebappsalfrescojspcustom,始终需要登录才能访问页面,这对我来说似乎很奇怪。但是,这里的问题是我们不希望允许用户同时访问共享和资源管理器,因此我们不希望在此处配置 SSO。我们只允许组"经理"的人员或组"经理"中当前登录的用户访问此页面,因为它位于共享端。我们尝试将以下内容添加到

C:AlfrescotomcatwebappsshareWEB-INFweb.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>

但这没有用。有没有人对我们如何获得所需的身份验证有建议?

谢谢

共享中的身份验证由 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后缀)必须与页面的<template-instance>属性中指定的名称匹配。

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

<?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 来执行此操作,具体取决于您的喜好。

最新更新