Class SecurityDesc
- java.lang.Object
-
- net.adoptopenjdk.icedteaweb.jnlp.element.security.SecurityDesc
-
public class SecurityDesc extends java.lang.ObjectThe security element.- Version:
- $Revision: 1.7 $
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.ObjectALL_PERMISSIONSAll permissions.private AppletPermissionLevelappletPermissionLevelprivate ApplicationPermissionLevelapplicationPermissionLevelprivate java.security.PolicycustomTrustedPolicyprivate java.net.URLdownloadHostthe download hostprivate JNLPFilefilethe JNLP fileprivate booleangrantAwtPermissionswhether sandbox applications should get the show window without banner permissionstatic java.lang.ObjectJ2EE_PERMISSIONSJ2EE permissions.private static java.security.Permission[]j2eePermissionsbasic permissions for restricted modeprivate static java.security.Permission[]jnlpRIAPermissionsbasic permissions for restricted modeprivate static LoggerLOGprivate static java.lang.StringPROPERTY_READ_ACTIONprivate static java.lang.StringPROPERTY_RW_ACTIONstatic java.lang.ObjectSANDBOX_PERMISSIONSApplet permissions.private static java.security.Permission[]sandboxPermissionsbasic permissions for restricted modestatic java.lang.StringSECURITY_ELEMENTprivate java.lang.Objecttypepermissions typeprivate static java.lang.Class<java.security.Permission>urlPermissionClassURLPermission is new in Java 8, so we use reflection to check for it to keep compatibility with Java 6/7.private static java.lang.reflect.Constructor<java.security.Permission>urlPermissionConstructor
-
Constructor Summary
Constructors Constructor Description SecurityDesc(JNLPFile file, AppletPermissionLevel appletPermissionLevel, java.lang.Object type, java.net.URL downloadHost)Create a security descriptor.SecurityDesc(JNLPFile file, ApplicationPermissionLevel applicationPermissionLevel, java.lang.Object type, java.net.URL downloadHost)Create a security descriptor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.StringappendRecursiveSubdirToCodebaseHostString(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.htmlAppletPermissionLevelgetAppletPermissionLevel()ApplicationPermissionLevelgetApplicationPermissionLevel()private java.security.PolicygetCustomTrustedPolicy()Returns a Policy object that represents a custom policy to use instead of grantingAllPermissionto aCodeSource(package private) static java.net.URIgetHost(java.net.URI codebase)Gets the host domain part of an applet's codebase.(package private) static java.net.URIgetHostWithSpecifiedPort(java.net.URI codebase, int port)Gets the host domain part of an applet's codebase.static java.lang.String[]getJnlpRIAPermissions()java.security.PermissionCollectiongetPermissions(java.security.CodeSource cs)java.security.PermissionCollectiongetSandBoxPermissions()java.lang.ObjectgetSecurityType()private java.util.Set<java.security.Permission>getUrlPermissions()
-
-
-
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
-
applicationPermissionLevel
private ApplicationPermissionLevel applicationPermissionLevel
-
appletPermissionLevel
private AppletPermissionLevel appletPermissionLevel
-
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 togetSandBoxPermissions(), 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 fileapplicationPermissionLevel- the permissions specified in the JNLPtype- the type of securitydownloadHost- 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 fileappletPermissionLevel- the permissions specified in the JNLPtype- the type of securitydownloadHost- 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 grantingAllPermissionto aCodeSource- Returns:
- a
Policyobject 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.
-
getApplicationPermissionLevel
public ApplicationPermissionLevel getApplicationPermissionLevel()
-
getAppletPermissionLevel
public AppletPermissionLevel getAppletPermissionLevel()
-
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.URISyntaxExceptionGets 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 URLport-- Returns:
- the host domain of the codebase
- Throws:
java.net.URISyntaxException
-
getHost
static java.net.URI getHost(java.net.URI codebase) throws java.net.URISyntaxExceptionGets 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
-
-