本文整理匯總了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;
}