Class ManifestAttributesReader


  • public class ManifestAttributesReader
    extends java.lang.Object
    This class allows to read the security and configuration attributes specified in the JAR file manifest.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ClasspathMatcher.ClasspathMatchers getApplicationLibraryAllowableCodebase()
      The Application-Library-Allowable-Codebase attribute identifies the locations where your signed RIA is expected to be found.
      java.lang.String getApplicationName()
      The Application-Name attribute is used in security prompts to provide a title for your signed RIA.
      private java.lang.String getAttribute​(java.lang.String name)
      Get the manifest attribute value.
      java.lang.String getAttribute​(java.util.jar.Attributes.Name name)
      Returns the value of the specified manifest attribute name.
      static java.lang.String getAttributeFromJar​(java.util.jar.Attributes.Name name, java.net.URL location, ResourceTracker tracker)
      Returns the value of the specified manifest attribute name, or null if the JAR referenced by the given location URL does not contain a manifest or the attribute could not not be found in the manifest.
      static java.lang.String getAttributeFromJars​(java.util.jar.Attributes.Name name, java.util.List<JARDesc> jars, ResourceTracker tracker)
      Returns the value of the specified manifest attribute name.
      private ManifestBoolean getBooleanAttribute​(java.lang.String name)  
      ClasspathMatcher.ClasspathMatchers getCallerAllowableCodebase()
      The Caller-Allowable-Codebase attribute is used to identify the domains from which JavaScript code can make calls to your RIA without security prompts.
      static java.util.Set<java.lang.String> getClassPaths​(java.util.jar.Manifest manifest, java.net.URL originalJarPathLocation)
      Returns a set of paths that indicate the Class-Path entries in the manifest file.
      ClasspathMatcher.ClasspathMatchers getCodebase()
      The Codebase attribute is used to restrict the code base of the JAR file to specific domains.
      private ClasspathMatcher.ClasspathMatchers getCodeBaseMatchersAttribute​(java.lang.String name, boolean includePath)  
      java.lang.String getEntryPoint()
      The raw string representation (fully qualified class names separated by a space) of the Entry-Point manifest attribute value that can be used as entry point for the RIA.
      java.lang.String[] getEntryPoints()
      The fully qualified class names that can be used as entry point for the RIA.
      java.lang.String getMainClass()
      main class can be defined outside of manifest.
      java.lang.String getMainClass​(java.net.URL location, ResourceTracker resourceTracker)
      Gets the name of the main method as specified in the manifest used for launching applications packaged in JAR files.
      java.lang.String getPermissions()
      The Permissions attribute is used to verify that the permissions level requested by the RIA when it runs matches the permissions level that was set when the JAR file was created.
      boolean isLoader()  
      ManifestBoolean isTrustedLibrary()
      The Trusted-Library attribute is used for applications and applets that are designed to allow untrusted components.
      ManifestBoolean isTrustedOnly()
      The Trusted-Only attribute is used to prevent untrusted classes or resources from being loaded for an applet or application.
      void setLoader​(JNLPClassLoader loader)  
      (package private) static java.lang.String[] splitEntryPoints​(java.lang.String entryPointString)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ManifestAttributesReader

        public ManifestAttributesReader​(JNLPFile jnlpFile)
    • Method Detail

      • isLoader

        public boolean isLoader()
      • getMainClass

        public java.lang.String getMainClass()
        main class can be defined outside of manifest. This method is mostly for completeness
        Returns:
        main-class as it is specified in application
      • getEntryPoint

        public java.lang.String getEntryPoint()
        The raw string representation (fully qualified class names separated by a space) of the Entry-Point manifest attribute value that can be used as entry point for the RIA.
        Returns:
        the Entry-Point manifest attribute value
        See Also:
        for a tokenized representation of the entry points
      • getEntryPoints

        public java.lang.String[] getEntryPoints()
        The fully qualified class names that can be used as entry point for the RIA.
        Returns:
        the Entry-Point class names
      • splitEntryPoints

        static java.lang.String[] splitEntryPoints​(java.lang.String entryPointString)
      • getApplicationName

        public java.lang.String getApplicationName()
        The Application-Name attribute is used in security prompts to provide a title for your signed RIA. Use of this attribute is recommended to help users make the decision to trust and run the RIA.
        Returns:
        value of Application-Name manifest attribute
      • getCallerAllowableCodebase

        public ClasspathMatcher.ClasspathMatchers getCallerAllowableCodebase()
        The Caller-Allowable-Codebase attribute is used to identify the domains from which JavaScript code can make calls to your RIA without security prompts. Set this attribute to the domain that hosts the JavaScript code.
        Returns:
        values of Caller-Allowable-Codebase manifest attribute
      • getApplicationLibraryAllowableCodebase

        public ClasspathMatcher.ClasspathMatchers getApplicationLibraryAllowableCodebase()
        The Application-Library-Allowable-Codebase attribute identifies the locations where your signed RIA is expected to be found.
        Returns:
        values of Application-Library-Allowable-Codebase manifest attribute
      • getCodebase

        public ClasspathMatcher.ClasspathMatchers getCodebase()
        The Codebase attribute is used to restrict the code base of the JAR file to specific domains. Use this attribute to prevent someone from re-deploying your application on another website for malicious purposes.
        Returns:
        values of Codebase manifest attribute
      • isTrustedOnly

        public ManifestBoolean isTrustedOnly()
        The Trusted-Only attribute is used to prevent untrusted classes or resources from being loaded for an applet or application.
        Returns:
        value of Trusted-Only manifest attribute
      • isTrustedLibrary

        public ManifestBoolean isTrustedLibrary()
        The Trusted-Library attribute is used for applications and applets that are designed to allow untrusted components.
        Returns:
        value of Trusted-Library manifest attribute
      • getPermissions

        public java.lang.String getPermissions()
        The Permissions attribute is used to verify that the permissions level requested by the RIA when it runs matches the permissions level that was set when the JAR file was created.
        Returns:
        value of Permissions manifest attribute
      • getAttribute

        private java.lang.String getAttribute​(java.lang.String name)
        Get the manifest attribute value.
      • getAttribute

        public java.lang.String getAttribute​(java.util.jar.Attributes.Name name)
        Returns the value of the specified manifest attribute name.
        Parameters:
        name - name of the manifest attribute to find in application
        Returns:
        plain attribute value
      • getBooleanAttribute

        private ManifestBoolean getBooleanAttribute​(java.lang.String name)
                                             throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • getAttributeFromJars

        public static java.lang.String getAttributeFromJars​(java.util.jar.Attributes.Name name,
                                                            java.util.List<JARDesc> jars,
                                                            ResourceTracker tracker)
        Returns the value of the specified manifest attribute name. To do so, the given jar files are consulted in the following order: "main" jar in the given list, first jar in the given list, all jars in the given list.
        Parameters:
        name - attribute to be found
        jars - Jars that are checked to see if they contain the main class
        tracker - tracker to use for the jar file lookup
        Returns:
        the attribute value, null if no attribute could be found for some reason
      • getAttributeFromJar

        public static java.lang.String getAttributeFromJar​(java.util.jar.Attributes.Name name,
                                                           java.net.URL location,
                                                           ResourceTracker tracker)
        Returns the value of the specified manifest attribute name, or null if the JAR referenced by the given location URL does not contain a manifest or the attribute could not not be found in the manifest.
        Parameters:
        name - name of the attribute to find
        location - The JAR location
        tracker - resource tracker to use for the jar file lookup
        Returns:
        the attribute value, null if no attribute could be found for some reason
      • getMainClass

        public java.lang.String getMainClass​(java.net.URL location,
                                             ResourceTracker resourceTracker)
        Gets the name of the main method as specified in the manifest used for launching applications packaged in JAR files.
        Parameters:
        location - The JAR location
        Returns:
        the main class name, null if there isn't one of if there was an error
      • getClassPaths

        public static java.util.Set<java.lang.String> getClassPaths​(java.util.jar.Manifest manifest,
                                                                    java.net.URL originalJarPathLocation)
        Returns a set of paths that indicate the Class-Path entries in the manifest file. The paths are rooted in the same directory as the originalJarPath.
        Parameters:
        manifest - the manifest
        originalJarPathLocation - the remote/original path of the jar containing the manifest
        Returns:
        a Set of String where each string is a path to the jar on the original jar's classpath.