本文整理汇总了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;
}
示例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"));
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}