Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
102 lines (91 loc) · 2.27 KB

File metadata and controls

102 lines (91 loc) · 2.27 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package java.security;
/**
* A GuardedObject is an object that is used to protect access to
* another object.
*
* <p>A GuardedObject encapsulates a target object and a Guard object,
* such that access to the target object is possible
* only if the Guard object allows it.
* Once an object is encapsulated by a GuardedObject,
* access to that object is controlled by the {@code getObject}
* method, which invokes the
* {@code checkGuard} method on the Guard object that is
* guarding access. If access is not allowed,
* an exception is thrown.
*
* @see Guard
* @see Permission
*
* @author Roland Schemers
* @author Li Gong
*/
public class GuardedObject implements java.io.Serializable {
private static final long serialVersionUID = -5240450096227834308L;
private Object object; // the object we are guarding
private Guard guard; // the guard
/**
* Constructs a GuardedObject using the specified object and guard.
* If the Guard object is null, then no restrictions will
* be placed on who can access the object.
*
* @param object the object to be guarded.
*
* @param guard the Guard object that guards access to the object.
*/
public GuardedObject(Object object, Guard guard)
{
this.guard = guard;
this.object = object;
}
/**
* Retrieves the guarded object, or throws an exception if access
* to the guarded object is denied by the guard.
*
* @return the guarded object.
*
* @exception SecurityException if access to the guarded object is
* denied.
*/
public Object getObject()
throws SecurityException
{
if (guard != null)
guard.checkGuard(object);
return object;
}
/**
* Writes this object out to a stream (i.e., serializes it).
* We check the guard if there is one.
*/
private void writeObject(java.io.ObjectOutputStream oos)
throws java.io.IOException
{
if (guard != null)
guard.checkGuard(object);
oos.defaultWriteObject();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.