mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 15:20:54 +03:00
Improvements per JVE.
This commit is contained in:
@@ -426,18 +426,7 @@ public class Buffer<T extends Buffer<T>> {
|
||||
public PublicKey readPublicKey()
|
||||
throws BufferException {
|
||||
try {
|
||||
final KeyType type = KeyType.fromString(readString());
|
||||
switch (type) {
|
||||
case RSA:
|
||||
case DSA:
|
||||
return type.readPubKeyFromBuffer(this);
|
||||
default:
|
||||
if (SecurityUtils.isBouncyCastleRegistered()) {
|
||||
return type.readPubKeyFromBuffer(this);
|
||||
} else {
|
||||
throw new BufferException("BouncyCastle is required to read a key of type " + type);
|
||||
}
|
||||
}
|
||||
return KeyType.fromString(readString()).readPubKeyFromBuffer(this);
|
||||
} catch (GeneralSecurityException e) {
|
||||
throw new SSHRuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -116,6 +116,9 @@ public enum KeyType {
|
||||
@Override
|
||||
public PublicKey readPubKeyFromBuffer(Buffer<?> buf)
|
||||
throws GeneralSecurityException {
|
||||
if (!SecurityUtils.isBouncyCastleRegistered()) {
|
||||
throw new GeneralSecurityException("BouncyCastle is required to read a key of type " + sType);
|
||||
}
|
||||
try {
|
||||
// final String algo = buf.readString(); it has been already read
|
||||
final String curveName = buf.readString();
|
||||
|
||||
@@ -57,7 +57,7 @@ public class OpenSSHKnownHosts
|
||||
try {
|
||||
// Read in the file, storing each line as an entry
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
while ((line = br.readLine()) != null) {
|
||||
try {
|
||||
HostEntry entry = entryFactory.parseEntry(line);
|
||||
if (entry != null) {
|
||||
@@ -65,6 +65,9 @@ public class OpenSSHKnownHosts
|
||||
}
|
||||
} catch (SSHException ignore) {
|
||||
log.debug("Bad line ({}): {} ", ignore.toString(), line);
|
||||
} catch (SSHRuntimeException ignore) {
|
||||
log.debug("Failed to process line ({}): {} ", ignore.toString(), line);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
IOUtils.closeQuietly(br);
|
||||
|
||||
Reference in New Issue
Block a user