Secure iNet Factory

com.jscape.inet.ssh
Class SshWriter

java.lang.Object
  extended by com.jscape.inet.ssh.SshWriter

public class SshWriter
extends java.lang.Object

Writes the basic SSH types to the underlayed output stream.

Version:
1.0
Author:
Alex Usun

Constructor Summary
SshWriter(java.io.OutputStream out, boolean owner)
          Creates a new writer instance.
 
Method Summary
 void close()
          Closes the current writer.
 void write(byte[] b)
          Writes the byte array.
 void write(byte[] b, int offset, int length)
          Writes the byte array.
 void writeBoolean(boolean val)
          Writes a SSH boolean value.
 void writeByte(int val)
          Writes a SSH byte value.
 void writeInt32(int val)
          Writes a SSH int32 value.
 void writeInt64(long val)
          Writes a SSH int64 value.
 void writeLine(java.lang.String val)
          Writes the specified line with ending "\r\n" characters.
 void writeMpint(java.math.BigInteger val)
          Writes a SSH mpint value.
 void writeNameList(java.lang.String[] val)
          Writes a SSH name list.
 void writeString(byte[] val)
          Writes a SSH string represented as a byte array.
 void writeString(byte[] val, int offset, int length)
          Writes a SSH string represented as a byte array.
 void writeString(java.lang.String val)
          Writes a SSH string.
 void writeUint32(long val)
          Writes a SSH uint32 value.
 void writeUint64(java.math.BigInteger val)
          Writes a SSH uint64 value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SshWriter

public SshWriter(java.io.OutputStream out,
                 boolean owner)
Creates a new writer instance.

Parameters:
out - the underlayed output stream
owner - if true the writer will close the underlayed stream while its own closing
Method Detail

close

public void close()
Closes the current writer.


writeBoolean

public void writeBoolean(boolean val)
                  throws java.io.IOException
Writes a SSH boolean value. A SSH boolean value is stored as a single byte. The value 0 represents FALSE, and the value 1 represents TRUE. All non-zero values are interpreted as TRUE.

Parameters:
val - the value to write
Throws:
java.io.IOException - if an I/O error occurs

writeByte

public void writeByte(int val)
               throws java.io.IOException
Writes a SSH byte value. A SSH byte represents an arbitrary 8-bit value (octet) in range [0..255].

Parameters:
val - the value to write
Throws:
java.io.IOException - if an I/O error occurs

writeUint32

public void writeUint32(long val)
                 throws java.io.IOException
Writes a SSH uint32 value. A SSH uint32 represents a 32-bit unsigned integer stored as four bytes in the order of decreasing significance (network byte order).

Parameters:
val - the value to write
Throws:
java.io.IOException - if an I/O error occurs

writeInt32

public void writeInt32(int val)
                throws java.io.IOException
Writes a SSH int32 value. A SSH uint32 represents a 32-bit signed integer stored as four bytes in the order of decreasing significance (network byte order).

Parameters:
val - the value to write
Throws:
java.io.IOException - if an I/O error occurs

writeUint64

public void writeUint64(java.math.BigInteger val)
                 throws java.io.IOException
Writes a SSH uint64 value. A SSH uint64 value represents a 64-bit unsigned integer. Stored as eight bytes in the order of decreasing significance (network byte order).

Parameters:
val - the value to write
Throws:
java.io.IOException - if an I/O error occurs

writeInt64

public void writeInt64(long val)
                throws java.io.IOException
Writes a SSH int64 value. A SSH uint64 value represents a 64-bit signed integer. Stored as eight bytes in the order of decreasing significance (network byte order).

Parameters:
val - the value to write
Throws:
java.io.IOException - if an I/O error occurs

writeString

public void writeString(java.lang.String val)
                 throws java.io.IOException
Writes a SSH string. A SSH string is allowed to contain arbitrary binary data, including null characters and 8-bit characters. It is stored as a uint32 containing its length (number of bytes that follow) and zero (= empty string) or more bytes that are the value of the string. Terminating null characters are not used.

Parameters:
val - the value to write
Throws:
java.io.IOException - if an I/O error occurs

writeString

public void writeString(byte[] val)
                 throws java.io.IOException
Writes a SSH string represented as a byte array.

Parameters:
val - the value to write
Throws:
java.io.IOException - if an I/O error occurs

writeString

public void writeString(byte[] val,
                        int offset,
                        int length)
                 throws java.io.IOException
Writes a SSH string represented as a byte array.

Parameters:
val - the value to write
offset - the data offset
length - the data length
Throws:
java.io.IOException - if an I/O error occurs

writeMpint

public void writeMpint(java.math.BigInteger val)
                throws java.io.IOException
Writes a SSH mpint value. A SSH mpint represents multiple precision integers in two's complement format, stored as a string, 8 bits per byte, MSB first. Negative numbers have the value 1 as the most significant bit of the first byte of the data partition. If the most significant bit would be set for a positive number, the number is preceded by a zero byte.

Parameters:
val - the value to write
Throws:
java.io.IOException - if an I/O error occurs

writeNameList

public void writeNameList(java.lang.String[] val)
                   throws java.io.IOException
Writes a SSH name list. A SSH anme list is a string containing a comma separated list of names. A name list is represented as a uint32 containing its length (number of bytes that follow) followed by a comma-separated list of zero or more names. A name must be non-zero length, and it must not contain a comma (','). Context may impose additional restrictions on the names; for example, the names in a list may have to be valid algorithm identifier (see Section 6 below), or [RFC3066] language tags. The order of the names in a list may or may not be significant, also depending on the context where the list is is used. Terminating NUL characters are not used, neither for the individual names, nor for the list as a whole.

Parameters:
val - the value to write
Throws:
java.io.IOException - if an I/O error occurs

writeLine

public void writeLine(java.lang.String val)
               throws java.io.IOException
Writes the specified line with ending "\r\n" characters.

Parameters:
val - the value to write
Throws:
java.io.IOException - if an I/O error occurs

write

public void write(byte[] b)
           throws java.io.IOException
Writes the byte array.

Parameters:
b - the data to write
Throws:
java.io.IOException - if an I/O error occurs

write

public void write(byte[] b,
                  int offset,
                  int length)
           throws java.io.IOException
Writes the byte array.

Parameters:
b - the data to write
offset - the data offset
length - the data length
Throws:
java.io.IOException - if an I/O error occurs

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved