| java.lang.Object |
| ↳ |
javax.net.SocketFactory |
| |
↳ |
javax.net.ssl.SSLSocketFactory |
| |
|
↳ |
com.google.code.com.sun.mail.util.MailSSLSocketFactory |
Class Overview
An SSL socket factory that makes it easier to specify trust.
This socket factory can be configured to trust all hosts or
trust a specific set of hosts, in which case the server's
certificate isn't verified. Alternatively, a custom TrustManager
can be supplied.
An instance of this factory can be set as the value of the
mail.<protocol>.ssl.socketFactory property.
Summary
| Fields |
|
private
SSLSocketFactory |
adapteeFactory |
Holds a SSLSocketFactory to pass all API-method-calls to |
|
private
KeyManager[] |
keyManagers |
Holds the KeyManager array to use |
|
private
SecureRandom |
secureRandom |
Holds the SecureRandom to use |
|
private
SSLContext |
sslcontext |
Holds a SSLContext to get SSLSocketFactories from |
|
private
boolean |
trustAllHosts |
Should all hosts be trusted? |
|
private
TrustManager[] |
trustManagers |
Holds the TrustManager array to use |
|
private
String[] |
trustedHosts |
String-array of trusted hosts |
|
[Expand]
Inherited Fields |
From class
javax.net.ssl.SSLSocketFactory
|
static
final
boolean |
DEBUG |
|
|
private
static
boolean |
propertyChecked |
|
|
private
static
SSLSocketFactory |
theFactory |
|
|
From class
javax.net.SocketFactory
|
private
static
SocketFactory |
theFactory |
|
|
| Public Methods |
|
synchronized
Socket
|
createSocket(String s, int i)
|
|
synchronized
Socket
|
createSocket(String s, int i, InetAddress inetaddress, int j)
|
|
synchronized
Socket
|
createSocket(InetAddress inetaddress, int i, InetAddress inetaddress1, int j)
|
|
synchronized
Socket
|
createSocket(InetAddress inetaddress, int i)
|
|
synchronized
Socket
|
createSocket(Socket socket, String s, int i, boolean flag)
|
|
synchronized
Socket
|
createSocket()
|
|
synchronized
String[]
|
getDefaultCipherSuites()
|
|
synchronized
KeyManager[]
|
getKeyManagers()
|
|
synchronized
SecureRandom
|
getSecureRandom()
|
|
synchronized
String[]
|
getSupportedCipherSuites()
|
|
synchronized
TrustManager[]
|
getTrustManagers()
|
|
synchronized
String[]
|
getTrustedHosts()
|
|
synchronized
boolean
|
isServerTrusted(String server, SSLSocket sslSocket)
After a successful conection to the server, this method is
called to ensure that the server should be trusted.
|
|
synchronized
boolean
|
isTrustAllHosts()
|
|
synchronized
void
|
setKeyManagers(KeyManager[] keyManagers)
|
|
synchronized
void
|
setSecureRandom(SecureRandom secureRandom)
|
|
synchronized
void
|
setTrustAllHosts(boolean trustAllHosts)
|
|
synchronized
void
|
setTrustManagers(TrustManager[] trustManagers)
|
|
synchronized
void
|
setTrustedHosts(String[] trustedHosts)
|
|
[Expand]
Inherited Methods |
From class
javax.net.ssl.SSLSocketFactory
|
abstract
Socket
|
createSocket(Socket arg0, String arg1, int arg2, boolean arg3)
|
|
synchronized
static
SocketFactory
|
getDefault()
|
|
abstract
String[]
|
getDefaultCipherSuites()
|
|
abstract
String[]
|
getSupportedCipherSuites()
|
|
From class
javax.net.SocketFactory
|
abstract
Socket
|
createSocket(String arg0, int arg1, InetAddress arg2, int arg3)
|
|
abstract
Socket
|
createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3)
|
|
abstract
Socket
|
createSocket(InetAddress arg0, int arg1)
|
|
abstract
Socket
|
createSocket(String arg0, int arg1)
|
|
Socket
|
createSocket()
|
|
static
SocketFactory
|
getDefault()
|
|
From class
java.lang.Object
|
Object
|
clone()
|
|
boolean
|
equals(Object arg0)
|
|
void
|
finalize()
|
|
final
Class<?>
|
getClass()
|
|
int
|
hashCode()
|
|
final
void
|
notify()
|
|
final
void
|
notifyAll()
|
|
String
|
toString()
|
|
final
void
|
wait()
|
|
final
void
|
wait(long arg0, int arg1)
|
|
final
void
|
wait(long arg0)
|
|
Fields
private
SSLSocketFactory
adapteeFactory
Holds a SSLSocketFactory to pass all API-method-calls to
private
KeyManager[]
keyManagers
Holds the KeyManager array to use
private
SecureRandom
secureRandom
Holds the SecureRandom to use
private
SSLContext
sslcontext
Holds a SSLContext to get SSLSocketFactories from
private
boolean
trustAllHosts
Should all hosts be trusted?
private
TrustManager[]
trustManagers
Holds the TrustManager array to use
private
String[]
trustedHosts
String-array of trusted hosts
Public Constructors
public
MailSSLSocketFactory
()
Initializes a new MailSSLSocketFactory.
public
MailSSLSocketFactory
(String protocol)
Initializes a new MailSSLSocketFactory with a given protocol.
Normally the protocol will be specified as "TLS".
Parameters
| protocol
| The protocol to use |
Throws
| NoSuchAlgorithmException
| if given protocol is not supported
|
| GeneralSecurityException
| |
Public Methods
public
synchronized
Socket
createSocket
(String s, int i)
Throws
| IOException
| |
| UnknownHostException
| |
public
synchronized
Socket
createSocket
(String s, int i, InetAddress inetaddress, int j)
Throws
| IOException
| |
| UnknownHostException
| |
public
synchronized
Socket
createSocket
(InetAddress inetaddress, int i, InetAddress inetaddress1, int j)
Parameters
| inetaddress
| |
| i
| |
| inetaddress1
| |
| j
| |
public
synchronized
Socket
createSocket
(InetAddress inetaddress, int i)
public
synchronized
Socket
createSocket
(Socket socket, String s, int i, boolean flag)
public
synchronized
Socket
createSocket
()
public
synchronized
String[]
getDefaultCipherSuites
()
public
synchronized
KeyManager[]
getKeyManagers
()
public
synchronized
SecureRandom
getSecureRandom
()
public
synchronized
String[]
getSupportedCipherSuites
()
public
synchronized
TrustManager[]
getTrustManagers
()
public
synchronized
String[]
getTrustedHosts
()
public
synchronized
boolean
isServerTrusted
(String server, SSLSocket sslSocket)
After a successful conection to the server, this method is
called to ensure that the server should be trusted.
Parameters
| server
| Name of the server we connected to |
| sslSocket
| SSLSocket connected to the server |
Returns
- true if "trustAllHosts" is set to true OR the server
is contained in the "trustedHosts" array;
public
synchronized
boolean
isTrustAllHosts
()
Returns
- true if all hosts should be trusted
public
synchronized
void
setKeyManagers
(KeyManager[] keyManagers)
Parameters
| keyManagers
| The keyManagers to set
|
public
synchronized
void
setSecureRandom
(SecureRandom secureRandom)
Parameters
| secureRandom
| The secureRandom to set
|
public
synchronized
void
setTrustAllHosts
(boolean trustAllHosts)
Parameters
| trustAllHosts
| Should all hosts be trusted?
|
public
synchronized
void
setTrustManagers
(TrustManager[] trustManagers)
Parameters
| trustManagers
| The trustManagers to set
|
public
synchronized
void
setTrustedHosts
(String[] trustedHosts)
Parameters
| trustedHosts
| The hosts to trust
|