Skip to content

Commit 634302d

Browse files
Thomas Wolfmsohn
Thomas Wolf
authored andcommitted
sshd: add support for ssh-agent
Add a simple SSH agent connector using JNA. Include com.sum.jna and com.sun.jna.platform in the target platform. JNA is used to communicate through Unix domain sockets with ssh-agent, and if on Windows, to communicate via shared memory with Pageant. The new bundle o.e.j.ssh.apache.agent is an OSGi fragment so that the java.util.ServiceLoader can find the provided factory without further ado in OSGi environments. Adapt both maven and bazel builds to include the new bundle. Manually tested on OS X, CentOS 7, and Win10 with Pageant 0.76. Tested by installing JGit built from this change into freshly downloaded Eclipse 2021-12 M1, and then doing git fetches via SSH with different ~/.ssh/config settings (explicit IdentityFile, without any but a key in the agent, with no keys and a key in the agent and IdentitiesOnly=yes (must fail)). Bug: 541274 Bug: 541275 Change-Id: I34e85467293707dbad1eb44d1f40fc2e70ba3622 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
1 parent 68017a0 commit 634302d

File tree

57 files changed

+2362
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2362
-24
lines changed

BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ genrule(
1414
"//org.eclipse.jgit.lfs.server:jgit-lfs-server",
1515
"//org.eclipse.jgit.junit:junit",
1616
"//org.eclipse.jgit.ssh.apache:ssh-apache",
17+
"//org.eclipse.jgit.ssh.apache.agent:ssh-apache-agent",
1718
"//org.eclipse.jgit.ssh.jsch:ssh-jsch",
1819
],
1920
outs = ["all.zip"],

WORKSPACE

+12
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ maven_jar(
133133
sha1 = "0c9eff7145e20b338c1dd6aca36ba93ed7c0147c",
134134
)
135135

