本文整理汇总了Java中java.security.UnresolvedPermission类的典型用法代码示例。如果您正苦于以下问题:Java UnresolvedPermission类的具体用法?Java UnresolvedPermission怎么用?Java UnresolvedPermission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UnresolvedPermission类属于java.security包,在下文中一共展示了UnresolvedPermission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkUnresolvedPermission
import java.security.UnresolvedPermission; //导入依赖的package包/类
protected boolean checkUnresolvedPermission(UnresolvedPermission perm) {
/*
* From documentation:
* -------------------------------------------------------------------------------------------------------------------------- The
* java.security.UnresolvedPermission class is used to hold Permissions that were "unresolved" when the Policy was initialized. An unresolved
* permission is one whose actual Permission class does not yet exist at the time the Policy is initialized (see below). The policy for a Java
* runtime (specifying which permissions are available for code from various principals) is represented by a Policy object. Whenever a Policy
* is initialized or refreshed, Permission objects of appropriate classes are created for all permissions allowed by the Policy. Many
* permission class types referenced by the policy configuration are ones that exist locally (i.e., ones that can be found on CLASSPATH).
* Objects for such permissions can be instantiated during Policy initialization. For example, it is always possible to instantiate a
* java.io.FilePermission, since the FilePermission class is found on the CLASSPATH. Other permission classes may not yet exist during Policy
* initialization. For example, a referenced permission class may be in a JAR file that will later be loaded. For each such class, an
* UnresolvedPermission is instantiated. Thus, an UnresolvedPermission is essentially a "placeholder" containing information about the
* permission. Later, when code calls AccessController.checkPermission on a permission of a type that was previously unresolved, but whose
* class has since been loaded, previously-unresolved permissions of that type are "resolved". That is, for each such UnresolvedPermission, a
* new object of the appropriate class type is instantiated, based on the information in the UnresolvedPermission. This new object replaces
* the UnresolvedPermission, which is removed.
* -------------------------------------------------------------------------------------------------------------------------- In theory it
* shouldn't really happen, unless some customized permission classes are used in the SUT. It also poses a problem: we might run a test case
* that throws this security exception but, if we run it again, it might not throw it anymore. Just to be sure, for now we deny this
* permission
*/
return false;
}
示例2: testSerialization
import java.security.UnresolvedPermission; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "!SerializationSelf",
args = {}
)
public void testSerialization() throws Exception {
UnresolvedPermission up = new UnresolvedPermission(
"java.security.SecurityPermission", "a.b.c", "actions", null);
assertEquals("java.security.SecurityPermission", up.getUnresolvedType());
assertEquals("a.b.c", up.getUnresolvedName());
assertEquals("actions", up.getUnresolvedActions());
assertNull(up.getUnresolvedCerts());
UnresolvedPermission deserializedUp = (UnresolvedPermission) SerializationTester
.getDeserilizedObject(up);
assertEquals("java.security.SecurityPermission", deserializedUp
.getUnresolvedType());
assertEquals("a.b.c", deserializedUp.getUnresolvedName());
assertEquals("actions", deserializedUp.getUnresolvedActions());
assertNull(deserializedUp.getUnresolvedCerts());
}
示例3: testSerialization_Compatibility
import java.security.UnresolvedPermission; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "!SerializationGolden",
args = {}
)
public void testSerialization_Compatibility() throws Exception {
UnresolvedPermission up = new UnresolvedPermission(
"java.security.SecurityPermission", "a.b.c", "actions", null);
assertEquals("java.security.SecurityPermission", up.getUnresolvedType());
assertEquals("a.b.c", up.getUnresolvedName());
assertEquals("actions", up.getUnresolvedActions());
assertNull(up.getUnresolvedCerts());
SerializationTest.verifyGolden(this, up, new SerializableAssert() {
public void assertDeserialized(Serializable orig, Serializable ser) {
UnresolvedPermission deserializedUp = (UnresolvedPermission) ser;
assertEquals("java.security.SecurityPermission", deserializedUp
.getUnresolvedType());
assertEquals("a.b.c", deserializedUp.getUnresolvedName());
assertEquals("actions", deserializedUp.getUnresolvedActions());
assertNull(deserializedUp.getUnresolvedCerts());
}
});
}
示例4: testGetActions
import java.security.UnresolvedPermission; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getActions",
args = {}
)
public void testGetActions() {
UnresolvedPermission up1 = new UnresolvedPermission("type1", "name1",
"action1", null);
UnresolvedPermission up2 = null;
assertEquals("", up1.getActions());
try {
up2.getActions();
fail("NullPointerException expected");
} catch (NullPointerException e) {
// expected
}
}
示例5: testGetUnresolvedActions
import java.security.UnresolvedPermission; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getUnresolvedActions",
args = {}
)
public void testGetUnresolvedActions() {
UnresolvedPermission up1 = new UnresolvedPermission("type1", "name1",
"action1 @#$%^&*", null);
UnresolvedPermission up2 = null;
assertEquals("action1 @#$%^&*", up1.getUnresolvedActions());
try {
up2.getUnresolvedActions();
fail("NullPointerException expected");
} catch (NullPointerException e) {
// expected
}
}
示例6: testGetUnresolvedName
import java.security.UnresolvedPermission; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getUnresolvedName",
args = {}
)
public void testGetUnresolvedName() {
UnresolvedPermission up1 = new UnresolvedPermission("type1", "[email protected]#$%^&&* )(",
"action1 @#$%^&*", null);
UnresolvedPermission up2 = null;
assertEquals("[email protected]#$%^&&* )(", up1.getUnresolvedName());
try {
up2.getUnresolvedName();
fail("NullPointerException expected");
} catch (NullPointerException e) {
// expected
}
}
示例7: testGetUnresolvedType
import java.security.UnresolvedPermission; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "getUnresolvedType",
args = {}
)
public void testGetUnresolvedType() {
UnresolvedPermission up1 = new UnresolvedPermission("[email protected]#$%^&* )(", "name1",
"action1", null);
UnresolvedPermission up2 = null;
assertEquals("[email protected]#$%^&* )(", up1.getUnresolvedType());
try {
up2.getUnresolvedType();
fail("NullPointerException expected");
} catch (NullPointerException e) {
// expected
}
}
示例8: testToString
import java.security.UnresolvedPermission; //导入依赖的package包/类
@TestTargetNew(
level = TestLevel.COMPLETE,
notes = "",
method = "toString",
args = {}
)
public void testToString() {
UnresolvedPermission up1 = new UnresolvedPermission("type1", "name1",
"action1", null);
UnresolvedPermission up2 = new UnresolvedPermission("type1", "name1",
"action1", null);
UnresolvedPermission up3 = null;
assertTrue(up1.toString().contains(""));
assertTrue(up2.toString().contains(""));
try {
up3.toString();
fail("NullPointerException expected");
}catch (NullPointerException e) {
// expected
}
}
示例9: createPermission
import java.security.UnresolvedPermission; //导入依赖的package包/类
private java.security.Permission createPermission(
final Permissions.Permission permission) {
try {
// First add explicitly already resolved permissions will not be
// resolved when added as unresolved permission.
final Class<? extends java.security.Permission> clazz = Class.forName(
permission.getClassName()).asSubclass(java.security.Permission.class);
final String name = permission.getName();
final String actions = permission.getActions();
final Constructor<? extends java.security.Permission> ctr = clazz.getConstructor(PARAMS);
return ctr.newInstance(new Object[] {name, actions});
} catch (final Exception e) {
// Let the UnresolvedPermission handle it.
return new UnresolvedPermission(permission.getClassName(),
permission.getName(), permission.getActions(), null);
}
}
示例10: getData
import java.security.UnresolvedPermission; //导入依赖的package包/类
/**
* Return array holding 3 collections: empty, single- and multi-element.
*/
protected Object[] getData() {
Permission up1 = new UnresolvedPermission("131234", null, null, null);
Permission up2 = new UnresolvedPermission("131234", "ui23rjh", null,
null);
Permission up3 = new UnresolvedPermission("KUJKHVKJgyuygjhb", "xcv456",
"26r ytf", new java.security.cert.Certificate[0]);
PermissionCollection pc1 = up1.newPermissionCollection();
PermissionCollection pc2 = up1.newPermissionCollection();
pc2.add(up3);
PermissionCollection pc3 = up1.newPermissionCollection();
pc3.add(up1);
pc3.add(up2);
pc3.add(up3);
return new Object[] { pc1, pc2, pc3 };
}
示例11: testSerialization
import java.security.UnresolvedPermission; //导入依赖的package包/类
public void testSerialization() throws Exception {
UnresolvedPermission up = new UnresolvedPermission(
"java.security.SecurityPermission", "a.b.c", "actions", null);
assertEquals("java.security.SecurityPermission", up.getUnresolvedType());
assertEquals("a.b.c", up.getUnresolvedName());
assertEquals("actions", up.getUnresolvedActions());
assertNull(up.getUnresolvedCerts());
UnresolvedPermission deserializedUp = (UnresolvedPermission) SerializationTester
.getDeserilizedObject(up);
assertEquals("java.security.SecurityPermission", deserializedUp
.getUnresolvedType());
assertEquals("a.b.c", deserializedUp.getUnresolvedName());
assertEquals("actions", deserializedUp.getUnresolvedActions());
assertNull(deserializedUp.getUnresolvedCerts());
}
示例12: testSerialization_Compatibility
import java.security.UnresolvedPermission; //导入依赖的package包/类
public void testSerialization_Compatibility() throws Exception {
UnresolvedPermission up = new UnresolvedPermission(
"java.security.SecurityPermission", "a.b.c", "actions", null);
assertEquals("java.security.SecurityPermission", up.getUnresolvedType());
assertEquals("a.b.c", up.getUnresolvedName());
assertEquals("actions", up.getUnresolvedActions());
assertNull(up.getUnresolvedCerts());
SerializationTest.verifyGolden(this, up, new SerializableAssert() {
public void assertDeserialized(Serializable orig, Serializable ser) {
UnresolvedPermission deserializedUp = (UnresolvedPermission) ser;
assertEquals("java.security.SecurityPermission", deserializedUp
.getUnresolvedType());
assertEquals("a.b.c", deserializedUp.getUnresolvedName());
assertEquals("actions", deserializedUp.getUnresolvedActions());
assertNull(deserializedUp.getUnresolvedCerts());
}
});
}
示例13: equalsUnresolvedPermission
import java.security.UnresolvedPermission; //导入依赖的package包/类
private boolean equalsUnresolvedPermission(UnresolvedPermission up1,
UnresolvedPermission up2) {
java.security.cert.Certificate[] certs = up1.getUnresolvedCerts();
if (certs != null && certs.length == 0) {
if (null == up2.getUnresolvedCerts()) {
if (up1.getName().equals(up2.getName())) {
String up1Name = up1.getUnresolvedName();
String up2Name = up2.getUnresolvedName();
if (up1Name == null ? up2Name == null : up1Name
.equals(up2Name)) {
String up1Actions = up1.getUnresolvedActions();
String up2Actions = up2.getUnresolvedActions();
return up1Actions == null ? up2Actions == null
: up1Actions.equals(up2Actions);
}
}
}
return false;
}
return up1.equals(up2);
}
示例14: assertDeserialized
import java.security.UnresolvedPermission; //导入依赖的package包/类
public void assertDeserialized(Serializable initial,
Serializable deserialized) {
UnresolvedPermission initPerm = (UnresolvedPermission) initial;
UnresolvedPermission dserPerm = (UnresolvedPermission) deserialized;
java.security.cert.Certificate[] certs = initPerm
.getUnresolvedCerts();
if (certs != null && certs.length == 0) {
Assert.assertEquals(initPerm.getUnresolvedType(), dserPerm
.getUnresolvedType());
Assert.assertEquals(initPerm.getUnresolvedName(), dserPerm
.getUnresolvedName());
Assert.assertEquals(initPerm.getUnresolvedActions(), dserPerm
.getUnresolvedActions());
Assert.assertNull(dserPerm.getUnresolvedCerts());
} else {
Assert.assertEquals(initPerm, dserPerm);
}
}
示例15: testInstantiatePermission
import java.security.UnresolvedPermission; //导入依赖的package包/类
public void testInstantiatePermission()
throws Throwable
{
String name = "abc";
Permission expected = new SecurityPermission( name );
//test valid input
assertEquals( expected, PolicyUtils.instantiatePermission( SecurityPermission.class, name, null ) );
assertEquals( expected, PolicyUtils.instantiatePermission( SecurityPermission.class, name, "4t46" ) );
//test invalid class
try
{
PolicyUtils.instantiatePermission( UnresolvedPermission.class, null, null );
fail( "IllegalArgumentException expected on invalid class argument" );
}
catch( IllegalArgumentException ok )
{
}
}