com.outbackinc.services.protocol.snmp
Class SnmpAsn1Encoder

java.lang.Object
  |
  +--com.outbackinc.services.protocol.snmp.SnmpAsn1Encoder

public class SnmpAsn1Encoder
extends java.lang.Object

The SnmpAsn1Encoder class contains static methods to do ASN.1 encoding for SNMP packets. This class is provided for implementers of future SNMPv3 security models, otherwise it should not be normally used in JSNMP applications.

See Also:
SnmpConstants

Method Summary
static int decodeLength(byte[] cbBuffer, int iPos)
          Decode an ASN.1 length at iPos.
static int encodeCounter(byte[] cbBuffer, int iPos, java.lang.Long lNum)
          Encode a SnmpConstants.ASN_COUNTER type into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeGauge(byte[] cbBuffer, int iPos, java.lang.Long lNum)
          Encode a SnmpConstants.ASN_GAUGE type into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeInteger(byte[] cbBuffer, int iPos, java.math.BigInteger igr)
          Encode a SnmpConstants.ASN_INTEGER type into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeIpAddress(byte[] cbBuffer, int iPos, byte[] address)
          Encode a SnmpConstants.ASN_IPADDRESS type into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeLength(byte[] cbBuffer, int iPos, int iLength)
          Encode a length value into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeMaxLength(byte[] cbBuffer, int iPos, int iLength)
          Encode a length value (using the maximum amount of space within the packet [3 bytes]) into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeMaxSequence(byte[] cbBuffer, int iPos, int iLength)
          Encode a SnmpConstants.ASN_SEQUENCE type (using the maximum amount of space within the packet [3 bytes]) into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeNull(byte[] cbBuffer, int iPos)
          Encode a SnmpConstants.ASN_NULL type into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeOctetString(byte[] cbBuffer, int iPos, byte[] octets)
          Encode a SnmpConstants.ASN_OCTSTR type into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeOID(byte[] cbBuffer, int iPos, java.lang.String szOID)
          Encode a SnmpConstants.ASN_OID type into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeOIDWithNull(byte[] cbBuffer, int iPos, java.lang.String szOID)
          Encode an OID with a SnmpConstants.ASN_NULL type into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeOIDWithValue(byte[] cbBuffer, int iPos, java.lang.String szOID, byte bType, java.lang.Object value)
          Encode an OID with a type and value into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeOpaque(byte[] cbBuffer, int iPos, byte[] opaque)
          Encode a SnmpConstants.ASN_OPAQUE type into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeRequestID(byte[] cbBuffer, int iPos, int iRequestID)
          Encode a message request identifier into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeTimeTicks(byte[] cbBuffer, int iPos, java.lang.Long lNum)
          Encode a SnmpConstants.ASN_TIMETICKS type into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeType(byte[] cbBuffer, int iPos, byte bType)
          Encode a type code into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeUnsigned32Bit(byte[] cbBuffer, int iPos, java.lang.Long lNum)
          Encode a SnmpConstants.ASN_UINTEGER32 type into it's ASN.1 byte representation and return the current encoding buffer index.
static int encodeUnsigned64Bit(byte[] cbBuffer, int iPos, java.math.BigInteger igrNum)
          Encode a SnmpConstants.ASN_COUNTER64 type into it's ASN.1 byte representation and return the current encoding buffer index.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodeLength

public static int encodeLength(byte[] cbBuffer,
                               int iPos,
                               int iLength)
                        throws java.lang.ArrayIndexOutOfBoundsException
Encode a length value into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
iLength - length value to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer

encodeMaxLength

public static int encodeMaxLength(byte[] cbBuffer,
                                  int iPos,
                                  int iLength)
                           throws java.lang.ArrayIndexOutOfBoundsException
Encode a length value (using the maximum amount of space within the packet [3 bytes]) into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
ipos - current encoding buffer index.
iLength - length value to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer

encodeType

public static int encodeType(byte[] cbBuffer,
                             int iPos,
                             byte bType)
                      throws java.lang.ArrayIndexOutOfBoundsException
Encode a type code into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
bType - The ASN.1 type (as defined in SnmpConstants).
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer

encodeMaxSequence

public static int encodeMaxSequence(byte[] cbBuffer,
                                    int iPos,
                                    int iLength)
                             throws java.lang.ArrayIndexOutOfBoundsException
Encode a SnmpConstants.ASN_SEQUENCE type (using the maximum amount of space within the packet [3 bytes]) into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
iLength - length value to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
See Also:
SnmpConstants

encodeInteger

public static int encodeInteger(byte[] cbBuffer,
                                int iPos,
                                java.math.BigInteger igr)
                         throws java.lang.ArrayIndexOutOfBoundsException,
                                java.lang.IllegalArgumentException
Encode a SnmpConstants.ASN_INTEGER type into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
igr - integer to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
java.lang.IllegalArgumentException - if value argument is null or out of range
See Also:
SnmpConstants

encodeOctetString

public static int encodeOctetString(byte[] cbBuffer,
                                    int iPos,
                                    byte[] octets)
                             throws java.lang.ArrayIndexOutOfBoundsException,
                                    java.lang.IllegalArgumentException
Encode a SnmpConstants.ASN_OCTSTR type into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
octets - octets to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
java.lang.IllegalArgumentException - if value argument is null
See Also:
SnmpConstants

encodeRequestID

public static int encodeRequestID(byte[] cbBuffer,
                                  int iPos,
                                  int iRequestID)
                           throws java.lang.ArrayIndexOutOfBoundsException
Encode a message request identifier into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
iRequestID - request ID to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer

