public abstract class Buffer extends Object implements Readable
Modifier and Type | Field and Description |
---|---|
protected byte[] |
workBuf |
Modifier | Constructor and Description |
---|---|
protected |
Buffer() |
Modifier and Type | Method and Description |
---|---|
abstract byte[] |
array() |
abstract int |
capacity() |
void |
clear() |
abstract void |
clear(boolean wipeData) |
abstract void |
compact() |
protected abstract void |
copyRawBytes(int offset,
byte[] buf,
int pos,
int len) |
void |
dumpHex(SimplifiedLog logger,
Level level,
String prefix,
PropertyResolver resolver) |
void |
dumpHex(SimplifiedLog logger,
String prefix,
PropertyResolver resolver) |
void |
ensureAvailable(int reqLen) |
protected void |
ensureCapacity(int capacity) |
abstract void |
ensureCapacity(int capacity,
IntUnaryOperator growthFactor) |
protected KeyPair |
extractEC(String expectedCurveName,
ECParameterSpec spec) |
Collection<String> |
getAvailableStrings() |
Collection<String> |
getAvailableStrings(Charset charset) |
boolean |
getBoolean() |
byte |
getByte() |
byte[] |
getBytes() |
byte[] |
getCompactData() |
int |
getInt() |
KeyPair |
getKeyPair() |
long |
getLong() |
BigInteger |
getMPInt() |
byte[] |
getMPIntAsBytes() |
PublicKey |
getPublicKey() |
PublicKey |
getPublicKey(BufferPublicKeyParser<? extends PublicKey> parser) |
void |
getRawBytes(byte[] buf) |
PublicKey |
getRawPublicKey() |
PublicKey |
getRawPublicKey(BufferPublicKeyParser<? extends PublicKey> parser) |
short |
getShort() |
String |
getString() |
abstract String |
getString(Charset charset) |
Collection<String> |
getStringList(boolean usePrependedLength) |
Collection<String> |
getStringList(boolean usePrependedLength,
Charset charset) |
List<String> |
getStringList(int count) |
List<String> |
getStringList(int count,
Charset charset) |
int |
getUByte() |
long |
getUInt() |
boolean |
isValidMessageStructure(Class<?>... fieldTypes) |
boolean |
isValidMessageStructure(Collection<Class<?>> fieldTypes) |
void |
putAndWipeBytes(byte[] b)
Adds the bytes to the buffer and wipes the data from the
input buffer after having added it - useful for sensitive
information such as password
|
void |
putAndWipeBytes(byte[] b,
int off,
int len) |
void |
putAndWipeChars(char[] chars)
Zeroes the input array after having put the characters in the
buffer - useful for sensitive information such as passwords
|
void |
putAndWipeChars(char[] chars,
Charset charset) |
void |
putAndWipeChars(char[] chars,
int offset,
int len) |
void |
putAndWipeChars(char[] chars,
int offset,
int len,
Charset charset) |
void |
putBoolean(boolean b) |
abstract void |
putBuffer(ByteBuffer buffer) |
void |
putBuffer(Readable buffer) |
abstract int |
putBuffer(Readable buffer,
boolean expand) |
void |
putByte(byte b) |
void |
putBytes(byte[] b) |
void |
putBytes(byte[] b,
int off,
int len) |
void |
putChars(char[] chars) |
void |
putChars(char[] chars,
Charset charset) |
void |
putChars(char[] chars,
int offset,
int len) |
void |
putChars(char[] chars,
int offset,
int len,
Charset charset) |
void |
putInt(long i)
Writes 32 bits
|
void |
putKeyPair(KeyPair kp) |
void |
putLong(long i)
Writes 64 bits
|
void |
putMPInt(BigInteger bi) |
void |
putMPInt(byte[] foo) |
void |
putPublicKey(PublicKey key) |
void |
putRawBytes(byte[] d) |
abstract void |
putRawBytes(byte[] d,
int off,
int len) |
void |
putRawPublicKey(PublicKey key) |
void |
putShort(int i)
Writes 16 bits
|
void |
putString(String string) |
void |
putString(String string,
Charset charset) |
void |
putStringList(Collection<?> objects,
boolean prependLength)
Encodes the
Transformer#TOSTRING value of each member. |
void |
putStringList(Collection<?> objects,
Charset charset,
boolean prependLength)
Encodes the
Transformer#TOSTRING value of each member |
abstract int |
rpos() |
abstract void |
rpos(int rpos) |
protected abstract int |
size() |
String |
toHex() |
String |
toString() |
abstract int |
wpos() |
abstract void |
wpos(int wpos) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
available, getRawBytes, readable
public abstract int rpos()
public abstract void rpos(int rpos)
public abstract int wpos()
public abstract void wpos(int wpos)
public abstract int capacity()
public abstract byte[] array()
public abstract void compact()
public byte[] getCompactData()
public void clear()
public abstract void clear(boolean wipeData)
public boolean isValidMessageStructure(Class<?>... fieldTypes)
public boolean isValidMessageStructure(Collection<Class<?>> fieldTypes)
protected abstract void copyRawBytes(int offset, byte[] buf, int pos, int len)
public String toHex()
public void dumpHex(SimplifiedLog logger, String prefix, PropertyResolver resolver)
public void dumpHex(SimplifiedLog logger, Level level, String prefix, PropertyResolver resolver)
public int getUByte()
public byte getByte()
public short getShort()
public int getInt()
public long getUInt()
public long getLong()
public boolean getBoolean()
public String getString()
public Collection<String> getStringList(boolean usePrependedLength)
usePrependedLength
- If true
then there is a 32-bit
value indicating the number of strings to read. Otherwise, the
method will use a "greedy" reading of strings while more
data availableCollection
of the read stringsgetStringList(boolean, Charset)
public Collection<String> getStringList(boolean usePrependedLength, Charset charset)
usePrependedLength
- If true
then there is a 32-bit
value indicating the number of strings to read. Otherwise, the
method will use a "greedy" reading of strings while more
data availablecharset
- The Charset
to use for the stringCollection
of the read stringsgetStringList(int, Charset)
,
getAvailableStrings()
public Collection<String> getAvailableStrings()
getAvailableStrings(Charset)
public Collection<String> getAvailableStrings(Charset charset)
charset
- The Charset
to use for the stringsReadable.available()
,
getString(Charset)
public List<String> getStringList(int count)
count
- The exact number of strings to read - can be zeroList
with the specified number of stringsgetStringList(int, Charset)
public List<String> getStringList(int count, Charset charset)
count
- The exact number of strings to read - can be zerocharset
- The Charset
of the stringsList
with the specified number of stringsgetString(Charset)
public BigInteger getMPInt()
public byte[] getMPIntAsBytes()
public byte[] getBytes()
public void getRawBytes(byte[] buf)
public PublicKey getPublicKey() throws SshException
SshException
public PublicKey getPublicKey(BufferPublicKeyParser<? extends PublicKey> parser) throws SshException
parser
- A BufferPublicKeyParser
to extract the key from the buffer
- never null
PublicKey
- may be null
if the parser so decidedSshException
- If failed to extract the keygetRawPublicKey(BufferPublicKeyParser)
public PublicKey getRawPublicKey() throws SshException
SshException
public PublicKey getRawPublicKey(BufferPublicKeyParser<? extends PublicKey> parser) throws SshException
parser
- A BufferPublicKeyParser
to extract the key from the buffer
- never null
PublicKey
- may be null
if the parser so decidedSshException
- If failed to extract the keypublic KeyPair getKeyPair() throws SshException
SshException
protected KeyPair extractEC(String expectedCurveName, ECParameterSpec spec) throws GeneralSecurityException
GeneralSecurityException
public void ensureAvailable(int reqLen) throws BufferException
BufferException
public void putByte(byte b)
public void putBuffer(Readable buffer)
public abstract int putBuffer(Readable buffer, boolean expand)
public abstract void putBuffer(ByteBuffer buffer)
public void putShort(int i)
i
- The 16-bit valuepublic void putInt(long i)
i
- The 32-bit valuepublic void putLong(long i)
i
- The 64-bit valuepublic void putBoolean(boolean b)
public void putAndWipeBytes(byte[] b)
b
- The buffer to add - OK if null
public void putAndWipeBytes(byte[] b, int off, int len)
public void putBytes(byte[] b)
public void putBytes(byte[] b, int off, int len)
public void putStringList(Collection<?> objects, boolean prependLength)
Transformer#TOSTRING
value of each member.objects
- The objects to be encoded in the buffer - OK if
null
/emptyprependLength
- If true
then the list is preceded by
a 32-bit count of the number of members in the listputStringList(Collection, Charset, boolean)
public void putStringList(Collection<?> objects, Charset charset, boolean prependLength)
Transformer#TOSTRING
value of each memberobjects
- The objects to be encoded in the buffer - OK if
null
/emptycharset
- The Charset
to use for encodingprependLength
- If true
then the list is preceded by
a 32-bit count of the number of members in the listputString(String, Charset)
public void putString(String string)
public void putAndWipeChars(char[] chars)
chars
- The characters to put in the buffer - may be null
/emptyputAndWipeChars(char[], Charset)
,
putChars(char[], Charset)
public void putAndWipeChars(char[] chars, int offset, int len)
public void putAndWipeChars(char[] chars, Charset charset)
public void putAndWipeChars(char[] chars, int offset, int len, Charset charset)
public void putChars(char[] chars)
public void putChars(char[] chars, int offset, int len)
public void putChars(char[] chars, Charset charset)
public void putChars(char[] chars, int offset, int len, Charset charset)
public void putMPInt(BigInteger bi)
public void putMPInt(byte[] foo)
public void putRawBytes(byte[] d)
public abstract void putRawBytes(byte[] d, int off, int len)
public void putPublicKey(PublicKey key)
public void putRawPublicKey(PublicKey key)
public void putKeyPair(KeyPair kp)
protected void ensureCapacity(int capacity)
public abstract void ensureCapacity(int capacity, IntUnaryOperator growthFactor)
capacity
- The requires capacitygrowthFactor
- An IntUnaryOperator
that is invoked
if the current capacity is insufficient. The argument is the minimum
required new data length, the function result should be the
effective new data length to be allocated - if less than minimum
then an exception is thrownprotected abstract int size()
Copyright © 2008–2019 The Apache Software Foundation. All rights reserved.