I - an identity classG - a group classpublic abstract class CommonJsonDb<I extends CommonJsonIdentity,G extends CommonJsonGroup> extends Object implements IamDb<I,G>
| Modifier and Type | Class and Description |
|---|---|
static interface |
CommonJsonDb.AclFactory |
| Modifier and Type | Field and Description |
|---|---|
static String |
kAlias |
static String |
kCreateTsMs |
static String |
kEnabled |
static String |
kExpireEpoch |
static String |
kPasswordBlock |
static String |
kPasswordHash |
static String |
kPasswordSalt |
static String |
kSecret |
static String |
kTagId |
static String |
kTagType |
static String |
kTagType_PasswordReset |
static String |
kUserId |
kCreateOperation, kDeleteOperation, kReadOperation, kWriteOperation| Modifier | Constructor and Description |
|---|---|
protected |
CommonJsonDb() |
protected |
CommonJsonDb(CommonJsonDb.AclFactory aclMaker,
JwtProducer jwtProd) |
| Modifier and Type | Method and Description |
|---|---|
void |
addAlias(String userId,
String alias)
Add a username/alias for this user.
|
void |
addJwtValidator(JwtValidator v)
Add a JWT validator to the identity manager.
|
void |
addUserToGroup(String groupId,
String userId)
Add a user to a given group
|
protected boolean |
aliasExists(String userId) |
I |
authenticate(ApiKeyCredential akc)
Authenticate with an API key and signature
|
I |
authenticate(JwtCredential jwt)
Authenticate with a JWT token
|
I |
authenticate(UsernamePasswordCredential upc)
Authenticate with a username and password
|
boolean |
canUser(String id,
Resource resource,
String operation)
Can the given user perform the requested access?
|
boolean |
completePasswordReset(String tagId,
String newPassword)
Complete a password reset by providing a tag and a new password.
|
I |
createAnonymousUser()
Create a new anonymous user in the identity manager.
|
ApiKey |
createApiKey(String userId) |
protected abstract org.json.JSONObject |
createApiKeyObject(String userId,
String apiKey,
String apiSecret) |
G |
createGroup(String groupDesc)
Create a group
|
G |
createGroup(String groupId,
String groupDesc)
Create a group with a given group ID
|
String |
createJwtToken(Identity ii)
Create a JWT token for the given identity.
|
protected abstract org.json.JSONObject |
createNewGroup(String id,
String groupDesc) |
protected abstract org.json.JSONObject |
createNewUser(String id) |
String |
createTag(String userId,
String appTagType,
long duration,
TimeUnit durationTimeUnit,
String nonce)
Create a tag for a given user id with a particular type and duration.
|
I |
createUser(String userId)
Create a new user in the identity manager.
|
protected abstract void |
deleteAclObject(String id) |
protected abstract void |
deleteAliasObject(String id) |
protected abstract void |
deleteApiKeyObject(String id) |
protected abstract void |
deleteGroupObject(String id) |
protected abstract void |
deleteTagObject(String id,
String userId,
String appTagType) |
void |
deleteUser(String userId)
Delete a user from the identity manager.
|
protected abstract void |
deleteUserObject(String id) |
static String |
generateKey(int length,
String nonce) |
AccessControlList |
getAclFor(Resource resource)
load an ACL for a resource
|
Collection<String> |
getAliasesFor(String userId)
Get the aliases for a userId.
|
String |
getAppNonce()
return a nonce value for used in seeding things like password salts
|
String |
getUserIdForTag(String tagId)
Retrieves the userId associated with a tag.
|
Set<String> |
getUsersGroups(String userId)
Find out which groups a user is a member of.
|
Set<String> |
getUsersInGroup(String groupId)
Get the set of user IDs in a particular group.
|
protected abstract ApiKey |
instantiateApiKey(String id,
org.json.JSONObject data) |
protected abstract G |
instantiateGroup(String id,
org.json.JSONObject data) |
protected abstract I |
instantiateIdentity(String id,
org.json.JSONObject data) |
void |
invalidateJwtToken(String token)
Invalidate the given JWT token
|
protected abstract boolean |
isInvalidJwtToken(String token) |
protected abstract org.json.JSONObject |
loadAclObject(String id) |
protected abstract Collection<String> |
loadAliasesForUser(String userId) |
protected abstract org.json.JSONObject |
loadAliasObject(String id) |
protected abstract org.json.JSONObject |
loadApiKeyObject(String id) |
ApiKey |
loadApiKeyRecord(String apiKey)
Load an API key record based on the API key ID.
|
protected abstract Collection<String> |
loadApiKeysForUser(String userId) |
G |
loadGroup(String groupId)
Get a group by its identifier.
|
protected abstract org.json.JSONObject |
loadGroupObject(String id) |
protected abstract org.json.JSONObject |
loadTagObject(String id,
boolean expiredOk) |
protected abstract org.json.JSONObject |
loadTagObject(String userId,
String appTagType,
boolean expiredOk) |
I |
loadUser(String userId)
Load a user from the identity manager.
|
protected abstract org.json.JSONObject |
loadUserObject(String id) |
I |
loadUserOrAlias(String userIdOrAlias)
Load a user from the identity manager.
|
void |
onAclUpdate(AccessControlList acl) |
void |
populateMetrics(MetricsCatalog metrics) |
void |
removeAlias(String alias)
Remove a username/alias from the database.
|
void |
removeMatchingTag(String userId,
String appTagType)
Remove any matching tag for the given user and type.
|
void |
removeUserFromGroup(String groupId,
String userId)
Remove a user from a given group
|
void |
restoreApiKey(ApiKey key)
Restore an API key into the API key store
|
protected abstract void |
storeAclObject(String id,
org.json.JSONObject data) |
protected abstract void |
storeAliasObject(String id,
org.json.JSONObject data) |
protected abstract void |
storeApiKeyObject(String id,
org.json.JSONObject data) |
protected abstract void |
storeGroupObject(String id,
org.json.JSONObject data) |
protected abstract void |
storeInvalidJwtToken(String token) |
protected abstract void |
storeTagObject(String id,
String userId,
String appTagType,
org.json.JSONObject data) |
protected abstract void |
storeUserObject(String id,
org.json.JSONObject data) |
boolean |
userExists(String userId)
Find out if a given user exists.
|
boolean |
userOrAliasExists(String userIdOrAlias)
Find out if a given user or alias exists.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfindUsers, getAllUsers, loadAllUsersgetAllGroupssweepExpiredTagspublic static final String kTagId
public static final String kUserId
public static final String kTagType
public static final String kExpireEpoch
public static final String kSecret
public static final String kAlias
public static final String kCreateTsMs
public static final String kEnabled
public static final String kPasswordBlock
public static final String kPasswordSalt
public static final String kPasswordHash
public static final String kTagType_PasswordReset
protected CommonJsonDb()
protected CommonJsonDb(CommonJsonDb.AclFactory aclMaker, JwtProducer jwtProd)
public void populateMetrics(MetricsCatalog metrics)
populateMetrics in interface MetricsSupplierpublic boolean userExists(String userId) throws IamSvcException
IdentityManageruserExists in interface IdentityManager<I extends CommonJsonIdentity>userId - a user IDIamSvcException - when the call cannot be completed due to a service errorpublic boolean userOrAliasExists(String userIdOrAlias) throws IamSvcException
IdentityManageruserOrAliasExists in interface IdentityManager<I extends CommonJsonIdentity>userIdOrAlias - the user ID or an aliasIamSvcException - when the call cannot be completed due to a service errorprotected boolean aliasExists(String userId) throws IamSvcException
IamSvcExceptionpublic I loadUser(String userId) throws IamSvcException
IdentityManagerloadUser in interface IdentityManager<I extends CommonJsonIdentity>userId - a user IDIamSvcException - when the call cannot be completed due to a service errorpublic I loadUserOrAlias(String userIdOrAlias) throws IamSvcException
IdentityManagerloadUserOrAlias in interface IdentityManager<I extends CommonJsonIdentity>userIdOrAlias - the actual userId or an aliasIamSvcException - when the call cannot be completed due to a service errorpublic I createUser(String userId) throws IamSvcException, IamIdentityExists
IdentityManagercreateUser in interface IdentityManager<I extends CommonJsonIdentity>userId - a user IDIamSvcException - when the call cannot be completed due to a service errorIamIdentityExists - if the user existspublic I createAnonymousUser() throws IamSvcException
IdentityManagercreateAnonymousUser in interface IdentityManager<I extends CommonJsonIdentity>IamSvcException - when the call cannot be completed due to a service errorpublic void deleteUser(String userId) throws IamSvcException
IdentityManagerdeleteUser in interface IdentityManager<I extends CommonJsonIdentity>userId - a user IDIamSvcException - when the call cannot be completed due to a service errorpublic boolean completePasswordReset(String tagId, String newPassword) throws IamSvcException
IdentityManagerrequestPasswordReset
for details on creating a password reset tag.completePasswordReset in interface IdentityManager<I extends CommonJsonIdentity>tagId - a tagnewPassword - a new passwordIamSvcException - when the call cannot be completed due to a service errorpublic ApiKey loadApiKeyRecord(String apiKey) throws IamSvcException
IdentityManagerloadApiKeyRecord in interface IdentityManager<I extends CommonJsonIdentity>apiKey - an API keyIamSvcException - when the call cannot be completed due to a service errorpublic void restoreApiKey(ApiKey key) throws IamIdentityDoesNotExist, IamBadRequestException, IamSvcException
restoreApiKey in interface IdentityManager<I extends CommonJsonIdentity>key - IamSvcExceptionIamBadRequestExceptionIamIdentityDoesNotExistpublic String createJwtToken(Identity ii) throws IamSvcException
IdentityDbcreateJwtToken in interface IdentityDb<I extends CommonJsonIdentity>ii - an identityIamSvcException - when the call cannot be completed due to a service errorpublic I authenticate(ApiKeyCredential akc) throws IamSvcException
IdentityDbauthenticate in interface IdentityDb<I extends CommonJsonIdentity>akc - the API key credentialIamSvcException - when the call cannot be completed due to a service errorpublic I authenticate(JwtCredential jwt) throws IamSvcException
IdentityDbauthenticate in interface IdentityDb<I extends CommonJsonIdentity>jwt - the JWT credentialIamSvcException - when the call cannot be completed due to a service errorpublic void invalidateJwtToken(String token) throws IamSvcException
IdentityDbinvalidateJwtToken in interface IdentityDb<I extends CommonJsonIdentity>token - a JWT tokenIamSvcException - when the call cannot be completed due to a service errorpublic I authenticate(UsernamePasswordCredential upc) throws IamSvcException
IdentityDbauthenticate in interface IdentityDb<I extends CommonJsonIdentity>upc - the username/password credentialIamSvcException - when the call cannot be completed due to a service errorpublic G createGroup(String groupDesc) throws IamSvcException
AccessManagercreateGroup in interface AccessManager<G extends CommonJsonGroup>groupDesc - the group descriptionIamSvcException - when the call cannot be completed due to a service errorpublic G createGroup(String groupId, String groupDesc) throws IamGroupExists, IamSvcException
AccessManagercreateGroup in interface AccessManager<G extends CommonJsonGroup>groupId - a group IDgroupDesc - a group descriptionIamGroupExists - if the group already existsIamSvcException - when the call cannot be completed due to a service errorpublic void addUserToGroup(String groupId, String userId) throws IamIdentityDoesNotExist, IamSvcException, IamGroupDoesNotExist
AccessManageraddUserToGroup in interface AccessManager<G extends CommonJsonGroup>groupId - a group IDuserId - a user IDIamIdentityDoesNotExist - when the identity doesn't existIamSvcException - when the call cannot be completed due to a service errorIamGroupDoesNotExist - if the group does not existpublic void removeUserFromGroup(String groupId, String userId) throws IamSvcException, IamIdentityDoesNotExist, IamGroupDoesNotExist
AccessManagerremoveUserFromGroup in interface AccessManager<G extends CommonJsonGroup>groupId - a group IDuserId - a user IDIamSvcException - when the call cannot be completed due to a service errorIamIdentityDoesNotExist - when the identity doesn't existIamGroupDoesNotExist - if the group does not existpublic Set<String> getUsersGroups(String userId) throws IamSvcException, IamIdentityDoesNotExist
AccessManagergetUsersGroups in interface AccessManager<G extends CommonJsonGroup>userId - a user IDIamSvcException - when the call cannot be completed due to a service errorIamIdentityDoesNotExist - when the identity doesn't existpublic Set<String> getUsersInGroup(String groupId) throws IamGroupDoesNotExist, IamSvcException
AccessManagergetUsersInGroup in interface AccessManager<G extends CommonJsonGroup>groupId - a group IDIamGroupDoesNotExist - when the identity doesn't existIamSvcException - when the call cannot be completed due to a service errorpublic G loadGroup(String groupId) throws IamSvcException
AccessDbloadGroup in interface AccessDb<G extends CommonJsonGroup>groupId - the group's IDIamSvcException - if there's a problem in the IAM servicepublic AccessControlList getAclFor(Resource resource) throws IamSvcException
AccessDbgetAclFor in interface AccessDb<G extends CommonJsonGroup>resource - the resource for which you want the ACLIamSvcException - if there's a problem in the IAM servicepublic void onAclUpdate(AccessControlList acl)
onAclUpdate in interface AclUpdateListenerpublic boolean canUser(String id, Resource resource, String operation) throws IamSvcException
AccessDbcanUser in interface AccessDb<G extends CommonJsonGroup>id - the identity/subject making the requestresource - the resource on which access is requestedoperation - the operationIamSvcException - if there's a problem in the IAM servicepublic String createTag(String userId, String appTagType, long duration, TimeUnit durationTimeUnit, String nonce) throws IamSvcException
TagManagercreateTag in interface TagManageruserId - a user IDappTagType - a tag typeduration - the length of time the tag should existdurationTimeUnit - the time unit for the durationnonce - used to seed random number generatorIamSvcException - if there's a problem in the IAM servicepublic String getUserIdForTag(String tagId) throws IamSvcException
TagManagergetUserIdForTag in interface TagManagertagId - a tag generated by createTagIamSvcException - if there's a problem in the IAM servicepublic void removeMatchingTag(String userId, String appTagType) throws IamSvcException
TagManagerremoveMatchingTag in interface TagManageruserId - a user IDappTagType - a tag typeIamSvcException - if there's a problem in the IAM servicepublic void addAlias(String userId, String alias) throws IamSvcException, IamBadRequestException
IdentityManageraddAlias in interface IdentityManager<I extends CommonJsonIdentity>userId - a user IDalias - an aliasIamSvcException - when the call cannot be completed due to a service errorIamBadRequestException - if the request is illegalpublic void removeAlias(String alias) throws IamBadRequestException, IamSvcException
IdentityManagerremoveAlias in interface IdentityManager<I extends CommonJsonIdentity>alias - an aliasIamBadRequestException - If a userId is provided.IamSvcException - when the call cannot be completed due to a service errorpublic Collection<String> getAliasesFor(String userId) throws IamSvcException, IamIdentityDoesNotExist
IdentityManagergetAliasesFor in interface IdentityManager<I extends CommonJsonIdentity>userId - a user IDIamSvcException - when the call cannot be completed due to a service errorIamIdentityDoesNotExist - if the identity does not existpublic void addJwtValidator(JwtValidator v)
IdentityManageraddJwtValidator in interface IdentityManager<I extends CommonJsonIdentity>v - a validatorpublic String getAppNonce()
public ApiKey createApiKey(String userId) throws IamIdentityDoesNotExist, IamSvcException, IamBadRequestException
protected abstract org.json.JSONObject createNewUser(String id)
protected abstract org.json.JSONObject loadUserObject(String id) throws IamSvcException
IamSvcExceptionprotected abstract void storeUserObject(String id, org.json.JSONObject data) throws IamSvcException
IamSvcExceptionprotected abstract void deleteUserObject(String id) throws IamSvcException
IamSvcExceptionprotected abstract org.json.JSONObject loadGroupObject(String id) throws IamSvcException
IamSvcExceptionprotected abstract void storeGroupObject(String id, org.json.JSONObject data) throws IamSvcException
IamSvcExceptionprotected abstract void deleteGroupObject(String id) throws IamSvcException
IamSvcExceptionprotected abstract org.json.JSONObject createApiKeyObject(String userId, String apiKey, String apiSecret)
protected abstract org.json.JSONObject loadApiKeyObject(String id) throws IamSvcException
IamSvcExceptionprotected abstract void storeApiKeyObject(String id, org.json.JSONObject data) throws IamSvcException, IamIdentityDoesNotExist, IamBadRequestException
protected abstract void deleteApiKeyObject(String id) throws IamSvcException
IamSvcExceptionprotected abstract Collection<String> loadApiKeysForUser(String userId) throws IamSvcException, IamIdentityDoesNotExist
protected abstract org.json.JSONObject loadAclObject(String id) throws IamSvcException
IamSvcExceptionprotected abstract void storeAclObject(String id, org.json.JSONObject data) throws IamSvcException
IamSvcExceptionprotected abstract void deleteAclObject(String id) throws IamSvcException
IamSvcExceptionprotected abstract org.json.JSONObject loadTagObject(String id, boolean expiredOk) throws IamSvcException
IamSvcExceptionprotected abstract org.json.JSONObject loadTagObject(String userId, String appTagType, boolean expiredOk) throws IamSvcException
IamSvcExceptionprotected abstract void storeTagObject(String id, String userId, String appTagType, org.json.JSONObject data) throws IamSvcException
IamSvcExceptionprotected abstract void deleteTagObject(String id, String userId, String appTagType) throws IamSvcException
IamSvcExceptionprotected abstract org.json.JSONObject loadAliasObject(String id) throws IamSvcException
IamSvcExceptionprotected abstract void storeAliasObject(String id, org.json.JSONObject data) throws IamSvcException, IamBadRequestException
protected abstract void deleteAliasObject(String id) throws IamSvcException
IamSvcExceptionprotected abstract Collection<String> loadAliasesForUser(String userId) throws IamSvcException, IamIdentityDoesNotExist
protected abstract void storeInvalidJwtToken(String token) throws IamSvcException
IamSvcExceptionprotected abstract boolean isInvalidJwtToken(String token) throws IamSvcException
IamSvcExceptionCopyright © 2022 continual.io. All rights reserved.