Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinston Prakash2012-02-10 21:23:17 -0500
committerWinston Prakash2012-02-10 21:23:17 -0500
commit27464da5b9aae3bd2f9f3fd86bc73f534ee06cdc (patch)
tree1f4ea310032fcd4689f373769ce5cd165344c117
parentecd1d82c7e8427e3f1d844bd776e7e808dffb4e2 (diff)
downloadorg.eclipse.hudson.core-27464da5b9aae3bd2f9f3fd86bc73f534ee06cdc.tar.gz
org.eclipse.hudson.core-27464da5b9aae3bd2f9f3fd86bc73f534ee06cdc.tar.xz
org.eclipse.hudson.core-27464da5b9aae3bd2f9f3fd86bc73f534ee06cdc.zip
Remove trilead SSH dependency, because its development has discontinued. Instead use Ganymede SSH library. Also remove the dependency on Logkit
-rw-r--r--hudson-core/pom.xml17
-rw-r--r--hudson-core/src/main/java/hudson/console/AnnotatedLargeText.java6
-rw-r--r--hudson-core/src/main/java/hudson/model/UpdateSite.java9
-rw-r--r--hudson-core/src/main/java/hudson/model/UsageStatistics.java4
-rw-r--r--hudson-core/src/main/java/hudson/util/ConsistentHash.java3
-rw-r--r--hudson-core/src/main/java/hudson/util/FormFieldValidator.java2
-rw-r--r--hudson-core/src/main/java/hudson/util/FormValidation.java23
-rw-r--r--hudson-core/src/main/java/hudson/util/Protector.java7
-rw-r--r--hudson-core/src/main/java/hudson/util/Scrambler.java7
-rw-r--r--hudson-core/src/main/java/hudson/util/Secret.java6
-rw-r--r--hudson-core/src/main/java/hudson/util/ssh/SFTPClient.java8
11 files changed, 39 insertions, 53 deletions
diff --git a/hudson-core/pom.xml b/hudson-core/pom.xml
index 4c7ec616..88216cff 100644
--- a/hudson-core/pom.xml
+++ b/hudson-core/pom.xml
@@ -35,7 +35,6 @@
<crypto-util.version>1.0</crypto-util.version>
<jtidy.version>r938</jtidy.version>
<jna-posix.version>1.0.3</jna-posix.version>
- <trilead-putty-extension.version>1.0</trilead-putty-extension.version>
<stapler.version>1.155</stapler.version>
<json-lib.version>2.4</json-lib.version>
<annotation-indexer.version>1.2</annotation-indexer.version>
@@ -344,11 +343,6 @@
</dependency>
<dependency>
- <groupId>org.kohsuke</groupId>
- <artifactId>trilead-putty-extension</artifactId>
- <version>${trilead-putty-extension.version}</version>
- </dependency>
- <dependency>
<groupId>org.jruby.ext.posix</groupId>
<artifactId>jna-posix</artifactId>
<version>${jna-posix.version}</version>
@@ -621,11 +615,6 @@
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
- <dependency>
- <groupId>logkit</groupId>
- <artifactId>logkit</artifactId>
- <version>${logkit.version}</version>
- </dependency>
<!--
| ^ end of optional commons-logging dependencies
-->
@@ -737,6 +726,12 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.jvnet.hudson</groupId>
+ <artifactId>ganymed-ssh-2</artifactId>
+ <version>build260</version>
+ <type>jar</type>
+ </dependency>
</dependencies>
<reporting>
diff --git a/hudson-core/src/main/java/hudson/console/AnnotatedLargeText.java b/hudson-core/src/main/java/hudson/console/AnnotatedLargeText.java
index d4b80d53..cea577c1 100644
--- a/hudson-core/src/main/java/hudson/console/AnnotatedLargeText.java
+++ b/hudson-core/src/main/java/hudson/console/AnnotatedLargeText.java
@@ -16,7 +16,6 @@
package hudson.console;
-import com.trilead.ssh2.crypto.Base64;
import hudson.model.Hudson;
import hudson.remoting.ObjectInputStreamEx;
import hudson.util.IOException2;
@@ -45,6 +44,7 @@ import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import static java.lang.Math.abs;
+import org.apache.commons.codec.binary.Base64;
/**
* Extension to {@link LargeText} that handles annotations by {@link ConsoleAnnotator}.
@@ -112,7 +112,7 @@ public class AnnotatedLargeText<T> extends LargeText {
sym.init(Cipher.DECRYPT_MODE, Hudson.getInstance().getSecretKeyAsAES128());
ObjectInputStream ois = new ObjectInputStreamEx(new GZIPInputStream(
- new CipherInputStream(new ByteArrayInputStream(Base64.decode(base64.toCharArray())),sym)),
+ new CipherInputStream(new ByteArrayInputStream(Base64.decodeBase64(base64)),sym)),
Hudson.getInstance().pluginManager.uberClassLoader);
long timestamp = ois.readLong();
if (TimeUnit2.HOURS.toMillis(1) > abs(System.currentTimeMillis()-timestamp))
@@ -156,7 +156,7 @@ public class AnnotatedLargeText<T> extends LargeText {
oos.close();
StaplerResponse rsp = Stapler.getCurrentResponse();
if (rsp!=null)
- rsp.setHeader("X-ConsoleAnnotator", new String(Base64.encode(baos.toByteArray())));
+ rsp.setHeader("X-ConsoleAnnotator", new String(Base64.encodeBase64(baos.toByteArray())));
} catch (GeneralSecurityException e) {
throw new IOException2(e);
}
diff --git a/hudson-core/src/main/java/hudson/model/UpdateSite.java b/hudson-core/src/main/java/hudson/model/UpdateSite.java
index 86356dd2..1fc3bdbd 100644
--- a/hudson-core/src/main/java/hudson/model/UpdateSite.java
+++ b/hudson-core/src/main/java/hudson/model/UpdateSite.java
@@ -57,9 +57,8 @@ import java.security.cert.X509Certificate;
import java.security.cert.CertificateFactory;
import java.security.cert.TrustAnchor;
-import com.trilead.ssh2.crypto.Base64;
-
import javax.servlet.ServletContext;
+import org.apache.commons.codec.binary.Base64;
/**
@@ -160,7 +159,7 @@ public class UpdateSite {
{// load and verify certificates
CertificateFactory cf = CertificateFactory.getInstance("X509");
for (Object cert : o.getJSONArray("certificates")) {
- X509Certificate c = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(Base64.decode(cert.toString().toCharArray())));
+ X509Certificate c = (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(Base64.decodeBase64(cert.toString())));
c.checkValidity();
certs.add(c);
}
@@ -188,14 +187,14 @@ public class UpdateSite {
// did the digest match? this is not a part of the signature validation, but if we have a bug in the c14n
// (which is more likely than someone tampering with update center), we can tell
- String computedDigest = new String(Base64.encode(sha1.digest()));
+ String computedDigest = new String(Base64.encodeBase64(sha1.digest()));
String providedDigest = signature.getString("digest");
if (!computedDigest.equalsIgnoreCase(providedDigest)) {
LOGGER.severe("Digest mismatch: "+computedDigest+" vs "+providedDigest);
return false;
}
- if (!sig.verify(Base64.decode(signature.getString("signature").toCharArray()))) {
+ if (!sig.verify(Base64.decodeBase64(signature.getString("signature")))) {
LOGGER.severe("Signature in the update center doesn't match with the certificate");
return false;
}
diff --git a/hudson-core/src/main/java/hudson/model/UsageStatistics.java b/hudson-core/src/main/java/hudson/model/UsageStatistics.java
index 0fae9b00..3d87163b 100644
--- a/hudson-core/src/main/java/hudson/model/UsageStatistics.java
+++ b/hudson-core/src/main/java/hudson/model/UsageStatistics.java
@@ -16,7 +16,6 @@
package hudson.model;
-import com.trilead.ssh2.crypto.Base64;
import hudson.PluginWrapper;
import hudson.Util;
import hudson.Extension;
@@ -46,6 +45,7 @@ import java.security.spec.X509EncodedKeySpec;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.GZIPOutputStream;
+import org.apache.commons.codec.binary.Base64;
/**
* @author Kohsuke Kawaguchi
@@ -172,7 +172,7 @@ public class UsageStatistics extends PageDecorator {
o.write(w);
w.close();
- return new String(Base64.encode(baos.toByteArray()));
+ return new String(Base64.encodeBase64(baos.toByteArray()));
} catch (GeneralSecurityException e) {
throw new Error(e); // impossible
}
diff --git a/hudson-core/src/main/java/hudson/util/ConsistentHash.java b/hudson-core/src/main/java/hudson/util/ConsistentHash.java
index 2cb2456e..59b64978 100644
--- a/hudson-core/src/main/java/hudson/util/ConsistentHash.java
+++ b/hudson-core/src/main/java/hudson/util/ConsistentHash.java
@@ -16,8 +16,7 @@
package hudson.util;
-import com.trilead.ssh2.crypto.digest.MD5;
-
+import ch.ethz.ssh2.crypto.digest.MD5;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
diff --git a/hudson-core/src/main/java/hudson/util/FormFieldValidator.java b/hudson-core/src/main/java/hudson/util/FormFieldValidator.java
index 7005f5b7..b62d79ab 100644
--- a/hudson-core/src/main/java/hudson/util/FormFieldValidator.java
+++ b/hudson-core/src/main/java/hudson/util/FormFieldValidator.java
@@ -606,7 +606,7 @@ public abstract class FormFieldValidator {
return;
}
- com.trilead.ssh2.crypto.Base64.decode(v.toCharArray());
+ org.apache.commons.codec.binary.Base64.decodeBase64(v);
ok();
} catch (IOException e) {
fail();
diff --git a/hudson-core/src/main/java/hudson/util/FormValidation.java b/hudson-core/src/main/java/hudson/util/FormValidation.java
index ff60bd6a..e3c953eb 100644
--- a/hudson-core/src/main/java/hudson/util/FormValidation.java
+++ b/hudson-core/src/main/java/hudson/util/FormValidation.java
@@ -36,6 +36,7 @@ import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Locale;
+import org.apache.commons.codec.binary.Base64;
/**
* Represents the result of the form field validation.
@@ -369,21 +370,19 @@ public abstract class FormValidation extends IOException implements HttpResponse
* @since 1.305
*/
public static FormValidation validateBase64(String value, boolean allowWhitespace, boolean allowEmpty, String errorMessage) {
- try {
- String v = value;
- if(!allowWhitespace) {
- if(v.indexOf(' ')>=0 || v.indexOf('\n')>=0)
- return error(errorMessage);
- }
- v=v.trim();
- if(!allowEmpty && v.length()==0)
+ String v = value;
+ if (!allowWhitespace) {
+ if (v.indexOf(' ') >= 0 || v.indexOf('\n') >= 0) {
return error(errorMessage);
-
- com.trilead.ssh2.crypto.Base64.decode(v.toCharArray());
- return ok();
- } catch (IOException e) {
+ }
+ }
+ v = v.trim();
+ if (!allowEmpty && v.length() == 0) {
return error(errorMessage);
}
+
+ Base64.decodeBase64(v);
+ return ok();
}
/**
diff --git a/hudson-core/src/main/java/hudson/util/Protector.java b/hudson-core/src/main/java/hudson/util/Protector.java
index 13f3d31a..ffc96ac4 100644
--- a/hudson-core/src/main/java/hudson/util/Protector.java
+++ b/hudson-core/src/main/java/hudson/util/Protector.java
@@ -23,8 +23,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.GeneralSecurityException;
import java.security.NoSuchAlgorithmException;
-
-import com.trilead.ssh2.crypto.Base64;
+import org.apache.commons.codec.binary.Base64;
/**
* Encrypt/decrypt data by using a "session" key that only lasts for
@@ -42,7 +41,7 @@ public class Protector {
try {
Cipher cipher = Secret.getCipher(ALGORITHM);
cipher.init(Cipher.ENCRYPT_MODE, DES_KEY);
- return new String(Base64.encode(cipher.doFinal((secret+ MAGIC).getBytes("UTF-8"))));
+ return new String(Base64.encodeBase64(cipher.doFinal((secret+ MAGIC).getBytes("UTF-8"))));
} catch (GeneralSecurityException e) {
throw new Error(e); // impossible
} catch (UnsupportedEncodingException e) {
@@ -58,7 +57,7 @@ public class Protector {
try {
Cipher cipher = Secret.getCipher(ALGORITHM);
cipher.init(Cipher.DECRYPT_MODE, DES_KEY);
- String plainText = new String(cipher.doFinal(Base64.decode(data.toCharArray())), "UTF-8");
+ String plainText = new String(cipher.doFinal(Base64.decodeBase64(data)), "UTF-8");
if(plainText.endsWith(MAGIC))
return plainText.substring(0,plainText.length()-3);
return null;
diff --git a/hudson-core/src/main/java/hudson/util/Scrambler.java b/hudson-core/src/main/java/hudson/util/Scrambler.java
index e1505fa9..0148bd00 100644
--- a/hudson-core/src/main/java/hudson/util/Scrambler.java
+++ b/hudson-core/src/main/java/hudson/util/Scrambler.java
@@ -16,10 +16,9 @@
package hudson.util;
-import com.trilead.ssh2.crypto.Base64;
-
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import org.apache.commons.codec.binary.Base64;
/**
* Used when storing passwords in configuration files.
@@ -36,7 +35,7 @@ public class Scrambler {
public static String scramble(String secret) {
if(secret==null) return null;
try {
- return new String(Base64.encode(secret.getBytes("UTF-8")));
+ return new String(Base64.encodeBase64(secret.getBytes("UTF-8")));
} catch (UnsupportedEncodingException e) {
throw new Error(e); // impossible
}
@@ -45,7 +44,7 @@ public class Scrambler {
public static String descramble(String scrambled) {
if(scrambled==null) return null;
try {
- return new String(Base64.decode(scrambled.toCharArray()),"UTF-8");
+ return new String(Base64.decodeBase64(scrambled),"UTF-8");
} catch (IOException e) {
return ""; // corrupted data.
}
diff --git a/hudson-core/src/main/java/hudson/util/Secret.java b/hudson-core/src/main/java/hudson/util/Secret.java
index 71860c51..fe0ead08 100644
--- a/hudson-core/src/main/java/hudson/util/Secret.java
+++ b/hudson-core/src/main/java/hudson/util/Secret.java
@@ -21,7 +21,6 @@ import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
-import com.trilead.ssh2.crypto.Base64;
import hudson.model.Hudson;
import hudson.Util;
import org.kohsuke.stapler.Stapler;
@@ -32,6 +31,7 @@ import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.security.GeneralSecurityException;
+import org.apache.commons.codec.binary.Base64;
/**
* Glorified {@link String} that uses encryption in the persisted form, to avoid accidental exposure of a secret.
@@ -107,7 +107,7 @@ public final class Secret implements Serializable {
Cipher cipher = getCipher("AES");
cipher.init(Cipher.ENCRYPT_MODE, getKey());
// add the magic suffix which works like a check sum.
- return new String(Base64.encode(cipher.doFinal((value+MAGIC).getBytes("UTF-8"))));
+ return new String(Base64.encodeBase64(cipher.doFinal((value+MAGIC).getBytes("UTF-8"))));
} catch (GeneralSecurityException e) {
throw new Error(e); // impossible
} catch (UnsupportedEncodingException e) {
@@ -124,7 +124,7 @@ public final class Secret implements Serializable {
try {
Cipher cipher = getCipher("AES");
cipher.init(Cipher.DECRYPT_MODE, getKey());
- String plainText = new String(cipher.doFinal(Base64.decode(data.toCharArray())), "UTF-8");
+ String plainText = new String(cipher.doFinal(Base64.decodeBase64(data)), "UTF-8");
if(plainText.endsWith(MAGIC))
return new Secret(plainText.substring(0,plainText.length()-MAGIC.length()));
return null;
diff --git a/hudson-core/src/main/java/hudson/util/ssh/SFTPClient.java b/hudson-core/src/main/java/hudson/util/ssh/SFTPClient.java
index cba04c29..94bce493 100644
--- a/hudson-core/src/main/java/hudson/util/ssh/SFTPClient.java
+++ b/hudson-core/src/main/java/hudson/util/ssh/SFTPClient.java
@@ -14,12 +14,8 @@
package hudson.util.ssh;
-import com.trilead.ssh2.Connection;
-import com.trilead.ssh2.SFTPException;
-import com.trilead.ssh2.SFTPv3Client;
-import com.trilead.ssh2.SFTPv3FileAttributes;
-import com.trilead.ssh2.SFTPv3FileHandle;
-import com.trilead.ssh2.sftp.ErrorCodes;
+import ch.ethz.ssh2.*;
+import ch.ethz.ssh2.sftp.ErrorCodes;
import hudson.util.IOException2;
import java.io.IOException;

Back to the top