Package gov.nist.javax.sip.header

Examples of gov.nist.javax.sip.header.HeaderFactoryImpl


             *                IMS headers
             * ++++++++++++++++++++++++++++++++++++++++++++
             */

            // work-around for IMS headers
            HeaderFactoryImpl headerFactoryImpl = new HeaderFactoryImpl();

            // Allow header
            /*
            AllowHeader allowHeader =
                headerFactory.createAllowHeader(Request.INVITE + "," +
                        Request.PRACK + "," +
                        Request.UPDATE);
            request.addHeader(allowHeader);
            */
                AllowHeader allow1 =
                headerFactory.createAllowHeader(Request.INVITE);
            request.addHeader(allow1);
            AllowHeader allow2 =
                headerFactory.createAllowHeader(Request.PRACK);
            request.addHeader(allow2);
            AllowHeader allow3 =
                headerFactory.createAllowHeader(Request.UPDATE);
            request.addHeader(allow3);

            // Supported
            /*
            SupportedHeader supportedHeader =
                headerFactory.createSupportedHeader("100rel" + "," +
                        "precondition");
            request.addHeader(supportedHeader);
            */
            SupportedHeader supported1 =
                headerFactory.createSupportedHeader("100rel");
            request.addHeader(supported1);
            SupportedHeader supported2 =
                headerFactory.createSupportedHeader("preconditions");
            request.addHeader(supported2);
            SupportedHeader supported3 =
                headerFactory.createSupportedHeader("path");
            request.addHeader(supported3);



            // Require
            /*
            RequireHeader requireHeader =
                headerFactory.createRequireHeader("sec-agree"+ "," +
                "precondition");
            request.addHeader(requireHeader);
            */
            RequireHeader require1 =
                headerFactory.createRequireHeader("sec-agree");
            request.addHeader(require1);
            RequireHeader require2 =
                headerFactory.createRequireHeader("preconditions");
            request.addHeader(require2);


            // Security-Client
            SecurityClientHeader secClient =
                headerFactoryImpl.createSecurityClientHeader();
            secClient.setSecurityMechanism("ipsec-3gpp");
            secClient.setAlgorithm("hmac-md5-96");
            secClient.setEncryptionAlgorithm("des-cbc");
            secClient.setSPIClient(10000);
            secClient.setSPIServer(10001);
            secClient.setPortClient(5063);
            secClient.setPortServer(4166);
            request.addHeader(secClient);


            // P-Access-Network-Info
            PAccessNetworkInfoHeader accessInfo =
                headerFactoryImpl.createPAccessNetworkInfoHeader();
            accessInfo.setAccessType("3GPP-UTRAN-TDD");
            accessInfo.setUtranCellID3GPP("0123456789ABCDEF");
            request.addHeader(accessInfo);

            // Privacy
            PrivacyHeader privacy = headerFactoryImpl.createPrivacyHeader("header");
            request.addHeader(privacy);
            PrivacyHeader privacy2 = headerFactoryImpl.createPrivacyHeader("user");
            request.addHeader(privacy2);

            // P-Preferred-Identity
            PPreferredIdentityHeader preferredID =
                headerFactoryImpl.createPPreferredIdentityHeader(fromNameAddress);
            request.addHeader(preferredID);



            /*
             * TEST
             */
            // this is only to illustrate the usage of this headers


            // P-Called-Party-ID
            // only to test
            PCalledPartyIDHeader calledPartyID =
                headerFactoryImpl.createPCalledPartyIDHeader(toNameAddress);
            request.addHeader(calledPartyID);

            // P-Visited-Network-ID
            PVisitedNetworkIDHeader visitedNetworkID1 =
                headerFactoryImpl.createPVisitedNetworkIDHeader();
            visitedNetworkID1.setVisitedNetworkID(fromSipAddress
                    .substring(fromSipAddress.indexOf("@")+1));
            PVisitedNetworkIDHeader visitedNetworkID2 =
                headerFactoryImpl.createPVisitedNetworkIDHeader();
            visitedNetworkID2.setVisitedNetworkID(toSipAddress
                    .substring(toSipAddress.indexOf("@")+1));
            request.addHeader(visitedNetworkID1);
            request.addHeader(visitedNetworkID2);


            // P-Associated-URI
            PAssociatedURIHeader associatedURI1 =
                headerFactoryImpl.createPAssociatedURIHeader(toNameAddress);
            PAssociatedURIHeader associatedURI2 =
                headerFactoryImpl.createPAssociatedURIHeader(fromNameAddress);
            request.addHeader(associatedURI1);
            request.addHeader(associatedURI2);


            // P-Asserted-Identity
            PAssertedIdentityHeader assertedID =
                headerFactoryImpl.createPAssertedIdentityHeader(
                        addressFactory.createAddress(toAddress));
            request.addHeader(assertedID);

            TelURL tel = addressFactory.createTelURL("+1-201-555-0123");
            Address telAddress = addressFactory.createAddress(tel);
            toNameAddress.setDisplayName(toDisplayName);
            PAssertedIdentityHeader assertedID2 =
                headerFactoryImpl.createPAssertedIdentityHeader(telAddress);
            request.addHeader(assertedID2);


            // P-Charging-Function-Addresses
            PChargingFunctionAddressesHeader chargAddr =
                headerFactoryImpl.createPChargingFunctionAddressesHeader();
            chargAddr.addChargingCollectionFunctionAddress("test1.ims.test");
            chargAddr.addEventChargingFunctionAddress("testevent");
            request.addHeader(chargAddr);

            // P-Charging-Vector
            PChargingVectorHeader chargVect =
                headerFactoryImpl.createChargingVectorHeader("icid");
            chargVect.setICIDGeneratedAt("icidhost");
            chargVect.setOriginatingIOI("origIOI");
            chargVect.setTerminatingIOI("termIOI");
            request.addHeader(chargVect);

            // P-Media-Authorization
            PMediaAuthorizationHeader mediaAuth1 =
                headerFactoryImpl.createPMediaAuthorizationHeader("13579bdf");
            PMediaAuthorizationHeader mediaAuth2 =
                headerFactoryImpl.createPMediaAuthorizationHeader("02468ace");
            request.addHeader(mediaAuth1);
            request.addHeader(mediaAuth2);


            // Path header
            PathHeader path1 =
                headerFactoryImpl.createPathHeader(fromNameAddress);
            PathHeader path2 =
                headerFactoryImpl.createPathHeader(toNameAddress);
            request.addHeader(path1);
            request.addHeader(path2);



