public class TcpParams
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.security.KeyStore |
certKeyStore
the keystore that holds the own certificates
|
private java.lang.String |
certPassword
the password for the certificate
|
private java.lang.String |
clientCertAlgorithm
the client cert algorithm
|
private long |
idleTimeout
the idle timeout in milliseconds (
0 = off) |
private int |
maxReceiveSize
the maximum receive message size
|
private java.lang.String |
protocol
the protocol
|
private int |
receiveTimeout
the wait timeout in milliseconds
|
private java.net.InetAddress |
serverAddress
the address of the server
|
private int |
serverPort
the port number of the server
|
private java.lang.String |
trustedCertsAlgorithm
the trust certs algorithm
|
private java.security.KeyStore |
trustKeyStore
the keystore that holds the trusted root certificates
|
private boolean |
verifyServerName
flag whether to check the CN
|
Constructor and Description |
---|
TcpParams()
constructor.
|
TcpParams(TcpParams other)
copy constructor
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCertAlgorithm()
return the name of the client certificate algorithm
|
java.security.KeyStore |
getCertKeyStore()
return the client key store
|
java.lang.String |
getCertPassword()
return the password for the private key of the client certificate
|
long |
getIdleTimeout()
return the delay from which on an idle connection is considered as
closed
|
int |
getMaxReceiveSize()
return the maximum message size that is accepted.
|
java.lang.String |
getProtocol()
return the name of the SSL protocol
|
int |
getReceiveTimeout()
return the maximum time to wait for a response
|
java.net.InetAddress |
getServerAddress()
return the server address
|
int |
getServerPort()
return the server port number
|
java.lang.String |
getTrustAlgorithm()
return the name of the trusted certificates algorithm
|
java.security.KeyStore |
getTrustKeyStore()
return the client key store
|
private static java.security.KeyStore |
loadKeyStore(java.io.File file,
java.lang.String storeType,
java.lang.String storePassword)
load a key store from the given file
|
private static java.security.KeyStore |
loadKeyStore(java.io.InputStream is,
java.lang.String storeType,
java.lang.String storePassword)
load a key store
|
void |
setCertAlgorithm(java.lang.String algorithm)
set the name of the client certificate algorithm
|
void |
setCertKeyStore(java.io.File file,
java.lang.String storeType,
java.lang.String storePassword)
set the client certificate key store
|
void |
setCertKeyStore(java.io.InputStream is,
java.lang.String storeType,
java.lang.String storePassword)
set the client certificate key store
|
void |
setCertKeyStore(java.security.KeyStore keyStore)
set the client certificate key store
|
void |
setCertPassword(java.lang.String password)
set the password for the private key of the client certificate
|
void |
setIdleTimeout(long timeout)
set the delay from which on an idle connection is considered as closed
|
void |
setMaxReceiveSize(int maxSize)
set the maximum message size that is accepted.
|
void |
setProtocol(java.lang.String theProtocol)
set the name of the SSL protocol
|
void |
setReceiveTimeout(int timeout)
set the maximum time to wait for a response
|
void |
setServerAddress(java.net.InetAddress address)
set the server address
|
void |
setServerPort(int port)
set the server port number
|
void |
setTrustAlgorithm(java.lang.String algorithm)
set the name of the trusted certificates algorithm
|
void |
setTrustKeyStore(java.io.File file,
java.lang.String storeType,
java.lang.String storePassword)
set the trust certificate key store
|
void |
setTrustKeyStore(java.io.InputStream is,
java.lang.String storeType,
java.lang.String storePassword)
set the trust certificate key store
|
void |
setTrustKeyStore(java.security.KeyStore keyStore)
set the trust certificate key store
|
void |
setupFromProperties(java.util.Properties props,
java.lang.String prefix)
initialize the object from the given properties.
|
void |
setVerifyServerName(boolean verify)
set whether the common name of the server certificate shall be
verified, i.e. shall be compared to the reverse mapping of the
server address.
|
boolean |
verifyServerName()
return whether the server name shall be verified
|
private java.net.InetAddress serverAddress
private int serverPort
private java.lang.String protocol
private java.lang.String clientCertAlgorithm
private java.lang.String trustedCertsAlgorithm
private java.lang.String certPassword
private java.security.KeyStore certKeyStore
private java.security.KeyStore trustKeyStore
private boolean verifyServerName
private int maxReceiveSize
private int receiveTimeout
private long idleTimeout
0
= off)public TcpParams()
public TcpParams(TcpParams other)
other
- the other instance to copy frompublic void setServerAddress(java.net.InetAddress address)
address
- the addresspublic java.net.InetAddress getServerAddress()
public void setServerPort(int port)
port
- the port numberpublic int getServerPort()
public void setMaxReceiveSize(int maxSize)
maxSize
- the size or 0
for unlimited sizepublic int getMaxReceiveSize()
0
for unlimited sizepublic void setReceiveTimeout(int timeout)
timeout
- the timeout time in milliseconds, if
0
, it is waited indefinitelypublic int getReceiveTimeout()
0
, it is waited indefinitelypublic void setIdleTimeout(long timeout)
timeout
- the idle timeout (off if 0
)public long getIdleTimeout()
0
if off)public void setProtocol(java.lang.String theProtocol)
theProtocol
- the protocol's namepublic java.lang.String getProtocol()
public void setCertAlgorithm(java.lang.String algorithm)
algorithm
- the namepublic java.lang.String getCertAlgorithm()
public void setTrustAlgorithm(java.lang.String algorithm)
algorithm
- the namepublic java.lang.String getTrustAlgorithm()
private static java.security.KeyStore loadKeyStore(java.io.InputStream is, java.lang.String storeType, java.lang.String storePassword) throws java.io.IOException, java.security.GeneralSecurityException
is
- the input streamstoreType
- the store type (may be null
for the default type)storePassword
- the store password (may be
null
)java.io.IOException
- if the loading failed due to I/O problemsjava.security.GeneralSecurityException
- if the key store could not be loadedprivate static java.security.KeyStore loadKeyStore(java.io.File file, java.lang.String storeType, java.lang.String storePassword) throws java.io.IOException, java.security.GeneralSecurityException
file
- the filestoreType
- the store type (may be null
for the default type)storePassword
- the store password (may be
null
)java.io.IOException
- if the loading failed due to I/O problemsjava.security.GeneralSecurityException
- if the key store could not be loadedpublic void setCertKeyStore(java.security.KeyStore keyStore)
keyStore
- the key storepublic void setCertKeyStore(java.io.InputStream is, java.lang.String storeType, java.lang.String storePassword) throws java.io.IOException, java.security.GeneralSecurityException
is
- the input streamstoreType
- the store type (may be null
for the default type)storePassword
- the store password (may be
null
)java.io.IOException
- if the loading failed due to I/O problemsjava.security.GeneralSecurityException
- if the key store could not be loadedpublic void setCertKeyStore(java.io.File file, java.lang.String storeType, java.lang.String storePassword) throws java.io.IOException, java.security.GeneralSecurityException
file
- the filestoreType
- the store type (may be null
for the default type)storePassword
- the store password (may be
null
)java.io.IOException
- if the loading failed due to I/O problemsjava.security.GeneralSecurityException
- if the key store could not be loadedpublic java.security.KeyStore getCertKeyStore()
null
public void setCertPassword(java.lang.String password)
password
- the password, may be null
public java.lang.String getCertPassword()
null
public void setTrustKeyStore(java.security.KeyStore keyStore)
keyStore
- the key storepublic void setTrustKeyStore(java.io.InputStream is, java.lang.String storeType, java.lang.String storePassword) throws java.io.IOException, java.security.GeneralSecurityException
is
- the input streamstoreType
- the store type (may be null
for the default type)storePassword
- the store password (may be
null
)java.io.IOException
- if the loading failed due to I/O problemsjava.security.GeneralSecurityException
- if the key store could not be loadedpublic void setTrustKeyStore(java.io.File file, java.lang.String storeType, java.lang.String storePassword) throws java.io.IOException, java.security.GeneralSecurityException
file
- the filestoreType
- the store type (may be null
for the default type)storePassword
- the store password (may be
null
)java.io.IOException
- if the loading failed due to I/O problemsjava.security.GeneralSecurityException
- if the key store could not be loadedpublic java.security.KeyStore getTrustKeyStore()
null
public void setVerifyServerName(boolean verify)
verify
- if true
, the name is verifiedpublic boolean verifyServerName()
true
if sopublic void setupFromProperties(java.util.Properties props, java.lang.String prefix) throws java.io.IOException, java.security.GeneralSecurityException, java.lang.NumberFormatException
prefixserver.name | required | Host name or IP address of server |
prefixserver.port | required | Port number |
prefixprotocol | optional | The protocol name |
prefixcert.algorithm | optional | The designated algorithm for dealing with client certificates |
prefixcert.keystore.path | optional | The path to the file containing the client certificate |
prefixcert.keystore.type | optional | The type of the key store, typically "jks" or "pkcs12" |
prefixcert.keystore.password | optional | The password, if the keystore is protected |
prefixcert.password | optional | The password for the certificate itself |
prefixtrust.algorithm | optional | The designated algorithm for dealing with trusted certificates |
prefixtrust.keystore.path | optional | The path to the file containing the trusted root certificates |
prefixtrust.keystore.type | optional | The type of the key store, typically "jks" or "pkcs12" |
prefixtrust.keystore.password | optional | The password, if the keystore is protected |
prefixtrust.verifyname | optional | Specifies whether the name shall be verified. If "true" or "yes" (case insensitive) are specified, the verification is done |
prefixtimeout.receive | optional | the timeout in milliseconds when reading responses from the server |
prefixtimeout.idle | optional | the idle timeout in milliseconds. If the given time no communication has taken place, the connection is considered as closed |
props
- the propertiesprefix
- the prefixjava.io.IOException
- if the specified files could not be
loadedjava.security.GeneralSecurityException
- if the key stores or the passwords are
invalidjava.lang.NumberFormatException
- if a numeric property is not parsableCopyright © 2005-2013 Knipp Medien und Kommunikation GmbH