aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang/SecurityManager.java
blob: 9c14552b9c9e7c405fdd1236800ee265168c40cc (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/* Copyright (C) 1998, 1999  Free Software Foundation

   This file is part of libgcj.

This software is copyrighted work licensed under the terms of the
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
details.  */

// SecurityManager

package java.lang;

/**
 * @author Anthony Green <green@cygnus.com>
 * @date October 5, 1998.  
 */

/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
 */

import java.io.*;
import java.net.*;

public abstract class SecurityManager
{
  protected boolean inCheck = false;

  public void checkAccept (String host, int port)
    {
      throw new SecurityException();
    }

  public void checkAccess (Thread thrd)
    {
      throw new SecurityException();
    }

  public void checkAccess (ThreadGroup thrdGroup)
    {
      throw new SecurityException();
    }

  public void checkAwtEventQueueAccess ()
    {
      throw new SecurityException();
    }

  public void checkConnect (String host, int prt)
    {
      throw new SecurityException();
    }

  public void checkConnect (String host, int prt, Object ctx)
    {
      throw new SecurityException();
    }

  public void checkCreateClassLoader ()
    {
      throw new SecurityException();
    }

  public void checkDelete (String fileName)
    {
      throw new SecurityException();
    }

  public void checkExec (String prog)
    {
      throw new SecurityException();
    }

  public void checkExit (int stat)
    {
      throw new SecurityException();
    }

  public void checkLink (String lib)
    {
      throw new SecurityException();
    }

  public void checkListen (int lport)
    {
      throw new SecurityException();
    }

  public void checkMemberAccess (Class cl, int mtype)
    {
      throw new SecurityException();
    }

  public void checkMulticast (InetAddress maddr)
    {
      throw new SecurityException();
    }

  public void checkMulticast (InetAddress maddr, byte ttl)
    {
      throw new SecurityException();
    }

  public void checkPackageAccess (String pkg)
    {
      throw new SecurityException();
    }

  public void checkPackageDefinition (String pkg)
    {
      throw new SecurityException();
    }

  public void checkPermission (java.security.Permission perm)
    {
      throw new SecurityException();
    }

  public void checkPrintJobAccess ()
    {
      throw new SecurityException();
    }

  public void checkPropertiesAccess ()
    {
      throw new SecurityException();
    }

  public void checkPropertyAccess (String prop)
    {
      throw new SecurityException();
    }

  public void checkPropertyAccess (String prop, String defval)
    {
      throw new SecurityException();
    }

  public void checkRead (FileDescriptor fd)
    {
      throw new SecurityException();
    }

  public void checkRead (String fileName)
    {
      throw new SecurityException();
    }

  public void checkRead (String fileName, Object ctx)
    {
      throw new SecurityException();
    }

  public void checkSecurityAccess (String action)
    {
      throw new SecurityException();
    }

  public void checkSetFactory ()
    {
      throw new SecurityException();
    }

  public void checkSystemClipboardAccess ()
    {
      throw new SecurityException();
    }

  public boolean checkTopLevelWindow (Object window)
    {
      throw new SecurityException();
    }

  public void checkWrite (FileDescriptor fd)
    {
      throw new SecurityException();
    }

  public void checkWrite (String fileName)
    {
      throw new SecurityException();
    }

  // Note: this method is deprecated in JDK 1.2
  protected /* native */ int classDepth (String className)
    {
      Class[] classStack = getClassContext ();
      for (int i = 0; i < classStack.length; i++)
	if (classStack[i].getName().compareTo(className) == 0)
	  return i;

      return -1;
    }

  // Note: this method is deprecated in JDK 1.2
  protected /* native */ int classLoaderDepth ()
    {
      Class[] classStack = getClassContext ();
      for (int i = 0; i < classStack.length; i++)
	if (classStack[i].getClassLoader() != null)
	  return i;

      return -1;
    }

  protected /* native */ ClassLoader currentClassLoader ()
    {
      Class[] classStack = getClassContext ();
      for (int i = 0; i < classStack.length; i++)
	{
	  ClassLoader loader = classStack[i].getClassLoader();
	  if (loader != null)
	    return loader;
	}

      return null;
    }

  protected /* native */ Class currentLoadedClass ()
    {
      Class[] classStack = getClassContext ();
      for (int i = 0; i < classStack.length; i++)
	{
	  ClassLoader loader = classStack[i].getClassLoader();
	  if (loader != null)
	    return classStack[i];
	}
      
      return null;
    }

  protected /* native */ Class[] getClassContext ()
    {
      return new Class[0];
    }

  // Note: this method is deprecated in JDK 1.2
  public boolean getInCheck ()
    {
      return inCheck;
    }

  public Object getSecurityContext ()
    {
      // FIXME: This has yet to be implemented.
      return new String("");
    }

  public ThreadGroup getThreadGroup ()
    {
      return Thread.currentThread().getThreadGroup();
    }

  protected boolean inClass (String className)
    {
      return (classDepth (className) != -1);
    }

  protected boolean inClassLoader ()
    {
      return (classLoaderDepth () != -1);
    }

  protected SecurityManager ()
    {
      if (System.getSecurityManager () != null)
	throw new SecurityException ();
    }
}