Package jmri.jmrit.permission
Class DefaultPermissionManager
- java.lang.Object
- 
- jmri.jmrit.permission.DefaultPermissionManager
 
- 
- All Implemented Interfaces:
- PermissionManager
 
 public class DefaultPermissionManager extends java.lang.Object implements PermissionManager Default permission manager.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface jmri.PermissionManagerPermissionManager.BadPasswordException, PermissionManager.BadUserOrPasswordException, PermissionManager.LoginListener, PermissionManager.RoleAlreadyExistsException, PermissionManager.RoleDoesNotExistException, PermissionManager.UserAlreadyExistsException, PermissionManager.UserDoesNotExistException
 
- 
 - 
Constructor SummaryConstructors Constructor Description DefaultPermissionManager()DefaultPermissionManager(DefaultPermissionManager source)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLoginListener(PermissionManager.LoginListener listener)Add a login listener.RoleaddRole(java.lang.String name)Add a new role.UseraddUser(java.lang.String username, java.lang.String password)Add a new user.voidchangePassword(java.lang.String newPassword, java.lang.String oldPassword)Change an user's password.booleanensureAtLeastPermission(Permission permission, PermissionValue minValue)Checks if the current user has the permission.java.lang.StringgetCurrentUserName()Get the current username.java.util.Set<PermissionOwner>getOwners()java.util.Set<Permission>getPermissions(PermissionOwner owner)java.util.Collection<Role>getRoles()DefaultPermissionManagergetTemporaryInstance()Return a copy of this PermissionManager.java.util.Collection<DefaultUser>getUsers()booleanhasAtLeastPermission(Permission permission, PermissionValue minValue)Has the current user permission?booleanhasAtLeastRemotePermission(java.lang.String sessionId, Permission permission, PermissionValue minValue)Has the current user of this session permission?(package private) DefaultPermissionManagerinit()booleanisAGuestUser(java.lang.String username)Is the user 'username' the guest user?booleanisAGuestUser(User user)Is the user 'user' the guest user?booleanisAllowEmptyPasswords()Get if empty passwords is allowed.booleanisCurrentUser(java.lang.String username)Is the user username the current user?booleanisCurrentUser(User user)Is the user 'user' the current user?booleanisCurrentUserPermittedToChangePassword()Is the current user allowed to change his password?booleanisEnabled()Is the permission manager enabled?booleanisLoggedIn()Is an user logged in locally?booleanisRemotelyLoggedIn(java.lang.String sessionId)Is an user logged in locally?booleanlogin(java.lang.String username, java.lang.String password)Login locally to JMRI.voidlogout()Logout locally from JMRI.voidregisterOwner(PermissionOwner owner)Register a permission owner.voidregisterPermission(Permission permission)Register a permission.booleanremoteLogin(java.lang.StringBuilder sessionId, java.util.Locale locale, java.lang.String username, java.lang.String password)Login remotely to JMRI.voidremoteLogout(java.lang.String sessionId)Logout remotely from JMRI.voidremoveRole(java.lang.String name)Removes a role.voidremoveUser(java.lang.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.voidstorePermissionSettings()Store permission settings.
 
- 
- 
- 
Constructor Detail- 
DefaultPermissionManagerDefaultPermissionManager() 
 - 
DefaultPermissionManagerDefaultPermissionManager(DefaultPermissionManager source) 
 
- 
 - 
Method Detail- 
getTemporaryInstancepublic DefaultPermissionManager getTemporaryInstance() Return a copy of this PermissionManager.- Returns:
- the copy
 
 - 
initDefaultPermissionManager init() 
 - 
getUserspublic java.util.Collection<DefaultUser> getUsers() 
 - 
getOwnerspublic java.util.Set<PermissionOwner> getOwners() 
 - 
getPermissionspublic java.util.Set<Permission> getPermissions(PermissionOwner owner) 
 - 
storePermissionSettingspublic void storePermissionSettings() Description copied from interface:PermissionManagerStore permission settings.- Specified by:
- storePermissionSettingsin interface- PermissionManager
 
 - 
