org.nuxeo.ecm.core.api.security.ACL.getName()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中org.nuxeo.ecm.core.api.security.ACL.getName()方法的一些代码示例,展示了ACL.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ACL.getName()方法的具体详情如下:
包路径:org.nuxeo.ecm.core.api.security.ACL
类名称:ACL
方法名:getName

ACL.getName介绍

[英]Gets the ACL name.
[中]获取ACL名称。

代码示例

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

@Override
public ACL getACL(String name) {
  String localName = name == null ? ACL.LOCAL_ACL : name;
  return acls.stream().filter(acl -> acl.getName().equals(localName)).findFirst().orElse(null);
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

@Override
public ACL removeACL(String name) {
  for (int i = 0, len = acls.size(); i < len; i++) {
    ACL acl = acls.get(i);
    if (acl.getName().equals(name)) {
      cache.clear();
      return acls.remove(i);
    }
  }
  return null;
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

@Override
public void addACL(int pos, ACL acl) {
  ACL oldACL = getACL(acl.getName());
  if (oldACL != null) {
    acls.remove(oldACL);
  }
  acls.add(pos, acl);
  cache.clear();
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

@Override
public void addACL(String afterMe, ACL acl) {
  if (afterMe == null) {
    addACL(0, acl);
  } else {
    int i;
    int len = acls.size();
    for (i = 0; i < len; i++) {
      if (acls.get(i).getName().equals(afterMe)) {
        break;
      }
    }
    addACL(i + 1, acl);
  }
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-api

public void addACL(ACL acl) {
  assert acl != null;
  ACL oldACL = getACL(acl.getName());
  if (!acl.equals(oldACL)) {
      oldACL.addAll(acl);
    } else {
      String name = acl.getName();
      switch (name) {
      case ACL.INHERITED_ACL:

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql

protected static ACLRow[] acpToAclRows(ACP acp) {
  List<ACLRow> aclrows = new LinkedList<>();
  for (ACL acl : acp.getACLs()) {
    String name = acl.getName();
    if (name.equals(ACL.INHERITED_ACL)) {
      continue;
    }
    for (ACE ace : acl.getACEs()) {
      addACLRow(aclrows, name, ace);
    }
  }
  ACLRow[] array = new ACLRow[aclrows.size()];
  return aclrows.toArray(array);
}

代码示例来源:origin: opentoutatice-ecm.platform/opentoutatice-ecm-platform-automation

@SuppressWarnings("unchecked")
private void copyACP(DocumentRef docRef) throws NuxeoException {
  List<String> aclsToCopyList = Collections.emptyList();
  
  // get the ACP from the source document
  ACP srcACP = session.getACP(srcDoc.getRef());
  
  // slurp the ACLs to copy
  if (!doCopyAll && StringUtils.isNotBlank(ACLnames)) {
    aclsToCopyList = Arrays.asList(ACLnames.split(","));
  }
  
  // copy the ACLs
  ACP dstACP = new ACPImpl();
  for (ACL srcAcl : srcACP.getACLs()) {
    if ( doCopyAll ||
      (!doCopyAll && aclsToCopyList.contains(srcAcl.getName())) ) {
      dstACP.addACL(srcAcl);
    }
  }
  
  // save new ACP
  session.setACP(docRef, dstACP, doOverwrite);
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql

Map<String, ACL> aclmap = new HashMap<>();
for (ACL acl : acp.getACLs()) {
  String name = acl.getName();
  if (ACL.INHERITED_ACL.equals(name)) {
    continue;
  name = acl.getName();
  for (ACE ace : acl.getACEs()) {
    addACLRow(newaclrows, name, ace);

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-storage-sql

protected void checkNegativeAcl(ACP acp) {
  if (negativeAclAllowed) {
    return;
  }
  if (acp == null) {
    return;
  }
  for (ACL acl : acp.getACLs()) {
    if (acl.getName().equals(ACL.INHERITED_ACL)) {
      continue;
    }
    for (ACE ace : acl.getACEs()) {
      if (ace.isGranted()) {
        continue;
      }
      String permission = ace.getPermission();
      if (permission.equals(SecurityConstants.EVERYTHING)
          && ace.getUsername().equals(SecurityConstants.EVERYONE)) {
        continue;
      }
      // allow Write, as we're sure it doesn't include Read/Browse
      if (permission.equals(SecurityConstants.WRITE)) {
        continue;
      }
      throw new IllegalArgumentException("Negative ACL not allowed: " + ace);
    }
  }
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

@Override
protected void writeEntityBody(ACP acp, JsonGenerator jg) throws IOException {
  jg.writeArrayFieldStart("acl");
  for (ACL acl : acp.getACLs()) {
    jg.writeStartObject();
    jg.writeStringField("name", acl.getName());
    jg.writeArrayFieldStart("ace");
    for (ACE ace : acl.getACEs()) {
      jg.writeStartObject();
      jg.writeStringField("id", ace.getId());
      jg.writeStringField("username", ace.getUsername());
      jg.writeStringField("permission", ace.getPermission());
      jg.writeBooleanField("granted", ace.isGranted());
      jg.writeStringField("creator", ace.getCreator());
      jg.writeStringField("begin",
          ace.getBegin() != null ? DateParser.formatW3CDateTime(ace.getBegin().getTime()) : null);
      jg.writeStringField("end", ace.getEnd() != null ? DateParser.formatW3CDateTime(ace.getEnd().getTime())
          : null);
      jg.writeStringField("status", ace.getStatus().toString().toLowerCase());
      jg.writeEndObject();
    }
    jg.writeEndArray();
    jg.writeEndObject();
  }
  jg.writeEndArray();
}

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-ws

@Override
@WebMethod
public WsACE[] getDocumentLocalACL(@WebParam(name = "sessionId") String sid, @WebParam(name = "uuid") String uuid)
    {
  logDeprecation();
  WSRemotingSession rs = initSession(sid);
  ACP acp = rs.getDocumentManager().getACP(new IdRef(uuid));
  if (acp != null) {
    ACL mergedAcl = new ACLImpl("MergedACL", true);
    for (ACL acl : acp.getACLs()) {
      if (!ACL.INHERITED_ACL.equals(acl.getName())) {
        mergedAcl.addAll(acl);
      }
    }
    return WsACE.wrap(mergedAcl.toArray(new ACE[mergedAcl.size()]));
  } else {
    return null;
  }
}

代码示例来源:origin: opentoutatice-ecm.platform/opentoutatice-ecm-platform-automation

/**
 * @param document
 * @return ACEs of document as List.
 * @throws NuxeoException
 */
@OperationMethod
public Object run(DocumentModel document) throws NuxeoException {
  JSONObject allACLs = new JSONObject();
  
  ACP acp = session.getACP(document.getRef());
  if (acp != null) {
    ACL[] acLs = acp.getACLs();
    if (ArrayUtils.isNotEmpty(acLs)) {
      JSONArray inheritedACLs = new JSONArray();
      JSONArray localACLs = new JSONArray();
      for (ACL acl : acLs) {
        if (ACL.INHERITED_ACL.equals(acl.getName())) {
          extractNSetACEs(inheritedACLs, acl);
        } else if (ACL.LOCAL_ACL.equals(acl.getName())) {
          extractNSetACEs(localACLs, acl);
        }
      }
      allACLs.element(ACL.INHERITED_ACL, inheritedACLs);
      allACLs.element(ACL.LOCAL_ACL, localACLs);
    }
  }
  
  return new StringBlob(allACLs.toString(), "application/json");
}

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-webapp-core

/**
 * Feeds security data object with user entries.
 */
public static void convertToSecurityData(ACP acp, SecurityData securityData) {
  if (null == acp || null == securityData) {
    log.error("Null params received, returning...");
    return;
  }
  securityData.clear();
  for (ACL acl : acp.getACLs()) {
    boolean modifiable = acl.getName().equals(ACL.LOCAL_ACL);
    for (ACE entry : acl.getACEs()) {
      if (modifiable) {
        securityData.addModifiablePrivilege(entry.getUsername(), entry.getPermission(), entry.isGranted());
      } else {
        securityData.addUnModifiablePrivilege(entry.getUsername(), entry.getPermission(), entry.isGranted());
      }
      if (!entry.isGranted() && entry.getUsername().equals(SecurityConstants.EVERYONE)
          && entry.getPermission().equals(SecurityConstants.EVERYTHING)) {
        break;
      }
    }
  }
  // needed so that the user lists are updated
  securityData.rebuildUserLists();
  securityData.setNeedSave(false);
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

protected static void readACP(Element element, ACP acp) {
  ACL[] acls = acp.getACLs();
  for (ACL acl : acls) {
    Element aclElement = element.addElement(ExportConstants.ACL_TAG);
    aclElement.addAttribute(ExportConstants.NAME_ATTR, acl.getName());
    ACE[] aces = acl.getACEs();
    for (ACE ace : aces) {
      Element aceElement = aclElement.addElement(ExportConstants.ACE_TAG);
      aceElement.addAttribute(ExportConstants.PRINCIPAL_ATTR, ace.getUsername());
      aceElement.addAttribute(ExportConstants.PERMISSION_ATTR, ace.getPermission());
      aceElement.addAttribute(ExportConstants.GRANT_ATTR, String.valueOf(ace.isGranted()));
      aceElement.addAttribute(ExportConstants.CREATOR_ATTR, ace.getCreator());
      Calendar begin = ace.getBegin();
      if (begin != null) {
        aceElement.addAttribute(ExportConstants.BEGIN_ATTR,
            DateParser.formatW3CDateTime((begin).getTime()));
      }
      Calendar end = ace.getEnd();
      if (end != null) {
        aceElement.addAttribute(ExportConstants.END_ATTR, DateParser.formatW3CDateTime((end).getTime()));
      }
    }
  }
}

相关文章