- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Wed, 23 Sep 2009 12:56:51 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/util/mail In directory hutz:/tmp/cvs-serv16630/src/org/w3c/unicorn/util/mail Added Files: UnicornAuthenticator.java Log Message: Authenticator that manage smtp username and password --- NEW FILE: UnicornAuthenticator.java --- package org.w3c.unicorn.util.mail; import java.awt.HeadlessException; import java.util.StringTokenizer; import javax.mail.Authenticator; import javax.mail.PasswordAuthentication; import javax.swing.JOptionPane; import org.w3c.unicorn.Framework; public class UnicornAuthenticator extends Authenticator { String username; String password; public UnicornAuthenticator(String username, String password) { this.username = username; this.password = password; } @Override protected PasswordAuthentication getPasswordAuthentication() { try { if (username == null && password == null) { String result = JOptionPane.showInputDialog("Enter 'username,password' for your SMTP Server. This is asked only once. You can also set the username and password in mail.properties"); StringTokenizer st = new StringTokenizer(result, ","); username = st.nextToken(); password = st.nextToken(); } } catch (HeadlessException e) { Framework.logger.error("Before sending mails you must specify a username and a password in mail.properties. If your SMTP server does not need authentication, set mail.smtp.auth to false."); } return new PasswordAuthentication(username, password); } }
Received on Wednesday, 23 September 2009 12:57:00 UTC