encodeCounter

public static int encodeCounter(byte[] cbBuffer,
                                int iPos,
                                java.lang.Long lNum)
                         throws java.lang.ArrayIndexOutOfBoundsException,
                                java.lang.IllegalArgumentException
Encode a SnmpConstants.ASN_COUNTER type into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
igrNum - value to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
java.lang.IllegalArgumentException - if value argument is null or out of range
See Also:
SnmpConstants

encodeGauge

public static int encodeGauge(byte[] cbBuffer,
                              int iPos,
                              java.lang.Long lNum)
                       throws java.lang.ArrayIndexOutOfBoundsException,
                              java.lang.IllegalArgumentException
Encode a SnmpConstants.ASN_GAUGE type into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
igrNum - value to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
java.lang.IllegalArgumentException - if value argument is null or out of range
See Also:
SnmpConstants

encodeTimeTicks

public static int encodeTimeTicks(byte[] cbBuffer,
                                  int iPos,
                                  java.lang.Long lNum)
                           throws java.lang.ArrayIndexOutOfBoundsException,
                                  java.lang.IllegalArgumentException
Encode a SnmpConstants.ASN_TIMETICKS type into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
igrNum - value to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
java.lang.IllegalArgumentException - if value argument is null or out of range
See Also:
SnmpConstants

encodeUnsigned32Bit

public static int encodeUnsigned32Bit(byte[] cbBuffer,
                                      int iPos,
                                      java.lang.Long lNum)
                               throws java.lang.ArrayIndexOutOfBoundsException,
                                      java.lang.IllegalArgumentException
Encode a SnmpConstants.ASN_UINTEGER32 type into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
igrNum - value to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
java.lang.IllegalArgumentException - if value argument is null or out of range
See Also:
SnmpConstants

encodeUnsigned64Bit

public static int encodeUnsigned64Bit(byte[] cbBuffer,
                                      int iPos,
                                      java.math.BigInteger igrNum)
                               throws java.lang.ArrayIndexOutOfBoundsException,
                                      java.lang.IllegalArgumentException
Encode a SnmpConstants.ASN_COUNTER64 type into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
igrNum - value to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
java.lang.IllegalArgumentException - if value argument is null or out of range
See Also:
SnmpConstants

encodeOID

public static int encodeOID(byte[] cbBuffer,
                            int iPos,
                            java.lang.String szOID)
                     throws java.lang.ArrayIndexOutOfBoundsException,
                            java.lang.IllegalArgumentException
Encode a SnmpConstants.ASN_OID type into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
szOID - value to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
java.lang.IllegalArgumentException - if value argument is null
See Also:
SnmpConstants

encodeIpAddress

public static int encodeIpAddress(byte[] cbBuffer,
                                  int iPos,
                                  byte[] address)
                           throws java.lang.ArrayIndexOutOfBoundsException,
                                  java.lang.IllegalArgumentException
Encode a SnmpConstants.ASN_IPADDRESS type into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
address - value to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
java.lang.IllegalArgumentException - if value argument is null
See Also:
SnmpConstants

encodeOpaque

public static int encodeOpaque(byte[] cbBuffer,
                               int iPos,
                               byte[] opaque)
                        throws java.lang.ArrayIndexOutOfBoundsException,
                               java.lang.IllegalArgumentException
Encode a SnmpConstants.ASN_OPAQUE type into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
opaque - value to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
java.lang.IllegalArgumentException - if value argument is null
See Also:
SnmpConstants

encodeNull

public static int encodeNull(byte[] cbBuffer,
                             int iPos)
                      throws java.lang.ArrayIndexOutOfBoundsException
Encode a SnmpConstants.ASN_NULL type into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
See Also:
SnmpConstants

encodeOIDWithValue

public static int encodeOIDWithValue(byte[] cbBuffer,
                                     int iPos,
                                     java.lang.String szOID,
                                     byte bType,
                                     java.lang.Object value)
                              throws java.lang.ArrayIndexOutOfBoundsException,
                                     SnmpUnsupportedTypeException,
                                     java.lang.IllegalArgumentException
Encode an OID with a type and value into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
szOID - OID to encode.
bType - OID value type.
value - OID value.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
SnmpUnsupportedTypeException - if bType is unsupported
java.lang.IllegalArgumentException - if szOID is null or 'value' is wrong type for 'bType' or value argument is null or out of range

encodeOIDWithNull

public static int encodeOIDWithNull(byte[] cbBuffer,
                                    int iPos,
                                    java.lang.String szOID)
                             throws java.lang.ArrayIndexOutOfBoundsException,
                                    java.lang.IllegalArgumentException
Encode an OID with a SnmpConstants.ASN_NULL type into it's ASN.1 byte representation and return the current encoding buffer index.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
szOID - OID to encode.
Returns:
current encoding buffer index
Throws:
java.lang.ArrayIndexOutOfBoundsException - if iPos plus the size of the encoded value exceeds the size of cbBuffer
java.lang.IllegalArgumentException - if szOID is null
See Also:
SnmpConstants

decodeLength

public static int decodeLength(byte[] cbBuffer,
                               int iPos)
                        throws java.lang.IllegalArgumentException
Decode an ASN.1 length at iPos.
Parameters:
cbBuffer - encoding buffer.
iPos - current encoding buffer index.
Returns:
length
Throws:
java.lang.IllegalArgumentException - wrong field length


Home  Services  Products  Purchase  Contact Us  About Us  Legal  Ceramics
Copyright © 2003-2008 jSNMP Enterprises All rights reserved.