if ( a.isSecure() ^ b.isSecure() ) return false; if (a.getUser()==null ^ b.getUser()==null) return false; if (a.getUserPassword()==null ^ b.getUserPassword()==null) return false; if (a.getUser()!=null && !UriDecoder.decode(a.getUser()).equals(UriDecoder.decode(b.getUser()))) return false; if (a.getUserPassword()!=null && !UriDecoder.decode(a.getUserPassword()).equals(UriDecoder.decode(b.getUserPassword()))) return false; if (a.getHost() == null ^ b.getHost() == null) return false; if (a.getHost() != null && !a.getHost().equalsIgnoreCase(b.getHost())) return false; if (a.getPort() != b.getPort()) return false; for (Iterator i = a.getParameterNames(); i.hasNext();) { String pname = (String) i.next(); String p1 = a.getParameter(pname); String p2 = b.getParameter(pname); if (a.getTransportParam()==null ^ b.getTransportParam()==null) return false; if (a.getUserParam()==null ^ b.getUserParam()==null) return false; if (a.getTTLParam()==-1 ^ b.getTTLParam()==-1) return false; if (a.getMethodParam()==null ^ b.getMethodParam()==null) return false; if (a.getMAddrParam()==null ^ b.getMAddrParam()==null) return false; if(a.getHeaderNames().hasNext() && !b.getHeaderNames().hasNext()) return false; if(!a.getHeaderNames().hasNext() && b.getHeaderNames().hasNext()) return false; if(a.getHeaderNames().hasNext() && b.getHeaderNames().hasNext()) { HeaderFactory headerFactory = null; try {
if(outboundInterface!=null){ javax.sip.address.SipURI outboundInterfaceURI = (javax.sip.address.SipURI) SipFactoryImpl.addressFactory.createURI(outboundInterface); host = outboundInterfaceURI.getHost(); } else { host = getIpAddress(usePublicAddress); sipURI.setHost(host); sipURI.setPort(port); if((!sipURI.isSecure() && !ListeningPoint.UDP.equalsIgnoreCase(transport)) || (sipURI.isSecure() && !ListeningPoint.TCP.equalsIgnoreCase(transport))) { sipURI.setTransportParam(transport);
public boolean getLrParam() { return getSipURI().hasLrParam(); }
if(uri instanceof SipURI) { SipURI sipURI = (SipURI) uri; if(sipURI.isSecure()) { transport = ListeningPoint.TLS; } else { String transportParam = sipURI.getTransportParam();
/** * Check if the route is external * @param routeHeader the route to check * @return true if the route is external, false otherwise */ public final boolean isRouteExternal(RouteHeader routeHeader) { if (routeHeader != null) { javax.sip.address.SipURI routeUri = (javax.sip.address.SipURI) routeHeader.getAddress().getURI(); String routeTransport = routeUri.getTransportParam(); if(routeTransport == null) { routeTransport = ListeningPoint.UDP; } return isExternal(routeUri.getHost(), routeUri.getPort(), routeTransport); } return true; }
flowURI.setPort(remotePort); flowURI.setTransportParam(transport); + remotePort + ";transport=" + transport + " due to a parse exception"); } else if(sipServletRequest.getPoppedRouteHeader() != null && (requestUri instanceof javax.sip.address.SipURI && ((javax.sip.address.SipURI)requestUri).getParameter(SIP_OUTBOUND_PARAM_OB) != null)) { String flowToken = poppedURI.getUser();
String displayName = fromHeader.getAddress().getDisplayName(); if(fromUri instanceof javax.sip.address.SipURI) { fromName = ((javax.sip.address.SipURI)fromUri).getUser(); contactSipUri.setHost(sipConnector.getStaticServerAddress()); contactSipUri.setPort(sipConnector.getStaticServerPort()); javax.sip.address.SipURI outboundInterfaceURI = (javax.sip.address.SipURI) SipFactoryImpl.addressFactory.createURI(outboundInterface); String outboundHost = ((gov.nist.javax.sip.address.SipUri)outboundInterfaceURI).getHost(); contactSipUri.setHost(outboundHost); } else { boolean usePublicAddress = JainSipUtils.findUsePublicAddress( sipNetworkInterfaceManager, request, matchingListeningPoint); contactSipUri.setHost(matchingListeningPoint.getIpAddress(usePublicAddress)); contactSipUri.setPort(matchingListeningPoint.getPort()); contactSipUri.setTransportParam(transportForRequest); String transportParam = contactSipUri.getTransportParam(); if(transportParam != null && !transportParam.equalsIgnoreCase(transportForRequest)) { contactSipUri.setTransportParam(transportForRequest); if(requestURI.isSipURI() && ((javax.sip.address.SipURI)requestURI).isSecure()) { contactSipUri.setSecure(true); } else if(requestURI.isSipURI() && !((javax.sip.address.SipURI)requestURI).isSecure() && contactSipUri.isSecure()) { contactSipUri.setSecure(false);
String transport = sipUri.isSecure() ? SIPConstants.TLS : sipUri .getTransportParam(); if (transport == null) { if (sipUri.getPort() != -1) { port = sipUri.getPort(); } else { if (transport.equalsIgnoreCase(SIPConstants.TLS)) port = 5060; // TCP or UDP String host = sipUri.getMAddrParam() != null ? sipUri.getMAddrParam() : sipUri.getHost(); AddressResolver addressResolver = this.sipStack.getAddressResolver(); return addressResolver
String flowToken = generateFlowToken(originalRequest); try { pathURI.setUser(flowToken); pathURI.setParameter(MessageDispatcher.SIP_OUTBOUND_PARAM_OB, null); } catch (ParseException e) { logger.error("Impossible to add the ob parameter to the following path header " + pathHeader + " or flow token " + flowToken, e); final String user = (poppedURI).getUser(); Hop hop = null; if(user != null) { javax.sip.address.SipURI routeURI = (javax.sip.address.SipURI) sipFactoryImpl.getAddressFactory().createSipURI(null, hop.getHost()); routeURI.setPort(hop.getPort()); routeURI.setTransportParam(hop.getTransport()); routeURI.setLrParam(); RouteHeader routeHeader = sipFactoryImpl.getHeaderFactory().createRouteHeader( sipFactoryImpl.getAddressFactory().createAddress(routeURI));
/** * * @param hop * @param request */ private void addDnsRoute(Hop hop, final Request request) throws ParseException, SipException { if(hop != null && sipFactoryImpl.getSipApplicationDispatcher().isExternal(hop.getHost(), hop.getPort(), hop.getTransport())) { javax.sip.address.SipURI nextHopUri = SipFactoryImpl.addressFactory.createSipURI(null, hop.getHost()); nextHopUri.setLrParam(); nextHopUri.setPort(hop.getPort()); if(hop.getTransport() != null) { nextHopUri.setTransportParam(hop.getTransport()); } // Deal with http://code.google.com/p/mobicents/issues/detail?id=2346 nextHopUri.setParameter(DNSAwareRouter.DNS_ROUTE, Boolean.TRUE.toString()); final javax.sip.address.Address nextHopRouteAddress = SipFactoryImpl.addressFactory.createAddress(nextHopUri); final RouteHeader nextHopRouteHeader = SipFactoryImpl.headerFactory.createRouteHeader(nextHopRouteAddress); if(logger.isDebugEnabled()) { logger.debug("Adding next hop found by RFC 3263 lookups as route header" + nextHopRouteHeader); } request.addFirst(nextHopRouteHeader); } }
/** * Create a Record Route URI based on the host, port and transport of this listening point * @param usePublicAddress if true, the host will be the global ip address found by STUN otherwise * it will be the local network interface ipaddress * @return the record route uri */ public javax.sip.address.SipURI createRecordRouteURI(boolean usePublicAddress) { try { String host = getIpAddress(usePublicAddress); SipURI sipUri = SipFactoryImpl.addressFactory.createSipURI(null, host); sipUri.setPort(port); sipUri.setTransportParam(transport); // Do we want to add an ID here? return sipUri; } catch (ParseException ex) { logger.error ("Unexpected error while creating a record route URI",ex); throw new IllegalArgumentException("Unexpected exception when creating a record route URI", ex); } }
boolean isExternal = sipFactoryImpl.getSipApplicationDispatcher().isExternal(sipUri.getHost(), sipUri.getPort(), transport); if(!isExternal) { if(logger.isDebugEnabled()) { sipUri.getHost()) || sipConnector .getStaticServerAddress().equals( sipUri.getHost() + ":" + sipUri.getPort()))) { if(logger.isDebugEnabled()) { logger.debug("Avoiding URI optimization due to connector configuration and URI points to the static server address."); lp = sipNetworkInterfaceManager.findMatchingListeningPoint(transport, false); sipUri.setHost(lp.getHost(false)); sipUri.setPort(lp.getPort()); sipUri.setTransportParam(lp.getTransport());
public String getUser() { return RFC2396UrlDecoder.decode(getSipURI().getUser()); }
SipURI newSipURI = (SipURI) newURI; SipURI newContactSipURI = (SipURI) newContactHeader.getAddress().getURI(); ((SipURI)newContactHeader.getAddress().getURI()).setUser(newSipURI.getUser()); Iterator<String> uriParameters = newSipURI.getParameterNames(); while (uriParameters.hasNext()) { String parameter = uriParameters.next(); if(!CONTACT_FORBIDDEN_PARAMETER.contains(parameter)) { String value = newSipURI.getParameter(parameter); newContactSipURI.setParameter(parameter, "".equals(value) ? null : value);
try { javax.sip.address.SipURI sipUriUdp = addressFactory.createSipURI(null, address.getHostAddress()); sipUriUdp.setPort(sipPort); sipUriUdp.setLrParam(); javax.sip.address.SipURI sipAddressUri = (SipURI) sipUriUdp.clone(); sipUriUdp.setTransportParam("udp"); javax.sip.address.SipURI sipUriTcp = (SipURI) sipUriUdp.clone(); sipUriTcp.setTransportParam("tcp");
private void checkRequestURIForNonCompliantAgents(MobicentsProxyBranch finalBranch, Request request) throws ServletParseException { URI requestURI = request.getRequestURI(); if(request.getRequestURI() instanceof javax.sip.address.SipURI && ((Parameters)requestURI).getParameter(MessageDispatcher.RR_PARAM_PROXY_APP) != null && requestURI instanceof SipURI) { final String host = ((SipURI) requestURI).getHost(); final int port = ((SipURI) requestURI).getPort(); final String transport = JainSipUtils.findTransport(request); boolean isAnotherDomain = StaticServiceHolder.sipStandardService.getSipApplicationDispatcher().isExternal(host, port, transport); if(!isAnotherDomain) { if(logger.isDebugEnabled()) { logger.debug("Non Compliant Agent targeting Mobicents directly, Changing the request URI from " + requestURI + " to " + finalBranch.getTargetURI() + " to avoid going in a loop"); } request.setRequestURI( ((URIImpl)(StaticServiceHolder.sipStandardService.getSipApplicationDispatcher().getSipFactory().createURI( finalBranch.getTargetURI()))).getURI()); } } } }
String nextApp = ((javax.sip.address.SipURI)rHeader.getAddress().getURI()).getParameter(MessageDispatcher.RR_PARAM_APPLICATION_NAME); String serverName = ((javax.sip.address.SipURI)rHeader.getAddress().getURI()).getParameter(MessageDispatcher.RR_PARAM_SERVER_NAME); if(sipFactoryImpl.getSipApplicationDispatcher().getApplicationServerId().equals(serverName) && nextApp != null) { String nextSipAppId = ((javax.sip.address.SipURI)rHeader.getAddress().getURI()).getParameter(MessageDispatcher.APP_ID); if(nextApp != null) { final MobicentsSipApplicationSessionKey sipAppKey = originalRequest.getSipSession().getSipApplicationSession().getKey(); outboundTransport = ((javax.sip.address.SipURI)rHeader.getAddress().getURI()).getTransportParam(); if(outboundTransport == null) { outboundTransport = ListeningPoint.UDP; outboundTransport = ((javax.sip.address.SipURI)clonedRequest.getRequestURI()).getTransportParam(); if(destination != null && destination.isSipURI()) { String destinationTransport = ((SipURI)destination).getTransportParam(); if(clonedRequest.getRequestURI().isSipURI()) { javax.sip.address.SipURI sipURI = ((javax.sip.address.SipURI)clonedRequest.getRequestURI()); String transportFromURI = sipURI.getTransportParam(); if(transportFromURI == null) transportFromURI = ListeningPoint.UDP; if(!transportFromURI.equalsIgnoreCase(outboundTransport)) sipURI.setTransportParam(outboundTransport); if(!inboundTransport.equalsIgnoreCase(outboundTransport)) { javax.sip.address.SipURI inboundRURI = JainSipUtils.createRecordRouteURI(sipFactoryImpl.getSipNetworkInterfaceManager(), clonedRequest, inboundTransport); if(originalRequest.getTransport() != null) inboundRURI.setTransportParam(originalRequest.getTransport()); final Iterator<String> paramNames = routeRecord.getParameterNames(); String paramName = paramNames.next();
public ContactHeader createContactHeader() { try { String ipAddress = this.getIPAddress(); int port = this.getPort(); SipURI sipURI = new SipUri(); sipURI.setHost(ipAddress); sipURI.setPort(port); sipURI.setTransportParam(this.transport); Contact contact = new Contact(); AddressImpl address = new AddressImpl(); address.setURI(sipURI); contact.setAddress(address); return contact; } catch (Exception ex) { InternalErrorHandler.handleException("Unexpected exception",logger); return null; } }
/** * This method is used to know if the it is going to be used the voice mail * of the same user or the voice mail of a different user. * * @param event * @return TRUE: If the called user is sip:vmail@nist.gov */ private boolean sameUser(javax.sip.RequestEvent event) { boolean sameUser = false; Request inviteRequest = event.getRequest(); // Checking if the called user and the caller are the same ToHeader toHeader = (ToHeader) inviteRequest.getHeader(ToHeader.NAME); SipURI toURI = (SipURI) toHeader.getAddress().getURI(); if ((toURI.getUser().equals(USER) && toURI.getHost().equals(HOST))) { sameUser = true; } // Setting Same User value this.setSameUser(sameUser); return sameUser; }