Package org.eclipse.hono.auth
Class AuthoritiesImpl
java.lang.Object
org.eclipse.hono.auth.AuthoritiesImpl
- All Implemented Interfaces:
Authorities
A map backed implementation of authorities on resources and operations.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddAll
(Authorities authoritiesToAdd) Adds all authorities contained in another object to this instance.addOperation
(String resource, String operation) Adds an authority to execute an operation.addOperation
(String endpoint, String tenant, String operation) Adds an authority to execute an operation.addResource
(String endpoint, String tenant, Activity... activities) Adds an authority to perform one or more activities on a resource.addResource
(String resource, Activity... activities) Adds an authority to perform one or more activities on a resource.asMap()
Gets the authorities as a map of claims.static Authorities
from
(io.jsonwebtoken.Claims claims) Creates authorities from claims from a JWT.boolean
isAuthorized
(ResourceIdentifier resource, String operation) Checks if these authorities include claims allowing execution of an operation of a resource.boolean
isAuthorized
(ResourceIdentifier resource, Activity intent) Checks if these authorities include claims allowing an intended activity on a resource.
-
Field Details
-
PREFIX_RESOURCE
The prefix used to indicate an authority on a resource.- See Also:
-
PREFIX_OPERATION
The prefix used to indicate an authority on an operation.- See Also:
-
-
Constructor Details
-
AuthoritiesImpl
public AuthoritiesImpl()
-
-
Method Details
-
from
Creates authorities from claims from a JWT.- Parameters:
claims
- The claims object to retrieve authorities from.- Returns:
- The authorities.
- Throws:
NullPointerException
- if claims isnull
.
-
addOperation
Adds an authority to execute an operation.- Parameters:
resource
- The resource the operation belongs to.operation
- The operation.- Returns:
- This instance for command chaining.
-
addOperation
Adds an authority to execute an operation.- Parameters:
endpoint
- The endpoint segment of the resource the operation belongs to.tenant
- The tenant segment of the resource the operation belongs to.operation
- The operation.- Returns:
- This instance for command chaining.
-
addResource
Adds an authority to perform one or more activities on a resource.- Parameters:
resource
- The resource.activities
- The activities.- Returns:
- This instance for command chaining.
-
addResource
Adds an authority to perform one or more activities on a resource.- Parameters:
endpoint
- The endpoint segment of the resource.tenant
- The tenant segment of the resource.activities
- The activities.- Returns:
- This instance for command chaining.
-
addAll
Adds all authorities contained in another object to this instance.- Parameters:
authoritiesToAdd
- The object containing the authorities to add.- Returns:
- This instance for command chaining.
-
isAuthorized
Description copied from interface:Authorities
Checks if these authorities include claims allowing an intended activity on a resource.- Specified by:
isAuthorized
in interfaceAuthorities
- Parameters:
resource
- The resource.intent
- The intended activity on the resource- Returns:
true
if the activity is allowed.
-
isAuthorized
Description copied from interface:Authorities
Checks if these authorities include claims allowing execution of an operation of a resource.- Specified by:
isAuthorized
in interfaceAuthorities
- Parameters:
resource
- The resource.operation
- The operation to execute.- Returns:
true
if execution is allowed.
-
asMap
Description copied from interface:Authorities
Gets the authorities as a map of claims.- Specified by:
asMap
in interfaceAuthorities
- Returns:
- The claims.
-