W3C home > Mailing lists > Public > www-validator-cvs@w3.org > September 2009

2006/unicorn/src/org/w3c/unicorn/util/mail UnicornAuthenticator.java,NONE,1.1

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 23 Sep 2009 12:56:51 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MqROt-0004Ke-Kl@lionel-hutz.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:
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;
	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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:14 GMT