Class JNLPRuntime
- java.lang.Object
-
- net.sourceforge.jnlp.runtime.JNLPRuntime
-
public class JNLPRuntime extends java.lang.ObjectConfigure and access the runtime environment. This class stores global jnlp properties such as default download indicators, the install/base directory, the default resource update policy, etc. Some settings, such as the base directory, cannot be changed once the runtime has been initialized.
The JNLP runtime can be locked to prevent further changes to the runtime environment except by a specified class. If set, only instances of the exit class can exit the JVM or change the JNLP runtime settings once the runtime has been initialized.
- Version:
- $Revision: 1.19 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classJNLPRuntime.DeploymentConfigurationHoldersee Double-checked locking in Java for cases how not to do lazy initialization and Initialization on demand holder idiom for ITW approachprivate static classJNLPRuntime.ExtensionPointHolder
-
Field Summary
Fields Modifier and Type Field Description private static booleanallowRedirectallows 301.302.303.307.308 redirects to be followed when downloading resourcesprivate static booleandebugwhether debug mode is onprivate static java.nio.channels.FileLockfileLocka lock which is held to indicate that an instance of netx is runningprivate static ForkingStrategyforkingStrategyset to NEVER to indicate another JVM should not be spawned, even if necessaryprivate static LaunchHandlerhandlera default launch handlerprivate static booleanheadlesswhether netx is in command-line mode (headless)private static booleanheadlessCheckedprivate static java.lang.Stringhistoryjava-abrt-connector can print out specific application String method, it is good to save visited urls for reproduce purposes.private static booleanignoreHeadersHeader is not checked and so eg gifar exploit is possible.
However if jar file is a bit corrupted, then it sometimes can work so this switch can disable the header check.private static DownloadIndicatorindicatordefault download indicatorprivate static java.util.List<java.lang.String>initialArgumentscontains the arguments passed to the jnlp runtimeprivate static booleaninitializedwhether initializedstatic java.lang.ObjectinitMutexmutex to wait on, for initializationprivate static java.lang.StringjnlpPathprivate static LoggerLOGprivate static booleanofflineForcedwhen this is true, ITW will not attempt any inet connections and will work only with what is in cacheprivate static java.lang.BooleanonlineDetectedprivate static java.lang.BooleanpluginDebugwhether plugin debug mode is onprivate static JNLPPolicypolicythe security policyprivate static booleansandboxUnsupportedset when the JVM refused our SecurityManagerprivate static JNLPSecurityManagersecuritythe security managerprivate static SecurityDialogMessageHandlersecurityDialogMessageHandlerhandles all security message to show appropriate security dialogsprivate static booleansecurityEnabledwhether the runtime uses securityprivate static booleanshowWebSplashflag to prevent show the splash screen at start of webstart applicationprivate static booleantrustAllall security dialogs will be consumed and pretented as being verified by user and allowed.private static booleantrustNoneall security dialogs will be consumed and we will pretend the Sandbox NumberOfArguments was chosenprivate static UpdatePolicyupdatePolicyupdate policy that controls when to check for updatesprivate static booleanverifywhether we'll be checking for jar signing
-
Constructor Summary
Constructors Constructor Description JNLPRuntime()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private static voidcheckExitClass()Throws an exception if called with security enabled but a caller is not the exit class and the runtime has been initialized.private static voidcheckHeadless()Check whether the VM is in headless mode.private static voidcheckInitialized()Throws an exception if called when the runtime is already initialized.static voiddetectOnline(java.net.URL location)static voiddisableExit()Disables applets from calling exit.private static voiddoMainAppContextHacks()Performs a few hacks that are needed for the main AppContext see Launcher#doPerApplicationAppContextHacksstatic <T> Texit(int i)static <T> Texit(int i, boolean waitToCloseExceptionDialogs)static ApplicationInstancegetApplication()static DeploymentConfigurationgetConfiguration()Gets the Configuration associated with this runtimestatic DownloadIndicatorgetDefaultDownloadIndicator()static LaunchHandlergetDefaultLaunchHandler()Returns the default launch handler.static UpdatePolicygetDefaultUpdatePolicy()static ExtensionPointgetExtensionPoint()static ForkingStrategygetForksStrategy()private static java.lang.StringgetHistory()Used by java-abrt-connector via reflectionstatic java.util.List<java.lang.String>getInitialArguments()static java.lang.StringgetJnlpPath()static java.lang.StringgetLocalisedTimeStamp(java.util.Date timestamp)static SecurityDialogMessageHandlergetSecurityDialogHandler()static SecurityDialogMessageHandlergetSecurityDialogMessageHandler()Returns the Security Dialog Message Handler.private static javax.net.ssl.TrustManagergetSSLSocketTrustManager()Returns a TrustManager ideal for the running VM.static voidinitialize()Initialize the JNLP runtime environment by installing the security manager and security policy, initializing the JNLP standard services, etc.static booleanisAllowRedirect()static booleanisConnectable(java.net.URL location)static booleanisDebug()static booleanisHeadless()static booleanisIgnoreHeaders()static booleanisInitialized()Returns whether the JNLP runtime environment has been initialized.static booleanisOfflineForced()static booleanisOnline()static booleanisOnlineDetected()private static booleanisPluginDebug()static booleanisSandboxUnsupported()static booleanisSecurityEnabled()Returns whether the secure runtime environment is enabled.static booleanisSetDebug()static booleanisShowWebSplash()static booleanisTrustAll()static booleanisTrustNone()static booleanisUnix()Deprecated.static booleanisVerifying()static voidmarkNetxRunning()Indicate that netx is running by creating theConfigurationConstants.KEY_USER_NETX_RUNNING_FILEand acquiring a shared lock on itprivate static voidmarkNetxStopped()Indicate that netx is stopped by releasing the shared lock onConfigurationConstants.KEY_USER_NETX_RUNNING_FILE.static voidreloadPolicy()static voidsaveHistory(java.lang.String documentBase)static voidsetAllowRedirect(boolean enabled)static voidsetDebug(boolean enabled)Sets whether debug statements for the JNLP client code should be printed to the standard output.static voidsetDefaultDownloadIndicator(DownloadIndicator indicator)Sets the default download indicator.static voidsetDefaultLaunchHandler(LaunchHandler handler)Sets the default launch handler.static voidsetDefaultUpdatePolicy(UpdatePolicy policy)Sets the default update policy.static voidsetExitClass(java.lang.Class<?> exitClass)Set a class that can exit the JVM; if not set then any class can exit the JVM.static voidsetForkingStrategy(ForkingStrategy strategy)static voidsetHeadless(boolean enabled)Sets whether the JNLP client will use any AWT/Swing components.static voidsetIgnoreHeaders(boolean ignoreHeaders)static voidsetInitialArguments(java.util.List<java.lang.String> args)(package private) static voidsetJnlpPath(java.lang.String jnlpPath)static voidsetOfflineForced(boolean b)static voidsetOnlineDetected(boolean online)static voidsetSecurityDialogMessageHandler(SecurityDialogMessageHandler securityDialogMessageHandler)Sets the Security Dialog Message Handler.static voidsetSecurityEnabled(boolean enabled)Sets whether to enable the secure runtime environment.static voidsetShowWebSplash(boolean showWebSplash)static voidsetTrustAll(boolean b)static voidsetTrustNone(boolean b)static voidsetVerify(boolean enabled)Sets whether we will verify code signing.private static SecurityDialogMessageHandlerstartSecurityThreads()This must NOT be called form the application ThreadGroup.static voidwaitForExceptionDialogsToBeClosed()
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
history
private static java.lang.String history
java-abrt-connector can print out specific application String method, it is good to save visited urls for reproduce purposes. For javaws we can read the destination jnlp from commandline However for plugin (url arrive via pipes). Also for plugin we can not be sure which opened tab/window have caused the crash. That's why the individual urls are added, not replaced.
-
security
private static JNLPSecurityManager security
the security manager
-
policy
private static JNLPPolicy policy
the security policy
-
securityDialogMessageHandler
private static SecurityDialogMessageHandler securityDialogMessageHandler
handles all security message to show appropriate security dialogs
-
handler
private static LaunchHandler handler
a default launch handler
-
indicator
private static DownloadIndicator indicator
default download indicator
-
updatePolicy
private static UpdatePolicy updatePolicy
update policy that controls when to check for updates
-
initialized
private static boolean initialized
whether initialized
-
headless
private static boolean headless
whether netx is in command-line mode (headless)
-
headlessChecked
private static boolean headlessChecked
-
verify
private static boolean verify
whether we'll be checking for jar signing
-
securityEnabled
private static boolean securityEnabled
whether the runtime uses security
-
sandboxUnsupported
private static boolean sandboxUnsupported
set when the JVM refused our SecurityManager
-
debug
private static boolean debug
whether debug mode is on
-
pluginDebug
private static java.lang.Boolean pluginDebug
whether plugin debug mode is on
-
initMutex
public static java.lang.Object initMutex
mutex to wait on, for initialization
-
forkingStrategy
private static ForkingStrategy forkingStrategy
set to NEVER to indicate another JVM should not be spawned, even if necessary
-
trustAll
private static boolean trustAll
all security dialogs will be consumed and pretented as being verified by user and allowed.
-
trustNone
private static boolean trustNone
all security dialogs will be consumed and we will pretend the Sandbox NumberOfArguments was chosen
-
allowRedirect
private static boolean allowRedirect
allows 301.302.303.307.308 redirects to be followed when downloading resources
-
offlineForced
private static boolean offlineForced
when this is true, ITW will not attempt any inet connections and will work only with what is in cache
-
onlineDetected
private static java.lang.Boolean onlineDetected
-
ignoreHeaders
private static boolean ignoreHeaders
Header is not checked and so eg gifar exploit is possible.
However if jar file is a bit corrupted, then it sometimes can work so this switch can disable the header check.- See Also:
- Gifar attack
-
initialArguments
private static java.util.List<java.lang.String> initialArguments
contains the arguments passed to the jnlp runtime
-
jnlpPath
private static java.lang.String jnlpPath
-
fileLock
private static java.nio.channels.FileLock fileLock
a lock which is held to indicate that an instance of netx is running
-
showWebSplash
private static boolean showWebSplash
flag to prevent show the splash screen at start of webstart application
-
-
Method Detail
-
isInitialized
public static boolean isInitialized()
Returns whether the JNLP runtime environment has been initialized. Once initialized, some properties such as the base directory cannot be changed. Before- Returns:
- whether this runtime was already initialized
-
initialize
public static void initialize() throws java.lang.IllegalStateExceptionInitialize the JNLP runtime environment by installing the security manager and security policy, initializing the JNLP standard services, etc.This method should be called from the main AppContext/Thread.
This method cannot be called more than once. Once initialized, methods that alter the runtime can only be called by the exit class.
- Throws:
java.lang.IllegalStateException- if the runtime was previously initialized
-
reloadPolicy
public static void reloadPolicy()
-
getSSLSocketTrustManager
private static javax.net.ssl.TrustManager getSSLSocketTrustManager() throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetExceptionReturns a TrustManager ideal for the running VM.- Returns:
- TrustManager the trust manager to use for verifying https certificates
- Throws:
java.lang.ClassNotFoundExceptionjava.lang.IllegalAccessExceptionjava.lang.InstantiationExceptionjava.lang.reflect.InvocationTargetException
-
startSecurityThreads
private static SecurityDialogMessageHandler startSecurityThreads()
This must NOT be called form the application ThreadGroup. An application can inject events into itsEventQueueand bypass the security dialogs.- Returns:
- a
SecurityDialogMessageHandlerthat can be used to post security messages
-
doMainAppContextHacks
private static void doMainAppContextHacks()
Performs a few hacks that are needed for the main AppContext see Launcher#doPerApplicationAppContextHacks
-
setOfflineForced
public static void setOfflineForced(boolean b)
-
isOfflineForced
public static boolean isOfflineForced()
-
setOnlineDetected
public static void setOnlineDetected(boolean online)
-
isOnlineDetected
public static boolean isOnlineDetected()
-
isOnline
public static boolean isOnline()
-
detectOnline
public static void detectOnline(java.net.URL location)
-
isConnectable
public static boolean isConnectable(java.net.URL location)
-
getConfiguration
public static DeploymentConfiguration getConfiguration()
Gets the Configuration associated with this runtime- Returns:
- a
DeploymentConfigurationobject that can be queried to find relevant configuration settings
-
isHeadless
public static boolean isHeadless()
- Returns:
- whether the JNLP client will use any AWT/Swing components.
-
isVerifying
public static boolean isVerifying()
- Returns:
- whether we are verifying code signing.
-
setHeadless
public static void setHeadless(boolean enabled)
Sets whether the JNLP client will use any AWT/Swing components. In headless mode, client features that use the AWT are disabled such that the client can be used in headless mode (java.awt.headless=true).- Parameters:
enabled- true if application do not wont/need gui or X at all- Throws:
java.lang.IllegalStateException- if the runtime was previously initialized
-
setAllowRedirect
public static void setAllowRedirect(boolean enabled)
-
isAllowRedirect
public static boolean isAllowRedirect()
-
setVerify
public static void setVerify(boolean enabled)
Sets whether we will verify code signing.- Parameters:
enabled- true if app should verify signatures- Throws:
java.lang.IllegalStateException- if the runtime was previously initialized
-
isSecurityEnabled
public static boolean isSecurityEnabled()
Returns whether the secure runtime environment is enabled.- Returns:
- true if security manager is created
-
isSandboxUnsupported
public static boolean isSandboxUnsupported()
- Returns:
- true if security is enabled but the JVM cannot enforce it (no SecurityManager); restricted applications must then be refused
-
setSecurityEnabled
public static void setSecurityEnabled(boolean enabled)
Sets whether to enable the secure runtime environment. Disabling security can increase performance for some applications, and can be used to use netx with other code that uses its own security manager or policy.Disabling security is not recommended and should only be used if the JNLP files opened are trusted. This method can only be called before initializing the runtime.
- Parameters:
enabled- whether security should be enabled- Throws:
java.lang.IllegalStateException- if the runtime is already initialized
-
getSecurityDialogHandler
public static SecurityDialogMessageHandler getSecurityDialogHandler()
- Returns:
- the
SecurityDialogMessageHandlerthat should be used to post security dialog messages
-
setExitClass
public static void setExitClass(java.lang.Class<?> exitClass)
Set a class that can exit the JVM; if not set then any class can exit the JVM.- Parameters:
exitClass- a class that can exit the JVM- Throws:
java.lang.IllegalStateException- if caller is not the exit class
-
disableExit
public static void disableExit()
Disables applets from calling exit. Once disabled, exit cannot be re-enabled for the duration of the JVM instance
-
getApplication
public static ApplicationInstance getApplication()
- Returns:
- the current Application, or null if none can be determined.
-
isDebug
public static boolean isDebug()
- Returns:
- whether debug statements for the JNLP client code should be printed.
-
isSetDebug
public static boolean isSetDebug()
-
setDebug
public static void setDebug(boolean enabled)
Sets whether debug statements for the JNLP client code should be printed to the standard output.- Parameters:
enabled- set to true if you need full debug output- Throws:
java.lang.IllegalStateException- if caller is not the exit class
-
setDefaultUpdatePolicy
public static void setDefaultUpdatePolicy(UpdatePolicy policy)
Sets the default update policy.- Parameters:
policy- global update policy of environment- Throws:
java.lang.IllegalStateException- if caller is not the exit class
-
getDefaultUpdatePolicy
public static UpdatePolicy getDefaultUpdatePolicy()
- Returns:
- the default update policy.
-
setDefaultLaunchHandler
public static void setDefaultLaunchHandler(LaunchHandler handler)
Sets the default launch handler.- Parameters:
handler- default handler
-
getDefaultLaunchHandler
public static LaunchHandler getDefaultLaunchHandler()
Returns the default launch handler.- Returns:
- default handler
-
getSecurityDialogMessageHandler
public static SecurityDialogMessageHandler getSecurityDialogMessageHandler()
Returns the Security Dialog Message Handler.- Returns:
- SecurityDialogMessageHandler
-
setSecurityDialogMessageHandler
public static void setSecurityDialogMessageHandler(SecurityDialogMessageHandler securityDialogMessageHandler)
Sets the Security Dialog Message Handler.- Parameters:
securityDialogMessageHandler- handler for Security Dialog messages
-
setDefaultDownloadIndicator
public static void setDefaultDownloadIndicator(DownloadIndicator indicator)
Sets the default download indicator.- Parameters:
indicator- where to show progress- Throws:
java.lang.IllegalStateException- if caller is not the exit class
-
getDefaultDownloadIndicator
public static DownloadIndicator getDefaultDownloadIndicator()
- Returns:
- the default download indicator.
-
getLocalisedTimeStamp
public static java.lang.String getLocalisedTimeStamp(java.util.Date timestamp)
-
getForksStrategy
public static ForkingStrategy getForksStrategy()
- Returns:
trueif the current runtime will fork
-
setForkingStrategy
public static void setForkingStrategy(ForkingStrategy strategy)
-
checkInitialized
private static void checkInitialized()
Throws an exception if called when the runtime is already initialized.
-
checkExitClass
private static void checkExitClass()
Throws an exception if called with security enabled but a caller is not the exit class and the runtime has been initialized.
-
checkHeadless
private static void checkHeadless()
Check whether the VM is in headless mode.
-
isUnix
@Deprecated public static boolean isUnix()
Deprecated.- Returns:
trueif running on a Unix or Unix-like system (including Linux and *BSD)
-
setInitialArguments
public static void setInitialArguments(java.util.List<java.lang.String> args)
-
setJnlpPath
static void setJnlpPath(java.lang.String jnlpPath)
-
getJnlpPath
public static java.lang.String getJnlpPath()
-
getInitialArguments
public static java.util.List<java.lang.String> getInitialArguments()
-
markNetxRunning
public static void markNetxRunning()
Indicate that netx is running by creating theConfigurationConstants.KEY_USER_NETX_RUNNING_FILEand acquiring a shared lock on it
-
markNetxStopped
private static void markNetxStopped()
Indicate that netx is stopped by releasing the shared lock onConfigurationConstants.KEY_USER_NETX_RUNNING_FILE.
-
setTrustAll
public static void setTrustAll(boolean b)
-
isTrustAll
public static boolean isTrustAll()
-
setTrustNone
public static void setTrustNone(boolean b)
-
isTrustNone
public static boolean isTrustNone()
-
isIgnoreHeaders
public static boolean isIgnoreHeaders()
-
setIgnoreHeaders
public static void setIgnoreHeaders(boolean ignoreHeaders)
-
isPluginDebug
private static boolean isPluginDebug()
-
exit
public static <T> T exit(int i, boolean waitToCloseExceptionDialogs)
-
exit
public static <T> T exit(int i)
-
waitForExceptionDialogsToBeClosed
public static void waitForExceptionDialogsToBeClosed()
-
saveHistory
public static void saveHistory(java.lang.String documentBase)
-
getHistory
private static java.lang.String getHistory()
Used by java-abrt-connector via reflection- Returns:
- history
-
setShowWebSplash
public static void setShowWebSplash(boolean showWebSplash)
- Parameters:
showWebSplash- show splash screen at start of webstart application
-
isShowWebSplash
public static boolean isShowWebSplash()
- Returns:
- show splash screen at start of webstart application
-
getExtensionPoint
public static ExtensionPoint getExtensionPoint()
-
-