OSDN Git Service

677dc90212d17f271fc31d7459ae508f55242833
[pf3gnuchains/gcc-fork.git] / libjava / java / lang / SecurityManager.java
1 /* java.lang.SecurityManager
2    Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10  
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING.  If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
20
21 As a special exception, if you link this library with other files to
22 produce an executable, this library does not by itself cause the
23 resulting executable to be covered by the GNU General Public License.
24 This exception does not however invalidate any other reasons why the
25 executable file might be covered by the GNU General Public License. */
26
27
28 package java.lang;
29
30 import java.net.*;
31 import java.util.*;
32 import java.io.*;
33
34 /**
35  ** SecurityManager is a class you can extend to create
36  ** your own Java security policy.  By default, there is
37  ** no SecurityManager installed in 1.1, which means that
38  ** all things are permitted to all people.<P>
39  **
40  ** The default methods in this class deny all
41  ** things to all people.
42  **
43  ** @author  John Keiser
44  ** @version 1.1.0, 31 May 1998
45  ** @since JDK1.0
46  **/
47 public class SecurityManager {
48         /** Tells whether or not the SecurityManager is currently
49          ** performing a security check.
50          **/
51         protected boolean inCheck;
52
53         /** Tells whether or not the SecurityManager is currently
54          ** performing a security check.
55          **
56          ** @return whether or not the SecurityManager is
57          **         currently performing a security check.
58          **/
59         public boolean getInCheck() {
60                 return inCheck;
61         }
62
63         /** Get a list of all the classes currently executing
64          ** methods on the Java stack.  getClassContext()[0] is
65          ** the currently executing method
66          ** <STRONG>Spec Note:</STRONG> does not say whether
67          ** the stack will include the getClassContext() call or
68          ** the one just before it.
69          **
70          ** @return an array containing all the methods on classes
71          **         on the Java execution stack.
72          **/
73         protected Class[] getClassContext() {
74                 return VMSecurityManager.getClassContext();
75         }
76
77         /** Find the ClassLoader for the most recent class on the
78          ** stack that was loaded by an explicit ClassLoader.  If
79          ** everything on the stack was loaded by the system
80          ** classloader, null is returned.
81          **
82          ** @return the most recent ClassLoader on the execution
83          **         stack.
84          **/
85         protected ClassLoader currentClassLoader() {
86                 return VMSecurityManager.currentClassLoader();
87         }
88
89         /** Find the most recent class on the stack that was
90          ** loaded by an explicit ClassLoader.  If everything on
91          ** the stack was loaded by the system classloader, null
92          ** is returned.
93          **
94          ** @return the most recent loaded Class on the execution
95          **         stack.
96          **/
97         protected Class currentLoadedClass() {
98                 Class[] c = getClassContext();
99                 for(int i=0;i<c.length;i++) {
100                         if(c[i].getClassLoader() != null) {
101                                 return c[i];
102                         }
103                 }
104                 return null;
105         }
106
107         /** Get the depth on the execution stack of the most
108          ** recent class that was loaded by an explicit
109          ** ClassLoader.  This can be used as an index into
110          ** getClassContext().
111          **
112          ** @return the index of the most recent loaded Class on
113          **         the execution stack.
114          **/
115         protected int classLoaderDepth() {
116                 Class[] c = getClassContext();
117                 for(int i=0;i<c.length;i++) {
118                         if(c[i].getClassLoader() != null) {
119                                 return i;
120                         }
121                 }
122                 return -1;
123         }
124
125         /** Tell whether there is a class loaded with an explicit
126          ** ClassLoader on the stack.
127          **
128          ** @return whether there is a class loaded with an
129          **         explicit ClassLoader on the stack.
130          **/
131         protected boolean inClassLoader() {
132                 return classLoaderDepth() != -1;
133         }
134
135
136         /** Get the depth of a particular class on the execution
137          ** stack.
138          **
139          ** @param className the fully-qualified name of the class
140          **        to search for on the stack.
141          ** @return the index of the class on the stack, or -1 if
142          **         the class is not on the stack.
143          **/
144         protected int classDepth(String className) {
145                 Class[] c = getClassContext();
146                 for(int i=0;i<c.length;i++) {
147                         if(className.equals(c[i].getName())) {
148                                 return i;
149                         }
150                 }
151                 return -1;
152         }
153
154         /** Tell whether the specified class is on the execution
155          ** stack.
156          **
157          ** @param className the fully-qualified name of the class
158          **        to search for on the stack.
159          ** @return whether the specified class is on the
160          **         execution stack.
161          **/
162         protected boolean inClass(String className) {
163                 return classDepth(className) != -1;
164         }
165
166         /** Get an implementation-dependent Object that contains
167          ** enough information about the current environment to be
168          ** able to perform standard security checks later.  This
169          ** is used by trusted methods that need to verify that
170          ** their callers have sufficient access to perform
171          ** certain operations.<P>
172          **
173          ** Currently the only methods that use this are checkRead()
174          ** and checkConnect().
175          **
176          ** @see checkConnect(java.lang.String,int,java.lang.Object)
177          ** @see checkRead(java.lang.String,java.lang.Object)
178          **/
179         public Object getSecurityContext() {
180                 return new SecurityContext(getClassContext());
181         }
182
183         /** Check if the current thread is allowed to create a
184          ** ClassLoader.<P>
185          **
186          ** This method is called from ClassLoader.ClassLoader(),
187          ** in other words, whenever a ClassLoader is created.<P>
188          **
189          ** SecurityManager's implementation always denies access.
190          **
191          ** @exception SecurityException if the operation is not
192          **            permitted.
193          ** @see java.lang.ClassLoader#ClassLoader()
194          **/
195         public void checkCreateClassLoader() {
196                 throw new SecurityException("Cannot create new ClassLoaders.");
197         }
198
199         /** Check if the current thread is allowed to modify this
200          ** other Thread.<P>
201          **
202          ** Called by Thread.stop(), suspend(), resume(), and
203          ** interrupt(), destroy(), setPriority(), setName() and
204          ** setDaemon().<P>
205          **
206          ** SecurityManager's implementation always denies access.
207          **
208          ** @param g the Thread to check against
209          ** @exception SecurityException if the operation is not
210          **            permitted.
211          ** @see java.lang.Thread#stop()
212          ** @see java.lang.Thread#suspend()
213          ** @see java.lang.Thread#resume()
214          ** @see java.lang.Thread#interrupt()
215          ** @see java.lang.Thread#destroy()
216          ** @see java.lang.Thread#setPriority(int)
217          ** @see java.lang.Thread#setName(java.lang.String)
218          ** @see java.lang.Thread#setDaemon(boolean)
219          **/
220         public void checkAccess(Thread t) {
221                 throw new SecurityException("Cannot modify Threads.");
222         }
223
224         /** Check if the current thread is allowed to modify this
225          ** ThreadGroup.<P>
226          **
227          ** Called by Thread.Thread() (to add a thread to the
228          ** ThreadGroup), ThreadGroup.ThreadGroup() (to add this
229          ** ThreadGroup to a parent), ThreadGroup.stop(),
230          ** suspend(), resume(), interrupt(), destroy(),
231          ** setDaemon(), and setMaxPriority().<P>
232          **
233          ** SecurityManager's implementation always denies access.
234          **
235          ** @param g the ThreadGroup to check against
236          ** @exception SecurityException if the operation is not
237          **            permitted.
238          ** @see java.lang.Thread#Thread()
239          ** @see java.lang.ThreadGroup#ThreadGroup()
240          ** @see java.lang.ThreadGroup#stop()
241          ** @see java.lang.ThreadGroup#suspend()
242          ** @see java.lang.ThreadGroup#resume()
243          ** @see java.lang.ThreadGroup#interrupt()
244          ** @see java.lang.ThreadGroup#setDaemon(boolean)
245          ** @see java.lang.ThreadGroup#setMaxPriority(int)
246          **/
247         public void checkAccess(ThreadGroup g) {
248                 throw new SecurityException("Cannot modify ThreadGroups.");
249         }
250
251         /** Check if the current thread is allowed to exit the
252          ** JVM with the given status.<P>
253          **
254          ** This method is called from Runtime.exit().<P>
255          **
256          ** SecurityManager's implementation always denies access.
257          **
258          ** @param status the status to exit with
259          ** @exception SecurityException if the operation is not
260          **            permitted.
261          ** @see java.lang.Runtime#exit()
262          ** @see java.lang.Runtime#exit(int)
263          **/
264         public void checkExit(int status) {
265                 throw new SecurityException("Cannot exit JVM.");
266         }
267
268         /** Check if the current thread is allowed to execute the
269          ** given program.<P>
270          **
271          ** This method is called from Runtime.exec().<P>
272          **
273          ** SecurityManager's implementation always denies access.
274          **
275          ** @param program the name of the program to exec
276          ** @exception SecurityException if the operation is not
277          **            permitted.
278          ** @see java.lang.Runtime#exec(java.lang.String[],java.lang.String[])
279          **/
280         public void checkExec(String program) {
281                 throw new SecurityException("Cannot execute programs.");
282         }
283
284         /** Check if the current thread is allowed to link in the
285          ** given native library.<P>
286          **
287          ** This method is called from Runtime.load() (and hence,
288          ** by loadLibrary() as well).<P>
289          **
290          ** SecurityManager's implementation always denies access.
291          **
292          ** @param filename the full name of the library to load
293          ** @exception SecurityException if the operation is not
294          **            permitted.
295          ** @see java.lang.Runtime#load(java.lang.String)
296          **/
297         public void checkLink(String filename) {
298                 throw new SecurityException("Cannot link native libraries.");
299         }
300
301         /** Check if the current thread is allowed to read the
302          ** given file using the FileDescriptor.<P>
303          **
304          ** This method is called from
305          ** FileInputStream.FileInputStream().<P>
306          **
307          ** SecurityManager's implementation always denies access.
308          **
309          ** @param desc the FileDescriptor representing the file
310          **        to access
311          ** @exception SecurityException if the operation is not
312          **            permitted.
313          ** @see java.io.FileInputStream#FileInputStream(java.io.FileDescriptor)
314          **/
315         public void checkRead(FileDescriptor desc) {
316                 throw new SecurityException("Cannot read files via file descriptors.");
317         }
318
319         /** Check if the current thread is allowed to read the
320          ** given file.<P>
321          **
322          ** This method is called from
323          ** FileInputStream.FileInputStream(),
324          ** RandomAccessFile.RandomAccessFile(), File.exists(),
325          ** canRead(), isFile(), isDirectory(), lastModified(),
326          ** length() and list().<P>
327          **
328          ** SecurityManager's implementation always denies access.
329          **
330          ** @param filename the full name of the file to access
331          ** @exception SecurityException if the operation is not
332          **            permitted.
333          ** @see java.io.File
334          ** @see java.io.FileInputStream#FileInputStream(java.lang.String)
335          ** @see java.io.RandomAccessFile#RandomAccessFile(java.lang.String)
336          **/
337         public void checkRead(String filename) {
338                 throw new SecurityException("Cannot read files via file names.");
339         }
340
341         /** Check if the current thread is allowed to read the
342          ** given file. using the given SecurityContext.<P>
343          **
344          ** I know of no core class that calls this method.<P>
345          **
346          ** SecurityManager's implementation always denies access.
347          **
348          ** @param filename the full name of the file to access
349          ** @param securityContext the Security Context to
350          **        determine access for.
351          ** @exception SecurityException if the operation is not
352          **            permitted.
353          **/
354         public void checkRead(String filename, Object securityContext) {
355                 throw new SecurityException("Cannot read files via file names.");
356         }
357
358         /** Check if the current thread is allowed to write to the
359          ** given file using the FileDescriptor.<P>
360          **
361          ** This method is called from
362          ** FileOutputStream.FileOutputStream().<P>
363          **
364          ** SecurityManager's implementation always denies access.
365          **
366          ** @param desc the FileDescriptor representing the file
367          **        to access
368          ** @exception SecurityException if the operation is not
369          **            permitted.
370          ** @see java.io.FileOutputStream#FileOutputStream(java.io.FileDescriptor)
371          **/
372         public void checkWrite(FileDescriptor desc) {
373                 throw new SecurityException("Cannot write files via file descriptors.");
374         }
375
376         /** Check if the current thread is allowed to write to the
377          ** given file.<P>
378          **
379          ** This method is called from
380          ** FileOutputStream.FileOutputStream(),
381          ** RandomAccessFile.RandomAccessFile(),
382          ** File.canWrite(), mkdir(), and renameTo().<P>
383          **
384          ** SecurityManager's implementation always denies access.
385          **
386          ** @param filename the full name of the file to access
387          ** @exception SecurityException if the operation is not
388          **            permitted.
389          ** @see java.io.File#canWrite()
390          ** @see java.io.File#mkdir()
391          ** @see java.io.File#renameTo()
392          ** @see java.io.FileOutputStream#FileOutputStream(java.lang.String)
393          ** @see java.io.RandomAccessFile#RandomAccessFile(java.lang.String)
394          **/
395         public void checkWrite(String filename) {
396                 throw new SecurityException("Cannot write files via file names.");
397         }
398
399         /** Check if the current thread is allowed to delete the
400          ** given file.<P>
401          **
402          ** This method is called from File.delete().<P>
403          **
404          ** SecurityManager's implementation always denies access.
405          **
406          ** @param filename the full name of the file to delete
407          ** @exception SecurityException if th operation is not
408          **            permitted.
409          ** @see java.io.File#delete()
410          **/
411         public void checkDelete(String filename) {
412                 throw new SecurityException("Cannot delete files.");
413         }
414
415         /** Check if the current thread is allowed to connect to a
416          ** given host on a given port.<P>
417          **
418          ** This method is called from Socket.Socket().
419          **
420          ** SecurityManager's implementation always denies access.
421          **
422          ** @param host the host to connect to
423          ** @param port the port to connect on
424          ** @exception SecurityException if the operation is not
425          **            permitted
426          ** @see java.net.Socket#Socket()
427          **/
428         public void checkConnect(String host, int port) {
429                 throw new SecurityException("Cannot make network connections.");
430         }
431
432         /** Check if the current thread is allowed to connect to a
433          ** given host on a given port using a specific security
434          ** context to determine access.<P>
435          **
436          ** This method is not called in the 1.1 core classes.<P>
437          **
438          ** SecurityManager's implementation always denies access.
439          **
440          ** @param host the host to connect to
441          ** @param port the port to connect on
442          ** @param securityContext the security context to
443          **        determine access with
444          ** @exception SecurityException if the operation is not
445          **            permitted
446          **/
447         public void checkConnect(String host, int port, Object securityContext) {
448                 throw new SecurityException("Cannot make network connections.");
449         }
450
451         /** Check if the current thread is allowed to listen to a
452          ** specific port for data.<P>
453          **
454          ** This method is called by ServerSocket.ServerSocket().<P>
455          **
456          ** SecurityManager's implementation always denies access.
457          **
458          ** @param port the port to listen on
459          ** @exception SecurityException if the operation is not
460          **            permitted
461          ** @see java.net.ServerSocket#ServerSocket(int)
462          **/
463         public void checkListen(int port) {
464                 throw new SecurityException("Cannot listen for connections.");
465         }
466
467         /** Check if the current thread is allowed to accept a
468          ** connection from a particular host on a particular
469          ** port.<P>
470          **
471          ** This method is called by ServerSocket.implAccept().<P>
472          **
473          ** SecurityManager's implementation always denies access.
474          **
475          ** @param host the host which wishes to connect
476          ** @param port the port the connection will be on
477          ** @exception SecurityException if the operation is not
478          **            permitted
479          ** @see java.net.ServerSocket#accept()
480          **/
481         public void checkAccept(String host, int port) {
482                 throw new SecurityException("Cannot accept connections.");
483         }
484
485         /** Check if the current thread is allowed to read and
486          ** write multicast to a particular address.<P>
487          **
488          ** SecurityManager's implementation always denies access.
489          **
490          ** @XXX where is it called?
491          **
492          ** @param addr the address to multicast to.
493          ** @exception SecurityException if the operation is not
494          **            permitted.
495          **/
496         public void checkMulticast(InetAddress addr) {
497                 throw new SecurityException("Cannot read or write multicast.");
498         }
499
500         /** Check if the current thread is allowed to read and
501          ** write multicast to a particular address with a
502          ** particular ttl value.<P>
503          **
504          ** SecurityManager's implementation always denies access.<P>
505          **
506          ** @XXX where is it called?
507          **
508          ** @XXX what the hell is ttl?  Expand abbreviation.
509          **
510          ** @param addr the address to multicast to.
511          ** @param ttl the ttl value to use
512          ** @exception SecurityException if the operation is not
513          **            permitted.
514          **/
515         public void checkMulticast(InetAddress addr, byte ttl) {
516                 throw new SecurityException("Cannot read or write multicast.");
517         }
518
519         /**
520          ** Check if the current thread is allowed to perform an
521          ** operation that requires the specified <code>Permission</code>.
522          **
523          ** @param perm The <code>Permission</code> required.
524          ** @exception SecurityException If the operation is not allowed.
525          **/
526          public void checkPermission(java.security.Permission perm) {
527                 throw new SecurityException("Operation not allowed");
528         }
529
530         /**
531          ** Check if the current thread is allowed to perform an
532          ** operation that requires the specified <code>Permission</code>.
533          **
534          ** @param perm The <code>Permission</code> required.
535          ** @param context A security context
536          ** @exception SecurityException If the operation is not allowed.
537          ** @since 1.2
538          **/
539          public void checkPermission(java.security.Permission perm,
540                                      Object context) {
541                 throw new SecurityException("Operation not allowed");
542         }
543
544         /** Check if the current thread is allowed to read or
545          ** write all the system properties at once.<P>
546          **
547          ** This method is called by System.getProperties()
548          ** and setProperties().<P>
549          **
550          ** SecurityManager's implementation always denies access.
551          **
552          ** @exception SecurityException if the operation is not
553          **            permitted.
554          ** @see java.lang.System#getProperties()
555          ** @see java.lang.System#setProperties(java.util.Properties)
556          **/
557         public void checkPropertiesAccess() {
558                 throw new SecurityException("Cannot access all system properties at once.");
559         }
560
561         /** Check if the current thread is allowed to read or
562          ** write a particular system property.<P>
563          **
564          ** This method is called by System.getProperty() and
565          ** setProperty().<P>
566          **
567          ** SecurityManager's implementation always denies access.
568          **
569          ** @exception SecurityException is the operation is not
570          **            permitted.
571          ** @see java.lang.System#getProperty(java.lang.String)
572          ** @see java.lang.System#setProperty(java.lang.String,java.lang.String)
573          **/
574         public void checkPropertyAccess(String name) {
575                 throw new SecurityException("Cannot access individual system properties.");
576         }
577
578         /** Check if the current thread is allowed to create a
579          ** top-level window.  If it is not, the operation should
580          ** still go through, but some sort of nonremovable
581          ** warning should be placed on the window to show that it
582          ** is untrusted.<P>
583          **
584          ** This method is called by Window.Window().<P>
585          **
586          ** SecurityManager's implementation always denies access.
587          **
588          ** @param window the window to create
589          ** @see java.awt.Window#Window(java.awt.Frame)
590          **/
591         public boolean checkTopLevelWindow(Object window) {
592           return false;
593         }
594
595         /** Check if the current thread is allowed to create a
596          ** print job.<P>
597          **
598          ** This method is called by Toolkit.getPrintJob().  (I
599          ** assume so, at least, it just don't say nothing about
600          ** it in the spec.)<P>
601          ** 
602          ** SecurityManager's implementation always denies access.
603          **
604          ** @exception SecurityException if the operation is not
605          **            permitted.
606          ** @see java.awt.Toolkit.getPrintJob(java.awt.Frame,java.lang.String,java.util.Properties)
607          **/
608         public void checkPrintJobAccess() {
609                 throw new SecurityException("Cannot create print jobs.");
610         }
611
612         /** Check if the current thread is allowed to use the
613          ** system clipboard.<P>
614          **
615          ** This method is called by Toolkit.getSystemClipboard().
616          ** (I assume.)<P>
617          **
618          ** SecurityManager's implementation always denies access.
619          **
620          ** @exception SecurityException if the operation is not
621          **            permitted.
622          ** @see java.awt.Toolkit#getSystemClipboard()
623          **/
624         public void checkSystemClipboardAccess() {
625                 throw new SecurityException("Cannot access the system clipboard.");
626         }
627
628         /** Check if the current thread is allowed to use the AWT
629          ** event queue.<P>
630          **
631          ** This method is called by Toolkit.getSystemEventQueue().<P>
632          **
633          ** SecurityManager's implementation always denies access.
634          **
635          ** @exception SecurityException if the operation is not
636          **            permitted.
637          ** @see java.awt.Toolkit#getSystemEventQueue()
638          **/
639         public void checkAwtEventQueueAccess() {
640                 throw new SecurityException("Cannot access the AWT event queue.");
641         }
642
643         /** Check if the current thread is allowed to access the
644          ** specified package at all.<P>
645          **
646          ** This method is called by ClassLoader.loadClass() in
647          ** user-created ClassLoaders.<P>
648          **
649          ** SecurityManager's implementation always denies access.
650          **
651          ** @param packageName the package name to check access to
652          ** @exception SecurityException if the operation is not
653          **            permitted.
654          ** @see java.lang.ClassLoader#loadClass(java.lang.String,boolean)
655          **/
656         public void checkPackageAccess(String packageName) {
657                 throw new SecurityException("Cannot access packages via the ClassLoader.");
658         }
659
660         /** Check if the current thread is allowed to define
661          ** classes the specified package.  If the class already
662          ** created, though, ClassLoader.loadClass() can still
663          ** return the Class if checkPackageAccess() checks out.<P>
664          **
665          ** This method is called by ClassLoader.loadClass() in
666          ** user-created ClassLoaders.<P>
667          **
668          ** SecurityManager's implementation always denies access.
669          **
670          ** @param packageName the package name to check access to
671          ** @exception SecurityException if the operation is not
672          **            permitted.
673          ** @see java.lang.ClassLoader#loadClass(java.lang.String,boolean)
674          **/
675         public void checkPackageDefinition(String packageName) {
676                 throw new SecurityException("Cannot load classes into any packages via the ClassLoader.");
677         }
678
679         /** Check if the current thread is allowed to set the
680          ** current socket factory.<P>
681          **
682          ** This method is called by Socket.setSocketImplFactory(),
683          ** ServerSocket.setSocketFactory(), and
684          ** URL.setURLStreamHandlerFactory().<P>
685          **
686          ** SecurityManager's implementation always denies access.
687          **
688          ** @exception SecurityException if the operation is not
689          **            permitted.
690          ** @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory)
691          ** @see java.net.ServerSocket#setSocketFactory(java.net.SocketImplFactory)
692          ** @see java.net.URL#setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory)
693          **/
694         public void checkSetFactory() {
695                 throw new SecurityException("Cannot set the socket factory.");
696         }
697
698         /** Check if the current thread is allowed to get certain
699          ** types of Methods, Fields and Constructors from a Class
700          ** object.<P>
701          **
702          ** This method is called by Class.getMethod[s](),
703          ** Class.getField[s](), Class.getConstructor[s],
704          ** Class.getDeclaredMethod[s](),
705          ** Class.getDeclaredField[s](), and
706          ** Class.getDeclaredConstructor[s]().<P>
707          **
708          ** SecurityManager's implementation always denies access.
709          **
710          ** @param c the Class to check
711          ** @param memberType the type of members to check
712          **        against, either Member.DECLARED or
713          **        Member.PUBLIC.
714          ** @exception SecurityException if the operation is not
715          **            permitted.
716          ** @see java.lang.Class
717          ** @see java.lang.reflect.Member#DECLARED
718          ** @see java.lang.reflect.Member#PUBLIC
719          **/
720         public void checkMemberAccess(Class c, int memberType) {
721                 throw new SecurityException("Cannot access members of classes.");
722         }
723
724         /** Test whether a particular security action may be
725          ** taken.
726          ** @param action the desired action to take
727          ** @exception SecurityException if the action is denied.
728          ** @XXX I have no idea what actions must be tested
729          **      or where.
730          **/
731         public void checkSecurityAccess(String action) {
732                 checkPermission (new java.security.SecurityPermission (action));
733         }
734
735         /** Get the ThreadGroup that a new Thread should belong
736          ** to by default.<P>
737          **
738          ** Called by Thread.Thread().<P>
739          **
740          ** SecurityManager's implementation just uses the
741          ** ThreadGroup of the current Thread.<P>
742          **
743          ** <STRONG>Spec Note:</STRONG> it is not clear whether
744          ** the new Thread is guaranteed to pass the
745          ** checkAccessThreadGroup() test when using this
746          ** ThreadGroup.  I presume so.
747          **
748          ** @return the ThreadGroup to put the new Thread into.
749          **/
750         public ThreadGroup getThreadGroup() {
751                 return Thread.currentThread().getThreadGroup();
752         }
753
754         public SecurityManager () {
755                 if (System.getSecurityManager () != null)
756                         throw new SecurityException ();
757         }
758 }
759
760 class SecurityContext {
761         Class[] classes;
762         SecurityContext(Class[] classes) {
763                 this.classes = classes;
764         }
765 }