Search in sources :

Example 1 with UnsupportedHostsKeyTypeException

use of com.jn.agileway.ssh.client.transport.hostkey.UnsupportedHostsKeyTypeException in project agileway by fangjinuo.

the class PublicKeyCodecs method decode.

public static PublicKey decode(byte[] key) {
    try {
        Buffer<?> buffer = new Buffer.PlainBuffer(key);
        final String keyType = extractKeyType(buffer);
        if (keyType == null) {
            throw new IllegalSshKeyException();
        }
        PublicKeyCodec codec = PublicKeyCodecRegistry.getInstance().get(keyType);
        if (codec == null) {
            throw new UnsupportedHostsKeyTypeException(keyType);
        }
        return codec.decode(buffer.remainingRawBytes());
    } catch (Buffer.BufferException e) {
        throw new IllegalSshKeyException(e);
    }
}
Also used : Buffer(com.jn.agileway.ssh.client.utils.Buffer) UnsupportedHostsKeyTypeException(com.jn.agileway.ssh.client.transport.hostkey.UnsupportedHostsKeyTypeException) IllegalSshKeyException(com.jn.agileway.ssh.client.transport.hostkey.IllegalSshKeyException)

Aggregations

IllegalSshKeyException (com.jn.agileway.ssh.client.transport.hostkey.IllegalSshKeyException)1 UnsupportedHostsKeyTypeException (com.jn.agileway.ssh.client.transport.hostkey.UnsupportedHostsKeyTypeException)1 Buffer (com.jn.agileway.ssh.client.utils.Buffer)1