public class Buffer<T extends Buffer<T>>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Buffer.BufferException |
static class |
Buffer.PlainBuffer |
Modifier and Type | Field and Description |
---|---|
protected byte[] |
data |
static int |
DEFAULT_SIZE
The default size for a
Buffer (256 bytes) |
static int |
MAX_SIZE
The maximum valid size of buffer (i.e.
|
protected int |
rpos |
protected int |
wpos |
Constructor and Description |
---|
Buffer() |
Buffer(Buffer<?> from) |
Buffer(byte[] data) |
Buffer(int size) |
Modifier and Type | Method and Description |
---|---|
byte[] |
array() |
int |
available() |
void |
clear()
Resets this buffer.
|
void |
compact()
Compact this
SSHPacket |
protected void |
ensureAvailable(int a) |
void |
ensureCapacity(int capacity) |
byte[] |
getCompactData() |
protected static int |
getNextPowerOf2(int i) |
java.lang.String |
printHex()
Gives a readable snapshot of the buffer in hex.
|
T |
putBoolean(boolean b)
Puts an SSH boolean value
|
T |
putBuffer(Buffer<? extends Buffer<?>> buffer)
Copies the contents of provided buffer into this buffer
|
T |
putByte(byte b)
Writes a single byte into this buffer
|
T |
putBytes(byte[] b)
Writes Java byte-array as an SSH byte-array
|
T |
putBytes(byte[] b,
int off,
int len)
Writes Java byte-array as an SSH byte-array
|
T |
putMPInt(java.math.BigInteger bi) |
T |
putPublicKey(java.security.PublicKey key) |
T |
putRawBytes(byte[] d) |
T |
putRawBytes(byte[] d,
int off,
int len) |
T |
putSensitiveString(char[] str)
Writes a char-array as an SSH string and then blanks it out.
|
T |
putSignature(java.lang.String sigFormat,
byte[] sigData) |
T |
putString(byte[] str) |
T |
putString(byte[] str,
int offset,
int len) |
T |
putString(java.lang.String string) |
T |
putUInt32(long uint32)
Writes a uint32 integer
|
T |
putUInt64(long uint64) |
boolean |
readBoolean()
Read an SSH boolean byte
|
byte |
readByte()
Read a byte from the buffer
|
byte[] |
readBytes()
Read an SSH byte-array
|
java.math.BigInteger |
readMPInt()
Read an SSH multiple-precision integer
|
java.security.PublicKey |
readPublicKey() |
void |
readRawBytes(byte[] buf) |
void |
readRawBytes(byte[] buf,
int off,
int len) |
java.lang.String |
readString()
Reads an SSH string
|
byte[] |
readStringAsBytes()
Reads an SSH string
|
long |
readUInt32() |
int |
readUInt32AsInt() |
long |
readUInt64() |
int |
rpos() |
void |
rpos(int rpos) |
java.lang.String |
toString() |
int |
wpos() |
void |
wpos(int wpos) |
public static final int DEFAULT_SIZE
Buffer
(256 bytes)public static final int MAX_SIZE
protected byte[] data
protected int rpos
protected int wpos
public Buffer()
DEFAULT_SIZE
public Buffer(Buffer<?> from)
public Buffer(byte[] data)
public Buffer(int size)
protected static int getNextPowerOf2(int i)
public byte[] array()
public int available()
public void clear()
public int rpos()
public void rpos(int rpos)
public int wpos()
public void wpos(int wpos)
protected void ensureAvailable(int a) throws Buffer.BufferException
Buffer.BufferException
public void ensureCapacity(int capacity)
public void compact()
SSHPacket
public byte[] getCompactData()
public boolean readBoolean() throws Buffer.BufferException
true
or false
value readBuffer.BufferException
public T putBoolean(boolean b)
b
- the valuepublic byte readByte() throws Buffer.BufferException
Buffer.BufferException
public T putByte(byte b)
b
- public byte[] readBytes() throws Buffer.BufferException
Buffer.BufferException
public T putBytes(byte[] b)
b
- Java byte-arraypublic T putBytes(byte[] b, int off, int len)
b
- Java byte-arrayoff
- offsetlen
- lengthpublic void readRawBytes(byte[] buf) throws Buffer.BufferException
Buffer.BufferException
public void readRawBytes(byte[] buf, int off, int len) throws Buffer.BufferException
Buffer.BufferException
public T putRawBytes(byte[] d)
public T putRawBytes(byte[] d, int off, int len)
public T putBuffer(Buffer<? extends Buffer<?>> buffer)
buffer
- the Buffer
to copypublic int readUInt32AsInt() throws Buffer.BufferException
Buffer.BufferException
public long readUInt32() throws Buffer.BufferException
Buffer.BufferException
public T putUInt32(long uint32)
uint32
- public java.math.BigInteger readMPInt() throws Buffer.BufferException
BigInteger
Buffer.BufferException
public T putMPInt(java.math.BigInteger bi)
public long readUInt64() throws Buffer.BufferException
Buffer.BufferException
public T putUInt64(long uint64)
public java.lang.String readString() throws Buffer.BufferException
String
Buffer.BufferException
public byte[] readStringAsBytes() throws Buffer.BufferException
Buffer.BufferException
public T putString(byte[] str)
public T putString(byte[] str, int offset, int len)
public T putString(java.lang.String string)
public T putSensitiveString(char[] str)
str
is null
, an empty string is
written.str
- (null-ok) the string as a character arraypublic java.security.PublicKey readPublicKey() throws Buffer.BufferException
Buffer.BufferException
public T putPublicKey(java.security.PublicKey key)
public T putSignature(java.lang.String sigFormat, byte[] sigData)
public java.lang.String printHex()
public java.lang.String toString()
toString
in class java.lang.Object