View Full Code Here


        System.out.println("Let us now test the usage of this header from the");
        System.out.println("perspective of the application");
        System.out.println("***********************************************");


        HeaderFactoryImpl himpl = new HeaderFactoryImpl();

        PPreferredServiceHeader ppsh = himpl.createPPreferredServiceHeader();

        // This is a 3gpp-service type:
        ppsh.setSubserviceIdentifiers("chatroom.presenceenabled.photoshareservice");

        System.out.println("The encoded header is-----> "+ppsh.toString());
View Full Code Here

     * @return -- an iterator of Content blocks.
     *
     */
    public void createContentList(String body) throws ParseException {
        try {
            HeaderFactoryExt headerFactory = new HeaderFactoryImpl();
            String delimiter = this.getContentTypeHeader().getParameter(BOUNDARY);

            if (delimiter == null) {
                this.contentList = new LinkedList<Content>();
                ContentImpl content = new ContentImpl(body, delimiter);
                content.setContentTypeHeader(this.getContentTypeHeader());
                this.contentList.add(content);
                return;
            }

            String[] fragments = body.split("--" + delimiter + "\r\n");


            for (String nextPart : fragments) {
                // NOTE - we are not hanlding line folding for the sip header here.

                if (nextPart == null) {
                    return;
                }
                StringBuilder strbuf = new StringBuilder(nextPart);
                while (strbuf.length() > 0
                        && (strbuf.charAt(0) == '\r' || strbuf.charAt(0) == '\n'))
                    strbuf.deleteCharAt(0);

                if (strbuf.length() == 0)
                    continue;
                nextPart = strbuf.toString();
                int position = nextPart.indexOf("\r\n\r\n");
                int off = 4;
                if (position == -1) {
                    position = nextPart.indexOf("\n");
                    off = 2;
                }
                if (position == -1)
                    throw new ParseException("no content type header found in " + nextPart, 0);
                String rest = nextPart.substring(position + off);

                if (rest == null)
                    throw new ParseException("No content [" + nextPart + "]", 0);
                // logger.debug("rest = [[" + rest + "]]");
                String headers = nextPart.substring(0, position);
                ContentImpl content = new ContentImpl(rest, boundary);

                String[] headerArray = headers.split("\r\n");
                for (String hdr : headerArray) {
                    Header header = headerFactory.createHeader(hdr);
                    if (header instanceof ContentTypeHeader) {
                        content.setContentTypeHeader((ContentTypeHeader) header);
                    } else if (header instanceof ContentDispositionHeader) {
                        content.setContentDispositionHeader((ContentDispositionHeader) header);
                    } else {
View Full Code Here

     * ++++++++++++++++++++++++++++++++++++++++++++ 
     */
   
    // work-around for IMS headers
    //HeaderFactoryImpl headerFactoryImpl = new HeaderFactoryImpl();
    HeaderFactoryImpl headerFactoryImpl = (HeaderFactoryImpl)headerFactory;
       
    // check headers Allow, Require and Supported
   
    // Allow header
    ListIterator li = null;
    AllowHeader allow = null;
    String allowMethods = new String();      // all the methods in Allow Header
    li = request.getHeaders(AllowHeader.NAME);    // get all the allow methods
    // creates an Allow header for each method
   
    try {
      while(li.hasNext())    // concatenate the method of each Allow header in one string
      allow = (AllowHeader) li.next();
        allowMethods = allowMethods.concat(allow.getMethod()).concat(" ");
      }
    }catch (Exception ex)
    {
      System.out.println("\n(!) Exception getting Allow header! - " + ex);
    }
   
    /*
    // Allow: PRACK ??
    if (allowMethods.indexOf(Request.PRACK) != -1)
      System.out.println("\n*** UAC allows PRACK method ");
    else
      System.out.println("\n*** UAC does NOT allow PRACK method ");
    */
   
   
    // Require header
    RequireHeader require = null;
    String requireOptionTags = new String();
    li = null;
    li = request.getHeaders(RequireHeader.NAME);
    try {
      while(li.hasNext())   
      {  require = (RequireHeader) li.next();
        requireOptionTags = requireOptionTags
          .concat( require.getOptionTag())
          .concat(" ");
      }
    }
    catch (Exception ex)
    {
      System.out.println("\n(!) Exception getting Require header! - " + ex);
    }
   
    /*
    // Require: 100rel ??
    if (requireOptionTags.indexOf("100rel") != -1)
      System.out.println("\n*** UAC requires \"100rel\"");
    else
      System.out.println("\n*** UAC does NOT require \"100rel\"");
    // Require: precondition ??
    if (requireOptionTags.indexOf("precondition") != -1)
      System.out.println("\n*** UAC requires \"precondition\"");
    else
      System.out.println("\n*** UAC does NOT require \"precondition\"");
    // Require: sec-agree ??
    if (requireOptionTags.indexOf("sec-agree") != -1)
      System.out.println("\n*** UAC requires \"sec-agree\"");
    else
      System.out.println("\n*** UAC does NOT require \"sec-agree\"");
    */
   
   
    // Supported header
    SupportedHeader supported = null;
    String supportedOptionTags = new String();
    li = request.getHeaders(SupportedHeader.NAME);
    try {
      while(li.hasNext())   
      {  supported = (SupportedHeader) li.next();
        supportedOptionTags = supportedOptionTags
          .concat( supported.getOptionTag())
          .concat(" ");
      }
    }
    catch (NullPointerException ex)
    {
      System.out.println("\n(!) Exception getting Supported header! - " + ex);
    }
   
    /*
    // Supported: 100rel ??
    if (supportedOptionTags.indexOf("100rel") != -1)
      System.out.println("\n*** UAC supports \"100rel\"");
    else
      System.out.println("\n*** UAC does NOT support \"100rel\"");
   
    // Supported: precondition ??
    if (supportedOptionTags.indexOf("precondition") != -1)
      System.out.println("\n*** UAC supports \"precondition\"");
    else
      System.out.println("\n*** UAC does NOT support \"precondition\"");
    */
   
    // check P-Headers
   
    // check P-Called-Party-ID
    PCalledPartyIDHeader calledParty;
    try {
      calledParty = (PCalledPartyIDHeader)
        request.getHeader(PCalledPartyIDHeader.NAME);
     
      if (calledParty != null)
      {
        System.out.println(".: P-Called-Party-ID = "
          + calledParty.getAddress().toString());
      }
      else
        System.out.println(".: NOT received P-Called-Party-ID ! ");
     
    }
    catch (Exception ex)
    {
      System.out.println("(!) Exception getting P-Called-Party-ID header! - " + ex);
    }

   
    // check P-Associated-URI
    ListIterator associatedURIList;
    try {
      associatedURIList = request.getHeaders(PAssociatedURIHeader.NAME);
            if (associatedURIList != null)
            {
          System.out.print(".: P-Associated-URI = ");
        while (associatedURIList.hasNext())
        {
          PAssociatedURIHeader associatedURI = (PAssociatedURIHeader) associatedURIList.next();
         
          System.out.print(associatedURI.getAssociatedURI().toString());
          if (associatedURIList.hasNext())
            System.out.print(", ");
         
        }
            }
            else
              System.out.println(".: NOT received P-Associated-URI ! ");
           
      System.out.print("\n");
    }
    catch (Exception ex)
    {
      System.out.println("(!) Exception getting P-Associated-URI header! - " + ex);
    }
   
   
    // check P-Access-Network-Info
    PAccessNetworkInfoHeader accessInfo = null;
    try {
      accessInfo = (PAccessNetworkInfoHeader)
        request.getHeader(PAccessNetworkInfoHeader.NAME);
      if (accessInfo != null)
      {
        System.out.print(".: P-Access-Network-Info: Access Type = "
          + accessInfo.getAccessType());
     
        if (accessInfo.getAccessType()
            .equalsIgnoreCase(
                PAccessNetworkInfoHeader.GGGPP_UTRAN_TDD)) // 3GPP-UTRAN-TDD
          System.out.print(" - Cell ID = "
              + accessInfo.getUtranCellID3GPP());
      }
      else
        System.out.println(".: NOT received P-Access-Network-Info ! ");
     
      System.out.println("");
    }
    catch (Exception ex)
    {
      System.out.println("(!) Exception getting P-Access-Network-Info header! - " + ex);
    }
   
    // check if .clone() and .equals() is working
    if (accessInfo != null)
    {
      PAccessNetworkInfo accessInfoClone =
        (PAccessNetworkInfo) accessInfo.clone();
     
      System.out.println("--> clone = " + accessInfoClone.toString());
      System.out.println("--> equals? " + accessInfoClone.equals(accessInfo));
    }
   
   
    // check P-Visited-Network-ID
    ListIterator visitedNetList;
    try {
      visitedNetList = request.getHeaders(PVisitedNetworkIDHeader.NAME);
      if (visitedNetList != null)
      {
        System.out.print(".: P-Visited-Network-ID = ");
        while (visitedNetList.hasNext())
        {
          PVisitedNetworkIDHeader visitedID =
            (PVisitedNetworkIDHeader) visitedNetList.next();
          System.out.print(visitedID.getVisitedNetworkID());
          if (visitedNetList.hasNext())
            System.out.print(", ");
        }
        System.out.print("\n");
      }
      else
        System.out.print(".: NOT received P-Visited-Network-ID ! ");
    }
    catch (Exception ex)
    {
      System.out.println("(!) Exception getting P-Visited-Network-ID header! - " + ex);
    }
   

    // check Privacy
    ListIterator privacyList;
    try {
      privacyList = request.getHeaders(PrivacyHeader.NAME);
      if (privacyList != null && privacyList.hasNext())
      {
        System.out.print(".: Privacy = ");
        while (privacyList.hasNext())
        {
          PrivacyHeader privacy =
            (PrivacyHeader) privacyList.next();
          System.out.print(privacy.getPrivacy());
          if (privacyList.hasNext())
            System.out.print("; ");
        }
        System.out.println("");
      }
      else
        System.out.println(".: NOT received Privacy ! ");
    }
   
    catch (Exception ex)
    {
      System.out.println("(!) Exception getting Privacy header! - " + ex);
    }
   
    // check P-Preferred-Identity
    PPreferredIdentityHeader preferredID;
    try {
      preferredID = (PPreferredIdentityHeader)
        request.getHeader(PPreferredIdentityHeader.NAME);
      if (preferredID != null)
      {
        System.out.println(".: P-Preferred-Identity = " + preferredID.getAddress().toString());
      }
      else
        System.out.println(".: NOT received P-Preferred-Identity ! ");
    }
    catch (Exception ex)
    {
      System.out.println("(!) Exception getting P-Preferred-Identity header! - " + ex);
    }
   

    /*
     * TEST
     */
    // this is only to illustrate the usage of this headers
   
   
    // P-Asserted-Identity
    ListIterator assertedIDList;
    try {
      assertedIDList = 
        request.getHeaders(PAssertedIdentityHeader.NAME);
      if (assertedIDList != null && assertedIDList.hasNext())
      {
        System.out.print(".: P-Asserted-Identity = ");
        while (assertedIDList.hasNext())
        {
          PAssertedIdentityHeader assertedID =
            (PAssertedIdentityHeader) assertedIDList.next();
          System.out.print(assertedID.getAddress().toString());
          if (assertedIDList.hasNext())
            System.out.print(", ");
        }
        System.out.println("");
      }
      else
        System.out.println(".: NOT received P-Asserted-Identity... ");
    }
    catch (Exception ex)
    {
      System.out.println("(!) Exception getting P-Asserted-Identity header! - " + ex);
    }
   
   
   
    // P-Charging-Function-Addresses
    PChargingFunctionAddressesHeader chargAddr;
    try {
      chargAddr = (PChargingFunctionAddressesHeader)
        request.getHeader(PChargingFunctionAddressesHeader.NAME);
     
      if (chargAddr != null)
      {
        Iterator param = chargAddr.getParameterNames();
       
        System.out.print(".: P-Charging-Function-Addresses = ");
       
        if (param != null) {
          while (param.hasNext()) {
            String paramName = (String)param.next();
            System.out.print( paramName + "=" + chargAddr.getParameter(paramName));
            if (param.hasNext())
              System.out.print(", ");
          }
        }
        System.out.println("");
      }
      else
        System.out.println(".: NOT containing P-Charging-Function-Addresses... ");
    }
    catch (Exception ex)
    {
      System.out.println("(!) Exception getting P-Charging-Function-Addresses header! - " + ex);
    }
   
    // P-Charging-Vector
    PChargingVectorHeader chargVect;
    try {
      chargVect = (PChargingVectorHeader)
        request.getHeader(PChargingVectorHeader.NAME);
      if (chargVect != null)
      {
        Iterator param = chargVect.getParameterNames();
       
        System.out.print(".: P-Charging-Vector = ");
       
        if (param != null && param.hasNext()) {
          while (param.hasNext()) {
            String paramName = (String)param.next();
            System.out.print( paramName + "="
                + chargVect.getParameter(paramName));
            if (param.hasNext())
              System.out.print(", ");
          }
        }
        System.out.println("");
      }
      else
        System.out.println(".: NOT containing P-Charging-Vector... ");
    }
    catch (Exception ex)
    {
      System.out.println("(!) Exception getting P-Charging-Vector header! - " + ex);
    }
   
   
    // P-Media-Authorization
    ListIterator mediaAuthList;
    try {
      mediaAuthList = request.getHeaders(PMediaAuthorizationHeader.NAME);

      if (mediaAuthList != null)
      {
        System.out.print(".: P-Media-Authorization = ");
        while (mediaAuthList.hasNext())
        {
          PMediaAuthorizationHeader mediaAuth =
            (PMediaAuthorizationHeader) mediaAuthList.next();
          System.out.print(mediaAuth.getToken());
          if (mediaAuthList.hasNext())
            System.out.print(", ");
        }
        System.out.println("");
      }
      else
        System.out.println(".: NOT containing P-Media-Authorization... ");
    }
    catch (Exception ex)
    {
      System.out.println("(!) Exception getting P-Media-Authorization header! - " + ex);
    }
   
    // Security-Client header
    ListIterator secClientList;
    try {
      secClientList = request.getHeaders(SecurityClientHeader.NAME);

      if (secClientList != null)
      {
        while (secClientList.hasNext())
        {
          System.out.println(".: "
              + ((SecurityClientHeader)secClientList.next()).toString());
        }
      }
      else
        System.out.println(".: NOT containing Security-Client header... ");
    }
    catch (Exception ex)
    {
      System.out.println("(!) Exception getting Security-Client header! - " + ex);
    }
   
   
    // this is only to illustrate the usage of this headers
    // send Security-Server if Require: sec-agree
    SecurityServerList secServerList = null;
    if (requireOptionTags.indexOf("sec-agree") != -1)
    {
      secServerList = new SecurityServerList();
      try {
        SecurityServerHeader secServer1 =
          headerFactoryImpl.createSecurityClientHeader();
        secServer1.setSecurityMechanism("ipsec-3gpp");
        secServer1.setAlgorithm("hmac-md5-96");
        secServer1.setEncryptionAlgorithm("des-cbc");
        secServer1.setSPIClient(10000);
        secServer1.setSPIServer(10001);
        secServer1.setPortClient(5063);
        secServer1.setPortServer(4166);
        secServer1.setPreference(0.1f);
       
        SecurityServerHeader secServer2 =
          headerFactoryImpl.createSecurityClientHeader();
        secServer2.setSecurityMechanism("ipsec-3gpp");
        secServer2.setAlgorithm("hmac-md5-96");
        secServer2.setEncryptionAlgorithm("des-cbc");
        secServer2.setSPIClient(20000);
        secServer2.setSPIServer(20001);
View Full Code Here

 
  public void processInviteOK(Response ok, ClientTransaction ct)
  {
   
    HeaderFactoryImpl headerFactoryImpl =
      (HeaderFactoryImpl) headerFactory;
   
    try
    {
     
      RequireHeader require = null;
      String requireOptionTags = new String();
      ListIterator li = ok.getHeaders(RequireHeader.NAME);
      if (li != null) {
        try {
          while(li.hasNext())   
          {  require = (RequireHeader) li.next();
            requireOptionTags = requireOptionTags
              .concat( require.getOptionTag())
              .concat(" ");
          }
        }
        catch (Exception ex)
        {
          System.out.println("\n(!) Exception getting Require header! - " + ex);
        }
      }
     
     
      // this is only to illustrate the usage of this headers
      // send Security-Verify (based on Security-Server) if Require: sec-agree
      SecurityVerifyList secVerifyList = null;
      if (requireOptionTags.indexOf("sec-agree") != -1)
      {
        ListIterator secServerReceived =
          ok.getHeaders(SecurityServerHeader.NAME);
        if (secServerReceived != null && secServerReceived.hasNext())
        {
            System.out.println(".: Security-Server received: ");
           
           while (secServerReceived.hasNext())
            {
              SecurityServerHeader security = null;
              try {
                security = (SecurityServerHeader) secServerReceived.next();
              }
              catch (Exception ex)
              {
                System.out.println("(!) Exception getting Security-Server header : " + ex);
              }
             
              try {
                Iterator parameters = security.getParameterNames();
                SecurityVerifyHeader newSecVerify = headerFactoryImpl.createSecurityVerifyHeader();
                newSecVerify.setSecurityMechanism(security.getSecurityMechanism());
                while (parameters.hasNext())
                {
                  String paramName = (String)parameters.next();
                  newSecVerify.setParameter(paramName,security.getParameter(paramName));
View Full Code Here

       *                IMS headers
       * ++++++++++++++++++++++++++++++++++++++++++++ 
       */
     
      // work-around for IMS headers
      HeaderFactoryImpl headerFactoryImpl = new HeaderFactoryImpl();
     
      // Allow header
      /*
      AllowHeader allowHeader =
        headerFactory.createAllowHeader(Request.INVITE + "," + 
            Request.PRACK + "," +
            Request.UPDATE);
      request.addHeader(allowHeader);
      */
        AllowHeader allow1 =
        headerFactory.createAllowHeader(Request.INVITE);
      request.addHeader(allow1);
      AllowHeader allow2 =
        headerFactory.createAllowHeader(Request.PRACK);
      request.addHeader(allow2);
      AllowHeader allow3 =
        headerFactory.createAllowHeader(Request.UPDATE);
      request.addHeader(allow3);
     
      // Supported
      /*
      SupportedHeader supportedHeader =
        headerFactory.createSupportedHeader("100rel" + "," +
            "precondition");
      request.addHeader(supportedHeader);
      */
      SupportedHeader supported1 =
        headerFactory.createSupportedHeader("100rel");
      request.addHeader(supported1);
      SupportedHeader supported2 =
        headerFactory.createSupportedHeader("preconditions");
      request.addHeader(supported2);
      SupportedHeader supported3 =
        headerFactory.createSupportedHeader("path");
      request.addHeader(supported3);
   
     
     
      // Require
      /*
      RequireHeader requireHeader =
        headerFactory.createRequireHeader("sec-agree"+ "," +
        "precondition");
      request.addHeader(requireHeader);
      */
      RequireHeader require1 =
        headerFactory.createRequireHeader("sec-agree");
      request.addHeader(require1);
      RequireHeader require2 =
        headerFactory.createRequireHeader("preconditions");
      request.addHeader(require2);
       
     
      // Security-Client
      SecurityClientHeader secClient =
        headerFactoryImpl.createSecurityClientHeader();
      secClient.setSecurityMechanism("ipsec-3gpp");
      secClient.setAlgorithm("hmac-md5-96");
      secClient.setEncryptionAlgorithm("des-cbc");
      secClient.setSPIClient(10000);
      secClient.setSPIServer(10001);
      secClient.setPortClient(5063);
      secClient.setPortServer(4166);
      request.addHeader(secClient);
     
     
      // P-Access-Network-Info
      PAccessNetworkInfoHeader accessInfo =
        headerFactoryImpl.createPAccessNetworkInfoHeader();
      accessInfo.setAccessType("3GPP-UTRAN-TDD");
      accessInfo.setUtranCellID3GPP("0123456789ABCDEF");
      request.addHeader(accessInfo);

      // Privacy
      PrivacyHeader privacy = headerFactoryImpl.createPrivacyHeader("header");
      request.addHeader(privacy);
      PrivacyHeader privacy2 = headerFactoryImpl.createPrivacyHeader("user");
      request.addHeader(privacy2);
     
      // P-Preferred-Identity
      PPreferredIdentityHeader preferredID =
        headerFactoryImpl.createPPreferredIdentityHeader(fromNameAddress);
      request.addHeader(preferredID);
     
     

      /*
       * TEST
       */
      // this is only to illustrate the usage of this headers
     
     
      // P-Called-Party-ID
      // only to test
      PCalledPartyIDHeader calledPartyID =
        headerFactoryImpl.createPCalledPartyIDHeader(toNameAddress);
      request.addHeader(calledPartyID);
     
      // P-Visited-Network-ID
      PVisitedNetworkIDHeader visitedNetworkID1 =
        headerFactoryImpl.createPVisitedNetworkIDHeader();
      visitedNetworkID1.setVisitedNetworkID(fromSipAddress
          .substring(fromSipAddress.indexOf("@")+1));
      PVisitedNetworkIDHeader visitedNetworkID2 =
        headerFactoryImpl.createPVisitedNetworkIDHeader();
      visitedNetworkID2.setVisitedNetworkID(toSipAddress
          .substring(toSipAddress.indexOf("@")+1));
      request.addHeader(visitedNetworkID1);
      request.addHeader(visitedNetworkID2);
     
     
      // P-Associated-URI
      PAssociatedURIHeader associatedURI1 =
        headerFactoryImpl.createPAssociatedURIHeader(toNameAddress);
      PAssociatedURIHeader associatedURI2 =
        headerFactoryImpl.createPAssociatedURIHeader(fromNameAddress);
      request.addHeader(associatedURI1);
      request.addHeader(associatedURI2);
     
     
      // P-Asserted-Identity
      PAssertedIdentityHeader assertedID =
        headerFactoryImpl.createPAssertedIdentityHeader(
            addressFactory.createAddress(toAddress));
      request.addHeader(assertedID);
     
      TelURL tel = addressFactory.createTelURL("+1-201-555-0123");
      Address telAddress = addressFactory.createAddress(tel);
      toNameAddress.setDisplayName(toDisplayName);
      PAssertedIdentityHeader assertedID2 =
        headerFactoryImpl.createPAssertedIdentityHeader(telAddress);
      request.addHeader(assertedID2);
     
     
      // P-Charging-Function-Addresses
      PChargingFunctionAddressesHeader chargAddr =
        headerFactoryImpl.createPChargingFunctionAddressesHeader();
      chargAddr.addChargingCollectionFunctionAddress("test1.ims.test");
      chargAddr.addEventChargingFunctionAddress("testevent");
      request.addHeader(chargAddr);
     
      // P-Charging-Vector
      PChargingVectorHeader chargVect =
        headerFactoryImpl.createChargingVectorHeader("icid");
      chargVect.setICIDGeneratedAt("icidhost");
      chargVect.setOriginatingIOI("origIOI");
      chargVect.setTerminatingIOI("termIOI");
      request.addHeader(chargVect);
     
      // P-Media-Authorization
      PMediaAuthorizationHeader mediaAuth1 =
        headerFactoryImpl.createPMediaAuthorizationHeader("13579bdf");
      PMediaAuthorizationHeader mediaAuth2 =
        headerFactoryImpl.createPMediaAuthorizationHeader("02468ace");
      request.addHeader(mediaAuth1);
      request.addHeader(mediaAuth2);
     

      // Path header
      PathHeader path1 =
        headerFactoryImpl.createPathHeader(fromNameAddress);
      PathHeader path2 =
        headerFactoryImpl.createPathHeader(toNameAddress);
      request.addHeader(path1);
      request.addHeader(path2);
     
     
     
View Full Code Here

     * @return -- an iterator of Content blocks.
     *
     */
    public void createContentList(String body) throws ParseException {
        try {
            HeaderFactoryExt headerFactory = new HeaderFactoryImpl();
            String delimiter = this.getContentTypeHeader().getParameter(BOUNDARY);

            if (delimiter == null) {
                this.contentList = new LinkedList<Content>();
                ContentImpl content = new ContentImpl(body, delimiter);
                content.setContentTypeHeader(this.getContentTypeHeader());
                this.contentList.add(content);
                return;
            }

            String[] fragments = body.split("--" + delimiter + "\r\n");


            for (String nextPart : fragments) {
                // NOTE - we are not hanlding line folding for the sip header here.

                if (nextPart == null) {
                    return;
                }
                StringBuffer strbuf = new StringBuffer(nextPart);
                while (strbuf.length() > 0
                        && (strbuf.charAt(0) == '\r' || strbuf.charAt(0) == '\n'))
                    strbuf.deleteCharAt(0);

                if (strbuf.length() == 0)
                    continue;
                nextPart = strbuf.toString();
                int position = nextPart.indexOf("\r\n\r\n");
                int off = 4;
                if (position == -1) {
                    position = nextPart.indexOf("\n");
                    off = 2;
                }
                if (position == -1)
                    throw new ParseException("no content type header found in " + nextPart, 0);
                String rest = nextPart.substring(position + off);

                if (rest == null)
                    throw new ParseException("No content [" + nextPart + "]", 0);
                // logger.debug("rest = [[" + rest + "]]");
                String headers = nextPart.substring(0, position);
                ContentImpl content = new ContentImpl(rest, boundary);

                String[] headerArray = headers.split("\r\n");
                for (String hdr : headerArray) {
                    Header header = headerFactory.createHeader(hdr);
                    if (header instanceof ContentTypeHeader) {
                        content.setContentTypeHeader((ContentTypeHeader) header);
                    } else if (header instanceof ContentDispositionHeader) {
                        content.setContentDispositionHeader((ContentDispositionHeader) header);
                    } else {
View Full Code Here

        System.out.println("Let us now test the usage of this header from the");
        System.out.println("perspective of the application");
        System.out.println("***********************************************");


        HeaderFactoryImpl himpl = new HeaderFactoryImpl();

        PAssertedServiceHeader ppsh = himpl.createPAssertedServiceHeader();

        // This is a 3gpp-service type:
        ppsh.setSubserviceIdentifiers("chatroom.presenceenabled.photoshareservice");

        System.out.println("The encoded header is-----> "+ppsh.toString());
View Full Code Here

TOP

Related Classes of gov.nist.javax.sip.header.HeaderFactoryImpl

Copyright © 2018 www.massapicom. 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.