(no commit message)
[utils] / crawler / kiss / src / org / wamblee / crawler / kiss / UsernamePasswordAuthenticator.java
1 /**
2  * Copyright (c) 2005 UPS_SCS NL
3  *  
4  */
5 package org.wamblee.crawler.kiss;
6
7 import javax.mail.Authenticator;
8 import javax.mail.PasswordAuthentication;
9
10 /**
11  * Authenticator to supply username and password to the mail server
12  * (if needed).
13  *
14  */
15 public class UsernamePasswordAuthenticator extends Authenticator {
16     
17     private String _username; 
18     private String _password; 
19
20     /**
21      * Constructs the authenticator.
22      * @param aUsername User name. 
23      * @param aPassword Password.
24      */
25     public UsernamePasswordAuthenticator(String aUsername, String aPassword) { 
26         _username = aUsername; 
27         _password = aPassword; 
28     }
29     
30     /*
31      *  (non-Javadoc)
32      * @see javax.mail.Authenticator#getPasswordAuthentication()
33      */
34     @Override
35     protected PasswordAuthentication getPasswordAuthentication( ) {
36         if ( _username == null ) { 
37             return null; 
38         }
39         return new PasswordAuthentication(_username, _password);
40     }
41 }