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


Java ObjectIdentity类代码示例

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


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

示例1: createAcl

import org.springframework.security.acls.model.ObjectIdentity; //导入依赖的package包/类
@Override
public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException {
    Assert.notNull(objectIdentity, "Object Identity required");

    // Check this object identity hasn't already been persisted
    if (retrieveObjectIdentityPrimaryKey(objectIdentity) != null) {
        throw new AlreadyExistsException("Object identity '" + objectIdentity + "' already exists");
    }

    // Need to retrieve the current principal, in order to know who "owns" this ACL (can be changed later on)
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    PrincipalSid sid = new PrincipalSid(auth);

    // Create the acl_object_identity row
    createObjectIdentity(objectIdentity, sid);

    // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc)
    Acl acl = readAclById(objectIdentity);
    Assert.isInstanceOf(MutableAcl.class, acl, "MutableAcl should be been returned");

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

示例2: readAclById

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

示例3: createAcl

import org.springframework.security.acls.model.ObjectIdentity; //导入依赖的package包/类
public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException {
    Assert.notNull(objectIdentity, "Object Identity required");

    // Check this object identity hasn't already been persisted
    if (retrieveObjectIdentityPrimaryKey(objectIdentity) != null) {
        throw new AlreadyExistsException("Object identity '" + objectIdentity + "' already exists");
    }

    // Need to retrieve the current principal, in order to know who "owns" this ACL (can be changed later on)
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    PrincipalSid sid = new PrincipalSid(auth);

    // Create the acl_object_identity row
    createObjectIdentity(objectIdentity, sid);

    // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc)
    Acl acl = readAclById(objectIdentity);
    Assert.isInstanceOf(MutableAcl.class, acl, "MutableAcl should be been returned");

    return (MutableAcl) acl;
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:22,代码来源:JdbcMutableAclService.java

示例4: deletePermis

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

示例5: mapRow

import org.springframework.security.acls.model.ObjectIdentity; //导入依赖的package包/类
/**
 * @param resultSet Set the result set
 * @param row Set the row
 * @return an access control entry
 * @throws SQLException if there is a problem
 */
public final AccessControlEntry mapRow(final ResultSet resultSet,
	 final int row) throws SQLException {
 ObjectIdentity objectIdentity = new ObjectIdentityImpl(
		 resultSet.getString("object_class"),
		 resultSet.getLong("object_identity"));
 Acl acl = new AclImpl(objectIdentity, 0, aclAuthorizationStrategy, auditLogger);
 int mask = resultSet.getInt("mask");
 Permission permission = null;
 if (mask == BasePermission.CREATE.getMask()) {
	 permission = BasePermission.CREATE;
 } else if (mask == BasePermission.READ.getMask()) {
	 permission = BasePermission.READ;
 } else if (mask == BasePermission.WRITE.getMask()) {
	 permission = BasePermission.WRITE;
 } else if (mask == BasePermission.DELETE.getMask()) {
	 permission = BasePermission.DELETE;
 }  else {
	 permission = BasePermission.ADMINISTRATION;
 }
 AccessControlEntry ace = new AccessControlEntryImpl(0, acl, sid,
		 permission, resultSet.getBoolean("granting"),
		 resultSet.getBoolean("auditSuccess"),
		 resultSet.getBoolean("auditFailure"));
 return ace;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:32,代码来源:AclServiceImpl.java

示例6: readAclsById

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

示例7: createAcl

import org.springframework.security.acls.model.ObjectIdentity; //导入依赖的package包/类
@Override
public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException {
       Assert.notNull(objectIdentity, "Object Identity required");

       // Check this object identity hasn't already been persisted
       if (retrieveObjectIdentityPrimaryKey(objectIdentity) != null) {
           throw new AlreadyExistsException("Object identity '" + objectIdentity + "' already exists");
       }

       // Need to retrieve the current principal, in order to know who "owns" this ACL (can be changed later on)
       Authentication auth = SecurityContextHolder.getContext().getAuthentication();
       PrincipalSid sid = new PrincipalSid(auth);

       // Create the acl_object_identity row
       createObjectIdentity(objectIdentity, sid);

       // Retrieve the ACL via superclass (ensures cache registration, proper retrieval etc)
       Acl acl = readAclById(objectIdentity);
       Assert.isInstanceOf(MutableAcl.class, acl, "MutableAcl should be been returned");

       return (MutableAcl) acl;
   }
 
开发者ID:AlexCzar,项目名称:spring-security-acl-mongodb,代码行数:23,代码来源:MongodbMutableAclService.java

示例8: readAclById_ValidObjectIdentity_ReturnData

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

示例9: readAclsById

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

示例10: getAclEntriesGroupedBySid

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

示例11: findChildren

import org.springframework.security.acls.model.ObjectIdentity; //导入依赖的package包/类
public List<ObjectIdentity> findChildren(ObjectIdentity parentIdentity) {
    Object[] args = {parentIdentity.getIdentifier(), parentIdentity.getType()};
    List<ObjectIdentity> objects = jdbcTemplate.query(findChildrenSql, args,
            new RowMapper<ObjectIdentity>() {
                public ObjectIdentity mapRow(ResultSet rs, int rowNum) throws SQLException {
                    String javaType = rs.getString("class");
                    Long identifier = new Long(rs.getLong("obj_id"));

                    return new ObjectIdentityImpl(javaType, identifier);
                }
            });

    if (objects.size() == 0) {
        return null;
    }

    return objects;
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:19,代码来源:JdbcAclService.java

示例12: revocarPermisos

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

示例13: findChildren

import org.springframework.security.acls.model.ObjectIdentity; //导入依赖的package包/类
@Override
public List<ObjectIdentity> findChildren(ObjectIdentity parentIdentity) {
    List<ObjectIdentity> oids = new ArrayList<ObjectIdentity>();
    try {
        List<AclRecord> allAclRecords = aclStore.getAllResources(String.valueOf(DIR_PREFIX), AclRecord.class,
                SERIALIZER);
        for (AclRecord record : allAclRecords) {
            DomainObjectInfo parent = record.getParentDomainObjectInfo();
            if (parent != null && parent.getId().equals(String.valueOf(parentIdentity.getIdentifier()))) {
                DomainObjectInfo child = record.getDomainObjectInfo();
                oids.add(new ObjectIdentityImpl(child.getType(), child.getId()));
            }
        }
        return oids;
    } catch (IOException e) {
        throw new InternalErrorException(e);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:19,代码来源:AclService.java

示例14: deleteAcl

import org.springframework.security.acls.model.ObjectIdentity; //导入依赖的package包/类
@Override
public void deleteAcl(ObjectIdentity objectIdentity, boolean deleteChildren) throws ChildrenExistException {
    Message msg = MsgPicker.getMsg();
    try {
        List<ObjectIdentity> children = findChildren(objectIdentity);
        if (!deleteChildren && children.size() > 0) {
            throw new BadRequestException(String.format(msg.getIDENTITY_EXIST_CHILDREN(), objectIdentity));
        }
        for (ObjectIdentity oid : children) {
            deleteAcl(oid, deleteChildren);
        }
        aclStore.deleteResource(getQueryKeyById(String.valueOf(objectIdentity.getIdentifier())));
        logger.debug("ACL of " + objectIdentity + " deleted successfully.");
    } catch (IOException e) {
        throw new InternalErrorException(e);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:18,代码来源:AclService.java

示例15: hasPermission

import org.springframework.security.acls.model.ObjectIdentity; //导入依赖的package包/类
@Transactional
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')")
public void clean(AclEntity ae, boolean deleteChildren) {
    Message msg = MsgPicker.getMsg();

    if (ae == null) {
        throw new BadRequestException(msg.getACL_DOMAIN_NOT_FOUND());
    }

    // For those may have null uuid, like DataModel, won't delete Acl.
    if (ae.getId() == null)
        return;

    ObjectIdentity objectIdentity = new ObjectIdentityImpl(ae.getClass(), ae.getId());

    try {
        aclService.deleteAcl(objectIdentity, deleteChildren);
    } catch (NotFoundException e) {
        //do nothing?
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:22,代码来源:AccessService.java


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