1 |
758 |
jeremybenn |
/* VMAccessControlState.java -- per-thread state for the access controller.
|
2 |
|
|
Copyright (C) 2006 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
This program is free software; you can redistribute it and/or modify
|
5 |
|
|
it under the terms of the GNU General Public License as published by
|
6 |
|
|
the Free Software Foundation; either version 2, or (at your option)
|
7 |
|
|
any later version.
|
8 |
|
|
|
9 |
|
|
This program is distributed in the hope that it will be useful, but
|
10 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12 |
|
|
General Public License for more details.
|
13 |
|
|
|
14 |
|
|
You should have received a copy of the GNU General Public License
|
15 |
|
|
along with this program; see the file COPYING. If not, write to the
|
16 |
|
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
17 |
|
|
02110-1301 USA.
|
18 |
|
|
|
19 |
|
|
Linking this library statically or dynamically with other modules is
|
20 |
|
|
making a combined work based on this library. Thus, the terms and
|
21 |
|
|
conditions of the GNU General Public License cover the whole
|
22 |
|
|
combination.
|
23 |
|
|
|
24 |
|
|
As a special exception, the copyright holders of this library give you
|
25 |
|
|
permission to link this library with independent modules to produce an
|
26 |
|
|
executable, regardless of the license terms of these independent
|
27 |
|
|
modules, and to copy and distribute the resulting executable under
|
28 |
|
|
terms of your choice, provided that you also meet, for each linked
|
29 |
|
|
independent module, the terms and conditions of the license of that
|
30 |
|
|
module. An independent module is a module which is not derived from
|
31 |
|
|
or based on this library. If you modify this library, you may extend
|
32 |
|
|
this exception to your version of the library, but you are not
|
33 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
34 |
|
|
exception statement from your version. */
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
package java.security;
|
38 |
|
|
|
39 |
|
|
import java.util.LinkedList;
|
40 |
|
|
|
41 |
|
|
class VMAccessControlState
|
42 |
|
|
{
|
43 |
|
|
/**
|
44 |
|
|
* A list of {@link AccessControlContext} objects (which can be
|
45 |
|
|
* null) for each call to {@link AccessController#doPrivileged()} in
|
46 |
|
|
* the thread's call stack.
|
47 |
|
|
*/
|
48 |
|
|
private LinkedList contexts = new LinkedList();
|
49 |
|
|
|
50 |
|
|
/**
|
51 |
|
|
* A flag indicating that we are within a call to {@link
|
52 |
|
|
* VMAccessController#getContext()}.
|
53 |
|
|
*/
|
54 |
|
|
private boolean inGetContext = false;
|
55 |
|
|
|
56 |
|
|
/**
|
57 |
|
|
* Not directly instantiable: use getThreadState() instead.
|
58 |
|
|
*/
|
59 |
|
|
private VMAccessControlState() {}
|
60 |
|
|
|
61 |
|
|
/**
|
62 |
|
|
* Return an object representing the access control state of this
|
63 |
|
|
* thread.
|
64 |
|
|
*
|
65 |
|
|
* @return The access control state of this thread, or
|
66 |
|
|
* <code>null</code> if the VM is not initialized to the point of
|
67 |
|
|
* being able to return this.
|
68 |
|
|
*/
|
69 |
|
|
static native VMAccessControlState getThreadState();
|
70 |
|
|
|
71 |
|
|
/**
|
72 |
|
|
* Indicate whether this thread is within a call to {@link
|
73 |
|
|
* VMAccessController#getContext()}.
|
74 |
|
|
*
|
75 |
|
|
* @return <code>true</code> if this thread is within a call to
|
76 |
|
|
* {@link VMAccessController#getContext()}.
|
77 |
|
|
*/
|
78 |
|
|
boolean isInGetContext()
|
79 |
|
|
{
|
80 |
|
|
return inGetContext;
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
/**
|
84 |
|
|
* Specify whether this thread is within a call to {@link
|
85 |
|
|
* VMAccessController#getContext()}.
|
86 |
|
|
*/
|
87 |
|
|
void setInGetContext(boolean inGetContext)
|
88 |
|
|
{
|
89 |
|
|
this.inGetContext = inGetContext;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
/**
|
93 |
|
|
* Return a list of {@link AccessControlContext} objects (which can
|
94 |
|
|
* be null) for each call to {@link AccessController#doPrivileged()}
|
95 |
|
|
* in the thread's call stack.
|
96 |
|
|
*
|
97 |
|
|
* @return a list of {@link AccessControlContext} objects.
|
98 |
|
|
*/
|
99 |
|
|
LinkedList getContexts()
|
100 |
|
|
{
|
101 |
|
|
return contexts;
|
102 |
|
|
}
|
103 |
|
|
}
|