![]() |
![]() |
org.eclipse.team.cvs.ssh2_3.2.300.I20110511-080016:47:56.160 INFO jd.cli.Main - Decompiling org.eclipse.team.cvs.ssh2_3.2.300.I20110511-0800.jar package org.eclipse.team.internal.ccvs.ssh2; import org.eclipse.osgi.util.NLS; public class CVSSSH2Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.team.internal.ccvs.ssh2.messages"; public static String JSchSession_3; public static String JSchSession_4; public static String JSchSession_5; public static String CVSSSH2ServerConnection_open; public static String CVSSSH2PreferencePage_18; public static String CVSSSH2PreferencePage_19; public static String CVSSSH2PreferencePage_20; public static String CVSSSH2PreferencePage_21; public static String CVSSSH2PreferencePage_23; public static String CVSSSH2PreferencePage_24; public static String CVSSSH2PreferencePage_25; public static String CVSSSH2PreferencePage_26; public static String CVSSSH2PreferencePage_27; public static String CVSSSH2PreferencePage_30; public static String CVSSSH2PreferencePage_31; public static String CVSSSH2PreferencePage_32; public static String CVSSSH2PreferencePage_33; public static String CVSSSH2PreferencePage_34; public static String CVSSSH2PreferencePage_35; public static String CVSSSH2PreferencePage_36; public static String CVSSSH2PreferencePage_39; public static String CVSSSH2PreferencePage_41; public static String CVSSSH2PreferencePage_42; public static String CVSSSH2PreferencePage_43; public static String CVSSSH2PreferencePage_44; public static String CVSSSH2PreferencePage_45; public static String CVSSSH2PreferencePage_47; public static String CVSSSH2PreferencePage_48; public static String CVSSSH2PreferencePage_49; public static String CVSSSH2PreferencePage_50; public static String CVSSSH2PreferencePage_53; public static String CVSSSH2PreferencePage_55; public static String CVSSSH2PreferencePage_57; public static String CVSSSH2PreferencePage_59; public static String CVSSSH2PreferencePage_99; public static String CVSSSH2PreferencePage_100; public static String CVSSSH2PreferencePage_104; public static String CVSSSH2PreferencePage_105; public static String CVSSSH2PreferencePage_106; public static String CVSSSH2PreferencePage_107; public static String CVSSSH2PreferencePage_108; public static String CVSSSH2PreferencePage_109; public static String CVSSSH2PreferencePage_110; public static String CVSSSH2PreferencePage_111; public static String CVSSSH2ServerConnection_3; public static String CVSSSH2ServerConnection_0; public static String CVSSSH2ServerConnection_1; public static String CVSSSH2ServerConnection_4; public static String CVSSSH2PreferencePage_information; public static String CVSSSH2PreferencePage_error; public static String CVSSSH2PreferencePage_confirmation; public static String CVSSSH2PreferencePage_question; public static String CVSSSH2PreferencePage_125; public static String CVSSSH2PreferencePage_126; public static String CVSSSH2PreferencePage_127; public static String CVSSSH2PreferencePage_128; public static String CVSSSH2PreferencePage_129; public static String CVSSSH2PreferencePage_130; public static String CVSSSH2PreferencePage_131; public static String CVSSSH2PreferencePage_132; public static String CVSSSH2PreferencePage_133; public static String CVSSSH2PreferencePage_134; public static String CVSSSH2PreferencePage_135; public static String CVSSSH2PreferencePage_136; public static String CVSSSH2PreferencePage_138; public static String CVSSSH2PreferencePage_139; static { NLS.initializeMessages("org.eclipse.team.internal.ccvs.ssh2.messages", CVSSSH2Messages.class); } } /* Location: * Qualified Name: org.eclipse.team.internal.ccvs.ssh2.CVSSSH2Messages * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ccvs.ssh2; 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 CVSSSH2Method implements IConnectionMethod { public String getName() { return "extssh"; } public IServerConnection createConnection(ICVSRepositoryLocation root, String password) { return new CVSSSH2ServerConnection(root, password); } public void disconnect(ICVSRepositoryLocation location) {} } /* Location: * Qualified Name: org.eclipse.team.internal.ccvs.ssh2.CVSSSH2Method * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ccvs.ssh2; import org.eclipse.core.runtime.Plugin; import org.eclipse.jsch.core.IJSchService; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.util.tracker.ServiceTracker; public class CVSSSH2Plugin extends Plugin { public static String ID = "org.eclipse.team.cvs.ssh2"; private static CVSSSH2Plugin plugin; private ServiceTracker tracker; public CVSSSH2Plugin() { plugin = this; } /* Error */ public void stop(BundleContext context) throws Exception { // Byte code: // 0: invokestatic 95 org/eclipse/team/internal/ccvs/ssh2/JSchSession:shutdown ()V // 3: aload_0 // 4: getfield 86 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2Plugin:tracker Lorg/osgi/util/tracker/ServiceTracker; // 7: invokevirtual 96 org/osgi/util/tracker/ServiceTracker:close ()V // 10: goto +11 -> 21 // 13: astore_2 // 14: aload_0 // 15: aload_1 // 16: invokespecial 93 org/eclipse/core/runtime/Plugin:stop (Lorg/osgi/framework/BundleContext;)V // 19: aload_2 // 20: athrow // 21: aload_0 // 22: aload_1 // 23: invokespecial 93 org/eclipse/core/runtime/Plugin:stop (Lorg/osgi/framework/BundleContext;)V // 26: return // Line number table: // Java source line #33 -> byte code offset #0 // Java source line #34 -> byte code offset #3 // Java source line #35 -> byte code offset #13 // Java source line #36 -> byte code offset #14 // Java source line #37 -> byte code offset #19 // Java source line #36 -> byte code offset #21 // Java source line #38 -> byte code offset #26 // Local variable table: // start length slot name signature // 0 27 0 this CVSSSH2Plugin // 0 27 1 context BundleContext // 13 7 2 localObject Object // Exception table: // from to target type // 0 13 13 finally } public static CVSSSH2Plugin getDefault() { return plugin; } public void start(BundleContext context) throws Exception { super.start(context); tracker = new ServiceTracker(getBundle().getBundleContext(), IJSchService.class.getName(), null); tracker.open(); } public IJSchService getJSchService() { return (IJSchService)tracker.getService(); } } /* Location: * Qualified Name: org.eclipse.team.internal.ccvs.ssh2.CVSSSH2Plugin * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ccvs.ssh2; import java.io.FilterInputStream; import java.io.InputStream; class CVSSSH2ServerConnection$1 extends FilterInputStream { final CVSSSH2ServerConnection this$0; CVSSSH2ServerConnection$1(CVSSSH2ServerConnection paramCVSSSH2ServerConnection, InputStream $anonymous0) { super($anonymous0);this$0 = paramCVSSSH2ServerConnection; } public void close() {} } /* Location: * Qualified Name: org.eclipse.team.internal.ccvs.ssh2.CVSSSH2ServerConnection.1 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ccvs.ssh2; import java.io.FilterOutputStream; import java.io.OutputStream; class CVSSSH2ServerConnection$2 extends FilterOutputStream { final CVSSSH2ServerConnection this$0; CVSSSH2ServerConnection$2(CVSSSH2ServerConnection paramCVSSSH2ServerConnection, OutputStream $anonymous0) { super($anonymous0);this$0 = paramCVSSSH2ServerConnection; } public void close() {} } /* Location: * Qualified Name: org.eclipse.team.internal.ccvs.ssh2.CVSSSH2ServerConnection.2 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ccvs.ssh2; import com.jcraft.jsch.JSchException; import java.io.IOException; final class CVSSSH2ServerConnection$SSH2IOException extends IOException { private static final long serialVersionUID = 1L; private final JSchException e; final CVSSSH2ServerConnection this$0; CVSSSH2ServerConnection$SSH2IOException(CVSSSH2ServerConnection paramCVSSSH2ServerConnection, String s, JSchException e) { super(s);this$0 = paramCVSSSH2ServerConnection; this.e = e; } public Throwable getCause() { return e; } } /* Location: * Qualified Name: org.eclipse.team.internal.ccvs.ssh2.CVSSSH2ServerConnection.SSH2IOException * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ccvs.ssh2; import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; import java.io.FilterInputStream; import java.io.FilterOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.net.NoRouteToHostException; import java.net.UnknownHostException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.osgi.util.NLS; import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; import org.eclipse.team.internal.ccvs.core.IServerConnection; import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException; import org.eclipse.team.internal.core.streams.PollingInputStream; import org.eclipse.team.internal.core.streams.PollingOutputStream; import org.eclipse.team.internal.core.streams.TimeoutInputStream; import org.eclipse.team.internal.core.streams.TimeoutOutputStream; public class CVSSSH2ServerConnection implements IServerConnection { private static final String SSH1_COMPATIBILITY_CLASS = "org.eclipse.team.internal.ccvs.ssh.SSHServerConnection"; private static final String COMMAND = "cvs server"; private ICVSRepositoryLocation location; private String password; private InputStream inputStream; private OutputStream outputStream; private JSchSession session; private Channel channel; private IServerConnection ssh1; private final class SSH2IOException extends IOException { private static final long serialVersionUID = 1L; private final JSchException e; SSH2IOException(String s, JSchException e) { super(); this.e = e; } public Throwable getCause() { return e; } } protected CVSSSH2ServerConnection(ICVSRepositoryLocation location, String password) { this.location = location; this.password = password; } /* Error */ public void close() throws IOException { // Byte code: // 0: aload_0 // 1: getfield 293 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:ssh1 Lorg/eclipse/team/internal/ccvs/core/IServerConnection; // 4: ifnull +18 -> 22 // 7: aload_0 // 8: getfield 293 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:ssh1 Lorg/eclipse/team/internal/ccvs/core/IServerConnection; // 11: invokeinterface 352 1 0 // 16: aload_0 // 17: aconst_null // 18: putfield 293 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:ssh1 Lorg/eclipse/team/internal/ccvs/core/IServerConnection; // 21: return // 22: aload_0 // 23: getfield 287 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:inputStream Ljava/io/InputStream; // 26: ifnull +72 -> 98 // 29: aload_0 // 30: getfield 287 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:inputStream Ljava/io/InputStream; // 33: invokevirtual 304 java/io/InputStream:close ()V // 36: goto +62 -> 98 // 39: pop // 40: goto +58 -> 98 // 43: astore_1 // 44: aload_0 // 45: getfield 288 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:outputStream Ljava/io/OutputStream; // 48: ifnull +34 -> 82 // 51: aload_0 // 52: getfield 288 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:outputStream Ljava/io/OutputStream; // 55: invokevirtual 305 java/io/OutputStream:close ()V // 58: goto +24 -> 82 // 61: pop // 62: goto +20 -> 82 // 65: astore_2 // 66: aload_0 // 67: getfield 286 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:channel Lcom/jcraft/jsch/Channel; // 70: ifnull +10 -> 80 // 73: aload_0 // 74: getfield 286 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:channel Lcom/jcraft/jsch/Channel; // 77: invokevirtual 297 com/jcraft/jsch/Channel:disconnect ()V // 80: aload_2 // 81: athrow // 82: aload_0 // 83: getfield 286 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:channel Lcom/jcraft/jsch/Channel; // 86: ifnull +10 -> 96 // 89: aload_0 // 90: getfield 286 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:channel Lcom/jcraft/jsch/Channel; // 93: invokevirtual 297 com/jcraft/jsch/Channel:disconnect ()V // 96: aload_1 // 97: athrow // 98: aload_0 // 99: getfield 288 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:outputStream Ljava/io/OutputStream; // 102: ifnull +34 -> 136 // 105: aload_0 // 106: getfield 288 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:outputStream Ljava/io/OutputStream; // 109: invokevirtual 305 java/io/OutputStream:close ()V // 112: goto +24 -> 136 // 115: pop // 116: goto +20 -> 136 // 119: astore_2 // 120: aload_0 // 121: getfield 286 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:channel Lcom/jcraft/jsch/Channel; // 124: ifnull +10 -> 134 // 127: aload_0 // 128: getfield 286 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:channel Lcom/jcraft/jsch/Channel; // 131: invokevirtual 297 com/jcraft/jsch/Channel:disconnect ()V // 134: aload_2 // 135: athrow // 136: aload_0 // 137: getfield 286 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:channel Lcom/jcraft/jsch/Channel; // 140: ifnull +10 -> 150 // 143: aload_0 // 144: getfield 286 org/eclipse/team/internal/ccvs/ssh2/CVSSSH2ServerConnection:channel Lcom/jcraft/jsch/Channel; // 147: invokevirtual 297 com/jcraft/jsch/Channel:disconnect ()V // 150: return // Line number table: // Java source line #72 -> byte code offset #0 // Java source line #73 -> byte code offset #7 // Java source line #74 -> byte code offset #16 // Java source line #75 -> byte code offset #21 // Java source line #78 -> byte code offset #22 // Java source line #80 -> byte code offset #29 // Java source line #81 -> byte code offset #39 // Java source line #85 -> byte code offset #43 // Java source line #87 -> byte code offset #44 // Java source line #89 -> byte code offset #51 // Java source line #90 -> byte code offset #61 // Java source line #94 -> byte code offset #65 // Java source line #95 -> byte code offset #66 // Java source line #96 -> byte code offset #73 // Java source line #97 -> byte code offset #80 // Java source line #95 -> byte code offset #82 // Java source line #96 -> byte code offset #89 // Java source line #98 -> byte code offset #96 // Java source line #87 -> byte code offset #98 // Java source line #89 -> byte code offset #105 // Java source line #90 -> byte code offset #115 // Java source line #94 -> byte code offset #119 // Java source line #95 -> byte code offset #120 // Java source line #96 -> byte code offset #127 // Java source line #97 -> byte code offset #134 // Java source line #95 -> byte code offset #136 // Java source line #96 -> byte code offset #143 // Java source line #99 -> byte code offset #150 // Local variable table: // start length slot name signature // 0 151 0 this CVSSSH2ServerConnection // 43 54 1 localObject1 Object // 65 16 2 localObject2 Object // 119 16 2 localObject3 Object // 39 1 4 localIOException1 IOException // 61 1 5 localIOException2 IOException // 115 1 6 localIOException3 IOException // Exception table: // from to target type // 29 36 39 java/io/IOException // 22 43 43 finally // 51 58 61 java/io/IOException // 44 65 65 finally // 105 112 115 java/io/IOException // 98 119 119 finally } public InputStream getInputStream() { if (ssh1 != null) { return ssh1.getInputStream(); } return inputStream; } public OutputStream getOutputStream() { if (ssh1 != null) { return ssh1.getOutputStream(); } return outputStream; } public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException { if (ssh1 != null) { ssh1.open(monitor); return; } monitor.subTask(NLS.bind(CVSSSH2Messages.CVSSSH2ServerConnection_open, new String[] { location.getHost() })); monitor.worked(1); internalOpen(monitor); } private void internalOpen(IProgressMonitor monitor) throws IOException, CVSAuthenticationException { try { OutputStream channel_out = null; InputStream channel_in = null; boolean firstTime = true; boolean tryAgain = false; while ((firstTime) || (tryAgain)) { tryAgain = false; session = JSchSession.getSession(location, location.getUsername(), password, location.getHost(), location.getPort(), monitor); channel = session.getSession().openChannel("exec"); ((ChannelExec)channel).setCommand("cvs server"); channel_out = channel.getOutputStream(); channel_in = channel.getInputStream(); try { channel.connect(); } catch (JSchException ee) { try { if ((firstTime) && ((isSessionDownError(ee)) || (isChannelNotOpenError(ee)))) { tryAgain = true; } if (!tryAgain) { throw ee; } } finally { session.dispose(); } session.dispose(); } firstTime = false; } int timeout = location.getTimeout(); inputStream = new PollingInputStream(new TimeoutInputStream(new FilterInputStream(channel_in) { public void close() {} }, 8192, timeout > 0 ? 1000 : 0, -1L, true), timeout > 0 ? timeout : 1, monitor); outputStream = new PollingOutputStream(new TimeoutOutputStream(new FilterOutputStream(channel_out) { public void close() {} }, 8192, timeout > 0 ? 1000 : 0, timeout > 0 ? 1000 : 0), timeout > 0 ? timeout : 1, monitor); } catch (JSchException e) { if (isSSH2Unsupported(e)) { ssh1 = createSSH1Connection(); if (ssh1 == null) { throw new SSH2IOException( CVSSSH2Messages.CVSSSH2ServerConnection_4, e); } ssh1.open(monitor); } else { String message = e.getMessage(); if (JSchSession.isAuthenticationFailure(e)) { throw new CVSAuthenticationException(CVSSSH2Messages.CVSSSH2ServerConnection_0, 2, location, e); } if (message.startsWith("Session.connect: ")) { int start = message.indexOf(": ") + 1; if (start != -1) { int end = message.indexOf(": ", start); if (end != -1) { String exception = message.substring(start, end).trim(); if (exception.indexOf("NoRouteToHostException") != -1) { message = NLS.bind(CVSSSH2Messages.CVSSSH2ServerConnection_1, new String[] { location.getHost() }); throw new NoRouteToHostException(message); } if (exception.indexOf("java.net.UnknownHostException") != -1) { throw new UnknownHostException(location.getHost()); } message = message.substring(end + 1).trim(); } } } throw new SSH2IOException(message, e); } } } private IServerConnection createSSH1Connection() { try { return (IServerConnection)Class.forName("org.eclipse.team.internal.ccvs.ssh.SSHServerConnection") .getConstructor( new Class[] { ICVSRepositoryLocation.class, String.class }).newInstance( new Object[] { location, password }); } catch (IllegalArgumentException e1) { if (Policy.DEBUG) { e1.printStackTrace(); } } catch (SecurityException e1) { if (Policy.DEBUG) { e1.printStackTrace(); } } catch (InstantiationException e1) { if (Policy.DEBUG) { e1.printStackTrace(); } } catch (IllegalAccessException e1) { if (Policy.DEBUG) { e1.printStackTrace(); } } catch (InvocationTargetException e1) { if (Policy.DEBUG) { e1.printStackTrace(); } } catch (NoSuchMethodException e1) { if (Policy.DEBUG) { e1.printStackTrace(); } } catch (ClassNotFoundException e1) { if (Policy.DEBUG) { e1.printStackTrace(); } } return null; } private boolean isChannelNotOpenError(JSchException ee) { return ee.getMessage().indexOf("channel is not opened") != -1; } private boolean isSessionDownError(JSchException ee) { return ee.getMessage().equals("session is down"); } private boolean isSSH2Unsupported(JSchException e) { return e.toString().indexOf("invalid server's version string") != -1; } } /* Location: * Qualified Name: org.eclipse.team.internal.ccvs.ssh2.CVSSSH2ServerConnection * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ccvs.ssh2; import org.eclipse.jsch.core.IJSchLocation; import org.eclipse.jsch.core.IPasswordStore; import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; class JSchSession$1 implements IPasswordStore { private final ICVSRepositoryLocation val$location; JSchSession$1(ICVSRepositoryLocation paramICVSRepositoryLocation) { val$location = paramICVSRepositoryLocation; } public void clear(IJSchLocation l) { val$location.flushUserInfo(); } public boolean isCached(IJSchLocation l) { return val$location.getUserInfoCached(); } public void update(IJSchLocation l) { val$location.setPassword(l.getPassword()); val$location.setAllowCaching(true); } } /* Location: * Qualified Name: org.eclipse.team.internal.ccvs.ssh2.JSchSession.1 * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ccvs.ssh2; import com.jcraft.jsch.JSch; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; import java.util.Enumeration; import java.util.Hashtable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.jsch.core.IJSchLocation; import org.eclipse.jsch.core.IJSchService; import org.eclipse.jsch.core.IPasswordStore; import org.eclipse.osgi.util.NLS; import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; import org.eclipse.team.internal.ccvs.core.IConnectionMethod; class JSchSession { private static final int SSH_DEFAULT_PORT = 22; private static Hashtable pool = new Hashtable(); private final Session session; private final ICVSRepositoryLocation location; protected static int getCVSTimeoutInMillis() { return 60000; } public static boolean isAuthenticationFailure(JSchException ee) { return ee.getMessage().equals("Auth fail"); } static JSchSession getSession(ICVSRepositoryLocation location, String username, String password, String hostname, int port, IProgressMonitor monitor) throws JSchException { int actualPort = port; if (actualPort == 0) { actualPort = getPort(location); } String key = getPoolKey(username, hostname, actualPort); try { JSchSession jschSession = (JSchSession)pool.get(key); if ((jschSession != null) && (!jschSession.getSession().isConnected())) { pool.remove(key); jschSession = null; } if (jschSession == null) { IJSchService service = getJSchService(); IJSchLocation jlocation = service.getLocation(username, hostname, actualPort); if (!location.getMethod().getName().equals("pserverssh2")) { IPasswordStore pstore = new IPasswordStore() { public void clear(IJSchLocation l) { flushUserInfo(); } public boolean isCached(IJSchLocation l) { return getUserInfoCached(); } public void update(IJSchLocation l) { setPassword(l.getPassword()); setAllowCaching(true); } }; jlocation.setPasswordStore(pstore); } jlocation.setComment(NLS.bind(CVSSSH2Messages.JSchSession_3, new String[] { location.toString() })); Session session = null; try { session = createSession(service, jlocation, password, monitor); } catch (JSchException e) { throw e; } if (session == null) { throw new JSchException(CVSSSH2Messages.JSchSession_4); } if (session.getTimeout() != location.getTimeout() * 1000) { session.setTimeout(location.getTimeout() * 1000); } JSchSession schSession = new JSchSession(session, location); pool.put(key, schSession); return schSession; } return jschSession; } catch (JSchException e) { pool.remove(key); if (e.toString().indexOf("Auth cancel") != -1) { throw new OperationCanceledException(); } throw e; } } private static Session createSession(IJSchService service, IJSchLocation location, String password, IProgressMonitor monitor) throws JSchException { if (password != null) { location.setPassword(password); } Session session = service.createSession(location, null); session.setTimeout(getCVSTimeoutInMillis()); if (password != null) { session.setPassword(password); } service.connect(session, getCVSTimeoutInMillis(), monitor); return session; } private static IJSchService getJSchService() { return CVSSSH2Plugin.getDefault().getJSchService(); } private static String getPoolKey(String username, String hostname, int port) { return username + "@" + hostname + ":" + port; } private static String getPoolKey(ICVSRepositoryLocation location) { return location.getUsername() + "@" + location.getHost() + ":" + getPort(location); } private static int getPort(ICVSRepositoryLocation location) { int port = location.getPort(); if (port == 0) { port = 22; } return port; } static void shutdown() { if ((getJSch() != null) && (pool.size() > 0)) { for (Enumeration e = pool.elements(); e.hasMoreElements();) { JSchSession session = (JSchSession)e.nextElement(); try { session.getSession().disconnect(); } catch (Exception localException) {} } pool.clear(); } } static JSch getJSch() { return getJSchService().getJSch(); } private JSchSession(Session session, ICVSRepositoryLocation location) { this.session = session; this.location = location; } public Session getSession() { return session; } public void dispose() { if (session.isConnected()) { session.disconnect(); } pool.remove(getPoolKey(location)); } } /* Location: * Qualified Name: org.eclipse.team.internal.ccvs.ssh2.JSchSession * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ccvs.ssh2; 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 PServerSSH2Method implements IConnectionMethod { public String getName() { return "pserverssh2"; } public IServerConnection createConnection(ICVSRepositoryLocation root, String password) { return new PServerSSH2ServerConnection(root, password); } public void disconnect(ICVSRepositoryLocation location) {} } /* Location: * Qualified Name: org.eclipse.team.internal.ccvs.ssh2.PServerSSH2Method * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ccvs.ssh2; import com.jcraft.jsch.JSchException; import com.jcraft.jsch.Session; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation; import org.eclipse.team.internal.ccvs.core.IConnectionMethod; import org.eclipse.team.internal.ccvs.core.IServerConnection; import org.eclipse.team.internal.ccvs.core.connection.CVSAuthenticationException; import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; public class PServerSSH2ServerConnection implements IServerConnection { private ICVSRepositoryLocation location; private String password; private Session session; private static int localport = 2403; private IServerConnection psc = null; protected PServerSSH2ServerConnection(ICVSRepositoryLocation location, String password) { this.location = location; this.password = password; } public void close() throws IOException { psc.close(); } public InputStream getInputStream() { return psc.getInputStream(); } public OutputStream getOutputStream() { return psc.getOutputStream(); } public void open(IProgressMonitor monitor) throws IOException, CVSAuthenticationException { monitor.subTask("PServerSSH2ServerConnection.open"); monitor.worked(1); String cvs_root = location.getRootDirectory(); int cvs_port = location.getPort(); if (cvs_port == 0) { cvs_port = 2401; } String cvs_host = location.getHost(); String ssh_host = cvs_host; String ssh_user = location.getUsername(); String host = cvs_host; if (host.indexOf('@') != -1) { cvs_host = host.substring(host.lastIndexOf('@') + 1); host = host.substring(0, host.lastIndexOf('@')); if (host.indexOf('@') != -1) { ssh_host = host.substring(host.lastIndexOf('@') + 1); if (ssh_host.length() == 0) { ssh_host = cvs_host; } ssh_user = host.substring(0, host.lastIndexOf('@')); } else { ssh_host = host; } } int ssh_port = 0; if (ssh_host.indexOf('#') != -1) { try { ssh_port = Integer.parseInt(ssh_host.substring(ssh_host.lastIndexOf('#') + 1)); ssh_host = ssh_host.substring(0, ssh_host.lastIndexOf('#')); } catch (Exception localException1) {} } int lport = cvs_port; String rhost = cvs_host.equals(ssh_host) ? "localhost" : cvs_host; int rport = cvs_port; int retry = 1; for (;;) { try { session = JSchSession.getSession(location, ssh_user, null, ssh_host, ssh_port, monitor).getSession(); String[] list = session.getPortForwardingL(); String name = ":" + rhost + ":" + rport; boolean done = false; int i = 0; if (list[i].endsWith(name)) { try { String foo = list[i].substring(0, list[i].indexOf(':')); lport = Integer.parseInt(foo); } catch (Exception localException2) {} done = true; } else { i++; if (i < list.length) { continue; } } if (done) { break; } lport = localport++; session.setPortForwardingL(lport, rhost, rport); } catch (JSchException localJSchException) { retry--; if (retry < 0) { throw new CVSAuthenticationException(CVSSSH2Messages.CVSSSH2ServerConnection_3, 2, location); } } if ((session != null) && (session.isConnected())) { session.disconnect(); } } ((CVSRepositoryLocation)location).setPassword(password); try { String _password = ""; if (password != null) { _password = password; } Properties prop = new Properties(); prop.put("connection", "pserver"); prop.put("user", location.getUsername()); prop.put("password", _password); prop.put("host", "localhost"); prop.put("port", Integer.toString(lport)); prop.put("root", cvs_root); CVSRepositoryLocation cvsrl = CVSRepositoryLocation.fromProperties(prop); IConnectionMethod method = cvsrl.getMethod(); psc = method.createConnection(cvsrl, _password); } catch (Exception e) { throw new CVSAuthenticationException(e.toString(), 2, location); } psc.open(monitor); } } /* Location: * Qualified Name: org.eclipse.team.internal.ccvs.ssh2.PServerSSH2ServerConnection * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ package org.eclipse.team.internal.ccvs.ssh2; public class Policy { public static boolean DEBUG = false; static { if (CVSSSH2Plugin.getDefault().isDebugging()) { DEBUG = true; } } } /* Location: * Qualified Name: org.eclipse.team.internal.ccvs.ssh2.Policy * Java Class Version: 1.2 (46.0) * JD-Core Version: 0.7.1 */ 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
|