karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [1/2] karaf git commit: [KARAF-4861] Upgrade to sshd 1.4.0
Date Fri, 10 Mar 2017 12:20:24 GMT
Repository: karaf
Updated Branches:
  refs/heads/master 52ff2d2fb -> 9275458dd


[KARAF-4861] Upgrade to sshd 1.4.0

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/9117d473
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/9117d473
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/9117d473

Branch: refs/heads/master
Commit: 9117d473b4cafc1434178352c340262ade6d7922
Parents: 52ff2d2
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Wed Feb 15 08:37:30 2017 +0100
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Fri Mar 10 12:12:13 2017 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/karaf/client/Main.java   |  7 ++-----
 pom.xml                                               |  2 +-
 .../org/apache/karaf/shell/ssh/KarafAgentFactory.java | 13 +++++++------
 .../org/apache/karaf/shell/ssh/KnownHostsManager.java |  6 +++---
 .../java/org/apache/karaf/shell/ssh/SshAction.java    | 10 ++--------
 .../org/apache/karaf/tooling/client/ClientMojo.java   |  9 +++------
 .../org/apache/karaf/tooling/client/DeployMojo.java   | 14 +++-----------
 7 files changed, 21 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/9117d473/client/src/main/java/org/apache/karaf/client/Main.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/karaf/client/Main.java b/client/src/main/java/org/apache/karaf/client/Main.java
index 6615ed0..424b90b 100644
--- a/client/src/main/java/org/apache/karaf/client/Main.java
+++ b/client/src/main/java/org/apache/karaf/client/Main.java
@@ -34,7 +34,6 @@ import java.net.URL;
 import java.nio.charset.Charset;
 import java.nio.file.Paths;
 import java.security.KeyPair;
-import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.List;
@@ -56,8 +55,7 @@ import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.RuntimeSshException;
 import org.apache.sshd.common.channel.PtyMode;
-import org.apache.sshd.common.keyprovider.AbstractFileKeyPairProvider;
-import org.apache.sshd.common.util.SecurityUtils;
+import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
 import org.apache.sshd.common.util.io.NoCloseInputStream;
 import org.jline.terminal.Attributes;
 import org.jline.terminal.Attributes.ControlChar;
