Class AuthRedirectContext

  • All Implemented Interfaces:
    Context

    public class AuthRedirectContext
    extends AbstractContext
    Used by the FragmentFilter and the DataPreservationFilter to know if a filter has attempted an impending IG redirection. Note: there should only ever be one instance of the AuthRedirectContext 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;
                          });
     
     
    • 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.
        Parameters:
        uri - The URI to update.
        Returns:
        The updated URI, if there are any query parameters to apply, otherwise return the original value.
      • 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 the notifyImpendingIgRedirectAndUpdateUri(URI) call.
        Parameters:
        name - The query parameter name.
        value - The query parameter value.