Package net.sourceforge.jnlp.services
Class ServiceUtil
- java.lang.Object
-
- net.sourceforge.jnlp.services.ServiceUtil
-
public class ServiceUtil extends java.lang.ObjectProvides static methods to interact useful for using the JNLP services.- Version:
- $Revision: 1.8 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classServiceUtil.PrivilegedHandlercalls the object's method using privileged access
-
Constructor Summary
Constructors Constructor Description ServiceUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancheckAccess(ApplicationInstance app, AccessType type, java.lang.Object... extras)Returns whether the app requesting a JNLP service has the right permissions.static booleancheckAccess(AccessType type, java.lang.Object... extras)Returns whether the app requesting a JNLP service has the right permissions.static voidcheckExistingSingleInstance(JNLPFile jnlpFile)Checks that this application (represented by the jnlp) isn't already running(package private) static java.lang.ObjectcreatePrivilegedProxy(java.lang.Class<?> iface, java.lang.Object receiver)Creates a Proxy object implementing the specified interface when makes all calls in the security context of the system classes (ie, AllPermissions).static BasicServicegetBasicService()static ClipboardServicegetClipboardService()static DownloadServicegetDownloadService()static DownloadService2getDownloadService2()static ExtensionInstallerServicegetExtensionInstallerService()static FileOpenServicegetFileOpenService()static FileSaveServicegetFileSaveService()static PersistenceServicegetPersistenceService()static PrintServicegetPrintService()private static java.lang.ObjectgetService(java.lang.String name)Returns the service, or null instead of an UnavailableServiceExceptionstatic SingleInstanceServicegetSingleInstanceService()static booleanisSigned(ApplicationInstance app)Returns whether the app requesting a JNLP service is a trusted applicationprivate static booleanshouldPromptUser()Returns whether the current runtime configuration allows prompting the user for JNLP permissions.
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
-
Method Detail
-
getBasicService
public static BasicService getBasicService()
- Returns:
- the BasicService reference, or null if the service is unavailable.
-
getClipboardService
public static ClipboardService getClipboardService()
- Returns:
- the ClipboardService reference, or null if the service is unavailable.
-
getDownloadService
public static DownloadService getDownloadService()
- Returns:
- the DownloadService reference, or null if the service is unavailable.
-
getDownloadService2
public static DownloadService2 getDownloadService2()
- Returns:
- the DownloadService reference, or null if the service is unavailable.
-
getExtensionInstallerService
public static ExtensionInstallerService getExtensionInstallerService()
- Returns:
- the ExtensionInstallerService reference, or null if the service is unavailable.
-
getFileOpenService
public static FileOpenService getFileOpenService()
- Returns:
- the FileOpenService reference, or null if the service is unavailable.
-
getFileSaveService
public static FileSaveService getFileSaveService()
- Returns:
- the FileSaveService reference, or null if the service is unavailable.
-
getPersistenceService
public static PersistenceService getPersistenceService()
- Returns:
- the PersistenceService reference, or null if the service is unavailable.
-
getPrintService
public static PrintService getPrintService()
- Returns:
- the PrintService reference, or null if the service is unavailable.
-
getSingleInstanceService
public static SingleInstanceService getSingleInstanceService()
- Returns:
- the SingleInstanceService reference, or null if the service is unavailable.
-
checkExistingSingleInstance
public static void checkExistingSingleInstance(JNLPFile jnlpFile)
Checks that this application (represented by the jnlp) isn't already running- Parameters:
jnlpFile- theJNLPFilethat specifies the application- Throws:
InstanceExistsException- if an instance of this application already exists
-
getService
private static java.lang.Object getService(java.lang.String name)
Returns the service, or null instead of an UnavailableServiceException
-
createPrivilegedProxy
static java.lang.Object createPrivilegedProxy(java.lang.Class<?> iface, java.lang.Object receiver)Creates a Proxy object implementing the specified interface when makes all calls in the security context of the system classes (ie, AllPermissions). This means that the services must be more than extremely careful in the operations they perform.
-
checkAccess
public static boolean checkAccess(AccessType type, java.lang.Object... extras)
Returns whether the app requesting a JNLP service has the right permissions. If it doesn't, user is prompted for permissions. This method should only be used for JNLP API related permissions.- Parameters:
type- the type of access being requestedextras- extra Strings (usually) that are passed to the dialog for message formatting.- Returns:
- true if the access was granted, false otherwise.
-
checkAccess
public static boolean checkAccess(ApplicationInstance app, AccessType type, java.lang.Object... extras)
Returns whether the app requesting a JNLP service has the right permissions. If it doesn't, user is prompted for permissions. This method should only be used for JNLP API related permissions.- Parameters:
app- the application which is requesting the check. If null, the current application is used.type- the type of access being requestedextras- extra Strings (usually) that are passed to the dialog for message formatting.- Returns:
- true if the access was granted, false otherwise.
-
shouldPromptUser
private static boolean shouldPromptUser()
Returns whether the current runtime configuration allows prompting the user for JNLP permissions.- Returns:
- true if the user should be prompted for JNLP API related permissions.
-
isSigned
public static boolean isSigned(ApplicationInstance app)
Returns whether the app requesting a JNLP service is a trusted application- Parameters:
app- the application which is requesting the check. If null, the current application is used.- Returns:
- true, if the app is a trusted application; false otherwise
-
-