Revision: 14940
Author: [email protected]
Date: Thu Oct 28 01:05:37 2010
Log: Fixes Issue 2048
http://code.google.com/p/mobicents/source/detail?r=14940

Modified:
/trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/InitialRequestDispatcher.java /trunk/servers/sip-servlets/sip-servlets-test-suite/applications/replaces-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/DispatchReplacesMainSipServlet.java /trunk/servers/sip-servlets/sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/replaces/ReplacesSipServletTest.java

=======================================
--- /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/InitialRequestDispatcher.java Thu Sep 9 15:06:29 2010 +++ /trunk/servers/sip-servlets/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/core/dispatchers/InitialRequestDispatcher.java Thu Oct 28 01:05:37 2010
@@ -207,17 +207,18 @@
                        if(targetedRequestInfo != null) {
// If no match is found, but the Request-URI in the INVITE corresponds to a conference URI, the UAS MUST ignore the Join header and continue
                                // processing the INVITE as if the Join header 
did not exist
-                       } else
- //Otherwise if no match is found, the UAS rejects the INVITE and returns a 481 Call/Transaction Does Not Exist response.
-                       if(joinReplacesDialog == null && targetedRequestInfo == 
null) {
- throw new DispatcherException(Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST, "Join/Replaces Header : no match is found as per RFC 3911, Section 4 or RFC 3891, Section 3 in the request " + request);
-                       } else
- //Likewise, if the Join/Replaces header field matches a dialog which was not created with an INVITE, the UAS MUST reject the request with a 481 response. - if(((TransactionApplicationData)joinReplacesDialog.getApplicationData()) != null && !Request.INVITE.equals(((TransactionApplicationData)joinReplacesDialog.getApplicationData()).getSipServletMessage().getMethod())) {
+                       }  else if(joinReplacesDialog == null && 
targetedRequestInfo == null) {
+ // Issue 2048 : Should comply with 15.11.4.4.If no SipSession matching the tuple is found, + // the container MUST pass the request to the Application Router as an untargeted request, i.e., where the SipTargetedRequestInfo argument to getNextApplication() is null.
+                               // so nothing to do here
+
+ //Otherwise if no match is found, the UAS rejects the INVITE and returns a 481 Call/Transaction Does Not Exist response. +// throw new DispatcherException(Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST, "Join/Replaces Header : no match is found as per RFC 3911, Section 4 or RFC 3891, Section 3 in the request " + request); + } else if(((TransactionApplicationData)joinReplacesDialog.getApplicationData()) != null && !Request.INVITE.equals(((TransactionApplicationData)joinReplacesDialog.getApplicationData()).getSipServletMessage().getMethod())) { + //Likewise, if the Join/Replaces header field matches a dialog which was not created with an INVITE, the UAS MUST reject the request with a 481 response. throw new DispatcherException(Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST, "Join/Replaces header field matches a dialog which was not created with an INVITE as per RFC 3911, Section 4 or RFC 3891, Section 3 in the request " + request);
-                       } else
- // If the Join/Replaces header field matches a dialog which has already terminated, the UA SHOULD decline the request with a 603 Declined response.
-                       
if(DialogState.TERMINATED.equals(joinReplacesDialog.getState())) {
+ } else if(DialogState.TERMINATED.equals(joinReplacesDialog.getState())) { + // If the Join/Replaces header field matches a dialog which has already terminated, the UA SHOULD decline the request with a 603 Declined response. throw new DispatcherException(Response.DECLINE, "Join/Replaces header field matches a dialog which has already terminated as per RFC 3911, Section 4 or RFC 3891, Section 3 in the request " + request);
                        }
