001    package railo.runtime.net.smtp;
002    
003    import javax.mail.Authenticator;
004    import javax.mail.PasswordAuthentication;
005    
006    /**
007     * This is a very simple authentication object that can be used for any
008     * transport needing basic userName and password type authentication.
009     *
010     */
011    public final class SMTPAuthenticator extends Authenticator {
012        /** Stores the login information for authentication */
013        private PasswordAuthentication authentication;
014    
015        /**
016         * Default constructor
017         *
018         * @param userName user name to use when authentication is requested
019         * @param password password to use when authentication is requested
020         *
021         */
022        public SMTPAuthenticator(String userName, String password){
023            this.authentication = new PasswordAuthentication(userName, password);
024        }
025    
026        /**
027         * Gets the authentication object that will be used to login to the mail
028         * server.
029         *
030         * @return A <code>PasswordAuthentication</code> object containing the
031         *         login information.
032         *
033         */
034        protected PasswordAuthentication getPasswordAuthentication() {
035            return this.authentication;
036        }
037    }