private void _decode(AsnInputStream ansIS, int length)
      throws MAPParsingComponentException, IOException, AsnException {

    AsnInputStream ais = ansIS.readSequenceStreamData(length);

    int tag = ais.readTag();

    // ussd-DataCodingScheme USSD-DataCodingScheme
    if (ais.getTagClass() != Tag.CLASS_UNIVERSAL || !ais.isTagPrimitive())
      throw new MAPParsingComponentException(
          "Error while decoding UnstructuredSSResponseIndication: Parameter ussd-DataCodingScheme bad tag class or not primitive",
          MAPParsingComponentExceptionReason.MistypedParameter);

    int length1 = ais.readLength();
    this.ussdDataCodingSch = new CBSDataCodingSchemeImpl(ais.readOctetStringData(length1)[0]);

    tag = ais.readTag();

    // ussd-String USSD-String
    if (ais.getTagClass() != Tag.CLASS_UNIVERSAL || !ais.isTagPrimitive())
      throw new MAPParsingComponentException(
          "Error while decoding UnstructuredSSResponseIndication: Parameter ussd-String bad tag class or not primitive",
          MAPParsingComponentExceptionReason.MistypedParameter);

    this.ussdString = new USSDStringImpl(this.ussdDataCodingSch);
    ((USSDStringImpl) this.ussdString).decodeAll(ais);
  }
Example #2
0
  @Test(groups = {"functional.decode", "primitives"})
  public void testDecode() throws Exception {

    byte[] data = this.getData1();

    AsnInputStream asn = new AsnInputStream(data);
    int tag = asn.readTag();

    LocationAreaImpl prim = new LocationAreaImpl();
    prim.decodeAll(asn);

    assertEquals(tag, LocationAreaImpl._TAG_laiFixedLength);
    assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC);

    LAIFixedLength lai = prim.getLAIFixedLength();
    assertEquals(lai.getMCC(), 249);
    assertEquals(lai.getMNC(), 1);
    assertEquals(lai.getLac(), 14010);
    assertNull(prim.getLAC());

    data = this.getData2();

    asn = new AsnInputStream(data);
    tag = asn.readTag();

    prim = new LocationAreaImpl();
    prim.decodeAll(asn);

    assertEquals(tag, LocationAreaImpl._TAG_lac);
    assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC);

    assertNull(prim.getLAIFixedLength());
    LAC lac = prim.getLAC();
    assertEquals(lac.getLac(), 14010);
  }
