01: package email;
02:
03: import javax.mail.PasswordAuthentication;
04: import javax.mail.Authenticator;
05:
06: /** The class Authenticator represents an object that knows how to obtain authentication
07: * for a network connection.
08: * Applications use this class by creating a subclass, and registering an instance of that
09: * subclass with the system with setDefault(). When authentication is required, the system
10: * will invoke a method on the subclass (like getPasswordAuthentication)
11: *
12: * @author Paloma Trigueros Cabezon
13: * @version 1.0
14: */
15:
16: public class SmtpAuthenticator extends javax.mail.Authenticator {
17:
18: String pass = "";
19: String login = "";
20:
21: public SmtpAuthenticator() {
22: super ();
23: }
24:
25: public SmtpAuthenticator(String login, String pass) {
26: super ();
27:
28: this .login = login;
29: this .pass = pass;
30: }
31:
32: public PasswordAuthentication getPasswordAuthentication() {
33: if (pass.equals(""))
34: return null;
35: else
36: return new PasswordAuthentication(login, pass);
37: }
38:
39: }
|