Contents | Package | Class | Tree | Deprecated | Index | Help
PREV | NEXT SHOW LISTS | HIDE LISTS

Class com.orbs.pub.app.agent.vaft.security.UntrustedSecurityManager

java.lang.Object
    |
    +----java.lang.SecurityManager
            |
            +----com.orbs.pub.app.agent.vaft.security.UntrustedSecurityManager
Subclasses:
HostSecurityManager

public class UntrustedSecurityManager
extends java.lang.SecurityManager

A generic SecurityManager implementation to host untrusted code loaded over a network. "Untrusted" code is defined as any class that was loaded using a ClassLoader instead of being read in directly from the local classpath.

Implement by including the following as the very first line of the main ( ) method of your application:

 System.setSecurityManager ( new HostSecurityManager ( ) );
 

Each of the 29 "check" methods of the standard Java 1.1.5 superclass SecurityManager are overridden to just call the reject_untrusted ( ) method. This method simply throws a SecurityException if the superclass method inClassLoader ( ) returns true.

To my knowledge, the only four possible "hostile" actions remaining that untrusted code could still perform on the host when using this implementation of SecurityManager are

Preventing untrusted code from reading from and writing to the standard console could be accomplished by replacing the default IO streams with customized classes that would throw a SecurityException. See System.setErr ( err ), System.setIn ( in ), and System.setOut ( out ).

If the standard console IO stream blocking were implemented, untrusted code would have no method of communication except by calling the methods of other objects within the virtual machine. Further communication (sockets, etc.) to the outside could then be optionally permitted by trusted classes. See SecurityManager.inCheck, SecurityManager.getInCheck ( ), and SecurityManager.getSecurityContext ( ).

Version:
1998-03-08
Author:
David W. Croft

Fields inherited from class java.lang.SecurityManager
 inCheck
 

Constructor Summary
 UntrustedSecurityManager()
 
 

Method Summary
void  checkAccept(java.lang.String host, int port)
 
void  checkAccess(java.lang.Thread t)
 
void  checkAccess(java.lang.ThreadGroup g)
 
void  checkAwtEventQueueAccess()
 
void  checkConnect(java.lang.String host, int port)
 
void  checkConnect(java.lang.String host, int port, java.lang.Object context)
 
void  checkCreateClassLoader()
 
void  checkDelete(java.lang.String file)
 
void  checkExec(java.lang.String cmd)
 
void  checkExit(int status)
 
void  checkLink(java.lang.String libname)
 
void  checkListen(int port)
 
void  checkMemberAccess(java.lang.Class clazz, int which)
 
void  checkMulticast(java.net.InetAddress maddr)
 
void  checkMulticast(java.net.InetAddress maddr, byte ttl)
 
void  checkPackageAccess(java.lang.String pkg)
 
void  checkPackageDefinition(java.lang.String pkg)
 
void  checkPrintJobAccess()
 
void  checkPropertiesAccess()
 
void  checkPropertyAccess(java.lang.String key)
 
void  checkRead(java.io.FileDescriptor fd)
 
void  checkRead(java.lang.String file)
 
void  checkRead(java.lang.String file, java.lang.Object context)
 
void  checkSecurityAccess(java.lang.String action)
 
void  checkSetFactory()
 
void  checkSystemClipboardAccess()
 
boolean  checkTopLevelWindow(java.lang.Object window)
 
void  checkWrite(java.io.FileDescriptor fd)
 
void  checkWrite(java.lang.String file)
 
void  reject_untrusted()
Called by all of the "check" methods to foil untrusted code.
 
Methods inherited from class java.lang.SecurityManager
 checkAccept, checkAccess, checkAccess, checkAwtEventQueueAccess, checkConnect, checkConnect, checkCreateClassLoader, checkDelete, checkExec, checkExit, checkLink, checkListen, checkMemberAccess, checkMulticast, checkMulticast, checkPackageAccess, checkPackageDefinition, checkPrintJobAccess, checkPropertiesAccess, checkPropertyAccess, checkRead, checkRead, checkRead, checkSecurityAccess, checkSetFactory, checkSystemClipboardAccess, checkTopLevelWindow, checkWrite, checkWrite, classDepth, classLoaderDepth, currentClassLoader, currentLoadedClass, getClassContext, getInCheck, getSecurityContext, getThreadGroup, inClass, inClassLoader
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UntrustedSecurityManager

