Module org.hsqldb

Class AuthBeanMultiplexer

java.lang.Object
org.hsqldb.auth.AuthBeanMultiplexer

public class AuthBeanMultiplexer extends Object
This class provides a method which can be used directly as a HyperSQL static Java function method. Manages a set of AuthFunctionBean implementations
Since:
2.0.1
Author:
Blaine Simpson (blaine dot simpson at admc dot com)
  • Method Details

    • getSingleton

      public static AuthBeanMultiplexer getSingleton()
    • clear

      public void clear()
      Clear the set of AuthFunctionBeans
    • setAuthFunctionBeans

      public void setAuthFunctionBeans(Map<String,List<AuthFunctionBean>> authFunctionBeanMap)
      Primary purpose of this class is to manage this static map. From dbNames to ordered-lists-of-AuthFunctionBeans. This is not an "adder" function, but a "setter" function, so do not use this to add to a partial set, but to assign the entire set.

      The given entries are copied, to limit side-effects and concurrency issues.

      Parameters:
      authFunctionBeanMap - Map
    • setAuthFunctionBeans

      public void setAuthFunctionBeans(Connection c, List<AuthFunctionBean> authFunctionBeans) throws SQLException
      Wrapper for setAuthFunctionBeans(String, List<AuthFunctionBean>)
      Parameters:
      c - An open Connection to the desired database.
      authFunctionBeans - List
      Throws:
      SQLException - if failed to obtain unique name from given Connection.
    • setAuthFunctionBeans

      public void setAuthFunctionBeans(String dbName, List<AuthFunctionBean> authFunctionBeans)
      This is not an "adder" function, but a "setter" function for the specified dbName , so do not use this to add to a database's FunctionBeans, but to assign the entire list for that database.

      The given entries are copied, to limit side-effects and concurrency issues.

      Use this method instead of setAuthFunctionBean(String, AuthFunctionBean) in order to set up multiple authenticators for a single database for redundancy purposes.

      Parameters:
      dbName - String
      authFunctionBeans - List
      See Also:
    • setAuthFunctionBean

      public void setAuthFunctionBean(Connection c, AuthFunctionBean authFunctionBean) throws SQLException
      Exactly the same as setAuthFunctionBeans(String, List) other than taking an open Connection to identify the database.
      Parameters:
      c - Connection
      authFunctionBean - AuthFunctionBean
      Throws:
      SQLException - if failed to obtain unique name from given Connection.
    • setAuthFunctionBean

      public void setAuthFunctionBean(String dbName, AuthFunctionBean authFunctionBean)
      This is not an "adder" function, but a "setter" function for the specified dbName , so do not use this to add to a database's FunctionBeans, but to assign ths single given AuthFunctionBean as the specified database's authenticator.

      To set up multiple authenticators for a single database for redundancy purposes, use the method setAuthFunctionBeans(String, List) instead.

      Parameters:
      dbName - String
      authFunctionBean - AuthFunctionBean
      See Also:
    • authenticate

      public static Array authenticate(String database, String user, String password) throws Exception
      HyperSQL Java Function Method.

      Registered AuthFunctionBeans matching the specified database and password will be tried in order.

      1. If the AuthFunctionBean being tried throws a non-runtime Exception, then that RuntimeException is passed through (re-thrown), resulting in a SQLException for the authenticating application.
      2. If the AuthFunctionBean being tried doesn't throw anything, then the return value is passed through (returned) and HyperSQL will allow access and set roles according to HyperSQL's authentication function contract.
      3. If the AuthFunctionBean being tried throws a RuntimeException, then the next AuthFunctionBean in turn will be tried. If all matching AuthFunctionBeans throw RuntimeExceptions, then the first RuntimeException that was thrown will be passed through (re-thrown), resulting in a SQLException for the authenticating application.
      4. If there are no AuthFunctionBeans registered for the specified dbName, then this method will throw an IllegalArgumentException, resulting in a SQLException for the authenticating application.
      Parameters:
      database - String
      user - String
      password - String
      Returns:
      Null or java.sql.Array to indicate successful authentication according to the contract for HyperSQL authentication functions.
      Throws:
      IllegalArgumentException - if no AuthFunctionBean has been set for specified dbName.
      RuntimeException - if all matching AuthFunctionBeans threw RuntimeExceptions. (This indicates that no matching AuthFunctionBean functioned properly, not that authentication was purposefully denied by any AuthFunctionBean).
      Exception - (non-runtime). A matching AuthFunctionBean threw this Exception.
      See Also:
      • "HyperSQL User Guide, System Management chapter, Authentication Settings subsection."