KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > businessUtility > EMailAuthenticator


1 /*
2  ******************************************************************************
3  * The contents of this file are subject to the Compiere License Version 1.1
4  * ("License"); You may not use this file except in compliance with the License
5  * You may obtain a copy of the License at http://www.compiere.org/license.html
6  * Software distributed under the License is distributed on an "AS IS" basis,
7  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
8  * the specific language governing rights and limitations under the License.
9  * The Original Code is Compiere ERP & CRM Business Solution
10  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
11  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
12  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
13  * Contributor(s): Openbravo SL
14  * Contributions are Copyright (C) 2001-2006 Openbravo S.L.
15  ******************************************************************************
16 */

17 package org.openbravo.erpCommon.businessUtility;
18
19 import javax.mail.Authenticator JavaDoc;
20 import javax.mail.PasswordAuthentication JavaDoc;
21 import org.apache.log4j.Logger ;
22
23 public class EMailAuthenticator extends Authenticator JavaDoc {
24   static Logger log4j = Logger.getLogger(EMailAuthenticator.class);
25
26   private PasswordAuthentication JavaDoc m_pass;
27
28   public EMailAuthenticator(String JavaDoc username, String JavaDoc password) {
29     m_pass = new PasswordAuthentication JavaDoc(username, password);
30     if(username == null || username.length() == 0) {
31       log4j.error("EMailAuthenticator - Username is NULL");
32       Thread.dumpStack();
33     }
34     if(password == null || password.length() == 0) {
35       log4j.error("EMailAuthenticator - Password is NULL");
36       Thread.dumpStack();
37     }
38   }
39
40   protected PasswordAuthentication JavaDoc getPasswordAuthentication() {
41     return m_pass;
42   }
43
44   public String JavaDoc toString() {
45     if(m_pass == null)
46       return "EMailAuthenticator[]";
47     else
48       return "EMailAuthenticator[" + m_pass.getUserName() + "/" + m_pass.getPassword() + "]";
49   }
50 }
51
Popular Tags