netx.jnlp.runtime

Class JNLPSecurityManager


(package private) class JNLPSecurityManager
extends SecurityManager

Security manager for JNLP environment. This security manager cannot be replaced as it always denies attempts to replace the security manager or policy.

The JNLP security manager tracks windows created by an application, allowing those windows to be disposed when the application exits but the JVM does not. If security is not enabled then the first application to call System.exit will halt the JVM.

Version:
$Revision: 1.17 $
Author:
Jon A. Maxwell (JAM) - initial author

Constructor Summary

JNLPSecurityManager()
Creates a JNLP SecurityManager.

Method Summary

void
checkExit(int status)
Checks whether the caller can exit the system.
void
checkPermission(Permission perm)
Throws a SecurityException if the permission is denied, otherwise return normally.
boolean
checkTopLevelWindow(Object window)
Checks whether the window can be displayed without an applet warning banner, and adds the window to the list of windows to be disposed when the calling application exits.
protected ApplicationInstance
getApplication()
Return the current Application, or null if none can be determined.
protected ApplicationInstance
getApplication(Window window)
Return the application the opened the specified window (only call from event dispatch thread).
protected ApplicationInstance
getApplication(stack[] , int maxDepth)
Return the current Application, or null.
ThreadGroup
getThreadGroup()
Returns the application's thread group if the application can be determined; otherwise returns super.getThreadGroup()
boolean
isExitClass()
Returns whether the exit class is present on the stack, or true if no exit class is set.
void
setExitClass(Class exitClass)
Set the exit class, which is the only class that can exit the JVM; if not set then any class can exit the JVM.

Constructor Details

JNLPSecurityManager

(package private)  JNLPSecurityManager()
Creates a JNLP SecurityManager.

Method Details

checkExit

public void checkExit(int status)
Checks whether the caller can exit the system. This method identifies whether the caller is a real call to Runtime.exec and has special behavior when returning from this method would exit the JVM and an exit class is set: if the caller is not the exit class then the calling application will be stopped and its resources destroyed (when possible), and an exception will be thrown to prevent the JVM from shutting down.

Calls not from Runtime.exit or with no exit class set will behave normally, and the exit class can always exit the JVM.


checkPermission

public void checkPermission(Permission perm)
Throws a SecurityException if the permission is denied, otherwise return normally. This method always denies permission to change the security manager or policy.

checkTopLevelWindow

public boolean checkTopLevelWindow(Object window)
Checks whether the window can be displayed without an applet warning banner, and adds the window to the list of windows to be disposed when the calling application exits.

getApplication

protected ApplicationInstance getApplication()
Return the current Application, or null if none can be determined.

getApplication

protected ApplicationInstance getApplication(Window window)
Return the application the opened the specified window (only call from event dispatch thread).

getApplication

protected ApplicationInstance getApplication(stack[] ,
                                             int maxDepth)
Return the current Application, or null.

getThreadGroup

public ThreadGroup getThreadGroup()
Returns the application's thread group if the application can be determined; otherwise returns super.getThreadGroup()

isExitClass

public boolean isExitClass()
Returns whether the exit class is present on the stack, or true if no exit class is set.

setExitClass

public void setExitClass(Class exitClass)
            throws IllegalStateException
Set the exit class, which is the only class that can exit the JVM; if not set then any class can exit the JVM.
Parameters:
exitClass - the exit class