Class SecurityDesc


  • public class SecurityDesc
    extends java.lang.Object
    The security element.
    Version:
    $Revision: 1.7 $
    • Field Detail

      • PROPERTY_READ_ACTION

        private static final java.lang.String PROPERTY_READ_ACTION
        See Also:
        Constant Field Values
      • PROPERTY_RW_ACTION

        private static final java.lang.String PROPERTY_RW_ACTION
        See Also:
        Constant Field Values
      • LOG

        private static final Logger LOG
      • SECURITY_ELEMENT

        public static final java.lang.String SECURITY_ELEMENT
        See Also:
        Constant Field Values
      • ALL_PERMISSIONS

        public static final java.lang.Object ALL_PERMISSIONS
        All permissions.
      • SANDBOX_PERMISSIONS

        public static final java.lang.Object SANDBOX_PERMISSIONS
        Applet permissions.
      • J2EE_PERMISSIONS

        public static final java.lang.Object J2EE_PERMISSIONS
        J2EE permissions.
      • type

        private java.lang.Object type
        permissions type
      • downloadHost

        private final java.net.URL downloadHost
        the download host
      • grantAwtPermissions

        private final boolean grantAwtPermissions
        whether sandbox applications should get the show window without banner permission
      • file

        private final JNLPFile file
        the JNLP file
      • customTrustedPolicy

        private final java.security.Policy customTrustedPolicy
      • urlPermissionClass

        private static java.lang.Class<java.security.Permission> urlPermissionClass
        URLPermission is new in Java 8, so we use reflection to check for it to keep compatibility with Java 6/7. If we can't find the class or fail to construct it then we continue as usual without. These are saved as fields so that the reflective lookup only needs to be performed once when the SecurityDesc is constructed, rather than every time a call is made to getSandBoxPermissions(), which is called frequently.
      • urlPermissionConstructor

        private static java.lang.reflect.Constructor<java.security.Permission> urlPermissionConstructor
      • j2eePermissions

        private static final java.security.Permission[] j2eePermissions
        basic permissions for restricted mode
      • sandboxPermissions

        private static final java.security.Permission[] sandboxPermissions
        basic permissions for restricted mode
      • jnlpRIAPermissions

        private static final java.security.Permission[] jnlpRIAPermissions
        basic permissions for restricted mode
        See Also:
        Secure System Properties
    • Constructor Detail

      • SecurityDesc

        public SecurityDesc​(JNLPFile file,
                            ApplicationPermissionLevel applicationPermissionLevel,
                            java.lang.Object type,
                            java.net.URL downloadHost)
        Create a security descriptor.
        Parameters:
        file - the JNLP file
        applicationPermissionLevel - the permissions specified in the JNLP
        type - the type of security
        downloadHost - the download host (can always connect to)
      • SecurityDesc

        public SecurityDesc​(JNLPFile file,
                            AppletPermissionLevel appletPermissionLevel,
                            java.lang.Object type,
                            java.net.URL downloadHost)
        Create a security descriptor.
        Parameters:
        file - the JNLP file
        appletPermissionLevel - the permissions specified in the JNLP
        type - the type of security
        downloadHost - the download host (can always connect to)
    • Method Detail

      • getCustomTrustedPolicy

        private java.security.Policy getCustomTrustedPolicy()
        Returns a Policy object that represents a custom policy to use instead of granting AllPermission to a CodeSource
        Returns:
        a Policy object to delegate to. May be null, which indicates that no policy exists and AllPermissions should be granted instead.
      • getSecurityType

        public java.lang.Object getSecurityType()
        Returns:
        the permissions type, one of: ALL, SANDBOX_PERMISSIONS, J2EE_PERMISSIONS.
      • getPermissions

        public java.security.PermissionCollection getPermissions​(java.security.CodeSource cs)
        Parameters:
        cs - the CodeSource to get permissions for
        Returns:
        a PermissionCollection containing the basic permissions granted depending on the security type.
      • getSandBoxPermissions

        public java.security.PermissionCollection getSandBoxPermissions()
        Returns:
        a PermissionCollection containing the sandbox permissions
      • getUrlPermissions

        private java.util.Set<java.security.Permission> getUrlPermissions()
      • getHostWithSpecifiedPort

        static java.net.URI getHostWithSpecifiedPort​(java.net.URI codebase,
                                                     int port)
                                              throws java.net.URISyntaxException
        Gets the host domain part of an applet's codebase. Removes path, query, and fragment, but preserves scheme, user info, and host. The port used is overridden with the specified port.
        Parameters:
        codebase - the applet codebase URL
        port -
        Returns:
        the host domain of the codebase
        Throws:
        java.net.URISyntaxException
      • getHost

        static java.net.URI getHost​(java.net.URI codebase)
                             throws java.net.URISyntaxException
        Gets the host domain part of an applet's codebase. Removes path, query, and fragment, but preserves scheme, user info, host, and port.
        Parameters:
        codebase - the applet codebase URL
        Returns:
        the host domain of the codebase
        Throws:
        java.net.URISyntaxException
      • appendRecursiveSubdirToCodebaseHostString

        static java.lang.String appendRecursiveSubdirToCodebaseHostString​(java.lang.String codebaseHost)
        Appends a recursive access marker to a codebase host, for granting Java 8 URLPermissions which are no more restrictive than the existing SocketPermissions See http://docs.oracle.com/javase/8/docs/api/java/net/URLPermission.html
        Parameters:
        codebaseHost - the applet's codebase's host domain URL as a String. Expected to be formatted as eg "http://example.com:8080" or "http://example.com/"
        Returns:
        the resulting String eg "http://example.com:8080/-
      • getJnlpRIAPermissions

        public static java.lang.String[] getJnlpRIAPermissions()
        Returns:
        all the names of the basic JNLP system properties accessible by RIAs