Class BaseOAuth2RequestDecoder<T extends Request>

Type Parameters:
T - The exact type of the request message, extends Request.
All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, UnmodifiableComponent, MessageDecoder, HttpServletRequestMessageDecoder
Direct Known Subclasses:
OAuth2AuthorizationRequestDecoder, OAuth2IntrospectionRequestDecoder, OAuth2PushedAuthorizationRequestDecoder, OAuth2RevocationRequestDecoder, OIDCAuthenticationRequestDecoder, OIDCClientRegistrationRequestDecoder, OIDCLogoutRequestDecoder, OIDCTokenRequestDecoder, OIDCUserInfoRequestDecoder

public abstract class BaseOAuth2RequestDecoder<T extends Request> extends AbstractHttpServletRequestMessageDecoder
Base decoder for Nimbus OAuth2 request messages.
  • Field Details

    • log

      @Nonnull private static final org.slf4j.Logger log
      Class logger.
    • removeIpAddressFromEndpointUri

      private boolean removeIpAddressFromEndpointUri
      A flag to remove the IP address from the endpoint URI.
    • customRequestParser

      @Nullable protected CustomNimbusRequestParser<T extends Request> customRequestParser
      A custom extension for parsing Nimbus object out of the servlet request.
  • Constructor Details

    • BaseOAuth2RequestDecoder

      public BaseOAuth2RequestDecoder()
      Constructor.
  • Method Details

    • setRemoveIpAddressFromEndpointUri

      public void setRemoveIpAddressFromEndpointUri(boolean flag)
      Set the flag to remove the IP address from the endpoint URI.
      Parameters:
      flag - What to set.
    • setCustomRequestParser

      public void setCustomRequestParser(@Nullable CustomNimbusRequestParser<T> customParser)
      Set the custom extension for parsing Nimbus object out of the servlet request.
      Parameters:
      customParser - What to set.
    • doDecode

      protected void doDecode() throws MessageDecodingException
      Specified by:
      doDecode in class AbstractMessageDecoder
      Throws:
      MessageDecodingException
    • parseMessage

      @Nullable protected abstract T parseMessage() throws MessageDecodingException
      Parses the message into the exact type of the request message.
      Returns:
      The request message
      Throws:
      MessageDecodingException - if there is a problem decoding the message context
    • getMessageToLog

      @Nullable protected abstract String getMessageToLog(T message)
      Get the string representation of what will be logged as the protocol message.
      Parameters:
      message - the request message
      Returns:
      the string representing the protocol message for logging purposes
    • serializeMessageForLogging

      @Nullable protected String serializeMessageForLogging(@Nullable Object message)
      Overrides:
      serializeMessageForLogging in class AbstractMessageDecoder
    • getEndpointURI

      @Nullable protected String getEndpointURI(Request message)
      Returns the endpoint URI either from servlet request or from the given message, depending on the flag for removing IP address from the endpoint URI.
      Parameters:
      message - the message from which to take the endpoint URI (with IP address), if the flag is false
      Returns:
      the endpoint URI
    • switchIntoCustomResource

      protected void switchIntoCustomResource(@Nonnull HTTPRequest httpRequest)
      Switches the 'resource' parameter values in the given HTTP request body to contain a custom parameter prefix. This allows us to avoid Nimbus library's strict requirement of URI values for the parameter.
      Parameters:
      httpRequest - The HTTP request object where the parameter values are prefixed
    • transformResourceParameter

      @Nullable public static String transformResourceParameter(@Nullable String string)
      Transforms the 'resource' parameter values in the given input to contain a prefix defined by DefaultRequestAudienceLookupFunction.CUSTOM_RESOURCE_PARAM_PREFIX.
      Parameters:
      string - the input
      Returns:
      the input with resource parameter values transformed having the custom prefix.