git commit: CAMEL-7039. Fix build issue due to dependency on newly introduced FileKeyPairProvider

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

git commit: CAMEL-7039. Fix build issue due to dependency on newly introduced FileKeyPairProvider

hadrian-3
Updated Branches:
  refs/heads/master dec4a2293 -> 6aebbb391


CAMEL-7039. Fix build issue due to dependency on newly introduced FileKeyPairProvider


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6aebbb39
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6aebbb39
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6aebbb39

Branch: refs/heads/master
Commit: 6aebbb391bd02a4bf04454202b4876c309d6fcab
Parents: dec4a22
Author: Hadrian Zbarcea <[hidden email]>
Authored: Wed Dec 11 10:44:51 2013 -0500
Committer: Hadrian Zbarcea <[hidden email]>
Committed: Wed Dec 11 10:44:51 2013 -0500

----------------------------------------------------------------------
 components/camel-ftp/pom.xml                    |   5 +
 .../file/remote/sftp/SftpServerTestSupport.java |   2 +-
 components/camel-jsch/pom.xml                   |   5 +
 .../component/jsch/ScpServerTestSupport.java    |   3 +-
 .../component/ssh/FileKeyPairProvider.java      | 114 +++++++++++++++++++
 .../component/ssh/FileKeyPairProvider.java      | 114 -------------------
 6 files changed, 127 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6aebbb39/components/camel-ftp/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-ftp/pom.xml b/components/camel-ftp/pom.xml
index 0411e35..6029403 100644
--- a/components/camel-ftp/pom.xml
+++ b/components/camel-ftp/pom.xml
@@ -65,6 +65,11 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-ssh</artifactId>      
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/camel/blob/6aebbb39/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpServerTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpServerTestSupport.java b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpServerTestSupport.java
index 72d09f4..0c56501 100644
--- a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpServerTestSupport.java
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpServerTestSupport.java
@@ -21,10 +21,10 @@ import java.security.PublicKey;
 import java.util.Arrays;
 
 import org.apache.camel.component.file.remote.BaseServerTestSupport;
+import org.apache.camel.component.ssh.FileKeyPairProvider;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.sshd.SshServer;
 import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
 import org.apache.sshd.server.Command;
 import org.apache.sshd.server.PublickeyAuthenticator;
 import org.apache.sshd.server.command.ScpCommandFactory;

http://git-wip-us.apache.org/repos/asf/camel/blob/6aebbb39/components/camel-jsch/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-jsch/pom.xml b/components/camel-jsch/pom.xml
index 25c314f..cdca5b8 100644
--- a/components/camel-jsch/pom.xml
+++ b/components/camel-jsch/pom.xml
@@ -62,6 +62,11 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-ssh</artifactId>
+      <scope>test</scope>
+    </dependency>  
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/camel/blob/6aebbb39/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpServerTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpServerTestSupport.java b/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpServerTestSupport.java
index c207742..8d56ff1 100644
--- a/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpServerTestSupport.java
+++ b/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpServerTestSupport.java
@@ -29,12 +29,13 @@ import com.jcraft.jsch.JSchException;
 import com.jcraft.jsch.Session;
 import com.jcraft.jsch.UserInfo;
 
+import org.apache.camel.component.ssh.FileKeyPairProvider;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.FileUtil;
 import org.apache.sshd.SshServer;
 import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
+// import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
 import org.apache.sshd.server.Command;
 import org.apache.sshd.server.PasswordAuthenticator;
 import org.apache.sshd.server.PublickeyAuthenticator;

