當前位置: 首頁>>代碼示例>>Java>>正文


Java Acl類代碼示例

本文整理匯總了Java中org.alfresco.repo.domain.permissions.Acl的典型用法代碼示例。如果您正苦於以下問題:Java Acl類的具體用法?Java Acl怎麽用?Java Acl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Acl類屬於org.alfresco.repo.domain.permissions包,在下文中一共展示了Acl類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAllAcls

import org.alfresco.repo.domain.permissions.Acl; //導入依賴的package包/類
private List<Acl> getAllAcls(Long nodeAclId) {
	logger.debug("getAllAcls from " + nodeAclId);
	Acl acl = aclDao.getAcl(nodeAclId);
	Long parentNodeAclId = acl.getInheritsFrom();
	logger.debug("parent acl is  " + parentNodeAclId);
	if (parentNodeAclId == null || !acl.getInherits()) {
		List<Acl> ret = new ArrayList<Acl>();
		ret.add(acl);
		return ret;
	} else {
		List<Acl> inheritedAcls = getAllAcls(parentNodeAclId);
		logger.debug("Current acl with id " + nodeAclId + " is " + acl);
		inheritedAcls.add(acl);
		return inheritedAcls;
	}
}
 
開發者ID:Alfresco,項目名稱:alfresco-indexer,代碼行數:17,代碼來源:NodeDetailsWebScript.java

示例2: cleanSitePermissions

import org.alfresco.repo.domain.permissions.Acl; //導入依賴的package包/類
public void cleanSitePermissions(final NodeRef targetNode, SiteInfo containingSite)
{
    if (!nodeDAO.exists(targetNode))
    {
        return;
    }
    // We can calculate the containing site at the start of a recursive call & then reuse it on subsequent calls.
    if (containingSite == null)
    {
        containingSite = siteServiceImpl.getSite(targetNode);
    }

    // Short-circuit at this point if the node is not in a Site.
    if (containingSite == null)
    {
        return;
    }
    // For performance reasons we navigate down the containment hierarchy using the DAOs
    // rather than the NodeService. Note: direct use of NodeDAO requires tenantService (ALF-12732).
    final Long targetNodeID = nodeDAO.getNodePair(tenantService.getName(targetNode)).getFirst();
    final Long targetNodeAclID = nodeDAO.getNodeAclId(targetNodeID);
    Acl targetNodeAcl = aclDAO.getAcl(targetNodeAclID);

    // Nodes that don't have defining ACLs do not need to be considered.
    if (targetNodeAcl.getAclType() == ACLType.DEFINING)
    {
        AccessControlList targetNodeAccessControlList = aclDAO.getAccessControlList(targetNodeAclID);
        List<AccessControlEntry> targetNodeAclEntries = targetNodeAccessControlList.getEntries();
        for (AccessControlEntry entry : targetNodeAclEntries)
        {
            String authority = entry.getAuthority();

            String thisSiteGroupPrefix = siteServiceImpl.getSiteGroup(containingSite.getShortName(), true);

            // If it's a group site permission for a site other than the current site
            if (authority.startsWith(PermissionService.GROUP_PREFIX) &&
                    // And it's not GROUP_EVERYONE
                    !authority.startsWith(PermissionService.ALL_AUTHORITIES) && !authority.startsWith(thisSiteGroupPrefix) &&
                    //  And if the current user has permissions to do it
                    publicServiceAccessService.hasAccess("PermissionService", "clearPermission", targetNode, authority) == AccessStatus.ALLOWED)
            {
                // Then remove it.
                permissionService.clearPermission(targetNode, authority);
            }

            if (!permissionService.getInheritParentPermissions(targetNode))
            {
                // The site manager from the new site, where this node was moved to, has to have permission to this node
                String siteManagerAuthority = thisSiteGroupPrefix + "_" + SiteModel.SITE_MANAGER;
                AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Void>()
                {
                    public Void doWork() throws Exception
                    {
                        permissionService.setPermission(targetNode, siteManagerAuthority, SiteModel.SITE_MANAGER, true);
                        return null;
                    }
                }, AuthenticationUtil.getSystemUserName());
            }
        }
    }

    // Recurse
    List<NodeIdAndAclId> childNodeIds = nodeDAO.getPrimaryChildrenAcls(targetNodeID);
    for (NodeIdAndAclId nextChild : childNodeIds)
    {
        cleanSitePermissions(nodeDAO.getNodePair(nextChild.getId()).getSecond(), containingSite);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:69,代碼來源:SitesPermissionCleaner.java

示例3: cleanSitePermissions

import org.alfresco.repo.domain.permissions.Acl; //導入依賴的package包/類
public void cleanSitePermissions(final NodeRef targetNode, SiteInfo containingSite)
{
    if (nodeDAO.exists(targetNode))
    {
        // We can calculate the containing site at the start of a recursive call & then reuse it on subsequent calls.
        if (containingSite == null)
        {
            containingSite = siteServiceImpl.getSite(targetNode);
        }

        // Short-circuit at this point if the node is not in a Site.
        if (containingSite != null)
        {
            // For performance reasons we navigate down the containment hierarchy using the DAOs
            // rather than the NodeService. Note: direct use of NodeDAO requires tenantService (ALF-12732).
            final Long targetNodeID = nodeDAO.getNodePair(tenantService.getName(targetNode)).getFirst();
            final Long targetNodeAclID = nodeDAO.getNodeAclId(targetNodeID);
            Acl targetNodeAcl = aclDAO.getAcl(targetNodeAclID);
            
            // Nodes that don't have defining ACLs do not need to be considered.
            if (targetNodeAcl.getAclType() == ACLType.DEFINING)
            {
                AccessControlList targetNodeAccessControlList = aclDAO.getAccessControlList(targetNodeAclID);
                List<AccessControlEntry> targetNodeAclEntries = targetNodeAccessControlList.getEntries();
                for (AccessControlEntry entry : targetNodeAclEntries)
                {
                    String authority = entry.getAuthority();
                    
                    String thisSiteGroupPrefix = siteServiceImpl.getSiteGroup(containingSite.getShortName(), true);
                    
                    // If it's a group site permission for a site other than the current site
                    if (authority.startsWith(PermissionService.GROUP_PREFIX) &&
                            !authority.startsWith(PermissionService.ALL_AUTHORITIES) && // And it's not GROUP_EVERYONE
                            !authority.startsWith(thisSiteGroupPrefix))
                    {
                        // And if the current user has permissions to do it
                        if (publicServiceAccessService.hasAccess("PermissionService", "clearPermission", targetNode, authority) == AccessStatus.ALLOWED)
                        {
                            // Then remove it.
                            permissionService.clearPermission(targetNode, authority);
                        }
                        if (publicServiceAccessService.hasAccess("PermissionService", "setInheritParentPermissions", targetNode, true) == AccessStatus.ALLOWED)
                        {
                            // And reenable permission inheritance.
                            permissionService.setInheritParentPermissions(targetNode, true);
                        }
                    }
                    
                }
            }
            
            // Recurse
            List<NodeIdAndAclId> childNodeIds = nodeDAO.getPrimaryChildrenAcls(targetNodeID);
            for (NodeIdAndAclId nextChild : childNodeIds)
            {
                cleanSitePermissions(nodeDAO.getNodePair(nextChild.getId()).getSecond(), containingSite);
            }
        }
    }
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:61,代碼來源:SitesPermissionCleaner.java


注:本文中的org.alfresco.repo.domain.permissions.Acl類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。