Example #3
0
  private void _decode(AsnInputStream asnIS, int length)
      throws MAPParsingComponentException, IOException, AsnException {

    if (asnIS.getTagClass() != Tag.CLASS_CONTEXT_SPECIFIC || !asnIS.isTagPrimitive())
      throw new MAPParsingComponentException(
          "Error while decoding "
              + _PrimitiveName
              + ": bad tag class or is not primitive: TagClass="
              + asnIS.getTagClass(),
          MAPParsingComponentExceptionReason.MistypedParameter);

    switch (asnIS.getTag()) {
      case _TAG_MSC_NUMBER:
        this.mSCNumber = new ISDNAddressStringImpl();
        ((ISDNAddressStringImpl) this.mSCNumber).decodeData(asnIS, length);
        break;
      case _TAG_SGSN_NUMBER:
        this.sGSNNumber = new ISDNAddressStringImpl();
        ((ISDNAddressStringImpl) this.sGSNNumber).decodeData(asnIS, length);
        break;
      default:
        throw new MAPParsingComponentException(
            "Error while decoding "
                + _PrimitiveName
                + ": Expexted msc-Number [0] ISDN-AddressString or sgsn-Number [1] ISDN-AddressString, but found "
                + asnIS.getTag(),
            MAPParsingComponentExceptionReason.MistypedParameter);
    }
  }
  @Test(groups = {"functional.decode"})
  public void testDecode() throws Exception {

    byte[] rawData = getEncodedData();
    AsnInputStream asn = new AsnInputStream(rawData);

    int tag = asn.readTag();
    EpsAuthenticationSetListImpl asc = new EpsAuthenticationSetListImpl();
    asc.decodeAll(asn);

    assertEquals(tag, Tag.SEQUENCE);
    assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL);

    ArrayList<EpcAv> epcAvs = asc.getEpcAv();
    assertEquals(epcAvs.size(), 2);

    assertTrue(Arrays.equals(epcAvs.get(0).getRand(), EpcAvTest.getRandData()));
    assertTrue(Arrays.equals(epcAvs.get(0).getXres(), EpcAvTest.getXresData()));
    assertTrue(Arrays.equals(epcAvs.get(0).getAutn(), EpcAvTest.getAutnData()));
    assertTrue(Arrays.equals(epcAvs.get(0).getKasme(), EpcAvTest.getKasmeData()));

    assertTrue(Arrays.equals(epcAvs.get(1).getRand(), EpcAvTest.getRandData()));
    assertTrue(Arrays.equals(epcAvs.get(1).getXres(), getXresData()));
    assertTrue(Arrays.equals(epcAvs.get(1).getAutn(), EpcAvTest.getAutnData()));
    assertTrue(Arrays.equals(epcAvs.get(1).getKasme(), EpcAvTest.getKasmeData()));
  }
  @Test(groups = {"functional.decode", "isup"})
  public void testDecode() throws Exception {

    byte[] data = this.getData();
    AsnInputStream ais = new AsnInputStream(data);
    OriginalCalledNumberCapImpl elem = new OriginalCalledNumberCapImpl();
    int tag = ais.readTag();
    elem.decodeAll(ais);
    OriginalCalledNumber ocn = elem.getOriginalCalledNumber();
    assertTrue(Arrays.equals(elem.getData(), this.getIntData()));
    assertEquals(ocn.getNatureOfAddressIndicator(), 3);
    assertTrue(ocn.getAddress().equals("7010900"));
    assertEquals(ocn.getNumberingPlanIndicator(), 1);
    assertEquals(ocn.getAddressRepresentationRestrictedIndicator(), 1);

    data = this.getData2();
    ais = new AsnInputStream(data);
    elem = new OriginalCalledNumberCapImpl();
    tag = ais.readTag();
    elem.decodeAll(ais);
    ocn = elem.getOriginalCalledNumber();
    assertEquals(ocn.getNumberingPlanIndicator(), 1);
    assertEquals(ocn.getAddressRepresentationRestrictedIndicator(), 0);
    assertEquals(ocn.getNatureOfAddressIndicator(), 4);
    assertEquals(ocn.getAddress(), "c48980491770922937");
  }
Example #6
0
  @Test(groups = {"functional.decode", "primitives"})
  public void testDecode() throws Exception {
    byte[] data = this.getData();
    AsnInputStream asn = new AsnInputStream(data);
    int tag = asn.readTag();
    EPSQoSSubscribedImpl prim = new EPSQoSSubscribedImpl();

    prim.decodeAll(asn);

    assertEquals(tag, Tag.SEQUENCE);
    assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL);

    AllocationRetentionPriority allocationRetentionPriority = prim.getAllocationRetentionPriority();
    MAPExtensionContainer extensionContainer = prim.getExtensionContainer();
    assertEquals(allocationRetentionPriority.getPriorityLevel(), 1);
    assertTrue(allocationRetentionPriority.getPreEmptionCapability());
    assertTrue(allocationRetentionPriority.getPreEmptionVulnerability());
    assertNotNull(allocationRetentionPriority.getExtensionContainer());
    ;
    assertTrue(
        MAPExtensionContainerTest.CheckTestExtensionContainer(
            allocationRetentionPriority.getExtensionContainer()));
    assertNotNull(extensionContainer);
    assertEquals(prim.getQoSClassIdentifier(), QoSClassIdentifier.QCI_1);
    assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer));
  }
  @Test(groups = {"functional.decode", "circuitSwitchedCall.primitive"})
  public void testDecode() throws Exception {

    byte[] data = this.getData();
    AsnInputStream ais = new AsnInputStream(data);
    TDisconnectSpecificInfoImpl elem = new TDisconnectSpecificInfoImpl();
    int tag = ais.readTag();
    assertEquals(tag, EventSpecificInformationBCSMImpl._ID_tDisconnectSpecificInfo);
    assertEquals(ais.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC);
    elem.decodeAll(ais);
    assertTrue(Arrays.equals(elem.getReleaseCause().getData(), this.getIntData()));
  }
