Package org.keycloak.broker.oidc
Class AbstractOAuth2IdentityProvider<C extends OAuth2IdentityProviderConfig>
- java.lang.Object
- 
- org.keycloak.broker.provider.AbstractIdentityProvider<C>
- 
- org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider<C>
 
 
- 
- All Implemented Interfaces:
- ExchangeExternalToken,- ExchangeTokenToIdentityProviderToken,- IdentityProvider<C>,- Provider
 - Direct Known Subclasses:
- BitbucketIdentityProvider,- FacebookIdentityProvider,- GitHubIdentityProvider,- InstagramIdentityProvider,- LinkedInIdentityProvider,- MicrosoftIdentityProvider,- OIDCIdentityProvider,- OpenshiftV3IdentityProvider,- OpenshiftV4IdentityProvider,- PayPalIdentityProvider,- StackoverflowIdentityProvider
 
 public abstract class AbstractOAuth2IdentityProvider<C extends OAuth2IdentityProviderConfig> extends AbstractIdentityProvider<C> implements ExchangeTokenToIdentityProviderToken, ExchangeExternalToken - Author:
- Pedro Igor
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classAbstractOAuth2IdentityProvider.Endpoint- 
Nested classes/interfaces inherited from interface org.keycloak.broker.provider.IdentityProviderIdentityProvider.AuthenticationCallback
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static StringACCESS_DENIEDstatic StringFEDERATED_REFRESH_TOKENstatic StringFEDERATED_TOKEN_EXPIRATIONprotected static org.jboss.logging.Loggerloggerprotected static com.fasterxml.jackson.databind.ObjectMappermapperstatic StringOAUTH2_GRANT_TYPE_AUTHORIZATION_CODEstatic StringOAUTH2_GRANT_TYPE_REFRESH_TOKENstatic StringOAUTH2_PARAMETER_ACCESS_TOKENstatic StringOAUTH2_PARAMETER_CLIENT_IDstatic StringOAUTH2_PARAMETER_CLIENT_SECRETstatic StringOAUTH2_PARAMETER_CODEstatic StringOAUTH2_PARAMETER_GRANT_TYPEstatic StringOAUTH2_PARAMETER_REDIRECT_URIstatic StringOAUTH2_PARAMETER_RESPONSE_TYPEstatic StringOAUTH2_PARAMETER_SCOPEstatic StringOAUTH2_PARAMETER_STATE- 
Fields inherited from class org.keycloak.broker.provider.AbstractIdentityProviderACCOUNT_LINK_URL, session
 - 
Fields inherited from interface org.keycloak.broker.provider.IdentityProviderEXTERNAL_IDENTITY_PROVIDER, FEDERATED_ACCESS_TOKEN
 
- 
 - 
Constructor SummaryConstructors Constructor Description AbstractOAuth2IdentityProvider(KeycloakSession session, C config)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description com.fasterxml.jackson.databind.JsonNodeasJsonNode(String json)SimpleHttpauthenticateTokenRequest(SimpleHttp tokenRequest)voidauthenticationFinished(AuthenticationSessionModel authSession, BrokeredIdentityContext context)protected SimpleHttpbuildUserInfoRequest(String subjectToken, String userInfoUrl)Objectcallback(RealmModel realm, IdentityProvider.AuthenticationCallback callback, EventBuilder event)JAXRS callback endpoint for when the remote IDP wants to callback to keycloak.protected javax.ws.rs.core.UriBuildercreateAuthorizationUrl(AuthenticationRequest request)protected BrokeredIdentityContextdoGetFederatedIdentity(String accessToken)BrokeredIdentityContextexchangeExternal(EventBuilder event, javax.ws.rs.core.MultivaluedMap<String,String> params)voidexchangeExternalComplete(UserSessionModel userSession, BrokeredIdentityContext context, javax.ws.rs.core.MultivaluedMap<String,String> params)protected BrokeredIdentityContextexchangeExternalImpl(EventBuilder event, javax.ws.rs.core.MultivaluedMap<String,String> params)protected BrokeredIdentityContextexchangeExternalUserInfoValidationOnly(EventBuilder event, javax.ws.rs.core.MultivaluedMap<String,String> params)javax.ws.rs.core.ResponseexchangeFromToken(javax.ws.rs.core.UriInfo uriInfo, EventBuilder event, ClientModel authorizedClient, UserSessionModel tokenUserSession, UserModel tokenSubject, javax.ws.rs.core.MultivaluedMap<String,String> params)protected javax.ws.rs.core.ResponseexchangeSessionToken(javax.ws.rs.core.UriInfo uriInfo, EventBuilder event, ClientModel authorizedClient, UserSessionModel tokenUserSession, UserModel tokenSubject)protected javax.ws.rs.core.ResponseexchangeStoredToken(javax.ws.rs.core.UriInfo uriInfo, EventBuilder event, ClientModel authorizedClient, UserSessionModel tokenUserSession, UserModel tokenSubject)protected BrokeredIdentityContextextractIdentityFromProfile(EventBuilder event, com.fasterxml.jackson.databind.JsonNode node)protected StringextractTokenFromResponse(String response, String tokenName)protected JsonWebTokengenerateToken()protected StringgetAccessTokenResponseParameter()CgetConfig()protected abstract StringgetDefaultScopes()BrokeredIdentityContextgetFederatedIdentity(String response)StringgetJsonProperty(com.fasterxml.jackson.databind.JsonNode jsonNode, String name)Get JSON property as text.protected StringgetProfileEndpointForValidation(EventBuilder event)protected SignatureSignerContextgetSignatureContext()protected javax.ws.rs.core.ResponsehasExternalExchangeToken(EventBuilder event, UserSessionModel tokenUserSession, javax.ws.rs.core.MultivaluedMap<String,String> params)check to see if we have a token exchange in session in other words check to see if this session was created by an external exchangebooleanisIssuer(String issuer, javax.ws.rs.core.MultivaluedMap<String,String> params)javax.ws.rs.core.ResponseperformLogin(AuthenticationRequest request)Initiates the authentication process by sending an authentication request to an identity provider.javax.ws.rs.core.ResponseretrieveToken(KeycloakSession session, FederatedIdentityModel identity)Returns aResponsecontaining the token previously stored during the authentication process for a specific user.protected booleansupportsExternalExchange()protected BrokeredIdentityContextvalidateExternalTokenThroughUserInfo(EventBuilder event, String subjectToken, String subjectTokenType)- 
Methods inherited from class org.keycloak.broker.provider.AbstractIdentityProviderbackchannelLogout, close, exchangeErrorResponse, exchangeNotLinked, exchangeNotLinkedNoStore, exchangeNotSupported, exchangeTokenExpired, exchangeUnsupportedRequiredType, export, getLinkingUrl, getMarshaller, importNewUser, keycloakInitiatedBrowserLogout, preprocessFederatedIdentity, updateBrokeredUser
 
- 
 
- 
- 
- 
Field Detail- 
loggerprotected static final org.jboss.logging.Logger logger 
 - 
OAUTH2_GRANT_TYPE_REFRESH_TOKENpublic static final String OAUTH2_GRANT_TYPE_REFRESH_TOKEN - See Also:
- Constant Field Values
 
 - 
OAUTH2_GRANT_TYPE_AUTHORIZATION_CODEpublic static final String OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE - See Also:
- Constant Field Values
 
 - 
FEDERATED_REFRESH_TOKENpublic static final String FEDERATED_REFRESH_TOKEN - See Also:
- Constant Field Values
 
 - 
FEDERATED_TOKEN_EXPIRATIONpublic static final String FEDERATED_TOKEN_EXPIRATION - See Also:
- Constant Field Values
 
 - 
ACCESS_DENIEDpublic static final String ACCESS_DENIED - See Also:
- Constant Field Values
 
 - 
mapperprotected static com.fasterxml.jackson.databind.ObjectMapper mapper 
 - 
OAUTH2_PARAMETER_ACCESS_TOKENpublic static final String OAUTH2_PARAMETER_ACCESS_TOKEN - See Also:
- Constant Field Values
 
 - 
OAUTH2_PARAMETER_SCOPEpublic static final String OAUTH2_PARAMETER_SCOPE - See Also:
- Constant Field Values
 
 - 
