Package com.authlete.common.api
Enum AccessRight
- java.lang.Object
-
- java.lang.Enum<AccessRight>
-
- com.authlete.common.api.AccessRight
-
- All Implemented Interfaces:
Serializable
,Comparable<AccessRight>
public enum AccessRight extends Enum<AccessRight>
Utility class to describe the possible values used in the RAR objects when accessing the Authlete API with an access token. The enum values each represent a specific possible value of theaction
field of the RAR object. Each AccessRight value in turn is aware of whether the action is specific to a particular service or client, which necessitate the presence of theservice
andclient
fields of the RAR object, respectively. Each AccessRight value also knows which other AccessRights it subsumes. For example, theUSE_SERVICE
value also includes theVIEW_SERVICE
andVIEW_CLIENT
actions inherently. TheAUTHLETE_API_V3
constant is used as thetype
value for all RAR objects addressing the Authlete API.- Since:
- 3.73
- Author:
- jricher
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ADMIN
can call administrative functions on the Authlete serverCREATE_CLIENT
can create new clients on this serviceCREATE_SERVICE
can create additional servicesDELETE_SERVICE
can delete a specific serviceMODIFY_CLIENT
can modify existing clients on this service or clientMODIFY_SERVICE
can modify this serviceUSE_SERVICE
can use the non-destructive service API calls (auth endpoint, token endpoint, etc.)VIEW_CLIENT
can view client details on this service or clientVIEW_DEFAULT_SERVICE
can view default service parametersVIEW_SERVICE
can view the details of this service
-
Field Summary
Fields Modifier and Type Field Description static String
AUTHLETE_API_V3
Thetype
value of the RAR object for the authlete API.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canDo(long clientId, long serviceId, AccessRight compare)
Return true if this access right has at least the amount of access of the compared access right.boolean
canDoAny(long serviceId, AccessRight compare)
Return true if this access right has at least the amount of access of the compared access right on any object in the list.static AccessRight
fromJson(String key)
Look up and fetch an access right value based on its (lowercased) name from a JSON object.boolean
isClientSpecific()
Return true if this access right requires a specific service and client to be applied.boolean
isServiceSpecific()
Return true if this access right requires a specific service to be applied.String
toJson()
Return the name of this access right in lowercase form, appropriate for use in JSON objects (such as RAR object values).static AccessRight
valueOf(String name)
Returns the enum constant of this type with the specified name.static AccessRight[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
VIEW_CLIENT
public static final AccessRight VIEW_CLIENT
can view client details on this service or client
-
MODIFY_CLIENT
public static final AccessRight MODIFY_CLIENT
can modify existing clients on this service or client
-
VIEW_SERVICE
public static final AccessRight VIEW_SERVICE
can view the details of this service
-
USE_SERVICE
public static final AccessRight USE_SERVICE
can use the non-destructive service API calls (auth endpoint, token endpoint, etc.)
-
CREATE_CLIENT
public static final AccessRight CREATE_CLIENT
can create new clients on this service
-
MODIFY_SERVICE
public static final AccessRight MODIFY_SERVICE
can modify this service
-
VIEW_DEFAULT_SERVICE
public static final AccessRight VIEW_DEFAULT_SERVICE
can view default service parameters
-
CREATE_SERVICE
public static final AccessRight CREATE_SERVICE
can create additional services
-
DELETE_SERVICE
public static final AccessRight DELETE_SERVICE
can delete a specific service
-
ADMIN
public static final AccessRight ADMIN
can call administrative functions on the Authlete server
-
-
Field Detail
-
AUTHLETE_API_V3
public static final String AUTHLETE_API_V3
Thetype
value of the RAR object for the authlete API.- See Also:
- Constant Field Values
-
-
Method Detail
-
values
public static AccessRight[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (AccessRight c : AccessRight.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static AccessRight valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
isServiceSpecific
public boolean isServiceSpecific()
Return true if this access right requires a specific service to be applied.
-
isClientSpecific
public boolean isClientSpecific()
Return true if this access right requires a specific service and client to be applied.- Returns:
-
canDo
public boolean canDo(long clientId, long serviceId, AccessRight compare)
Return true if this access right has at least the amount of access of the compared access right. This checks whether the clientId and serviceId parameters are present if they are required for the given access right to function.
-
canDoAny
public boolean canDoAny(long serviceId, AccessRight compare)
Return true if this access right has at least the amount of access of the compared access right on any object in the list. If the access right is client specific, the serviceId is a required parameter. If the access right is service specific, this is true for all possible services regardless of value.- Since:
- 3.99
-
fromJson
public static AccessRight fromJson(String key)
Look up and fetch an access right value based on its (lowercased) name from a JSON object.
-
toJson
public String toJson()
Return the name of this access right in lowercase form, appropriate for use in JSON objects (such as RAR object values).
-
-