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 URI
protected AuthenticationFlowContext
protected List<IdentityProviderBean.IdentityProvider>
protected RealmModel
protected KeycloakSession
-
Constructor Summary
ConstructorsConstructorDescriptionIdentityProviderBean
(KeycloakSession session, RealmModel realm, URI baseURI, AuthenticationFlowContext context) -
Method Summary
Modifier and TypeMethodDescriptionprotected IdentityProviderBean.IdentityProvider
createIdentityProvider
(RealmModel realm, URI baseURI, IdentityProviderModel identityProvider) Creates anIdentityProviderBean.IdentityProvider
instance 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.IdentityProvider
s.protected String
getExistingIDP
(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.IdentityProvider
instances 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.IdentityProvider
instances 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.IdentityProvider
instance from the specifiedIdentityProviderModel
.- Parameters:
realm
- a reference to the realm.baseURI
- the base URI.identityProvider
- theIdentityProviderModel
from which the freemarkerIdentityProviderBean.IdentityProvider
is 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 isnull
and 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. Returningnull
indicates 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
Set
containing 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.IdentityProvider
instances 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 theexistingIDP
parameter, it must be filtered out.- Parameters:
federatedProviders
- aSet
containing 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
List
containing the constructedIdentityProviderBean.IdentityProvider
s.
-
federatedProviderPredicate
Returns a predicate that can filter out IDPs associated with the current user's federated identities before those are converted intoIdentityProviderBean.IdentityProvider
s. Subclasses may use this as a way to further refine the IDPs that are to be returned.- Returns:
- the custom
Predicate
used as a last filter before conversion intoIdentityProviderBean.IdentityProvider
-
searchForIdentityProviders
protected List<IdentityProviderBean.IdentityProvider> searchForIdentityProviders(String existingIDP) Builds and returns a list ofIdentityProviderBean.IdentityProvider
instances that will be available for login. This method goes to theIdentityProviderStorageProvider
to 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
List
containing the constructedIdentityProviderBean.IdentityProvider
s.
-