Example #8
0
  @Test(groups = {"functional.decode", "circuitSwitchedCall"})
  public void testDecode() throws Exception {

    byte[] data = this.getData1();
    AsnInputStream ais = new AsnInputStream(data);
    ResetTimerRequestImpl elem = new ResetTimerRequestImpl();
    int tag = ais.readTag();
    elem.decodeAll(ais);
    assertEquals(elem.getTimerID(), TimerID.tssf);
    assertEquals(elem.getTimerValue(), 1000);
    assertTrue(CAPExtensionsTest.checkTestCAPExtensions(elem.getExtensions()));
    assertEquals((int) elem.getCallSegmentID(), 100);
  }
Example #9
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);
    }
  }
  @Test(groups = {"functional.decode", "circuitSwitchedCall.primitive"})
  public void testDecode() throws Exception {

    byte[] data = this.getData1();
    AsnInputStream ais = new AsnInputStream(data);
    VariableMessageImpl elem = new VariableMessageImpl();
    int tag = ais.readTag();
    assertEquals(tag, Tag.SEQUENCE);
    elem.decodeAll(ais);
    assertEquals(elem.getElementaryMessageID(), 800);
    assertEquals(elem.getVariableParts().size(), 2);
    assertEquals((int) elem.getVariableParts().get(0).getInteger(), 111);
    assertEquals((int) elem.getVariableParts().get(1).getTime().getHour(), 23);
    assertEquals((int) elem.getVariableParts().get(1).getTime().getMinute(), 59);
  }
  @Test(groups = {"functional.decode", "service.supplementary"})
  public void testDecode() throws Exception {

    byte[] rawData = getEncodedData();

    AsnInputStream asn = new AsnInputStream(rawData);

    int tag = asn.readTag();
    assertEquals(tag, Tag.STRING_NUMERIC);
    assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL);

    GetPasswordResponseImpl impl = new GetPasswordResponseImpl();
    impl.decodeAll(asn);

    assertEquals(impl.getPassword().getData(), "0123");
  }
  @Test(groups = {"functional.decode", "service.sms"})
  public void testDecode() throws Exception {

    byte[] rawData = getEncodedData();

    AsnInputStream asn = new AsnInputStream(rawData);

    int tag = asn.readTag();
    assertEquals(tag, Tag.SEQUENCE);
    assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL);

    ReadyForSMResponseImpl impl = new ReadyForSMResponseImpl();
    impl.decodeAll(asn);

    assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(impl.getExtensionContainer()));
  }
  @Override
  protected void _decode(AsnInputStream asnIS, int length)
      throws MAPParsingComponentException, IOException, AsnException {

    AsnInputStream ais = asnIS.readSequenceStreamData(length);
    int num = 0;
    while (true) {
      if (ais.available() == 0) break;

      int tag = ais.readTag();
      switch (num) {
        case 0:
          if (tag != Tag.STRING_OCTET
              || ais.getTagClass() != Tag.CLASS_UNIVERSAL
              || !ais.isTagPrimitive()) {
            throw new MAPParsingComponentException(
                "Error while decoding "
                    + _PrimitiveName
                    + ".kc: Parameter 0 bad tag or tag class or not primitive",
                MAPParsingComponentExceptionReason.MistypedParameter);
          }
          this.kc = new KcImpl();
          ((KcImpl) this.kc).decodeAll(ais);
          break;
        case 1:
          if (tag != Tag.STRING_OCTET
              || ais.getTagClass() != Tag.CLASS_UNIVERSAL
              || !ais.isTagPrimitive()) {
            throw new MAPParsingComponentException(
                "Error while decoding "
                    + _PrimitiveName
                    + ".cksn: Parameter 1 bad tag or tag class or not primitive",
                MAPParsingComponentExceptionReason.MistypedParameter);
          }
          this.cksn = new CksnImpl();
          ((CksnImpl) this.cksn).decodeAll(ais);
          break;
        default:
          ais.advanceElement();
          break;
      }

      num++;
    }
    if (num < 2)
      throw new MAPParsingComponentException(
          "Error while decoding "
              + _PrimitiveName
              + ": Needs at least 2 mandatory parameters, found "
              + num,
          MAPParsingComponentExceptionReason.MistypedParameter);
  }
  @Test(groups = {"functional.decode", "circuitSwitchedCall"})
  public void testDecode() throws Exception {

    byte[] data = this.getData1();
    AsnInputStream ais = new AsnInputStream(data);
    FurnishChargingInformationRequestImpl elem = new FurnishChargingInformationRequestImpl();
    int tag = ais.readTag();
    assertEquals(tag, Tag.STRING_OCTET);
    elem.decodeAll(ais);
    assertTrue(
        Arrays.equals(
            elem.getFCIBCCCAMELsequence1().getFreeFormatData().getData(), this.getDataFFD()));
    assertEquals(
        elem.getFCIBCCCAMELsequence1().getPartyToCharge().getSendingSideID(), LegType.leg2);
    assertEquals(
        elem.getFCIBCCCAMELsequence1().getAppendFreeFormatData(), AppendFreeFormatData.append);
  }
  @Test(groups = {"functional.decode", "subscriberInformation"})
  public void testDecode() throws Exception {

    byte[] rawData = getEncodedData();

    AsnInputStream asn = new AsnInputStream(rawData);

    int tag = asn.readTag();
    GeodeticInformationImpl impl = new GeodeticInformationImpl();
    impl.decodeAll(asn);

    assertEquals(impl.getScreeningAndPresentationIndicators(), 3);
    assertEquals(impl.getTypeOfShape(), TypeOfShape.EllipsoidPointWithUncertaintyCircle);
    assertTrue(Math.abs(impl.getLatitude() - 21.5) < 0.0001);
    assertTrue(Math.abs(impl.getLongitude() - 171) < 0.0001);
    assertTrue(Math.abs(impl.getUncertainty() - 0) < 0.01);
    assertEquals(impl.getConfidence(), 11);
  }
