org.springframework.security.acls.model.Acl.getEntries()方法的使用及代码示例

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

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

Acl.getEntries介绍

[英]Returns all of the entries represented by the present Acl. Entries associated with the Acl parents are not returned.

This method is typically used for administrative purposes.

The order that entries appear in the array is important for methods declared in the MutableAcl interface. Furthermore, some implementations MAY use ordering as part of advanced permission checking.

Do NOT use this method for making authorization decisions. Instead use #isGranted(List,List,boolean).

This method must operate correctly even if the Acl only represents a subset of Sids. The caller is responsible for correctly handling the result if only a subset of Sids is represented.
[中]返回当前Acl表示的所有条目。不会返回与Acl父项关联的条目。
此方法通常用于管理目的。
条目在数组中出现的顺序对于在MutableAcl接口中声明的方法很重要。此外,一些实现可能使用排序作为高级权限检查的一部分。
请勿*使用此方法进行授权决策。而是使用#isgrated(List,List,boolean)。
即使Acl仅代表SID的一个子集,此方法也必须正确运行。如果只表示SID的子集,则调用方负责正确处理结果。

代码示例

代码示例来源:origin: apache/kylin

private List<Sid> getAllSids(String project) {
  List<Sid> allSids = new ArrayList<>();
  ProjectInstance prj = projectService.getProjectManager().getProject(project);
  AclEntity ae = accessService.getAclEntity("ProjectInstance", prj.getUuid());
  Acl acl = accessService.getAcl(ae);
  if (acl != null && acl.getEntries() != null) {
    for (AccessControlEntry ace : acl.getEntries()) {
      allSids.add(ace.getSid());
    }
  }
  return allSids;
}

代码示例来源:origin: apache/kylin

public List<String> getAllAclSids(Acl acl, String type) {
  if (null == acl) {
    return Collections.emptyList();
  }
  List<String> result = new ArrayList<>();
  for (AccessControlEntry ace : acl.getEntries()) {
    String name = null;
    if (type.equalsIgnoreCase(MetadataConstants.TYPE_USER) && ace.getSid() instanceof PrincipalSid) {
      name = ((PrincipalSid) ace.getSid()).getPrincipal();
    }
    if (type.equalsIgnoreCase(MetadataConstants.TYPE_GROUP) && ace.getSid() instanceof GrantedAuthoritySid) {
      name = ((GrantedAuthoritySid) ace.getSid()).getGrantedAuthority();
    }
    if (!StringUtils.isBlank(name)) {
      result.add(name);
    }
  }
  return result;
}

代码示例来源:origin: apache/kylin

public Object generateAllAceResponses(Acl acl) {
  List<AccessEntryResponse> result = new ArrayList<AccessEntryResponse>();
  while (acl != null) {
    for (AccessControlEntry ace : acl.getEntries()) {
      result.add(new AccessEntryResponse(ace.getId(), ace.getSid(), ace.getPermission(), ace.isGranting()));
    }
    acl = acl.getParentAcl();
  }
  return result;
}

代码示例来源:origin: apache/kylin

public List<AccessEntryResponse> generateAceResponsesByFuzzMatching(Acl acl, String nameSeg,
    boolean isCaseSensitive) {
  if (null == acl) {
    return Collections.emptyList();
  }
  List<AccessEntryResponse> result = new ArrayList<AccessEntryResponse>();
  for (AccessControlEntry ace : acl.getEntries()) {
    if (nameSeg != null && !needAdd(nameSeg, isCaseSensitive, getName(ace.getSid()))) {
      continue;
    }
    result.add(new AccessEntryResponse(ace.getId(), ace.getSid(), ace.getPermission(), ace.isGranting()));
  }
  return result;
}

代码示例来源:origin: apache/kylin

private Map<String, Integer> getProjectPermission(String project) {
  Map<String, Integer> SidWithPermission = new HashMap<>();
  String uuid = ProjectManager.getInstance(KylinConfig.getInstanceFromEnv()).getProject(project).getUuid();
  AclEntity ae = getAclEntity(AclEntityType.PROJECT_INSTANCE, uuid);
  Acl acl = getAcl(ae);
  if (acl != null && acl.getEntries() != null) {
    List<AccessControlEntry> aces = acl.getEntries();
    for (AccessControlEntry ace : aces) {
      Sid sid = ace.getSid();
      if (sid instanceof PrincipalSid) {
        String principal = ((PrincipalSid) sid).getPrincipal();
        SidWithPermission.put(principal, ace.getPermission().getMask());
      }
      if (sid instanceof GrantedAuthoritySid) {
        String grantedAuthority = ((GrantedAuthoritySid) sid).getGrantedAuthority();
        SidWithPermission.put(grantedAuthority, ace.getPermission().getMask());
      }
    }
  }
  return SidWithPermission;
}

代码示例来源:origin: spring-projects/spring-security

boolean administrativeMode) throws NotFoundException {
final List<AccessControlEntry> aces = acl.getEntries();

代码示例来源:origin: org.molgenis/molgenis-core-ui

private Multimap<String, String> getPermissions(Map<ObjectIdentity, Acl> acls, Sid sid) {
 Multimap<String, String> result = LinkedHashMultimap.create();
 acls.forEach(
   (objectIdentity, acl) -> {
    String id = objectIdentity.getIdentifier().toString();
    acl.getEntries()
      .stream()
      .filter(ace -> ace.getSid().equals(sid))
      .map(this::getPermissionString)
      .forEach(permission -> result.put(id, permission));
   });
 return result;
}

代码示例来源:origin: codeabovelab/haven-platform

final List<AccessControlEntry> aces = acl.getEntries();
pgc.setHasAces(!aces.isEmpty());

代码示例来源:origin: codeabovelab/haven-platform

public Builder from(Acl aclData) {
  if(aclData instanceof MutableAcl) {
    this.setId((Long)((MutableAcl) aclData).getId());
  }
  final List<AccessControlEntry> srcEntries = aclData.getEntries();
  if(srcEntries != null) {
    final int size = srcEntries.size();
    final List<AceData> aceDatas = new ArrayList<>(size);
    for(int i = 0; i < size; ++i) {
      AccessControlEntry entry = srcEntries.get(i);
      AceData aceData = AceDataImpl.builder().from(entry).build();
      aceDatas.add(aceData);
    }
    this.setEntries(aceDatas);
  }
  this.setObjectIdentity(aclData.getObjectIdentity());
  this.setOwner(aclData.getOwner());
  Acl parentAcl = aclData.getParentAcl();
  if(parentAcl != null) {
    this.setParentAclData(AclDataImpl.builder().from(parentAcl).build());
  }
  this.setEntriesInheriting(aclData.isEntriesInheriting());
  return this;
}

代码示例来源:origin: org.molgenis/molgenis-security

public boolean isGranted(
  Acl acl, List<Permission> permission, List<Sid> sids, boolean administrativeMode) {
 final List<AccessControlEntry> aces = acl.getEntries();

代码示例来源:origin: apache/servicemix-bundles

boolean administrativeMode) throws NotFoundException {
final List<AccessControlEntry> aces = acl.getEntries();

相关文章