Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<jgit.version>2.0.0.201206130900-r</jgit.version>
<log4j.extras.version>1.1</log4j.extras.version>
<openshift.client.version>2.0.1</openshift.client.version>
<jsch.version>0.1.48</jsch.version>
<jsch.version>0.1.49</jsch.version>
<jsch.agent.version>0.0.7</jsch.agent.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -48,6 +49,21 @@
<artifactId>jsch</artifactId>
<version>${jsch.version}</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch.agentproxy.core</artifactId>
<version>${jsch.agent.version}</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch.agentproxy.jsch</artifactId>
<version>${jsch.agent.version}</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch.agentproxy.connector-factory</artifactId>
<version>${jsch.agent.version}</version>
</dependency>
<dependency>
<groupId>com.openshift</groupId>
<artifactId>openshift-java-client</artifactId>
Expand All @@ -63,7 +79,7 @@
<artifactId>apache-log4j-extras</artifactId>
<version>${log4j.extras.version}</version>
</dependency>
</dependencies>
</dependencies>
<repositories>
<repository>
<id>JBOSS_NEXUS</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@

package com.redhat.openshift.forge.jsch;

import java.util.Properties;

import javax.inject.Inject;

import org.eclipse.jgit.transport.JschConfigSessionFactory;
import org.eclipse.jgit.transport.OpenSshConfig.Host;
import org.eclipse.jgit.util.FS;

import com.jcraft.jsch.IdentityRepository;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import org.eclipse.jgit.util.FS;
import com.jcraft.jsch.agentproxy.AgentProxyException;
import com.jcraft.jsch.agentproxy.Connector;
import com.jcraft.jsch.agentproxy.ConnectorFactory;
import com.jcraft.jsch.agentproxy.RemoteIdentityRepository;

/**
* @author <a href="mailto:[email protected]">Rafael Benevides</a>
Expand All @@ -45,17 +48,30 @@ public class ForgeJschConfigSessionFactory extends JschConfigSessionFactory {
/*
* (non-Javadoc)
*
* @see org.eclipse.jgit.transport.JschConfigSessionFactory#configure(org.eclipse.jgit.transport.OpenSshConfig.Host,
* com.jcraft.jsch.Session)
* @see
* org.eclipse.jgit.transport.JschConfigSessionFactory#configure(org.eclipse
* .jgit.transport.OpenSshConfig.Host, com.jcraft.jsch.Session)
*/
@Override
protected void configure(Host hc, Session session) {

try {
session.setUserInfo(forgeUserInfo);

//JSch jsch = this.getJSch(hc, FS.DETECTED);

JSch jsch = this.getJSch(hc, FS.DETECTED);
JSch.setConfig("PreferredAuthentications", "publickey");

Connector con;
try {
ConnectorFactory cf = ConnectorFactory.getDefault();
con = cf.createConnector();
if (con != null) {
IdentityRepository irepo = new RemoteIdentityRepository(con);
jsch.setIdentityRepository(irepo);
}
} catch (AgentProxyException e) {
System.out.println(e);
}
//Properties config = new Properties();
//config.put("StrictHostKeyChecking", "no");
//config.put("GSSAPIAuthentication", "no");
Expand All @@ -66,5 +82,4 @@ protected void configure(Host hc, Session session) {
e.printStackTrace();
}
}

}