136+
maven_jar(
137+
name = "jna",
138+
artifact = "net.java.dev.jna:jna:5.8.0",
139+
sha1 = "3551d8d827e54858214107541d3aff9c615cb615",
140+
)
141+
142+
maven_jar(
143+
name = "jna-platform",
144+
artifact = "net.java.dev.jna:jna-platform:5.8.0",
145+
sha1 = "2f12f6d7f7652270d13624cef1b82d8cd9a5398e",
146+
)
147+
136148
maven_jar(
137149
name = "commons-codec",
138150
artifact = "commons-codec:commons-codec:1.14",

lib/BUILD

+17
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ java_library(
7676
visibility = [
7777
"//org.eclipse.jgit.junit.ssh:__pkg__",
7878
"//org.eclipse.jgit.ssh.apache:__pkg__",
79+
"//org.eclipse.jgit.ssh.apache.agent:__pkg__",
7980
"//org.eclipse.jgit.ssh.apache.test:__pkg__",
8081
"//org.eclipse.jgit.test:__pkg__",
8182
],
@@ -93,6 +94,22 @@ java_library(
9394
exports = ["@sshd-sftp//jar"],
9495
)
9596

97+
java_library(
98+
name = "jna",
99+
visibility = [
100+
"//org.eclipse.jgit.ssh.apache.agent:__pkg__",
101+
],
102+
exports = ["@jna//jar"],
103+
)
104+
105+
java_library(
106+
name = "jna-platform",
107+
visibility = [
108+
"//org.eclipse.jgit.ssh.apache.agent:__pkg__",
109+
],
110+
exports = ["@jna-platform//jar"],
111+
)
112+
96113
java_library(
97114
name = "javaewah",
98115
visibility = ["//visibility:public"],

org.eclipse.jgit.packaging/org.eclipse.jgit.pgm.feature/pom.xml

+13
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@
4545
<artifactId>org.eclipse.jgit.ui</artifactId>
4646
<version>${project.version}</version>
4747
</dependency>
48+
49+
<dependency>
50+
<groupId>org.eclipse.jgit</groupId>
51+
<artifactId>org.eclipse.jgit.ssh.apache</artifactId>
52+
<version>${project.version}</version>
53+
</dependency>
54+
55+
<dependency>
56+
<groupId>org.eclipse.jgit</groupId>
57+
<artifactId>org.eclipse.jgit.ssh.apache.agent</artifactId>
58+
<version>${project.version}</version>
59+
</dependency>
60+
4861
</dependencies>
4962

5063
</project>

org.eclipse.jgit.packaging/org.eclipse.jgit.repository/category.xml

+12
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@
5757
<bundle id="com.jcraft.jzlib.source">
5858
<category name="JGit-dependency-bundles"/>
5959
</bundle>
60+
<bundle id="com.sun.jna">
61+
<category name="JGit-dependency-bundles"/>
62+
</bundle>
63+
<bundle id="com.sun.jna.source">
64+
<category name="JGit-dependency-bundles"/>
65+
</bundle>
66+
<bundle id="com.sun.jna.platform">
67+
<category name="JGit-dependency-bundles"/>
68+
</bundle>
69+
<bundle id="com.sun.jna.platform.source">
70+
<category name="JGit-dependency-bundles"/>
71+
</bundle>
6072
<bundle id="javaewah">
6173
<category name="JGit-dependency-bundles"/>
6274
</bundle>

org.eclipse.jgit.packaging/org.eclipse.jgit.repository/pom.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@
9191
<artifactId>org.eclipse.jgit.ssh.apache</artifactId>
9292
<version>${project.version}</version>
9393
</dependency>
94-
<dependency>
94+
<dependency>
95+
<groupId>org.eclipse.jgit</groupId>
96+
<artifactId>org.eclipse.jgit.ssh.apache.agent</artifactId>
97+
<version>${project.version}</version>
98+
</dependency>
99+
<dependency>
95100
<groupId>org.eclipse.jgit</groupId>
96101
<artifactId>org.eclipse.jgit.ssh.jsch</artifactId>
97102
<version>${project.version}</version>

org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/feature.xml

+7
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@
110110
version="0.0.0"
111111
unpack="false"/>
112112

113+
<plugin
114+
id="org.eclipse.jgit.ssh.apache.agent.source"
115+
download-size="0"
116+
install-size="0"
117+
version="0.0.0"
118+
unpack="false"/>
119+
113120
<plugin
114121
id="org.eclipse.jgit.ssh.jsch.source"
115122
download-size="0"

org.eclipse.jgit.packaging/org.eclipse.jgit.ssh.apache.feature/feature.xml

+8
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,12 @@
3333
version="0.0.0"
3434
unpack="false"/>
3535

36+
<plugin
37+
id="org.eclipse.jgit.ssh.apache.agent"
38+
download-size="0"
39+
install-size="0"
40+
version="0.0.0"
41+
fragment="true"
42+
unpack="false"/>
43+
3644
</feature>

org.eclipse.jgit.packaging/org.eclipse.jgit.ssh.apache.feature/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
<version>${project.version}</version>
4040
</dependency>
4141

42+
<dependency>
43+
<groupId>org.eclipse.jgit</groupId>
44+
<artifactId>org.eclipse.jgit.ssh.apache.agent</artifactId>
45+
<version>${project.version}</version>
46+
</dependency>
47+
4248
</dependencies>
4349

4450
</project>

org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.target

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<?pde?>
33
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
4-
<target name="jgit-4.17" sequenceNumber="1635977786">
4+
<target name="jgit-4.17" sequenceNumber="1635979596">
55
<locations>
66
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
77
<unit id="org.eclipse.jetty.client" version="9.4.43.v20210629"/>
@@ -31,6 +31,10 @@
3131
<unit id="com.jcraft.jsch.source" version="0.1.55.v20190404-1902"/>
3232
<unit id="com.jcraft.jzlib" version="1.1.1.v201205102305"/>
3333
<unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/>
34+
<unit id="com.sun.jna" version="5.8.0.v20210503-0343"/>
35+
<unit id="com.sun.jna.source" version="5.8.0.v20210503-0343"/>
36+
<unit id="com.sun.jna.platform" version="5.8.0.v20210406-1004"/>
37+
<unit id="com.sun.jna.platform.source" version="5.8.0.v20210406-1004"/>
3438
<unit id="javaewah" version="1.1.12.v20210622-2206"/>
3539
<unit id="javaewah.source" version="1.1.12.v20210622-2206"/>
3640
<unit id="javax.servlet" version="3.1.0.v201410161800"/>

org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18.target

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<?pde?>
33
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
4-
<target name="jgit-4.18" sequenceNumber="1635977786">
4+
<target name="jgit-4.18" sequenceNumber="1635979596">
55
<locations>
66
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
77
<unit id="org.eclipse.jetty.client" version="9.4.43.v20210629"/>
@@ -31,6 +31,10 @@
3131
<unit id="com.jcraft.jsch.source" version="0.1.55.v20190404-1902"/>
3232
<unit id="com.jcraft.jzlib" version="1.1.1.v201205102305"/>
3333
<unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/>
34+
<unit id="com.sun.jna" version="5.8.0.v20210503-0343"/>
35+
<unit id="com.sun.jna.source" version="5.8.0.v20210503-0343"/>
36+
<unit id="com.sun.jna.platform" version="5.8.0.v20210406-1004"/>
37+
<unit id="com.sun.jna.platform.source" version="5.8.0.v20210406-1004"/>
3438
<unit id="javaewah" version="1.1.12.v20210622-2206"/>
3539
<unit id="javaewah.source" version="1.1.12.v20210622-2206"/>
3640
<unit id="javax.servlet" version="3.1.0.v201410161800"/>

org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.19.target

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<?pde?>
33
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
4-
<target name="jgit-4.19-staging" sequenceNumber="1635977786">
4+
<target name="jgit-4.19-staging" sequenceNumber="1635979596">
55
<locations>
66
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
77
<unit id="org.eclipse.jetty.client" version="9.4.43.v20210629"/>
@@ -31,6 +31,10 @@
3131
<unit id="com.jcraft.jsch.source" version="0.1.55.v20190404-1902"/>
3232
<unit id="com.jcraft.jzlib" version="1.1.1.v201205102305"/>
3333
<unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/>
34+
<unit id="com.sun.jna" version="5.8.0.v20210503-0343"/>
35+
<unit id="com.sun.jna.source" version="5.8.0.v20210503-0343"/>
36+
<unit id="com.sun.jna.platform" version="5.8.0.v20210406-1004"/>
37+
<unit id="com.sun.jna.platform.source" version="5.8.0.v20210406-1004"/>
3438
<unit id="javaewah" version="1.1.12.v20210622-2206"/>
3539
<unit id="javaewah.source" version="1.1.12.v20210622-2206"/>
3640
<unit id="javax.servlet" version="3.1.0.v201410161800"/>

org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.20.target

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<?pde?>
33
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
4-
<target name="jgit-4.20" sequenceNumber="1635977786">
4+
<target name="jgit-4.20" sequenceNumber="1635979596">
55
<locations>
66
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
77
<unit id="org.eclipse.jetty.client" version="9.4.43.v20210629"/>
@@ -31,6 +31,10 @@
3131
<unit id="com.jcraft.jsch.source" version="0.1.55.v20190404-1902"/>
3232
<unit id="com.jcraft.jzlib" version="1.1.1.v201205102305"/>
3333
<unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/>
34+
<unit id="com.sun.jna" version="5.8.0.v20210503-0343"/>
35+
<unit id="com.sun.jna.source" version="5.8.0.v20210503-0343"/>
36+
<unit id="com.sun.jna.platform" version="5.8.0.v20210406-1004"/>
37+
<unit id="com.sun.jna.platform.source" version="5.8.0.v20210406-1004"/>
3438
<unit id="javaewah" version="1.1.12.v20210622-2206"/>
3539
<unit id="javaewah.source" version="1.1.12.v20210622-2206"/>
3640
<unit id="javax.servlet" version="3.1.0.v201410161800"/>

org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.21.target

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<?pde?>
33
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
4-
<target name="jgit-4.21" sequenceNumber="1635977845">
4+
<target name="jgit-4.21" sequenceNumber="1635979596">
55
<locations>
66
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
77
<unit id="org.eclipse.jetty.client" version="9.4.43.v20210629"/>
@@ -31,6 +31,10 @@
3131
<unit id="com.jcraft.jsch.source" version="0.1.55.v20190404-1902"/>
3232
<unit id="com.jcraft.jzlib" version="1.1.1.v201205102305"/>
3333
<unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/>
34+
<unit id="com.sun.jna" version="5.8.0.v20210503-0343"/>
35+
<unit id="com.sun.jna.source" version="5.8.0.v20210503-0343"/>
36+
<unit id="com.sun.jna.platform" version="5.8.0.v20210406-1004"/>
37+
<unit id="com.sun.jna.platform.source" version="5.8.0.v20210406-1004"/>
3438
<unit id="javaewah" version="1.1.12.v20210622-2206"/>
3539
<unit id="javaewah.source" version="1.1.12.v20210622-2206"/>
3640
<unit id="javax.servlet" version="3.1.0.v201410161800"/>

org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20210825222808-2021-09.tpd

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ location "https://download.eclipse.org/tools/orbit/downloads/drops/R202108252228
88
com.jcraft.jsch.source [0.1.55.v20190404-1902,0.1.55.v20190404-1902]
99
com.jcraft.jzlib [1.1.1.v201205102305,1.1.1.v201205102305]
1010
com.jcraft.jzlib.source [1.1.1.v201205102305,1.1.1.v201205102305]
11+
com.sun.jna [5.8.0.v20210503-0343,5.8.0.v20210503-0343]
12+
com.sun.jna.source [5.8.0.v20210503-0343,5.8.0.v20210503-0343]
13+
com.sun.jna.platform [5.8.0.v20210406-1004,5.8.0.v20210406-1004]
14+
com.sun.jna.platform.source [5.8.0.v20210406-1004,5.8.0.v20210406-1004]
1115
javaewah [1.1.12.v20210622-2206,1.1.12.v20210622-2206]
1216
javaewah.source [1.1.12.v20210622-2206,1.1.12.v20210622-2206]
1317
javax.servlet [3.1.0.v201410161800,3.1.0.v201410161800]

org.eclipse.jgit.packaging/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@
147147
<version>${project.version}</version>
148148
<classifier>sources</classifier>
149149
</dependency>
150+
<dependency>
151+
<groupId>org.eclipse.jgit</groupId>
152+
<artifactId>org.eclipse.jgit.ssh.apache.agent</artifactId>
153+
<version>${project.version}</version>
154+
<classifier>sources</classifier>
155+
</dependency>
150156
<dependency>
151157
<groupId>org.eclipse.jgit</groupId>
152158
<artifactId>org.eclipse.jgit.ssh.jsch</artifactId>

org.eclipse.jgit.pgm/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
<version>${project.version}</version>
8080
</dependency>
8181

82+
<dependency>
83+
<groupId>org.eclipse.jgit</groupId>
84+
<artifactId>org.eclipse.jgit.ssh.apache.agent</artifactId>
85+
<version>${project.version}</version>
86+
</dependency>
87+
8288
<dependency>
8389
<groupId>org.eclipse.jgit</groupId>
8490
<artifactId>org.eclipse.jgit.ssh.jsch</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
4+
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5+
<classpathentry kind="src" path="src"/>
6+
<classpathentry kind="src" path="resources"/>
7+
<classpathentry kind="output" path="bin"/>
8+
</classpath>

0 commit comments

Comments
 (0)