Package org.forgerock.authz.filter.api
Class AuthorizationContext
- java.lang.Object
-
- org.forgerock.authz.filter.api.AuthorizationContext
-
public class AuthorizationContext extends Object
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
Constructors Constructor Description AuthorizationContext()
Constructs 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object that)
<T> T
getAttribute(String key)
Gets an attribute from the authorization context, returning null if it does not exist.Map<String,Object>
getAttributes()
Gets a copy of all attributes set in this authorization context.int
hashCode()
AuthorizationContext
setAttribute(String key, Object value)
Sets an attribute in the shared context.
-
-
-
Method Detail
-
getAttribute
public <T> T getAttribute(String key)
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
public AuthorizationContext setAttribute(String key, Object value)
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
public Map<String,Object> 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.
-
-