Package org.cipango.sip

Examples of org.cipango.sip.NameAddr


public class B2bHelperTest
{
  @Test
  public void testMergeContact() throws Exception
  {
    Address destination = new NameAddr("<sip:127.0.0.1:5060>");
    B2bHelper.mergeContact("Bob <sip:bob@127.0.0.22:5070;transport=UDP;ttl=1>;p=2", destination);
    assertEquals("Bob <sip:bob@127.0.0.1:5060;transport=UDP>;p=2", destination.toString());
  }
View Full Code Here


public class TestReadOnly
{
  @Test
  public void testAddress() throws Exception
  {
    Address orig = new NameAddr("\"Hello World\" <sip:foo@bar.com;transport=tcp>;tag=12345");
    Address readOnly = new ReadOnlyAddress((Address) orig.clone());
   
    assertEquals(orig, readOnly);
    try { readOnly.setParameter("foo", "bar"); fail();} catch (IllegalStateException e) {}
    try { readOnly.removeParameter("tag"); fail();} catch (IllegalStateException e) {}
    try { readOnly.setDisplayName(""); fail();} catch (IllegalStateException e) {}
    try { ((SipURI) readOnly.getURI()).removeParameter("transport"); fail();} catch (IllegalStateException e) {}
    try { ((SipURI) readOnly.getURI()).setUser("foo2"); fail();} catch (IllegalStateException e) {}
   
    assertEquals(orig, readOnly);
    assertEquals(readOnly, orig);
   
    try { readOnly.setURI(new TelURLImpl("tel:+3398648;user=phone")); fail();} catch (IllegalStateException e) {}
   
    assertEquals(orig, readOnly);
    assertEquals(readOnly, orig);
    assertEquals(orig.toString(), readOnly.toString());
    Address clone = (Address) readOnly.clone();
    clone.setParameter("a", "b");
    testSerializable(readOnly);
  }
View Full Code Here

