Class OAuth2UserInfoFactory
java.lang.Object
com.alpaca.security.oauth2.userinfo.OAuth2UserInfoFactory
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:
- google — returns an instance of
GoogleUserInfo
.
registrationId
does not match a supported provider, a BadRequestException
is thrown with a descriptive error message.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic OAuth2UserInfo
getOAuth2UserInfo
(String registrationId, Map<String, Object> attributes) Returns anOAuth2UserInfo
instance suitable for the specified provider.
-
Constructor Details
-
OAuth2UserInfoFactory
public OAuth2UserInfoFactory()
-
-
Method Details
-
getOAuth2UserInfo
public static OAuth2UserInfo getOAuth2UserInfo(String registrationId, Map<String, Object> attributes) Returns anOAuth2UserInfo
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
-