7.7.2. Implementing UserQueryProvider
Without implementing UserQueryProvider
the administration console would not be able to view and manage users that were loaded by our example provider. Let’s look at implementing this interface.
PropertyFileUserStorageProvider
The getUsers()
method iterates over the key set of the property file, delegating to getUserByUsername()
to load a user. Notice that we are indexing this call based on the firstResult
and maxResults
parameter. If your external store does not support pagination, you will have to do similar logic.
PropertyFileUserStorageProvider
The first declaration of searchForUser()
takes a String
parameter. This is supposed to be a string that you use to search username and email attributes to find the user. This string can be a substring, which is why we use the String.contains()
method when doing our search.
PropertyFileUserStorageProvider
The searchForUser()
method that takes a Map
parameter can search for a user based on first, last name, username, and email. We only store usernames, so we only search based on usernames. We delegate to searchForUser()
for this.
PropertyFileUserStorageProvider
We do not store groups or attributes, so the other methods return an empty list.