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


Java MutableAcl.insertAce方法代码示例

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


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

示例1: createEvent

import org.springframework.security.acls.model.MutableAcl; //导入方法依赖的package包/类
@Transactional
@Override
public int createEvent(Event event) {

    int result = eventDao.createEvent(event);
    event.setId(result);

    // Add new ACL Entry:
    MutableAcl acl = aclService.createAcl(new ObjectIdentityImpl(event));
    PrincipalSid sid = new PrincipalSid(userContext.getCurrentUser().getEmail());
    acl.setOwner(sid);
    acl.insertAce(0,  BasePermission.READ, sid, true);
    aclService.updateAcl(acl);

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

示例2: deleteAclRemovesRowsFromDatabase

import org.springframework.security.acls.model.MutableAcl; //导入方法依赖的package包/类
@Test
public void deleteAclRemovesRowsFromDatabase() throws Exception {
    SecurityContextHolder.getContext().setAuthentication(auth);
    MutableAcl child = mongodbMutableAclService.createAcl(childOid);
    child.insertAce(0, BasePermission.DELETE, new PrincipalSid(auth), false);
    mongodbMutableAclService.updateAcl(child);

    // Remove the child and check all related database rows were removed accordingly
    mongodbMutableAclService.deleteAcl(childOid, false);
    
    assertEquals(1, mongoTemplate.findAll(AclClass.class).size());
    assertEquals(0, mongoTemplate.findAll(AclObjectIdentity.class).size());
    assertEquals(0, mongoTemplate.findAll(AclEntry.class).size());

    // Check the cache
    assertNull(cache.getFromCache(childOid));
    assertNull(cache.getFromCache("102"));
}
 
开发者ID:AlexCzar,项目名称:spring-security-acl-mongodb,代码行数:19,代码来源:MongodbMutableAclServiceTest.java

示例3: cumulativePermissions

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

示例4: test2UpdateAcl

import org.springframework.security.acls.model.MutableAcl; //导入方法依赖的package包/类
@Test
@Rollback(false)
@Transactional(rollbackFor = Exception.class)
public void test2UpdateAcl() {
	Authentication auth = new TestingAuthenticationToken("shazin", "N/A");
	auth.setAuthenticated(true);
	SecurityContextHolder.getContext().setAuthentication(auth);
	ObjectIdentity oid = new ObjectIdentityImpl("my.test.Class", 1l);
	MutableAcl acl = (MutableAcl) mutableAclService.readAclById(oid);

	acl.insertAce(0, BasePermission.CREATE, new GrantedAuthoritySid(
			"ROLE_USER"), true);
	acl.insertAce(1, BasePermission.DELETE, new GrantedAuthoritySid(
			"ROLE_ADMIN"), true);

	mutableAclService.updateAcl(acl);
}
 
开发者ID:shazin,项目名称:spring-security-acl-neo4j,代码行数:18,代码来源:Neo4jMutableAclServiceTest.java

示例5: createUser

import org.springframework.security.acls.model.MutableAcl; //导入方法依赖的package包/类
protected User createUser(EntityManager entityManager, String name) {
    authenticate(name);
    User user = super.createUser(entityManager, name);
    entityManager.flush();
    ObjectIdentity id = new ObjectIdentityImpl(user);
    MutableAcl acl = aclService.createAcl(id);
    acl.insertAce(0, CREATE, acl.getOwner(), true);
    acl.insertAce(1, READ, acl.getOwner(), true);
    acl.insertAce(2, WRITE, acl.getOwner(), true);
    acl.insertAce(3, DELETE, acl.getOwner(), true);
    acl.insertAce(4, READ, new GrantedAuthoritySid("ROLE_ADMIN"), true);
    aclService.updateAcl(acl);
    return user;
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:15,代码来源:AclContactsTestData.java

示例6: createContact

import org.springframework.security.acls.model.MutableAcl; //导入方法依赖的package包/类
protected Contact createContact(EntityManager entityManager, User owner, String text) {
    authenticate(owner.getName());
    Contact contact = super.createContact(entityManager, owner, text);
    ObjectIdentity id = new ObjectIdentityImpl(contact);
    MutableAcl acl = aclService.createAcl(id);
    acl.insertAce(0, CREATE, acl.getOwner(), true);
    acl.insertAce(1, READ, acl.getOwner(), true);
    acl.insertAce(2, WRITE, acl.getOwner(), true);
    acl.insertAce(3, DELETE, acl.getOwner(), true);
    acl.insertAce(4, READ, new GrantedAuthoritySid("ROLE_ADMIN"), true);
    aclService.updateAcl(acl);
    return contact;
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:14,代码来源:AclContactsTestData.java

示例7: updateAcl_addEntries

import org.springframework.security.acls.model.MutableAcl; //导入方法依赖的package包/类
@Test
@ShouldMatchDataSet
public void updateAcl_addEntries() {
    MutableAcl acl = (MutableAcl) fixture.readAclById(new ObjectIdentityImpl("com.cedac.smartresidence.profile.domain.Device", "1.1.2"));
    acl.insertAce(0, BasePermission.READ, new GrantedAuthoritySid("ROLE_USER"), true);
    acl.insertAce(1, BasePermission.WRITE, new GrantedAuthoritySid("ROLE_USER"), true);

    fixture.updateAcl(acl);
}
 
开发者ID:cedac-software,项目名称:spring-security-mongodb,代码行数:10,代码来源:MongoMutableAclServiceTests.java

示例8: isPermissionGranted

import org.springframework.security.acls.model.MutableAcl; //导入方法依赖的package包/类
private void isPermissionGranted(Permission permission, Sid sid, MutableAcl acl) {
	try {
		acl.isGranted(Arrays.asList(permission), Arrays.asList(sid), false);
	} catch (NotFoundException e) {
		acl.insertAce(acl.getEntries().size(), permission, sid, true);
	}
}
 
开发者ID:thiagoandrade6,项目名称:security-acl,代码行数:8,代码来源:AclManagerImpl.java

示例9: postMessage

import org.springframework.security.acls.model.MutableAcl; //导入方法依赖的package包/类
@Transactional
@Secured("ROLE_USER")
public synchronized void postMessage(Message message) {
    message.setId(System.currentTimeMillis());
    messages.put(message.getId(), message);

    ObjectIdentity oid = new ObjectIdentityImpl(Message.class, message.getId());
    MutableAcl acl = mutableAclService.createAcl(oid);
    acl.insertAce(0, BasePermission.ADMINISTRATION, new PrincipalSid(message.getAuthor()), true);
    acl.insertAce(1, BasePermission.DELETE, new GrantedAuthoritySid("ROLE_ADMIN"), true);
    acl.insertAce(2, BasePermission.READ, new GrantedAuthoritySid("ROLE_USER"), true);
    mutableAclService.updateAcl(acl);
}
 
开发者ID:AncientMariner,项目名称:SpringByExample,代码行数:14,代码来源:MessageBoardServiceImpl.java

示例10: createReadWriteDeleteAcl

import org.springframework.security.acls.model.MutableAcl; //导入方法依赖的package包/类
private void createReadWriteDeleteAcl(String sid, Report report) {
	MutableAcl acl = aclService.createAcl(new ObjectIdentityImpl(report));
	acl.insertAce(0, BasePermission.READ, new PrincipalSid(sid), true);
	acl.insertAce(1, BasePermission.WRITE, new PrincipalSid(sid), true);
	acl.insertAce(2, BasePermission.DELETE, new PrincipalSid(sid), true);
	aclService.updateAcl(acl);
}
 
开发者ID:RigasGrigoropoulos,项目名称:spring-security-acl-cassandra,代码行数:8,代码来源:ReportServiceTest.java


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