Class OAuth2UserInfoFactory

java.lang.Object
com.alpaca.security.oauth2.userinfo.OAuth2UserInfoFactory

public class OAuth2UserInfoFactory extends Object
Factory for creating provider-specific OAuth2 user information handlers.

This class follows the Factory design pattern by encapsulating the logic to instantiate an appropriate OAuth2UserInfo subclass based on the OAuth2 provider identified by registrationId.

Current implementation supports:

If the registrationId does not match a supported provider, a BadRequestException is thrown with a descriptive error message.
See Also:
  • Constructor Details

    • OAuth2UserInfoFactory

      public OAuth2UserInfoFactory()
  • Method Details

    • getOAuth2UserInfo

      public static OAuth2UserInfo getOAuth2UserInfo(String registrationId, Map<String,Object> attributes)
      Returns an OAuth2UserInfo instance suitable for the specified provider.
      Parameters:
      registrationId - the provider identifier (e.g., "google")
      attributes - the raw user attributes from the OAuth2 provider
      Returns:
      a concrete OAuth2UserInfo subclass for the provider
      Throws:
      BadRequestException - if the provider is not supported