Skip to content

Commit

Permalink
some commented debug
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Lamy <[email protected]>
  • Loading branch information
olamy committed May 9, 2024
1 parent 5aa74b6 commit e283189
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 19 deletions.
17 changes: 12 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,18 @@
<artifactId>mina-sshd-api-core</artifactId>
</dependency>
<!-- this could be optional? -->
<!-- <dependency>-->
<!-- <groupId>net.i2p.crypto</groupId>-->
<!-- <artifactId>eddsa</artifactId>-->
<!-- <version>0.3.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>net.i2p.crypto</groupId>
<artifactId>eddsa</artifactId>
<version>0.3.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.77</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
Expand Down
76 changes: 66 additions & 10 deletions src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import org.apache.commons.lang.SystemUtils;
import org.apache.commons.lang.time.FastDateFormat;
import org.apache.sshd.common.util.security.SecurityUtils;
import org.apache.sshd.common.util.security.bouncycastle.BouncyCastleSecurityProviderRegistrar;
import org.eclipse.jgit.api.AddNoteCommand;
import org.eclipse.jgit.api.CommitCommand;
import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
Expand Down Expand Up @@ -157,15 +156,72 @@ public class JGitAPIImpl extends LegacyCompatibleGitAPIImpl {
private final HostKeyVerifierFactory hostKeyVerifierFactory;
private transient CredentialsProvider provider;

static {
// TODO should we have this configurable?
// to avoid any registration of using "net.i2p.crypto.eddsa.EdDSASecurityProvider";
LOGGER.info("configuring SecurityUtils, isRegistrationCompleted:" + SecurityUtils.isRegistrationCompleted());
SecurityUtils.setDefaultProviderChoice(new BouncyCastleSecurityProviderRegistrar());
LOGGER.info("SecurityUtils.isEDDSACurveSupported():" + SecurityUtils.isEDDSACurveSupported());

LOGGER.info("SecurityUtils.getRegisteredProviders():" + SecurityUtils.getRegisteredProviders());
}
// static {
// // to avoid any registration of using "net.i2p.crypto.eddsa.EdDSASecurityProvider";
// ClassLoader orig = Thread.currentThread().getContextClassLoader();
//
// try {
// Thread.currentThread()
// .setContextClassLoader(Jenkins.get().getPlugin("git-client").getWrapper().classLoader);
// LOGGER.info(
// "configuring SecurityUtils, isRegistrationCompleted:" +
// SecurityUtils.isRegistrationCompleted());
// ///SecurityUtils.setDefaultProviderChoice(new BouncyCastleSecurityProviderRegistrar());
// LOGGER.info("SecurityUtils.isEDDSACurveSupported():" + SecurityUtils.isEDDSACurveSupported());
//
// LOGGER.info("SecurityUtils.getRegisteredProviders():" + SecurityUtils.getRegisteredProviders());
// } catch (Throwable e) {
// e.printStackTrace();
// } finally {
// Thread.currentThread().setContextClassLoader(orig);
// }
// }
//
// static {
// try {
// Class<?> clazz = Jenkins.get()
// .getPlugin("git-client")
// .getWrapper()
// .classLoader
// .loadClass("org.bouncycastle.jce.provider.BouncyCastleProvider");
// System.out.println("yup: " + clazz);
// } catch (ClassNotFoundException e) {
// e.printStackTrace();
// }
//
// try {
// Class<?> clazz = Jenkins.get()
// .getPlugin("git")
// .getWrapper()
// .classLoader
// .loadClass("net.i2p.crypto.eddsa.EdDSASecurityProvider");
// System.out.println("yup: " + clazz);
// } catch (Throwable e) {
// e.printStackTrace();
// }
//
// try {
// org.bouncycastle.jce.provider.BouncyCastleProvider foo =
// new org.bouncycastle.jce.provider.BouncyCastleProvider();
// int size = foo.size();
// System.out.println("size: " + size);
// Thread.currentThread()
// .getContextClassLoader()
// .loadClass("org.bouncycastle.jce.provider.BouncyCastleProvider");
// } catch (Throwable e) {
// e.printStackTrace();
// }
//
// try {
// net.i2p.crypto.eddsa.EdDSASecurityProvider foo = new net.i2p.crypto.eddsa.EdDSASecurityProvider();
// int size = foo.size();
// System.out.println("size: " + size);
//
// Thread.currentThread().getContextClassLoader().loadClass("net.i2p.crypto.eddsa.EdDSASecurityProvider");
// } catch (Throwable e) {
// e.printStackTrace();
// }
// }

JGitAPIImpl(File workspace, TaskListener listener) {
/* If workspace is null, then default to current directory to match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,12 @@ public void testVerifyServerHostKeyWhenHostnamePortProvided() throws Exception {
22,
mockedKnownHosts,
acceptFirstConnectionVerifier.forJGit(StreamBuildListener.fromStdout()),
s -> {
assertThat(s.isOpen(), is(true));
Awaitility.await().atMost(Duration.ofSeconds(45)).until(() -> s.getServerKey() != null);
assertThat(KnownHostsTestUtil.checkKeys(s), is(true));
session -> {
assertThat(session.isOpen(), is(true));
Awaitility.await()
.atMost(Duration.ofSeconds(45))
.until(() -> session.getServerKey() != null);
assertThat(KnownHostsTestUtil.checkKeys(session), is(true));
// Should have first connection and create a file
assertThat(mockedKnownHosts, is(anExistingFile()));
try {
Expand Down

0 comments on commit e283189

Please sign in to comment.