Example #16
0
  private void _decode(AsnInputStream ansIS, int length)
      throws MAPParsingComponentException, IOException, AsnException {
    this.signalInfo = null;
    this.protocolId = null;
    this.extensionContainer = null;

    AsnInputStream ais = ansIS.readSequenceStreamData(length);
    while (true) {
      if (ais.available() == 0) break;

      int tag = ais.readTag();
      if (ais.getTagClass() == Tag.CLASS_UNIVERSAL) {
        switch (tag) {
          case Tag.ENUMERATED:
            int code = (int) ais.readInteger();
            this.protocolId = ProtocolId.getProtocolId(code);
            break;
          case Tag.STRING_OCTET:
            if (!ais.isTagPrimitive())
              throw new MAPParsingComponentException(
                  "Error while decoding "
                      + _PrimitiveName
                      + ".signalInfo: Parameter extensionContainer is not primitive",
                  MAPParsingComponentExceptionReason.MistypedParameter);
            this.signalInfo = new SignalInfoImpl();
            ((SignalInfoImpl) this.signalInfo).decodeAll(ais);
            break;
          case Tag.SEQUENCE:
            if (ais.isTagPrimitive())
              throw new MAPParsingComponentException(
                  "Error while decoding "
                      + _PrimitiveName
                      + ".extensionContainer: Parameter extensionContainer is primitive",
                  MAPParsingComponentExceptionReason.MistypedParameter);
            this.extensionContainer = new MAPExtensionContainerImpl();
            ((MAPExtensionContainerImpl) this.extensionContainer).decodeAll(ais);
            break;
          default:
            ais.advanceElement();
            break;
        }
      }
    }

    if (this.protocolId == null || this.signalInfo == null)
      throw new MAPParsingComponentException(
          "Error while decoding " + _PrimitiveName + ": protocolId and signalInfo must not be null",
          MAPParsingComponentExceptionReason.MistypedParameter);
  }
