org.eclipse.team.cvs.core_3.3.400.I20110510-0800

    for (int i = 0; i < children.length; i++) {
      if (children[i].getSeverity() == 4) {
        return true;
      }
    }
    return false;
  }
  
  public CVSServerException(IStatus status)
  {
    super(status);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.connection.CVSServerException
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.connection;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSMessages;
import org.eclipse.team.internal.ccvs.core.CVSStatus;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.IServerConnection;
import org.eclipse.team.internal.ccvs.core.Policy;

public class Connection
{
  private static final byte NEWLINE = 10;
  private IServerConnection serverConnection;
  private ICVSRepositoryLocation fCVSRoot;
  private boolean fIsEstablished;
  private InputStream fResponseStream;
  private String fServerEncoding;
  private byte[] readLineBuffer = new byte['?'];
  
  public Connection(ICVSRepositoryLocation cvsroot, IServerConnection serverConnection)
  {
    fCVSRoot = cvsroot;
    this.serverConnection = serverConnection;
    fServerEncoding = getEncoding(fCVSRoot);
  }
  
  private static byte[] append(byte[] buffer, int index, byte b)
  {
    if (index >= buffer.length)
    {
      byte[] newBuffer = new byte[index * 2];
      System.arraycopy(buffer, 0, newBuffer, 0, buffer.length);
      buffer = newBuffer;
    }
    buffer[index] = b;
    return buffer;
  }
  
  /* Error */
  public void close()
  {
    // Byte code:
    //   0: aload_0
    //   1: invokevirtual 211	org/eclipse/team/internal/ccvs/core/connection/Connection:isEstablished	()Z
    //   4: ifne +4 -> 8
    //   7: return
    //   8: aload_0
    //   9: getfield 188	org/eclipse/team/internal/ccvs/core/connection/Connection:serverConnection	Lorg/eclipse/team/internal/ccvs/core/IServerConnection;
    //   12: invokeinterface 220 1 0
    //   17: goto +57 -> 74
    //   20: astore_1
    //   21: invokestatic 203	org/eclipse/team/internal/ccvs/core/CVSProviderPlugin:getPlugin	()Lorg/eclipse/team/internal/ccvs/core/CVSProviderPlugin;
    //   24: invokevirtual 201	org/eclipse/team/internal/ccvs/core/CVSProviderPlugin:isDebugging	()Z
    //   27: ifeq +21 -> 48
    //   30: new 103	org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException
    //   33: dup
    //   34: getstatic 180	org/eclipse/team/internal/ccvs/core/CVSMessages:Connection_cannotClose	Ljava/lang/String;
    //   37: aload_0
    //   38: getfield 187	org/eclipse/team/internal/ccvs/core/connection/Connection:fCVSRoot	Lorg/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation;
    //   41: aload_1
    //   42: invokespecial 210	org/eclipse/team/internal/ccvs/core/connection/CVSCommunicationException:<init>	(Ljava/lang/String;Lorg/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation;Ljava/lang/Exception;)V
    //   45: invokestatic 202	org/eclipse/team/internal/ccvs/core/CVSProviderPlugin:log	(Lorg/eclipse/core/runtime/CoreException;)V
    //   48: aload_0
    //   49: aconst_null
    //   50: putfield 185	org/eclipse/team/internal/ccvs/core/connection/Connection:fResponseStream	Ljava/io/InputStream;
    //   53: aload_0
    //   54: iconst_0
    //   55: putfield 183	org/eclipse/team/internal/ccvs/core/connection/Connection:fIsEstablished	Z
    //   58: goto +26 -> 84
    //   61: astore_2
    //   62: aload_0
    //   63: aconst_null
    //   64: putfield 185	org/eclipse/team/internal/ccvs/core/connection/Connection:fResponseStream	Ljava/io/InputStream;
    //   67: aload_0
    //   68: iconst_0
    //   69: putfield 183	org/eclipse/team/internal/ccvs/core/connection/Connection:fIsEstablished	Z
    //   72: aload_2
    //   73: athrow
    //   74: aload_0
    //   75: aconst_null
    //   76: putfield 185	org/eclipse/team/internal/ccvs/core/connection/Connection:fResponseStream	Ljava/io/InputStream;
    //   79: aload_0
    //   80: iconst_0
    //   81: putfield 183	org/eclipse/team/internal/ccvs/core/connection/Connection:fIsEstablished	Z
    //   84: return
    // Line number table:
    //   Java source line #68	-> byte code offset #0
    //   Java source line #69	-> byte code offset #7
    //   Java source line #71	-> byte code offset #8
    //   Java source line #72	-> byte code offset #20
    //   Java source line #75	-> byte code offset #21
    //   Java source line #76	-> byte code offset #30
    //   Java source line #79	-> byte code offset #48
    //   Java source line #80	-> byte code offset #53
    //   Java source line #78	-> byte code offset #61
    //   Java source line #79	-> byte code offset #62
    //   Java source line #80	-> byte code offset #67
    //   Java source line #81	-> byte code offset #72
    //   Java source line #79	-> byte code offset #74
    //   Java source line #80	-> byte code offset #79
    //   Java source line #82	-> byte code offset #84
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	85	0	this	Connection
    //   20	22	1	ex	IOException
    //   61	12	2	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   8	17	20	java/io/IOException
    //   8	48	61	finally
  }
  
  public void flush()
    throws CVSException
  {
    if (!isEstablished()) {
      return;
    }
    try
    {
      getOutputStream().flush();
    }
    catch (IOException e)
    {
      throw new CVSCommunicationException(fCVSRoot, e);
    }
  }
  
  public OutputStream getOutputStream()
  {
    if (!isEstablished()) {
      return null;
    }
    return serverConnection.getOutputStream();
  }
  
  public InputStream getInputStream()
  {
    if (!isEstablished()) {
      return null;
    }
    if (fResponseStream == null) {
      fResponseStream = serverConnection.getInputStream();
    }
    return fResponseStream;
  }
  
  public boolean isEstablished()
  {
    return fIsEstablished;
  }
  
  public void open(IProgressMonitor monitor)
    throws CVSException
  {
    if (isEstablished()) {
      return;
    }
    try
    {
      serverConnection.open(monitor);
    }
    catch (IOException e)
    {
      throw new CVSCommunicationException(NLS.bind(CVSMessages.Connection_0, new String[] { fCVSRoot.getLocation(true), CVSCommunicationException.getMessageFor(e) }), fCVSRoot, e);
    }
    fIsEstablished = true;
  }
  
  public String readLine()
    throws CVSException
  {
    if (!isEstablished()) {
      throw new CVSCommunicationException(CVSMessages.Connection_readUnestablishedConnection, fCVSRoot, null);
    }
    try
    {
      InputStream in = getInputStream();
      int index = 0;
      int r;
      while ((r = in.read()) != -1)
      {
        int r;
        if (r == 10) {
          break;
        }
        readLineBuffer = append(readLineBuffer, index++, (byte)r);
      }
      String result = new String(readLineBuffer, 0, index, fServerEncoding);
      if (Policy.isDebugProtocol()) {
        Policy.printProtocolLine(result);
      }
      return result;
    }
    catch (IOException e)
    {
      throw new CVSCommunicationException(fCVSRoot, e);
    }
  }
  
  static String readLine(ICVSRepositoryLocation location, InputStream in)
    throws IOException
  {
    byte[] buffer = new byte['?'];
    int index = 0;
    int r;
    while ((r = in.read()) != -1)
    {
      int r;
      if (r == 10) {
        break;
      }
      buffer = append(buffer, index++, (byte)r);
    }
    String result = new String(buffer, 0, index, getEncoding(location));
    if (Policy.isDebugProtocol()) {
      Policy.printProtocolLine(result);
    }
    return result;
  }
  
  public void write(String s)
    throws CVSException
  {
    try
    {
      write(s.getBytes(fServerEncoding), false);
    }
    catch (UnsupportedEncodingException e)
    {
      IStatus status = new CVSStatus(4, -10, e.getMessage(), e, fCVSRoot);
      throw new CVSException(status);
    }
  }
  
  public static String getEncoding(ICVSRepositoryLocation location)
  {
    return location.getEncoding();
  }
  
  public void writeLine(String s)
    throws CVSException
  {
    try
    {
      write(s.getBytes(fServerEncoding), true);
    }
    catch (UnsupportedEncodingException e)
    {
      IStatus status = new CVSStatus(4, -10, e.getMessage(), e, fCVSRoot);
      throw new CVSException(status);
    }
  }
  
  void write(byte[] bytes, boolean newLine)
    throws CVSException
  {
    write(bytes, 0, bytes.length, newLine);
  }
  
  void write(byte[] b, int off, int len, boolean newline)
    throws CVSException
  {
    if (!isEstablished()) {
      throw new CVSCommunicationException(CVSMessages.Connection_writeUnestablishedConnection, fCVSRoot, null);
    }
    if (Policy.isDebugProtocol()) {
      Policy.printProtocol(new String(b, off, len), newline);
    }
    try
    {
      OutputStream out = getOutputStream();
      out.write(b, off, len);
      if (newline) {
        out.write(10);
      }
    }
    catch (IOException e)
    {
      throw new CVSCommunicationException(fCVSRoot, e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.connection.Connection
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.connection;

import java.io.InputStream;
import java.io.OutputStream;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.IServerConnection;

public class ExtConnection
  implements IServerConnection
{
  private ICVSRepositoryLocation location;
  private String password;
  InputStream inputStream;
  OutputStream outputStream;
  Process process;
  
  protected ExtConnection(ICVSRepositoryLocation location, String password)
  {
    this.location = location;
    this.password = password;
  }
  
  /* Error */
  public void close()
    throws java.io.IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 89	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:inputStream	Ljava/io/InputStream;
    //   4: ifnull +79 -> 83
    //   7: aload_0
    //   8: getfield 89	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:inputStream	Ljava/io/InputStream;
    //   11: invokevirtual 94	java/io/InputStream:close	()V
    //   14: goto +69 -> 83
    //   17: astore_1
    //   18: aload_0
    //   19: aconst_null
    //   20: putfield 89	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:inputStream	Ljava/io/InputStream;
    //   23: aload_0
    //   24: getfield 90	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:outputStream	Ljava/io/OutputStream;
    //   27: ifnull +35 -> 62
    //   30: aload_0
    //   31: getfield 90	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:outputStream	Ljava/io/OutputStream;
    //   34: invokevirtual 95	java/io/OutputStream:close	()V
    //   37: goto +25 -> 62
    //   40: astore_2
    //   41: aload_0
    //   42: aconst_null
    //   43: putfield 90	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:outputStream	Ljava/io/OutputStream;
    //   46: aload_0
    //   47: getfield 91	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:process	Ljava/lang/Process;
    //   50: ifnull +10 -> 60
    //   53: aload_0
    //   54: getfield 91	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:process	Ljava/lang/Process;
    //   57: invokevirtual 97	java/lang/Process:destroy	()V
    //   60: aload_2
    //   61: athrow
    //   62: aload_0
    //   63: aconst_null
    //   64: putfield 90	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:outputStream	Ljava/io/OutputStream;
    //   67: aload_0
    //   68: getfield 91	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:process	Ljava/lang/Process;
    //   71: ifnull +10 -> 81
    //   74: aload_0
    //   75: getfield 91	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:process	Ljava/lang/Process;
    //   78: invokevirtual 97	java/lang/Process:destroy	()V
    //   81: aload_1
    //   82: athrow
    //   83: aload_0
    //   84: aconst_null
    //   85: putfield 89	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:inputStream	Ljava/io/InputStream;
    //   88: aload_0
    //   89: getfield 90	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:outputStream	Ljava/io/OutputStream;
    //   92: ifnull +35 -> 127
    //   95: aload_0
    //   96: getfield 90	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:outputStream	Ljava/io/OutputStream;
    //   99: invokevirtual 95	java/io/OutputStream:close	()V
    //   102: goto +25 -> 127
    //   105: astore_2
    //   106: aload_0
    //   107: aconst_null
    //   108: putfield 90	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:outputStream	Ljava/io/OutputStream;
    //   111: aload_0
    //   112: getfield 91	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:process	Ljava/lang/Process;
    //   115: ifnull +10 -> 125
    //   118: aload_0
    //   119: getfield 91	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:process	Ljava/lang/Process;
    //   122: invokevirtual 97	java/lang/Process:destroy	()V
    //   125: aload_2
    //   126: athrow
    //   127: aload_0
    //   128: aconst_null
    //   129: putfield 90	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:outputStream	Ljava/io/OutputStream;
    //   132: aload_0
    //   133: getfield 91	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:process	Ljava/lang/Process;
    //   136: ifnull +10 -> 146
    //   139: aload_0
    //   140: getfield 91	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:process	Ljava/lang/Process;
    //   143: invokevirtual 97	java/lang/Process:destroy	()V
    //   146: return
    // Line number table:
    //   Java source line #58	-> byte code offset #0
    //   Java source line #59	-> byte code offset #17
    //   Java source line #60	-> byte code offset #18
    //   Java source line #62	-> byte code offset #23
    //   Java source line #63	-> byte code offset #40
    //   Java source line #64	-> byte code offset #41
    //   Java source line #65	-> byte code offset #46
    //   Java source line #66	-> byte code offset #60
    //   Java source line #64	-> byte code offset #62
    //   Java source line #65	-> byte code offset #67
    //   Java source line #67	-> byte code offset #81
    //   Java source line #60	-> byte code offset #83
    //   Java source line #62	-> byte code offset #88
    //   Java source line #63	-> byte code offset #105
    //   Java source line #64	-> byte code offset #106
    //   Java source line #65	-> byte code offset #111
    //   Java source line #66	-> byte code offset #125
    //   Java source line #64	-> byte code offset #127
    //   Java source line #65	-> byte code offset #132
    //   Java source line #68	-> byte code offset #146
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	147	0	this	ExtConnection
    //   17	65	1	localObject1	Object
    //   40	21	2	localObject2	Object
    //   105	21	2	localObject3	Object
    // Exception table:
    //   from	to	target	type
    //   0	17	17	finally
    //   23	40	40	finally
    //   88	105	105	finally
  }
  
  public InputStream getInputStream()
  {
    return inputStream;
  }
  
  public OutputStream getOutputStream()
  {
    return outputStream;
  }
  
  /* Error */
  public void open(org.eclipse.core.runtime.IProgressMonitor monitor)
    throws java.io.IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 93	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:location	Lorg/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation;
    //   4: checkcast 48	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation
    //   7: aload_0
    //   8: getfield 92	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:password	Ljava/lang/String;
    //   11: invokevirtual 100	org/eclipse/team/internal/ccvs/core/connection/CVSRepositoryLocation:getExtCommand	(Ljava/lang/String;)[Ljava/lang/String;
    //   14: astore_2
    //   15: iconst_0
    //   16: istore_3
    //   17: aload_0
    //   18: aload_2
    //   19: aload_1
    //   20: invokestatic 102	org/eclipse/team/internal/ccvs/core/util/Util:createProcess	([Ljava/lang/String;Lorg/eclipse/core/runtime/IProgressMonitor;)Ljava/lang/Process;
    //   23: putfield 91	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:process	Ljava/lang/Process;
    //   26: aload_0
    //   27: new 51	org/eclipse/team/internal/core/streams/PollingInputStream
    //   30: dup
    //   31: new 53	org/eclipse/team/internal/core/streams/TimeoutInputStream
    //   34: dup
    //   35: aload_0
    //   36: getfield 91	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:process	Ljava/lang/Process;
    //   39: invokevirtual 98	java/lang/Process:getInputStream	()Ljava/io/InputStream;
    //   42: sipush 8192
    //   45: ldc2_w 39
    //   48: ldc2_w 37
    //   51: invokespecial 105	org/eclipse/team/internal/core/streams/TimeoutInputStream:<init>	(Ljava/io/InputStream;IJJ)V
    //   54: aload_0
    //   55: getfield 93	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:location	Lorg/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation;
    //   58: invokeinterface 107 1 0
    //   63: aload_1
    //   64: invokespecial 103	org/eclipse/team/internal/core/streams/PollingInputStream:<init>	(Ljava/io/InputStream;ILorg/eclipse/core/runtime/IProgressMonitor;)V
    //   67: putfield 89	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:inputStream	Ljava/io/InputStream;
    //   70: aload_0
    //   71: new 52	org/eclipse/team/internal/core/streams/PollingOutputStream
    //   74: dup
    //   75: new 54	org/eclipse/team/internal/core/streams/TimeoutOutputStream
    //   78: dup
    //   79: aload_0
    //   80: getfield 91	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:process	Ljava/lang/Process;
    //   83: invokevirtual 99	java/lang/Process:getOutputStream	()Ljava/io/OutputStream;
    //   86: sipush 8192
    //   89: ldc2_w 39
    //   92: ldc2_w 39
    //   95: invokespecial 106	org/eclipse/team/internal/core/streams/TimeoutOutputStream:<init>	(Ljava/io/OutputStream;IJJ)V
    //   98: aload_0
    //   99: getfield 93	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:location	Lorg/eclipse/team/internal/ccvs/core/ICVSRepositoryLocation;
    //   102: invokeinterface 107 1 0
    //   107: aload_1
    //   108: invokespecial 104	org/eclipse/team/internal/core/streams/PollingOutputStream:<init>	(Ljava/io/OutputStream;ILorg/eclipse/core/runtime/IProgressMonitor;)V
    //   111: putfield 90	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:outputStream	Ljava/io/OutputStream;
    //   114: iconst_1
    //   115: istore_3
    //   116: goto +16 -> 132
    //   119: astore 4
    //   121: iload_3
    //   122: ifne +7 -> 129
    //   125: aload_0
    //   126: invokevirtual 101	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:close	()V
    //   129: aload 4
    //   131: athrow
    //   132: iload_3
    //   133: ifne +7 -> 140
    //   136: aload_0
    //   137: invokevirtual 101	org/eclipse/team/internal/ccvs/core/connection/ExtConnection:close	()V
    //   140: return
    // Line number table:
    //   Java source line #92	-> byte code offset #0
    //   Java source line #93	-> byte code offset #15
    //   Java source line #95	-> byte code offset #17
    //   Java source line #97	-> byte code offset #26
    //   Java source line #98	-> byte code offset #42
    //   Java source line #97	-> byte code offset #67
    //   Java source line #99	-> byte code offset #70
    //   Java source line #100	-> byte code offset #86
    //   Java source line #99	-> byte code offset #111
    //   Java source line #103	-> byte code offset #114
    //   Java source line #104	-> byte code offset #119
    //   Java source line #105	-> byte code offset #121
    //   Java source line #107	-> byte code offset #125
    //   Java source line #112	-> byte code offset #129
    //   Java source line #105	-> byte code offset #132
    //   Java source line #107	-> byte code offset #136
    //   Java source line #113	-> byte code offset #140
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	141	0	this	ExtConnection
    //   0	141	1	monitor	org.eclipse.core.runtime.IProgressMonitor
    //   14	5	2	command	String[]
    //   16	117	3	connected	boolean
    //   119	11	4	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   17	119	119	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.connection.ExtConnection
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.connection;

import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.IConnectionMethod;
import org.eclipse.team.internal.ccvs.core.IServerConnection;

public class ExtConnectionMethod
  implements IConnectionMethod
{
  public String getName()
  {
    return "ext";
  }
  
  public IServerConnection createConnection(ICVSRepositoryLocation repositoryRoot, String password)
  {
    if (password == null) {
      password = "";
    }
    return new ExtConnection(repositoryRoot, password);
  }
  
  public void disconnect(ICVSRepositoryLocation location) {}
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.connection.ExtConnectionMethod
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.connection;

import com.jcraft.jsch.Proxy;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.net.Socket;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jsch.core.IJSchService;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.internal.ccvs.core.CVSMessages;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.IServerConnection;
import org.eclipse.team.internal.ccvs.core.util.Util;
import org.eclipse.team.internal.core.streams.PollingInputStream;
import org.eclipse.team.internal.core.streams.PollingOutputStream;
import org.eclipse.team.internal.core.streams.TimeoutOutputStream;

public class PServerConnection
  implements IServerConnection
{
  public static final char NEWLINE = '\n';
  private static final int DEFAULT_PORT = 2401;
  private static final char ERROR_CHAR = 'E';
  private static final String ERROR_MESSAGE = "error 0";
  private static final String NO_SUCH_USER = "no such user";
  private static final char[] SCRAMBLING_TABLE = {
    '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', '\b', '\t', '\n', '\013', '\f', '\r', '\016', '\017', 
    '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', 
    'r', 'x', '5', 'O', '`', 'm', 'H', 'l', 'F', '@', 'L', 'C', 't', 'J', 'D', 'W', 
    'o', '4', 'K', 'w', '1', '"', 'R', 'Q', '_', 'A', 'p', 'V', 'v', 'n', 'z', 'i', 
    ')', '9', 'S', '+', '.', 'f', '(', 'Y', '&', 'g', '-', '2', '*', '{', '[', '#', 
    '}', '7', '6', 'B', '|', '~', ';', '/', '\\', 'G', 's', 'N', 'X', 'k', 'j', '8', 
    '$', 'y', 'u', 'h', 'e', 'd', 'E', 'I', 'c', '?', '^', ']', '\'', '%', '=', '0', 
    ':', 'q', ' ', 'Z', ',', 'b', '<', '3', '!', 'a', '>', 'M', 'T', 'P', 'U', '�', 
    '�', '�', '�', '�', '�', '�', '�', '�', '?', '�', '?', '�', '�', '?', '�', '�', 
    '�', '�', '�', '�', '?', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', '�', 
    '�', '�', '�', '�', '�', '�', '?', '�', '�', '�', '?', '�', '�', '�', '�', '�', 
    '�', '�', '�', '�', '�', '?', '�', '?', '?', '�', '�', '?', '?', '?', '?', '�', 
    '�', '?', '�', '�', '�', '�', '�', '?', '?', '�', '�', '?', '?', '�', '�', '�', 
    '�', '�', '�', '�', '�', '?', '�', '�', '?', '�', '?', '�', '?', '�', '?', '', 
    '�', '?', '?', '�', '�', '?', '�', '�', '?', '�', '?', '�', '�', '�', '�', '�', 
    '�', '�', '�', '�', '�', '�', '�', '?', '?', '?', '�', '�', '�', '�', '�', '?' };
  private static final String BEGIN = "BEGIN AUTH REQUEST";
  private static final String END = "END AUTH REQUEST";
  private static final String LOGIN_OK = "I LOVE YOU";
  private static final String LOGIN_FAILED = "I HATE YOU";
  private String password;
  private ICVSRepositoryLocation cvsroot;
  private Socket fSocket;
  private InputStream inputStream;
  private OutputStream outputStream;
  
  /* Error */
  public void close()
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 287	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:inputStream	Ljava/io/InputStream;
    //   4: ifnull +111 -> 115
    //   7: aload_0
    //   8: getfield 287	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:inputStream	Ljava/io/InputStream;
    //   11: invokevirtual 294	java/io/InputStream:close	()V
    //   14: goto +101 -> 115
    //   17: astore_1
    //   18: aload_0
    //   19: aconst_null
    //   20: putfield 287	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:inputStream	Ljava/io/InputStream;
    //   23: aload_0
    //   24: getfield 288	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:outputStream	Ljava/io/OutputStream;
    //   27: ifnull +51 -> 78
    //   30: aload_0
    //   31: getfield 288	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:outputStream	Ljava/io/OutputStream;
    //   34: invokevirtual 296	java/io/OutputStream:close	()V
    //   37: goto +41 -> 78
    //   40: astore_2
    //   41: aload_0
    //   42: aconst_null
    //   43: putfield 288	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:outputStream	Ljava/io/OutputStream;
    //   46: aload_0
    //   47: getfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   50: ifnull +21 -> 71
    //   53: aload_0
    //   54: getfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   57: invokevirtual 317	java/net/Socket:close	()V
    //   60: goto +11 -> 71
    //   63: astore_3
    //   64: aload_0
    //   65: aconst_null
    //   66: putfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   69: aload_3
    //   70: athrow
    //   71: aload_0
    //   72: aconst_null
    //   73: putfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   76: aload_2
    //   77: athrow
    //   78: aload_0
    //   79: aconst_null
    //   80: putfield 288	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:outputStream	Ljava/io/OutputStream;
    //   83: aload_0
    //   84: getfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   87: ifnull +21 -> 108
    //   90: aload_0
    //   91: getfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   94: invokevirtual 317	java/net/Socket:close	()V
    //   97: goto +11 -> 108
    //   100: astore_3
    //   101: aload_0
    //   102: aconst_null
    //   103: putfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   106: aload_3
    //   107: athrow
    //   108: aload_0
    //   109: aconst_null
    //   110: putfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   113: aload_1
    //   114: athrow
    //   115: aload_0
    //   116: aconst_null
    //   117: putfield 287	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:inputStream	Ljava/io/InputStream;
    //   120: aload_0
    //   121: getfield 288	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:outputStream	Ljava/io/OutputStream;
    //   124: ifnull +51 -> 175
    //   127: aload_0
    //   128: getfield 288	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:outputStream	Ljava/io/OutputStream;
    //   131: invokevirtual 296	java/io/OutputStream:close	()V
    //   134: goto +41 -> 175
    //   137: astore_2
    //   138: aload_0
    //   139: aconst_null
    //   140: putfield 288	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:outputStream	Ljava/io/OutputStream;
    //   143: aload_0
    //   144: getfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   147: ifnull +21 -> 168
    //   150: aload_0
    //   151: getfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   154: invokevirtual 317	java/net/Socket:close	()V
    //   157: goto +11 -> 168
    //   160: astore_3
    //   161: aload_0
    //   162: aconst_null
    //   163: putfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   166: aload_3
    //   167: athrow
    //   168: aload_0
    //   169: aconst_null
    //   170: putfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   173: aload_2
    //   174: athrow
    //   175: aload_0
    //   176: aconst_null
    //   177: putfield 288	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:outputStream	Ljava/io/OutputStream;
    //   180: aload_0
    //   181: getfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   184: ifnull +21 -> 205
    //   187: aload_0
    //   188: getfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   191: invokevirtual 317	java/net/Socket:close	()V
    //   194: goto +11 -> 205
    //   197: astore_3
    //   198: aload_0
    //   199: aconst_null
    //   200: putfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   203: aload_3
    //   204: athrow
    //   205: aload_0
    //   206: aconst_null
    //   207: putfield 290	org/eclipse/team/internal/ccvs/core/connection/PServerConnection:fSocket	Ljava/net/Socket;
    //   210: return
    // Line number table:
    //   Java source line #79	-> byte code offset #0
    //   Java source line #80	-> byte code offset #17
    //   Java source line #81	-> byte code offset #18
    //   Java source line #83	-> byte code offset #23
    //   Java source line #84	-> byte code offset #40
    //   Java source line #85	-> byte code offset #41
    //   Java source line #87	-> byte code offset #46
    //   Java source line #88	-> byte code offset #63
    //   Java source line #89	-> byte code offset #64
    //   Java source line #90	-> byte code offset #69
    //   Java source line #89	-> byte code offset #71
    //   Java source line #91	-> byte code offset #76
    //   Java source line #85	-> byte code offset #78
    //   Java source line #87	-> byte code offset #83
    //   Java source line #88	-> byte code offset #100
    //   Java source line #89	-> byte code offset #101
    //   Java source line #90	-> byte code offset #106
    //   Java source line #89	-> byte code offset #108
    //   Java source line #92	-> byte code offset #113
    //   Java source line #81	-> byte code offset #115
    //   Java source line #83	-> byte code offset #120
    //   Java source line #84	-> byte code offset #137
    //   Java source line #85	-> byte code offset #138
    //   Java source line #87	-> byte code offset #143
    //   Java source line #88	-> byte code offset #160
    //   Java source line #89	-> byte code offset #161
    //   Java source line #90	-> byte code offset #166
    //   Java source line #89	-> byte code offset #168
    //   Java source line #91	-> byte code offset #173
    //   Java source line #85	-> byte code offset #175
    //   Java source line #87	-> byte code offset #180
    //   Java source line #88	-> byte code offset #197
    //   Java source line #89	-> byte code offset #198
    //   Java source line #90	-> byte code offset #203
    //   Java source line #89	-> byte code offset #205
    //   Java source line #93	-> byte code offset #210
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	211	0	this	PServerConnection
    //   17	97	1	localObject1	Object
    //   40	37	2	localObject2	Object
    //   137	37	2	localObject3	Object
    //   63	7	3	localObject4	Object
    //   100	7	3	localObject5	Object
    //   160	7	3	localObject6	Object
    //   197	7	3	localObject7	Object
    // Exception table:
    //   from	to	target	type
    //   0	17	17	finally
    //   23	40	40	finally
    //   46	63	63	finally
    //   83	100	100	finally
    //   120	137	137	finally
    //   143	160	160	finally
    //   180	197	197	finally
  }
  
  public void open(IProgressMonitor monitor)
    throws IOException, CVSAuthenticationException
  {
    monitor.subTask(CVSMessages.PServerConnection_authenticating);
    monitor.worked(1);
    
    InputStream is = null;
    OutputStream os = null;
    
    Proxy proxy = getProxy();
    if (proxy != null)
    {
      String host = cvsroot.getHost();
      port = cvsroot.getPort();
      if (port == 0) {
        port = 2401;
      }
      try
      {
        int timeout = CVSProviderPlugin.getPlugin().getTimeout() * 1000;
        IJSchService service = CVSProviderPlugin.getPlugin().getJSchService();
        service.connect(proxy, host, port, timeout, monitor);
      }
      catch (Exception ex)
      {
        ex.printStackTrace();
        throw new IOException(ex.getMessage());
      }
      is = proxy.getInputStream();
      os = proxy.getOutputStream();
    }
    else
    {
      fSocket = createSocket(monitor);
      is = fSocket.getInputStream();
      os = fSocket.getOutputStream();
    }
    boolean connected = false;
    try
    {
      inputStream = new BufferedInputStream(new PollingInputStream(is, 
        cvsroot.getTimeout(), monitor));
      outputStream = new PollingOutputStream(new TimeoutOutputStream(
        os, 8192, 1000L, 1000L), 
        cvsroot.getTimeout(), monitor);
      authenticate();
      connected = true;
    }
    finally
    {
      if (!connected) {
        close();
      }
    }
  }
  
  private Proxy getProxy()
  {
    IJSchService service = CVSProviderPlugin.getPlugin().getJSchService();
    if (service == null) {
      return null;
    }
    Proxy proxy = service.getProxyForHost(cvsroot.getHost(), "SOCKS");
    if (proxy == null) {
      proxy = service.getProxyForHost(cvsroot.getHost(), "HTTPS");
    }
    return proxy;
  }
  
  public InputStream getInputStream()
  {
    return inputStream;
  }
  
  public OutputStream getOutputStream()
  {
    return outputStream;
  }
  
  PServerConnection(ICVSRepositoryLocation cvsroot, String password)
  {
    this.cvsroot = cvsroot;
    this.password = password;
  }
  
  private void authenticate()
    throws IOException, CVSAuthenticationException
  {
    String scrambledPassword = scramblePassword(password);
    
    String user = cvsroot.getUsername();
    OutputStream out = getOutputStream();
    
    StringBuffer request = new StringBuffer();
    request.append("BEGIN AUTH REQUEST");
    request.append('\n');
    request.append(cvsroot.getRootDirectory());
    request.append('\n');
    request.append(user);
    request.append('\n');
    request.append(scrambledPassword);
    request.append('\n');
    request.append("END AUTH REQUEST");
    request.append('\n');
    out.write(request.toString().getBytes());
    out.flush();
    String line = Connection.readLine(cvsroot, getInputStream()).trim();
    if ("I LOVE YOU".equals(line)) {
      return;
    }
    if (line.length() == 0) {
      throw new IOException(CVSMessages.PServerConnection_noResponse);
    }
    String message = "";
    String separator = "";
    if (!CVSProviderPlugin.getPlugin().isUseProxy()) {
      do
      {
        if (line.length() > 2)
        {
          message = message + separator + line.substring(2);
          separator = " ";
        }
        line = Connection.readLine(cvsroot, getInputStream());
        if (line.length() <= 0) {
          break;
        }
      } while (line.charAt(0) == 'E');
    } else {
      while (line.length() > 0)
      {
        message = message + separator + line;
        separator = "\n";
        line = Connection.readLine(cvsroot, getInputStream());
      }
    }
    if ("I HATE YOU".equals(line))
    {
      if (message.length() == 0) {
        throw new CVSAuthenticationException(CVSMessages.PServerConnection_loginRefused, 1, cvsroot);
      }
      throw new CVSAuthenticationException(message, 1, cvsroot);
    }
    if (line.startsWith("error 0")) {
      message = message + separator + line.substring("error 0".length() + 1);
    } else {
      message = message + separator + line;
    }
    if (message.indexOf("no such user") != -1) {
      throw new CVSAuthenticationException(NLS.bind(CVSMessages.PServerConnection_invalidUser, new Object[] { message }), 1, cvsroot);
    }
    throw new IOException(NLS.bind(CVSMessages.PServerConnection_connectionRefused, new Object[] { message }));
  }
  
  protected Socket createSocket(IProgressMonitor monitor)
    throws IOException
  {
    int port = cvsroot.getPort();
    if (port == 0) {
      port = 2401;
    }
    try
    {
      Socket result = Util.createSocket(cvsroot.getHost(), port, monitor);
      
      result.setTcpNoDelay(true);
    }
    catch (InterruptedIOException localInterruptedIOException)
    {
      throw new InterruptedIOException(NLS.bind(CVSMessages.PServerConnection_socket, new Object[] { cvsroot.getHost() }));
    }
    Socket result;
    result.setSoTimeout(1000);
    return result;
  }
  
  private String scramblePassword(String password)
    throws CVSAuthenticationException
  {
    int length = password.length();
    char[] out = new char[length];
    for (int i = 0; i < length; i++)
    {
      char value = password.charAt(i);
      if ((value < 0) || (value > '�')) {
        throwInValidCharacter();
      }
      out[i] = SCRAMBLING_TABLE[value];
    }
    return "A" + new String(out);
  }
  
  private void throwInValidCharacter()
    throws CVSAuthenticationException
  {
    throw new CVSAuthenticationException(CVSMessages.PServerConnection_invalidChars, 1, cvsroot);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.connection.PServerConnection
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ccvs.core.connection;

import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.IConnectionMethod;
import org.eclipse.team.internal.ccvs.core.IServerConnection;

public class PServerConnectionMethod
  implements IConnectionMethod
{
  public IServerConnection createConnection(ICVSRepositoryLocation location, String password)
  {
    if (password == null) {
      password = "";
    }
    return new PServerConnection(location, password);
  }
  
  public String getName()
  {
    return "pserver";
  }
  
  public void disconnect(ICVSRepositoryLocation location) {}
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ccvs.core.connection.PServerConnectionMethod
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd