Class IdentityProviderBean
java.lang.Object
org.keycloak.forms.login.freemarker.model.IdentityProviderBean
- Direct Known Subclasses:
OrganizationAwareIdentityProviderBean
- Author:
- Stian Thorgersen, Vlastimil Elias (velias at redhat dot com)
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected URIprotected AuthenticationFlowContextprotected List<IdentityProviderBean.IdentityProvider>protected RealmModelprotected KeycloakSession -
Constructor Summary
ConstructorsConstructorDescriptionIdentityProviderBean(KeycloakSession session, RealmModel realm, URI baseURI, AuthenticationFlowContext context) -
Method Summary
Modifier and TypeMethodDescriptionprotected IdentityProviderBean.IdentityProvidercreateIdentityProvider(RealmModel realm, URI baseURI, IdentityProviderModel identityProvider) Creates anIdentityProviderBean.IdentityProviderinstance from the specifiedIdentityProviderModel.protected Predicate<IdentityProviderModel>Returns a predicate that can filter out IDPs associated with the current user's federated identities before those are converted intoIdentityProviderBean.IdentityProviders.protected StringgetExistingIDP(KeycloakSession session, AuthenticationFlowContext context) Checks if an IDP is being connected to the user's account.protected List<IdentityProviderBean.IdentityProvider>getFederatedIdentityProviders(Set<String> federatedProviders, String existingIDP) Builds and returns a list ofIdentityProviderBean.IdentityProviderinstances from the specified set of federated IDPs.getLinkedBrokerAliases(KeycloakSession session, RealmModel realm, AuthenticationFlowContext context) Returns the list of IDPs linked with the user's federated identities, if any.getRealm()protected List<IdentityProviderBean.IdentityProvider>searchForIdentityProviders(String existingIDP) Builds and returns a list ofIdentityProviderBean.IdentityProviderinstances that will be available for login.
-
Field Details
-
IDP_COMPARATOR_INSTANCE
public static OrderedModel.OrderedModelComparator<IdentityProviderBean.IdentityProvider> IDP_COMPARATOR_INSTANCE -
context
-
providers
-
session
-
realm
-
baseURI
-
-
Constructor Details
-
IdentityProviderBean
public IdentityProviderBean(KeycloakSession session, RealmModel realm, URI baseURI, AuthenticationFlowContext context)
-
-
Method Details
-
getProviders
-
getSession
-
getRealm
-
getBaseURI
-
getFlowContext
-
createIdentityProvider
protected IdentityProviderBean.IdentityProvider createIdentityProvider(RealmModel realm, URI baseURI, IdentityProviderModel identityProvider) Creates anIdentityProviderBean.IdentityProviderinstance from the specifiedIdentityProviderModel.- Parameters:
realm- a reference to the realm.baseURI- the base URI.identityProvider- theIdentityProviderModelfrom which the freemarkerIdentityProviderBean.IdentityProvideris to be built.- Returns:
- the constructed
IdentityProviderBean.IdentityProvider.
-
getExistingIDP
Checks if an IDP is being connected to the user's account. In this case the currentUser isnulland the current flow is theFIRST_BROKER_LOGIN_PATH, so we should retrieve the IDP they used for login and filter it out of the list of IDPs that are available for login. (GHI #14173).- Parameters:
session- a reference to theKeycloakSession.context- a reference to theAuthenticationFlowContext.- Returns:
- the alias of the IDP used for login before linking a new IDP to the user's account (if any).
-
getLinkedBrokerAliases
protected Set<String> getLinkedBrokerAliases(KeycloakSession session, RealmModel realm, AuthenticationFlowContext context) Returns the list of IDPs linked with the user's federated identities, if any. In case these IDPs exist, the login page should show only the IDPs already linked to the user. Returningnullindicates that all public enabled IDPs should be available. Returning an empty set essentially narrows the list of available IDPs to zero, so no IDPs will be shown for login.- Parameters:
session- a reference to theKeycloakSession.realm- a reference to the realm.context- a reference to theAuthenticationFlowContext.- Returns:
- a
Setcontaining the aliases of the IDPs that should be available for login. An empty set indicates that no IDPs should be available.
-
getFederatedIdentityProviders
protected List<IdentityProviderBean.IdentityProvider> getFederatedIdentityProviders(Set<String> federatedProviders, String existingIDP) Builds and returns a list ofIdentityProviderBean.IdentityProviderinstances from the specified set of federated IDPs. The IDPs must be enabled, not link-only, and not set to be hidden on login page. If any IDP has an alias that matches theexistingIDPparameter, it must be filtered out.- Parameters:
federatedProviders- aSetcontaining the aliases of the federated IDPs that should be considered for login.existingIDP- the alias of the IDP that must be filtered out from the result (used when linking a new IDP to a user's account).- Returns:
- a
Listcontaining the constructedIdentityProviderBean.IdentityProviders.
-
federatedProviderPredicate
Returns a predicate that can filter out IDPs associated with the current user's federated identities before those are converted intoIdentityProviderBean.IdentityProviders. Subclasses may use this as a way to further refine the IDPs that are to be returned.- Returns:
- the custom
Predicateused as a last filter before conversion intoIdentityProviderBean.IdentityProvider
-
searchForIdentityProviders
protected List<IdentityProviderBean.IdentityProvider> searchForIdentityProviders(String existingIDP) Builds and returns a list ofIdentityProviderBean.IdentityProviderinstances that will be available for login. This method goes to theIdentityProviderStorageProviderto fetch the IDPs that can be used for login (enabled, not link-only and not set to be hidden on login page).- Parameters:
existingIDP- the alias of the IDP that must be filtered out from the result (used when linking a new IDP to a user's account).- Returns:
- a
Listcontaining the constructedIdentityProviderBean.IdentityProviders.
-