|
CXI
|
This class implements an interface to Utimaco's Hardware Security Module "CryptoServer". More...
Public Member Functions | |
Constructors | |
| 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 |
Authentication & Secure Messaging | |
| void | logonPassword (String user, byte[] password) throws IOException, CryptoServerException |
| Authenticates a user and establishs a secure messaging session with the CryptoServer. More... | |
| void | logonPassword (String user, String password) throws IOException, CryptoServerException |
| Authenticates a user and establishs a secure messaging session with the CryptoServer. More... | |
| void | logonSign (String user, String keySpec, String pin) throws IOException, CryptoServerException |
| Authenticates a user and establishes a secure messaging session with the CryptoServer. More... | |
| void | logoff () throws IOException, CryptoServerException |
| Terminates a secure messaging session and invalidates authentication. More... | |
| int | getAuthState () throws IOException, CryptoServerException |
| Returns resulting authentication state. More... | |
| 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... | |
| synchronized void | setKeepSessionAlive (boolean flag) throws CryptoServerException |
| Starts or stops an additional thread that keeps the current session alive and prevents it from expiring after 15 minutes idle time. 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 | logonSC (String user, String pin) throws IOException, CryptoServerException |
Deprecated | |
| void | getSessionKeyDH (int size) throws IOException, CryptoServerException |
| void | keepSessionAlive () throws CryptoServerException |
| void | setTrace (PrintStream out) |
| void | setTrace (boolean flag) |
Static Public Member Functions | |
| static String | getName () |
| Returns the name of the CryptoServerAPI. More... | |
| static double | getVersion () |
| Returns the version of the CryptoServerAPI (x.xx) More... | |
Basic Functions | |
| synchronized void | close () |
| Terminates the current session, invalidates authentication and closes the connection to the CryptoServer. More... | |
| String | getDevice () |
| Returns the device specifier of the connected CryptoServer. | |
| synchronized void | setTimeout (int readTimeout) throws IOException, CryptoServerException |
| Set the (read) timeout for all communication with the CryptoServer. More... | |
| int | getTimeout () |
| Returns the current (read) timeout for all communication with the CryptoServer. More... | |
| void | setTrace (PrintStream out, boolean flag) |
| Enables or disables the trace function. More... | |
| byte[] | exec (int fc, int sfc, byte[] cmd) throws IOException, CryptoServerException |
| Executes a command of the CryptoServer. More... | |
This class implements an interface to Utimaco's Hardware Security Module "CryptoServer".
Each instance of this class handles a connection to one dedicated CryptoServer.
The following code illustrates the usage of the class CryptoServer:
| CryptoServer | ( | String | device, |
| int | timeout | ||
| ) | throws IOException, NumberFormatException, CryptoServerException |
Creates a new connection to a 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:
|
| timeout | Timeout in milliseconds to establish the connection. |
| CryptoServer | ( | String | device | ) | throws IOException, NumberFormatException, CryptoServerException |
Creates a new connection to a 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:
|
| CryptoServer | ( | CryptoServerConfig | config | ) | throws IOException, NumberFormatException, CryptoServerException |
Creates a new connection to a CryptoServer.
| config | Configuration object. The following key names will be recognized:
|
|
static |
Returns the name of the CryptoServerAPI.
|
static |
Returns the version of the CryptoServerAPI (x.xx)
Reimplemented in CryptoServerCXI.
| synchronized void close | ( | ) |
Terminates the current session, invalidates authentication and closes the connection to the CryptoServer.
Reimplemented in CryptoServerCluster.
| synchronized void setTimeout | ( | int | readTimeout | ) | throws IOException, CryptoServerException |
Set the (read) timeout for all communication with the CryptoServer.
| readTimeout | Timeout in milliseconds. |
Reimplemented in CryptoServerCluster.
| int getTimeout | ( | ) |
Returns the current (read) timeout for all communication with the CryptoServer.
Reimplemented in CryptoServerCluster.
| void setTrace | ( | PrintStream | out, |
| boolean | flag | ||
| ) |
Enables or disables the trace function.
If enabled all data sent to and received from the CryptoServer is printed to the output stream. This is for debugging purpose only. Don't use the trace function in a real life application to avoid disclosure of secret information.
| flag | trace function switched on if true, switched off if false. |
| out | OutputStream to which the trace output is sent (e.g. System.out). |
| byte[] exec | ( | int | fc, |
| int | sfc, | ||
| byte[] | cmd | ||
| ) | throws IOException, CryptoServerException |
Executes a command of the CryptoServer.
First the command data is sent to the CryptoServer. Then the answer from the CryptoServer is received and returned. This method blocks until an answer was received from the CryptoSever or an error occurs. If authentication was requested by calling one of the prepareAuthentication...() methods, the command data sent to the CryptoServer is authenticated. If secure messaging is established for this connection, then the data sent to and received from the CryptoServer is encrypted.
| fc | Function code of the function called. |
| sfc | Sub-Function code of the function called. |
| cmd | Command data sent to the CryptoServer. |
Reimplemented in CryptoServerCluster.
| void logonPassword | ( | String | user, |
| byte[] | password | ||
| ) | throws IOException, CryptoServerException |
Authenticates a user and establishs a secure messaging session with the CryptoServer.
| user | Name of the user who wants to autenticate to the CryptoServer. |
| password | Password of the user. May contain binary data. |
Reimplemented in CryptoServerCluster.
| void logonPassword | ( | String | user, |
| String | password | ||
| ) | throws IOException, CryptoServerException |
Authenticates a user and establishs a secure messaging session with the CryptoServer.
| user | Name of the user who wants to autenticate to the CryptoServer. |
| password | Password of the user. Should contain ISO8859-15 characters only.. |
Reimplemented in CryptoServerCluster.
| void logonSign | ( | String | user, |
| String | keySpec, | ||
| String | pin | ||
| ) | throws IOException, CryptoServerException |
Authenticates a user and establishes a secure messaging session with the CryptoServer.
| user | Name of the user who wants to autenticate to the CryptoServer. |
| keySpec | Specifies either the name of a - optionally encrypted - key file that contains the private key of the user or the combination of smartcard and PinPad reader (e.g. ':cs2:cyb:COM3', ':cs2:auto:USB0'). |
| pin | Keyfile: Password, if the key file is encrypted, or null. Smartcard: Pin of smartcard or null to enter pin at PinPad reader. |
Reimplemented in CryptoServerCluster.
| void logoff | ( | ) | throws IOException, CryptoServerException |
Terminates a secure messaging session and invalidates authentication.
Reimplemented in CryptoServerCluster.
| int getAuthState | ( | ) | throws IOException, CryptoServerException |
Returns resulting authentication state.
Reimplemented in CryptoServerCluster.
| void prepareAuthenticationHMAC | ( | String | user, |
| byte[] | password | ||
| ) | throws CryptoServerException |
Prepares to authenticate the subsequent commands with "HMAC Password" mechanism.
The next commands executed via the exec() method or the getSessionKeyDH() method are authenticated.
| user | Name of the user who wants to autenticate to the CryptoServer. |
| password | Password of the user. May contain binary data. |
| void prepareAuthenticationHMAC | ( | String | user, |
| String | password | ||
| ) | throws CryptoServerException, UnsupportedEncodingException |
Prepares to authenticate the subsequent commands with "HMAC Password" mechanism.
The next commands executed via the exec() method or the getSessionKeyDH() method are authenticated.
| user | Name of the user who wants to autenticate to the CryptoServer. |
| password | Password of the user. Should contain ISO8859-15 characters only. |
| void prepareAuthenticationRSASign | ( | String | user, |
| String | keySpec, | ||
| String | pin | ||
| ) | throws IOException, CryptoServerException |
Prepares to authenticate the subsequent commands with "RSA Signature" mechanism.
The next commands executed via the exec() method or the getSessionKeyDH() method are authenticated.
| user | Name of the user who wants to autenticate to the CryptoServer. |
| keySpec | Specifies either the name of a - optionally encrypted - key file that contains the private key of the user or smartcard and PinPad reader (e.g. ':cs2:cyb:COM3', ':cs2:auto:USB0') |
| pin | Keyfile: Password, if the key file is encrypted, or null. Smartcard: Pin of smartcard or null to enter pin at PinPad reader. |
| void prepareAuthenticationRSASC | ( | String | user, |
| String | pin | ||
| ) | throws IOException, CryptoServerException |
Prepares to authenticate the subsequent commands with "RSA Smartcard" mechanism.
The next commands executed via the exec() method or the getSessionKeyDH() method are authenticated.
| user | Name of the user who wants to autenticate to the CryptoServer. |
| pin | PIN of the smartcard (optional), or null |
| synchronized void endAuthentication | ( | ) |
Stops authentication.
All pending authentication requests issued with one of the prepareAuthentication...() methods are cancelled.
| void getSessionKeyDH | ( | ) | throws IOException, CryptoServerException |
Establishes a secure messaging session with the CryptoServer using 2048 bit Diffie-Hellman key agreement.
An AES session key is negotiated with the CryptoServer and used to encrypt all commands send to and all answers received from the CryptoServer. The session is valid for all subsequent communication until a new session key is generated or the session is terminated with the endSession() method.
| synchronized void setKeepSessionAlive | ( | boolean | flag | ) | throws CryptoServerException |
Starts or stops an additional thread that keeps the current session alive and prevents it from expiring after 15 minutes idle time.
If a session remains idle (no command was sent) for more than 15 minutes, the session expires and is automatically invalidated by the CryptoServer.
| flag |
|
Reimplemented in CryptoServerCluster.
| void setEndSessionOnShutdown | ( | boolean | flag | ) |
Enables or disables a ShutdownHook for terminating active sessions.
If enabled a session is automatically ended on shutdown without endSession() having been called explicitly.
| flag | ShutdownHook is enables if TRUE, disabled if FALSE. |
| synchronized void endSession | ( | ) |
Terminates a secure messaging session.
The session key will be invalidated and all subsequent communication with the CryptoServer will no longer be encrypted.
| void getSessionKeyDH | ( | int | size | ) | throws IOException, CryptoServerException |
| void keepSessionAlive | ( | ) | throws CryptoServerException |
Reimplemented in CryptoServerCluster.
| void setTrace | ( | PrintStream | out | ) |
| void setTrace | ( | boolean | flag | ) |