  public void testPushRoute() throws Exception
  {   
    SipRequest request = (SipRequest) getMessage(INVITE);
    assertFalse(request.isNextHopStrictRouting());
   
    request.pushRoute(new NameAddr("<sip:strictRouting@nexcom.fr>"));
    assertEquals("sip:strictRouting@nexcom.fr", request.getRequestURI().toString());
    assertEquals("<sips:ss2.biloxi.example.com>", request.getTopRoute().toString());
    assertTrue(request.isNextHopStrictRouting());
   
    request.pushRoute(new NameAddr("<sip:strictRouting-2@nexcom.fr>"));
    assertEquals("sip:strictRouting-2@nexcom.fr", request.getRequestURI().toString());
    ListIterator<Address> it = request.getAddressHeaders("route");
    List<String> expected = new ArrayList<String>();
    expected.add("<sip:strictRouting@nexcom.fr>");
    expected.add("<sips:ss2.biloxi.example.com>");
    assertAddress(expected, it);
    assertTrue(request.isNextHopStrictRouting());
   
    request.pushRoute(new NameAddr("<sip:looseRouting@nexcom.fr;lr>"));
    assertEquals("sips:ss2.biloxi.example.com", request.getRequestURI().toString());
    it = request.getAddressHeaders("route");
    expected = new ArrayList<String>();
    expected.add("<sip:looseRouting@nexcom.fr;lr>");
    expected.add("<sip:strictRouting-2@nexcom.fr>");
    expected.add("<sip:strictRouting@nexcom.fr>");
    assertAddress(expected, it);
    assertFalse(request.isNextHopStrictRouting());
   
    request.pushRoute(new NameAddr("<sip:looseRouting-2@nexcom.fr;lr>"));
    assertEquals("sips:ss2.biloxi.example.com", request.getRequestURI().toString());
    it = request.getAddressHeaders("route");
    expected = new ArrayList<String>();
    expected.add("<sip:looseRouting-2@nexcom.fr;lr>");
    expected.add("<sip:looseRouting@nexcom.fr;lr>");
    expected.add("<sip:strictRouting-2@nexcom.fr>");
    expected.add("<sip:strictRouting@nexcom.fr>");
    assertAddress(expected, it);
    assertFalse(request.isNextHopStrictRouting());
   
    /*-----------*/
    request = (SipRequest) getMessage(INVITE);
    request.pushRoute(new NameAddr("<sip:looseRouting@nexcom.fr;lr>"));
    assertEquals("sips:ss2.biloxi.example.com", request.getRequestURI().toString());
    assertEquals("<sip:looseRouting@nexcom.fr;lr>", request.getTopRoute().toString());
    assertFalse(request.isNextHopStrictRouting());
   
    request.pushRoute(new NameAddr("<sip:strictRouting@nexcom.fr>"));
    assertEquals("sip:strictRouting@nexcom.fr", request.getRequestURI().toString());
    it = request.getAddressHeaders("route");
    expected = new ArrayList<String>();
    expected.add("<sip:looseRouting@nexcom.fr;lr>");
    expected.add("<sips:ss2.biloxi.example.com>");
    assertAddress(expected, it);
    assertTrue(request.isNextHopStrictRouting());
   
    request.pushRoute(new NameAddr("<sip:strictRouting-2@nexcom.fr>"));
    assertEquals("sip:strictRouting-2@nexcom.fr", request.getRequestURI().toString());
    it = request.getAddressHeaders("route");
    expected = new ArrayList<String>();
    expected.add("<sip:strictRouting@nexcom.fr>");
    expected.add("<sip:looseRouting@nexcom.fr;lr>");
View Full Code Here

{
  @Test
  public void testProxyAddress() throws Exception
  {
    SipRequest request = new SipRequest();
    NameAddr address = new NameAddr("sip:alice@atlanta.com");
    Address readOnlyAddress = new ReadOnlyAddress(address);
   
    request.addAddressHeader("p-asserted-identity", readOnlyAddress, true);
   
    Address addr = request.getAddressHeader("p-asserted-identity");
View Full Code Here

    }
  }
 
  public static void main(String[] args) throws Exception
  {
    NameAddr dest = new NameAddr("Alice <sip:alice@atlanta.com>;toberemoved");
    NameAddr src = new NameAddr("sip:alice@atlanta2.com;tag=void;foo=bar");
    mergeFromTo(src, dest);
   
    System.out.println(dest);
  }
View Full Code Here

           
      _request.setMaxForwards(mf);
      _request.setRequestURI(_uri);
     
      if (_branchRRUri != null)
        _request.addRecordRoute(new NameAddr(_branchRRUri));
     
      if (_branchPathUri != null && _request.isRegister())
        _request.addAddressHeader(SipHeaders.PATH, new NameAddr(_branchPathUri), true);
       
      //_ctx = _request.getCallSession().getServer().sendRequest(_request, this);
      try
      {
        _ctx = _request.session().sendRequest(_request, this);
View Full Code Here

  private String _user;
  private String _passwd;
 
  public UserAgent(SipURI aor)
  {
    _localAddress = new NameAddr(aor);
  }
View Full Code Here

  public void addAgent(UserAgent agent)
  {
    SipURI contact = (SipURI) getContact().clone();
   
    agent.setFactory(_context.getSipFactory());
    agent.setContact(new NameAddr(contact));
   
    synchronized(_userAgents)
    {
      _userAgents.add(agent);
    }
View Full Code Here

   */
  public SipServletRequest createRequest(SipServletRequest origRequest)
  {
    SipRequest srcRequest = (SipRequest) origRequest;

    NameAddr local = (NameAddr) srcRequest.from().clone();
      local.setParameter(SipParams.TAG, ID.newTag());
     
      NameAddr remote = (NameAddr) srcRequest.to().clone();
      remote.removeParameter(SipParams.TAG);
     
      String callId = ID.newCallId(srcRequest.getCallId());
   
    AppSession appSession = srcRequest.appSession();
       
View Full Code Here

            List<String> l = entry.getValue();
            if (l.size() > 0)
            {
              try
              {
                Address address = new NameAddr(l.get(0));
               
                mergeFromTo(address, request.getFields().getAddress(name));
              }
              catch (ServletException e)
              {
                throw new IllegalArgumentException("Invalid " + name + " header ", e);
              }
            }
          }
          else if (ordinal == SipHeaders.ROUTE_ORDINAL && request.isInitial())
          {
            request.getFields().remove(SipHeaders.ROUTE_BUFFER);
            for (String route : entry.getValue())
            {
              request.getFields().addString(SipHeaders.ROUTE_BUFFER, route);
            }
          }
          else
          {
            throw new IllegalArgumentException("Header " + s + " is system.");
          }
        }
        else if (ordinal == SipHeaders.CONTACT_ORDINAL)
        {
          NameAddr contact = (NameAddr) request.getFields().getAddress(SipHeaders.CONTACT_BUFFER);
          List<String> contacts = entry.getValue();
         
          if (contacts.size() > 0)
          {
            try
            {
              if (contact != null)
                mergeContact(contacts.get(0), contact);
              else if (request.isRegister())
                request.getFields().setAddress(SipHeaders.CONTACT_BUFFER, new NameAddr(contacts.get(0)));
            }
            catch (ServletParseException e)
            {
              throw new IllegalArgumentException("Invalid Contact header: " + contacts.get(0));
            }
View Full Code Here

TOP

Related Classes of org.cipango.sip.NameAddr

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.