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, org.eclipse.jetty.util.component.LifeCycle, org.eclipse.jetty.util.PathWatcher.Listener

public class PropertyUserStore extends UserStore implements org.eclipse.jetty.util.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
    Modifier and Type
    Class
    Description
    static interface 
     

    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

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Path
     
    protected boolean
     
    protected boolean
     
     
    protected org.eclipse.jetty.util.PathWatcher
     

    Fields inherited from class org.eclipse.jetty.security.UserStore

    _users

    Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    FAILED, STARTED, STARTING, STOPPED, STOPPING
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    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
     
    Get the config (as a string)
    Get the Config Path reference.
    org.eclipse.jetty.util.resource.Resource
     
    boolean
    Is hot reload enabled on this user store
    protected void
     
    void
    onPathWatchEvent(org.eclipse.jetty.util.PathWatcher.PathWatchEvent event)
     
    void
    Registers a listener to be notified of the contents of the property file
    void
    setConfig(String config)
    Set the Config Path from a String reference to a file
    void
    setConfigFile(File configFile)
    Set the Config Path from a File reference
    void
    setConfigPath(Path configPath)
    Set the Config Path
    void
    setHotReload(boolean enable)
    Enable Hot Reload of the Property File
     

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • _configPath

      protected Path _configPath
    • _pathWatcher

      protected org.eclipse.jetty.util.PathWatcher _pathWatcher
    • _hotReload

      protected boolean _hotReload
    • _firstLoad

      protected boolean _firstLoad
    • _listeners

      protected List<PropertyUserStore.UserListener> _listeners
  • Constructor Details

    • PropertyUserStore

      public PropertyUserStore()
  • Method Details

    • getConfig

      public String getConfig()
      Get the config (as a string)
      Returns:
      the config path as a string
    • setConfig

      public void setConfig(String config)
      Set the Config Path from a String reference to a file
      Parameters:
      config - the config file
    • getConfigPath

      public Path getConfigPath()
      Get the Config Path reference.
      Returns:
      the config path
    • setConfigFile

      public void setConfigFile(File configFile)
      Set the Config Path from a File reference
      Parameters:
      configFile - the config file
    • setConfigPath

      public void setConfigPath(Path configPath)
      Set the Config Path
      Parameters:
      configPath - the config path
    • getConfigResource

      public org.eclipse.jetty.util.resource.Resource 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

      public String toString()
      Overrides:
      toString in class UserStore
    • loadUsers

      protected void loadUsers() throws IOException
      Throws:
      IOException
    • doStart

      protected void doStart() throws Exception
      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 class org.eclipse.jetty.util.component.AbstractLifeCycle
      Throws:
      Exception
    • onPathWatchEvent

      public void onPathWatchEvent(org.eclipse.jetty.util.PathWatcher.PathWatchEvent event)
      Specified by:
      onPathWatchEvent in interface org.eclipse.jetty.util.PathWatcher.Listener
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.eclipse.jetty.util.component.AbstractLifeCycle
      Throws:
      Exception
    • registerUserListener

      public void registerUserListener(PropertyUserStore.UserListener listener)
      Registers a listener to be notified of the contents of the property file
      Parameters:
      listener - the user listener