http://git-wip-us.apache.org/repos/asf/camel/blob/6aebbb39/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/FileKeyPairProvider.java
----------------------------------------------------------------------
diff --git a/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/FileKeyPairProvider.java b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/FileKeyPairProvider.java
new file mode 100644
index 0000000..e4f2b88
--- /dev/null
+++ b/components/camel-ssh/src/main/java/org/apache/camel/component/ssh/FileKeyPairProvider.java
@@ -0,0 +1,114 @@
+/*
+ * 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.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.camel.component.ssh;
+
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.security.KeyPair;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.sshd.common.keyprovider.AbstractKeyPairProvider;
+import org.apache.sshd.common.util.SecurityUtils;
+import org.bouncycastle.openssl.PEMDecryptorProvider;
+import org.bouncycastle.openssl.PEMEncryptedKeyPair;
+import org.bouncycastle.openssl.PEMKeyPair;
+import org.bouncycastle.openssl.PEMParser;
+import org.bouncycastle.openssl.PasswordFinder;
+import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
+import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder;
+
+/**
+ * This host key provider loads private keys from the specified files.
+ *
+ * Note that this class has a direct dependency on BouncyCastle and won't work
+ * unless it has been correctly registered as a security provider.
+ *
+ * @author <a href="mailto:[hidden email]">Apache MINA SSHD Project</a>
+ */
+public class FileKeyPairProvider extends AbstractKeyPairProvider {
+
+    private String[] files;
+    private PasswordFinder passwordFinder;
+
+    public FileKeyPairProvider() {
+    }
+
+    public FileKeyPairProvider(String[] files) {
+        this.files = files;
+    }
+
+    public FileKeyPairProvider(String[] files, PasswordFinder passwordFinder) {
+        this.files = files;
+        this.passwordFinder = passwordFinder;
+    }
+
+    public String[] getFiles() {
+        return files;
+    }
+
+    public void setFiles(String[] files) {
+        this.files = files;
+    }
+
+    public PasswordFinder getPasswordFinder() {
+        return passwordFinder;
+    }
+
+    public void setPasswordFinder(PasswordFinder passwordFinder) {
+        this.passwordFinder = passwordFinder;
+    }
+
+    public KeyPair[] loadKeys() {
+        if (!SecurityUtils.isBouncyCastleRegistered()) {
+            throw new IllegalStateException("BouncyCastle must be registered as a JCE provider");
+        }
+        List<KeyPair> keys = new ArrayList<KeyPair>();
+        for (int i = 0; i < files.length; i++) {
+            try {
+                PEMParser r = new PEMParser(new InputStreamReader(new FileInputStream(files[i])));
+                try {
+                    Object o = r.readObject();
+                    
+                    JcaPEMKeyConverter pemConverter = new JcaPEMKeyConverter();
+                    pemConverter.setProvider("BC");
+                    if (passwordFinder != null && o instanceof PEMEncryptedKeyPair) {
+                        JcePEMDecryptorProviderBuilder decryptorBuilder = new JcePEMDecryptorProviderBuilder();
+                        PEMDecryptorProvider pemDecryptor = decryptorBuilder.build(passwordFinder.getPassword());
+                        o = pemConverter.getKeyPair(((PEMEncryptedKeyPair) o).decryptKeyPair(pemDecryptor));
+                    }
+                    
+                    if (o instanceof PEMKeyPair) {
+                        o = pemConverter.getKeyPair((PEMKeyPair)o);
+                        keys.add((KeyPair) o);
+                    } else if (o instanceof KeyPair) {
+                        keys.add((KeyPair) o);
+                    }
+                    
+                } finally {
+                    r.close();
+                }
+            } catch (Exception e) {
+                log.warn("Unable to read key {}: {}", files[i], e);
+            }
+        }
+        return keys.toArray(new KeyPair[keys.size()]);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/6aebbb39/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/FileKeyPairProvider.java
----------------------------------------------------------------------
diff --git a/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/FileKeyPairProvider.java b/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/FileKeyPairProvider.java
deleted file mode 100644
index e4f2b88..0000000
--- a/components/camel-ssh/src/test/java/org/apache/camel/component/ssh/FileKeyPairProvider.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.camel.component.ssh;
-
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.security.KeyPair;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.sshd.common.keyprovider.AbstractKeyPairProvider;
-import org.apache.sshd.common.util.SecurityUtils;
-import org.bouncycastle.openssl.PEMDecryptorProvider;
-import org.bouncycastle.openssl.PEMEncryptedKeyPair;
-import org.bouncycastle.openssl.PEMKeyPair;
-import org.bouncycastle.openssl.PEMParser;
-import org.bouncycastle.openssl.PasswordFinder;
-import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
-import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder;
-
-/**
- * This host key provider loads private keys from the specified files.
- *
- * Note that this class has a direct dependency on BouncyCastle and won't work
- * unless it has been correctly registered as a security provider.
- *
- * @author <a href="mailto:[hidden email]">Apache MINA SSHD Project</a>
- */
-public class FileKeyPairProvider extends AbstractKeyPairProvider {
-
-    private String[] files;
-    private PasswordFinder passwordFinder;
-
-    public FileKeyPairProvider() {
-    }
-
-    public FileKeyPairProvider(String[] files) {
-        this.files = files;
-    }
-
-    public FileKeyPairProvider(String[] files, PasswordFinder passwordFinder) {
-        this.files = files;
-        this.passwordFinder = passwordFinder;
-    }
-
-    public String[] getFiles() {
-        return files;
-    }
-
-    public void setFiles(String[] files) {
-        this.files = files;
-    }
-
-    public PasswordFinder getPasswordFinder() {
-        return passwordFinder;
-    }
-
-    public void setPasswordFinder(PasswordFinder passwordFinder) {
-        this.passwordFinder = passwordFinder;
-    }
-
-    public KeyPair[] loadKeys() {
-        if (!SecurityUtils.isBouncyCastleRegistered()) {
-            throw new IllegalStateException("BouncyCastle must be registered as a JCE provider");
-        }
-        List<KeyPair> keys = new ArrayList<KeyPair>();
-        for (int i = 0; i < files.length; i++) {
-            try {
-                PEMParser r = new PEMParser(new InputStreamReader(new FileInputStream(files[i])));
-                try {
-                    Object o = r.readObject();
-                    
-                    JcaPEMKeyConverter pemConverter = new JcaPEMKeyConverter();
-                    pemConverter.setProvider("BC");
-                    if (passwordFinder != null && o instanceof PEMEncryptedKeyPair) {
-                        JcePEMDecryptorProviderBuilder decryptorBuilder = new JcePEMDecryptorProviderBuilder();
-                        PEMDecryptorProvider pemDecryptor = decryptorBuilder.build(passwordFinder.getPassword());
-                        o = pemConverter.getKeyPair(((PEMEncryptedKeyPair) o).decryptKeyPair(pemDecryptor));
-                    }
-                    
-                    if (o instanceof PEMKeyPair) {
-                        o = pemConverter.getKeyPair((PEMKeyPair)o);
-                        keys.add((KeyPair) o);
-                    } else if (o instanceof KeyPair) {
-                        keys.add((KeyPair) o);
-                    }
-                    
-                } finally {
-                    r.close();
-                }
-            } catch (Exception e) {
-                log.warn("Unable to read key {}: {}", files[i], e);
-            }
-        }
-        return keys.toArray(new KeyPair[keys.size()]);
-    }
-
-}