package org.apache.tools.ant.taskdefs.optional.starteam;

import org.apache.tools.ant.BuildException;
import com.starbase.starteam.Server;
import com.starbase.starteam.ServerException;

/**
 * This module implements a default log on to a StarTeam server using the
 * username and password parameter of the parent StarTeamTask.
 *  
 * @author John Ballment
 *
 */
public class StarTeamDefaultLogOn implements StarTeamLogOnProvider {

	/**
	 * LogOn method uses the StarTeamTask's username and password parameters to initiate a log on to the 
	 * specified server instance.
	 * 
	 * (non-Javadoc)
	 * @see org.apache.tools.ant.taskdefs.optional.starteam.StarTeamLogOnProvider#LogOn(org.apache.tools.ant.taskdefs.optional.starteam.StarTeamTask, com.starbase.starteam.Server)
	 */
	public void LogOn(StarTeamTask task, Server server) throws BuildException {
		try {
			server.logOn(task.getUserName(), task.getPassword());
		} catch (ServerException e) {
			throw new BuildException("Unable to log onto server because " + e.getErrorMessage());
		}
	}

}
