Package javax.sip.address

Examples of javax.sip.address.AddressFactory


    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) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here


    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

         *
         * 11. Set timer C
         */

        HeaderFactory headerFactory = jiplet.getHeaderFactory();
        AddressFactory addressFactory = jiplet.getAddressFactory();
        // Get the parameters and the transport of the request URI
        URI requestURI = requestEvent.getRequest().getRequestURI();
        Iterator parametersNames = null;

        if (requestURI.isSipURI())
        {
            parametersNames = ((SipURI) requestURI).getParameterNames();

            // this is how the JAIN-SIP jiplet guys have done it but it seems
            // problematic. Why?
            // transport = ((SipURI) requestURI).getTransportParam();
        }

        for (int i = 0; i < targetsURIList.size(); i++)
        {
            URI targetURI = (URI) targetsURIList.get(i);

            // Copy the parameters and the transport in the new Request URI
            // of the cloned Request

            //           
            // 1. Make a clone of the received request
            //           
            //           

            Request clonedRequest = (Request) requestEvent.getRequest().clone();

            //           
            // 2. Update the Request-URI
            //         

            /*
             * The Request-URI in the copy's start line MUST be replaced with
             * the URI for this target. If the URI contains any parameters not
             * allowed in a Request-URI, they MUST be removed.
             *
             * This is the essence of a jiplet's role. This is the mechanism
             * through which a jiplet routes a request toward its destination.
             *
             * In some circumstances, the received Request-URI is placed into
             * the target set without being modified. For that target, the
             * replacement above is effectively a no-op.
             *
             */
            // All the targets URI are already canonicalized
            if (requestURI.isSipURI())
            {
                clonedRequest.setRequestURI(targetURI);
            }

            //           
            // 3. Max-Forwards
            //           
            /*
             * If the copy contains a Max-Forwards header field, the jiplet MUST
             * decrement its value by one (1). If the copy does not contain a
             * Max-Forwards header field, the jiplet MUST add one with a field
             * value, which SHOULD be 70.
             */
            MaxForwardsHeader mf = (MaxForwardsHeader) clonedRequest
                    .getHeader(MaxForwardsHeader.NAME);
            if (mf == null)
            {
                mf = headerFactory.createMaxForwardsHeader(70);
                clonedRequest.addHeader(mf);
            }
            else
            {
                int max = mf.getMaxForwards() - 1;
                mf.setMaxForwards(max);
            }

            //           
            // 4. Record-Route
            //           
            /*
             * The URI placed in the Record-Route header field value MUST be a
             * SIP or SIPS URI. This URI MUST contain an lr parameter (see
             * Section 19.1.1). This URI MAY be different for each destination
             * the request is forwarded to. The URI SHOULD NOT contain the
             * transport parameter.
             */

            ListeningPoint defaultLP = jiplet.getListeningPointDefault();
            SipProvider sipProvider = jiplet.getSipProvider(defaultLP);
           
            if (addRecordRoute)
            {
                // Only in stateful forwarding
                // We add our jiplet RecordRoute header to the top of the
                // list - use the following recommended mechanism to handle multi-homing

                /*
                 * If the URI placed in the Record-Route header field needs to
                 * be rewritten when it passes back through in a response, the
                 * URI MUST be distinct enough to locate at that time. (The
                 * request may spiral through this proxy, resulting in more than
                 * one Record-Route header field value being added). Item 8 of
                 * Section 16.7 recommends a mechanism to make the URI
                 * sufficiently distinct.
                 *
                 * The proxy MAY include parameters in the Record-Route header
                 * field value. These will be echoed in some responses to the
                 * request such as the 200 (OK) responses to INVITE. Such
                 * parameters may be useful for keeping state in the message
                 * rather than the proxy.
                 */

                if (stateful)
                {
                    SipURI sipURI = addressFactory.createSipURI(null, defaultLP
                            .getIPAddress());

                    sipURI.setPort(defaultLP.getPort());
                    sipURI.setTransportParam(defaultLP.getTransport());
                    sipURI.setLrParam();

                    // save the IP address and port the request came in on, for
                    // rewriting the record route header later in the response
                    // put it in this forwarded message itself - user part of RR
                    SipProvider sourceProvider = (SipProvider) requestEvent
                            .getSource();
                    ListeningPoint sourceLp = sourceProvider
                            .getListeningPoints()[0];
                    sipURI.setUser(sourceLp.getIPAddress() + '-' + sourceLp.getPort());
                   
                    Address address = addressFactory
                            .createAddress(null, sipURI);
                    RecordRouteHeader recordRouteHeader = headerFactory
                            .createRecordRouteHeader(address);

                    ListIterator recordRouteHeaders = clonedRequest
View Full Code Here

        } catch (ParseException ex) {
            fail(this.getClass().getName());
        }
        // Non regression test for Issue 316 : createAddress can add spurious angle brackets
        try {
            AddressFactory addressFactory = SipFactory.getInstance().createAddressFactory();
            String uriString = "<sip:1004@172.16.0.99;user=phone>";           
            try {
                addressFactory.createURI(uriString);
                fail("uriString should throw a ParseException because the angle brackets are not valid");
            } catch (ParseException e) {}
            try {
                Address address = addressFactory.createAddress(uriString);
                assertEquals(uriString, address.toString());    
                address.setDisplayName("1004");
                assertEquals("\"1004\" " + uriString, address.toString());
            } catch (ParseException e) {
                e.printStackTrace();
View Full Code Here

        } catch (ParseException ex) {
            fail(this.getClass().getName());
        }
        // Non regression test for Issue 316 : createAddress can add spurious angle brackets
        try {
            AddressFactory addressFactory = SipFactory.getInstance().createAddressFactory();
            String uriString = "<sip:1004@172.16.0.99;user=phone>";           
            try {
                addressFactory.createURI(uriString);
                fail("uriString should throw a ParseException because the angle brackets are not valid");
            } catch (ParseException e) {}
            try {
                Address address = addressFactory.createAddress(uriString);
                assertEquals(uriString, address.toString());    
                address.setDisplayName("1004");
                assertEquals("\"1004\" " + uriString, address.toString());
            } catch (ParseException e) {
                e.printStackTrace();
View Full Code Here

        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) {
            // TODO Auto-generated catch block
            e.printStackTrace();
View Full Code Here

        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

public class Parser {

    public static void main(String[] args) throws Exception {
        SipFactory sipFactory = null;
        HeaderFactory headerFactory;
        AddressFactory addressFactory;
        MessageFactory messageFactory;

        sipFactory = SipFactory.getInstance();
        sipFactory.setPathName("gov.nist");
View Full Code Here

public class Parser {

  public static void main(String[] args) throws Exception {
    SipFactory sipFactory = null;
    HeaderFactory headerFactory;
    AddressFactory addressFactory;
    MessageFactory messageFactory;

    sipFactory = SipFactory.getInstance();
    sipFactory.setPathName("gov.nist");
View Full Code Here

    }
    return new String(c);
  }

  private AddressFactory getAddressFactory() {
    AddressFactory addressFactory = null;
    try {
      Context myEnv = (Context) new InitialContext()
          .lookup("java:comp/env");
      SipFactoryProvider factoryProvider = (SipFactoryProvider) myEnv
          .lookup("slee/resources/jainsip/1.2/provider");
View Full Code Here

TOP

Related Classes of javax.sip.address.AddressFactory

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.