Class PropertyUserStore
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.security.UserStore
org.eclipse.jetty.security.PropertyUserStore
- All Implemented Interfaces:
EventListener, LifeCycle, PathWatcher.Listener
This class monitors a property file of the format mentioned below and notifies registered listeners of the changes to the the given file.
username: password [,rolename ...]
Passwords may be clear text, obfuscated or checksummed.
The class Password should be used
to generate obfuscated passwords or password checksums.
If DIGEST Authentication is used, the password must be in a recoverable format, either plain text or obfuscated.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListenerNested classes/interfaces inherited from interface LifeCycle
LifeCycle.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Pathprotected booleanprotected booleanprotected List<PropertyUserStore.UserListener> protected PathWatcherprivate static final Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoStart()Depending on the value of the refresh interval, this method will either start up a scanner thread that will monitor the properties file for changes after it has initially loaded it.protected voiddoStop()private PathextractPackedFile(JarFileResource configResource) Get the config (as a string)Get the ConfigPathreference.booleanIs hot reload enabled on this user storeprotected voidprivate voidnotifyRemove(String username) Notifies the registered listeners that a user has been removed.private voidnotifyUpdate(String username, Credential credential, String[] roleArray) Notifies the registered listeners of potential updates to a uservoidvoidRegisters a listener to be notified of the contents of the property filevoidSet the Config Path from a String reference to a filevoidsetConfigFile(File configFile) Set the Config Path from aFilereferencevoidsetConfigPath(File configFile) Deprecated.voidsetConfigPath(String configFile) Deprecated.voidsetConfigPath(Path configPath) Set the Config PathvoidsetHotReload(boolean enable) Enable Hot Reload of the Property FiletoString()Methods inherited from class UserStore
addUser, getIdentityService, getKnownUserIdentities, getUserIdentity, removeUserMethods inherited from class AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
-
Field Details
-
LOG
-
_configPath
-
_pathWatcher
-
_hotReload
protected boolean _hotReload -
_firstLoad
protected boolean _firstLoad -
_listeners
-
-
Constructor Details
-
PropertyUserStore
public PropertyUserStore()
-
-
Method Details
-
getConfig
-
setConfig
Set the Config Path from a String reference to a file- Parameters:
config- the config file
-
getConfigPath
-
setConfigPath
Deprecated.Set the Config Path from a String reference to a file- Parameters:
configFile- the config file can a be a file path or a reference to a file within a jar filejar:file:
-
extractPackedFile
- Throws:
IOException
-
setConfigPath
-
setConfigFile
-
setConfigPath
Set the Config Path- Parameters:
configPath- the config path
-
getConfigResource
- Returns:
- the resource associated with the configured properties file, creating it if necessary
-
isHotReload
public boolean isHotReload()Is hot reload enabled on this user store- Returns:
- true if hot reload was enabled before startup
-
setHotReload
public void setHotReload(boolean enable) Enable Hot Reload of the Property File- Parameters:
enable- true to enable, false to disable
-
toString
- Overrides:
toStringin classAbstractLifeCycle
-
loadUsers
- Throws:
IOException
-
doStart
Depending on the value of the refresh interval, this method will either start up a scanner thread that will monitor the properties file for changes after it has initially loaded it. Otherwise the users will be loaded and there will be no active monitoring thread so changes will not be detected.- Overrides:
doStartin classAbstractLifeCycle- Throws:
Exception
-
onPathWatchEvent
- Specified by:
onPathWatchEventin interfacePathWatcher.Listener
-
doStop
- Overrides:
doStopin classAbstractLifeCycle- Throws:
Exception
-
notifyUpdate
Notifies the registered listeners of potential updates to a user- Parameters:
username- the user that was updatedcredential- the updated credentialsroleArray- the updated roles
-
notifyRemove
Notifies the registered listeners that a user has been removed.- Parameters:
username- the user that was removed
-
registerUserListener
Registers a listener to be notified of the contents of the property file- Parameters:
listener- the user listener
-