Class DenyAction
java.lang.Object
org.cojen.boxtin.DenyAction
Specifies the action to take when access to an operation is denied.
-
Method Summary
Modifier and TypeMethodDescriptioncheck
(MethodHandleInfo predicate) Returns this deny action but with a predicate check to determine if the operation should actually be allowed.static DenyAction
custom
(MethodHandleInfo mhi) Returns a deny action which performs a custom operation.static DenyAction
empty()
Returns a deny action which returns an empty instance.static DenyAction
Returns a deny action which throws an exception without a message.static DenyAction
Returns a deny action which throws an exception with an optional message.static DenyAction
Returns a deny action which throws an exception without a message.static DenyAction
Returns a deny action which throws an exception with an optional message.static DenyAction
standard()
Returns the standard deny action, which throws aSecurityException
without a message.static DenyAction
Returns a deny action which returns a specific value, possibly null.
-
Method Details
-
standard
Returns the standard deny action, which throws aSecurityException
without a message. -
exception
Returns a deny action which throws an exception without a message. -
exception
Returns a deny action which throws an exception with an optional message. -
exception
Returns a deny action which throws an exception without a message. -
exception
Returns a deny action which throws an exception with an optional message. -
value
Returns a deny action which returns a specific value, possibly null. If the value is incompatible with the actual value type, then null, 0, false, or void is returned instead.Note: This action has no effect for constructors, and if configured as such, the standard action is used instead.
- Throws:
IllegalArgumentException
- if the given value isn't null, a boxed primitive, or a string
-
empty
Returns a deny action which returns an empty instance. Types supported are arrays,String
,Optional
,Iterable
,Collection
,Stream
, and any of the empty variants supported by theCollections
class. Otherwise, a new instance is created using a no-arg constructor, possibly resulting in aLinkageError
at runtime. If the actual type is primitive, then 0, false or void is returned instead.Note: This action has no effect for constructors, and if configured as such, the standard action is used instead.
-
custom
Returns a deny action which performs a custom operation. The parameters given to the custom method are theCaller
(optional), the non-null instance (if applicable), and the original method parameters. The return type must exactly match the original method's return type. If the custom method type is incompatible, then aSecurityException
orWrongMethodTypeException
can be thrown instead.Note: This action has no effect for constructors, unless the custom operation throws an exception. If it doesn't throw an exception, a
SecurityException
is thrown instead. -
check
Returns this deny action but with a predicate check to determine if the operation should actually be allowed. The parameters given to the predicate are theCaller
(optional), the non-null instance (if applicable), and the original method parameters. The return type must be boolean. If the predicate format is incompatible, then aSecurityException
orWrongMethodTypeException
can be thrown instead.- Parameters:
predicate
- the predicate checking method which returns true when the operation is allowed- Throws:
IllegalArgumentException
- if the predicate doesn't return a booleanIllegalStateException
- if this action is already checked
-