OAUTH2_PARAMETER_STATEpublic static final String OAUTH2_PARAMETER_STATE - See Also:
- Constant Field Values
 
 - 
OAUTH2_PARAMETER_RESPONSE_TYPEpublic static final String OAUTH2_PARAMETER_RESPONSE_TYPE - See Also:
- Constant Field Values
 
 - 
OAUTH2_PARAMETER_REDIRECT_URIpublic static final String OAUTH2_PARAMETER_REDIRECT_URI - See Also:
- Constant Field Values
 
 - 
OAUTH2_PARAMETER_CODEpublic static final String OAUTH2_PARAMETER_CODE - See Also:
- Constant Field Values
 
 - 
OAUTH2_PARAMETER_CLIENT_IDpublic static final String OAUTH2_PARAMETER_CLIENT_ID - See Also:
- Constant Field Values
 
 - 
OAUTH2_PARAMETER_CLIENT_SECRETpublic static final String OAUTH2_PARAMETER_CLIENT_SECRET - See Also:
- Constant Field Values
 
 - 
OAUTH2_PARAMETER_GRANT_TYPEpublic static final String OAUTH2_PARAMETER_GRANT_TYPE - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
AbstractOAuth2IdentityProviderpublic AbstractOAuth2IdentityProvider(KeycloakSession session, C config) 
 
- 
 - 
Method Detail- 
callbackpublic Object callback(RealmModel realm, IdentityProvider.AuthenticationCallback callback, EventBuilder event) Description copied from interface:IdentityProviderJAXRS callback endpoint for when the remote IDP wants to callback to keycloak.- Specified by:
- callbackin interface- IdentityProvider<C extends OAuth2IdentityProviderConfig>
- Overrides:
- callbackin class- AbstractIdentityProvider<C extends OAuth2IdentityProviderConfig>
- Returns:
 
 - 
performLoginpublic javax.ws.rs.core.Response performLogin(AuthenticationRequest request) Description copied from interface:IdentityProviderInitiates the authentication process by sending an authentication request to an identity provider. This method is called only once during the authentication. - Specified by:
- performLoginin interface- IdentityProvider<C extends OAuth2IdentityProviderConfig>
- Overrides:
- performLoginin class- AbstractIdentityProvider<C extends OAuth2IdentityProviderConfig>
- Parameters:
- request- The initial authentication request. Contains all the contextual information in order to build an authentication request to the identity provider.
- Returns:
 
 - 
retrieveTokenpublic javax.ws.rs.core.Response retrieveToken(KeycloakSession session, FederatedIdentityModel identity) Description copied from interface:IdentityProviderReturns a Responsecontaining the token previously stored during the authentication process for a specific user.- Specified by:
- retrieveTokenin interface- IdentityProvider<C extends OAuth2IdentityProviderConfig>
- Returns:
 
 - 
getConfigpublic C getConfig() - Overrides:
- getConfigin class- AbstractIdentityProvider<C extends OAuth2IdentityProviderConfig>
 
 - 
extractTokenFromResponseprotected String extractTokenFromResponse(String response, String tokenName) 
 - 
exchangeFromTokenpublic javax.ws.rs.core.Response exchangeFromToken(javax.ws.rs.core.UriInfo uriInfo, EventBuilder event, ClientModel authorizedClient, UserSessionModel tokenUserSession, UserModel tokenSubject, javax.ws.rs.core.MultivaluedMap<String,String> params)- Specified by:
- exchangeFromTokenin interface- ExchangeTokenToIdentityProviderToken
- authorizedClient- client requesting exchange
- tokenUserSession- UserSessionModel of token exchanging from
- tokenSubject- UserModel of token exchanging from
- params- form parameters received for requested exchange
- Returns:
 
 - 
hasExternalExchangeTokenprotected javax.ws.rs.core.Response hasExternalExchangeToken(EventBuilder event, UserSessionModel tokenUserSession, javax.ws.rs.core.MultivaluedMap<String,String> params) check to see if we have a token exchange in session in other words check to see if this session was created by an external exchange- Parameters:
- tokenUserSession-
- params-
- Returns:
 
 - 
