當前位置: 首頁>>代碼示例>>Java>>正文


Java CumulativePermission類代碼示例

本文整理匯總了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;
    }
 
開發者ID:codeabovelab,項目名稱:haven-platform,代碼行數:19,代碼來源:PropertyAclServiceConfigurer.java

示例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();
}
 
開發者ID:AlexCzar,項目名稱:spring-security-acl-mongodb,代碼行數:26,代碼來源:MongodbMutableAclServiceTest.java

示例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;
}
 
開發者ID:nextreports,項目名稱:nextreports-server,代碼行數:22,代碼來源:NextServerPermission.java


注:本文中的org.springframework.security.acls.domain.CumulativePermission類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。