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()
|
public PublicKey readPublicKey()
|
||||||
throws BufferException {
|
throws BufferException {
|
||||||
try {
|
try {
|
||||||
final KeyType type = KeyType.fromString(readString());
|
return KeyType.fromString(readString()).readPubKeyFromBuffer(this);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (GeneralSecurityException e) {
|
} catch (GeneralSecurityException e) {
|
||||||
throw new SSHRuntimeException(e);
|
throw new SSHRuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,6 +116,9 @@ public enum KeyType {
|
|||||||
@Override
|
@Override
|
||||||
public PublicKey readPubKeyFromBuffer(Buffer<?> buf)
|
public PublicKey readPubKeyFromBuffer(Buffer<?> buf)
|
||||||
throws GeneralSecurityException {
|
throws GeneralSecurityException {
|
||||||
|
if (!SecurityUtils.isBouncyCastleRegistered()) {
|
||||||
|
throw new GeneralSecurityException("BouncyCastle is required to read a key of type " + sType);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// final String algo = buf.readString(); it has been already read
|
// final String algo = buf.readString(); it has been already read
|
||||||
final String curveName = buf.readString();
|
final String curveName = buf.readString();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class OpenSSHKnownHosts
|
|||||||
try {
|
try {
|
||||||
// Read in the file, storing each line as an entry
|
// Read in the file, storing each line as an entry
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null) {
|
||||||
try {
|
try {
|
||||||
HostEntry entry = entryFactory.parseEntry(line);
|
HostEntry entry = entryFactory.parseEntry(line);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
@@ -65,7 +65,10 @@ public class OpenSSHKnownHosts
|
|||||||
}
|
}
|
||||||
} catch (SSHException ignore) {
|
} catch (SSHException ignore) {
|
||||||
log.debug("Bad line ({}): {} ", ignore.toString(), line);
|
log.debug("Bad line ({}): {} ", ignore.toString(), line);
|
||||||
|
} catch (SSHRuntimeException ignore) {
|
||||||
|
log.debug("Failed to process line ({}): {} ", ignore.toString(), line);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeQuietly(br);
|
IOUtils.closeQuietly(br);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user