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

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

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 23 Sep 2009 14:09:41 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MqSXN-0003gT-Nq@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/util
In directory hutz:/tmp/cvs-serv14128/src/org/w3c/unicorn/util

Added Files:
Log Message:
moved UnicornAuthenticator out of the mail directory

--- NEW FILE: UnicornAuthenticator.java ---
package org.w3c.unicorn.util;

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 14:09:51 GMT

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