public class FileUserManager extends Object implements UserManager
UserManager
responsible for managing users stored in a file. The file is
read on construction and written to on the call to #close()
. A UserDetails
password is encrypted using the defined PasswordEncoder
. The encoded password is set,
assuming that UserDetails
has a setPassword(String)
method. If one isn't
declared an exception is thrown.
Constructor and Description |
---|
FileUserManager(FileServiceAccessor fileServiceAccessor,
boolean isReadOnly) |
Modifier and Type | Method and Description |
---|---|
void |
createUser(UserDetails userDetails)
Create a new user with the specified
userDetails . |
void |
deleteUser(String username)
Delete an existing user represented by the specified
username . |
UserDetails |
getUser(String username)
Retrieve the user details by
username . |
boolean |
isReadOnly()
Indicates that this manager is for read-only purposes, and that any invocation of a
destructive operation will throw an
AccessDeniedException . |
Map<String,UserDetails> |
mapUsers()
Returns a map containing mapping between username and user-details.
|
void |
updateUser(UserDetails userDetails)
Updates the user details, excluding the username which must remain the same.
|
boolean |
userExists(String username)
Queries for presence of a user by username.
|
public FileUserManager(FileServiceAccessor fileServiceAccessor, boolean isReadOnly)
public boolean isReadOnly()
UserManager
AccessDeniedException
.isReadOnly
in interface UserManager
true
if read-only access is allowed.public void createUser(UserDetails userDetails) throws UserAlreadyExistsException, UserDataAccessException, AccessDeniedException
UserManager
userDetails
.createUser
in interface UserManager
userDetails
- new user details to store.UserAlreadyExistsException
- if the user details represent a non-unique userUserDataAccessException
- if could not store the specified user details.AccessDeniedException
- if read-only access is allowed.public void deleteUser(String username) throws UserNotFoundException, UserDataAccessException, AccessDeniedException
UserManager
username
.deleteUser
in interface UserManager
username
- an existing user name.UserNotFoundException
- if the user was not found.UserDataAccessException
- if could not delete the specified user details.AccessDeniedException
- if read-only access is allowed.public UserDetails getUser(String username) throws UserNotFoundException, UserDataAccessException
UserManager
username
.getUser
in interface UserManager
username
- an existing user to retrieve.UserNotFoundException
- if the user was not found.UserDataAccessException
- if could not retrieve the specified user details.public Map<String,UserDetails> mapUsers() throws UserDataAccessException
UserManager
mapUsers
in interface UserManager
UserDataAccessException
- if could not retrieve user-details to map.public void updateUser(UserDetails userDetails) throws UserNotFoundException, UserDataAccessException
UserManager
updateUser
in interface UserManager
userDetails
- the user details to update.UserNotFoundException
- if the user was not found.UserDataAccessException
- if could not update the user details.public boolean userExists(String username) throws UserDataAccessException
UserManager
userExists
in interface UserManager
username
- the user to check existence for.true
if the user exists; false
otherwise.UserDataAccessException
- if could not query for the specified user.Copyright © GigaSpaces.