7.7. Add/Remove User and Query Capability interfaces
One thing we have not done with our example is allow it to add and remove users or change passwords. Users defined in our example are also not queryable or viewable in the administration console. To add these enhancements, our example provider must implement the UserQueryProvider
and UserRegistrationProvider
interfaces.
7.7.1. Implementing UserRegistrationProvider リンクのコピーリンクがクリップボードにコピーされました!
To implement adding and removing users from this particular store, we first have to be able to save our properties file to disk.
PropertyFileUserStorageProvider
Then, the implementation of the addUser()
and removeUser()
methods becomes simple.
PropertyFileUserStorageProvider
Notice that when adding a user we set the password value of the property map to be UNSET_PASSWORD
. We do this as we can’t have null values for a property in the property value. We also have to modify the CredentialInputValidator
methods to reflect this.
The addUser()
method will be called if the provider implements the UserRegistrationProvider
interface. If your provider has a configuration switch to turn off adding a user, returning null
from this method will skip the provider and call the next one.
PropertyFileUserStorageProvider
Since we can now save our property file, it also makes sense to allow password updates.
PropertyFileUserStorageProvider
We can now also implement disabling a password.
PropertyFileUserStorageProvider
With these methods implemented, you’ll now be able to change and disable the password for the user in the administration console.