public void MakeConnection_Good() { LOGGER.Debug("Entering MakeConnection_Good"); CvsRoot root = new CvsRoot(this.Settings.Config.Cvsroot); WorkingDirectory working = new WorkingDirectory(root, this.Settings.Config.LocalPath, this.Settings.Config.Module); CVSServerConnection connection = new CVSServerConnection(); Assert.IsNotNull(connection, "Should have a connection object. WorkingDirectory=[" + working + "]"); try { connection.Connect(working, this.Settings.Config.ValidPassword); } catch (Exception e) { Assert.Fail(e.ToString() + "; WorkingDirectory=[" + working + "]"); } connection.Close(); }
public void MakeConnection_Bad() { CvsRoot root = new CvsRoot(this.Settings.Config.Cvsroot); root.User = "******"; WorkingDirectory working = new WorkingDirectory(root, this.Settings.Config.LocalPath, this.Settings.Config.Module); CVSServerConnection connection = new CVSServerConnection(); Assert.IsNotNull(connection, "Should have a connection object."); try { connection.Connect(working, this.Settings.Config.InvalidPassword); } catch (AuthenticationException e) { connection.Close(); throw e; } }
public IExternalSource Checkout(string cvsroot, string module, string password, out string target) { //Set temp checkout dir target = System.IO.Path.Combine(Globals.TempDirectory, Guid.NewGuid().ToString()); Directory.CreateDirectory(target); //Setup CVS vars CvsRoot root = new CvsRoot(cvsroot); WorkingDirectory working = new WorkingDirectory(root, target, module); CVSServerConnection connection = new CVSServerConnection(); if (connection == null) throw new ToolExecutionException("Unable to connect to the CVS server"); //Connect to CVS ICSharpCode.SharpCvsLib.Commands.ICommand command = new CheckoutModuleCommand(working); if (command == null) throw new ToolExecutionException("Failure to create a checkout command object"); try { connection.Connect(working, password); } catch (AuthenticationException) { throw new ToolExecutionException("CVS rejected access (doublecheck all fields): Authentication failure"); } catch (Exception er) { throw new ToolExecutionException("CVS rejected access (doublecheck all fields): " + er.Message); } //Execute checkout command try { command.Execute(connection); connection.Close(); } catch (Exception er) { throw new ToolExecutionException("CVS error: " + er.Message); } //Create source from module root return CreateSource(Path.Combine(target, module)); }
private void DoExecute() { string[] args = this._args; CommandLineParser parser = new CommandLineParser (args); ICommand command = null; try { command = parser.Execute (); } catch (CommandLineParseException e) { Writer.WriteLine( String.Format("{0}{1}{2}", Usage.General, Environment.NewLine, e.Message)); return; } catch (Exception e) { ExitProgram("Exception parsing command.", e); } if (null != command) { // might need to move this up to the library, make working // directory a public property?? Not sure. WorkingDirectory workingDirectory = parser.CurrentWorkingDirectory; string password = this.GetPassword(parser, workingDirectory); // Create CVSServerConnection object that has the ICommandConnection CVSServerConnection serverConn = new CVSServerConnection(workingDirectory); if (parser.Verbose) { serverConn.RequestMessageEvent += new MessageEventHandler(Writer.WriteLine); serverConn.ResponseMessageEvent += new MessageEventHandler(Writer.WriteLine); } serverConn.StartProcessEvent += new ProcessEventHandler(Writer.StartProcess); serverConn.StopProcessEvent += new ProcessEventHandler(Writer.StopProcess); serverConn.ResponseMessageEvents.UpdatedResponseMessageEvent += new MessageEventHandler(Writer.WriteLine); serverConn.ResponseMessageEvents.ClearStaticDirectoryResponseMessageEvent += new MessageEventHandler(Writer.WriteLine); serverConn.ResponseMessageEvents.SetStaticDirectoryResponseMessageEvent += new MessageEventHandler(Writer.WriteLine); serverConn.ResponseMessageEvents.ErrorResponseMessageEvent += new MessageEventHandler(Writer.WriteError); serverConn.ResponseMessageEvents.ListResponseMessageEvent += new MessageEventHandler(Writer.WriteLine); if (null == serverConn) { string msg = "Unable to connect to server."; ExitProgram(msg); } try{ // try connecting with empty password for anonymous users serverConn.Connect(workingDirectory, password); } catch (AuthenticationException e){ string msg = String.Format("Fatal error, aborting. cvs [login aborted]: {0}: unknown user or bad password.", workingDirectory.CvsRoot.User); ExitProgram(msg, e); } catch (Exception ex) { string msg = String.Format("Fatal cvs error ( {0} ).", ex.Message); ExitProgram(msg, ex); } // Execute the command on cvs repository. command.Execute(serverConn); serverConn.Close(); } }