Class SecurityDesc

java.lang.Object
net.adoptopenjdk.icedteaweb.jnlp.element.security.SecurityDesc

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

    • PROPERTY_READ_ACTION

      private static final String PROPERTY_READ_ACTION
      See Also:
    • PROPERTY_RW_ACTION

      private static final String PROPERTY_RW_ACTION
      See Also:
    • LOG

      private static final Logger LOG
    • SECURITY_ELEMENT

      public static final String SECURITY_ELEMENT
      See Also:
    • applicationPermissionLevel

      private ApplicationPermissionLevel applicationPermissionLevel
    • appletPermissionLevel

      private AppletPermissionLevel appletPermissionLevel
    • ALL_PERMISSIONS

      public static final Object ALL_PERMISSIONS
      All permissions.
    • SANDBOX_PERMISSIONS

      public static final Object SANDBOX_PERMISSIONS
      Applet permissions.
    • J2EE_PERMISSIONS

      public static final Object J2EE_PERMISSIONS
      J2EE permissions.
    • type

      private Object type
      permissions type
    • downloadHost

      private final 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 Policy customTrustedPolicy
    • urlPermissionClass

      private static Class<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 Constructor<Permission> urlPermissionConstructor
    • j2eePermissions

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

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

      private static final Permission[] jnlpRIAPermissions
      basic permissions for restricted mode
      See Also:
  • Constructor Details

    • SecurityDesc

      public SecurityDesc(JNLPFile file, ApplicationPermissionLevel applicationPermissionLevel, Object type, 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, Object type, 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 Details

    • getCustomTrustedPolicy

      private 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 Object getSecurityType()
      Returns:
      the permissions type, one of: ALL, SANDBOX_PERMISSIONS, J2EE_PERMISSIONS.
    • getPermissions

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

      public ApplicationPermissionLevel getApplicationPermissionLevel()
    • getAppletPermissionLevel

      public AppletPermissionLevel getAppletPermissionLevel()
    • getSandBoxPermissions

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

      private Set<Permission> getUrlPermissions()
    • getHostWithSpecifiedPort

      static URI getHostWithSpecifiedPort(URI codebase, int port) throws 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:
      URISyntaxException
    • getHost

      static URI getHost(URI codebase) throws 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:
      URISyntaxException
    • appendRecursiveSubdirToCodebaseHostString

      static String appendRecursiveSubdirToCodebaseHostString(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 String[] getJnlpRIAPermissions()
      Returns:
      all the names of the basic JNLP system properties accessible by RIAs