Package io.continual.iam.identity
Interface IdentityManager<I extends Identity>
- All Superinterfaces:
IdentityDb<I>
- All Known Subinterfaces:
IamDb<I,G>
- All Known Implementing Classes:
CommonJsonDb,JsonDocDb,MultiSourceDb
This interface to the database allows the caller to make changes to identity
information, like creating users, enabling/disabling users, etc.
A userId string can be any value suitable to the application, such as email address or UUID. Note that userIds are fixed, so using an email address comes with some risk of identity migration work if the email address changes.
A userId string can be any value suitable to the application, such as email address or UUID. Note that userIds are fixed, so using an email address comes with some risk of identity migration work if the email address changes.
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a username/alias for this user.voidAdd a JWT validator to the identity manager.booleancompletePasswordReset(String tag, String newPassword) Complete a password reset by providing a tag and a new password.Create a new anonymous user in the identity manager.createUser(String userId) Create a new user in the identity manager.voiddeleteUser(String userId) Delete a user from the identity manager.Find users with a user ID that starts with the given stringgetAliasesFor(String userId) Get the aliases for a userId.Get all user IDs in this db.Load all users in this identity manager.loadApiKeyRecord(String apiKey) Load an API key record based on the API key ID.voidremoveAlias(String alias) Remove a username/alias from the database.voidrestoreApiKey(ApiKey key) Restore an API key into the API key storeMethods inherited from interface io.continual.iam.identity.IdentityDb
authenticate, authenticate, authenticate, createJwtToken, invalidateJwtToken, loadUser, loadUserOrAlias, userExists, userOrAliasExists
-
Method Details
-
findUsers
Find users with a user ID that starts with the given string- Parameters:
startingWith- a prefix for users- Returns:
- a list of 0 or more matching user IDs
- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
createUser
Create a new user in the identity manager. The username for this user defaults to the userId value provided here.- Parameters:
userId- a user ID- Returns:
- the new user
- Throws:
IamIdentityExists- if the user existsIamSvcException- when the call cannot be completed due to a service error
-
createAnonymousUser
Create a new anonymous user in the identity manager.- Returns:
- a new anonymous user
- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
deleteUser
Delete a user from the identity manager.- Parameters:
userId- a user ID- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
addAlias
Add a username/alias for this user. Identity DBs should normally support multiple aliases (username, email, mobile phone, etc.). Tracking them beyond being references to an identity record is done at the application level.- Parameters:
userId- a user IDalias- an alias- Throws:
IamSvcException- when the call cannot be completed due to a service errorIamBadRequestException- if the request is illegal
-
removeAlias
Remove a username/alias from the database. A userId may not be removed (disable the user instead).- Parameters:
alias- an alias- Throws:
IamBadRequestException- If a userId is provided.IamSvcException- when the call cannot be completed due to a service error
-
getAliasesFor
Get the aliases for a userId. The result must be non-null but may be empty. The userId is not included in the list.- Parameters:
userId- a user ID- Returns:
- a collection of 0 or more aliases for a userId
- Throws:
IamSvcException- when the call cannot be completed due to a service errorIamIdentityDoesNotExist- if the identity does not exist
-
completePasswordReset
Complete a password reset by providing a tag and a new password. The update will fail if the tag is unknown or has expired. SeerequestPasswordResetfor details on creating a password reset tag.- Parameters:
tag- a tagnewPassword- a new password- Returns:
- true if the password was updated successfully.
- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
loadApiKeyRecord
Load an API key record based on the API key ID.- Parameters:
apiKey- an API key- Returns:
- an API key or null if it doesn't exist
- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
restoreApiKey
void restoreApiKey(ApiKey key) throws IamIdentityDoesNotExist, IamBadRequestException, IamSvcException Restore an API key into the API key store- Parameters:
key-- Throws:
IamBadRequestExceptionIamIdentityDoesNotExistIamSvcException
-
addJwtValidator
Add a JWT validator to the identity manager.- Parameters:
v- a validator
-
getAllUsers
Get all user IDs in this db. Clearly not suitable for systems beyond a few thousand users. For larger scale, this call may throw an IamSvcException signaling that the underlying database won't return a user list.- Returns:
- a collection of user Ids
- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
loadAllUsers
Load all users in this identity manager. Clearly not suitable for systems beyond a few thousand users. For larger scale, this call may throw an IamSvcException signaling that the underlying database won't return a user list.- Returns:
- a map of user ID to identity
- Throws:
IamSvcException- when the call cannot be completed due to a service error
-