Example #17
0
  private void _decode(AsnInputStream ais, int length)
      throws MAPParsingComponentException, IOException, AsnException {
    this.forwardingInfo = null;
    this.callBarringInfo = null;
    this.cugInfo = null;
    this.ssData = null;
    this.emlppInfo = null;

    if (ais.getTagClass() != Tag.CLASS_CONTEXT_SPECIFIC || ais.isTagPrimitive())
      throw new MAPParsingComponentException(
          "Error while decoding "
              + _PrimitiveName
              + ": bad tag class or is primitive: TagClass="
              + ais.getTagClass(),
          MAPParsingComponentExceptionReason.MistypedParameter);

    switch (ais.getTag()) {
      case _TAG_forwardingInfo:
        this.forwardingInfo = new ExtForwInfoImpl();
        ((ExtForwInfoImpl) this.forwardingInfo).decodeData(ais, length);
        break;
      case _TAG_callBarringInfo:
        this.callBarringInfo = new ExtCallBarInfoImpl();
        ((ExtCallBarInfoImpl) this.callBarringInfo).decodeData(ais, length);
        break;
      case _TAG_cugInfo:
        this.cugInfo = new CUGInfoImpl();
        ((CUGInfoImpl) this.cugInfo).decodeData(ais, length);
        break;
      case _TAG_ssData:
        this.ssData = new ExtSSDataImpl();
        ((ExtSSDataImpl) this.ssData).decodeData(ais, length);
        break;
      case _TAG_emlppInfo:
        this.emlppInfo = new EMLPPInfoImpl();
        ((EMLPPInfoImpl) this.emlppInfo).decodeData(ais, length);
        break;

      default:
        throw new MAPParsingComponentException(
            "Error while " + _PrimitiveName + ": bad tag: " + ais.getTag(),
            MAPParsingComponentExceptionReason.MistypedParameter);
    }
  }
Example #18
0
  @Test(groups = {"functional.decode", "subscriberInformation"})
  public void testDecode() throws Exception {
    AsnInputStream ansIS = new AsnInputStream(data);
    int tag = ansIS.readTag();
    assertEquals(tag, Tag.SEQUENCE);

    ExtCwFeatureImpl extCwFeature = new ExtCwFeatureImpl();
    extCwFeature.decodeAll(ansIS);

    ExtBasicServiceCode extBasicServiceCode = extCwFeature.getBasicService();
    assertEquals(
        extBasicServiceCode.getExtTeleservice().getTeleserviceCodeValue(),
        TeleserviceCodeValue.allShortMessageServices);

    ExtSSStatus extSSStatus = extCwFeature.getSsStatus();
    assertTrue(extSSStatus.getBitQ());
    assertTrue(extSSStatus.getBitP());
    assertFalse(extSSStatus.getBitR());
    assertFalse(extSSStatus.getBitA());
  }
Example #19
0
  @Test(groups = {"functional.decode", "service.lsm"})
  public void testDecode() throws Exception {
    byte[] data = getEncodedData();

    AsnInputStream asn = new AsnInputStream(data);
    int tag = asn.readTag();
    assertEquals(tag, Tag.SEQUENCE);

    DeferredmtlrDataImpl imp = new DeferredmtlrDataImpl();
    imp.decodeAll(asn);

    assertFalse(imp.getDeferredLocationEventType().getMsAvailable());
    assertTrue(imp.getDeferredLocationEventType().getEnteringIntoArea());
    assertFalse(imp.getDeferredLocationEventType().getLeavingFromArea());
    assertTrue(imp.getDeferredLocationEventType().getBeingInsideArea());

    assertEquals(imp.getTerminationCause(), TerminationCause.mtlrRestart);

    assertTrue(imp.getLCSLocationInfo().getNetworkNodeNumber().getAddress().equals("330044005500"));
  }
