Examples of BERDecoder


Examples of com.sun.jmx.snmp.BerDecoder

     */
    public void decodeMessage(byte[] inputBytes, int byteCount)
        throws SnmpStatusException {

        try {
            BerDecoder bdec = new BerDecoder(inputBytes);
            bdec.openSequence();
            version = bdec.fetchInteger();
            bdec.openSequence();
            msgId = bdec.fetchInteger();
            msgMaxSize = bdec.fetchInteger();
            msgFlags = bdec.fetchOctetString()[0];
            msgSecurityModel =bdec.fetchInteger();
            bdec.closeSequence();
            msgSecurityParameters = bdec.fetchOctetString();
            if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
                bdec.openSequence();
                contextEngineId = bdec.fetchOctetString();
                contextName = bdec.fetchOctetString();
                data = bdec.fetchAny();
                dataLength = data.length;
                bdec.closeSequence();
            }
            else {
                encryptedPdu = bdec.fetchOctetString();
            }
            bdec.closeSequence() ;
        }
        catch(BerException x) {
            x.printStackTrace();
            throw new SnmpStatusException("Invalid encoding") ;
        }
View Full Code Here

Examples of com.sun.jmx.snmp.BerDecoder

     * Returns the associated request Id.
     * @param data The flat message.
     * @return The request Id.
     */
    public int getRequestId(byte[] data) throws SnmpStatusException {
        BerDecoder bdec = null;
        int msgId = 0;
        try {
            bdec = new BerDecoder(data);
            bdec.openSequence();
            bdec.fetchInteger();
            bdec.openSequence();
            msgId = bdec.fetchInteger();
        }catch(BerException x) {
            throw new SnmpStatusException("Invalid encoding") ;
        }
        try {
            bdec.closeSequence();
        }
        catch(BerException x) {
        }

        return msgId;
View Full Code Here

Examples of com.sun.jmx.snmp.BerDecoder

    public SnmpPdu decodeSnmpPdu()
        throws SnmpStatusException {

        SnmpScopedPduPacket pdu = null;

        BerDecoder bdec = new BerDecoder(data) ;
        try {
            int type = bdec.getTag() ;
            bdec.openSequence(type) ;
            switch(type) {

            case pduGetRequestPdu :
            case pduGetNextRequestPdu :
            case pduInformRequestPdu :
            case pduGetResponsePdu :
            case pduSetRequestPdu :
            case pduV2TrapPdu :
            case pduReportPdu :
                SnmpScopedPduRequest reqPdu = new SnmpScopedPduRequest() ;
                reqPdu.requestId = bdec.fetchInteger() ;
                reqPdu.setErrorStatus(bdec.fetchInteger());
                reqPdu.setErrorIndex(bdec.fetchInteger());
                pdu = reqPdu ;
                break ;

            case pduGetBulkRequestPdu :
                SnmpScopedPduBulk bulkPdu = new SnmpScopedPduBulk() ;
                bulkPdu.requestId = bdec.fetchInteger() ;
                bulkPdu.setNonRepeaters(bdec.fetchInteger());
                bulkPdu.setMaxRepetitions(bdec.fetchInteger());
                pdu = bulkPdu ;
                break ;
            default:
                throw new SnmpStatusException(snmpRspWrongEncoding) ;
            }
            pdu.type = type;
            pdu.varBindList = decodeVarBindList(bdec);
            bdec.closeSequence() ;
        } catch(BerException e) {
            if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
                SNMP_LOGGER.logp(Level.FINEST, SnmpV3Message.class.getName(),
                        "decodeSnmpPdu", "BerException", e);
            }
View Full Code Here

Examples of com.sun.jndi.ldap.BerDecoder

        throws IOException {

        super(id, criticality, value);

        // decode value
        BerDecoder ber = new BerDecoder(value, 0, value.length);

        ber.parseSeq(null);
        resultCode = ber.parseEnumeration();
        if ((ber.bytesLeft() > 0) && (ber.peekByte() == Ber.ASN_CONTEXT)) {
            badAttrId = ber.parseStringWithTag(Ber.ASN_CONTEXT, true, null);
        }
    }
View Full Code Here

Examples of com.sun.jndi.ldap.BerDecoder

        byte[] value) throws IOException {

        super(id, criticality, value);

        // decode value
        BerDecoder ber = new BerDecoder(value, 0, value.length);

        ber.parseSeq(null);
        resultSize = ber.parseInt();
        cookie = ber.parseOctetString(Ber.ASN_OCTET_STR, null);
    }
View Full Code Here

Examples of com.sun.jndi.ldap.BerDecoder

  throws IOException {

  super(id, criticality, value);

  // decode value
  BerDecoder ber = new BerDecoder(value, 0, value.length);

  ber.parseSeq(null);
  resultCode = ber.parseEnumeration();
  if ((ber.bytesLeft() > 0) && (ber.peekByte() == Ber.ASN_CONTEXT)) {
      badAttrId = ber.parseStringWithTag(Ber.ASN_CONTEXT, true, null);
  }
    }
View Full Code Here

Examples of com.sun.jndi.ldap.BerDecoder

        byte[] value) throws IOException {

        super(id, criticality, value);

        // decode value
        BerDecoder ber = new BerDecoder(value, 0, value.length);

        ber.parseSeq(null);
        resultSize = ber.parseInt();
  cookie = ber.parseOctetString(Ber.ASN_OCTET_STR, null);
    }
View Full Code Here

Examples of com.sun.jndi.ldap.BerDecoder

        throws IOException {

        super(id, criticality, value);

        // decode value
        BerDecoder ber = new BerDecoder(value, 0, value.length);

        ber.parseSeq(null);
        resultCode = ber.parseEnumeration();
        if ((ber.bytesLeft() > 0) && (ber.peekByte() == Ber.ASN_CONTEXT)) {
            badAttrId = ber.parseStringWithTag(Ber.ASN_CONTEXT, true, null);
        }
    }
View Full Code Here

Examples of com.sun.jndi.ldap.BerDecoder

        byte[] value) throws IOException {

        super(id, criticality, value);

        // decode value
        BerDecoder ber = new BerDecoder(value, 0, value.length);

        ber.parseSeq(null);
        resultSize = ber.parseInt();
        cookie = ber.parseOctetString(Ber.ASN_OCTET_STR, null);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.