Package io.continual.iam.impl.common
Class CommonJsonIdentity
java.lang.Object
io.continual.iam.impl.common.CommonJsonObject
io.continual.iam.impl.common.CommonJsonIdentity
- All Implemented Interfaces:
Identity,UserDataHolder
-
Constructor Summary
ConstructorsConstructorDescriptionCommonJsonIdentity(String userId, org.json.JSONObject userRecord, CommonJsonDb<? extends CommonJsonIdentity, ?> db) -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected booleanorg.json.JSONObjectasJson()Create an API key for this user.voiddeleteApiKey(ApiKey key) Delete an API key from the user.voidenable(boolean enable) Enable or disable the user.Get the API key supplied to the constructor, if any.protected org.json.JSONObjectGet a group by ID if the user is a member.Get the IDs of the groups this user belongs toGet the groups this user belongs togetId()Get the unique id for this userstatic org.json.JSONObjectbooleanIs this identity enabled?Load the set of API keys for this user.static voidvoidreload()reload this object from the serverprotected booleanremoveGroup(String groupId) requestPasswordReset(long secondsUntilExpire, String nonce) Request a password reset.voidsetApiKeyUsedForAuth(String apiKey) voidsetPassword(String password) Set the user's password.voidsetPasswordSaltAndHash(String salt, String hash) protected voidstore()toString()Methods inherited from class io.continual.iam.impl.common.CommonJsonObject
getAllUserData, getUserData, getValue, getValue, putUserData, removeUserData, removeValue, setValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.continual.iam.identity.UserDataHolder
getAllUserData, getUserData, putUserData, removeUserData
-
Constructor Details
-
CommonJsonIdentity
public CommonJsonIdentity(String userId, org.json.JSONObject userRecord, CommonJsonDb<? extends CommonJsonIdentity, ?> db)
-
-
Method Details
-
initializeIdentity
public static org.json.JSONObject initializeIdentity() -
getId
Description copied from interface:IdentityGet the unique id for this user -
toString
-
setApiKeyUsedForAuth
-
getApiKey
Get the API key supplied to the constructor, if any.- Returns:
- an API key or null
-
asJson
public org.json.JSONObject asJson() -
setPassword
Description copied from interface:IdentitySet the user's password. Implementations of this interface should be careful to store the password indirectly (e.g. via salted hash), but this is not enforced at the interface layer.- Specified by:
setPasswordin interfaceIdentity- Parameters:
password- a password- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
setPasswordSaltAndHash
- Throws:
IamSvcException
-
requestPasswordReset
public String requestPasswordReset(long secondsUntilExpire, String nonce) throws IamSvcException, IamBadRequestException Description copied from interface:IdentityRequest a password reset. The response is a unique tag that would normally be distributed to the user via email as a link. The user acknowledges the password change request by clicking the link. The link handler then calls completePasswordReset().- Specified by:
requestPasswordResetin interfaceIdentity- Parameters:
secondsUntilExpire- amount of time until the generated tag expiresnonce- arbitrary user data used to create the tag- Returns:
- a unique tag
- Throws:
IamSvcException- when the call cannot be completed due to a service errorIamBadRequestException- when the request is now allowed
-
createApiKey
Description copied from interface:IdentityCreate an API key for this user.- Specified by:
createApiKeyin interfaceIdentity- Returns:
- an API key
- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
loadApiKeysForUser
Description copied from interface:IdentityLoad the set of API keys for this user.- Specified by:
loadApiKeysForUserin interfaceIdentity- Returns:
- a set of 0 or more API keys
- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
deleteApiKey
Description copied from interface:IdentityDelete an API key from the user.- Specified by:
deleteApiKeyin interfaceIdentity- Parameters:
key- the API key to remove- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
enable
Description copied from interface:IdentityEnable or disable the user. When disabled, authentication will fail.- Specified by:
enablein interfaceIdentity- Parameters:
enable- if true, enable the user- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
isEnabled
public boolean isEnabled()Description copied from interface:IdentityIs this identity enabled? -
getPasswordSalt
-
getPasswordHash
-
getGroupIds
Description copied from interface:IdentityGet the IDs of the groups this user belongs to- Specified by:
getGroupIdsin interfaceIdentity- Returns:
- a set of group IDs
- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
getGroups
Description copied from interface:IdentityGet the groups this user belongs to- Specified by:
getGroupsin interfaceIdentity- Returns:
- a set of groups
- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
getGroup
Description copied from interface:IdentityGet a group by ID if the user is a member. Otherwise, null is returned.- Specified by:
getGroupin interfaceIdentity- Parameters:
groupId- the ID of the group to retrieve- Returns:
- a group or null if not a member
- Throws:
IamSvcException- when the call cannot be completed due to a service error
-
addApiKey
-
addGroup
-
removeGroup
-
getDataRecord
protected org.json.JSONObject getDataRecord()- Specified by:
getDataRecordin classCommonJsonObject
-
reload
Description copied from interface:UserDataHolderreload this object from the server- Specified by:
reloadin interfaceUserDataHolder- Specified by:
reloadin classCommonJsonObject- Throws:
IamSvcException- if there's a problem in the IAM service
-
store
- Specified by:
storein classCommonJsonObject- Throws:
IamSvcException
-
main
-