/** * Copyright (c) 2005 UPS_SCS NL * */ package org.wamblee.crawler.kiss.notification; import javax.mail.Authenticator; import javax.mail.PasswordAuthentication; /** * Authenticator to supply username and password to the mail server (if needed). * */ public class UsernamePasswordAuthenticator extends Authenticator { private String _username; private String _password; /** * Constructs the authenticator. * * @param aUsername * User name. * @param aPassword * Password. */ public UsernamePasswordAuthenticator(String aUsername, String aPassword) { _username = aUsername; _password = aPassword; } /* * (non-Javadoc) * * @see javax.mail.Authenticator#getPasswordAuthentication() */ @Override protected PasswordAuthentication getPasswordAuthentication() { if (_username == null) { return null; } return new PasswordAuthentication(_username, _password); } }