Package org.keycloak.ipatuura_user_spi
Class IpatuuraUserStorageProvider
java.lang.Object
org.keycloak.ipatuura_user_spi.IpatuuraUserStorageProvider
- All Implemented Interfaces:
CredentialAuthentication
,CredentialInputValidator
,Provider
,ImportedUserValidation
,UserCountMethodsProvider
,UserLookupProvider
,UserQueryMethodsProvider
,UserQueryProvider
,UserRegistrationProvider
,UserStorageProvider
public class IpatuuraUserStorageProvider
extends Object
implements UserStorageProvider, UserLookupProvider, CredentialInputValidator, CredentialAuthentication, UserRegistrationProvider, UserQueryProvider, ImportedUserValidation
- Version:
- $Revision: 1 $
- Author:
- Justin Stephenson
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.keycloak.storage.UserStorageProvider
UserStorageProvider.EditMode
-
Field Summary
Modifier and TypeFieldDescriptionprotected IpatuuraUserStorageProviderFactory
protected Ipatuura
protected ComponentModel
protected KeycloakSession
-
Constructor Summary
ConstructorDescriptionIpatuuraUserStorageProvider
(KeycloakSession session, ComponentModel model, Ipatuura ipatuura, IpatuuraUserStorageProviderFactory factory) -
Method Summary
Modifier and TypeMethodDescriptionaddUser
(RealmModel realm, String username) All storage providers that implement this interface will be looped through.authenticate
(RealmModel realm, CredentialInput input) void
close()
protected UserModel
createUserInKeycloak
(RealmModel realm, String username) getGroupMembersStream
(RealmModel arg0, GroupModel arg1, Integer arg2, Integer arg3) Obtains users that belong to a specific group.getUserByEmail
(RealmModel realm, String email) Returns a user with the given email belonging to the realmgetUserById
(RealmModel realm, String id) Returns a user with the given id belonging to the realmgetUserByUsername
(RealmModel realm, String username) Exact search for a user by its username.int
getUsersCount
(RealmModel realm) Returns the number of users, without consider any service account.boolean
isConfiguredFor
(RealmModel realm, UserModel user, String credentialType) boolean
isValid
(RealmModel realm, UserModel user, CredentialInput input) Tests whether a credential is validboolean
removeUser
(RealmModel realm, UserModel user) Called if user originated from this provider.searchForUserByUserAttributeStream
(RealmModel realm, String attrName, String attrValue) Searches for users that have a specific attribute with a specific value.searchForUserStream
(RealmModel realm, Map<String, String> params, Integer firstResult, Integer maxResults) Searches for user by parameter.boolean
boolean
supportsCredentialType
(String credentialType) validate
(RealmModel realm, UserModel local) If this method returns null, then the user in local storage will be removedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.keycloak.storage.user.UserCountMethodsProvider
getUsersCount, getUsersCount, getUsersCount, getUsersCount, getUsersCount, getUsersCount
Methods inherited from interface org.keycloak.storage.user.UserLookupProvider
getUserByCredential
Methods inherited from interface org.keycloak.storage.user.UserQueryMethodsProvider
getGroupMembersStream, getGroupMembersStream, getRoleMembersStream, getRoleMembersStream, searchForUserStream, searchForUserStream, searchForUserStream
Methods inherited from interface org.keycloak.storage.UserStorageProvider
preRemove, preRemove, preRemove
-
Field Details
-
session
-
model
-
ipatuura
-
supportedCredentialTypes
-
factory
-
-
Constructor Details
-
IpatuuraUserStorageProvider
public IpatuuraUserStorageProvider(KeycloakSession session, ComponentModel model, Ipatuura ipatuura, IpatuuraUserStorageProviderFactory factory)
-
-
Method Details
-
getUserByEmail
Description copied from interface:UserLookupProvider
Returns a user with the given email belonging to the realm- Specified by:
getUserByEmail
in interfaceUserLookupProvider
- Parameters:
realm
- the realm modelemail
- email address- Returns:
- found user model, or
null
if no such user exists
-
getUserById
Description copied from interface:UserLookupProvider
Returns a user with the given id belonging to the realm- Specified by:
getUserById
in interfaceUserLookupProvider
- Parameters:
realm
- the realm modelid
- id of the user- Returns:
- found user model, or
null
if no such user exists
-
getUserByUsername
Description copied from interface:UserLookupProvider
Exact search for a user by its username. Returns a user with the given username belonging to the realm- Specified by:
getUserByUsername
in interfaceUserLookupProvider
- Parameters:
realm
- the realm modelusername
- (case-sensitivity is controlled by storage)- Returns:
- found user model, or
null
if no such user exists
-
createUserInKeycloak
-
close
public void close() -
getSupportedCredentialTypes
-
isConfiguredFor
- Specified by:
isConfiguredFor
in interfaceCredentialInputValidator
-
supportsCredentialType
- Specified by:
supportsCredentialType
in interfaceCredentialInputValidator
-
isValid
Description copied from interface:CredentialInputValidator
Tests whether a credential is valid- Specified by:
isValid
in interfaceCredentialInputValidator
- Parameters:
realm
- The realm in which to which the credential belongs touser
- The user for which to test the credentialinput
- the credential details to verify- Returns:
- true if the passed secret is correct
-
validate
Description copied from interface:ImportedUserValidation
If this method returns null, then the user in local storage will be removed- Specified by:
validate
in interfaceImportedUserValidation
- Returns:
- null if user no longer valid
-
addUser
Description copied from interface:UserRegistrationProvider
All storage providers that implement this interface will be looped through. If this method returns null, then the next storage provider's addUser() method will be called. If no storage providers handle the add, then the user will be created in local storage. Returning null is useful when you want optional support for adding users. For example, our LDAP provider can enable and disable the ability to add users.- Specified by:
addUser
in interfaceUserRegistrationProvider
- Parameters:
realm
- a reference to the realmusername
- a username the created user will be assigned- Returns:
- a model of created user
-
removeUser
Description copied from interface:UserRegistrationProvider
Called if user originated from this provider. If a local user is linked to this provider, this method will be called before local storage's removeUser() method is invoked. If you are using an import strategy, and this is a local user linked to this provider, this method will be called before local storage's removeUser() method is invoked. Also, you DO NOT need to remove the imported user. The runtime will handle this for you.- Specified by:
removeUser
in interfaceUserRegistrationProvider
- Parameters:
realm
- a reference to the realmuser
- a reference to the user that is removed- Returns:
- true if the user was removed, false otherwise
-
getGroupMembersStream
public Stream<UserModel> getGroupMembersStream(RealmModel arg0, GroupModel arg1, Integer arg2, Integer arg3) Description copied from interface:UserQueryMethodsProvider
Obtains users that belong to a specific group.- Specified by:
getGroupMembersStream
in interfaceUserQueryMethodsProvider
- Parameters:
arg0
- a reference to the realm.arg1
- a reference to the group.arg2
- first result to return. Ignored if negative, zero, ornull
.arg3
- maximum number of results to return. Ignored if negative ornull
.- Returns:
- a non-null
Stream
of users that belong to the group.
-
getUsersCount
Description copied from interface:UserCountMethodsProvider
Returns the number of users, without consider any service account.- Specified by:
getUsersCount
in interfaceUserCountMethodsProvider
- Parameters:
realm
- the realm- Returns:
- the number of users
-
searchForUserByUserAttributeStream
public Stream<UserModel> searchForUserByUserAttributeStream(RealmModel realm, String attrName, String attrValue) Description copied from interface:UserQueryMethodsProvider
Searches for users that have a specific attribute with a specific value.- Specified by:
searchForUserByUserAttributeStream
in interfaceUserQueryMethodsProvider
- Parameters:
realm
- a reference to the realm.attrName
- the attribute name.attrValue
- the attribute value.- Returns:
- a non-null
Stream
of users that match the search criteria.
-
searchForUserStream
public Stream<UserModel> searchForUserStream(RealmModel realm, Map<String, String> params, Integer firstResult, Integer maxResults) Description copied from interface:UserQueryMethodsProvider
Searches for user by parameter. If possible, implementations should treat the parameter values as partial match patterns (i.e. in RDMBS terms use LIKE). Valid parameters are:UserModel.SEARCH
- search for users whose username, email, first name or last name contain any of the strings insearch
separated by whitespace, whenSEARCH
is set all other params are ignoredUserModel.FIRST_NAME
- first name (case insensitive string)UserModel.LAST_NAME
- last name (case insensitive string)UserModel.EMAIL
- email (case insensitive string)UserModel.USERNAME
- username (case insensitive string)UserModel.EXACT
- whether search with FIRST_NAME, LAST_NAME, USERNAME or EMAIL should be exact matchUserModel.EMAIL_VERIFIED
- search only for users with verified/non-verified email (true/false)UserModel.ENABLED
- search only for enabled/disabled users (true/false)UserModel.IDP_ALIAS
- search only for users that have a federated identity from idp with the given alias configured (case sensitive string)UserModel.IDP_USER_ID
- search for users with federated identity with the given userId (case sensitive string)
Any other parameters will be treated as custom user attributes.
This method is used by the REST API when querying users.
- Specified by:
searchForUserStream
in interfaceUserQueryMethodsProvider
- Parameters:
realm
- a reference to the realm.params
- a map containing the search parameters.firstResult
- first result to return. Ignored if negative, zero, ornull
.maxResults
- maximum number of results to return. Ignored if negative ornull
.- Returns:
- a non-null
Stream
of users that match the search criteria.
-
supportsCredentialAuthenticationFor
- Specified by:
supportsCredentialAuthenticationFor
in interfaceCredentialAuthentication
-
authenticate
- Specified by:
authenticate
in interfaceCredentialAuthentication
-