mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 23:30:55 +03:00
minor
This commit is contained in:
@@ -137,7 +137,7 @@ public interface Config {
|
||||
|
||||
/**
|
||||
* Set the software version information for identification during SSH connection initialization. For example, {@code
|
||||
* "NET_3_0"}.
|
||||
* "SSHJ_0_1"}.
|
||||
*
|
||||
* @param version software version info
|
||||
*/
|
||||
|
||||
@@ -265,7 +265,7 @@ public class SSHClient
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate {@code username} using the {@code "publickey"} authentication method, with keys from some commons
|
||||
* Authenticate {@code username} using the {@code "publickey"} authentication method, with keys from some common
|
||||
* locations on the file system. This method relies on {@code ~/.ssh/id_rsa} and {@code ~/.ssh/id_dsa}.
|
||||
* <p/>
|
||||
* This method does not provide a way to specify a passphrase.
|
||||
|
||||
@@ -462,15 +462,13 @@ public class Buffer<T extends Buffer<T>> {
|
||||
}
|
||||
|
||||
public PublicKey readPublicKey() {
|
||||
PublicKey key = null;
|
||||
try {
|
||||
switch (KeyType.fromString(readString())) {
|
||||
case RSA: {
|
||||
BigInteger e = readMPInt();
|
||||
BigInteger n = readMPInt();
|
||||
KeyFactory keyFactory = SecurityUtils.getKeyFactory("RSA");
|
||||
key = keyFactory.generatePublic(new RSAPublicKeySpec(n, e));
|
||||
break;
|
||||
return keyFactory.generatePublic(new RSAPublicKeySpec(n, e));
|
||||
}
|
||||
case DSA: {
|
||||
BigInteger p = readMPInt();
|
||||
@@ -478,8 +476,7 @@ public class Buffer<T extends Buffer<T>> {
|
||||
BigInteger g = readMPInt();
|
||||
BigInteger y = readMPInt();
|
||||
KeyFactory keyFactory = SecurityUtils.getKeyFactory("DSA");
|
||||
key = keyFactory.generatePublic(new DSAPublicKeySpec(y, p, q, g));
|
||||
break;
|
||||
return keyFactory.generatePublic(new DSAPublicKeySpec(y, p, q, g));
|
||||
}
|
||||
default:
|
||||
assert false;
|
||||
@@ -487,12 +484,12 @@ public class Buffer<T extends Buffer<T>> {
|
||||
} catch (GeneralSecurityException e) {
|
||||
throw new SSHRuntimeException(e);
|
||||
}
|
||||
return key;
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T putPublicKey(PublicKey key) {
|
||||
KeyType type = KeyType.fromKey(key);
|
||||
final KeyType type = KeyType.fromKey(key);
|
||||
switch (type) {
|
||||
case RSA: {
|
||||
final RSAPublicKey rsaKey = (RSAPublicKey) key;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
*/
|
||||
package net.schmizz.sshj.common;
|
||||
|
||||
/** Represents unrecoverable exceptions in the {@code org.apache.commons.net.ssh} package. */
|
||||
/** Represents unrecoverable exceptions in the {@code net.schmizz.sshj} package. */
|
||||
public class SSHRuntimeException
|
||||
extends RuntimeException {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user