maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] cquoss commented on a change in pull request #89: SCM-919 jgit codecheck cleanup
Date Fri, 08 Feb 2019 22:27:05 GMT
cquoss commented on a change in pull request #89: SCM-919 jgit codecheck cleanup
URL: https://github.com/apache/maven-scm/pull/89#discussion_r255255525
 
 

 ##########
 File path: maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/main/java/org/apache/maven/scm/provider/git/jgit/command/JGitTransportConfigCallback.java
 ##########
 @@ -25,81 +25,106 @@
 import org.apache.maven.scm.log.ScmLogger;
 import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
 import org.eclipse.jgit.api.TransportConfigCallback;
-import org.eclipse.jgit.transport.*;
+import org.eclipse.jgit.transport.JschConfigSessionFactory;
+import org.eclipse.jgit.transport.OpenSshConfig;
+import org.eclipse.jgit.transport.SshSessionFactory;
+import org.eclipse.jgit.transport.SshTransport;
+import org.eclipse.jgit.transport.Transport;
 import org.eclipse.jgit.util.FS;
 import org.eclipse.jgit.util.StringUtils;
 
 /**
  * Implementation of {@link TransportConfigCallback} which adds
  * a public/private key identity to ssh URLs if configured.
  */
-public class JGitTransportConfigCallback implements TransportConfigCallback {
+public class JGitTransportConfigCallback implements TransportConfigCallback
+{
     private SshSessionFactory sshSessionFactory = null;
 
-    public JGitTransportConfigCallback(GitScmProviderRepository repo, ScmLogger logger) {
-        if (repo.getFetchInfo().getProtocol().equals("ssh")) {
-            if (!StringUtils.isEmptyOrNull(repo.getPrivateKey()) && repo.getPassphrase()
== null) {
-                logger.debug("using private key with passphrase: " + repo.getPrivateKey());
-                sshSessionFactory = new UnprotectedPrivateKeySessionFactory(repo);
-            } else if (!StringUtils.isEmptyOrNull(repo.getPrivateKey()) && repo.getPassphrase()
!= null) {
-                logger.debug("using private key: " + repo.getPrivateKey());
-                sshSessionFactory = new ProtectedPrivateKeyFileSessionFactory(repo);
-            } else {
+    public JGitTransportConfigCallback( GitScmProviderRepository repo, ScmLogger logger )
+    {
+        if ( repo.getFetchInfo().getProtocol().equals( "ssh" ) )
+        {
+            if ( !StringUtils.isEmptyOrNull( repo.getPrivateKey() ) && repo.getPassphrase()
== null )
+            {
+                logger.debug( "using private key with passphrase: " + repo.getPrivateKey()
);
+                sshSessionFactory = new UnprotectedPrivateKeySessionFactory( repo );
+            }
+            else if ( !StringUtils.isEmptyOrNull( repo.getPrivateKey() ) && repo.getPassphrase()
!= null )
+            {
+                logger.debug( "using private key: " + repo.getPrivateKey() );
+                sshSessionFactory = new ProtectedPrivateKeyFileSessionFactory( repo );
+            }
+            else
+            {
                 sshSessionFactory = new SimpleSessionFactory();
             }
         }
     }
 
     @Override
-    public void configure(Transport transport) {
-        if (transport instanceof SshTransport) {
-            SshTransport sshTransport = (SshTransport) transport;
-            sshTransport.setSshSessionFactory(sshSessionFactory);
+    public void configure( Transport transport )
+    {
+        if ( transport instanceof SshTransport )
+        {
+            SshTransport sshTransport = ( SshTransport ) transport;
 
 Review comment:
   Will revert that change.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message