Class LegacyImplicitAuthorizationRequestConverter

java.lang.Object
com.irurueta.authserver.authorization.api.web.implicit.LegacyImplicitAuthorizationRequestConverter
All Implemented Interfaces:
org.springframework.security.web.authentication.AuthenticationConverter

public class LegacyImplicitAuthorizationRequestConverter extends Object implements org.springframework.security.web.authentication.AuthenticationConverter
Reads an authorization request with response_type=token. The framework refuses that response type; this converter, installed first, takes it over for the one client of the legacy flow and refuses it, with the same unsupported_response_type and no redirect, for any other client.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final org.springframework.security.web.util.matcher.RequestMatcher
    Matches a GET of the authorization endpoint.
    private final String
    Identifier of the only client that may use the flow.
    static final String
    Response type of the implicit flow.
  • Constructor Summary

    Constructors
    Constructor
    Description
    LegacyImplicitAuthorizationRequestConverter(String clientId, String authorizationEndpoint)
    Creates the converter.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.security.core.Authentication
    convert(jakarta.servlet.http.HttpServletRequest request)
    Reads the request.
    private static org.springframework.security.core.Authentication
    Reads the user of the request from the security context, an anonymous one when there is none.
    private static boolean
    isRepeated(jakarta.servlet.http.HttpServletRequest request, String name)
    Tells whether a parameter is sent more than once.
    private static org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthorizationCodeRequestAuthenticationException
    Builds the refusal, which carries no authentication and so is answered with 400.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • RESPONSE_TYPE_TOKEN

      public static final String RESPONSE_TYPE_TOKEN
      Response type of the implicit flow.
      See Also:
    • clientId

      private final String clientId
      Identifier of the only client that may use the flow.
    • authorizationRequest

      private final org.springframework.security.web.util.matcher.RequestMatcher authorizationRequest
      Matches a GET of the authorization endpoint.
  • Constructor Details

    • LegacyImplicitAuthorizationRequestConverter

      public LegacyImplicitAuthorizationRequestConverter(String clientId, String authorizationEndpoint)
      Creates the converter.
      Parameters:
      clientId - identifier of the only client that may use the flow.
      authorizationEndpoint - path of the authorization endpoint.
  • Method Details

    • convert

      public org.springframework.security.core.Authentication convert(jakarta.servlet.http.HttpServletRequest request)
      Reads the request.
      Specified by:
      convert in interface org.springframework.security.web.authentication.AuthenticationConverter
      Parameters:
      request - the request.
      Returns:
      the request of the legacy flow, or null when the request is not a GET of the authorization endpoint with response_type=token.
      Throws:
      org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthorizationCodeRequestAuthenticationException - unsupported_response_type (no redirect) when the client is not the one of the legacy flow, invalid_request (no redirect) when a parameter is repeated.
    • isRepeated

      private static boolean isRepeated(jakarta.servlet.http.HttpServletRequest request, String name)
      Tells whether a parameter is sent more than once.
      Parameters:
      request - the request.
      name - name of the parameter.
      Returns:
      true when it has more than one value.
    • currentUser

      private static org.springframework.security.core.Authentication currentUser()
      Reads the user of the request from the security context, an anonymous one when there is none.
      Returns:
      the user.
    • refused

      private static org.springframework.security.oauth2.server.authorization.authentication.OAuth2AuthorizationCodeRequestAuthenticationException refused(String code)
      Builds the refusal, which carries no authentication and so is answered with 400.
      Parameters:
      code - error code.
      Returns:
      the exception.