public final class HostAccess extends Object
There are three predefined instances of host access policies:
HostAccess.EXPLICIT
- Java host methods or fields, must be public and be annotated with
@Export
to make them accessible to the guest language.
HostAccess.SCOPED
- Java host methods or fields, must be public and be annotated with
@Export
to make them accessible to the guest language. Guest-to-host callback
parameter validity is scoped to the duration of the callback by default.
HostAccess.NONE
- Does not allow any access to methods or fields of host objects. Java host
objects may still be passed into a context, but they cannot be accessed.
HostAccess.ALL
- Does allow full unrestricted access to public methods or fields of host
objects. Note that this policy allows unrestricted access to reflection. It is highly discouraged
from using this policy in environments where the guest application is not fully trusted.
HostAccess.CONSTRAINED
host access policy suitable for a context with
CONSTRAINED
sandbox policy.
HostAccess.ISOLATED
host access policy suitable for a context with
ISOLATED
sandbox policy.
HostAccess.UNTRUSTED
host access policy suitable for a context with
UNTRUSTED
sandbox policy.
HostAccess.newBuilder()
. The builder allows to
specify a custom export annotation and allowed and denied methods or fields.Modifier and Type | Class and Description |
---|---|
class |
HostAccess.Builder
Builder to create a custom
host access policy . |
static interface |
HostAccess.DisableMethodScoping
If
HostAccess.SCOPED is used, placing this annotation on an exported host function
excludes it from parameter scoping, i.e. |
static interface |
HostAccess.Export
Annotation used by the predefined
HostAccess.EXPLICIT access policy to mark public
constructors, methods and fields in public classes that should be accessible by the guest
application. |
static interface |
HostAccess.Implementable
Allows guest language to implement a Java type.
|
static class |
HostAccess.MutableTargetMapping
List of default host object mappings of mutable target types available in
Value.as(Class) . |
static class |
HostAccess.TargetMappingPrecedence
Represents the precedence of a target type mapping.
|
Modifier and Type | Field and Description |
---|---|
static HostAccess |
ALL
Predefined host access policy that allows full unrestricted access to public methods or
fields of public host classes.
|
static HostAccess |
CONSTRAINED
Predefined host access policy used by Context with a
SandboxPolicy.CONSTRAINED
sandbox policy when the host access policy is not explicitly specified by the embedder. |
static HostAccess |
EXPLICIT
Predefined host access policy that allows access to public host methods or fields that were
annotated with @Export and were declared in public class.
|
static HostAccess |
ISOLATED
Predefined host access policy used by Context with an
SandboxPolicy.ISOLATED sandbox
policy when the host access policy is not explicitly specified by the embedder. |
static HostAccess |
NONE
Predefined host access policy that disallows any access to public host methods or fields.
|
static HostAccess |
SCOPED
Predefined host access policy that is the same as EXPLICIT and enables method scoping of
callback parameter values on top.
|
static HostAccess |
UNTRUSTED
Predefined host access policy used by Context with an
SandboxPolicy.UNTRUSTED sandbox
policy when the host access policy is not explicitly specified by the embedder. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
int |
hashCode() |
static HostAccess.Builder |
newBuilder()
Creates a new builder that allows to create a custom host access policy.
|
static HostAccess.Builder |
newBuilder(HostAccess conf)
Creates a new builder that allows to create a custom host access policy based of a preset
configuration.
|
String |
toString() |
public static final HostAccess EXPLICIT
Context.Builder.allowAllAccess(boolean)
is
false
.
Equivalent of using the following builder configuration:
HostAccess.newBuilder().allowAccessAnnotatedBy(HostAccess.Export.class).
allowImplementationsAnnotatedBy(HostAccess.Implementable.class).
allowImplementationsAnnotatedBy(FunctionalInterface.class).
.build();
public static final HostAccess SCOPED
HostAccess.DisableMethodScoping
are exempt from scoping.
Equivalent of using the following builder configuration:
HostAccess.newBuilder().allowAccessAnnotatedBy(HostAccess.Export.class).
allowImplementationsAnnotatedBy(HostAccess.Implementable.class).
allowImplementationsAnnotatedBy(FunctionalInterface.class).
methodScoping(true).
disableMethodScopingAnnotatedBy(HostAccess.DisableMethodScoping.class)
.build();
public static final HostAccess ALL
Context.Builder.allowAllAccess(boolean)
is true
.
Equivalent of using the following builder configuration:
HostAccess.newBuilder()
allowPublicAccess(true).
allowAllImplementations(true).
allowAllClassImplementations(true).
allowArrayAccess(true).
allowListAccess(true).
allowBufferAccess(true).
allowIterableAccess(true).
allowIteratorAccess(true).
allowMapAccess(true).
allowAccessInheritance(true).
.build();
public static final HostAccess NONE
Equivalent of using the following builder configuration:
HostAccess.newBuilder().build();
public static final HostAccess CONSTRAINED
SandboxPolicy.CONSTRAINED
sandbox policy when the host access policy is not explicitly specified by the embedder.
Equivalent of using the following builder configuration:
HostAccess.newBuilder().
allowAccessAnnotatedBy(Export.class).
allowImplementationsAnnotatedBy(Implementable.class).
allowMutableTargetMappings().build();
public static final HostAccess ISOLATED
SandboxPolicy.ISOLATED
sandbox
policy when the host access policy is not explicitly specified by the embedder.
Equivalent of using the following builder configuration:
HostAccess.newBuilder(CONSTRAINED).
methodScoping(true).build();
public static final HostAccess UNTRUSTED
SandboxPolicy.UNTRUSTED
sandbox
policy when the host access policy is not explicitly specified by the embedder.
Equivalent of using the following builder configuration:
HostAccess.newBuilder().
allowAccessAnnotatedBy(Export.class).
allowMutableTargetMappings().
methodScoping(true).build();
public static HostAccess.Builder newBuilder()
method
.public static HostAccess.Builder newBuilder(HostAccess conf)
method
.