package votorola.g.mail; // Copyright 2008, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import java.io.*; import votorola.g.lang.*; /** Mail transfer service (transport), via Simple Mail Transfer Protocol (SMTP). * * @see com.sun.mail.smtp.SMTPTransport * @see ConstructionContext */ public final class SMTPTransportX { private SMTPTransportX() {} // ==================================================================================== /** A context for configuring access to an SMTP transfer server. */ public static @ThreadSafe class ConstructionContext { /** Constructs a ConstructionContext. * * @param startupConfigurationFile * per {@linkplain #startupConfigurationFile() startupConfigurationFile}() */ public ConstructionContext( File startupConfigurationFile ) { this.startupConfigurationFile = startupConfigurationFile; } // -------------------------------------------------------------------------------- /** The file from which this construction context was generated. */ public File startupConfigurationFile() { return startupConfigurationFile; } private final File startupConfigurationFile; /** Returns the authentication method for access to the server; * or null, if no authentication is required. * * @see #setAuthenticationMethodSimple(String,String) */ public SimpleAuthentication getAuthenticationMethod() { return authenticationMethod; } private SimpleAuthentication authenticationMethod; /** Sets the authentication method to simple name/password (not yet tested). * * @see #getAuthenticationMethod() */ @ThreadRestricted("constructor") public void setAuthenticationMethodSimple( String name, String password ) { authenticationMethod = new SimpleAuthentication( name, password ); } /** Returns the encryption method for communication with the server ("ssl"); * or null, if no encryption is used. * * @see #setEncryptionMethodSSL() */ public String getEncryptionMethod() { return encryptionMethod; } private String encryptionMethod; /** Sets the encryption method to Secure Sockets Layer (not yet tested). * * @see #getEncryptionMethod() */ @ThreadRestricted("constructor") public void setEncryptionMethodSSL() { encryptionMethod = "ssl"; } /** Returns the name of the transfer server. For example "localhost", or * "smtp.somewhere.net". * * @see #setServerName(String) */ public String getServerName() { return serverName; } private String serverName = "localhost"; /** Sets the name of the transfer server. The default value is "localhost". * * @see #getServerName() */ @ThreadRestricted("constructor") public void setServerName( String serverName ) { this.serverName = serverName; } /** Returns the communication port of the transfer server. * * @see #setServerPort(int) */ public int getServerPort() { return serverPort; } private int serverPort = 25; /** Sets the port of the PostgreSQL transfer server. * The default value is 25. * * @see #getServerPort() */ @ThreadRestricted("constructor") public void setServerPort( int serverPort ) { this.serverPort = serverPort; } } // ==================================================================================== /** Simple authentication for server access. */ public static final class SimpleAuthentication { private SimpleAuthentication( String name, String password ) { this.name = name; this.password = password; } public String password() { return password; } private final String password; public String name() { return name; } private final String name; } }