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