Example #20
0
  private void _decode(AsnInputStream ais, int length)
      throws CAPParsingComponentException, IOException, AsnException, MAPParsingComponentException {

    this.volumeIfNoTariffSwitch = null;
    this.volumeIfTariffSwitch = null;

    int tag = ais.getTag();

    if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) {
      switch (tag) {
        case _ID_volumeIfNoTariffSwitch:
          if (!ais.isTagPrimitive())
            throw new CAPParsingComponentException(
                "Error while decoding "
                    + _PrimitiveName
                    + ".volumeIfNoTariffSwitch: Parameter is not primitive",
                CAPParsingComponentExceptionReason.MistypedParameter);
          this.volumeIfNoTariffSwitch = ais.readIntegerData(length);
          break;
        case _ID_volumeIfTariffSwitch:
          if (ais.isTagPrimitive())
            throw new CAPParsingComponentException(
                "Error while decoding "
                    + _PrimitiveName
                    + ".volumeIfTariffSwitch: Parameter is primitive",
                CAPParsingComponentExceptionReason.MistypedParameter);
          this.volumeIfTariffSwitch = new VolumeIfTariffSwitchImpl();
          ((VolumeIfTariffSwitchImpl) this.volumeIfTariffSwitch).decodeData(ais, length);
          break;

        default:
          throw new CAPParsingComponentException(
              "Error while decoding " + _PrimitiveName + ": bad choice tag",
              CAPParsingComponentExceptionReason.MistypedParameter);
      }
    } else {
      throw new CAPParsingComponentException(
          "Error while decoding " + _PrimitiveName + ": bad choice tagClass",
          CAPParsingComponentExceptionReason.MistypedParameter);
    }
  }
Example #21
0
  @Test(groups = {"functional.decode", "service.oam"})
  public void testDecode() throws Exception {

    byte[] rawData = getEncodedData();
    AsnInputStream asn = new AsnInputStream(rawData);

    int tag = asn.readTag();
    PGWInterfaceListImpl asc = new PGWInterfaceListImpl();
    asc.decodeAll(asn);

    assertEquals(tag, Tag.STRING_BIT);
    assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL);

    assertTrue(asc.getS2a());
    assertFalse(asc.getS2b());
    assertTrue(asc.getS2c());
    assertFalse(asc.getS5());
    assertTrue(asc.getS6b());
    assertTrue(asc.getGx());
    assertFalse(asc.getS8b());
    assertTrue(asc.getSgi());
  }
Example #22
0
  @Test(groups = {"functional.decode", "dialog"})
  public void testDecode() throws Exception {
    // The raw data is from last packet of long ussd-abort from msc2.txt
    byte[] data = this.getData();

    AsnInputStream asnIs = new AsnInputStream(data);

    int tag = asnIs.readTag();
    assertEquals(tag, 3);

    MAPRefuseInfoImpl mapRefuseInfoImpl = new MAPRefuseInfoImpl();
    mapRefuseInfoImpl.decodeAll(asnIs);

    Reason reason = mapRefuseInfoImpl.getReason();

    assertNotNull(reason);

    assertEquals(reason, Reason.noReasonGiven);

    data = this.getDataFull();
    asnIs = new AsnInputStream(data);

    tag = asnIs.readTag();
    assertEquals(tag, 3);

    mapRefuseInfoImpl = new MAPRefuseInfoImpl();
    mapRefuseInfoImpl.decodeAll(asnIs);

    reason = mapRefuseInfoImpl.getReason();
    assertNotNull(reason);
    assertEquals(reason, Reason.invalidOriginatingReference);
    assertTrue(
        MAPExtensionContainerTest.CheckTestExtensionContainer(
            mapRefuseInfoImpl.getExtensionContainer()));
    assertNotNull(mapRefuseInfoImpl.getAlternativeAcn());
    assertTrue(
        Arrays.equals(
            new long[] {1, 2, 3, 4, 5, 6}, mapRefuseInfoImpl.getAlternativeAcn().getOid()));
  }
