Class SBLStore

java.lang.Object
org.bzdev.ejws.SBLStore
All Implemented Interfaces:
AutoCloseable

public class SBLStore extends Object implements AutoCloseable
Persistent storage for SBL data and passwords. The constructor will be given a file. For a file fname in some directory, files names #fname and fname~ may also be created and are used to recover if the system goes down unexpectedly.
  • Constructor Details

    • SBLStore

      public SBLStore(File file) throws IOException
      Constructor. for a file named "store", files name "#store" and "store~" may be created temporarily.
      Parameters:
      file - the file used for persistent storage
      Throws:
      IOException
  • Method Details

    • mapStream

      public Stream<Map.Entry<String,SBLStore.Entry>> mapStream()
      Get a stream of entry-set elements whose keys are user names and whose values are the corresponding instance of SBLStore.Entry.
      Returns:
      the stream
    • getUsers

      public Set<String> getUsers(Map<String,? extends EjwsAuthenticator.Entry> emap, boolean active)
      Get users.
      Parameters:
      active - true if only active users should be included; false if only non-active users should be included
      Returns:
      a set of users
    • containsUser

      public boolean containsUser(String name)
      Determine if this SBLStore contains a user.
      Parameters:
      name - the name of the user
      Returns:
      true if the user is contained by this store; false otherwise
    • isActive

      public boolean isActive(String name)
      Determine if a user is in the active state.
      Parameters:
      name - the name of the user
      Returns:
      true if the user is active; false otherwise
    • isPending

      public boolean isPending(String name)
      Determine if a user is in the pending state.
      Parameters:
      name - the name of the user
      Returns:
      true if the user is pending; false otherwise
    • isGPGEntry

      public boolean isGPGEntry(String name)
      Determine if a user is represented by a GPG entry that indicates if the user is active or pending.
      Returns:
      true if the user's entry indicates if the user is active or passive, but does not contain password or SBL data
    • append

      public void append(String name, boolean pwmode, String data, boolean isActive) throws IOException
      Set all fields for a user.
      Parameters:
      name - the user name
      pwmode - the password mode (true if the data parameter is an basic-authentication password; false if it is SBL data encoded as a string
      data - the data
      isActive - true the user is active; false otherwise
      Throws:
      IOException
    • append

      public void append(String name, boolean pwmode, String data) throws IOException
      Set the data field for a user.
      Parameters:
      name - the user name
      pwmode - the password mode (true if the data parameter is an basic-authentication password; false if it is SBL data encoded as a string
      data - the data
      Throws:
      IOException
    • makeActive

      public void makeActive(String name) throws IOException
      Make a user active.
      Parameters:
      name - the user name
      Throws:
      IOException
    • makePending

      public void makePending(String name) throws IOException
      Make a user pending (that is, not active).
      Parameters:
      name - the user name
      Throws:
      IOException
    • removeUser

      public void removeUser(String name) throws IOException
      Remove a user.
      Parameters:
      name - the user name
      Throws:
      IOException - if an IO error occurs or if there is no entry for the given user name
    • getSBLData

      public String getSBLData(String name)
      Get SBL data.
      Parameters:
      name - the name of a user
      Returns:
      the String representation of SBL data; null if there is no SBL data
    • getPWData

      public String getPWData(String name)
      Get the password for a user.
      Parameters:
      name - the name of a user
      Returns:
      the password; null if a password was not strored
    • close

      public void close() throws IOException
      Close all output streams and terminate subprocesses.
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException