0

在 webcenter 驱动的 ADF 应用程序中,我们有一个名为的标准库generic-site-resources-model.jar,其中包含 file META-INF/service-definition.xml,我希望在一行中对其进行更改,以添加view资源的安全权限,如下所示:

@@ -1189,7 +1189,7 @@
         <resource-permission>
           <resource-permission-impl>oracle.webcenter.security.auth.WebCenterResourcePermission</resource-permission-impl>
           <resource-permission-target-id>resource_oracle_webcenter_siteresource_@scope@_navigation_@resource@</resource-permission-target-id>
-          <resource-permission-action-list>manage,update</resource-permission-action-list>
+          <resource-permission-action-list>view,manage,update</resource-permission-action-list>
         </resource-permission>
       </permission-metadata>
     </security-definition>

在不改变包含该库本身的 weblogic 域、以某种方式配置我们的应用程序的情况下,如何做到这一点?generic-site-resources-model.jar也许某种方式可以用应用程序提供的克隆覆盖整个?或者(理想情况下)以某种方式替换目标资源权限?还是某种自定义方式来控制应用程序中的资源加载?

4

1 回答 1

0

可以使用初始化阶段侦听器和一些代码来实现将自定义操作附加到特定资源类型,而根本不需要任何覆盖。

方法如下:

ViewControllerProject/src/META-INF/adf-settings.xml

<?xml version="1.0" encoding="UTF-8" ?>
<adf-settings xmlns="http://xmlns.oracle.com/adf/settings">
    <adfc-controller-config xmlns="http://xmlns.oracle.com/adf/controller/config">
        <lifecycle>
            <phase-listener>
                <listener-id>PortalInitializer</listener-id>
                <class>com.otr.portal.initializer.PortalInitializer</class>
            </phase-listener>
        </lifecycle>
    </adfc-controller-config>
</adf-settings>

com.otr.portal.initializer.PortalInitializer

package com.otr.portal.initializer;

import oracle.adf.controller.v2.lifecycle.Lifecycle;
import oracle.adf.controller.v2.lifecycle.PagePhaseEvent;
import oracle.adf.controller.v2.lifecycle.PagePhaseListener;
import oracle.webcenter.security.internal.common.SecurityUtil;
import oracle.webcenter.security.model.exception.SecExtensionNotFoundException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class PortalInitializer implements PagePhaseListener {
    private static final Log log = LogFactory.getLog(PortalInitializer.class);
    private boolean firstCall = true;

    @Override
    public void afterPhase(PagePhaseEvent pagePhaseEvent) {
        if (pagePhaseEvent.getPhaseId() == Lifecycle.INIT_CONTEXT_ID) {
            if (firstCall) {
                setupViewNavigationResourcePermssion();
                firstCall = false;
            }
        }
    }

    private void setupViewNavigationResourcePermssion() {
        try {
            SecurityUtil.getSecurityExtension("oracle.webcenter.siteresources.navigation").getExtensionPermMetadata().getResourcePermMetadata().getResourcePermActionsList().add("view");
        } catch (SecExtensionNotFoundException e) {
            log.error("Error adding view resource permission to navigation resource type", e);
        }
    }

    @Override
    public void beforePhase(PagePhaseEvent pagePhaseEvent) {

    }
}
于 2013-10-23T10:16:53.580 回答