Example #23
0
  @Override
  public void decodeAll(AsnInputStream ansIS) throws CAPParsingComponentException {

    try {
      int length = ansIS.readLength();
      this._decode(ansIS, length);
    } catch (IOException e) {
      throw new CAPParsingComponentException(
          "IOException when decoding " + _PrimitiveName + ": " + e.getMessage(),
          e,
          CAPParsingComponentExceptionReason.MistypedParameter);
    }
  }
Example #24
0
  protected void _decode(AsnInputStream ansIS, int length)
      throws CAPParsingComponentException, IOException {

    if (!ansIS.isTagPrimitive())
      throw new CAPParsingComponentException(
          "Error decoding " + _PrimitiveName + ": field must be primitive",
          CAPParsingComponentExceptionReason.MistypedParameter);

    if (length < this.minLength || length > this.maxLength)
      throw new CAPParsingComponentException(
          "Error decoding "
              + _PrimitiveName
              + ": the field must contain from "
              + this.minLength
              + " to "
              + this.maxLength
              + " octets. Contains: "
              + length,
          CAPParsingComponentExceptionReason.MistypedParameter);

    data = new byte[length];
    ansIS.read(data);
  }
  @Test(groups = {"functional.decode", "primitives"})
  public void testDecode() throws Exception {

    byte[] rawData = getData();
    AsnInputStream asn = new AsnInputStream(rawData);

    int tag = asn.readTag();
    AccessRestrictionDataImpl imp = new AccessRestrictionDataImpl();
    imp.decodeAll(asn);

    assertEquals(tag, Tag.STRING_BIT);
    assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL);

    assertTrue(!imp.getUtranNotAllowed());
    assertTrue(imp.getGeranNotAllowed());
    assertTrue(!imp.getGanNotAllowed());
    assertTrue(imp.getIHspaEvolutionNotAllowed());
    assertTrue(!imp.getEUtranNotAllowed());
    assertTrue(imp.getHoToNon3GPPAccessNotAllowed());

    rawData = getData1();
    asn = new AsnInputStream(rawData);

    tag = asn.readTag();
    imp = new AccessRestrictionDataImpl();
    imp.decodeAll(asn);

    assertEquals(tag, Tag.STRING_BIT);
    assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL);

    assertTrue(imp.getUtranNotAllowed());
    assertTrue(!imp.getGeranNotAllowed());
    assertTrue(imp.getGanNotAllowed());
    assertTrue(!imp.getIHspaEvolutionNotAllowed());
    assertTrue(imp.getEUtranNotAllowed());
    assertTrue(!imp.getHoToNon3GPPAccessNotAllowed());
  }