//TODO If the initiator of the new INVITE has authenticated successfully as equivalent to the user who is being joined, then the join is authorized
@@ -626,29 +627,31 @@
         */
        private MobicentsSipSession retrieveSipSession(Dialog dialog) {

- Iterator<SipContext> iterator = sipApplicationDispatcher.findSipApplications();
-               while(iterator.hasNext()) {
-                       SipContext sipContext = iterator.next();
-                       SipManager sipManager = sipContext.getSipManager();
-
- Iterator<MobicentsSipSession> sipSessionsIt= sipManager.getAllSipSessions();
-                       while (sipSessionsIt.hasNext()) {
- MobicentsSipSession mobicentsSipSession = (MobicentsSipSession) sipSessionsIt
-                                               .next();
-                               SipSessionKey sessionKey = 
mobicentsSipSession.getKey();
- if(sessionKey.getCallId().trim().equals(dialog.getCallId().getCallId())) {
-                                       if(logger.isDebugEnabled()) {
- logger.debug("found session with the same Call Id " + sessionKey + ", to Tag " + sessionKey.getToTag()); - logger.debug("dialog localParty = " + dialog.getLocalParty().getURI() + ", localTag " + dialog.getLocalTag()); - logger.debug("dialog remoteParty = " + dialog.getRemoteParty().getURI() + ", remoteTag " + dialog.getRemoteTag());
-                                       }
- if(sessionKey.getFromTag().equals(dialog.getLocalTag()) && sessionKey.getToTag().equals(dialog.getRemoteTag())) {
-                                               
if(mobicentsSipSession.getProxy() == null) {
-                                                       return 
mobicentsSipSession;
-                                               }
- } else if (sessionKey.getFromTag().equals(dialog.getRemoteTag()) && sessionKey.getToTag().equals(dialog.getLocalTag())){
-                                               
if(mobicentsSipSession.getProxy() == null) {
-                                                       return 
mobicentsSipSession;
+               if(dialog != null) {
+ Iterator<SipContext> iterator = sipApplicationDispatcher.findSipApplications();
+                       while(iterator.hasNext()) {
+                               SipContext sipContext = iterator.next();
+                               SipManager sipManager = 
sipContext.getSipManager();
+
+ Iterator<MobicentsSipSession> sipSessionsIt= sipManager.getAllSipSessions();
+                               while (sipSessionsIt.hasNext()) {
+ MobicentsSipSession mobicentsSipSession = (MobicentsSipSession) sipSessionsIt
+                                                       .next();
+                                       SipSessionKey sessionKey = 
mobicentsSipSession.getKey();
+ if(sessionKey.getCallId().trim().equals(dialog.getCallId().getCallId())) {
+                                               if(logger.isDebugEnabled()) {
+ logger.debug("found session with the same Call Id " + sessionKey + ", to Tag " + sessionKey.getToTag()); + logger.debug("dialog localParty = " + dialog.getLocalParty().getURI() + ", localTag " + dialog.getLocalTag()); + logger.debug("dialog remoteParty = " + dialog.getRemoteParty().getURI() + ", remoteTag " + dialog.getRemoteTag());
+                                               }
+ if(sessionKey.getFromTag().equals(dialog.getLocalTag()) && sessionKey.getToTag().equals(dialog.getRemoteTag())) {
+                                                       
if(mobicentsSipSession.getProxy() == null) {
+                                                               return 
mobicentsSipSession;
+                                                       }
+ } else if (sessionKey.getFromTag().equals(dialog.getRemoteTag()) && sessionKey.getToTag().equals(dialog.getLocalTag())){
+                                                       
if(mobicentsSipSession.getProxy() == null) {
+                                                               return 
mobicentsSipSession;
+                                                       }
                                                }
                                        }
                                }
=======================================
--- /trunk/servers/sip-servlets/sip-servlets-test-suite/applications/replaces-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/DispatchReplacesMainSipServlet.java Tue Sep 15 02:24:29 2009 +++ /trunk/servers/sip-servlets/sip-servlets-test-suite/applications/replaces-sip-servlet/src/main/java/org/mobicents/servlet/sip/testsuite/DispatchReplacesMainSipServlet.java Thu Oct 28 01:05:37 2010
@@ -50,6 +50,9 @@
getServletContext().getNamedDispatcher("ReplacesReceiverSipServlet");
                      dispatcher.forward(request,null);
                }
+ if("replaces-no-dialog".equalsIgnoreCase(((SipURI)request.getRequestURI()).getUser())) {
+                       request.createResponse(200).send();
+               }
        }

        @Override
@@ -71,4 +74,10 @@
                      dispatcher.forward(null,response);
                }
        }
-}
+
+       @Override
+       protected void doBye(SipServletRequest request) throws ServletException,
+                       IOException {
+               request.createResponse(200).send();
+       }
+}
=======================================
--- /trunk/servers/sip-servlets/sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/replaces/ReplacesSipServletTest.java Tue Nov 17 04:02:35 2009 +++ /trunk/servers/sip-servlets/sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/replaces/ReplacesSipServletTest.java Thu Oct 28 01:05:37 2010
@@ -16,6 +16,8 @@
  */
 package org.mobicents.servlet.sip.testsuite.replaces;

+import gov.nist.javax.sip.header.extensions.ReplacesHeader;
+
 import javax.sip.SipProvider;
 import javax.sip.address.SipURI;

@@ -137,6 +139,35 @@
                assertTrue(receiver.getByeReceived());
                assertTrue(sender.getByeReceived());
        }
+
+       /*
+        * Non regression test for Issue 2048
+        */
+       public void testSipServletReceivesReplacesNoDialog() throws Exception {
+               sender = new TestSipListener(5080, 5070, senderProtocolObjects, 
true);
+               sender.setRecordRoutingProxyTesting(true);
+               SipProvider senderProvider = sender.createProvider();
+
+               senderProvider.addSipListener(sender);
+
+               senderProtocolObjects.start();
+
+               String fromName = "sender";
+               String fromHost = "sip-servlets.com";
+               SipURI fromAddress = 
senderProtocolObjects.addressFactory.createSipURI(
+                               fromName, fromHost);
+
+               String toUser = "replaces-no-dialog";
+               String toHost = "sip-servlets.com";
+               SipURI toAddress = 
senderProtocolObjects.addressFactory.createSipURI(
+                               toUser, toHost);
+
+ sender.sendSipRequest("INVITE", fromAddress, toAddress, null, null, false, new String[] {ReplacesHeader.NAME}, new String[] {"YWJiMDVhYWQ5ZmRmNDdmMGZmZjU4MDE0MzY0ODRlZWQ.;from-tag=61190912_4d8055f4_51b2ad2b-94d2-4b51-bfbe-fc8381cf5857;to-tag=243e7a12"}, true);
+               Thread.sleep(TIMEOUT);
+               assertTrue(sender.isFinalResponseReceived());
+               assertFalse(sender.isServerErrorReceived());
+               assertTrue(sender.getOkToByeReceived());
+       }

        @Override
        protected void tearDown() throws Exception {

Reply via email to