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 classes/interfaces inherited from class org.eclipse.jetty.security.UserStore
UserStore.User
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Field Summary
Modifier and TypeFieldDescriptionprotected Path
protected boolean
protected boolean
protected List<PropertyUserStore.UserListener>
protected PathWatcher
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
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.protected void
doStop()
Method to override to stop the lifecycleGet the config (as a string)Get the ConfigPath
reference.boolean
Is hot reload enabled on this user storeprotected void
void
void
Registers a listener to be notified of the contents of the property filevoid
Set the Config Path from a String reference to a filevoid
setConfigFile
(File configFile) Set the Config Path from aFile
referencevoid
setConfigPath
(Path configPath) Set the Config Pathvoid
setHotReload
(boolean enable) Enable Hot Reload of the Property FiletoString()
Methods inherited from class org.eclipse.jetty.security.UserStore
addUser, getRolePrincipals, getUserPrincipal, removeUser
Methods 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 ConfigPath
reference.- Returns:
- the config path
-
setConfigFile
Set the Config Path from aFile
reference- 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:
doStart
in 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:
onPathWatchEvent
in interfacePathWatcher.Listener
-
doStop
Description copied from class:AbstractLifeCycle
Method to override to stop the lifecycle- Overrides:
doStop
in 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
-