Examples of BERDecoder


Examples of codec.asn1.BERDecoder

        .println("This bag is either password or public-key protected.");
      return null;
  }
  bais = new ByteArrayInputStream(encodedData);
  SafeContents safe = new SafeContents();
  BERDecoder decoder = new BERDecoder(bais);
  safe.decode(decoder);
  bais.close();
  return safe;
    }
View Full Code Here

Examples of codec.asn1.BERDecoder

  SecretKey pbeKey = skf.generateSecret(pbeSpec);
  encData.init(pbeKey);
  data = encData.getData();
  bais = new ByteArrayInputStream(data);
  SafeContents safe = new SafeContents();
  BERDecoder decoder = new BERDecoder(bais);
  safe.decode(decoder);
  bais.close();
  return safe;
    }
View Full Code Here

Examples of codec.asn1.BERDecoder

  envData.init(cert, key);
  byte[] data = envData.getData();

  bais = new ByteArrayInputStream(data);
  SafeContents safe = new SafeContents();
  BERDecoder decoder = new BERDecoder(bais);
  safe.decode(decoder);
  bais.close();
  return safe;
    }
View Full Code Here

Examples of codec.asn1.BERDecoder

      }
      seq.add(oid.clone());

      if (entry.isEncodedValue()) {
    ByteArrayInputStream in;
    BERDecoder dec;
    ASN1Type obj;
    byte[] buf;

    try {
        buf = entry.getEncodedValue();
        in = new ByteArrayInputStream(buf);
        dec = new BERDecoder(in);
        obj = dec.readType();

        dec.close();
    } catch (Exception e) {
        throw new BadNameException(
          "Binary data is not a valid BER encoding!");
    }
    seq.add(obj);
View Full Code Here

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.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 (isDebugOn()) {
                debug("decodeSnmpPdu", e);
            }
            throw new SnmpStatusException(snmpRspWrongEncoding);
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.