public void setValue(String value) { try { ContactHeader contactHeader = (ContactHeader) SipFactoryImpl.headerFactory.createHeader( ContactHeader.NAME, value); this.address = SipFactoryImpl.addressFactory.createAddress(value); this.parameters = getParameters(((Parameters) contactHeader)); } catch (Exception ex) { throw new IllegalArgumentException("Illegal argument", ex); } }
this.loadBalancerHeartBeatingService = loadBalancerHeartBeatingService; try { javax.sip.address.SipURI sipUriUdp = addressFactory.createSipURI(null, address.getHostAddress()); sipUriUdp.setPort(sipPort); sipUriUdp.setLrParam(); addressFactory.createAddress(sipUriUdp); balancerRouteHeaderUdp = headerFactory.createRouteHeader(routeAddressUdp); addressFactory.createAddress(sipUriTcp); balancerRouteHeaderTcp = headerFactory.createRouteHeader(routeAddressTcp); sipAddress = addressFactory.createAddress(sipAddressUri);
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { try { calleeCSeq = in.readLong(); callerCSeq = in.readLong(); calleeContact = SipFactoryImpl.addressFactory.createURI(in.readUTF()); callerContact = SipFactoryImpl.addressFactory.createURI(in.readUTF()); int routeSetSize = in.readInt(); for (int i = 0; i < routeSetSize; i++) { javax.sip.address.Address route = SipFactoryImpl.addressFactory.createAddress(in.readUTF()); callerRouteSet.add(route); } routeSetSize = in.readInt(); for (int i = 0; i < routeSetSize; i++) { javax.sip.address.Address route = SipFactoryImpl.addressFactory.createAddress(in.readUTF()); calleeRouteSet.add(route); } javax.sip.address.Address toAddress = SipFactoryImpl.addressFactory.createAddress(in.readUTF()); toHeader = (To) SipFactoryImpl.headerFactory.createToHeader(toAddress, in.readUTF()); javax.sip.address.Address fromAddress = SipFactoryImpl.addressFactory.createAddress(in.readUTF()); fromHeader = (From) SipFactoryImpl.headerFactory.createFromHeader(fromAddress, in.readUTF()); callId = in.readUTF(); } catch (ParseException e) { throw new IllegalArgumentException("Problem occurred while unserializing ProxyTerminationInfo", e); } } /*
javax.sip.address.SipURI outboundInterfaceURI = (javax.sip.address.SipURI) SipFactoryImpl.addressFactory.createURI(outboundInterface); host = outboundInterfaceURI.getHost(); } else { host = getIpAddress(usePublicAddress); javax.sip.address.SipURI sipURI = SipFactoryImpl.addressFactory.createSipURI(userName, host); sipURI.setHost(host); sipURI.setPort(port); sipURI.setTransportParam(transport); javax.sip.address.Address contactAddress = SipFactoryImpl.addressFactory.createAddress(sipURI); ContactHeader contact = SipFactoryImpl.headerFactory.createContactHeader(contactAddress);
public SipURI createSipURI(String user, String host) { if (logger.isDebugEnabled()) { logger.debug("Creating SipURI from USER[" + user + "] HOST[" + host + "]"); } // Fix for http://code.google.com/p/sipservlets/issues/detail?id=145 if(user != null && user.trim().isEmpty()) { user = null; } try { return new SipURIImpl(SipFactoryImpl.addressFactory.createSipURI( user, host), ModifiableRule.Modifiable); } catch (ParseException e) { logger.error("couldn't parse the SipURI from USER[" + user + "] HOST[" + host + "]", e); throw new IllegalArgumentException("Could not create SIP URI user = " + user + " host = " + host); } }
public void setValue(String value) { try { this.uri = SipFactoryImpl.addressFactory.createURI(value); } catch (ParseException ex) { logger.error("Bad input arg", ex); throw new IllegalArgumentException("Bad input arg", ex); } }
private void sendSIPMessage(String toAddressString, String message) { try { Address toAddress = sipAddressFactory.createAddress(toAddressString); toAddress.setDisplayName(toAddressString); ToHeader toHeader = sipHeaderFactory.createToHeader(toAddress, null); SipURI fromAddress = sipAddressFactory.createSipURI("missed-calls", System.getProperty("bind.address", "127.0.0.1")); Address fromNameAddress = sipAddressFactory.createAddress(fromAddress); fromNameAddress.setDisplayName("Missed Calls"); FromHeader fromHeader = sipHeaderFactory.createFromHeader(fromNameAddress, "12345SomeTagID6789"); URI uri = sipProvider.getAddressFactory().createURI(toAddressString); Request req = sipMessageFactory.createRequest(uri, Request.MESSAGE, this.sipProvider.getNewCallId(), sipHeaderFactory.createCSeqHeader(1L, Request.MESSAGE), fromHeader, toHeader, viaHeaders, maxForwards);
/** * 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); } }
public void setValue(String value) { try { this.uri = SipFactoryImpl.addressFactory.createURI(value); if(this.uri instanceof Parameters) { super.setParameters(AddressImpl.getParameters((Parameters)uri)); } else { super.setParameters(new ConcurrentHashMap<String, String>()); } } catch (ParseException ex) { logger.error("Bad input arg", ex); throw new IllegalArgumentException("Bad input arg", ex); } }
public Address createAddress(URI uri) { if (logger.isDebugEnabled()) { logger.debug("Creating Address fromm URI[" + uri.toString() + "]"); } URIImpl uriImpl = (URIImpl) uri; return new AddressImpl(SipFactoryImpl.addressFactory .createAddress(uriImpl.getURI()), null, ModifiableRule.Modifiable); }
private void createContactHeader() throws ParseException { SipURI contactURI = addressFactory.createSipURI(getFromUser(), getFromHost()); contactURI.setTransportParam(getTransport()); contactURI.setPort(Integer.valueOf(getFromPort()).intValue()); Address contactAddress = addressFactory.createAddress(contactURI); // Add the contact address. contactAddress.setDisplayName(getFromUser()); contactHeader = headerFactory.createContactHeader(contactAddress); }
/** * @param proxyBranch * @param request * @param proxy * @param poppedURI */ private static void addRecordRouteHeader( Request request, SipFactoryImpl sipFactoryImpl, javax.sip.address.SipURI poppedURI) { try { SipURI recordRouteURI = (SipURI)((RecordRouteHeader)request.getHeader(RecordRouteHeader.NAME)).getAddress().getURI(); javax.sip.address.SipURI newRecordRouteURI = (javax.sip.address.SipURI) sipFactoryImpl.getAddressFactory().createURI(recordRouteURI.toString()); newRecordRouteURI.removeParameter(MessageDispatcher.SIP_OUTBOUND_PARAM_OB); newRecordRouteURI.setUser(poppedURI.getUser()); RecordRouteHeader recordRouteHeader = sipFactoryImpl.getHeaderFactory().createRecordRouteHeader( sipFactoryImpl.getAddressFactory().createAddress(newRecordRouteURI)); // removes the header created when the request was cloned request.removeFirst(RecordRouteHeader.NAME); request.addFirst(recordRouteHeader); } catch (ParseException e) { logger.error("Impossible to parse the following popped URI " + poppedURI, e); } catch (SipException e) { logger.error("Impossible to add the following recordRouteHeader ", e); } }
public void setOutboundInterface(InetSocketAddress inetSocketAddress) { if(!isValid()) { throw new IllegalStateException("the session has been invalidated"); } if(inetSocketAddress == null) { throw new NullPointerException("parameter is null"); } String address = inetSocketAddress.getAddress().getHostAddress() + ":" + inetSocketAddress.getPort(); List<SipURI> list = sipFactory.getSipNetworkInterfaceManager().getOutboundInterfaces(); SipURI networkInterface = null; for(SipURI networkInterfaceURI : list) { if(networkInterfaceURI.toString().contains(address)) { networkInterface = networkInterfaceURI; break; } } if(networkInterface == null) throw new IllegalArgumentException("Network interface for " + address + " not found"); try { outboundInterface = new SipURIImpl(SipFactoryImpl.addressFactory.createSipURI(null, address), ModifiableRule.NotModifiable).toString(); } catch (ParseException e) { logger.error("couldn't parse the SipURI from USER[" + null + "] HOST[" + address + "]", e); throw new IllegalArgumentException("Could not create SIP URI user = " + null + " host = " + address); } }
public static MobicentsExtendedListeningPoint findListeningPoint( SipNetworkInterfaceManager sipNetworkInterfaceManager, Request request, String outboundInterface) { MobicentsExtendedListeningPoint listeningPoint; if(outboundInterface == null) { String transport = findTransport(request); listeningPoint = sipNetworkInterfaceManager.findMatchingListeningPoint(transport, false); } else { javax.sip.address.SipURI outboundInterfaceURI = null; try { outboundInterfaceURI = (javax.sip.address.SipURI) SipFactoryImpl.addressFactory.createURI(outboundInterface); } catch (ParseException e) { throw new IllegalArgumentException("couldn't parse the outbound interface " + outboundInterface, e); } listeningPoint = sipNetworkInterfaceManager.findMatchingListeningPoint(outboundInterfaceURI, false); } return listeningPoint; }
public Address createAddress(URI uri, String displayName) { try { if (logger.isDebugEnabled()) { logger.debug("Creating Address from URI[" + uri.toString() + "] with display name[" + displayName + "]"); } javax.sip.address.Address address = SipFactoryImpl.addressFactory .createAddress(((URIImpl) uri).getURI()); address.setDisplayName(displayName); return new AddressImpl(address, null, ModifiableRule.Modifiable); } catch (ParseException e) { throw new IllegalArgumentException(e); } }
private void createFromHeader() throws ParseException { SipURI fromAddress = getAddressFactory().createSipURI(getFromUser(), getFromHost()); fromAddress.setPort(Integer.valueOf(getFromPort()).intValue()); Address fromNameAddress = addressFactory.createAddress(fromAddress); fromNameAddress.setDisplayName(getFromUser()); setFromHeader(headerFactory.createFromHeader(fromNameAddress, getFromUser() + "_Header")); }
RouteHeader applicationRouterInfoRouteHeader = null; try { routeAddress = SipFactoryImpl.addressFactory.createAddress(routes[0]); applicationRouterInfoRouteHeader = SipFactoryImpl.headerFactory.createRouteHeader(routeAddress); if(sipApplicationDispatcher.isRouteExternal(applicationRouterInfoRouteHeader)) { routeAddress = SipFactoryImpl.addressFactory.createAddress(routes[i]); URI routeURI = routeAddress.getURI(); if(routeURI.isSipURI()) { logger.debug("Routing the request externally " + sipServletRequest ); request.setRequestURI(SipFactoryImpl.addressFactory.createURI(routes[0])); try { forwardRequestStatefully(sipServletRequest, null, sipRouteModifier);
public void setOutboundInterface(InetAddress inetAddress) { if(!isValid()) { throw new IllegalStateException("the session has been invalidated"); } if(inetAddress == null) { throw new NullPointerException("parameter is null"); } String address = inetAddress.getHostAddress(); List<SipURI> list = sipFactory.getSipNetworkInterfaceManager().getOutboundInterfaces(); SipURI networkInterface = null; for(SipURI networkInterfaceURI : list) { if(networkInterfaceURI.toString().contains(address)) { networkInterface = networkInterfaceURI; break; } } if(networkInterface == null) throw new IllegalArgumentException("Network interface for " + address + " not found"); try { outboundInterface = new SipURIImpl(SipFactoryImpl.addressFactory.createSipURI(null, address), ModifiableRule.NotModifiable).toString(); } catch (ParseException e) { logger.error("couldn't parse the SipURI from USER[" + null + "] HOST[" + address + "]", e); throw new IllegalArgumentException("Could not create SIP URI user = " + null + " host = " + address); } }
/** * Attempt to find a list of Blocked Addresses (SIP URIs), but the method * returns null if the called user (sipAddress) does not block to any user. */ private ArrayList getBlockedArrayList(String sipAddress) { //sipAddress is AOR: sip:newbie@restcomm.com ArrayList uris = null; CallControlProfileCMP profile = super.lookup(new Address(AddressPlan.SIP, sipAddress)); if (profile != null) { Address[] addresses = profile.getBlockedAddresses(); if (addresses != null) { uris = new ArrayList(addresses.length); for (int i = 0; i < addresses.length; i++) { String address = addresses[i].getAddressString(); try { SipURI uri = (SipURI) getAddressFactory().createURI(address); uris.add(uri); } catch (ParseException e) { log.severe(e.getMessage(), e); } } } } return uris; }
/** * Pushes a route header on initial request based on the jain sip sipUri given on parameter * @param sipUri the jain sip sip uri to use to construct the route header to push on the request */ private void pushRoute(javax.sip.address.SipURI sipUri) { if(!isInitial() && getSipSession().getProxy() == null) { //as per JSR 289 Section 11.1.3 Pushing Route Header Field Values // pushRoute can only be done on the initial requests. // Subsequent requests within a dialog follow the route set. // Any attempt to do a pushRoute on a subsequent request in a dialog // MUST throw and IllegalStateException. throw new IllegalStateException("Cannot push route on subsequent requests, only intial ones"); } else { if (logger.isDebugEnabled()) logger.debug("Pushing route into message of value [" + sipUri + "]"); sipUri.setLrParam(); try { javax.sip.header.Header p = SipFactoryImpl.headerFactory .createRouteHeader(SipFactoryImpl.addressFactory .createAddress(sipUri)); this.message.addFirst(p); } catch (SipException e) { logger.error("Error while pushing route [" + sipUri + "]"); throw new IllegalArgumentException("Error pushing route ", e); } } }