Package jmri.jmrit.permission
Class DefaultPermissionManager
java.lang.Object
jmri.jmrit.permission.DefaultPermissionManager
- All Implemented Interfaces:
PermissionManager
Default permission manager.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.PermissionManager
PermissionManager.BadPasswordException, PermissionManager.BadUserOrPasswordException, PermissionManager.LoginListener, PermissionManager.RoleAlreadyExistsException, PermissionManager.RoleDoesNotExistException, PermissionManager.UserAlreadyExistsException, PermissionManager.UserDoesNotExistException -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a login listener.Add a new role.Add a new user.voidchangePassword(String newPassword, String oldPassword) Change an user's password.booleanensureAtLeastPermission(Permission permission, PermissionValue minValue) Checks if the current user has the permission.Get the current username.getPermissions(PermissionOwner owner) getRoles()Return a copy of this PermissionManager.getUsers()booleanhasAtLeastPermission(Permission permission, PermissionValue minValue) Has the current user permission?booleanhasAtLeastRemotePermission(String sessionId, Permission permission, PermissionValue minValue) Has the current user of this session permission?(package private) DefaultPermissionManagerinit()booleanisAGuestUser(String username) Is the user 'username' the guest user?booleanisAGuestUser(User user) Is the user 'user' the guest user?booleanGet if empty passwords is allowed.booleanisCurrentUser(String username) Is the user username the current user?booleanisCurrentUser(User user) Is the user 'user' the current user?booleanIs the current user allowed to change his password?booleanIs the permission manager enabled?booleanIs an user logged in locally?booleanisRemotelyLoggedIn(String sessionId) Is an user logged in locally?booleanLogin locally to JMRI.voidlogout()Logout locally from JMRI.voidregisterOwner(PermissionOwner owner) Register a permission owner.voidregisterPermission(Permission permission) Register a permission.booleanremoteLogin(StringBuilder sessionId, Locale locale, String username, String password) Login remotely to JMRI.voidremoteLogout(String sessionId) Logout remotely from JMRI.voidremoveRole(String name) Removes a role.voidremoveUser(String username) Removes a role.voidsetAllowEmptyPasswords(boolean value) Set if empty passwords should be allowed.voidsetEnabled(boolean enabled) Set if the permission manager should be enabled or not.voidStore permission settings.
-
Constructor Details
-
DefaultPermissionManager
-
DefaultPermissionManager
-
-
Method Details
-
getTemporaryInstance
Return a copy of this PermissionManager.- Returns:
- the copy
-
init
-
getRoles
-
getUsers
-
getOwners
-
getPermissions
-
storePermissionSettings
Description copied from interface:PermissionManagerStore permission settings.- Specified by:
storePermissionSettingsin interfacePermissionManager
-
addRole
Description copied from interface:PermissionManagerAdd a new role.- Specified by:
addRolein interfacePermissionManager- Parameters:
name- the name of the role- Returns:
- the new role
- Throws:
PermissionManager.RoleAlreadyExistsException- if the role already exists
-
removeRole
Description copied from interface:PermissionManagerRemoves a role.- Specified by:
removeRolein interfacePermissionManager- Parameters:
name- the name of the role- Throws:
PermissionManager.RoleDoesNotExistException- if the role doesn't exist
-
addUser
public User addUser(String username, String password) throws PermissionManager.UserAlreadyExistsException Description copied from interface:PermissionManagerAdd a new user.- Specified by:
addUserin interfacePermissionManager- Parameters:
username- the usernamepassword- the password- Returns:
- the new user
- Throws:
PermissionManager.UserAlreadyExistsException- if the username already exists
-
removeUser
Description copied from interface:PermissionManagerRemoves a role.- Specified by:
removeUserin interfacePermissionManager- Parameters:
username- the username- Throws:
PermissionManager.UserDoesNotExistException- if the user doesn't exist
-
changePassword
Description copied from interface:PermissionManagerChange an user's password.- Specified by:
changePasswordin interfacePermissionManager- Parameters:
newPassword- the new passwordoldPassword- the old password
-
login
Description copied from interface:PermissionManagerLogin locally to JMRI.- Specified by:
loginin interfacePermissionManager- Parameters:
username- the usernamepassword- the password- Returns:
- true if login was successful, false otherwise
-
remoteLogin
public boolean remoteLogin(StringBuilder sessionId, Locale locale, String username, String password) Description copied from interface:PermissionManagerLogin remotely to JMRI. This is for the web server, WiThrottle server, and other remote connections.- Specified by:
remoteLoginin interfacePermissionManager- Parameters:
sessionId- the session ID. If empty string, a new session ID will be created.locale- the locale to be used for messages.username- the usernamepassword- the password- Returns:
- true if successful, false otherwise
-
logout
Description copied from interface:PermissionManagerLogout locally from JMRI.- Specified by:
logoutin interfacePermissionManager
-
remoteLogout
Description copied from interface:PermissionManagerLogout remotely from JMRI. This is for the web server, WiThrottle server, and other remote connections.- Specified by:
remoteLogoutin interfacePermissionManager- Parameters:
sessionId- the session ID
-
isLoggedIn
Description copied from interface:PermissionManagerIs an user logged in locally?- Specified by:
isLoggedInin interfacePermissionManager- Returns:
- true if any user except guest is logged in, false otherwise.
-
isRemotelyLoggedIn
Description copied from interface:PermissionManagerIs an user logged in locally?- Specified by:
isRemotelyLoggedInin interfacePermissionManager- Parameters:
sessionId- the session ID- Returns:
- true if any user except guest is logged in to this session, false otherwise.
-
isCurrentUser
Description copied from interface:PermissionManagerIs the user username the current user?- Specified by:
isCurrentUserin interfacePermissionManager- Parameters:
username- the username to check- Returns:
- true if the current user is username, false otherwise.
-
isCurrentUser
Description copied from interface:PermissionManagerIs the user 'user' the current user?- Specified by:
isCurrentUserin interfacePermissionManager- Parameters:
user- the user to check- Returns:
- true if the current user is 'user', false otherwise.
-
getCurrentUserName
Description copied from interface:PermissionManagerGet the current username.- Specified by:
getCurrentUserNamein interfacePermissionManager- Returns:
- the username of the user that's currently logged in or null if no user is logged in.
-
isAGuestUser
Description copied from interface:PermissionManagerIs the user 'username' the guest user?- Specified by:
isAGuestUserin interfacePermissionManager- Parameters:
username- the username to check- Returns:
- true if 'username' is the guest user
-
isAGuestUser
Description copied from interface:PermissionManagerIs the user 'user' the guest user?- Specified by:
isAGuestUserin interfacePermissionManager- Parameters:
user- the user to check- Returns:
- true if 'user' is the guest user
-
isCurrentUserPermittedToChangePassword
Description copied from interface:PermissionManagerIs the current user allowed to change his password?- Specified by:
isCurrentUserPermittedToChangePasswordin interfacePermissionManager- Returns:
- true if a user has logged in and that user is permitted to change his password, false otherwise
-
addLoginListener
Description copied from interface:PermissionManagerAdd a login listener.- Specified by:
addLoginListenerin interfacePermissionManager- Parameters:
listener- the listener
-
isEnabled
Description copied from interface:PermissionManagerIs the permission manager enabled?- Specified by:
isEnabledin interfacePermissionManager- Returns:
- true if it's enabled, false otherwise.
-
setEnabled
Description copied from interface:PermissionManagerSet if the permission manager should be enabled or not.- Specified by:
setEnabledin interfacePermissionManager- Parameters:
enabled- true if it should be enabled, false otherwise.
-
isAllowEmptyPasswords
Description copied from interface:PermissionManagerGet if empty passwords is allowed.- Specified by:
isAllowEmptyPasswordsin interfacePermissionManager- Returns:
- true if empty passwords is allowed, false otherwise.
-
setAllowEmptyPasswords
Description copied from interface:PermissionManagerSet if empty passwords should be allowed.- Specified by:
setAllowEmptyPasswordsin interfacePermissionManager- Parameters:
value- true if empty passwords should be allowed, false otherwise.
-
hasAtLeastPermission
Description copied from interface:PermissionManagerHas the current user permission?- Specified by:
hasAtLeastPermissionin interfacePermissionManager- Parameters:
permission- the permission to checkminValue- the minimum value- Returns:
- true if the user has the permission, false otherwise
-
hasAtLeastRemotePermission
public boolean hasAtLeastRemotePermission(String sessionId, Permission permission, PermissionValue minValue) Description copied from interface:PermissionManagerHas the current user of this session permission?- Specified by:
hasAtLeastRemotePermissionin interfacePermissionManager- Parameters:
sessionId- the session IDpermission- the permission to checkminValue- the minimum value- Returns:
- true if the user has the permission, false otherwise
-
ensureAtLeastPermission
Description copied from interface:PermissionManagerChecks if the current user has the permission. If not, show a message dialog if not headless. Otherwise log a message.- Specified by:
ensureAtLeastPermissionin interfacePermissionManager- Parameters:
permission- the permission to checkminValue- the minimum value- Returns:
- true if the user has the permission, false otherwise
-
registerOwner
Description copied from interface:PermissionManagerRegister a permission owner.- Specified by:
registerOwnerin interfacePermissionManager- Parameters:
owner- the owner
-
registerPermission
Description copied from interface:PermissionManagerRegister a permission.- Specified by:
registerPermissionin interfacePermissionManager- Parameters:
permission- the permission
-