org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl Java Examples
The following examples show how to use
org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlfrescoCmisServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public Acl getAcl(String repositoryId, String objectId, Boolean onlyBasicPermissions, ExtensionsData extension) { checkRepositoryId(repositoryId); CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object"); // relationships don't have ACLs if (info.isVariant(CMISObjectVariant.ASSOC)) { return new AccessControlListImpl(Collections.EMPTY_LIST); } // get the ACL return connector.getACL(info.getCurrentNodeNodeRef(), onlyBasicPermissions); }
Example #2
Source File: Converter.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Converts an ACL object with its ACEs * * @param acl the security policies * @param isExact if the specification is exact * * @return the converted ACL */ public static Acl convert(CmisAccessControlListType acl, Boolean isExact) { if (acl == null) { return null; } AccessControlListImpl result = new AccessControlListImpl(); List<Ace> aces = new ArrayList<Ace>(); for (CmisAccessControlEntryType entry : acl.getPermission()) { if (entry == null) { continue; } AccessControlEntryImpl ace = new AccessControlEntryImpl(); ace.setDirect(entry.isDirect()); ace.setPermissions(entry.getPermission()); AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl( entry.getPrincipal() == null ? null : entry.getPrincipal().getPrincipalId()); convertExtension(entry.getPrincipal(), principal); ace.setPrincipal(principal); // handle extensions convertExtension(entry, ace); aces.add(ace); } result.setAces(aces); result.setExact(isExact); // handle extensions convertExtension(acl, result); return result; }
Example #3
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Compiles the ACL for a file or folder * * @param object the persistent object * * @return the ACL */ private Acl compileAcl(PersistentObject object) { AccessControlListImpl result = new AccessControlListImpl(); result.setAces(new ArrayList<Ace>()); for (Map.Entry<String, Boolean> ue : userMap.entrySet()) { // create principal // AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl(); // principal.setPrincipalId(ue.getKey()); // create principal AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl(ue.getKey()); // create ACE AccessControlEntryImpl entry = new AccessControlEntryImpl(); entry.setPrincipal(principal); entry.setPermissions(new ArrayList<String>()); entry.getPermissions().add(CMIS_READ); if (!ue.getValue().booleanValue() && checkPermission(object, null, Permission.WRITE) && !(object instanceof Folder && ((Folder) object).getType() == Folder.TYPE_WORKSPACE)) { entry.getPermissions().add(CMIS_WRITE); entry.getPermissions().add(CMIS_ALL); } entry.setDirect(true); // add ACE result.getAces().add(entry); } return result; }
Example #4
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Filter acl to ignore inherited ACEs * * @param nodeRef NodeRef * @param acl Acl * @return Acl */ protected Acl excludeInheritedAces(NodeRef nodeRef, Acl acl) { List<Ace> newAces = new ArrayList<Ace>(); Acl allACLs = getACL(nodeRef, false); Map<String, Set<String>> originalsAcls = convertAclToMap(allACLs); Map<String, Set<String>> newAcls = convertAclToMap(acl); // iterate through the original ACEs for (Map.Entry<String, Set<String>> ace : originalsAcls.entrySet()) { // add permissions Set<String> addPermissions = newAcls.get(ace.getKey()); if (addPermissions != null) { ace.getValue().addAll(addPermissions); } // create new ACE if (!ace.getValue().isEmpty()) { newAces.add(new AccessControlEntryImpl(new AccessControlPrincipalDataImpl(ace .getKey()), new ArrayList<String>(ace.getValue()))); } } return new AccessControlListImpl(newAces); }
Example #5
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("unchecked") private ObjectData createCMISObjectImpl(final CMISNodeInfo info, Properties nodeProps, String filter, boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, boolean includePolicyIds, boolean includeAcl) { final ObjectDataImpl result = new ObjectDataImpl(); // set allowable actions if (includeAllowableActions) { result.setAllowableActions(getAllowableActions(info)); } // set policy ids if (includePolicyIds) { result.setPolicyIds(new PolicyIdListImpl()); } if (info.isRelationship()) { // set properties result.setProperties(getAssocProperties(info, filter)); // set ACL if (includeAcl) { // association have no ACL - return an empty list of ACEs result.setAcl(new AccessControlListImpl((List<Ace>) Collections.EMPTY_LIST)); result.setIsExactAcl(Boolean.FALSE); } } else { // set properties result.setProperties(nodeProps); // set relationships if (includeRelationships != IncludeRelationships.NONE) { result.setRelationships(getRelationships(info.getNodeRef(), includeRelationships)); } // set renditions if (!RENDITION_NONE.equals(renditionFilter)) { List<RenditionData> renditions = getRenditions(info.getNodeRef(), renditionFilter, null, null); if ((renditions != null) && (!renditions.isEmpty())) { result.setRenditions(renditions); } else { result.setRenditions(Collections.EMPTY_LIST); } } // set ACL if (includeAcl) { AuthenticationUtil.runAsSystem(new RunAsWork<Void>() { @Override public Void doWork() throws Exception { Acl acl = getACL(info.getCurrentNodeNodeRef(), false); if (acl != null) { result.setAcl(acl); result.setIsExactAcl(acl.isExact()); } return null; } }); } // add aspects List<CmisExtensionElement> extensions = getAspectExtensions(info, filter, result.getProperties() .getProperties().keySet()); if (!extensions.isEmpty()) { result.getProperties().setExtensions( Collections.singletonList((CmisExtensionElement) new CmisExtensionElementImpl( ALFRESCO_EXTENSION_NAMESPACE, ASPECTS, null, extensions))); } } return result; }