@@ -294,8 +292,7 @@ public class Main {
             is.close();
             agent.addIdentity(keyPair, user);
             if (keyFile != null) {
-                AbstractFileKeyPairProvider fileKeyPairProvider = SecurityUtils.createFileKeyPairProvider();
-                fileKeyPairProvider.setPaths(Collections.singleton(Paths.get(keyFile)));
+                FileKeyPairProvider fileKeyPairProvider = new FileKeyPairProvider(Paths.get(keyFile));
                 for (KeyPair key : fileKeyPairProvider.loadKeys()) {
                     agent.addIdentity(key, user);                
                 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/9117d473/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 4321812..5cd008b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -281,7 +281,7 @@
         <spring43.version>4.3.5.RELEASE_1</spring43.version>
         <spring.security31.version>3.1.4.RELEASE</spring.security31.version>
 
-        <sshd.version>1.2.0</sshd.version>
+        <sshd.version>1.4.0-SNAPSHOT</sshd.version>
         <derby-version>10.12.1.1</derby-version>
         <directory-version>2.0.0-M20</directory-version>
         <struts.bundle.version>1.3.10_1</struts.bundle.version>

http://git-wip-us.apache.org/repos/asf/karaf/blob/9117d473/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java
index cda3be1..61e69e1 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.net.URL;
 import java.security.KeyPair;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -32,8 +33,7 @@ import org.apache.sshd.agent.SshAgentServer;
 import org.apache.sshd.agent.common.AgentDelegate;
 import org.apache.sshd.agent.local.AgentImpl;
 import org.apache.sshd.agent.local.AgentServerProxy;
-import org.apache.sshd.agent.local.ChannelAgentForwarding;
-import org.apache.sshd.agent.local.ChannelAgentForwardingFactory;
+import org.apache.sshd.agent.local.LocalAgentFactory;
 import org.apache.sshd.common.FactoryManager;
 import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.channel.Channel;
@@ -47,11 +47,12 @@ public class KarafAgentFactory implements SshAgentFactory {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(KarafAgentFactory.class);
 
-    private final Map<String, AgentServerProxy> proxies = new ConcurrentHashMap<String,
AgentServerProxy>();
-    private final Map<String, SshAgent> locals = new ConcurrentHashMap<String, SshAgent>();
+    private final Map<String, AgentServerProxy> proxies = new ConcurrentHashMap<>();
+    private final Map<String, SshAgent> locals = new ConcurrentHashMap<>();
 
-    public NamedFactory<Channel> getChannelForwardingFactory() {
-        return new ChannelAgentForwardingFactory();
+    @Override
+    public List<NamedFactory<Channel>> getChannelForwardingFactories(FactoryManager
factoryManager) {
+        return LocalAgentFactory.DEFAULT_FORWARDING_CHANNELS;
     }
 
     public SshAgent createClient(FactoryManager manager) throws IOException {

http://git-wip-us.apache.org/repos/asf/karaf/blob/9117d473/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KnownHostsManager.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KnownHostsManager.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KnownHostsManager.java
index 933a7c3..ad0ed29 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KnownHostsManager.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KnownHostsManager.java
@@ -33,9 +33,9 @@ import java.security.PublicKey;
 import java.security.spec.InvalidKeySpecException;
 import java.security.spec.X509EncodedKeySpec;
 
-import org.apache.sshd.common.util.Base64;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import java.util.Base64;
 
 public class KnownHostsManager {
 	Logger LOG = LoggerFactory.getLogger(KnownHostsManager.class);
@@ -82,7 +82,7 @@ public class KnownHostsManager {
 			String serverAddress = lineParts[0];
 			String algorithm = lineParts[1];
 			if (checkServerAddress.equals(serverAddress) && checkAlgorithm.equals(algorithm))
{
-				byte[] key = Base64.decodeBase64(lineParts[2].getBytes());
+				byte[] key = Base64.getDecoder().decode(lineParts[2].getBytes());
 				KeyFactory keyFactory = KeyFactory.getInstance(algorithm);
 				X509EncodedKeySpec keySpec = new X509EncodedKeySpec(key);
 				return keyFactory.generatePublic(keySpec);
@@ -115,7 +115,7 @@ public class KnownHostsManager {
 		bw.append(serverKey.getAlgorithm());
 		bw.append(" ");
 		serverKey.getEncoded();
-		bw.append(new String(Base64.encodeBase64(serverKey.getEncoded()), "UTF-8"));
+		bw.append(new String(Base64.getEncoder().encode(serverKey.getEncoded()), "UTF-8"));
         bw.append("\n");
 	}
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/9117d473/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
index f704308..8a62b5f 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
@@ -24,11 +24,9 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInputStream;
-import java.lang.reflect.Field;
 import java.net.URL;
 import java.nio.file.Paths;
 import java.security.KeyPair;
-import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.List;
@@ -55,11 +53,8 @@ import org.apache.sshd.client.channel.ChannelShell;
 import org.apache.sshd.client.channel.ClientChannel;
 import org.apache.sshd.client.future.ConnectFuture;
 import org.apache.sshd.client.session.ClientSession;
-import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.channel.PtyMode;
-import org.apache.sshd.common.keyprovider.AbstractFileKeyPairProvider;
-import org.apache.sshd.common.util.SecurityUtils;
-import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
 import org.apache.sshd.common.util.io.NoCloseInputStream;
 import org.apache.sshd.common.util.io.NoCloseOutputStream;
 import org.jline.terminal.Attributes;
@@ -329,8 +324,7 @@ public class SshAction implements Action {
             is.close();
             agent.addIdentity(keyPair, user);
             if (keyFile != null) {
-                AbstractFileKeyPairProvider fileKeyPairProvider = SecurityUtils.createFileKeyPairProvider();
-                fileKeyPairProvider.setPaths(Collections.singleton(Paths.get(keyFile)));
+                FileKeyPairProvider fileKeyPairProvider = new FileKeyPairProvider(Paths.get(keyFile));
                 for (KeyPair key : fileKeyPairProvider.loadKeys()) {
                     agent.addIdentity(key, user);
                 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/9117d473/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/ClientMojo.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/ClientMojo.java
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/ClientMojo.java
index 3073ed0..7ab1908 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/ClientMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/ClientMojo.java
@@ -1,5 +1,4 @@
-/**
- *
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -34,8 +33,7 @@ import org.apache.sshd.client.future.ConnectFuture;
 import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.RuntimeSshException;
 
-import org.apache.sshd.common.keyprovider.AbstractFileKeyPairProvider;
-import org.apache.sshd.common.util.SecurityUtils;
+import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
 import org.fusesource.jansi.Ansi;
 import org.fusesource.jansi.Ansi.Color;
 import org.fusesource.jansi.AnsiConsole;
@@ -237,8 +235,7 @@ public class ClientMojo extends AbstractMojo {
             is.close();
             agent.addIdentity(keyPair, user);
             if (keyFile != null) {
-                AbstractFileKeyPairProvider fileKeyPairProvider = SecurityUtils.createFileKeyPairProvider();
-                fileKeyPairProvider.setPaths(Collections.singleton(keyFile.getAbsoluteFile().toPath()));
+                FileKeyPairProvider fileKeyPairProvider = new FileKeyPairProvider(keyFile.getAbsoluteFile().toPath());
                 for (KeyPair key : fileKeyPairProvider.loadKeys()) {
                     agent.addIdentity(key, user);
                 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/9117d473/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/DeployMojo.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/DeployMojo.java
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/DeployMojo.java
index 21c6f89..1c04563 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/DeployMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/client/DeployMojo.java
@@ -1,5 +1,4 @@
-/**
- *
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
@@ -19,7 +18,6 @@ package org.apache.karaf.tooling.client;
 
 import org.apache.karaf.tooling.utils.MojoSupport;
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
@@ -36,8 +34,7 @@ import org.apache.sshd.client.future.ConnectFuture;
 import org.apache.sshd.client.session.ClientSession;
 import org.apache.sshd.common.RuntimeSshException;
 
-import org.apache.sshd.common.keyprovider.AbstractFileKeyPairProvider;
-import org.apache.sshd.common.util.SecurityUtils;
+import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
 import org.fusesource.jansi.Ansi;
 import org.fusesource.jansi.Ansi.Color;
 import org.fusesource.jansi.AnsiConsole;
@@ -47,13 +44,10 @@ import javax.management.ObjectName;
 import javax.management.remote.JMXConnector;
 import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
-import javax.management.remote.MBeanServerForwarder;
-import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.Console;
 import java.io.File;
-import java.io.FileReader;
 import java.io.IOError;
 import java.io.IOException;
 import java.io.InputStream;
@@ -63,7 +57,6 @@ import java.io.StringWriter;
 import java.net.URL;
 import java.security.KeyPair;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.List;
@@ -259,8 +252,7 @@ public class DeployMojo extends MojoSupport {
             is.close();
             agent.addIdentity(keyPair, user);
             if (keyFile != null) {
-                AbstractFileKeyPairProvider fileKeyPairProvider = SecurityUtils.createFileKeyPairProvider();
-                fileKeyPairProvider.setPaths(Collections.singleton(keyFile.getAbsoluteFile().toPath()));
+                FileKeyPairProvider fileKeyPairProvider = new FileKeyPairProvider(keyFile.getAbsoluteFile().toPath());
                 for (KeyPair key : fileKeyPairProvider.loadKeys()) {
                     agent.addIdentity(key, user);
                 }


Mime
View raw message