/** * Reads an SSH string * * @param cs the charset to use for decoding * * @return the string as a Java {@code String} */ public String readString(Charset cs) throws BufferException { int len = readUInt32AsInt(); if (len < 0 || len > 32768) { throw new BufferException("Bad item length: " + len); } ensureAvailable(len); String s = new String(data, rpos, len, cs); rpos += len; return s; }
/** * Reads an SSH string * * @param cs the charset to use for decoding * * @return the string as a Java {@code String} */ public String readString(Charset cs) throws BufferException { int len = readUInt32AsInt(); if (len < 0 || len > 32768) { throw new BufferException("Bad item length: " + len); } ensureAvailable(len); String s = new String(data, rpos, len, cs); rpos += len; return s; }
/** * Reads an SSH string * * @return the string as a Java {@code String} */ public String readString() throws BufferException { int len = readUInt32AsInt(); if (len < 0 || len > 32768) throw new BufferException("Bad item length: " + len); ensureAvailable(len); String s; try { s = new String(data, rpos, len, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new SSHRuntimeException(e); } rpos += len; return s; }
/** * Read an SSH byte-array * * @return the byte-array read */ public byte[] readBytes() throws BufferException { int len = readUInt32AsInt(); if (len < 0 || len > 32768) throw new BufferException("Bad item length: " + len); byte[] b = new byte[len]; readRawBytes(b); return b; }
/** * Read an SSH byte-array * * @return the byte-array read */ public byte[] readBytes() throws BufferException { int len = readUInt32AsInt(); if (len < 0 || len > 32768) throw new BufferException("Bad item length: " + len); byte[] b = new byte[len]; readRawBytes(b); return b; }
public PublicKey readPublicKey() throws BufferException { KeyType keyType = KeyType.fromString(readString()); try { return keyType.readPubKeyFromBuffer(this); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } catch (UnsupportedOperationException uoe) { throw new BufferException("Could not decode keytype " + keyType); } }
public long readUInt64() throws BufferException { long uint64 = (readUInt32() << 32) + (readUInt32() & 0xffffffffL); if (uint64 < 0) throw new BufferException("Cannot handle values > Long.MAX_VALUE"); return uint64; }
protected void ensureAvailable(int a) throws BufferException { if (available() < a) { throw new BufferException("Underflow"); } }
protected void ensureAvailable(int a) throws BufferException { if (available() < a) throw new BufferException("Underflow"); }
public long readUInt64() throws BufferException { long uint64 = (readUInt32() << 32) + (readUInt32() & 0xffffffffL); if (uint64 < 0) throw new BufferException("Cannot handle values > Long.MAX_VALUE"); return uint64; }
/** * Read an SSH byte-array * * @return the byte-array read */ public byte[] readBytes() throws BufferException { int len = readUInt32AsInt(); if (len < 0 || len > 32768) throw new BufferException("Bad item length: " + len); byte[] b = new byte[len]; readRawBytes(b); return b; }
protected void ensureAvailable(int a) throws BufferException { if (available() < a) { throw new BufferException("Underflow"); } }
public PublicKey readPublicKey() throws BufferException { KeyType keyType = KeyType.fromString(readString()); try { return keyType.readPubKeyFromBuffer(this); } catch (GeneralSecurityException e) { throw new SSHRuntimeException(e); } catch (UnsupportedOperationException uoe) { throw new BufferException("Could not decode keytype " + keyType); } }
public long readUInt64() throws BufferException { long uint64 = (readUInt32() << 32) + (readUInt32() & 0xffffffffL); if (uint64 < 0) throw new BufferException("Cannot handle values > Long.MAX_VALUE"); return uint64; }