当前位置: 首页>>代码示例>>Java>>正文


Java SecurityPermission.newPermissionCollection方法代码示例

本文整理汇总了Java中java.security.SecurityPermission.newPermissionCollection方法的典型用法代码示例。如果您正苦于以下问题:Java SecurityPermission.newPermissionCollection方法的具体用法?Java SecurityPermission.newPermissionCollection怎么用?Java SecurityPermission.newPermissionCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.SecurityPermission的用法示例。


在下文中一共展示了SecurityPermission.newPermissionCollection方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_isReadOnly

import java.security.SecurityPermission; //导入方法依赖的package包/类
/**
 * @tests java.security.PermissionCollection#isReadOnly()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "isReadOnly",
    args = {}
)
public void test_isReadOnly() {
    // test java.security.permissionCollection.isReadOnly()
    SecurityPermission permi = new SecurityPermission(
            "testing permissionCollection-isREadOnly");
    PermissionCollection permCollect = permi.newPermissionCollection();
    assertTrue("readOnly has not been set, but isReadOnly returned true",
            !permCollect.isReadOnly());
    permCollect.setReadOnly();
    assertTrue("readOnly is set, but isReadonly returned false",
            permCollect.isReadOnly());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:PermissionCollectionTest.java

示例2: test_setReadOnly

import java.security.SecurityPermission; //导入方法依赖的package包/类
/**
 * @tests java.security.PermissionCollection#setReadOnly()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "setReadOnly",
    args = {}
)
public void test_setReadOnly() {
    // test java.security.permissionCollection.setReadOnly()
    SecurityPermission permi = new SecurityPermission(
            "testing permissionCollection-setReadOnly");
    PermissionCollection permCollect = permi.newPermissionCollection();
    assertTrue("readOnly has not been set, but isReadOnly returned true",
            !permCollect.isReadOnly());
    permCollect.setReadOnly();
    assertTrue("readOnly is set, but isReadonly returned false",
            permCollect.isReadOnly());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:PermissionCollectionTest.java

示例3: testImplies

import java.security.SecurityPermission; //导入方法依赖的package包/类
/** 
 * Tests that implies() does proper permission evaluation.
 */