exchangeStoredTokenprotected javax.ws.rs.core.Response exchangeStoredToken(javax.ws.rs.core.UriInfo uriInfo, EventBuilder event, ClientModel authorizedClient, UserSessionModel tokenUserSession, UserModel tokenSubject)
 - 
exchangeSessionTokenprotected javax.ws.rs.core.Response exchangeSessionToken(javax.ws.rs.core.UriInfo uriInfo, EventBuilder event, ClientModel authorizedClient, UserSessionModel tokenUserSession, UserModel tokenSubject)
 - 
getFederatedIdentitypublic BrokeredIdentityContext getFederatedIdentity(String response) 
 - 
getAccessTokenResponseParameterprotected String getAccessTokenResponseParameter() 
 - 
doGetFederatedIdentityprotected BrokeredIdentityContext doGetFederatedIdentity(String accessToken) 
 - 
createAuthorizationUrlprotected javax.ws.rs.core.UriBuilder createAuthorizationUrl(AuthenticationRequest request) 
 - 
getJsonPropertypublic String getJsonProperty(com.fasterxml.jackson.databind.JsonNode jsonNode, String name) Get JSON property as text. JSON numbers and booleans are converted to text. Empty string is converted to null.- Parameters:
- jsonNode- to get property from
- name- of property to get
- Returns:
- string value of the property or null.
 
 - 
asJsonNodepublic com.fasterxml.jackson.databind.JsonNode asJsonNode(String json) throws IOException - Throws:
- IOException
 
 - 
getDefaultScopesprotected abstract String getDefaultScopes() 
 - 
authenticationFinishedpublic void authenticationFinished(AuthenticationSessionModel authSession, BrokeredIdentityContext context) - Specified by:
- authenticationFinishedin interface- IdentityProvider<C extends OAuth2IdentityProviderConfig>
- Overrides:
- authenticationFinishedin class- AbstractIdentityProvider<C extends OAuth2IdentityProviderConfig>
 
 - 
authenticateTokenRequestpublic SimpleHttp authenticateTokenRequest(SimpleHttp tokenRequest) 
 - 
generateTokenprotected JsonWebToken generateToken() 
 - 
getSignatureContextprotected SignatureSignerContext getSignatureContext() 
 - 
getProfileEndpointForValidationprotected String getProfileEndpointForValidation(EventBuilder event) 
 - 
extractIdentityFromProfileprotected BrokeredIdentityContext extractIdentityFromProfile(EventBuilder event, com.fasterxml.jackson.databind.JsonNode node) 
 - 
validateExternalTokenThroughUserInfoprotected BrokeredIdentityContext validateExternalTokenThroughUserInfo(EventBuilder event, String subjectToken, String subjectTokenType) 
 - 
buildUserInfoRequestprotected SimpleHttp buildUserInfoRequest(String subjectToken, String userInfoUrl) 
 - 
supportsExternalExchangeprotected boolean supportsExternalExchange() 
 - 
isIssuerpublic boolean isIssuer(String issuer, javax.ws.rs.core.MultivaluedMap<String,String> params) - Specified by:
- isIssuerin interface- ExchangeExternalToken
 
 - 
exchangeExternalpublic final BrokeredIdentityContext exchangeExternal(EventBuilder event, javax.ws.rs.core.MultivaluedMap<String,String> params) - Specified by:
- exchangeExternalin interface- ExchangeExternalToken
 
 - 
exchangeExternalImplprotected BrokeredIdentityContext exchangeExternalImpl(EventBuilder event, javax.ws.rs.core.MultivaluedMap<String,String> params) 
 - 
exchangeExternalUserInfoValidationOnlyprotected BrokeredIdentityContext exchangeExternalUserInfoValidationOnly(EventBuilder event, javax.ws.rs.core.MultivaluedMap<String,String> params) 
 - 
exchangeExternalCompletepublic void exchangeExternalComplete(UserSessionModel userSession, BrokeredIdentityContext context, javax.ws.rs.core.MultivaluedMap<String,String> params) - Specified by:
- exchangeExternalCompletein interface- ExchangeExternalToken
 
 
- 
 
-