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


Java PermissionCollection.elements方法代碼示例

本文整理匯總了Java中java.security.PermissionCollection.elements方法的典型用法代碼示例。如果您正苦於以下問題:Java PermissionCollection.elements方法的具體用法?Java PermissionCollection.elements怎麽用?Java PermissionCollection.elements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.security.PermissionCollection的用法示例。


在下文中一共展示了PermissionCollection.elements方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addAllPermissions

import java.security.PermissionCollection; //導入方法依賴的package包/類
/**
 * Copies all permissions from <tt>src</tt> into <tt>target</tt>
 *
 * @param target To where put permissions
 * @param src From where take paermissions
 */
private static void addAllPermissions(PermissionCollection target, PermissionCollection src) {
    Enumeration e = src.elements();
    
    while (e.hasMoreElements()) {
        target.add((Permission) e.nextElement());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:NbClassLoader.java

示例2: addAll

import java.security.PermissionCollection; //導入方法依賴的package包/類
public PermissionsBuilder addAll(PermissionCollection col) {
    if (col != null) {
        for (Enumeration<Permission> e = col.elements(); e.hasMoreElements(); ) {
            perms.add(e.nextElement());
        }
    }
    return this;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:HandlersOnComplexResetUpdate.java

示例3: main

import java.security.PermissionCollection; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {

        int testFail = 0;

        DelegationPermission perm = new DelegationPermission(FOO + " " + TGT);
        PermissionCollection perms = perm.newPermissionCollection();

        // test 1
        System.out.println
            ("test 1: add throws IllegalArgException for wrong perm type");
        try {
            perms.add(new SecurityPermission("createAccessControlContext"));
            System.err.println("Expected IllegalArgumentException");
            testFail++;
        } catch (IllegalArgumentException iae) {}

        // test 2
        System.out.println("test 2: implies returns false for wrong perm type");
        if (perms.implies(new SecurityPermission("getPolicy"))) {
            System.err.println("Expected false, returned true");
            testFail++;
        }

        // test 3
        System.out.println("test 3: implies returns true for match on name");
        perms.add(new DelegationPermission(FOO + " " + TGT));
        if (!perms.implies(new DelegationPermission(FOO + " " + TGT))) {
            System.err.println("Expected true, returned false");
            testFail++;
        }

        // test 4
        System.out.println
            ("test 4: implies returns false for non-match on name");
        if (perms.implies(new DelegationPermission(BAR + " " + TGT))) {
            System.err.println("Expected false, returned true");
            testFail++;
        }

        // test 5
        System.out.println("test 5: elements returns correct number of perms");
        int numPerms = 0;
        Enumeration<Permission> e = perms.elements();
        while (e.hasMoreElements()) {
            numPerms++;
            System.out.println(e.nextElement());
        }
        if (numPerms != 1) {
            System.err.println("Expected 1, got " + numPerms);
            testFail++;
        }

        if (testFail > 0) {
            throw new Exception(testFail + " test(s) failed");
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:57,代碼來源:DelegationPermissionCollection.java


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