Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 210707 Details for
Bug 179924
[SSH2] SSH connection should respect ssh-agent in publickey authentication
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
a patch for o.e.jsch.{core,ui} to use jsch-agent-proxy
jsch-agent-proxy-eclipse.diff.txt (text/plain), 18.25 KB, created by
Atsuhiko Yamanaka
on 2012-02-08 00:28:13 EST
(
hide
)
Description:
a patch for o.e.jsch.{core,ui} to use jsch-agent-proxy
Filename:
MIME Type:
Creator:
Atsuhiko Yamanaka
Created:
2012-02-08 00:28:13 EST
Size:
18.25 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jsch.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jsch.core/META-INF/MANIFEST.MF,v >retrieving revision 1.12 >diff -u -r1.12 MANIFEST.MF >--- META-INF/MANIFEST.MF 1 Sep 2011 12:38:03 -0000 1.12 >+++ META-INF/MANIFEST.MF 8 Feb 2012 04:56:28 -0000 >@@ -8,8 +8,10 @@ > Bundle-Localization: plugin > Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)", > com.jcraft.jsch;bundle-version="[0.1.28,1.0.0)", >- org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)" >+ org.eclipse.core.net;bundle-version="[1.0.0,2.0.0)", >+ com.jcraft.jsch.agentproxy;bundle-version="0.0.2" > Bundle-ActivationPolicy: lazy >-Export-Package: org.eclipse.jsch.core, >+Export-Package: >+ org.eclipse.jsch.core, > org.eclipse.jsch.internal.core;x-friends:="org.eclipse.jsch.ui" > Bundle-RequiredExecutionEnvironment: J2SE-1.4 >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jsch.core/plugin.xml,v >retrieving revision 1.5 >diff -u -r1.5 plugin.xml >--- plugin.xml 13 May 2011 13:16:00 -0000 1.5 >+++ plugin.xml 8 Feb 2012 04:56:28 -0000 >@@ -12,7 +12,8 @@ > --> > > <plugin> >- <extension-point id="authenticator" name="%Authenticator" schema="schema/authenticator.exsd" /> >+ <extension-point id="authenticator" name="%Authenticator" schema="schema/authenticator.exsd" /> >+ <extension-point id="jschagentproxyconnector" name="jschagentproxyconnector" schema="schema/jsch_agent_proxy_connector.exsd"/> > <extension > point="org.eclipse.core.runtime.preferences"> > <initializer >Index: schema/jsch_agent_proxy_connector.exsd >=================================================================== >RCS file: schema/jsch_agent_proxy_connector.exsd >diff -N schema/jsch_agent_proxy_connector.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/jsch_agent_proxy_connector.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,93 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.jsch.core" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.jsch.core" id="jschagentproxyconnector" name="jschagentproxyconnector"/> >+ </appInfo> >+ <documentation> >+ [Enter description of this extension point.] >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appInfo> >+ <meta.element /> >+ </appInfo> >+ </annotation> >+ <complexType> >+ <sequence> >+ <element ref="jschagentproxyconnector"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="jschagentproxyconnector"> >+ <complexType> >+ <sequence> >+ <element ref="run"/> >+ </sequence> >+ </complexType> >+ </element> >+ >+ <element name="run"> >+ <complexType> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ [Enter the first release in which this extension point appears.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ [Enter extension point usage example here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiinfo"/> >+ </appInfo> >+ <documentation> >+ [Enter API information here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="implementation"/> >+ </appInfo> >+ <documentation> >+ [Enter information about supplied implementation of this extension point.] >+ </documentation> >+ </annotation> >+ >+ >+</schema> >Index: src/org/eclipse/jsch/core/IAgentProxyConnectorFactory.java >=================================================================== >RCS file: src/org/eclipse/jsch/core/IAgentProxyConnectorFactory.java >diff -N src/org/eclipse/jsch/core/IAgentProxyConnectorFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jsch/core/IAgentProxyConnectorFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+package org.eclipse.jsch.core; >+ >+import com.jcraft.jsch.agentproxy.Connector; >+ >+public interface IAgentProxyConnectorFactory{ >+ Connector create(); >+} >Index: src/org/eclipse/jsch/internal/core/IConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/IConstants.java,v >retrieving revision 1.4 >diff -u -r1.4 IConstants.java >--- src/org/eclipse/jsch/internal/core/IConstants.java 12 Jan 2011 11:02:58 -0000 1.4 >+++ src/org/eclipse/jsch/internal/core/IConstants.java 8 Feb 2012 04:56:29 -0000 >@@ -54,4 +54,5 @@ > > public static final String PREF_PREFERRED_AUTHENTICATION_METHODS="CVSSSH2PreferencePage.PREF_AUTH_METHODS"; //$NON-NLS-1$ > public static final String PREF_PREFERRED_AUTHENTICATION_METHODS_ORDER="CVSSSH2PreferencePage.PREF_AUTH_METHODS_ORDER"; //$NON-NLS-1$ >+ public static final String PREF_PREFERRED_SSHAGENT="CVSSSH2PreferencePage.PREF_SSHAGENT"; //$NON-NLS-1$ > } >Index: src/org/eclipse/jsch/internal/core/JSchCorePlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/JSchCorePlugin.java,v >retrieving revision 1.9 >diff -u -r1.9 JSchCorePlugin.java >--- src/org/eclipse/jsch/internal/core/JSchCorePlugin.java 3 Jun 2008 13:36:04 -0000 1.9 >+++ src/org/eclipse/jsch/internal/core/JSchCorePlugin.java 8 Feb 2012 04:56:29 -0000 >@@ -12,17 +12,22 @@ > package org.eclipse.jsch.internal.core; > > import java.util.Hashtable; >+import java.util.Vector; > > import org.eclipse.core.net.proxy.IProxyService; > import org.eclipse.core.runtime.*; >+import org.eclipse.jsch.core.IAgentProxyConnectorFactory; > import org.eclipse.jsch.core.IJSchService; > import org.eclipse.osgi.util.NLS; > import org.osgi.framework.BundleContext; > import org.osgi.framework.ServiceRegistration; > import org.osgi.util.tracker.ServiceTracker; > >+import com.jcraft.jsch.IdentityRepository; > import com.jcraft.jsch.JSch; > import com.jcraft.jsch.JSchException; >+import com.jcraft.jsch.agentproxy.Connector; >+import com.jcraft.jsch.agentproxy.RemoteIdentityRepository; > > public class JSchCorePlugin extends Plugin{ > >@@ -39,6 +44,8 @@ > private String current_pkeys=""; //$NON-NLS-1$ > > public static final String PT_AUTHENTICATOR="authenticator"; //$NON-NLS-1$ >+ public static final String PT_IDENTITYREPO="identityrepo"; //$NON-NLS-1$ >+ public static final String PT_AGENTPROXYCONNECTOR="jschagentproxyconnector"; //$NON-NLS-1$ > > private static JSchCorePlugin plugin; > private ServiceTracker tracker; >@@ -100,10 +107,81 @@ > } > > public synchronized JSch getJSch(){ >- if(jsch==null) >- jsch=new JSch(); >+ if(jsch==null){ >+ jsch=new JSch(); >+ setIdentityRepository(); >+ } > return jsch; > } >+ >+ public synchronized void setIdentityRepository(){ >+ Connector[] connectors = getPluggedInAgentProxyConnectors(); >+ String[] selected = Utils.getSelectedSSHAgent().split(","); //$NON-NLS-1$ >+ IdentityRepository irepo = null; >+ for(int i=0; i<selected.length; i++){ >+ for(int j=0; j<connectors.length; j++){ >+ Connector connector = connectors[j]; >+ if(selected[i].equals(connector.getName()) && >+ connector.isAvailable()){ >+ irepo = new RemoteIdentityRepository(connector); >+ break; >+ } >+ } >+ if(irepo!=null) >+ break; >+ } >+ if(irepo!=null){ >+ jsch.setIdentityRepository(irepo); >+ } >+ else{ >+ // TODO If the remote repository is not available, the default one should be setted. >+ >+ } >+ } >+ >+ public Connector[] getPluggedInAgentProxyConnectors(){ >+ >+ IExtension[] extensions=Platform.getExtensionRegistry().getExtensionPoint( >+ JSchCorePlugin.ID, JSchCorePlugin.PT_AGENTPROXYCONNECTOR).getExtensions(); >+ >+ if(extensions.length==0) >+ return new Connector[0]; >+ >+ Vector tmp = new Vector(); >+ for(int i=0; i<extensions.length; i++){ >+ IExtension extension=extensions[i]; >+ IConfigurationElement[] configs=extension.getConfigurationElements(); >+ if(configs.length==0){ >+ JSchCorePlugin >+ .log( >+ IStatus.ERROR, >+ NLS >+ .bind( >+ "Agent proxy connector {0} is missing required fields", (new Object[] {extension.getUniqueIdentifier()})), null);//$NON-NLS-1$ >+ continue; >+ } >+ try{ >+ IConfigurationElement config=configs[0]; >+ IAgentProxyConnectorFactory iapcf = >+ (IAgentProxyConnectorFactory)config.createExecutableExtension("run");//$NON-NLS-1$ >+ tmp.addElement(iapcf.create()); >+ } >+ catch(CoreException ex){ >+ JSchCorePlugin >+ .log( >+ IStatus.ERROR, >+ NLS >+ .bind( >+ "Unable to instantiate agent proxy connector {0}", (new Object[] {extension.getUniqueIdentifier()})), ex);//$NON-NLS-1$ >+ } >+ } >+ >+ Connector[] connectors = new Connector[tmp.size()]; >+ for(int i=0; i<tmp.size(); i++){ >+ connectors[i]=(Connector)tmp.elementAt(i); >+ } >+ return connectors; >+ } > > public void loadKnownHosts(){ > Preferences preferences=JSchCorePlugin.getPlugin().getPluginPreferences(); >Index: src/org/eclipse/jsch/internal/core/Utils.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/Utils.java,v >retrieving revision 1.12 >diff -u -r1.12 Utils.java >--- src/org/eclipse/jsch/internal/core/Utils.java 1 Sep 2011 12:38:03 -0000 1.12 >+++ src/org/eclipse/jsch/internal/core/Utils.java 8 Feb 2012 04:56:29 -0000 >@@ -26,6 +26,7 @@ > import com.jcraft.jsch.ProxyHTTP; > import com.jcraft.jsch.ProxySOCKS5; > import com.jcraft.jsch.Session; >+import com.jcraft.jsch.agentproxy.Connector; > > /** > * >@@ -212,6 +213,18 @@ > return service.getString(JSchCorePlugin.ID, > IConstants.PREF_PREFERRED_AUTHENTICATION_METHODS, getDefaultAuthMethods(), null); > } >+ >+ public static String getAvailableSSHAgents(){ >+ Connector[] connectors = JSchCorePlugin.getPlugin().getPluggedInAgentProxyConnectors(); >+ String s=""; //$NON-NLS-1$ >+ for(int i=0; i<connectors.length; i++){ >+ Connector c = connectors[i]; >+ s+=c.getName(); >+ if(i+1<connectors.length) >+ s+=","; //$NON-NLS-1$ >+ } >+ return s; >+ } > > public static String getMethodsOrder(){ > IPreferencesService service = Platform.getPreferencesService(); >@@ -225,6 +238,16 @@ > IConstants.PREF_PREFERRED_AUTHENTICATION_METHODS, methods); > service.getRootNode().node(InstanceScope.SCOPE).node(JSchCorePlugin.ID).put( > IConstants.PREF_PREFERRED_AUTHENTICATION_METHODS_ORDER, order);} >- > >+ public static String getSelectedSSHAgent(){ >+ IPreferencesService service = Platform.getPreferencesService(); >+ return service.getString(JSchCorePlugin.ID, >+ IConstants.PREF_PREFERRED_SSHAGENT, "", null); //$NON-NLS-1$ >+ } >+ >+ public static void setSelectedSSHAgents(String methods){ >+ IPreferencesService service=Platform.getPreferencesService(); >+ service.getRootNode().node(InstanceScope.SCOPE).node(JSchCorePlugin.ID).put( >+ IConstants.PREF_PREFERRED_SSHAGENT, methods); >+ } > } >#P org.eclipse.jsch.ui >Index: src/org/eclipse/jsch/internal/ui/Messages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/Messages.java,v >retrieving revision 1.7 >diff -u -r1.7 Messages.java >--- src/org/eclipse/jsch/internal/ui/Messages.java 5 May 2011 10:05:42 -0000 1.7 >+++ src/org/eclipse/jsch/internal/ui/Messages.java 8 Feb 2012 04:56:30 -0000 >@@ -88,6 +88,8 @@ > public static String CVSSSH2PreferencePage_137; > public static String CVSSSH2PreferencePage_138; > public static String CVSSSH2PreferencePage_139; >+ public static String CVSSSH2PreferencePage_140; >+ public static String CVSSSH2PreferencePage_141; > public static String KeyboardInteractiveDialog_0; > public static String KeyboardInteractiveDialog_1; > public static String KeyboardInteractiveDialog_2; >Index: src/org/eclipse/jsch/internal/ui/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/messages.properties,v >retrieving revision 1.8 >diff -u -r1.8 messages.properties >--- src/org/eclipse/jsch/internal/ui/messages.properties 8 Aug 2009 13:56:25 -0000 1.8 >+++ src/org/eclipse/jsch/internal/ui/messages.properties 8 Feb 2012 04:56:30 -0000 >@@ -78,6 +78,8 @@ > CVSSSH2PreferencePage_137=&Authentication Methods > CVSSSH2PreferencePage_138=&Remove > CVSSSH2PreferencePage_139=Keys of known hosts: >+CVSSSH2PreferencePage_140=SSH Agent >+CVSSSH2PreferencePage_141=Select preferred SSH Agent > UserInfoPrompter_0=SSH2 Message > UserInfoPrompter_1=SSH2 Message > KeyboardInteractiveDialog_0=Keyboard Interactive authentication for {0}: {1} >Index: src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java,v >retrieving revision 1.9 >diff -u -r1.9 PreferencePage.java >--- src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java 11 Aug 2011 06:08:27 -0000 1.9 >+++ src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java 8 Feb 2012 04:56:30 -0000 >@@ -146,6 +146,10 @@ > tabItem=new TabItem(tabFolder, SWT.NONE); > tabItem.setText(Messages.CVSSSH2PreferencePage_137); > tabItem.setControl(createPreferredAuthenticationPage(tabFolder)); >+ >+ tabItem=new TabItem(tabFolder, SWT.NONE); >+ tabItem.setText(Messages.CVSSSH2PreferencePage_140); >+ tabItem.setControl(createPreferredSSHAgentPage(tabFolder)); > > initControls(); > >@@ -807,6 +811,7 @@ > private Button removeHostKeyButton; > > Table preferedAuthMethodTable; >+ Table preferedSSHAgentTable; > > Button up; > >@@ -1064,6 +1069,49 @@ > } > } > >+ private Control createPreferredSSHAgentPage(Composite parent){ >+ Composite root = new Composite(parent, SWT.NONE); >+ GridLayout layout=new GridLayout(); >+ layout.marginHeight=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); >+ layout.marginWidth=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); >+ layout.verticalSpacing=convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); >+ layout.horizontalSpacing=convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); >+ layout.numColumns = 2; >+ root.setLayout(layout); >+ >+ Label label=new Label(root, SWT.NONE); >+ GridData textLayoutData=new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false); >+ textLayoutData.horizontalSpan = 2; >+ label.setLayoutData(textLayoutData); >+ label.setText(Messages.CVSSSH2PreferencePage_141); >+ >+ preferedSSHAgentTable=new Table(root, SWT.CHECK | SWT.BORDER); >+ GridData layoutData=new GridData(SWT.FILL, SWT.BEGINNING, true, true); >+ layoutData.verticalSpan = 3; >+ preferedSSHAgentTable.setLayoutData(layoutData); >+ layoutData.minimumHeight = 150; >+ layoutData.minimumWidth = 200; >+ populateSSHAgents(); >+ return root; >+ } >+ >+ private void populateSSHAgents(){ >+ preferedSSHAgentTable.removeAll(); >+ String[] methods = Utils.getAvailableSSHAgents().split(","); //$NON-NLS-1$ >+ String[] selected = Utils.getSelectedSSHAgent().split(","); //$NON-NLS-1$ >+ >+ for(int i=0; i<methods.length; i++){ >+ TableItem tableItem= new TableItem(preferedSSHAgentTable, SWT.NONE); >+ tableItem.setText(0, methods[i]); >+ for(int j=0; j<selected.length; j++){ >+ if(selected[j].equals(methods[i])){ >+ tableItem.setChecked(true); >+ break; >+ } >+ } >+ } >+ } >+ > void handleSelection(){ > boolean empty=viewer.getSelection().isEmpty(); > removeHostKeyButton.setEnabled(!empty); >@@ -1202,6 +1250,7 @@ > public boolean performOk(){ > boolean result=super.performOk(); > storeAuthenticationMethodSettings(); >+ storeSSHAgentSettings(); > if(result){ > setErrorMessage(null); > String home=ssh2HomeText.getText(); >@@ -1226,6 +1275,7 @@ > } > JSchCorePlugin.getPlugin().setNeedToLoadKnownHosts(true); > JSchCorePlugin.getPlugin().setNeedToLoadKeys(true); >+ JSchCorePlugin.getPlugin().setIdentityRepository(); > JSchCorePlugin.getPlugin().savePluginPreferences(); > return result; > } >@@ -1251,6 +1301,22 @@ > } > Utils.setEnabledPreferredAuthMethods(selected, order); > } >+ >+ private void storeSSHAgentSettings(){ >+ String selected = ""; //$NON-NLS-1$ >+ for(int i = 0; i < preferedSSHAgentTable.getItemCount(); i++){ >+ TableItem item=preferedSSHAgentTable.getItem(i); >+ if(item.getChecked()){ >+ if(selected.length()==0){ >+ selected=item.getText(); >+ } >+ else{ >+ selected+=","+item.getText(); //$NON-NLS-1$ >+ } >+ } >+ } >+ Utils.setSelectedSSHAgents(selected); >+ } > > public void performApply(){ > performOk();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 179924
: 210707 |
210708
|
250465
|
259972