addRolepublic Role addRole(java.lang.String name) throws PermissionManager.RoleAlreadyExistsException Description copied from interface:PermissionManagerAdd a new role.- Specified by:
- addRolein interface- PermissionManager
- Parameters:
- name- the name of the role
- Returns:
- the new role
- Throws:
- PermissionManager.RoleAlreadyExistsException- if the role already exists
 
 - 
removeRolepublic void removeRole(java.lang.String name) throws PermissionManager.RoleDoesNotExistException Description copied from interface:PermissionManagerRemoves a role.- Specified by:
- removeRolein interface- PermissionManager
- Parameters:
- name- the name of the role
- Throws:
- PermissionManager.RoleDoesNotExistException- if the role doesn't exist
 
 - 
addUserpublic User addUser(java.lang.String username, java.lang.String password) throws PermissionManager.UserAlreadyExistsException Description copied from interface:PermissionManagerAdd a new user.- Specified by:
- addUserin interface- PermissionManager
- Parameters:
- username- the username
- password- the password
- Returns:
- the new user
- Throws:
- PermissionManager.UserAlreadyExistsException- if the username already exists
 
 - 
removeUserpublic void removeUser(java.lang.String username) throws PermissionManager.UserDoesNotExistException Description copied from interface:PermissionManagerRemoves a role.- Specified by:
- removeUserin interface- PermissionManager
- Parameters:
- username- the username
- Throws:
- PermissionManager.UserDoesNotExistException- if the user doesn't exist
 
 - 
changePasswordpublic void changePassword(java.lang.String newPassword, java.lang.String oldPassword) Description copied from interface:PermissionManagerChange an user's password.- Specified by:
- changePasswordin interface- PermissionManager
- Parameters:
- newPassword- the new password
- oldPassword- the old password
 
 - 
loginpublic boolean login(java.lang.String username, java.lang.String password) Description copied from interface:PermissionManagerLogin locally to JMRI.- Specified by:
- loginin interface- PermissionManager
- Parameters:
- username- the username
- password- the password
- Returns:
- true if login was successful, false otherwise
 
 - 
