Class AccessTokenResConverter

java.lang.Object
com.alpaca.security.oauth2.AccessTokenResConverter
All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<Map<String,Object>,org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse>

public class AccessTokenResConverter extends Object implements org.springframework.core.convert.converter.Converter<Map<String,Object>,org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse>
Converter that transforms a raw token response Map into a structured OAuth2AccessTokenResponse.

This converter handles standard OAuth2 token response entries:

  • access_token: required access token string.
  • token_type: assigned as Bearer by default.
  • expires_in: duration in seconds (parsed via Number.longValue()), with default fallback when missing.
  • refresh_token: optional refresh token string.
  • scope: parsed robustly from String or Collection inputs.
All other entries in the source map are treated as additional parameters and included in the result as an immutable read-only map. This approach offers flexibility for OAuth2 providers returning non-standard fields or when additional metadata is needed alongside the access token.
See Also:
  • OAuth2AccessTokenResponse
  • Converter
  • Field Details

    • SCOPE_DELIMITER

      private static final Pattern SCOPE_DELIMITER
    • DEFAULT_EXPIRES_IN

      private static final long DEFAULT_EXPIRES_IN
      See Also:
    • TOKEN_RESPONSE_PARAMETER_NAMES

      private static final Set<String> TOKEN_RESPONSE_PARAMETER_NAMES
  • Constructor Details

    • AccessTokenResConverter

      public AccessTokenResConverter()
  • Method Details

    • convert

      public org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse convert(@NonNull Map<String,Object> source)
      Specified by:
      convert in interface org.springframework.core.convert.converter.Converter<Map<String,Object>,org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse>
    • parseExpiresIn

      private long parseExpiresIn(Map<String,Object> source)
    • parseScopes

      private Set<String> parseScopes(Map<String,Object> source)
    • extractAdditionalParameters

      private Map<String,Object> extractAdditionalParameters(Map<String,Object> source)