本文整理汇总了Java中java.security.GuardedObject类的典型用法代码示例。如果您正苦于以下问题:Java GuardedObject类的具体用法?Java GuardedObject怎么用?Java GuardedObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GuardedObject类属于java.security包,在下文中一共展示了GuardedObject类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testGuard
点赞 2
import java.security.GuardedObject; //导入依赖的package包/类
/** Test real guard can both allow and deny access. */
@TestTargets({
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "",
method = "GuardedObject",
args = {java.lang.Object.class, java.security.Guard.class}
),
@TestTargetNew(
level = TestLevel.PARTIAL_COMPLETE,
notes = "",
method = "getObject",
args = {}
)
})
public void testGuard() {
final String message = "test message";
final StringBuffer objBuffer = new StringBuffer("235345 t");
GuardedObject go = new GuardedObject(objBuffer, new Guard() {
public void checkGuard(Object object) throws SecurityException {
if (object == objBuffer && objBuffer.length() == 0) {
throw new SecurityException(message);
}
}
});
assertEquals(objBuffer, go.getObject());
objBuffer.setLength(0);
try {
go.getObject();
fail("SecurityException is not thrown");
} catch (Exception ok) {
assertEquals(message, ok.getMessage());
}
}
开发者ID:keplersj,
项目名称:In-the-Box-Fork,
代码行数:37,
代码来源:GuardedObjectTest.java
示例2: testDisableGuard
点赞 2
import java.security.GuardedObject; //导入依赖的package包/类
public void testDisableGuard() throws Throwable {
try {
copySerializable(new GuardedObject(null, new MyGuard(false)));
fail("Should not serialize if guard denies access");
}
catch (SecurityException ok) {}
}
开发者ID:shannah,
项目名称:cn1,
代码行数:8,
代码来源:GuardedObjectTest.java
示例3: getAttribute
点赞 2
import java.security.GuardedObject; //导入依赖的package包/类
/**
Retrieve an attribute, checking security permissions if it happens
to be a guarded object.
@param name
@return
*/
public Object getAttribute(String name) {
Object attr=attributes.get(name);
if (attr instanceof GuardedObject) {
return ((GuardedObject) attr).getObject();
}
return attr;
}
开发者ID:apache,
项目名称:river-container,
代码行数:14,
代码来源:AttributeStoreImpl.java
示例4: getData
点赞 2
import java.security.GuardedObject; //导入依赖的package包/类
/**
* @see com.intel.drl.test.SerializationTest#getData()
*/
protected Object[] getData() {
return new Object[] { new GuardedObject(null, null),
new GuardedObject("dsgdfg", null),
new GuardedObject(new Integer(76547), new MyGuard(true)), };
}
开发者ID:shannah,
项目名称:cn1,
代码行数:9,
代码来源:GuardedObjectTest.java
示例5: assertDeserialized
点赞 2
import java.security.GuardedObject; //导入依赖的package包/类
public void assertDeserialized(Serializable golden, Serializable test) {
assertSame(golden.getClass(), test.getClass());
assertEquals(((GuardedObject) golden).getObject(),
((GuardedObject) test).getObject());
}
开发者ID:shannah,
项目名称:cn1,
代码行数:6,
代码来源:GuardedObjectTest.java