本文整理汇总了Java中org.springframework.security.acls.domain.CumulativePermission类的典型用法代码示例。如果您正苦于以下问题:Java CumulativePermission类的具体用法?Java CumulativePermission怎么用?Java CumulativePermission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CumulativePermission类属于org.springframework.security.acls.domain包,在下文中一共展示了CumulativePermission类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parsePerms
import org.springframework.security.acls.domain.CumulativePermission; //导入依赖的package包/类
private static Permission parsePerms(String perms) {
final int length = perms.length();
if(length > 32) {
throw new IllegalArgumentException("Too long permission expression: " + perms + " it must be shortest than 32 chars.");
}
Permission perm;
if(length == 1) {
perm = parseLetter(perms.charAt(0));
} else {
CumulativePermission cp = new CumulativePermission();
for(int i = 0; i < length; ++i) {
cp.set(parseLetter(perms.charAt(i)));
}
perm = cp;
}
return perm;
}
示例2: cumulativePermissions
import org.springframework.security.acls.domain.CumulativePermission; //导入依赖的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();
}
示例3: buildFromMask
import org.springframework.security.acls.domain.CumulativePermission; //导入依赖的package包/类
public static Permission buildFromMask(int mask) {
if (permissionsByInteger.containsKey(mask)) {
return permissionsByInteger.get(mask);
}
// to get this far, we have to use a CumulativePermission
CumulativePermission cumulativePermission = new CumulativePermission();
for (int i = 0; i < 32; i++) {
int permissionToCheck = 1 << i;
if ((mask & permissionToCheck) == permissionToCheck) {
Permission permission = permissionsByInteger.get(permissionToCheck);
if (permission == null) {
System.out.println("Mask " + permissionToCheck + " does not have a corresponding static NextServerPermission");
continue;
}
cumulativePermission.set(permission);
}
}
return cumulativePermission;
}