public void testImplies() {
    TestProvider policy = new TestProvider();
    SecurityPermission sp = new SecurityPermission("abc");
    policy.pc = sp.newPermissionCollection();
    
    policy.pc.add(sp);
    assertTrue(policy.implies(new ProtectionDomain(null, null), sp));
    assertFalse(policy.implies(null, sp));
    assertFalse(policy.implies(new ProtectionDomain(null, null), null));
    
    //RI throws NullPointerException.
    try {
        policy.implies(null, null);
        fail("should throw NullPointerException");
    } catch (NullPointerException e) {
        // expected.
    }
    
    
    ProtectionDomain pd = new ProtectionDomain(null, policy.pc);
    policy.pc = null;
    assertTrue(policy.implies(pd, sp));        
    assertFalse(policy.implies(pd, new AllPermission()));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:28,代码来源:Policy_ImplTest.java

示例4: testImplies

import java.security.SecurityPermission; //导入方法依赖的package包/类
/** 
 * Tests that implies() does proper permission evaluation.
 */
public void testImplies() {
    TestProvider policy = new TestProvider();
    SecurityPermission sp = new SecurityPermission("abc");
    policy.pc = sp.newPermissionCollection();
    
    policy.pc.add(sp);
    assertTrue(policy.implies(new ProtectionDomain(null, null), sp));
    assertFalse(policy.implies(null, sp));
    assertFalse(policy.implies(new ProtectionDomain(null, null), null));
    assertFalse(policy.implies(null, null));
    
    ProtectionDomain pd = new ProtectionDomain(null, policy.pc);
    policy.pc = null;
    assertTrue(policy.implies(pd, sp));        
    assertFalse(policy.implies(pd, new AllPermission()));
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:20,代码来源:Policy_ImplTest.java

示例5: test_Constructor

import java.security.SecurityPermission; //导入方法依赖的package包/类
/**
 * @tests java.security.PermissionCollection#PermissionCollection()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "PermissionCollection",
    args = {}
)
public void test_Constructor() {
    // test java.security.permissionCollection.PermissionCollection()
    SecurityPermission permi = new SecurityPermission(
            "testing permissionCollection-isReadOnly");
    PermissionCollection permCollect = permi.newPermissionCollection();
    assertNotNull("creat permissionCollection constructor returned a null",
            permCollect);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:18,代码来源:PermissionCollectionTest.java

示例6: test_Constructor

import java.security.SecurityPermission; //导入方法依赖的package包/类
/**
 * @tests java.security.PermissionCollection#PermissionCollection()
 */
public void test_Constructor() {
    // test java.security.permissionCollection.PermissionCollection()
    SecurityPermission permi = new SecurityPermission(
            "testing permissionCollection-isReadOnly");
    PermissionCollection permCollect = permi.newPermissionCollection();
    assertNotNull("creat permissionCollection constructor returned a null",
            permCollect);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:PermissionCollectionTest.java

示例7: test_isReadOnly

import java.security.SecurityPermission; //导入方法依赖的package包/类
/**
 * @tests java.security.PermissionCollection#isReadOnly()
 */
public void test_isReadOnly() {
    // test java.security.permissionCollection.isReadOnly()
    SecurityPermission permi = new SecurityPermission(
            "testing permissionCollection-isREadOnly");
    PermissionCollection permCollect = permi.newPermissionCollection();
    assertTrue("readOnly has not been set, but isReadOnly returned true",
            !permCollect.isReadOnly());
    permCollect.setReadOnly();
    assertTrue("readOnly is set, but isReadonly returned false",
            permCollect.isReadOnly());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:PermissionCollectionTest.java

示例8: test_setReadOnly

import java.security.SecurityPermission; //导入方法依赖的package包/类
/**
 * @tests java.security.PermissionCollection#setReadOnly()
 */
public void test_setReadOnly() {
    // test java.security.permissionCollection.setReadOnly()
    SecurityPermission permi = new SecurityPermission(
            "testing permissionCollection-setReadOnly");
    PermissionCollection permCollect = permi.newPermissionCollection();
    assertTrue("readOnly has not been set, but isReadOnly returned true",
            !permCollect.isReadOnly());
    permCollect.setReadOnly();
    assertTrue("readOnly is set, but isReadonly returned false",
            permCollect.isReadOnly());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:PermissionCollectionTest.java

示例9: testGetPermissions

import java.security.SecurityPermission; //导入方法依赖的package包/类
/**
 * Tests that getPermissions() does proper permission evaluation.
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getPermissions",
    args = {java.security.ProtectionDomain.class}
)
public void testGetPermissions() {
    SecurityPermission sp = new SecurityPermission("abc");
    SecurityPermission sp2 = new SecurityPermission("fbdf");
    PermissionCollection spc = sp.newPermissionCollection();
    spc.add(sp2);
    ProtectionDomain pd = new ProtectionDomain(null, null);
    ProtectionDomain pd2 = new ProtectionDomain(null, spc);
    TestProvider policy = new TestProvider();
    policy.pc = sp.newPermissionCollection();

    // case1: empty policy, no static permissions in PD
    PermissionCollection pc4pd = policy.getPermissions(pd);
    assertNotNull(pc4pd);
    Enumeration<Permission> en = pc4pd.elements();
    assertFalse(en.hasMoreElements());

    // case2: empty policy, some static permissions in PD
    pc4pd = policy.getPermissions(pd2);
    assertNotNull(pc4pd);
    // no check for static permissions

    // case3: non-empty policy, no static permissions in PD
    policy.pc.add(sp);
    pc4pd = policy.getPermissions(pd);
    assertNotNull(pc4pd);
    Collection<Permission> c = new HashSet<Permission>();
    for (en = pc4pd.elements(); en.hasMoreElements(); c.add(en
            .nextElement())) {
    }

    assertTrue(c.contains(sp));

    // case4: non-empty policy, some static permissions in PD
    pc4pd = policy.getPermissions(pd2);
    assertNotNull(pc4pd);
    c = new HashSet<Permission>();
    for (en = pc4pd.elements(); en.hasMoreElements(); c.add(en
            .nextElement())) {
    }

    assertTrue(c.contains(sp));
    // no check for static permissions
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:53,代码来源:PolicyTest.java

示例10: testGetPermissions

import java.security.SecurityPermission; //导入方法依赖的package包/类
/** 
 * Tests that getPermissions() does proper permission evaluation.
 */
public void testGetPermissions() {
    SecurityPermission sp = new SecurityPermission("abc");
    SecurityPermission sp2 = new SecurityPermission("fbdf");
    PermissionCollection spc = sp.newPermissionCollection();
    spc.add(sp2);
    ProtectionDomain pd = new ProtectionDomain(null, null);
    ProtectionDomain pd2 = new ProtectionDomain(null, spc);
    TestProvider policy = new TestProvider();
    policy.pc = sp.newPermissionCollection();
             
    //case1: empty policy, no static permissions in PD
    PermissionCollection pc4pd = policy.getPermissions(pd);
    assertNotNull(pc4pd);
    Enumeration en = pc4pd.elements();
    assertFalse(en.hasMoreElements());
    
    //case2: empty policy, some static permissions in PD
    pc4pd = policy.getPermissions(pd2);
    assertNotNull(pc4pd);
    //no check for static permissions
    
    //case3: non-empty policy, no static permissions in PD
    policy.pc.add(sp);
    pc4pd = policy.getPermissions(pd);
    assertNotNull(pc4pd);
    Collection c = new HashSet();
    for (en = pc4pd.elements();en.hasMoreElements(); c.add(en.nextElement())) {
    }

    assertTrue(c.contains(sp));
    
    //case4: non-empty policy, some static permissions in PD
    pc4pd = policy.getPermissions(pd2);
    assertNotNull(pc4pd);
    c = new HashSet();
    for (en = pc4pd.elements();en.hasMoreElements(); c.add(en.nextElement())) {
    }

    assertTrue(c.contains(sp));
    //no check for static permissions
}
 
开发者ID:shannah,项目名称:cn1,代码行数:45,代码来源:PolicyTest.java


注:本文中的java.security.SecurityPermission.newPermissionCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。