Package org.osgi.service.condpermadmin
Interface Condition
@ConsumerType
public interface Condition
The interface implemented by a Condition. Conditions are bound to Permissions
using Conditional Permission Info. The Permissions of a ConditionalPermission
Info can only be used if the associated Conditions are satisfied.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether the Condition is mutable.boolean
Returns whether the evaluation must be postponed until the end of the permission check.boolean
Returns whether the Condition is satisfied.boolean
isSatisfied
(Condition[] conditions, Dictionary<Object, Object> context) Returns whether the specified set of Condition objects are satisfied.
-
Field Details
-
TRUE
A Condition object that will always evaluate to true and that is never postponed. -
FALSE
A Condition object that will always evaluate to false and that is never postponed.
-
-
Method Details
-
isPostponed
boolean isPostponed()Returns whether the evaluation must be postponed until the end of the permission check. If this method returnsfalse
(or this Condition is immutable), then this Condition must be able to directly answer theisSatisfied()
method. In other words, isSatisfied() will return very quickly since no external sources, such as for example users or networks, need to be consulted.This method must always return the same value whenever it is called so that the Conditional Permission Admin can cache its result.
- Returns:
true
to indicate the evaluation must be postponed. Otherwise,false
if the evaluation can be performed immediately.
-
isSatisfied
boolean isSatisfied()Returns whether the Condition is satisfied. This method is only called for immediate Condition objects or immutable postponed conditions, and must always be called inside a permission check. Mutable postponed Condition objects will be called with the grouped versionisSatisfied(Condition[],Dictionary)
at the end of the permission check.- Returns:
true
to indicate the Conditions is satisfied. Otherwise,false
if the Condition is not satisfied.
-
isMutable
boolean isMutable()Returns whether the Condition is mutable. A Condition can go from mutable (true
) to immutable (false
) over time but never from immutable (false
) to mutable (true
).- Returns:
true
isSatisfied()
can change. Otherwise,false
if the value returned byisSatisfied()
will not change for this condition.
-
isSatisfied
Returns whether the specified set of Condition objects are satisfied. Although this method is not static, it must be implemented as if it were static. All of the passed Condition objects will be of the same type and will correspond to the class type of the object on which this method is invoked. This method must be called inside a permission check only.- Parameters:
conditions
- The array of Condition objects, which must all be of the same class and mutable. The receiver must be one of those Condition objects.context
- A Dictionary object that implementors can use to track state. If this method is invoked multiple times in the same permission check, the same Dictionary will be passed multiple times. The SecurityManager treats this Dictionary as an opaque object and simply creates an empty dictionary and passes it to subsequent invocations if multiple invocations are needed.- Returns:
true
if all the Condition objects are satisfied. Otherwise,false
if one of the Condition objects is not satisfied.
-