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


Java Sid类代码示例

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


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

示例1: readAclById

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Override
public Acl readAclById(ObjectIdentity object, List<Sid> sids) throws NotFoundException {
    Map<ObjectIdentity, Acl> map = readAclsById(Arrays.asList(object), sids);
    Assert.isTrue(map.containsKey(object), "There should have been an Acl entry for ObjectIdentity " + object);

    return (Acl) map.get(object);
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:8,代码来源:JpaMutableAclService.java

示例2: lookupPrimaryKeys

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
/**
 * Locates the primary key IDs specified in "findNow", adding AclImpl instances with StubAclParents to the
 * "acls" Map.
 *
 * @param acls the AclImpls (with StubAclParents)
 * @param findNow Long-based primary keys to retrieve
 * @param sids
 */
private void lookupPrimaryKeys(final Map<Serializable, Acl> acls, final Set<Long> findNow, final List<Sid> sids) {
    Assert.notNull(acls, "ACLs are required");
    Assert.notEmpty(findNow, "Items to find now required");

    String sql = computeRepeatingSql(lookupPrimaryKeysWhereClause, findNow.size());

    Set<Long> parentsToLookup = jdbcTemplate.query(sql,
        new PreparedStatementSetter() {
            public void setValues(PreparedStatement ps) throws SQLException {
                int i = 0;

                for (Long toFind : findNow) {
                    i++;
                    ps.setLong(i, toFind);
                }
            }
        }, new ProcessResultSet(acls, sids));

    // Lookup the parents, now that our JdbcTemplate has released the database connection (SEC-547)
    if (parentsToLookup.size() > 0) {
        lookupPrimaryKeys(acls, parentsToLookup, sids);
    }
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:32,代码来源:BasicLookupStrategy.java

示例3: isGranted

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Override
public boolean isGranted(Acl acl, List<Permission> requests, List<Sid> sids, boolean administrativeMode) {
    PermissionData granted = getPermission(acl, sids);
    final int grantedMask = granted.getMask();
    boolean allow = false;
    for(Permission request: requests) {
        int reqMask = request.getMask();
        if((reqMask & grantedMask) == reqMask) {
            allow = true;
        }
        if(!allow) {
            // each false is mean disallow
            break;
        }
    }
    return allow;
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:18,代码来源:TenantBasedPermissionGrantedStrategy.java

示例4: getProjectPermission

import org.springframework.security.acls.model.Sid; //导入依赖的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

示例5: readAclsById

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Override
public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects,
		List<Sid> sids) throws NotFoundException {
	Map<ObjectIdentity, Acl> result = doLookup(objects, sids);

	// Check every requested object identity was found (throw
	// NotFoundException if needed)
	for (ObjectIdentity oid : objects) {
		if (!result.containsKey(oid)) {
			throw new NotFoundException("Unable to find ACL information for object identity '" + oid + "'");
		}
	}

	return result;

}
 
开发者ID:AlexCzar,项目名称:spring-security-acl-mongodb,代码行数:17,代码来源:MongodbAclService.java

示例6: lookUpParentAcls

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
private void lookUpParentAcls(Map<Serializable, Acl> acls, Set<String> parentIds, List<Sid> sids) {
	QAclObjectIdentity aclObjectIdentity = QAclObjectIdentity.aclObjectIdentity;
	BooleanExpression objectIdentityCondition = null;
	for (String oid : parentIds) {
		BooleanExpression oidCondition = aclObjectIdentity.id.eq(oid);
		if (objectIdentityCondition == null) {
			objectIdentityCondition = oidCondition;
		} else {
			objectIdentityCondition = objectIdentityCondition.or(oidCondition);
		}
	}
	List<AclObjectIdentity> aoiList = (List<AclObjectIdentity>) objectIdentityRepository
			.findAll(objectIdentityCondition, aclObjectIdentity.objectIdIdentity.asc());
	Set<String> parentIdsToLookup = getParentIdsToLookup(acls, aoiList, sids);
	if (parentIdsToLookup != null && parentIdsToLookup.size() > 0) {
		lookUpParentAcls(acls, parentIdsToLookup, sids);
	}
}
 
开发者ID:AlexCzar,项目名称:spring-security-acl-mongodb,代码行数:19,代码来源:MongodbAclService.java

示例7: readAclsById

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
/**
 * Read Acls By Object Identities and Sids
 */
@Override
public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects,
		List<Sid> sids) throws NotFoundException {
	Map<ObjectIdentity, Acl> result = lookupStrategy.readAclsById(objects,
			sids);

	// Check every requested object identity was found (throw
	// NotFoundException if needed)
	for (ObjectIdentity oid : objects) {
		if (!result.containsKey(oid)) {
			throw new NotFoundException(
					"Unable to find ACL information for object identity '"
							+ oid + "'");
		}
	}

	return result;
}
 
开发者ID:shazin,项目名称:spring-security-acl-neo4j,代码行数:22,代码来源:Neo4jAclService.java

示例8: getAclEntriesGroupedBySid

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public Map<Sid, List<AccessControlEntry>> getAclEntriesGroupedBySid(
		Serializable id,
		Class clazz) {
	ObjectIdentity oid = new ObjectIdentityImpl(clazz, id);
	try {
		Map<Sid, List<AccessControlEntry>> resposta = new HashMap<Sid, List<AccessControlEntry>>();
		List<AccessControlEntry> aces = aclServiceDao.findAclsByOid(oid);
		if (aces != null) {
			for (AccessControlEntry ace: aces) {
				List<AccessControlEntry> entriesForSid = resposta.get(ace.getSid());
				if (entriesForSid == null) {
					entriesForSid = new ArrayList<AccessControlEntry>();
					resposta.put(ace.getSid(), entriesForSid);
				}
				entriesForSid.add(ace);
			}
		}
		return resposta;
	} catch (NotFoundException ex) {
		return null;
	}
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:24,代码来源:PermissionService.java

示例9: revocarPermisos

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
private void revocarPermisos(
		Sid sid,
		Class<?> objectClass,
		Serializable objectIdentifier,
		Permission[] permissions) throws NotFoundException {
	ObjectIdentity oid = new ObjectIdentityImpl(objectClass, objectIdentifier);
	try {
		MutableAcl acl = (MutableAcl)aclService.readAclById(oid);
		List<Integer> indexosPerEsborrar = new ArrayList<Integer>();
		int aceIndex = 0;
		for (AccessControlEntry ace: acl.getEntries()) {
			if (ace.getSid().equals(sid)) {
				for (Permission p: permissions) {
					if (p.equals(ace.getPermission()))
						indexosPerEsborrar.add(aceIndex);
				}
			}
			aceIndex++;
		}
		for (Integer index: indexosPerEsborrar)
			acl.deleteAce(index);
		aclService.updateAcl(acl);
	} catch (NotFoundException nfex) {
		// Si no troba l'ACL no fa res
	}
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:27,代码来源:PermisosHelper.java

示例10: compareSids

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
/**
 * Note that position of SIDs is important
 * @param authSid
 * @param aclSid
 * @return
 */
private boolean compareSids(Sid authSid, Sid aclSid) {
    if(MultiTenancySupport.isNoTenant(aclSid)) {
        // acl sid can has no tenant, we must consider this
        // not that null tenant mean that it common rule for any GrantedAuthorities of tenants
        if(authSid instanceof GrantedAuthoritySid) {
            return (aclSid instanceof GrantedAuthoritySid) && Objects.equals(
              ((GrantedAuthoritySid) authSid).getGrantedAuthority(),
              ((GrantedAuthoritySid) aclSid).getGrantedAuthority()
            );
        }
        if(authSid instanceof PrincipalSid) {
            return (aclSid instanceof PrincipalSid) && Objects.equals(
              ((PrincipalSid) authSid).getPrincipal(),
              ((PrincipalSid) aclSid).getPrincipal()
            );
        }
    }
    // there a unsupported sids or its has tenant, compare its as usual objects
    return aclSid.equals(authSid);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:27,代码来源:TenantBasedPermissionGrantedStrategy.java

示例11: cumulativePermissions

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Test
 public void cumulativePermissions() {
    Authentication auth = new TestingAuthenticationToken("ben", "ignored", "ROLE_ADMINISTRATOR");
    auth.setAuthenticated(true);
    SecurityContextHolder.getContext().setAuthentication(auth);

    ObjectIdentity topParentOid = new ObjectIdentityImpl(TARGET_CLASS, "110");
    MutableAcl topParent = mongodbMutableAclService.createAcl(topParentOid);

    // Add an ACE permission entry
    Permission cm = new CumulativePermission().set(BasePermission.READ).set(BasePermission.ADMINISTRATION);
    assertEquals(17, cm.getMask());
    Sid benSid = new PrincipalSid(auth);
    topParent.insertAce(0, cm, benSid, true);
    assertEquals(1, topParent.getEntries().size());

    // Explicitly save the changed ACL
    topParent = mongodbMutableAclService.updateAcl(topParent);

    // Check the mask was retrieved correctly
    assertEquals(17, topParent.getEntries().get(0).getPermission().getMask());
    assertTrue(topParent.isGranted(Arrays.asList(cm), Arrays.asList(benSid), true));

    SecurityContextHolder.clearContext();
}
 
开发者ID:AlexCzar,项目名称:spring-security-acl-mongodb,代码行数:26,代码来源:MongodbMutableAclServiceTest.java

示例12: test4readAclById

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Test
@Rollback(false)
@Transactional(rollbackFor = Exception.class)
public void test4readAclById() {
	Authentication auth = new TestingAuthenticationToken("shazin", "N/A");
	auth.setAuthenticated(true);
	SecurityContextHolder.getContext().setAuthentication(auth);

	List<Sid> sids = Arrays.<Sid> asList(new PrincipalSid("USER_0"),
			new GrantedAuthoritySid("ROLE_1"));

	long start = System.nanoTime();
	Acl acl = mutableAclService.readAclById(new ObjectIdentityImpl(
			"com.test.Shazin1", 1l), sids);
	long end = System.nanoTime();

	System.out.println("Reading 1 objects in " + (end - start));

	assertNotNull(acl);
	assertEquals(2, acl.getEntries().size());
}
 
开发者ID:shazin,项目名称:spring-security-acl-neo4j,代码行数:22,代码来源:Neo4jAclServiceTest.java

示例13: findAuthorizedModules

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Override
public List<CfModule> findAuthorizedModules() {
    List<Sid> sids = sidRetrievalStrategy.getSids(SecurityContextHolder.getContext().getAuthentication());
    List<String> names = new ArrayList<String>();
    for (Sid sid : sids) {
        if (sid instanceof PrincipalSid)
            names.add(((PrincipalSid) sid).getPrincipal());
    }
    log.debug("==============================");
    for (String name : names) {
        log.debug("Group: " + name);
    }
    log.debug("==============================");
    List<CfModule> authorized = moduleDao.findAuthorized(names);
    log.debug("==============================");
    for (CfModule fsModule : authorized) {
        log.debug("authorized module: " + fsModule.getCode());
    }
    log.debug("==============================");
    return authorized;
}
 
开发者ID:rafizanbaharum,项目名称:cfi-gov,代码行数:22,代码来源:AmFinderImpl.java

示例14: readAclsById

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
@Override
public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, List<Sid> sids) throws NotFoundException {
    Map<ObjectIdentity, Acl> result = lookupStrategy.readAclsById(objects, sids);

    // Check every requested object identity was found (throw NotFoundException if needed)
    for (ObjectIdentity oid : objects) {
        if (!result.containsKey(oid)) {
            throw new NotFoundException("Unable to find ACL information for object identity '" + oid + "'");
        }
    }

    return result;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:14,代码来源:JpaMutableAclService.java

示例15: createObjectIdentity

import org.springframework.security.acls.model.Sid; //导入依赖的package包/类
/**
 * Creates an entry in the acl_object_identity table for the passed ObjectIdentity. The Sid is also
 * necessary, as acl_object_identity has defined the sid column as non-null.
 *
 * @param object to represent an acl_object_identity for
 * @param owner for the SID column (will be created if there is no acl_sid entry for this particular Sid already)
 * @return
 */
protected void createObjectIdentity(ObjectIdentity object, Sid owner) {
    AclSid sid = createOrRetrieveSidPrimaryKey(owner, true);
    AclClass clazz = createOrRetrieveClassPrimaryKey(object.getType(), true);
    AclObjectIdentity identity = new AclObjectIdentity();
    identity.setObjIdClass(clazz);
    identity.setObjIdIdentity((Long) object.getIdentifier());
    identity.setOwner(sid);
    identity.setEntriesInheriting(Boolean.TRUE);
    aclDao.createObjectIdentity(identity);

}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:20,代码来源:JpaMutableAclService.java


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