Package org.eclipse.jetty.security
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 org.eclipse.jetty.security.UserStore
UserStore.UserNested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Pathprotected booleanprotected booleanprotected List<PropertyUserStore.UserListener>protected PathWatcher -
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()Method to override to stop the lifecycleGet the config (as a string)Get the ConfigPathreference.booleanIs hot reload enabled on this user storeprotected voidvoidvoidRegisters 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(Path configPath) Set the Config PathvoidsetHotReload(boolean enable) Enable Hot Reload of the Property FiletoString()Methods inherited from class org.eclipse.jetty.security.UserStore
addUser, getRolePrincipals, getUserPrincipal, removeUserMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addEventListener, getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, setEventListeners, start, stop
-
Field Details
-
_configPath
-
_pathWatcher
-
_hotReload
protected boolean _hotReload -
_firstLoad
protected boolean _firstLoad -
_listeners
-
-
Constructor Details
-
PropertyUserStore
public PropertyUserStore()
-
-
Method Details
-
getConfig
Get the config (as a string)- Returns:
- the config path as a string
-
setConfig
Set the Config Path from a String reference to a file- Parameters:
config- the config file
-
getConfigPath
Get the ConfigPathreference.- Returns:
- the config path
-
setConfigFile
Set the Config Path from aFilereference- Parameters:
configFile- the config file
-
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
-
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:
AbstractLifeCycle.StopException- If thrown, the lifecycle will immediately be stopped.Exception- If there was a problem starting. Will cause a transition to FAILED state
-
onPathWatchEvent
- Specified by:
onPathWatchEventin interfacePathWatcher.Listener
-
doStop
Description copied from class:AbstractLifeCycleMethod to override to stop the lifecycle- Overrides:
doStopin classAbstractLifeCycle- Throws:
Exception- If there was a problem stopping. Will cause a transition to FAILED state
-
registerUserListener
Registers a listener to be notified of the contents of the property file- Parameters:
listener- the user listener
-