Class AbstractHttpOIDCAuthenticationAction<T extends com.nimbusds.oauth2.sdk.Response>

Type Parameters:
T - the response type of the object returned as a result of the request.
All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent, ProfileAction, Aware, MessageSource, MessageSourceAware, Action
Direct Known Subclasses:
ExchangeCodeForAccessToken, UserInfoEndpointLookup

@ThreadSafeAfterInit public abstract class AbstractHttpOIDCAuthenticationAction<T extends com.nimbusds.oauth2.sdk.Response> extends AbstractOIDCAuthenticationResponseAction
An abstract class for OIDC actions that make synchronous HTTP requests and return types of responses.
  • Field Details

    • log

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

      @NonnullAfterInit private Function<ProfileRequestContext,org.apache.hc.core5.http.ClassicHttpRequest> httpRequestEncoderStrategy
      The message encoder to encode the HTTP request into a HttpUriRequest.
    • httpResponseDecoderStrategy

      @NonnullAfterInit private org.apache.hc.core5.http.io.HttpClientResponseHandler<T extends com.nimbusds.oauth2.sdk.Response> httpResponseDecoderStrategy
      The message decoder (Http response handler) to decode the HTTP response.
    • httpClient

      @NonnullAfterInit private org.apache.hc.client5.http.classic.HttpClient httpClient
      Http client for contacting the endpoint.
    • httpClientSecurityParameters

      @Nullable private HttpClientSecurityParameters httpClientSecurityParameters
      HTTP client security parameters.
  • Constructor Details

    • AbstractHttpOIDCAuthenticationAction

      public AbstractHttpOIDCAuthenticationAction()
  • Method Details

    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class AbstractInitializableComponent
      Throws:
      ComponentInitializationException
    • getHttpRequestEncoderStrategy

      @NonnullAfterInit public Function<ProfileRequestContext,org.apache.hc.core5.http.ClassicHttpRequest> getHttpRequestEncoderStrategy()
      Get the HTTP request encoder strategy.
      Returns:
      the request encoder.
    • getHttpResponseDecoderStrategy

      @NonnullAfterInit public org.apache.hc.core5.http.io.HttpClientResponseHandler<T> getHttpResponseDecoderStrategy()
      Get the HTTP response decoder/handler strategy.
      Returns:
      the response decoder.
    • setHttpResponseDecoderStrategy

      public void setHttpResponseDecoderStrategy(@Nonnull org.apache.hc.core5.http.io.HttpClientResponseHandler<T> strategy)
      Set the strategy (Http client response handler) used to map a HTTP response the response type.
      Parameters:
      strategy - the strategy
    • setHttpRequestEncoderStrategy

      public void setHttpRequestEncoderStrategy(@Nonnull Function<ProfileRequestContext,org.apache.hc.core5.http.ClassicHttpRequest> strategy)
      Set the strategy used to map a HTTP request to a ClassicHttpRequest object.
      Parameters:
      strategy - the strategy
    • setHttpClient

      public void setHttpClient(@Nonnull org.apache.hc.client5.http.classic.HttpClient client)
      Set the HttpClient to use.
      Parameters:
      client - client to use
    • setHttpClientSecurityParameters

      public void setHttpClientSecurityParameters(@Nullable HttpClientSecurityParameters params)
      Set the optional client security parameters.
      Parameters:
      params - the new client security parameters
    • handleRequest

      @Nonnull protected T handleRequest(@Nonnull ProfileRequestContext profileRequestContext, @Nullable AbstractAuthenticatableOIDCContext authenticatableContext) throws OIDCRPException
      Encode the request using the supplied request encoder strategy, execute a synchronous HTTP request and decode the response using the supplied Http client response decoder strategy/handler. If an error response is returned an exception is thrown—the OIDC error object is not propagated back to the caller.

      The request encoder strategy should return null to indicate an error constructing the request.

      Parameters:
      profileRequestContext - the context to pull information out of for encoding the request.
      authenticatableContext - an authenticatable context to set the authenticated flag. Can be null if no flag is supplied.
      Returns:
      a successful decoded response. Never null.
      Throws:
      OIDCRPException - on error making the request, or if an error response is returned.
    • formatErrorResponse

      private String formatErrorResponse(@Nullable com.nimbusds.oauth2.sdk.ErrorObject error)
      Format an error message string from the ErrorObject provided.
      Parameters:
      error - the error object
      Returns:
      a human readable error string
    • executeHttpRequest

      @Nullable protected T executeHttpRequest(@Nonnull org.apache.hc.core5.http.ClassicHttpRequest request, @Nullable AbstractAuthenticatableOIDCContext authenticatableContext) throws IOException
      Performs a call to an Http endpoint using the configured HttpClient, HttpClientResponseHandler, and security parameters.
      Parameters:
      request - the prepared HTTP request
      authenticatableContext - an authenticatable context to set the authenticated flag. Can be null if no flag is supplied.
      Returns:
      the encoded Http response.
      Throws:
      IOException - if there is an error producing a response