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.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Path
protected boolean
protected boolean
protected List
<PropertyUserStore.UserListener> protected PathWatcher
private static final Logger
-
Constructor Summary
Constructors -
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()
private Path
extractPackedFile
(JarFileResource configResource) Get the config (as a string)Get the ConfigPath
reference.boolean
Is hot reload enabled on this user storeprotected void
private void
notifyRemove
(String username) Notifies the registered listeners that a user has been removed.private void
notifyUpdate
(String username, Credential credential, String[] roleArray) Notifies the registered listeners of potential updates to a uservoid
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
(File configFile) Deprecated.void
setConfigPath
(String configFile) Deprecated.void
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, getIdentityService, getKnownUserIdentities, getUserIdentity, removeUser
Methods inherited from class org.eclipse.jetty.util.component.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
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
-
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
Deprecated.Set the Config Path from aFile
reference- Parameters:
configFile
- the config file
-
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
- Overrides:
toString
in 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:
doStart
in classAbstractLifeCycle
- Throws:
Exception
-
onPathWatchEvent
- Specified by:
onPathWatchEvent
in interfacePathWatcher.Listener
-
doStop
- Overrides:
doStop
in 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
-