public final class Session
extends java.lang.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.
|
java.io.PrintStream |
getDebugOut()
Return the debug output stream.
|
static Session |
getDefaultInstance(java.util.Properties properties)
Get the "default" instance assuming no authenticator is required.
|
static Session |
getDefaultInstance(java.util.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(java.util.Properties properties)
Create a new session initialized with the supplied properties with no authenticator.
|
static Session |
getInstance(java.util.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
|
java.util.Properties |
getProperties()
Return the properties object for this Session; this is a live collection.
|
java.lang.String |
getProperty(java.lang.String property)
Return the specified property.
|
Provider |
getProvider(java.lang.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(java.lang.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(java.lang.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(java.net.InetAddress host,
int port,
java.lang.String protocol,
java.lang.String prompt,
java.lang.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(java.io.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(java.lang.String addressType,
java.lang.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(java.util.Properties properties, Authenticator authenticator)
properties - the session propertiesauthenticator - an authenticator for callbacks to the userpublic static Session getInstance(java.util.Properties properties)
properties - the session propertiesgetInstance(java.util.Properties, Authenticator)public static Session getDefaultInstance(java.util.Properties properties)
properties - the session propertiesjava.lang.SecurityException - if the does not have permission to access the default sessionpublic static Session getDefaultInstance(java.util.Properties properties, Authenticator authenticator)
properties - authenticator - java.lang.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(java.io.PrintStream out)
out - the stream to write debug information topublic java.io.PrintStream getDebugOut()
public Provider[] getProviders()
public Provider getProvider(java.lang.String protocol) throws NoSuchProviderException
getProviders()
for a entry for the specified protocol.protocol - the protocol to get a provider forNoSuchProviderExceptionpublic void setProvider(Provider provider) throws NoSuchProviderException
provider - the new default ProviderNoSuchProviderExceptionpublic Store getStore() throws NoSuchProviderException
NoSuchProviderExceptionpublic Store getStore(java.lang.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.NoSuchProviderExceptionpublic Transport getTransport(java.lang.String protocol) throws NoSuchProviderException
protocol - the protocol to useNoSuchProviderExceptionpublic Transport getTransport(URLName name) throws NoSuchProviderException
name - the URL whose scheme specifies the protocolNoSuchProviderExceptionpublic Transport getTransport(Address address) throws NoSuchProviderException
address - the address we are trying to deliver toNoSuchProviderExceptionpublic Transport getTransport(Provider provider) throws NoSuchProviderException
provider - the defining ProviderNoSuchProviderExceptionpublic void setPasswordAuthentication(URLName name, PasswordAuthentication authenticator)
name - the urlauthenticator - the authenticatorpublic PasswordAuthentication getPasswordAuthentication(URLName name)
name - the URLpublic PasswordAuthentication requestPasswordAuthentication(java.net.InetAddress host, int port, java.lang.String protocol, java.lang.String prompt, java.lang.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 java.util.Properties getProperties()
public java.lang.String getProperty(java.lang.String property)
property - the property to getpublic void addProvider(Provider provider)
provider - The new provider to add.public void setProtocolForAddress(java.lang.String addressType,
java.lang.String protocol)
addressType - The address type identifier.protocol - The protocol name mapping.