Class JNLPFile
- java.lang.Object
-
- net.sourceforge.jnlp.JNLPFile
-
public class JNLPFile extends java.lang.ObjectProvides methods to access the information in a Java Network Launching Protocol (JNLP) file. The Java Network Launching Protocol specifies in an XML file the information needed to load, cache, and run Java code over the network and in a secure environment.
This class represents the overall information about a JNLP file from the jnlp element. Other information is accessed through objects that represent the elements of a JNLP file (information, resources, application-desc, etc). References to these objects are obtained by calling the getInformation, getResources, getSecurity, etc methods.
- Version:
- $Revision: 1.21 $
-
-
Field Summary
Fields Modifier and Type Field Description protected java.net.URLcodeBasethe URL used to resolve relative URLs in the filestatic java.lang.StringCODEBASE_ATTRIBUTEprotected ComponentDesccomponentthe component descriptionprivate booleancontainsSpecialPropertiesJNLP file contains special propertiesprotected java.lang.StringdefaultArchthe default archprotected java.util.LocaledefaultLocalethe default JVM localeprotected java.lang.StringdefaultOSthe default OSprotected EntryPointentryPointDescthe application entry pointprivate static java.lang.StringFAKE_TITLEprotected java.net.URLfileLocationthe network location of this JNLP fileprotected VersionIdfileVersionThe version attribute of the jnlp element specifies the version of the application being launched, as well as the version of the JNLP file itself.private java.lang.String[]generalPropertiesList of acceptable properties (not-special)static java.lang.StringHREF_ATTRIBUTEprotected java.util.List<InformationDesc>infosinformationstatic java.lang.StringJNLP_ROOT_ELEMENTprivate static LoggerLOGprivate ManifestAttributesReadermanifestAttributesReaderimportant manifests' attributesprivate booleanmissingSignedJNLPA signed JNLP file is missing from the main jarprotected ParserSettingsparserSettingsthe ParserSettings which were used to parse this fileprotected java.util.List<ResourcesDesc>resourcesresourcesprotected SecurityDescsecuritythe security descriptorprotected ResourcesDescsharedResourcesadditional resources not in JNLP file (from command line)protected java.net.URLsourceLocationthe location this JNLP file was created fromstatic java.lang.StringSPEC_ATTRIBUTEstatic java.lang.StringSPEC_VERSION_DEFAULTprotected VersionStringspecVersionSpecifies the versions of the specification that this JNLP file requires.private static java.lang.StringTITLE_NOT_FOUNDprotected java.lang.StringuniqueKeyA key that uniquely identifies connected instances (main jnlp+ext)protected UpdateDescupdatestatic java.lang.StringVERSION_ATTRIBUTE
-
Constructor Summary
Constructors Modifier Constructor Description protectedJNLPFile()Empty stub, allowing child classes to override the constructorJNLPFile(java.io.InputStream input, java.net.URL codebase, ParserSettings settings)Create a JNLPFile from an input stream.(package private)JNLPFile(java.io.InputStream input, java.net.URL location, ParserSettings settings, java.lang.String uniqueKey)Create a JNLPFile from a URL and a version, checking for updates using the specified policy.JNLPFile(java.io.InputStream input, ParserSettings settings)Create a JNLPFile from an input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckForSpecialProperties()Inspects the JNLP file to check if it contains any special propertiesprivate java.lang.StringcreateShortcutNameFromLocation()AppletDescgetApplet()AppletPermissionLevelgetAppletPermissionLevel()ApplicationDescgetApplication()ApplicationPermissionLevelgetApplicationPermissionLevel()java.net.URLgetCodeBase()ComponentDescgetComponent()DownloadOptionsgetDownloadOptions()EntryPointgetEntryPointDesc()java.net.URLgetFileLocation()VersionIdgetFileVersion()InformationDescgetInformation()InformationDescgetInformation(java.util.Locale locale)InformationDescgetInformation(java.util.Locale locale, java.lang.String os, java.lang.String arch)InstallerDescgetInstaller()ManifestAttributesReadergetManifestAttributesReader()java.util.List<java.lang.String>getNewVMArgs()java.net.URLgetNotNullProbableCodeBase()It is not recommended to use this method for internals of itw - use normal getCodeBase rather, as null is expected always except toString calls.ParserSettingsgetParserSettings()ResourcesDescgetResources()ResourcesDescgetResources(java.util.Locale locale, java.lang.String os, java.lang.String arch)ResourcesDesc[]getResourcesDescs()private java.util.List<ResourcesDesc>getResourcesDescs(java.util.Locale locale, java.lang.String os, java.lang.String arch)SecurityDescgetSecurity()java.lang.StringgetShortcutName()java.net.URLgetSourceLocation()VersionStringgetSpecVersion()Returns the versions of the specification that this JNLP file requires.java.lang.StringgetTitle()java.lang.StringgetTitle(boolean kill)java.lang.StringgetTitleFromJnlp()java.lang.StringgetTitleFromManifest()private java.lang.StringgetTitleImpl()java.lang.StringgetUniqueKey()UpdateDescgetUpdate()java.lang.StringgetVendor()java.lang.StringgetVendor(boolean kill)private java.lang.StringgetVendorImpl()booleanisApplet()booleanisApplication()booleanisComponent()booleanisInstaller()booleanneedsNewVM()private voidparse(java.io.InputStream input, java.net.URL location, java.net.URL forceCodebase)Initialize the JNLPFile fields.booleanrequiresSignedJNLPWarning()Returns a boolean after determining if a signed JNLP warning should be displayed in the 'More Information' panel.voidsetDefaults(java.lang.String os, java.lang.String arch, java.util.Locale locale)Sets the default view of the JNLP file returned by getInformation, getResources, etc.voidsetSignedJNLPAsMissing()Informs that a signed JNLP file is missing in the main jar
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
JNLP_ROOT_ELEMENT
public static final java.lang.String JNLP_ROOT_ELEMENT
- See Also:
- Constant Field Values
-
SPEC_ATTRIBUTE
public static final java.lang.String SPEC_ATTRIBUTE
- See Also:
- Constant Field Values
-
VERSION_ATTRIBUTE
public static final java.lang.String VERSION_ATTRIBUTE
- See Also:
- Constant Field Values
-
HREF_ATTRIBUTE
public static final java.lang.String HREF_ATTRIBUTE
- See Also:
- Constant Field Values
-
CODEBASE_ATTRIBUTE
public static final java.lang.String CODEBASE_ATTRIBUTE
- See Also:
- Constant Field Values
-
SPEC_VERSION_DEFAULT
public static final java.lang.String SPEC_VERSION_DEFAULT
- See Also:
- Constant Field Values
-
sourceLocation
protected java.net.URL sourceLocation
the location this JNLP file was created from
-
fileLocation
protected final java.net.URL fileLocation
the network location of this JNLP file
-
parserSettings
protected final ParserSettings parserSettings
the ParserSettings which were used to parse this file
-
uniqueKey
protected final java.lang.String uniqueKey
A key that uniquely identifies connected instances (main jnlp+ext)
-
codeBase
protected java.net.URL codeBase
the URL used to resolve relative URLs in the file
-
fileVersion
protected VersionId fileVersion
The version attribute of the jnlp element specifies the version of the application being launched, as well as the version of the JNLP file itself.
-
specVersion
protected VersionString specVersion
Specifies the versions of the specification that this JNLP file requires. The value of the attribute is specified as a version string, see JSR-56, section 3.1
-
infos
protected java.util.List<InformationDesc> infos
information
-
update
protected UpdateDesc update
-
resources
protected java.util.List<ResourcesDesc> resources
resources
-
sharedResources
protected final ResourcesDesc sharedResources
additional resources not in JNLP file (from command line)
-
entryPointDesc
protected EntryPoint entryPointDesc
the application entry point
-
component
protected ComponentDesc component
the component description
-
security
protected SecurityDesc security
the security descriptor
-
defaultLocale
protected java.util.Locale defaultLocale
the default JVM locale
-
defaultOS
protected java.lang.String defaultOS
the default OS
-
defaultArch
protected java.lang.String defaultArch
the default arch
-
missingSignedJNLP
private boolean missingSignedJNLP
A signed JNLP file is missing from the main jar
-
containsSpecialProperties
private boolean containsSpecialProperties
JNLP file contains special properties
-
generalProperties
private final java.lang.String[] generalProperties
List of acceptable properties (not-special)
-
manifestAttributesReader
private final ManifestAttributesReader manifestAttributesReader
important manifests' attributes
-
TITLE_NOT_FOUND
private static final java.lang.String TITLE_NOT_FOUND
- See Also:
- Constant Field Values
-
FAKE_TITLE
private static final java.lang.String FAKE_TITLE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JNLPFile
protected JNLPFile()
Empty stub, allowing child classes to override the constructor
-
JNLPFile
JNLPFile(java.io.InputStream input, java.net.URL location, ParserSettings settings, java.lang.String uniqueKey) throws java.io.IOException, ParseExceptionCreate a JNLPFile from a URL and a version, checking for updates using the specified policy.- Parameters:
location- the location of the JNLP filesettings- the parser settings to use while parsing the file- Throws:
java.io.IOException- if an IO exception occurredParseException- if the JNLP file was invalid
-
JNLPFile
public JNLPFile(java.io.InputStream input, ParserSettings settings) throws ParseExceptionCreate a JNLPFile from an input stream.- Parameters:
input- input stream from which create jnlp filesettings- settings of parser- Throws:
ParseException- if the JNLP file was invalid
-
JNLPFile
public JNLPFile(java.io.InputStream input, java.net.URL codebase, ParserSettings settings) throws ParseExceptionCreate a JNLPFile from an input stream.- Parameters:
input- input stream of JNLP file.codebase- codebase to use if not specified in JNLP file..settings- theParserSettingsto use when parsing- Throws:
ParseException- if the JNLP file was invalid
-
-
Method Detail
-
getTitle
public java.lang.String getTitle()
- Returns:
- the JNLP file's best localized title. This method returns the same
value as InformationDesc.getTitle().
Since jdk7 u45, also manifest title, and mainclass are taken to consideration; See PluginBridge
-
getTitle
public java.lang.String getTitle(boolean kill) throws MissingTitleException- Throws:
MissingTitleException
-
getTitleImpl
private java.lang.String getTitleImpl()
-
getTitleFromJnlp
public java.lang.String getTitleFromJnlp()
- Returns:
- the JNLP file's best localized title. This method returns the same value as InformationDesc.getTitle().
-
getTitleFromManifest
public java.lang.String getTitleFromManifest()
-
getVendor
public java.lang.String getVendor()
- Returns:
- the JNLP file's best localized vendor. This method returns the same value as InformationDesc.getVendor().
-
getVendor
public java.lang.String getVendor(boolean kill) throws MissingVendorException- Throws:
MissingVendorException
-
getVendorImpl
private java.lang.String getVendorImpl()
-
getSourceLocation
public java.net.URL getSourceLocation()
- Returns:
- the JNLP file's network location as specified in the JNLP file.
-
getFileLocation
public java.net.URL getFileLocation()
- Returns:
- the location of the file parsed to create the JNLP file, or null if it was not created from a URL.
-
getUniqueKey
public java.lang.String getUniqueKey()
- Returns:
- the location of the parent file if it exists, null otherwise
-
getParserSettings
public ParserSettings getParserSettings()
- Returns:
- the ParserSettings that was used to parse this file
-
getFileVersion
public VersionId getFileVersion()
- Returns:
- the JNLP file's version.
-
getSpecVersion
public VersionString getSpecVersion()
Returns the versions of the specification that this JNLP file requires. The value of the attribute is specified as a version string, see JSR-56, section 3.1- Returns:
- the versions of the specification that this JNLP file requires.
-
getCodeBase
public java.net.URL getCodeBase()
- Returns:
- the codebase URL for the JNLP file.
-
getNotNullProbableCodeBase
public java.net.URL getNotNullProbableCodeBase()
It is not recommended to use this method for internals of itw - use normal getCodeBase rather, as null is expected always except toString calls.If you are not sure, use getCodeBase and check null as you need. See that this method is used mostly for xtendedAppletSecuriyty dialogs.
- Returns:
- the codebase URL for the JNLP file or url of location of calling file (jnlp, hreffed jnlp, or directly html)
-
getInformation
public InformationDesc getInformation()
- Returns:
- the information section of the JNLP file as viewed through the default locale.
-
getInformation
public InformationDesc getInformation(java.util.Locale locale)
- Parameters:
locale- preferred locale of information element- Returns:
- the information section of the JNLP file as viewed through the specified locale.
-
getInformation
public InformationDesc getInformation(java.util.Locale locale, java.lang.String os, java.lang.String arch)
- Parameters:
locale- preferred locale of information elementos- preferred os of information elementarch- preferred arch of information element- Returns:
- the information section of the JNLP file as viewed through the specified locale.
-
getUpdate
public UpdateDesc getUpdate()
- Returns:
- the update section of the JNLP file.
-
getSecurity
public SecurityDesc getSecurity()
- Returns:
- the security section of the JNLP file.
-
getApplicationPermissionLevel
public ApplicationPermissionLevel getApplicationPermissionLevel()
- Returns:
- the requested security level of the application represented by this JNLP file.
-
getAppletPermissionLevel
public AppletPermissionLevel getAppletPermissionLevel()
- Returns:
- the requested security level of the applet represented by this JNLP file.
-
getResources
public ResourcesDesc getResources()
- Returns:
- the resources section of the JNLP file as viewed through the default locale and the os.name and os.arch properties.
-
getResources
public ResourcesDesc getResources(java.util.Locale locale, java.lang.String os, java.lang.String arch)
- Parameters:
locale- preferred locale of resourceos- preferred os of resourcearch- preferred arch of resource- Returns:
- the resources section of the JNLP file for the specified locale, os, and arch.
-
getResourcesDescs
public ResourcesDesc[] getResourcesDescs()
- Returns:
- the resources section of the JNLP file as viewed through the default locale and the os.name and os.arch properties. XXX: Before overriding this method or changing its implementation, read the comment in JNLPFile.getDownloadOptionsForJar(JARDesc).
-
getResourcesDescs
private java.util.List<ResourcesDesc> getResourcesDescs(java.util.Locale locale, java.lang.String os, java.lang.String arch)
-
getEntryPointDesc
public EntryPoint getEntryPointDesc()
- Returns:
- an object of one of the following types: AppletDesc, ApplicationDesc and InstallerDesc
-
getApplet
public AppletDesc getApplet()
- Returns:
- the launch information for an applet.
- Throws:
java.lang.UnsupportedOperationException- if there is no applet information
-
getApplication
public ApplicationDesc getApplication()
- Returns:
- the launch information for an application.
- Throws:
java.lang.UnsupportedOperationException- if there is no application information
-
getComponent
public ComponentDesc getComponent()
- Returns:
- the launch information for a component.
- Throws:
java.lang.UnsupportedOperationException- if there is no component information
-
getInstaller
public InstallerDesc getInstaller()
- Returns:
- the launch information for an installer.
- Throws:
java.lang.UnsupportedOperationException- if there is no installer information
-
isApplet
public boolean isApplet()
- Returns:
- whether the launch descriptor describes an Applet.
-
isApplication
public boolean isApplication()
- Returns:
- whether the launch descriptor describes an Application.
-
isComponent
public boolean isComponent()
- Returns:
- whether the launch descriptor describes a Component.
-
isInstaller
public boolean isInstaller()
- Returns:
- whether the launch descriptor describes an Installer.
-
setDefaults
public void setDefaults(java.lang.String os, java.lang.String arch, java.util.Locale locale)Sets the default view of the JNLP file returned by getInformation, getResources, etc. If unset, the defaults are the properties os.name, os.arch, and the locale returned by Locale.getDefault().- Parameters:
os- preferred os of resourcearch- preferred arch of resourcelocale- preferred locale of resource
-
parse
private void parse(java.io.InputStream input, java.net.URL location, java.net.URL forceCodebase) throws ParseExceptionInitialize the JNLPFile fields. Private because it's called from the constructor.- Parameters:
location- the file location ornull- Throws:
ParseException
-
checkForSpecialProperties
private void checkForSpecialProperties()
Inspects the JNLP file to check if it contains any special properties
-
needsNewVM
public boolean needsNewVM()
- Returns:
- true if the JNLP file specifies things that can only be applied on a new vm (eg: different max heap memory)
-
getNewVMArgs
public java.util.List<java.lang.String> getNewVMArgs()
- Returns:
- a list of args to pass to the new JVM based on this JNLP file
-
getDownloadOptions
public DownloadOptions getDownloadOptions()
- Returns:
- the download options to use for downloading jars listed in this jnlp file.
-
requiresSignedJNLPWarning
public boolean requiresSignedJNLPWarning()
Returns a boolean after determining if a signed JNLP warning should be displayed in the 'More Information' panel.- Returns:
- true if a warning should be displayed; otherwise false
-
setSignedJNLPAsMissing
public void setSignedJNLPAsMissing()
Informs that a signed JNLP file is missing in the main jar
-
getManifestAttributesReader
public ManifestAttributesReader getManifestAttributesReader()
-
createShortcutNameFromLocation
private java.lang.String createShortcutNameFromLocation()
-
getShortcutName
public java.lang.String getShortcutName()
-
-