public UntrustedSecurityManager()
Method Detail

reject_untrusted

protected void reject_untrusted()
Called by all of the "check" methods to foil untrusted code.
 if ( inClassLoader ( ) )
   throw new SecurityException ( "untrusted" );
 

checkAccept

public void checkAccept(java.lang.String host,
                        int port)
Overrides:
checkAccept in class java.lang.SecurityManager

checkAccess

public void checkAccess(java.lang.Thread t)
Overrides:
checkAccess in class java.lang.SecurityManager

checkAccess

public void checkAccess(java.lang.ThreadGroup g)
Overrides:
checkAccess in class java.lang.SecurityManager

checkAwtEventQueueAccess

public void checkAwtEventQueueAccess()
Overrides:
checkAwtEventQueueAccess in class java.lang.SecurityManager

checkConnect

public void checkConnect(java.lang.String host,
                         int port)
Overrides:
checkConnect in class java.lang.SecurityManager

checkConnect

public void checkConnect(java.lang.String host,
                         int port,
                         java.lang.Object context)
Overrides:
checkConnect in class java.lang.SecurityManager

checkCreateClassLoader

public void checkCreateClassLoader()
Overrides:
checkCreateClassLoader in class java.lang.SecurityManager

checkDelete

public void checkDelete(java.lang.String file)
Overrides:
checkDelete in class java.lang.SecurityManager

checkExec

public void checkExec(java.lang.String cmd)
Overrides:
checkExec in class java.lang.SecurityManager

checkExit

public void checkExit(int status)
Overrides:
checkExit in class java.lang.SecurityManager

checkLink

public void checkLink(java.lang.String libname)
Overrides:
checkLink in class java.lang.SecurityManager

checkListen

public void checkListen(int port)
Overrides:
checkListen in class java.lang.SecurityManager

checkMemberAccess

public void checkMemberAccess(java.lang.Class clazz,
                              int which)
Overrides:
checkMemberAccess in class java.lang.SecurityManager

checkMulticast

public void checkMulticast(java.net.InetAddress maddr)
Overrides:
checkMulticast in class java.lang.SecurityManager

checkMulticast

public void checkMulticast(java.net.InetAddress maddr,
                           byte ttl)
Overrides:
checkMulticast in class java.lang.SecurityManager

checkPackageAccess

public void checkPackageAccess(java.lang.String pkg)
Overrides:
checkPackageAccess in class java.lang.SecurityManager

checkPackageDefinition

public void checkPackageDefinition(java.lang.String pkg)
Overrides:
checkPackageDefinition in class java.lang.SecurityManager

checkPrintJobAccess

public void checkPrintJobAccess()
Overrides:
checkPrintJobAccess in class java.lang.SecurityManager

checkPropertiesAccess

public void checkPropertiesAccess()
Overrides:
checkPropertiesAccess in class java.lang.SecurityManager

checkPropertyAccess

public void checkPropertyAccess(java.lang.String key)
Overrides:
checkPropertyAccess in class java.lang.SecurityManager

checkRead

public void checkRead(java.io.FileDescriptor fd)
Overrides:
checkRead in class java.lang.SecurityManager

checkRead

public void checkRead(java.lang.String file)
Overrides:
checkRead in class java.lang.SecurityManager

checkRead

public void checkRead(java.lang.String file,
                      java.lang.Object context)
Overrides:
checkRead in class java.lang.SecurityManager

checkSecurityAccess

public void checkSecurityAccess(java.lang.String action)
Overrides:
checkSecurityAccess in class java.lang.SecurityManager

checkSetFactory

public void checkSetFactory()
Overrides:
checkSetFactory in class java.lang.SecurityManager

checkSystemClipboardAccess

public void checkSystemClipboardAccess()
Overrides:
checkSystemClipboardAccess in class java.lang.SecurityManager

checkTopLevelWindow

public boolean checkTopLevelWindow(java.lang.Object window)
Overrides:
checkTopLevelWindow in class java.lang.SecurityManager

checkWrite

public void checkWrite(java.io.FileDescriptor fd)
Overrides:
checkWrite in class java.lang.SecurityManager

checkWrite

public void checkWrite(java.lang.String file)
Overrides:
checkWrite in class java.lang.SecurityManager

Contents | Package | Class | Tree | Deprecated | Index | Help


Virtual Anarchy of Free Traders
PREV | NEXT SHOW LISTS | HIDE LISTS