当前位置: 首页>>代码示例>>Java>>正文


Java Acl.getEntries方法代码示例

本文整理汇总了Java中org.springframework.security.acls.model.Acl.getEntries方法的典型用法代码示例。如果您正苦于以下问题:Java Acl.getEntries方法的具体用法?Java Acl.getEntries怎么用?Java Acl.getEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.security.acls.model.Acl的用法示例。


在下文中一共展示了Acl.getEntries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deletePermis

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
public void deletePermis(
		Long objectIdentifier,
		Class<?> objectClass,
		Long permisId) {
	try {
		ObjectIdentity oid = new ObjectIdentityImpl(objectClass, objectIdentifier);
		Acl acl = aclService.readAclById(oid);
		for (AccessControlEntry ace: acl.getEntries()) {
			if (permisId.equals(ace.getId())) {
				assignarPermisos(
						ace.getSid(),
						objectClass,
						objectIdentifier,
						new Permission[] {},
						true);
			}
		}
	} catch (NotFoundException nfex) {
	}
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:21,代码来源:PermisosHelper.java

示例2: getAllAclSids

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
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("user") && ace.getSid() instanceof PrincipalSid) {
            name = ((PrincipalSid) ace.getSid()).getPrincipal();
        }
        if (type.equalsIgnoreCase("group") && ace.getSid() instanceof GrantedAuthoritySid) {
            name = ((GrantedAuthoritySid) ace.getSid()).getGrantedAuthority();
        }
        if (!StringUtils.isBlank(name)) {
            result.add(name);
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:kylin,代码行数:21,代码来源:AccessService.java

示例3: getProjectPermission

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:23,代码来源:AccessService.java

示例4: readAclById_ValidObjectIdentity_ReturnData

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
@Test
public void readAclById_ValidObjectIdentity_ReturnData() throws Exception {
	// arrange 
	ObjectIdentity objectIdentity = new ObjectIdentityImpl("blog.core.Post", "1");

	// action
	Acl acl = mongodbAclService.readAclById(objectIdentity);
	
	// verify
	assertNotNull("Acl should not be null", acl);
	ObjectIdentity result = acl.getObjectIdentity();
	assertEquals(result.getIdentifier(), objectIdentity.getIdentifier());
	assertEquals(result.getType(), objectIdentity.getType());
	
	List<AccessControlEntry> entries = acl.getEntries();
	assertNotNull("Acl entries list should not be null", entries);
	assertEquals(3, entries.size());
}
 
开发者ID:AlexCzar,项目名称:spring-security-acl-mongodb,代码行数:19,代码来源:MongodbAclServiceTest.java

示例5: assertAcl

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
private void assertAcl(Acl expected, Acl actual) {
	assertEquals(expected.getObjectIdentity().getType(), actual.getObjectIdentity().getType());
	assertEquals(expected.getObjectIdentity().getIdentifier(), actual.getObjectIdentity().getIdentifier());
	assertEquals(expected.getOwner(), actual.getOwner());		
	assertEquals(expected.isEntriesInheriting(), actual.isEntriesInheriting());		
	
	if (expected.getEntries() != null && actual.getEntries() != null) {
		assertEquals(expected.getEntries().size(), actual.getEntries().size());
		for (int i = 0; i < expected.getEntries().size(); i++) {
			assertAclEntry(expected.getEntries().get(i), actual.getEntries().get(i));
		}
	} else {
		assertEquals(expected.getEntries(), actual.getEntries());
	}
	
	if (expected.getParentAcl() != null && actual.getParentAcl() != null) {
		assertAcl(expected.getParentAcl(), actual.getParentAcl());
	} else {
		assertEquals(expected.getParentAcl(), actual.getParentAcl());
	}
}
 
开发者ID:RigasGrigoropoulos,项目名称:spring-security-acl-cassandra,代码行数:22,代码来源:CassandraAclServiceTest.java

示例6: findPermisosPerAcl

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
private List<PermisDto> findPermisosPerAcl(Acl acl) {
	List<PermisDto> resposta = new ArrayList<PermisDto>();
	if (acl != null) {
		Map<String, PermisDto> permisosUsuari = new HashMap<String, PermisDto>();
		Map<String, PermisDto> permisosRol = new HashMap<String, PermisDto>();
		for (AccessControlEntry ace: acl.getEntries()) {
			PermisDto permis = null;
			if (ace.getSid() instanceof PrincipalSid) {
				String principal = ((PrincipalSid)ace.getSid()).getPrincipal();
				permis = permisosUsuari.get(principal);
				if (permis == null) {
					permis = new PermisDto();
					permis.setId((Long)ace.getId());
					permis.setPrincipalNom(principal);
					permis.setPrincipalTipus(PrincipalTipusEnumDto.USUARI);
					permisosUsuari.put(principal, permis);
				}
			} else if (ace.getSid() instanceof GrantedAuthoritySid) {
				String grantedAuthority = ((GrantedAuthoritySid)ace.getSid()).getGrantedAuthority();
				permis = permisosRol.get(grantedAuthority);
				if (permis == null) {
					permis = new PermisDto();
					permis.setId((Long)ace.getId());
					permis.setPrincipalNom(grantedAuthority);
					permis.setPrincipalTipus(PrincipalTipusEnumDto.ROL);
					permisosRol.put(grantedAuthority, permis);
				}
			}
			if (permis != null) {
				updatePermisAmbPermission(
						permis,
						ace.getPermission());
			}
		}
		resposta.addAll(permisosUsuari.values());
		resposta.addAll(permisosRol.values());
	}
	return resposta;
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:40,代码来源:PermisosHelper.java

示例7: generateAceResponsesByFuzzMatching

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:16,代码来源:AccessService.java

示例8: generateAllAceResponses

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:13,代码来源:AccessService.java

示例9: getAllSids

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:13,代码来源:ValidateUtil.java

示例10: readAclsById_MultipleObjectIdentity_ReturnData

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
@Test
public void readAclsById_MultipleObjectIdentity_ReturnData() throws Exception {
	// arrange 
	ObjectIdentity objectIdentity1 = new ObjectIdentityImpl("blog.core.Post", "1");
	ObjectIdentity objectIdentity4 = new ObjectIdentityImpl("blog.core.Post", "4");
	List<ObjectIdentity> list = new ArrayList<ObjectIdentity>();
	list.add(objectIdentity1);
	list.add(objectIdentity4);
	Map<ObjectIdentity, Acl> result = mongodbAclService.readAclsById(list);
	
	// verify
	assertNotNull(result);
	assertTrue(result.containsKey(objectIdentity1));
	assertTrue(result.containsKey(objectIdentity4));
	assertEquals(2, result.keySet().size());
	
	Acl acl1 = result.get(objectIdentity1);
	assertNotNull(acl1);
	List<AccessControlEntry> entries1 = acl1.getEntries();
	assertNotNull(entries1);
	assertEquals(3, entries1.size());
	
	Acl acl2 = result.get(objectIdentity4);
	assertNotNull(acl2);
	List<AccessControlEntry> entries2 = acl2.getEntries();
	assertNotNull(entries2);
	assertEquals(2, entries2.size());
}
 
开发者ID:AlexCzar,项目名称:spring-security-acl-mongodb,代码行数:29,代码来源:MongodbAclServiceTest.java

示例11: readAclsById_MultipleObjectIdentityAndSid_ReturnData

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
@Test
public void readAclsById_MultipleObjectIdentityAndSid_ReturnData() throws Exception {
	// arrange 
	ObjectIdentity objectIdentity1 = new ObjectIdentityImpl("blog.core.Post", "1");
	ObjectIdentity objectIdentity4 = new ObjectIdentityImpl("blog.core.Post", "4");
	List<ObjectIdentity> list = new ArrayList<ObjectIdentity>();
	list.add(objectIdentity1);
	list.add(objectIdentity4);
	
	List<Sid> sids = new ArrayList<Sid>();
	Sid sid = new PrincipalSid("1");
	sids.add(sid);
	Map<ObjectIdentity, Acl> result = mongodbAclService.readAclsById(list, sids);
	
	// verify
	assertNotNull(result);
	assertTrue(result.containsKey(objectIdentity1));
	assertTrue(result.containsKey(objectIdentity4));
	assertEquals(2, result.keySet().size());
	
	Acl acl1 = result.get(objectIdentity1);
	assertNotNull(acl1);
	List<AccessControlEntry> entries1 = acl1.getEntries();
	assertNotNull(entries1);
	assertEquals(3, entries1.size());
	
	Acl acl2 = result.get(objectIdentity4);
	assertNotNull(acl2);
	List<AccessControlEntry> entries2 = acl2.getEntries();
	assertNotNull(entries2);
	assertEquals(2, entries2.size());
}
 
开发者ID:AlexCzar,项目名称:spring-security-acl-mongodb,代码行数:33,代码来源:MongodbAclServiceTest.java

示例12: generateAceResponses

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
public List<AccessEntryResponse> generateAceResponses(Acl acl) {
    if (null == acl) {
        return Collections.emptyList();
    }
    List<AccessEntryResponse> accessControlEntities = new ArrayList<AccessEntryResponse>();

    // Cause there is a circle reference in AccessControlEntry, it needs to
    // set acl to null as a workaround.
    for (AccessControlEntry ace : acl.getEntries()) {
        accessControlEntities.add(new AccessEntryResponse(ace.getId(), ace.getSid(), ace.getPermission(), ace.isGranting()));
    }

    return accessControlEntities;
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:15,代码来源:AccessService.java

示例13: convertToAclEntries

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
/**
 * Converts an {@link Acl} to a list of {@link AclEntry} objects.
 * 
 * @param acl the {@link Acl} to convert.
 * @return the list of derived {@link AclEntry} objects.
 */
private List<AclEntry> convertToAclEntries(Acl acl) {
	List<AclEntry> result = new ArrayList<AclEntry>();
	
	for (AccessControlEntry entry : acl.getEntries()) {
		result.add(new AclEntry(entry));
	}		
	return result;
}
 
开发者ID:RigasGrigoropoulos,项目名称:spring-security-acl-cassandra,代码行数:15,代码来源:CassandraMutableAclService.java

示例14: findPermisosPerAcl

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
private List<PermisDto> findPermisosPerAcl(Acl acl) {
	List<PermisDto> resposta = new ArrayList<PermisDto>();
	if (acl != null) {
		Map<String, PermisDto> permisosUsuari = new HashMap<String, PermisDto>();
		Map<String, PermisDto> permisosRol = new HashMap<String, PermisDto>();
		for (AccessControlEntry ace: acl.getEntries()) {
			PermisDto permis = null;
			if (ace.getSid() instanceof PrincipalSid) {
				String principal = ((PrincipalSid)ace.getSid()).getPrincipal();
				permis = permisosUsuari.get(principal);
				if (permis == null) {
					permis = new PermisDto();
					permis.setId((Long)ace.getId());
					permis.setPrincipalNom(principal);
					permis.setPrincipalTipus(PrincipalTipusEnumDto.USUARI);
					permisosUsuari.put(principal, permis);
				}
			} else if (ace.getSid() instanceof GrantedAuthoritySid) {
				String grantedAuthority = ((GrantedAuthoritySid)ace.getSid()).getGrantedAuthority();
				permis = permisosUsuari.get(grantedAuthority);
				if (permis == null) {
					permis = new PermisDto();
					permis.setId((Long)ace.getId());
					permis.setPrincipalNom(grantedAuthority);
					permis.setPrincipalTipus(PrincipalTipusEnumDto.ROL);
					permisosRol.put(grantedAuthority, permis);
				}
			}
			if (permis != null) {
				if (BasePermission.READ.equals(ace.getPermission()))
					permis.setRead(true);
				if (BasePermission.WRITE.equals(ace.getPermission()))
					permis.setWrite(true);
				if (BasePermission.CREATE.equals(ace.getPermission()))
					permis.setCreate(true);
				if (BasePermission.DELETE.equals(ace.getPermission()))
					permis.setDelete(true);
				if (BasePermission.ADMINISTRATION.equals(ace.getPermission()))
					permis.setAdministration(true);
			}
		}
		resposta.addAll(permisosUsuari.values());
		resposta.addAll(permisosRol.values());
	}
	return resposta;
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:47,代码来源:PermisosHelper.java

示例15: getPermission

import org.springframework.security.acls.model.Acl; //导入方法依赖的package包/类
@Override
public PermissionData getPermission(Acl acl, List<Sid> sids) {
    Assert.notNull(tenantsService, "tenantsService is null");
    Assert.notNull(userDetailsService, "userDetailsService is null");

    final Sid ownerSid = acl.getOwner();
    final String ownerTenantId = getTenantFromSid(ownerSid);
    if(ownerTenantId == MultiTenancySupport.NO_TENANT) {
        throw new RuntimeException("Can not retrieve tenant from acl owner: acl.objectIdentity=" + acl.getObjectIdentity().getIdentifier());
    }

    final String currentPrincipalTenant = getPrincipalSidTenant(sids);

    PermissionGrantingContext pgc = new PermissionGrantingContext(this, ownerSid, currentPrincipalTenant);
    // below code based on DefaultPermissionGrantingStrategy
    final List<AccessControlEntry> aces = acl.getEntries();
    pgc.setHasAces(!aces.isEmpty());

    PermissionData.Builder pb = PermissionData.builder();
    pb.add(defaultBehavior.getPermission(pgc));

    // !! not use foreach here
    for(int aceIndex = 0; aceIndex < aces.size(); ++ aceIndex) {
        AccessControlEntry ace = aces.get(aceIndex);
        Sid aceSid = ace.getSid();
        final String aceTenant = getTenantFromSid(aceSid);
        for(int sidIndex = 0; sidIndex < sids.size(); ++sidIndex) {
            final Sid sid = sids.get(sidIndex);
            pgc.setCurrentSid(sid);

            //root SIDs consume all ACE
            if(aceTenant != null && !pgc.getCurrentTenants().contains(aceTenant)) {
                continue;
            }
            if(!compareSids(sid, aceSid)) {
                continue;
            }

            Permission acep = ace.getPermission();
            if(ace.isGranting()) {
                pb.add(acep);
            } else {
                pb.remove(acep);
            }
        }
    }
    //TODO handle ACL inheriting
    return pb.build();
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:50,代码来源:TenantBasedPermissionGrantedStrategy.java


注:本文中的org.springframework.security.acls.model.Acl.getEntries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。