KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > toolagent > SmtpAuthenticator


1 package org.enhydra.shark.toolagent;
2
3 import javax.mail.PasswordAuthentication JavaDoc;
4 import javax.mail.Authenticator JavaDoc;
5
6 /** The class Authenticator represents an object that knows how to obtain authentication
7  * for a network connection.
8  * Applications use this class by creating a subclass, and registering an instance of that
9  * 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 JavaDoc {
17
18    String JavaDoc pass = "";
19    String JavaDoc login = "";
20
21    public SmtpAuthenticator() {
22       super();
23    }
24
25    public SmtpAuthenticator(String JavaDoc login, String JavaDoc pass) {
26       super();
27       this.login = login;
28       this.pass = pass;
29    }
30
31    public PasswordAuthentication JavaDoc getPasswordAuthentication() {
32       if (pass.equals(""))
33          return null;
34       else
35          return new PasswordAuthentication JavaDoc(login, pass);
36    }
37
38 }
39
Popular Tags