Coverage details for com.martiansoftware.nailgun.NGSecurityManager

LineHitsSource
1 /*
2  
3 Copyright 2004, Martian Software, Inc.
4  
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8  
9 http://www.apache.org/licenses/LICENSE-2.0
10  
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16  
17 */
18  
19 package com.martiansoftware.nailgun;
20  
21 import java.security.Permission;
22  
23 import java.io.PrintStream;
24  
25 /**
26  * Security manager which does nothing other than trap
27  * checkExit, or delegate all non-deprecated methods to
28  * a base manager.
29  *
30  * @author Pete Kirkham
31  *
32  */
33 public class NGSecurityManager extends SecurityManager {
340        private static final ThreadLocal EXIT = new InheritableThreadLocal();
35         final SecurityManager base;
36         
37         /**
38          * Construct an NGSecurityManager with the given base.
39          * @param base the base security manager, or null for no base.
40          */
410        public NGSecurityManager (SecurityManager base) {
420                this.base = base;
430        }
44  
45         public void checkExit (int status) {
460                if (base != null) {
470                        base.checkExit(status);
48                 }
49                 
500                final PrintStream exit = (PrintStream)EXIT.get();
51                 
520                if (exit != null) {
530                        exit.println(status);
54                 }
55                 
560                throw new NGExitException(status);
57         }
58  
59         public void checkPermission(Permission perm) {
600                if (base != null) {
610                        base.checkPermission(perm);
62                 }
630        }
64    
65         public void checkPermission(Permission perm, Object context) {
660                if (base != null) {
670                        base.checkPermission(perm, context);
68                 }
690        }
70         
71         public static void setExit (PrintStream exit) {
720                EXIT.set(exit);
730        }
74 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.