簡體   English   中英

如何在Alfresco Share上向JSP頁面添加身份驗證

[英]How to Add Authentication to JSP Page on Alfresco Share

因此,對於我目前正在開展的項目,在參加Alfresco開發人員課程之前,我們創建了一個自定義JSP頁面,我們在工作流程中調用它們位於: C:\\Alfresco\\tomcat\\webapps\\share\\custom 目前任何人都可以訪問此jsp頁面。 但是,當我們將位置移動到C:\\Alfresco\\tomcat\\webapps\\alfresco\\jsp\\custom ,總是需要登錄才能訪問該頁面,這對我來說似乎很奇怪。 但是,這里的問題是我們不希望允許用戶訪問共享和資源管理器,因此我們不打算在此處配置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>

但這沒效果。 有沒有人建議我們如何獲得所需的身份驗證?

謝謝

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后綴)必須與頁面的<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來執行此操作,具體取決於您的偏好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM