public class SMTPSClient extends SMTPClient
SMTPSClient c = new SMTPSClient(true); c.connect("127.0.0.1", 465);Explicit usage:
SMTPSClient c = new SMTPSClient(); c.connect("127.0.0.1", 25); if (c.execTLS()) { // Rest of the commands here }Warning: the hostname is not verified against the certificate by default, use
setHostnameVerifier(HostnameVerifier)
or
setEndpointCheckingEnabled(boolean)
(on Java 1.7+) to enable verification._commandSupport_, DEFAULT_PORT, encoding
_defaultPort_, _hostname_, _input_, _output_, _serverSocketFactory_, _socket_, _socketFactory_, _timeout_, connectTimeout, NETASCII_EOL
Constructor and Description |
---|
SMTPSClient()
Constructor for SMTPSClient, using
DEFAULT_PROTOCOL i.e. |
SMTPSClient(boolean implicit)
Constructor for SMTPSClient, using
DEFAULT_PROTOCOL i.e. |
SMTPSClient(boolean implicit,
SSLContext ctx)
Constructor for SMTPSClient, using
DEFAULT_PROTOCOL i.e. |
SMTPSClient(SSLContext context)
Constructor for SMTPSClient.
|
SMTPSClient(String proto)
Constructor for SMTPSClient, using explicit security mode.
|
SMTPSClient(String proto,
boolean implicit)
Constructor for SMTPSClient.
|
SMTPSClient(String proto,
boolean implicit,
String encoding)
Constructor for SMTPSClient.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_connectAction_()
Because there are so many connect() methods, the _connectAction_() method is provided as a means of performing some action immediately after establishing
a connection, rather than reimplementing all of the connect() methods.
|
boolean |
execTLS()
The TLS command execution.
|
String[] |
getEnabledCipherSuites()
Returns the names of the cipher suites which could be enabled for use on this connection.
|
String[] |
getEnabledProtocols()
Returns the names of the protocol versions which are currently enabled for use on this connection.
|
HostnameVerifier |
getHostnameVerifier()
Get the currently configured
HostnameVerifier . |
KeyManager |
getKeyManager()
Get the
KeyManager instance. |
TrustManager |
getTrustManager()
Get the currently configured
TrustManager . |
boolean |
isEndpointCheckingEnabled()
Return whether or not endpoint identification using the HTTPS algorithm on Java 1.7+ is enabled.
|
void |
setEnabledCipherSuites(String[] cipherSuites)
Controls which particular cipher suites are enabled for use on this connection.
|
void |
setEnabledProtocols(String[] protocolVersions)
Controls which particular protocol versions are enabled for use on this connection.
|
void |
setEndpointCheckingEnabled(boolean enable)
Automatic endpoint identification checking using the HTTPS algorithm is supported on Java 1.7+.
|
void |
setHostnameVerifier(HostnameVerifier newHostnameVerifier)
Override the default
HostnameVerifier to use. |
void |
setKeyManager(KeyManager newKeyManager)
Set a
KeyManager to use. |
void |
setTrustManager(TrustManager newTrustManager)
Override the default
TrustManager to use. |
addRecipient, addRecipient, completePendingCommand, listHelp, listHelp, login, login, logout, reset, sendMessageData, sendNoOp, sendShortMessageData, sendSimpleMessage, sendSimpleMessage, setSender, setSender, verify
data, disconnect, expn, getCommandSupport, getReply, getReplyCode, getReplyString, getReplyStrings, helo, help, help, mail, noop, quit, rcpt, removeProtocolCommandistener, rset, saml, send, sendCommand, sendCommand, sendCommand, sendCommand, soml, turn, vrfy
addProtocolCommandListener, applySocketAttributes, connect, connect, connect, connect, connect, connect, createCommandSupport, fireCommandSent, fireReplyReceived, getCharset, getCharsetName, getConnectTimeout, getDefaultPort, getDefaultTimeout, getKeepAlive, getLocalAddress, getLocalPort, getProxy, getReceiveBufferSize, getRemoteAddress, getRemotePort, getSendBufferSize, getServerSocketFactory, getSoLinger, getSoTimeout, getTcpNoDelay, isAvailable, isConnected, removeProtocolCommandListener, setCharset, setConnectTimeout, setDefaultPort, setDefaultTimeout, setKeepAlive, setProxy, setReceiveBufferSize, setSendBufferSize, setServerSocketFactory, setSocketFactory, setSoLinger, setSoTimeout, setTcpNoDelay, verifyRemote
public SMTPSClient()
DEFAULT_PROTOCOL
i.e. TLS Sets security mode to explicit (isImplicit = false).public SMTPSClient(boolean implicit)
DEFAULT_PROTOCOL
i.e. TLSimplicit
- The security mode, true
for implicit, false
for explicitpublic SMTPSClient(boolean implicit, SSLContext ctx)
DEFAULT_PROTOCOL
i.e. TLSimplicit
- The security mode, true
for implicit, false
for explicitctx
- A pre-configured SSL Context.public SMTPSClient(SSLContext context)
context
- A pre-configured SSL Context.SMTPSClient(boolean, SSLContext)
public SMTPSClient(String proto)
proto
- the protocol.public SMTPSClient(String proto, boolean implicit)
proto
- the protocol.implicit
- The security mode, true
for implicit, false
for explicitpublic SMTPSClient(String proto, boolean implicit, String encoding)
proto
- the protocol.implicit
- The security mode, true
for implicit, false
for explicitencoding
- the encodingprotected void _connectAction_() throws IOException
_connectAction_
in class SMTP
IOException
- If it is thrown by _connectAction_().SocketClient._connectAction_()
public boolean execTLS() throws IOException
IOException
- If an I/O error occurs while sending the command or performing the negotiation.public String[] getEnabledCipherSuites()
Socket
is not an
SSLSocket
instance, returns null.null
.public String[] getEnabledProtocols()
Socket
is
not an SSLSocket
instance, returns null.null
.public HostnameVerifier getHostnameVerifier()
HostnameVerifier
.public KeyManager getKeyManager()
KeyManager
instance.KeyManager
instance.public TrustManager getTrustManager()
TrustManager
.public boolean isEndpointCheckingEnabled()
public void setEnabledCipherSuites(String[] cipherSuites)
cipherSuites
- The cipher suites.public void setEnabledProtocols(String[] protocolVersions)
protocolVersions
- The protocol versions.public void setEndpointCheckingEnabled(boolean enable)
enable
- Enable automatic endpoint identification checking using the HTTPS algorithm on Java 1.7+.public void setHostnameVerifier(HostnameVerifier newHostnameVerifier)
HostnameVerifier
to use.newHostnameVerifier
- The HostnameVerifier implementation to set or null
to disable.public void setKeyManager(KeyManager newKeyManager)
KeyManager
to use.newKeyManager
- The KeyManager implementation to set.KeyManagerUtils
public void setTrustManager(TrustManager newTrustManager)
TrustManager
to use.newTrustManager
- The TrustManager implementation to set.TrustManagerUtils
Copyright © 2001–2022 The Apache Software Foundation. All rights reserved.