Package gov.nist.javax.sip.header

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


    System.out.println("Now from the perspective of an application (I-CSCF) built on");
    System.out.println("top of the JSIP stack. Let us test the marshaling");
    System.out.println("of the P-User-Database header.");
    System.out.println("************************************************************");
   
    HeaderFactoryImpl himpl = new HeaderFactoryImpl();
    PUserDatabaseHeader pud = himpl.createPUserDatabaseHeader("rancorehss.rancore.com:5555");
    try {
      pud.setParameter("transport", "tcp");
    } catch (ParseException e) {
     
      e.printStackTrace();
View Full Code Here


    System.out.println("*****************************************************");
    System.out.println("From the perspective of the application, let us test");
    System.out.println("The creation of this header.....");
    System.out.println("*****************************************************");
   
    HeaderFactoryImpl himpl = new HeaderFactoryImpl();
    AddressFactory addFactory = new AddressFactoryImpl();
   
    try {
      PProfileKeyHeader ppkey = himpl.createPProfileKeyHeader
          (addFactory.createAddress("aayush's room",
               addFactory.createSipURI("aayushzChatRoom-19", "rancoremumbai.com")));
     
      System.out.println("The newly encoded header is---> "+ppkey.toString());
    } catch (ParseException e) {
View Full Code Here

    System.out.println("******************************************************");
    System.out.println("From the perspective of the application, lets test the");
    System.out.println("encoding and usage of the P-Served-User header.");
    System.out.println("******************************************************");
   
    HeaderFactoryImpl himpl = new HeaderFactoryImpl();
    AddressFactory addfact = new AddressFactoryImpl();
    try {
      PServedUserHeader psuh = himpl.createPServedUserHeader(addfact.createAddress(addfact.createSipURI("aayush", "rancore.com")));
      psuh.setSessionCase("orig");
      psuh.setRegistrationState("reg");
      System.out.println("The encoded header is---> "+psuh.toString());
      System.out.println("The sescase is---> "+psuh.getSessionCase());
      System.out.println("The Regs state is--->"+psuh.getRegistrationState());
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

    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

        System.out.println("Now from the perspective of an application (I-CSCF) built on");
        System.out.println("top of the JSIP stack. Let us test the marshaling");
        System.out.println("of the P-User-Database header.");
        System.out.println("************************************************************");

        HeaderFactoryImpl himpl = new HeaderFactoryImpl();
        PUserDatabaseHeader pud = himpl.createPUserDatabaseHeader("rancorehss.rancore.com:5555");
        try {
            pud.setParameter("transport", "tcp");
        } catch (ParseException e) {

            e.printStackTrace();
View Full Code Here

        System.out.println("*****************************************************");
        System.out.println("From the perspective of the application, let us test");
        System.out.println("The creation of this header.....");
        System.out.println("*****************************************************");

        HeaderFactoryImpl himpl = new HeaderFactoryImpl();
        AddressFactory addFactory = new AddressFactoryImpl();

        try {
            PProfileKeyHeader ppkey = himpl.createPProfileKeyHeader
                (addFactory.createAddress("aayush's room",
                         addFactory.createSipURI("aayushzChatRoom-19", "rancoremumbai.com")));

            System.out.println("The newly encoded header is---> "+ppkey.toString());
        } catch (ParseException e) {
View Full Code Here

        System.out.println("******************************************************");
        System.out.println("From the perspective of the application, lets test the");
        System.out.println("encoding and usage of the P-Served-User header.");
        System.out.println("******************************************************");

        HeaderFactoryImpl himpl = new HeaderFactoryImpl();
        AddressFactory addfact = new AddressFactoryImpl();
        try {
            PServedUserHeader psuh = himpl.createPServedUserHeader(addfact.createAddress(addfact.createSipURI("aayush", "rancore.com")));
            psuh.setSessionCase("orig");
            psuh.setRegistrationState("reg");
            System.out.println("The encoded header is---> "+psuh.toString());
            System.out.println("The sescase is---> "+psuh.getSessionCase());
            System.out.println("The Regs state is--->"+psuh.getRegistrationState());
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

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.