public class PopSsl extends Pop
Example Usage (implicit SSL/TLS):
// connection parameters for SSL connection String hostname = "pop3.myserver.com"; String username = "jsmith"; String password = "secret"; int port = 995; // new instance hostname, port, username and password PopSsl pop = new PopSsl(hostname,port,username,password); try { // connect to POP3 server pop.connect(); // get messages Enumeration e = pop.getMessages(); while(e.hasMoreElements()) { EmailMessage em = (EmailMessage)e.nextElement(); } // disconnect pop.disconnect(); } catch(Exception e) { System.out.println(e); }Example Usage (explicit SSL/TLS using STLS command on port 110):
// connection parameters for SSL connection String hostname = "pop3.myserver.com"; String username = "jsmith"; String password = "secret"; int port = 110; // new instance hostname, port, username and password PopSsl pop = new PopSsl(hostname,port,username,password); pop.setConnectionType(PopSsl.STARTTLS); try { // connect to POP3 server pop.connect(); // get messages Enumeration e = pop.getMessages(); while(e.hasMoreElements()) { EmailMessage em = (EmailMessage)e.nextElement(); } // disconnect pop.disconnect(); } catch(Exception e) { System.out.println(e); }
Pop.Authentication
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PORT
The default port to connect to for secure POP3 over SSL connections (995).
|
static int |
IMPLICIT_SSL
Connection type for implicit SSL/TLS connections on port 995.
|
static int |
STARTTLS
Connection type for explicit SSL/TLS connections using STARTTLS command on port 110.
|
AUTH_APOP, AUTH_LOGIN, AUTH_PASS, AUTH_XOAUTH2
Constructor and Description |
---|
PopSsl(java.lang.String hostname,
int port,
java.lang.String username,
java.lang.String password)
Constructs a new PopSsl instance.
|
PopSsl(java.lang.String hostname,
java.lang.String username,
java.lang.String password)
Constructs a new PopSsl instance.
|
Modifier and Type | Method and Description |
---|---|
void |
clearProxySettings()
Clears proxy server values.
|
PopSsl |
connect()
Establishes secure SSL connection to POP3 server.
|
void |
disconnect()
Disconnects from POP3 server.
|
int |
getConnectionType()
Gets the connection type for this session.
|
void |
setClientCertificates(java.lang.String filename,
java.lang.String password)
Sets optional client certificate to be used during authentication.
|
void |
setClientCertificates(java.lang.String filename,
java.lang.String password,
java.lang.String storetype)
Sets optional client certificate to be used during authentication.
|
void |
setConnectionType(int mode)
Sets the connection type for this session.
|
void |
setProxyAuthentication(java.lang.String proxyUsername,
java.lang.String proxyPassword)
Sets the username and password to use when for authentication with
proxy server.
|
void |
setProxyHost(java.lang.String proxyHostname,
int proxyPort)
Sets the proxy hostname and port for this connection.
|
void |
setProxyType(java.lang.String proxyType)
Sets the proxy type will be used for this connection.
|
void |
setServerCertificates(java.lang.String filename,
java.lang.String password)
Sets optional server certificate to be used during authentication.
|
void |
setServerCertificates(java.lang.String filename,
java.lang.String password,
java.lang.String storetype)
Sets optional server certificate to be used during authentication.
|
void |
setSSLContext(javax.net.ssl.SSLContext context)
Sets SSL context for this connection.
|
addPopListener, close, deleteMessage, getAuthMode, getConnectTimeout, getDebugStream, getHostname, getMessage, getMessageCount, getMessageReader, getMessages, getMessageSize, getPort, getReadTimeout, getTimeout, getTop, getUid, getUsername, isConnected, isDebug, isDelete, issueCommand, issueCommand, issueCommandMultiLine, removePopListener, setAuthentication, setAuthMode, setConnectTimeout, setDebug, setDebugStream, setDelete, setHostname, setPassword, setPort, setReadTimeout, setTimeout, setUsername
public static final int IMPLICIT_SSL
setConnectionType(int)
,
STARTTLS
,
Constant Field Valuespublic static final int STARTTLS
setConnectionType(int)
,
IMPLICIT_SSL
,
Constant Field Valuespublic static final int DEFAULT_PORT
public PopSsl(java.lang.String hostname, java.lang.String username, java.lang.String password)
hostname
- the hostname of POP3 serverusername
- the username of POP3 userpassword
- the password of POP3 userpublic PopSsl(java.lang.String hostname, int port, java.lang.String username, java.lang.String password)
hostname
- the hostname of POP3 serverport
- the port of secure POP3 serverusername
- the username of POP3 userpassword
- the password of POP3 userpublic void setClientCertificates(java.lang.String filename, java.lang.String password)
keytool
utility provided in the Sun JDK.
Example:
keytool.exe -import -file x509.cer -keystore your_store_nameThe example above imports the certificate x509.cer into a keystore named your_store_name
filename
- the keystore file containing the client certificatepassword
- the keystore passwordpublic void setClientCertificates(java.lang.String filename, java.lang.String password, java.lang.String storetype)
keytool
utility provided in the Sun JDK.
Example:
keytool.exe -import -file x509.cer -keystore your_store_nameThe example above imports the certificate x509.cer into a keystore named your_store_name
filename
- the keystore file containing the client certificatepassword
- the keystore passwordstoretype
- the keystore type valid values include jks and pkcs12public void setConnectionType(int mode)
mode
- a valid connection typeIMPLICIT_SSL
,
STARTTLS
public int getConnectionType()
IMPLICIT_SSL
,
STARTTLS
public void setSSLContext(javax.net.ssl.SSLContext context)
context
- an SSLContext instanceSSLContext
public void setServerCertificates(java.lang.String filename, java.lang.String password)
keytool
utility provided in the Sun JDK.
Example:
keytool.exe -import -file x509.cer -keystore your_store_nameThe example above imports the certificate x509.cer into a keystore named your_store_name
filename
- the keystore file containing the server certificatepassword
- the keystore passwordpublic void setServerCertificates(java.lang.String filename, java.lang.String password, java.lang.String storetype)
keytool
utility provided in the Sun JDK.
Example:
keytool.exe -import -file x509.cer -keystore your_store_nameThe example above imports the certificate x509.cer into a keystore named your_store_name
filename
- the keystore file containing the server certificatepassword
- the keystore passwordstoretype
- the keystore type valid values include jks and pkcs12public void setProxyAuthentication(java.lang.String proxyUsername, java.lang.String proxyPassword)
#clearProxySettings
method.setProxyAuthentication
in class Pop
proxyUsername
- the proxy usernameproxyPassword
- the proxy passwordclearProxySettings()
public void setProxyHost(java.lang.String proxyHostname, int proxyPort)
#clearProxySettings
method.setProxyHost
in class Pop
proxyHostname
- the hostname or ip address of the proxy serverproxyPort
- the port of the proxy serverclearProxySettings()
public void setProxyType(java.lang.String proxyType)
setProxyType
in class Pop
proxyType
- The proxy type. Valid values: HTTP, SOCKS5public void clearProxySettings()
clearProxySettings
in class Pop
public PopSsl connect() throws PopException
connect
in class Pop
PopException
- if I/O or POP3 related error occurspublic void disconnect() throws PopException
disconnect
in class Pop
PopException
- if I/O or POP3 related error occursCopyright © JSCAPE LLC. 1999-2021. All Rights Reserved