Top Description Fields Constructors Methods
org.hsqldb.auth

public Class AuthBeanMultiplexer

extends Object
Class Inheritance
Imports
java.sql.Connection, .ResultSet, .SQLException, .Statement, java.util.ArrayList, .Collections, .HashMap, .List, .Map, org.hsqldb.jdbc.JDBCArrayBasic, org.hsqldb.lib.FrameworkLogger, org.hsqldb.types.Type

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

Field Summary

Modifier and TypeField and Description
private static Map<String, List<AuthFunctionBean>>
private static FrameworkLogger
private static AuthBeanMultiplexer

Constructor Summary

AccessConstructor and Description
private
AuthBeanMultiplexer()

This sole constructor is purposefully private, so users or frameworks that want to work with instances will be forced to use the singleton instead of creating useless extra instance copies.

Method Summary

Modifier and TypeMethod and Description
public static Array

Returns:

Null or java.sql.Array to indicate successful authentication according to the contract for HyperSQL authentication functions.
authenticate
(String
String
database
,
String
String
user
,
String
String
password
)

HyperSQL Java Function Method.

public void
clear()

Clear the set of AuthFunctionBeans

public static AuthBeanMultiplexer
protected static String
public void
setAuthFunctionBean(Connection
Connection
c
,
AuthFunctionBean
AuthFunctionBean
authFunctionBean
)

Exactly the same as setAuthFunctionBeans(String, List) other than taking an open Connection to identify the database.

public void
setAuthFunctionBean(String
String
dbName
,
AuthFunctionBean
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.

public void
setAuthFunctionBeans(Map<String, List<AuthFunctionBean>>
Map
authFunctionBeanMap
)

Primary purpose of this class is to manage this static map.

public void
setAuthFunctionBeans(Connection
An open Connection to the desired database.
c
,
List<AuthFunctionBean>
List
authFunctionBeans
)

Wrapper for setAuthFunctionBeans(String, List<AuthFunctionBean>)

public void
setAuthFunctionBeans(String
String
dbName
,
List<AuthFunctionBean>
List
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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beansback to summary
private static Map<String, List<AuthFunctionBean>> beans
loggerback to summary
private static FrameworkLogger logger
singletonback to summary
private static AuthBeanMultiplexer singleton

Constructor Detail

AuthBeanMultiplexerback to summary
private AuthBeanMultiplexer()

This sole constructor is purposefully private, so users or frameworks that want to work with instances will be forced to use the singleton instead of creating useless extra instance copies.

Method Detail

authenticateback to summary
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

String

user:String

String

password:String

String

Returns:Array

Null or java.sql.Array to indicate successful authentication according to the contract for HyperSQL authentication functions.

Exceptions
Exception:
(non-runtime). A matching AuthFunctionBean threw this Exception.
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).
See Also
HyperSQL User Guide, System Management chapter, Authentication Settings subsection.
clearback to summary
public void clear()

Clear the set of AuthFunctionBeans

getSingletonback to summary
public static AuthBeanMultiplexer getSingleton()
getUniqueNameForback to summary
protected static String getUniqueNameFor(Connection c) throws SQLException
setAuthFunctionBeanback to summary
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

Connection

authFunctionBean:AuthFunctionBean

AuthFunctionBean

Exceptions
SQLException:
if failed to obtain unique name from given Connection.
setAuthFunctionBeanback to summary
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

String

authFunctionBean:AuthFunctionBean

AuthFunctionBean

See Also
setAuthFunctionBeans(String, List)
setAuthFunctionBeansback to summary
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<String, List<AuthFunctionBean>>

Map

setAuthFunctionBeansback to summary
public void setAuthFunctionBeans(Connection c, List<AuthFunctionBean> authFunctionBeans) throws SQLException

Wrapper for setAuthFunctionBeans(String, List<AuthFunctionBean>)

Parameters
c:Connection

An open Connection to the desired database.

authFunctionBeans:List<AuthFunctionBean>

List

Exceptions
SQLException:
if failed to obtain unique name from given Connection.
setAuthFunctionBeansback to summary
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

String

authFunctionBeans:List<AuthFunctionBean>

List

See Also
setAuthFunctionBeans(Map), setAuthFunctionBean(String, AuthFunctionBean)