Example #26
0
  @Test(groups = {"functional.decode", "subscriberInformation"})
  public void testDecode() throws Exception {

    AsnInputStream asn = new AsnInputStream(data);
    int tag = asn.readTag();
    assertEquals(tag, 1);

    RequestedInfoImpl requestedInfo = new RequestedInfoImpl();
    requestedInfo.decodeAll(asn);

    assertTrue(requestedInfo.getLocationInformation());
    assertTrue(requestedInfo.getSubscriberState());
    assertNull(requestedInfo.getExtensionContainer());
    assertFalse(requestedInfo.getCurrentLocation());
    assertNull(requestedInfo.getRequestedDomain());
    assertFalse(requestedInfo.getImei());
    assertFalse(requestedInfo.getMsClassmark());
    assertFalse(requestedInfo.getMnpRequestedInfo());

    asn = new AsnInputStream(dataFull);
    tag = asn.readTag();
    assertEquals(tag, Tag.SEQUENCE);

    requestedInfo = new RequestedInfoImpl();
    requestedInfo.decodeAll(asn);

    assertTrue(requestedInfo.getLocationInformation());
    assertTrue(requestedInfo.getSubscriberState());
    assertTrue(
        MAPExtensionContainerTest.CheckTestExtensionContainer(
            requestedInfo.getExtensionContainer()));
    assertTrue(requestedInfo.getCurrentLocation());
    assertEquals(requestedInfo.getRequestedDomain(), DomainType.psDomain);
    assertTrue(requestedInfo.getImei());
    assertTrue(requestedInfo.getMsClassmark());
    assertTrue(requestedInfo.getMnpRequestedInfo());
  }
  @Test(groups = {"functional.decode", "service.lsm"})
  public void testDecode() throws Exception {
    byte[] rawData = getEncodedData();
    AsnInputStream asn = new AsnInputStream(rawData);

    int tag = asn.readTag();
    SupportedGADShapesImpl supportedLCSCapabilityTest = new SupportedGADShapesImpl();
    supportedLCSCapabilityTest.decodeAll(asn);

    assertEquals(tag, Tag.STRING_BIT);
    assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL);

    assertEquals((boolean) supportedLCSCapabilityTest.getEllipsoidArc(), true);
    assertEquals((boolean) supportedLCSCapabilityTest.getEllipsoidPoint(), true);
    assertEquals((boolean) supportedLCSCapabilityTest.getEllipsoidPointWithAltitude(), true);
    assertEquals(
        (boolean) supportedLCSCapabilityTest.getEllipsoidPointWithAltitudeAndUncertaintyElipsoid(),
        true);
    assertEquals(
        (boolean) supportedLCSCapabilityTest.getEllipsoidPointWithUncertaintyCircle(), true);
    assertEquals(
        (boolean) supportedLCSCapabilityTest.getEllipsoidPointWithUncertaintyEllipse(), true);
    assertEquals((boolean) supportedLCSCapabilityTest.getPolygon(), true);
  }
Example #28
0
  private void _decode(AsnInputStream ais, int length)
      throws MAPParsingComponentException, IOException, AsnException {
    this.data = ais.readIA5StringData(length);

    if (data == null)
      throw new MAPParsingComponentException(
          "Error while decoding " + _PrimitiveName + ": bad String length: must be 4, found=0",
          MAPParsingComponentExceptionReason.MistypedParameter);
    if (data.length() != 4)
      throw new MAPParsingComponentException(
          "Error while decoding "
              + _PrimitiveName
              + ": bad String length: must be 4, found="
              + data.length(),
          MAPParsingComponentExceptionReason.MistypedParameter);
  }
  public void decodeAll(AsnInputStream ansIS) throws MAPParsingComponentException {

    try {
      int length = ansIS.readLength();
      this._decode(ansIS, length);
    } catch (IOException e) {
      throw new MAPParsingComponentException(
          "IOException when decoding UnstructuredSSResponseIndication: " + e.getMessage(),
          e,
          MAPParsingComponentExceptionReason.MistypedParameter);
    } catch (AsnException e) {
      throw new MAPParsingComponentException(
          "AsnException when decoding UnstructuredSSResponseIndication: " + e.getMessage(),
          e,
          MAPParsingComponentExceptionReason.MistypedParameter);
    }
  }
Example #30
0
  /*
   * (non-Javadoc)
   *
   * @see org.mobicents.protocols.ss7.tcap.asn.Encodable#decode(org.mobicents.protocols .asn.AsnInputStream)
   */
  public void decode(AsnInputStream ais) throws ParseException {

    try {

      byte[] buf = ais.readOctetString();
      if (buf == null || buf.length != 1)
        throw new ParseException(
            PAbortCause.BadlyStructuredDialoguePortion,
            "Error decoding ProtocolVersion: bad octet string length");

      this.data = (buf[0] & 0xFF);
    } catch (IOException e) {
      throw new ParseException(
          PAbortCause.BadlyStructuredDialoguePortion,
          "IOException while decoding ProtocolVersion: " + e.getMessage(),
          e);
    } catch (AsnException e) {
      throw new ParseException(
          PAbortCause.BadlyStructuredDialoguePortion,
          "AsnException while decoding ProtocolVersion: " + e.getMessage(),
          e);
    }
  }