public final class Session extends Object
Modifier and Type | Method and Description |
---|---|
void |
addProvider(Provider provider)
Add a provider to the Session managed provider list.
|
boolean |
getDebug()
Get the debug setting for this session.
|
PrintStream |
getDebugOut()
Return the debug output stream.
|
static Session |
getDefaultInstance(Properties properties)
Get the "default" instance assuming no authenticator is required.
|
static Session |
getDefaultInstance(Properties properties,
Authenticator authenticator)
Get the "default" session.
|
Folder |
getFolder(URLName name)
Return a closed folder for the supplied URLName, or null if it cannot be obtained.
|
static Session |
getInstance(Properties properties)
Create a new session initialized with the supplied properties with no authenticator.
|
static Session |
getInstance(Properties properties,
Authenticator authenticator)
Create a new session initialized with the supplied properties which uses the supplied authenticator.
|
PasswordAuthentication |
getPasswordAuthentication(URLName name)
Get the password authentication associated with a URL
|
Properties |
getProperties()
Return the properties object for this Session; this is a live collection.
|
String |
getProperty(String property)
Return the specified property.
|
Provider |
getProvider(String protocol)
Return the provider for a specific protocol.
|
Provider[] |
getProviders()
Return the list of providers available to this application.
|
Store |
getStore()
Return a Store for the default protocol defined by the mail.store.protocol property.
|
Store |
getStore(Provider provider)
Return the Store specified by the given provider.
|
Store |
getStore(String protocol)
Return a Store for the specified protocol.
|
Store |
getStore(URLName url)
Return a Store for the protocol specified in the given URL
|
Transport |
getTransport()
Return a Transport for the default protocol specified by the
mail.transport.protocol property. |
Transport |
getTransport(Address address)
Return a transport for the protocol associated with the type of this address.
|
Transport |
getTransport(Provider provider)
Return the Transport specified by a Provider
|
Transport |
getTransport(String protocol)
Return a Transport for the specified protocol.
|
Transport |
getTransport(URLName name)
Return a transport for the protocol specified in the URL.
|
PasswordAuthentication |
requestPasswordAuthentication(InetAddress host,
int port,
String protocol,
String prompt,
String defaultUserName)
Call back to the application supplied authenticator to get the needed username add password.
|
void |
setDebug(boolean debug)
Enable debugging for this session.
|
void |
setDebugOut(PrintStream out)
Set the output stream where debug information should be sent.
|
void |
setPasswordAuthentication(URLName name,
PasswordAuthentication authenticator)
Set the password authentication associated with a URL.
|
void |
setProtocolForAddress(String addressType,
String protocol)
Add a mapping between an address type and a protocol used
to process that address type.
|
void |
setProvider(Provider provider)
Make the supplied Provider the default for its protocol.
|
public static Session getInstance(Properties properties, Authenticator authenticator)
properties
- the session propertiesauthenticator
- an authenticator for callbacks to the userpublic static Session getInstance(Properties properties)
properties
- the session propertiesgetInstance(java.util.Properties, Authenticator)
public static Session getDefaultInstance(Properties properties)
properties
- the session propertiesSecurityException
- if the does not have permission to access the default sessionpublic static Session getDefaultInstance(Properties properties, Authenticator authenticator)
properties
- authenticator
- SecurityException
- if the does not have permission to access the default sessionpublic void setDebug(boolean debug)
debug
- the debug settingpublic boolean getDebug()
public void setDebugOut(PrintStream out)
out
- the stream to write debug information topublic PrintStream getDebugOut()
public Provider[] getProviders()
public Provider getProvider(String protocol) throws NoSuchProviderException
getProviders()
for a entry for the specified protocol.protocol
- the protocol to get a provider forNoSuchProviderException
public void setProvider(Provider provider) throws NoSuchProviderException
provider
- the new default ProviderNoSuchProviderException
public Store getStore() throws NoSuchProviderException
NoSuchProviderException
public Store getStore(String protocol) throws NoSuchProviderException
protocol
- the protocol to get a Store forNoSuchProviderException
- if no provider is defined for the specified protocolpublic Store getStore(URLName url) throws NoSuchProviderException
url
- the URL of the StoreNoSuchProviderException
- if no provider is defined for the specified protocolpublic Store getStore(Provider provider) throws NoSuchProviderException
provider
- the provider to create fromNoSuchProviderException
- if there was a problem creating the Storepublic Folder getFolder(URLName name) throws MessagingException
name
- the location of the folderNoSuchProviderException
- if there is no providerMessagingException
- if there was a problem accessing the Storepublic Transport getTransport() throws NoSuchProviderException
mail.transport.protocol
property.NoSuchProviderException
public Transport getTransport(String protocol) throws NoSuchProviderException
protocol
- the protocol to useNoSuchProviderException
public Transport getTransport(URLName name) throws NoSuchProviderException
name
- the URL whose scheme specifies the protocolNoSuchProviderException
public Transport getTransport(Address address) throws NoSuchProviderException
address
- the address we are trying to deliver toNoSuchProviderException
public Transport getTransport(Provider provider) throws NoSuchProviderException
provider
- the defining ProviderNoSuchProviderException
public void setPasswordAuthentication(URLName name, PasswordAuthentication authenticator)
name
- the urlauthenticator
- the authenticatorpublic PasswordAuthentication getPasswordAuthentication(URLName name)
name
- the URLpublic PasswordAuthentication requestPasswordAuthentication(InetAddress host, int port, String protocol, String prompt, String defaultUserName)
host
- the host we are trying to connect to, may be nullport
- the port on that hostprotocol
- the protocol trying to be usedprompt
- a String to show as part of the prompt, may be nulldefaultUserName
- the default username, may be nullpublic Properties getProperties()
public String getProperty(String property)
property
- the property to getpublic void addProvider(Provider provider)
provider
- The new provider to add.Copyright © 2013. All Rights Reserved.