Package org.forgerock.authz.filter.api
Class AuthorizationAttribute<T>
java.lang.Object
org.forgerock.authz.filter.api.AuthorizationAttribute<T>
- Type Parameters:
T- The type of the attribute.
Provides a convenience layer on top of AuthorizationContext to simplify access to particular attributes in
the authorisation context. Usage:
AuthorizationAttribute<Set<String>> rolesAttr = new AuthorizationAttribute<>("roles");
...
rolesAttr.set(context, Collections.singleton("someRole"));
...
Set<String> roles = rolesAttr.get(context);
Note that due to the dynamic nature of request attributes, it is not possible to make this completely type-safe.
Clients should be prepared for runtime ClassCastExceptions if an unexpected value is found in an
authorization context.
- Since:
- 1.4.0
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an authorization attribute for the given authorization context key. -
Method Summary
Modifier and TypeMethodDescriptionbooleanget(AuthorizationContext context) Gets this attribute from the given authorization context.inthashCode()voidset(AuthorizationContext context, T value) Sets this attribute in the given authorization context to the given value.toString()
-
Constructor Details
-
AuthorizationAttribute
Constructs an authorization attribute for the given authorization context key.- Parameters:
key- The key to use for this attribute in theAuthorizationContext.- Throws:
NullPointerException- If the key is null.
-
-
Method Details
-
get
Gets this attribute from the given authorization context.- Parameters:
context- The context to get this attribute from.- Returns:
- The attribute from the context or null if not set.
- Throws:
ClassCastException- If an entry exists in the context for this key but has the wrong type.NullPointerException- If the context is null.
-
set
Sets this attribute in the given authorization context to the given value.- Parameters:
context- The context to set the attribute in.value- The value to set.- Throws:
NullPointerException- If the context is null.
-
equals
-
hashCode
public int hashCode() -
toString
-