remoteLoginpublic boolean remoteLogin(java.lang.StringBuilder sessionId, java.util.Locale locale, java.lang.String username, java.lang.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 interface- PermissionManager
- 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 username
- password- the password
- Returns:
- true if successful, false otherwise
 
 - 
logoutpublic void logout() Description copied from interface:PermissionManagerLogout locally from JMRI.- Specified by:
- logoutin interface- PermissionManager
 
 - 
remoteLogoutpublic void remoteLogout(java.lang.String sessionId) Description copied from interface:PermissionManagerLogout remotely from JMRI. This is for the web server, WiThrottle server, and other remote connections.- Specified by:
- remoteLogoutin interface- PermissionManager
- Parameters:
- sessionId- the session ID
 
 - 
isLoggedInpublic boolean isLoggedIn() Description copied from interface:PermissionManagerIs an user logged in locally?- Specified by:
- isLoggedInin interface- PermissionManager
- Returns:
- true if any user except guest is logged in, false otherwise.
 
 - 
isRemotelyLoggedInpublic boolean isRemotelyLoggedIn(java.lang.String sessionId) Description copied from interface:PermissionManagerIs an user logged in locally?- Specified by:
- isRemotelyLoggedInin interface- PermissionManager
- Parameters:
- sessionId- the session ID
- Returns:
- true if any user except guest is logged in to this session, false otherwise.
 
 - 
isCurrentUserpublic boolean isCurrentUser(java.lang.String username) Description copied from interface:PermissionManagerIs the user username the current user?- Specified by:
- isCurrentUserin interface- PermissionManager
- Parameters:
- username- the username to check
- Returns:
- true if the current user is username, false otherwise.
 
 - 
isCurrentUserpublic boolean isCurrentUser(User user) Description copied from interface:PermissionManagerIs the user 'user' the current user?- Specified by:
- isCurrentUserin interface- PermissionManager
- Parameters:
- user- the user to check
- Returns:
- true if the current user is 'user', false otherwise.
 
 - 
getCurrentUserNamepublic java.lang.String getCurrentUserName() Description copied from interface:PermissionManagerGet the current username.- Specified by:
- getCurrentUserNamein interface- PermissionManager
- Returns:
- the username of the user that's currently logged in or null if no user is logged in.
 
 - 
isAGuestUserpublic boolean isAGuestUser(java.lang.String username) Description copied from interface:PermissionManagerIs the user 'username' the guest user?- Specified by:
- isAGuestUserin interface- PermissionManager
- Parameters:
- username- the username to check
- Returns:
- true if 'username' is the guest user
 
 - 
isAGuestUserpublic boolean isAGuestUser(User user) Description copied from interface:PermissionManagerIs the user 'user' the guest user?- Specified by:
- isAGuestUserin interface- PermissionManager
- Parameters:
- user- the user to check
- Returns:
- true if 'user' is the guest user
 
 - 
isCurrentUserPermittedToChangePasswordpublic boolean isCurrentUserPermittedToChangePassword() Description copied from interface:PermissionManagerIs the current user allowed to change his password?- Specified by:
- isCurrentUserPermittedToChangePasswordin interface- PermissionManager
- Returns:
- true if a user has logged in and that user is permitted to change his password, false otherwise
 
 - 
addLoginListenerpublic void addLoginListener(PermissionManager.LoginListener listener) Description copied from interface:PermissionManagerAdd a login listener.- Specified by:
- addLoginListenerin interface- PermissionManager
- Parameters:
- listener- the listener
 
 - 
isEnabledpublic boolean isEnabled() Description copied from interface:PermissionManagerIs the permission manager enabled?- Specified by:
- isEnabledin interface- PermissionManager
- Returns:
- true if it's enabled, false otherwise.
 
 - 
setEnabledpublic void setEnabled(boolean enabled) Description copied from interface:PermissionManagerSet if the permission manager should be enabled or not.- Specified by:
- setEnabledin interface- PermissionManager
- Parameters:
- enabled- true if it should be enabled, false otherwise.
 
 - 
isAllowEmptyPasswordspublic boolean isAllowEmptyPasswords() Description copied from interface:PermissionManagerGet if empty passwords is allowed.- Specified by:
- isAllowEmptyPasswordsin interface- PermissionManager
- Returns:
- true if empty passwords is allowed, false otherwise.
 
 - 
setAllowEmptyPasswordspublic void setAllowEmptyPasswords(boolean value) Description copied from interface:PermissionManagerSet if empty passwords should be allowed.- Specified by:
- setAllowEmptyPasswordsin interface- PermissionManager
- Parameters:
- value- true if empty passwords should be allowed, false otherwise.
 
 - 
hasAtLeastPermissionpublic boolean hasAtLeastPermission(Permission permission, PermissionValue minValue) Description copied from interface:PermissionManagerHas the current user permission?- Specified by:
- hasAtLeastPermissionin interface- PermissionManager
- Parameters:
- permission- the permission to check
- minValue- the minimum value
- Returns:
- true if the user has the permission, false otherwise
 
 - 
hasAtLeastRemotePermissionpublic boolean hasAtLeastRemotePermission(java.lang.String sessionId, Permission permission, PermissionValue minValue) Description copied from interface:PermissionManagerHas the current user of this session permission?- Specified by:
- hasAtLeastRemotePermissionin interface- PermissionManager
- Parameters:
- sessionId- the session ID
- permission- the permission to check
- minValue- the minimum value
- Returns:
- true if the user has the permission, false otherwise
 
 - 
ensureAtLeastPermissionpublic boolean ensureAtLeastPermission(Permission permission, PermissionValue minValue) 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 interface- PermissionManager
- Parameters:
- permission- the permission to check
- minValue- the minimum value
- Returns:
- true if the user has the permission, false otherwise
 
 - 
registerOwnerpublic void registerOwner(PermissionOwner owner) Description copied from interface:PermissionManagerRegister a permission owner.- Specified by:
- registerOwnerin interface- PermissionManager
- Parameters:
- owner- the owner
 
 - 
registerPermissionpublic void registerPermission(Permission permission) Description copied from interface:PermissionManagerRegister a permission.- Specified by:
- registerPermissionin interface- PermissionManager
- Parameters:
- permission- the permission
 
 
- 
 
-