KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > core > OzoneSecurityManager


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Core License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: OzoneSecurityManager.java,v 1.2 2002/08/27 08:32:25 per_nyfelt Exp $
8

9 package org.ozoneDB.core;
10
11 import org.ozoneDB.core.DbRemote.CommandThread;
12 import java.io.*;
13 import java.net.*;
14
15
16 public class OzoneSecurityManager extends SecurityManager JavaDoc {
17
18     static boolean enabled = false;
19
20
21     Thread JavaDoc thread() {
22         return Thread.currentThread();
23     }
24
25
26     public void enable( boolean value ) {
27         enabled = value;
28     }
29
30
31     boolean is3XThread() {
32         return !isTransaction();
33     }
34
35
36     boolean isTransaction() {
37         if (thread() instanceof CommandThread) {
38             return ((CommandThread)thread()).transaction() != null;
39         } else {
40             return false;
41         }
42     }
43
44
45     void standardSecurity() {
46         if (enabled) {
47             if (isTransaction()) {
48                 throw new SecurityException JavaDoc();
49             }
50         }
51     }
52
53
54     public OzoneSecurityManager() {
55     }
56
57
58     public void checkAccept( String JavaDoc host, int port ) {
59         standardSecurity();
60     }
61
62
63     public void checkAccess( Thread JavaDoc thread ) {
64         standardSecurity();
65     }
66
67
68     public void checkAccess( ThreadGroup JavaDoc threadGroup ) {
69         standardSecurity();
70     }
71
72
73     public void checkAwtEventQueueAccess() {
74         standardSecurity();
75     }
76
77
78     public void checkConnect( String JavaDoc host, int port ) {
79         standardSecurity();
80     }
81
82
83     public void checkConnect( String JavaDoc host, int port, Object JavaDoc obj ) {
84         standardSecurity();
85     }
86
87
88     public void checkCreateClassLoader() {
89         standardSecurity();
90     }
91
92
93     public void checkDelete( String JavaDoc file ) {
94         standardSecurity();
95     }
96
97
98     public void checkExec( String JavaDoc command ) {
99         standardSecurity();
100     }
101
102
103     public void checkExit( int code ) {
104         if (enabled) {
105             throw new SecurityException JavaDoc();
106         }
107     }
108
109
110     public void checkLink( String JavaDoc library ) {
111         standardSecurity();
112     }
113
114
115     public void checkListen( int port ) {
116         standardSecurity();
117     }
118
119
120     public void checkMemberAccess( Class JavaDoc clazz, int which ) {
121     }
122
123
124     public void checkMulitcast( InetAddress add, byte ip ) {
125         standardSecurity();
126     }
127
128
129     public void checkPackageAccess( String JavaDoc pkg ) {
130     }
131
132
133     public void checkPackageDefinition( String JavaDoc pkg ) {
134     }
135
136
137     public void checkPermission( java.security.Permission JavaDoc perm, Object JavaDoc context ) {
138     }
139
140
141     /**
142      * Allow ObjectOutputStream.enableReplceObject() to be set to true.
143      */

144     public void checkPermission( java.security.Permission JavaDoc perm ) {
145     }
146
147
148     public void checkPrintJobAccess() {
149     }
150
151
152     public void checkPropertiesAccess() {
153     }
154
155
156     public void checkPropertyAccess( String JavaDoc prop ) {
157     }
158
159
160     public void checkRead( FileDescriptor fd ) {
161     }
162
163
164     public void checkRead( String JavaDoc file ) {
165     }
166
167
168     public void checkRead( String JavaDoc file, Object JavaDoc obj ) {
169     }
170
171
172     public void checkSecurityAccess( String JavaDoc action ) {
173     }
174
175
176     public void checkSetFactory() {
177     }
178
179
180     public void checkSystemClipboardAccess() {
181     }
182
183
184     public boolean checkTopLevelWindow( Object JavaDoc window ) {
185         // in case of LocalDatabase this would also prevent the client
186
// from havin a GUI
187
// throw new SecurityException();
188
return true;
189     }
190
191
192     public void checkWrite( FileDescriptor fd ) {
193     }
194
195
196     public void checkWrite( String JavaDoc file ) {
197     }
198 }
199
Popular Tags