Class MongoUserDao
- All Implemented Interfaces:
UserDao
UserDao.
Created by patricktwohig on 3/26/15.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateOrUpdateUser(User user) Creates a user if one does not exist for the provided info or updates a user if one does exist.createUser(User user) Creates or activates a user, or if the user is currently inactive this will reinstate access.createUserStrict(User user) Creates a user with the given User object.createUserWithPassword(User user, String password) Creates a user and sets the user's password.createUserWithPasswordStrict(User user, String password) Creates a user with the given User object and password.findMongoUser(User user) findMongoUser(String userId) findMongoUser(org.bson.types.ObjectId userId) findUserByNameOrEmail(String userNameOrEmail) Finds a user either by email or name.findUserWithLoginAndPassword(String userNameOrEmail, String password) Finds aUsergiven the login credentials and assword.dev.morphia.DatastoregetMongoUser(User user) getMongoUser(String userId) getMongoUser(org.bson.types.ObjectId mongoUserId) Gets the user with the userId.getUsers(int offset, int count) Gets a listing of all users given the offset, and count.Gets a listing of all users given the offset, and count.getUsersByPrimaryPhoneNumbers(int offset, int count, List<String> phones) Gets a listing of all users given the offset, count and phone numbervoidsetDatastore(dev.morphia.Datastore datastore) voidsetDozerMapper(MapperRegistry dozerMapperRegistry) voidsetMongoDBUtils(MongoDBUtils mongoDBUtils) voidsetMongoPasswordUtils(MongoPasswordUtils mongoPasswordUtils) voidsetMongoProfileDao(MongoProfileDao mongoProfileDao) voidsetMongoUserUidDao(MongoUserUidDao mongoUserUidDao) voidsetPasswordEncoding(String passwordEncoding) voidsetValidationHelper(ValidationHelper validationHelper) voidsoftDeleteUser(String userId) Deletes a user from the database.updateUser(User user) Updates the given active user.updateUser(User user, String password) Updates the given active user.updateUser(User user, String newPassword, String oldPassword) Updates the given active user.updateUserStrict(User user) Updates the given user, regardless of active status and then returns the user instance as it was written to the database.updateUserStrict(User user, String password) Updates the given user, regardless of active status and then returns the user instance as it was written to the database.voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.getelements.elements.sdk.dao.UserDao
findUser, getUserByNameOrEmail, validateUserPassword
-
Constructor Details
-
MongoUserDao
public MongoUserDao()
-
-
Method Details
-
getUser
Description copied from interface:UserDaoGets the user with the userId. If the user is not active, then this method will behave as if the user does not exist.- Specified by:
getUserin interfaceUserDao- Parameters:
userId- the user's as determined byUser.getId()- Returns:
- the active user
-
getMongoUser
-
findMongoUser
-
findMongoUser
-
findMongoUser
-
getMongoUser
-
getMongoUser
-
findUserByNameOrEmail
Description copied from interface:UserDaoFinds a user either by email or name.- Specified by:
findUserByNameOrEmailin interfaceUserDao- Parameters:
userNameOrEmail- the username or email- Returns:
- an
Optional<User>
-
getUsers
Description copied from interface:UserDaoGets a listing of all users given the offset, and count. Additionally, the user requested must be active. Users not active will be treated as if they do not exist. -
getUsers
Description copied from interface:UserDaoGets a listing of all users given the offset, and count. Additionally, the user requested must be active. -
getUsersByPrimaryPhoneNumbers
Description copied from interface:UserDaoGets a listing of all users given the offset, count and phone number- Specified by:
getUsersByPrimaryPhoneNumbersin interfaceUserDao- Parameters:
offset- the offsetcount- the countphones- a phone numberto filter the results- Returns:
- the users in the system
-
createUserStrict
Description copied from interface:UserDaoCreates a user with the given User object. Using "Strict" semantics, if the user exists then this will throw an exception. The resulting user will have a scrambled password.- Specified by:
createUserStrictin interfaceUserDao- Parameters:
user- the user to create- Returns:
- the User as it was created.
-
createUserWithPasswordStrict
Description copied from interface:UserDaoCreates a user with the given User object and password. Using "Strict" semantics, if the user exists then this will throw an exception. The resulting user will be assigned the given password.- Specified by:
createUserWithPasswordStrictin interfaceUserDao- Parameters:
user- the user to createpassword- the password to assign the user- Returns:
- the User as it was created.
-
createUserWithPassword
Description copied from interface:UserDaoCreates a user and sets the user's password. If the user exists then this will reinstate the user's account with a new password.- Specified by:
createUserWithPasswordin interfaceUserDao- Parameters:
user- the user to createpassword- the password for the user to use- Returns:
- the User, as was written to the database
-
createUser
Description copied from interface:UserDaoCreates or activates a user, or if the user is currently inactive this will reinstate access. This securely scrambles the user's password and therefore the user must change password at a later date.Similar to
UserDao.createUserStrict(User)the user will be assigned a scrambled password if the user does not exist (or was previously inactive). This will not touch the user's password if the user both exists and was flagged as active.- Specified by:
createUserin interfaceUserDao- Parameters:
user- the user- Returns:
- the User, as written to the database
-
updateUserStrict
Description copied from interface:UserDaoUpdates the given user, regardless of active status and then returns the user instance as it was written to the database.This will only apply to a
This does not change the user's password.Userwith aUserUidcontaining a schema with an id prepended with dev.getelements. Other schemas will be assumed to external login methods.- Specified by:
updateUserStrictin interfaceUserDao- Parameters:
user- the user to update- Returns:
- the user as was written to the database
-
updateUserStrict
Description copied from interface:UserDaoUpdates the given user, regardless of active status and then returns the user instance as it was written to the database.This will only apply to a
This will update the user's password.Userwith aUserUidcontaining a schema with an id prepended with dev.getelements. Other schemas will be assumed to external login methods.- Specified by:
updateUserStrictin interfaceUserDao- Parameters:
user- the user to update- Returns:
- the user as was written to the database
-
updateUser
Description copied from interface:UserDaoUpdates the given active user. If the user has been deleted or has been flagged as inactive, then this method will fail.This will only apply to a
This does not change the user's password.Userwith aUserUidcontaining a schema with an id prepended with dev.getelements. Other schemas will be assumed to external login methods.- Specified by:
updateUserin interfaceUserDao- Parameters:
user- the user to update- Returns:
- the User as written to the database
-
updateUser
Description copied from interface:UserDaoUpdates the given active user. If the user has been deleted or has been flagged as inactive, then this method will fail.This will only apply to a
Userwith aUserUidcontaining a schema with an id prepended with dev.getelements. Other schemas will be assumed to external login methods.- Specified by:
updateUserin interfaceUserDao- Parameters:
user- the user to updatepassword- the user password- Returns:
- the User, as written to the database
-
updateUser
Description copied from interface:UserDaoUpdates the given active user. If the user has been deleted or has been flagged as inactive, then this method will fail.This will only apply to a
Userwith aUserUidcontaining a schema with an id prepended with dev.getelements. Other schemas will be assumed to external login methods.- Specified by:
updateUserin interfaceUserDao- Parameters:
user- the user to updatenewPassword- the user's new passwordoldPassword- the user's old password- Returns:
- the User, as written to the database
-
createOrUpdateUser
Description copied from interface:UserDaoCreates a user if one does not exist for the provided info or updates a user if one does exist.If the user is currently inactive this will reinstate access. This securely scrambles the user's password and therefore the user must change password at a later date.
Similar to
UserDao.createUserStrict(User)the user will be assigned a scrambled password if the user does not exist (or was previously inactive). This will not touch the user's password if the user both exists and was flagged as active.- Specified by:
createOrUpdateUserin interfaceUserDao- Parameters:
user- the user- Returns:
- the User, as written to the database
-
softDeleteUser
Description copied from interface:UserDaoDeletes a user from the database. In actuality, this isn't a true delete, but rather just flags the user as inactive. LazyValue flagged inactive, a user will not show up in any results for active users.- Specified by:
softDeleteUserin interfaceUserDao- Parameters:
userId- the user's as determined byUser.getId()
-
validate
-
findUserWithLoginAndPassword
Description copied from interface:UserDaoFinds aUsergiven the login credentials and assword. If the password validation fails, then this will return an emptyOptional. If the password validation succeeds, then this returns the user that matched.- Specified by:
findUserWithLoginAndPasswordin interfaceUserDao- Parameters:
userNameOrEmail- the user's name or email addresspassword- the password- Returns:
- the User, never null
-
getDatastore
public dev.morphia.Datastore getDatastore() -
setDatastore
@Inject public void setDatastore(dev.morphia.Datastore datastore) -
getPasswordEncoding
-
setPasswordEncoding
@Inject public void setPasswordEncoding(@Named("dev.getelements.elements.password.encoding") String passwordEncoding) -
getValidationHelper
-
setValidationHelper
-
getMongoDBUtils
-
setMongoDBUtils
-
getDozerMapper
-
setDozerMapper
-
getMongoPasswordUtils
-
setMongoPasswordUtils
-
getMongoProfileDao
-
setMongoProfileDao
-
getMongoUserUidDao
-
setMongoUserUidDao
-