--- /dev/null
+package com.gitblit.tests;\r
+\r
+import java.security.KeyPair;\r
+\r
+import org.eclipse.jgit.transport.JschConfigSessionFactory;\r
+import org.eclipse.jgit.transport.OpenSshConfig;\r
+import org.eclipse.jgit.util.FS;\r
+\r
+import com.jcraft.jsch.JSch;\r
+import com.jcraft.jsch.JSchException;\r
+import com.jcraft.jsch.Session;\r
+\r
+public class JschConfigTestSessionFactory extends JschConfigSessionFactory {\r
+\r
+ final KeyPair keyPair;\r
+\r
+ public JschConfigTestSessionFactory(KeyPair keyPair) {\r
+ this.keyPair = keyPair;\r
+ }\r
+\r
+ @Override\r
+ protected void configure(OpenSshConfig.Host host, Session session) {\r
+ session.setConfig("StrictHostKeyChecking", "no");\r
+ }\r
+\r
+ @Override\r
+ protected JSch getJSch(final OpenSshConfig.Host hc, FS fs) throws JSchException {\r
+ JSch jsch = super.getJSch(hc, fs);\r
+// jsch.removeAllIdentity();\r
+// jsch.addIdentity("unittest", keyPair.getPrivate().getEncoded(), keyPair.getPublic().getEncoded(), null);\r
+ return jsch;\r
+ }\r
+}
\ No newline at end of file