Class GenericSSLSocketFactory
java.lang.Object
org.jpos.util.SimpleLogSource
org.jpos.iso.GenericSSLSocketFactory
- All Implemented Interfaces:
Configurable, ISOClientSocketFactory, ISOServerSocketFactory, LogSource
- Direct Known Subclasses:
SunJSSESocketFactory
public class GenericSSLSocketFactory
extends SimpleLogSource
implements ISOServerSocketFactory, ISOClientSocketFactory, Configurable
SunJSSESocketFactory is used by BaseChannel and ISOServer
in order to provide hooks for SSL implementations.- Since:
- 1.3.3
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor; no instance state to initialise. -
Method Summary
Modifier and TypeMethodDescriptioncreateServerSocket(int port) Create a server socket on the specified port (port 0 indicates an anonymous port).protected SSLServerSocketFactoryCreate a socket factorycreateSocket(String host, int port) Create a client socket connected to the specified host and port.protected SSLSocketFactoryCreate a socket factorybooleanReturns whether accepted sockets require TLS client authentication.Returns the configuration applied viasetConfiguration(Configuration).String[]Returns the explicit list of TLS cipher suites enabled on created sockets.protected StringHook returning the private-key entry password.Returns the path of the configured JKS key store.protected StringHook returning the key store password.booleanReturns whether outbound sockets validate the server certificate chain.Returns the configured peer certificate Common Name.voidsetClientAuthNeeded(boolean clientAuthNeeded) Toggles whether accepted sockets require TLS client authentication.voidConfigures this object with the suppliedConfiguration.voidsetEnabledCipherSuites(String[] enabledCipherSuites) Sets the explicit list of TLS cipher suites enabled on created sockets.voidsetKeyPassword(String keyPassword) Sets the password protecting the private key entry.voidsetKeyStore(String keyStore) Sets the path of the JKS key store used for the TLS handshake.voidsetPassword(String password) Sets the key store password.voidsetServerAuthNeeded(boolean serverAuthNeeded) Toggles whether outbound sockets validate the server certificate chain.voidsetServerName(String serverName) Sets the Common Name (CN) used to verify the peer certificate.Methods inherited from class SimpleLogSource
error, error, getLogger, getRealm, info, info, setLogger, setRealm, warning, warningModifier and TypeMethodDescriptionvoidLogs an error message.voidLogs an error message with an attached object.Returns the logger.getRealm()Returns the logging realm.voidLogs an informational message.voidLogs an informational message with an attached object.voidSets the logger and realm for this log source.voidSets the logging realm.voidLogs a warning message.voidLogs a warning message with an attached object.
-
Constructor Details
-
GenericSSLSocketFactory
public GenericSSLSocketFactory()Default constructor; no instance state to initialise.
-
-
Method Details
-
setKeyStore
Sets the path of the JKS key store used for the TLS handshake.- Parameters:
keyStore- filesystem path of the JKS key store
-
setPassword
Sets the key store password.- Parameters:
password- key store password
-
setKeyPassword
Sets the password protecting the private key entry.- Parameters:
keyPassword- password protecting the private key entry
-
setServerName
Sets the Common Name (CN) used to verify the peer certificate.- Parameters:
serverName- expected Common Name (CN) of the peer certificate
-
setClientAuthNeeded
Toggles whether accepted sockets require TLS client authentication.- Parameters:
clientAuthNeeded- require TLS client authentication on accepted sockets
-
setServerAuthNeeded
Toggles whether outbound sockets validate the server certificate chain.- Parameters:
serverAuthNeeded- validate the server certificate chain on outbound sockets
-
createServerSocketFactory
Create a socket factory- Returns:
- the socket factory
- Throws:
ISOException- if an error occurs during server socket creation
-
createSocketFactory
Create a socket factory- Returns:
- the socket factory
- Throws:
ISOException- if an error occurs during server socket creation
-
createServerSocket
Create a server socket on the specified port (port 0 indicates an anonymous port).- Specified by:
createServerSocketin interfaceISOServerSocketFactory- Parameters:
port- the port number- Returns:
- the server socket on the specified port
- Throws:
IOException- should an I/O error occurs duringISOException- should an error occurs during creation
-
createSocket
Create a client socket connected to the specified host and port.- Specified by:
createSocketin interfaceISOClientSocketFactory- Parameters:
host- the host nameport- the port number- Returns:
- a socket connected to the specified host and port.
- Throws:
IOException- if an I/O error occurs during socket creationISOException- should any other error occurs
-
getKeyStore
Returns the path of the configured JKS key store.- Returns:
- filesystem path of the JKS key store
-
getPassword
Hook returning the key store password. Subclasses are expected to override this to source the password from a secret manager rather than a system property.- Returns:
- key store password
-
getKeyPassword
Hook returning the private-key entry password. Subclasses are expected to override this to source the password from a secret manager rather than a system property.- Returns:
- private-key entry password
-
getServerName
Returns the configured peer certificate Common Name.- Returns:
- expected Common Name (CN) of the peer certificate
-
getClientAuthNeeded
Returns whether accepted sockets require TLS client authentication.- Returns:
truewhen accepted sockets require TLS client authentication
-
getServerAuthNeeded
Returns whether outbound sockets validate the server certificate chain.- Returns:
truewhen outbound sockets validate the server certificate chain
-
setEnabledCipherSuites
Sets the explicit list of TLS cipher suites enabled on created sockets.- Parameters:
enabledCipherSuites- cipher suites to enable on created sockets;nullor empty leaves provider defaults in place
-
getEnabledCipherSuites
Returns the explicit list of TLS cipher suites enabled on created sockets.- Returns:
- cipher suites enabled on created sockets, or
nullwhen provider defaults apply
-
setConfiguration
Description copied from interface:ConfigurableConfigures this object with the suppliedConfiguration.- Specified by:
setConfigurationin interfaceConfigurable- Parameters:
cfg- Configuration object- Throws:
ConfigurationException- if the configuration is invalid
-
getConfiguration
Returns the configuration applied viasetConfiguration(Configuration).- Returns:
- active configuration, or
nullif not yet configured
-