Example #1
0
  public void decode(AsnInputStream aisA) throws ParseException {

    // TAG has been decoded already, now, lets get LEN
    try {
      AsnInputStream ais = aisA.readSequenceStream();

      int tag = ais.readTag();
      if (tag != Tag.EXTERNAL)
        throw new ParseException(
            PAbortCauseType.IncorrectTxPortion,
            null,
            "Error decoding DialogPortion: wrong value of tag, expected EXTERNAL, found: " + tag);

      ext.decode(ais);

      if (!isAsn() || !isOid()) {
        throw new ParseException(
            PAbortCauseType.IncorrectTxPortion,
            null,
            "Error decoding DialogPortion: Oid and Asd parts not found");
      }

      // Check Oid
      if (Arrays.equals(_DIALG_UNI, this.getOidValue())) this.uniDirectional = true;
      else if (Arrays.equals(_DIALG_STRUCTURED, this.getOidValue())) this.uniDirectional = false;
      else
        throw new ParseException(
            PAbortCauseType.IncorrectTxPortion,
            null,
            "Error decoding DialogPortion: bad Oid value");

      AsnInputStream loaclAsnIS = new AsnInputStream(ext.getEncodeType());

      // now lets get APDU
      tag = loaclAsnIS.readTag();
      this.dialogAPDU = TcapFactory.createDialogAPDU(loaclAsnIS, tag, isUnidirectional());

    } catch (IOException e) {
      throw new ParseException(
          PAbortCauseType.BadlyFormattedTxPortion,
          null,
          "IOException when decoding DialogPortion: " + e.getMessage(),
          e);
    } catch (AsnException e) {
      throw new ParseException(
          PAbortCauseType.BadlyFormattedTxPortion,
          null,
          "AsnException when decoding DialogPortion: " + e.getMessage(),
          e);
    }
  }