Package ej.service
Class ServicePermission
- java.lang.Object
-
- java.security.Permission
-
- ej.service.ServicePermission
-
- All Implemented Interfaces:
Serializable,Guard
public class ServicePermission extends Permission
Permission to manipulate services usingServiceLoader.getService(Class)orServiceRegistry.register(Class, Object)orServiceRegistry.unregister(Class, Object).- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringGET_ACTIONAction associated withServiceLoader.getService(Class).static StringREGISTER_ACTIONAction associated withServiceRegistry.register(Class, Object).static StringUNREGISTER_ACTIONAction associated withServiceRegistry.unregister(Class, Object).
-
Constructor Summary
Constructors Constructor Description ServicePermission(String parentName, Class<?> service, String action)Creates a permission for the given service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)Checks two Permission objects for equality.StringgetActions()Returns the actions as a String.Class<?>getService()Gets the service handled by this permission.inthashCode()Returns the hash code value for this Permission object.booleanimplies(Permission permission)Checks if the specified permission's actions are "implied by" this object's actions.-
Methods inherited from class java.security.Permission
getName, toString
-
-
-
-
Field Detail
-
GET_ACTION
public static final String GET_ACTION
Action associated withServiceLoader.getService(Class).- See Also:
- Constant Field Values
-
REGISTER_ACTION
public static final String REGISTER_ACTION
Action associated withServiceRegistry.register(Class, Object).- See Also:
- Constant Field Values
-
UNREGISTER_ACTION
public static final String UNREGISTER_ACTION
Action associated withServiceRegistry.unregister(Class, Object).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ServicePermission
public ServicePermission(String parentName, Class<?> service, String action)
Creates a permission for the given service.The action can be one of
GET_ACTION,REGISTER_ACTIONorUNREGISTER_ACTION.- Parameters:
parentName- the name of the service loader or service registry.service- the service.action- the action realized with the service.
-
-
Method Detail
-
getActions
public String getActions()
Description copied from class:PermissionReturns the actions as a String. This is abstract so subclasses can defer creating a String representation until one is needed. Subclasses should always return actions in what they consider to be their canonical form. For example, two FilePermission objects created via the following:perm1 = new FilePermission(p1, "read,write"); perm2 = new FilePermission(p2, "write,read");
both return "read,write" when thegetActionsmethod is invoked.- Specified by:
getActionsin classPermission- Returns:
- the actions of this Permission.
-
getService
public Class<?> getService()
Gets the service handled by this permission.- Returns:
- the service.
-
equals
public boolean equals(@Nullable Object obj)
Description copied from class:PermissionChecks two Permission objects for equality.Do not use the
equalsmethod for making access control decisions; use theimpliesmethod.- Specified by:
equalsin classPermission- Parameters:
obj- the object we are testing for equality with this object.- Returns:
- true if both Permission objects are equivalent.
- See Also:
Object.hashCode(),HashMap
-
hashCode
public int hashCode()
Description copied from class:PermissionReturns the hash code value for this Permission object.The required
hashCodebehavior for Permission Objects is the following:- Whenever it is invoked on the same Permission object more than once during an execution of a
Java application, the
hashCodemethod must consistently return the same integer. This integer need not remain consistent from one execution of an application to another execution of the same application. - If two Permission objects are equal according to the
equalsmethod, then calling thehashCodemethod on each of the two Permission objects must produce the same integer result.
- Specified by:
hashCodein classPermission- Returns:
- a hash code value for this object.
- See Also:
Object.equals(java.lang.Object),System.identityHashCode(java.lang.Object)
- Whenever it is invoked on the same Permission object more than once during an execution of a
Java application, the
-
implies
public boolean implies(@Nullable Permission permission)
Description copied from class:PermissionChecks if the specified permission's actions are "implied by" this object's actions.This must be implemented by subclasses of Permission, as they are the only ones that can impose semantics on a Permission object.
- Specified by:
impliesin classPermission- Parameters:
permission- the permission to check against.- Returns:
- true if the specified permission is implied by this object, false if not.
-
-