Package org.forgerock.authz.filter.api
Class AuthorizationContext
java.lang.Object
org.forgerock.authz.filter.api.AuthorizationContext
Context to use for authorization requests. Authorization modules can add additional information to the context, which
will be passed on to further authorization filters and the protected resource via request attributes. Provides simple
dynamic typing for getting and setting attribute values on the context.
- Since:
- 1.4.0
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a blank authorization context.AuthorizationContext(Map<String, Object> attributes) Creates a new authorization context using the given attribute map as a backing store. -
Method Summary
Modifier and TypeMethodDescriptionboolean<T> TgetAttribute(String key) Gets an attribute from the authorization context, returning null if it does not exist.Gets a copy of all attributes set in this authorization context.inthashCode()setAttribute(String key, Object value) Sets an attribute in the shared context.
-
Constructor Details
-
AuthorizationContext
public AuthorizationContext()Constructs a blank authorization context. -
AuthorizationContext
Creates a new authorization context using the given attribute map as a backing store.- Parameters:
attributes- The initial attributes to copy into the new context.
-
-
Method Details
-
getAttribute
Gets an attribute from the authorization context, returning null if it does not exist.- Type Parameters:
T- The result type.- Parameters:
key- The key of the attribute.- Returns:
- The attribute value, or null if it does not exist.
- Throws:
NullPointerException- If the key is null.ClassCastException- If the attribute exists but is not of the expected type.
-
setAttribute
Sets an attribute in the shared context.- Parameters:
key- The key to set.value- The value to associate with the key.- Returns:
- This context to allow method chaining.
- Throws:
NullPointerException- If the key or value is null.
-
getAttributes
Gets a copy of all attributes set in this authorization context. Changes made to the returned map will not be reflected in the authorization context.- Returns:
- A copy of the attributes in this context.
-
equals
-
hashCode
public int hashCode()
-