Package org.forgerock.openig.filter
Class AuthRedirectContext
- java.lang.Object
-
- org.forgerock.services.context.AbstractContext
-
- org.forgerock.openig.filter.AuthRedirectContext
-
- All Implemented Interfaces:
Context
public class AuthRedirectContext extends AbstractContext
Used by theFragmentFilter
and theDataPreservationFilter
to know if a filter has attempted an impending IG redirection. Note: there should only ever be one instance of theAuthRedirectContext
in the context hierarchy for any given request. It is important to validate if one is already present before adding a new instance, or when needing to add query parameters. For example:final Context authRedirectAwareContext = context.as(AuthRedirectContext.class) .map(authRedirectContext -> { authRedirectContext.addQueryParameter("foo", "bar"); return context; }) .orElseGet(() -> { AuthRedirectContext authRedirectContext = new AuthRedirectContext(context); authRedirectContext.addQueryParameter("foo", "bar"); return authRedirectContext; });
-
-
Field Summary
Fields Modifier and Type Field Description static String
NAME
Context's name.-
Fields inherited from class org.forgerock.services.context.AbstractContext
data
-
-
Constructor Summary
Constructors Constructor Description AuthRedirectContext(Context parent)
Create an AuthRedirectContext instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addQueryParameter(String name, String value)
Add a query parameter to the context.boolean
isImpendingIgRedirectNotified()
Returns whether an impending IG redirect has been performed or not.URI
notifyImpendingIgRedirectAndUpdateUri(URI uri)
Warn that an impending IG redirection has been attempted and if any query parameters have been added to this context, apply them to the uri and return an updated uri.-
Methods inherited from class org.forgerock.services.context.AbstractContext
as, asContext, containsContext, containsContext, get, getContext, getContextName, getId, getParent, getRootId, isRootContext, toJsonValue, toString
-
-
-
-
Field Detail
-
NAME
public static final String NAME
Context's name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AuthRedirectContext
public AuthRedirectContext(Context parent)
Create an AuthRedirectContext instance.- Parameters:
parent
- the parent context.
-
-
Method Detail
-
isImpendingIgRedirectNotified
public boolean isImpendingIgRedirectNotified()
Returns whether an impending IG redirect has been performed or not.- Returns:
true
if this context is aware of a impending IG redirect attempt.
-
notifyImpendingIgRedirectAndUpdateUri
public URI notifyImpendingIgRedirectAndUpdateUri(URI uri)
Warn that an impending IG redirection has been attempted and if any query parameters have been added to this context, apply them to the uri and return an updated uri. Any existing parameters of the same name will be replaced.
-
addQueryParameter
public void addQueryParameter(String name, String value)
Add a query parameter to the context. This will be used to tag the originalUri with a query parameter as part of thenotifyImpendingIgRedirectAndUpdateUri(URI)
call.- Parameters:
name
- The query parameter name.value
- The query parameter value.
-
-