|
CXI
|
This class implements an interface to a cluster of Utimaco's Hardware Security Modules "CryptoServer". More...
Classes | |
| enum | DeviceState |
| Device states as reported by CryptoServerCluster.EventHandler.stateChanged. More... | |
| class | Error |
| Defines an additional error code/mask that causes the cluster to switch to another device instead of returning to the caller. More... | |
| interface | EventHandler |
| The EventHandler interface provides callback functions, which are called if the state of the current CryptoServer within a cluster changes or an error occurs. More... | |
Public Member Functions | |
Constructors | |
| CryptoServerCluster (String[] devices, int timeout) throws IOException, CryptoServerException | |
| Creates a new connection to a CryptoServer cluster. More... | |
| CryptoServerCluster (CryptoServerConfig config) throws IOException, CryptoServerException | |
| Creates a new connection to a CryptoServer or CryptoServer cluster. More... | |
| CryptoServerCluster (String device, int timeout) throws IOException, CryptoServerException | |
| Creates a new connection to a CryptoServer (a cluster of one only one CryptoServer). More... | |
| CryptoServerCluster (String device) throws IOException, CryptoServerException | |
| Creates a new connection to a CryptoServer (a cluster of one only one CryptoServer). More... | |
| synchronized void | open (String[] devices, int connTimeout) throws CryptoServerException |
Basic Functions | |
| synchronized void | close () |
| Closes the connection to the CryptoServer cluster. More... | |
| byte[] | exec (int fc, int sfc, byte[] cmd, CryptoServerAPI.CryptoServerCluster.Error[] errList) throws IOException, CryptoServerException |
| Executes a command on the current CryptoServer. More... | |
| byte[] | exec (int fc, int sfc, byte[] cmd) throws IOException, CryptoServerException |
| Executes a command on the current CryptoServer. More... | |
| String | getDevice () |
| Returns the device specifier of the current CryptoServer. | |
| int | getTimeout () |
| Returns the current read timeout for all communication with the current CryptoServer. More... | |
| synchronized void | setTimeout (int timeout) throws IOException, CryptoServerException |
| Sets the read timeout. More... | |
| synchronized void | setFallbackInterval (int seconds) throws CryptoServerException |
| Sets the fallback interval time. More... | |
| synchronized void | setKeepSessionAlive (boolean flag) throws CryptoServerException |
| Starts an additional thread that keeps the current session alive and prevents it from expiring after 15 minutes of idle time. More... | |
| synchronized void | setEventHandler (EventHandler eventHandler) throws CryptoServerException |
| Registers an event (callback) handler, that receives notification messages if the state of a CryptoServer changes or an error occurs. More... | |
Authentication & Secure Messaging | |
| synchronized void | logon (String user, String keyFile, byte[] password) throws IOException, CryptoServerException |
| Authenticates a user and establishes a secure messaging session with the current CryptoServer. More... | |
| synchronized void | logoff () throws IOException, CryptoServerException |
| Terminates a secure messaging session and invalidates authentication. More... | |
| int | getAuthState () throws IOException, CryptoServerException |
| Returns resulting authentication state. More... | |
Deprecated | |
| void | setFallbackInterval (long seconds) throws CryptoServerException |
| void | logonPassword (String user, byte[] password) throws IOException, CryptoServerException |
| void | logonPassword (String user, String password) throws IOException, CryptoServerException |
| void | logonSign (String user, String keyFile, String password) throws IOException, CryptoServerException |
| void | keepSessionAlive () throws CryptoServerException |
| void | logonSC (String user, String pin) throws IOException, CryptoServerException |
Public Member Functions inherited from CryptoServer | |
| CryptoServer (String device, int timeout) throws IOException, NumberFormatException, CryptoServerException | |
| Creates a new connection to a CryptoServer. More... | |
| CryptoServer (String device) throws IOException, NumberFormatException, CryptoServerException | |
| Creates a new connection to a CryptoServer. More... | |
| CryptoServer (CryptoServerConfig config) throws IOException, NumberFormatException, CryptoServerException | |
| Creates a new connection to a CryptoServer. More... | |
| synchronized void | open (String device, int connTimeout) throws CryptoServerException |
| void | open (String device) throws CryptoServerException |
| void | prepareAuthenticationHMAC (String user, byte[] password) throws CryptoServerException |
| Prepares to authenticate the subsequent commands with "HMAC Password" mechanism. More... | |
| void | prepareAuthenticationHMAC (String user, String password) throws CryptoServerException, UnsupportedEncodingException |
| Prepares to authenticate the subsequent commands with "HMAC Password" mechanism. More... | |
| void | prepareAuthenticationRSASign (String user, String keySpec, String pin) throws IOException, CryptoServerException |
| Prepares to authenticate the subsequent commands with "RSA Signature" mechanism. More... | |
| void | prepareAuthenticationRSASC (String user, String pin) throws IOException, CryptoServerException |
| Prepares to authenticate the subsequent commands with "RSA Smartcard" mechanism. More... | |
| synchronized void | endAuthentication () |
| Stops authentication. More... | |
| void | getSessionKeyDH () throws IOException, CryptoServerException |
| Establishes a secure messaging session with the CryptoServer using 2048 bit Diffie-Hellman key agreement. More... | |
| void | setEndSessionOnShutdown (boolean flag) |
| Enables or disables a ShutdownHook for terminating active sessions. More... | |
| synchronized void | endSession () |
| Terminates a secure messaging session. More... | |
| void | getSessionKeyDH (int size) throws IOException, CryptoServerException |
| void | setTrace (PrintStream out) |
| void | setTrace (boolean flag) |
| void | setTrace (PrintStream out, boolean flag) |
| Enables or disables the trace function. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from CryptoServer | |
| static String | getName () |
| Returns the name of the CryptoServerAPI. More... | |
| static double | getVersion () |
| Returns the version of the CryptoServerAPI (x.xx) More... | |
This class implements an interface to a cluster of Utimaco's Hardware Security Modules "CryptoServer".
Only one CryptoServer is connected at a time but in case of a communication error the API automatically switches to another device and tries to execute the command on that device (failover).
The API tries to execute the command on every device and returns to the caller if the command could either be executed successfully or if it wasn't able to execute the command on any device.
The API begins with the first (primary) device in the given device list and switches to other devices in the given order. Once switched to another device the API basically stays at this device. Optionally a fallback interval can be given that causes the API to try to reconnect to the primary device after the interval time has expired (see setFallbackInterval).
In case of communication errors the API silently switches to another device and does not report the error to the calling application. If the calling application wants to get noticed about errors or state changes it can implement an event handler interface, see CryptoServerCluster.EventHandler
The following code illustrates the usage of the class CryptoServerCluster:
A sample configuration file looks as follows:
| CryptoServerCluster | ( | String[] | devices, |
| int | timeout | ||
| ) | throws IOException, CryptoServerException |
Creates a new connection to a CryptoServer cluster.
Internally only one CryptoServer is connected at a time. The API provides a failover mechanism that switches to another device in case of connection failures and returns as soon as a device has been successfully connected. If none of the devices in the cluster can be connected an exception will be thrown.
| devices | Array of CryptoServer device addresses. Each address may contain the prefix "TCP:" followed by the IP address or port number and IP address (seperated by a '@'), or the prefix "PCI:" followed by the device name of a PCI device. Examples: "TCP:192.168.4.99", "TCP:288@192.168.4.201", "PCI:0", "PCI:/dev/cs2.0". The array may contain one or more devices. |
| timeout | Timeout in milliseconds to establish the connection to a CryptoServer. |
| CryptoServerCluster | ( | CryptoServerConfig | config | ) | throws IOException, CryptoServerException |
Creates a new connection to a CryptoServer or CryptoServer cluster.
| config | Configuration object. The following key names will be recognized:
|
| CryptoServerCluster | ( | String | device, |
| int | timeout | ||
| ) | throws IOException, CryptoServerException |
Creates a new connection to a CryptoServer (a cluster of one only one CryptoServer).
| device | Address of the CryptoServer. May contain the prefix "TCP:" followed by the IP address or port number and IP address (seperated by a '@'), or the prefix "PCI:" followed by the device name of a PCI device. Examples: "TCP:192.168.4.99", "TCP:288@192.168.4.201", "PCI:0", "PCI:/dev/cs2.0". |
| timeout | Timeout in milliseconds to establish the connection. |
| CryptoServerCluster | ( | String | device | ) | throws IOException, CryptoServerException |
Creates a new connection to a CryptoServer (a cluster of one only one CryptoServer).
| device | Address of the CryptoServer. May contain the prefix "TCP:" followed by the IP address or port number and IP address (seperated by a '@'), or the prefix "PCI:" followed by the device name of a PCI device. Examples: "TCP:192.168.4.99", "TCP:288@192.168.4.201", "PCI:0", "PCI:/dev/cs2.0". |
| synchronized void close | ( | ) |
Closes the connection to the CryptoServer cluster.
Reimplemented from CryptoServer.
| byte[] exec | ( | int | fc, |
| int | sfc, | ||
| byte[] | cmd, | ||
| CryptoServerAPI.CryptoServerCluster.Error[] | errList | ||
| ) | throws IOException, CryptoServerException |
Executes a command on the current CryptoServer.
In case of failure the method automatically switches to the next device and tries to execute the command on that device. If the command could not be executed on any device an exception will be thrown.
| fc | Function code of the function called. |
| sfc | Sub-Function code of the function called. |
| cmd | Command data sent to the CryptoServer. |
| errList | Optional list of additional error codes the cluster should not report to the caller but switch to another device. Set to 'null' if only communication errors should cause the API to switch to another device. |
| byte[] exec | ( | int | fc, |
| int | sfc, | ||
| byte[] | cmd | ||
| ) | throws IOException, CryptoServerException |
Executes a command on the current CryptoServer.
In case of failure the method automatically switches to the next device and tries to execute the command on that device. If the command could not be executed on any device an exception will be thrown.
| fc | Function code of the function called. |
| sfc | Sub-Function code of the function called. |
| cmd | Command data sent to the CryptoServer. |
Reimplemented from CryptoServer.
| int getTimeout | ( | ) |
Returns the current read timeout for all communication with the current CryptoServer.
Reimplemented from CryptoServer.
| synchronized void setTimeout | ( | int | timeout | ) | throws IOException, CryptoServerException |
Sets the read timeout.
| timeout | Timeout in milliseconds to receive the answer from a CryptoServer. |
Reimplemented from CryptoServer.
| synchronized void setFallbackInterval | ( | int | seconds | ) | throws CryptoServerException |
Sets the fallback interval time.
If the API has switched to another device due to a communication error, this value specifies the time the API waits before it tries to reconnect to the primary device (first device in the list).
| seconds | interval time in seconds. A value of 0 (default) specifies that the API should never fall back. |
| synchronized void setKeepSessionAlive | ( | boolean | flag | ) | throws CryptoServerException |
Starts an additional thread that keeps the current session alive and prevents it from expiring after 15 minutes of idle time.
Reimplemented from CryptoServer.
| synchronized void setEventHandler | ( | EventHandler | eventHandler | ) | throws CryptoServerException |
Registers an event (callback) handler, that receives notification messages if the state of a CryptoServer changes or an error occurs.
| eventHandler | EventHandler class |
| synchronized void logon | ( | String | user, |
| String | keyFile, | ||
| byte[] | password | ||
| ) | throws IOException, CryptoServerException |
Authenticates a user and establishes a secure messaging session with the current CryptoServer.
The API provides a failover mechanism that switches to another device in case of failure and returns as soon as a secure messaging session to a device could be established. Therefore user credentials will be stored internally in order to reestablish a session in case of a failure. If logon fails on all devices an exception will be thrown.
| user | Name of the user who wants to autenticate to the CryptoServer. |
| keyFile | Key file user: Path to key file containing user's private key. Password user: null. |
| password | Key file user: Password of the key file if using an encrypted file, null otherwise. Password user: Password of the user. |
| synchronized void logoff | ( | ) | throws IOException, CryptoServerException |
Terminates a secure messaging session and invalidates authentication.
Reimplemented from CryptoServer.
| int getAuthState | ( | ) | throws IOException, CryptoServerException |
Returns resulting authentication state.
Reimplemented from CryptoServer.
| void setFallbackInterval | ( | long | seconds | ) | throws CryptoServerException |
| void logonPassword | ( | String | user, |
| byte[] | password | ||
| ) | throws IOException, CryptoServerException |
Reimplemented from CryptoServer.
| void logonPassword | ( | String | user, |
| String | password | ||
| ) | throws IOException, CryptoServerException |
Reimplemented from CryptoServer.
| void logonSign | ( | String | user, |
| String | keyFile, | ||
| String | password | ||
| ) | throws IOException, CryptoServerException |
Reimplemented from CryptoServer.
| void keepSessionAlive | ( | ) | throws CryptoServerException |
Reimplemented from CryptoServer.