James Moger
2015-10-05 92ae83de6b4f5401a1007bbb26e2f01168e9d6cb
commit | author | age
e5d609 1 package com.gitblit.tests;
JM 2
3 import java.security.KeyPair;
4
5 import org.eclipse.jgit.transport.JschConfigSessionFactory;
6 import org.eclipse.jgit.transport.OpenSshConfig;
7 import org.eclipse.jgit.util.FS;
8
9 import com.jcraft.jsch.JSch;
10 import com.jcraft.jsch.JSchException;
11 import com.jcraft.jsch.Session;
12
13 public class JschConfigTestSessionFactory extends JschConfigSessionFactory {
14
15     final KeyPair keyPair;
16
17     public JschConfigTestSessionFactory(KeyPair keyPair) {
18         this.keyPair = keyPair;
19     }
20
21     @Override
22     protected void configure(OpenSshConfig.Host host, Session session) {
23         session.setConfig("StrictHostKeyChecking", "no");
24     }
25
26     @Override
27     protected JSch getJSch(final OpenSshConfig.Host hc, FS fs) throws JSchException {
28         JSch jsch = super.getJSch(hc, fs);
29 //        jsch.removeAllIdentity();
30 //        jsch.addIdentity("unittest", keyPair.getPrivate().getEncoded(), keyPair.getPublic().getEncoded(), null);
31         return jsch;
32     }
33 }