本文整理汇总了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());
}
示例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());
}
示例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()));
}
示例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()));
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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
}
示例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
}