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); } }
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); } } /*
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); }
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); } }
/** * 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); } } }
private List<ContactHeader> getContactHeaders( Collection<RegistrationBinding> bindings) { if (bindings == null) return null; ArrayList<ContactHeader> contactHeaders = new ArrayList<ContactHeader>(); Iterator<RegistrationBinding> it = bindings.iterator(); while (it.hasNext()) { RegistrationBinding binding = it.next(); try { Address contactAddress = addressFactory.createAddress(binding .getContactAddress()); javax.sip.header.ContactHeader contactHeader = headerFactory .createContactHeader(contactAddress); // String comment = getComment(); contactHeader.setExpires((int) binding.getExpiresDelta()); contactHeader.setQValue(binding.getQValue()); contactHeaders.add(contactHeader); } catch (Exception e) { this.tracer.warning("Failed to create contact headers", e); } } return contactHeaders; }
/** * Attempt to find a Backup Address, but the method returns null if there * isn't any address to forward the INVITE. */ private Address getBackupAddress(String sipAddress) { Address backupAddress = null; CallControlProfileCMP profile = this.lookup(new javax.slee.Address( AddressPlan.SIP, sipAddress)); if (profile != null) { javax.slee.Address address = profile.getBackupAddress(); if (address != null) { try { backupAddress = getAddressFactory().createAddress( address.getAddressString()); } catch (ParseException e) { log.error(e.getMessage(), e); } } } return backupAddress; }
/** * Creates a {@link Address} with a {@link SipUri}, from the specified host * and port. Note that the uri has no transport set. * * @param host * @param port * @return */ private Address createAddress(String host, int port) { SipUri sipUri = new SipUri(); try { sipUri.setHost(host); } catch (ParseException e) { logger.logError("Bad load balancer host " + host, e); return null; } sipUri.setPort(port); return addressFactory.createAddress(sipUri); }
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); }
/** * Attempt to find a Backup Address, but the method returns null if there * isn't any address to forward the INVITE. */ private Address getBackupAddress(String sipAddress) { Address backupAddress = null; CallControlProfileCMP profile = this.lookup(new javax.slee.Address(AddressPlan.SIP, sipAddress)); if (profile != null) { javax.slee.Address address = profile.getBackupAddress(); if (address != null) { try { backupAddress = getAddressFactory().createAddress(address.getAddressString()); } catch (ParseException e) { log.severe(e.getMessage(), e); } } } return backupAddress; }
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")); }
private ContactHeader getContactHeader() throws ParseException { if (contactHeader == null) { ListeningPoint listeningPoint = sipFactoryProvider .getListeningPoint("udp"); Address address = addressFactory.createAddress( "Mobicents SIP AS <sip:"+listeningPoint.getIPAddress()+">"); ((SipURI) address.getURI()).setPort(listeningPoint.getPort()); contactHeader = headerFactory.createContactHeader(address); } return contactHeader; }
/** * Update the haSipDialog passed in param with the dialogMetaData and app meta data * @param dialogMetaData * @param dialogAppData * @param haSipDialog * @throws ParseException * @throws PeerUnavailableException */ private void updateDialogMetaData(Map<String, Object> dialogMetaData, Object dialogAppData, HASipDialog haSipDialog, boolean recreation) throws ParseException, PeerUnavailableException { haSipDialog.setMetaDataToReplicate(dialogMetaData, recreation); haSipDialog.setApplicationDataToReplicate(dialogAppData); final String contactStringified = (String) dialogMetaData.get(AbstractHASipDialog.CONTACT_HEADER); if(contactStringified != null) { Address contactAddress = SipFactory.getInstance().createAddressFactory().createAddress(contactStringified); ContactHeader contactHeader = SipFactory.getInstance().createHeaderFactory().createContactHeader(contactAddress); haSipDialog.setContactHeader(contactHeader); } }
private ContactHeader getContactHeader() throws ParseException { if (contactHeader == null) { final ListeningPoint listeningPoint = sleeSipProvider .getListeningPoint("udp"); final javax.sip.address.SipURI sipURI = addressFactory .createSipURI(null, listeningPoint.getIPAddress()); sipURI.setPort(listeningPoint.getPort()); sipURI.setTransportParam(listeningPoint.getTransport()); contactHeader = headerFactory.createContactHeader(addressFactory .createAddress(sipURI)); } return contactHeader; }
/** * * @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); } }
/** * @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); } }
private void createToHeader() throws ParseException { SipURI toAddress = getAddressFactory().createSipURI(getToUser(), getToHost()); toAddress.setPort(getToPort()); Address toNameAddress = addressFactory.createAddress(toAddress); toNameAddress.setDisplayName(getToUser()); setToHeader(headerFactory.createToHeader(toNameAddress, getToUser() + "_Header")); }
/** * Update the haSipDialog passed in param with the dialogMetaData and app meta data * @param dialogMetaData * @param dialogAppData * @param haSipDialog * @throws ParseException * @throws PeerUnavailableException */ private void updateDialogMetaData(Map<String, Object> dialogMetaData, Object dialogAppData, HASipDialog haSipDialog, boolean recreation) throws ParseException, PeerUnavailableException { haSipDialog.setMetaDataToReplicate(dialogMetaData, recreation); haSipDialog.setApplicationDataToReplicate(dialogAppData); final String contactStringified = (String) dialogMetaData.get(AbstractHASipDialog.CONTACT_HEADER); if(logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) { logger.logDebug("contactStringified " + contactStringified); } if(contactStringified != null) { Address contactAddress = SipFactory.getInstance().createAddressFactory().createAddress(contactStringified); ContactHeader contactHeader = SipFactory.getInstance().createHeaderFactory().createContactHeader(contactAddress); if(logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) { logger.logDebug("contactHeader " + contactHeader); logger.logDebug("contactURI " + contactHeader.getAddress().getURI()); } haSipDialog.setContactHeader(contactHeader); } }
private void finishSipSessionSetup(byte[] sdp) throws ParseException, SipException, InvalidArgumentException { ServerTransaction serverTransaction = (ServerTransaction) getServerTransactionACI() .getActivity(); ContentTypeHeader contentType = sipRaSbbInterface.getHeaderFactory() .createContentTypeHeader("application", "sdp"); String localAddress = sipRaSbbInterface.getListeningPoints()[0] .getIPAddress(); int localPort = sipRaSbbInterface.getListeningPoints()[0].getPort(); Address contactAddress = sipRaSbbInterface.getAddressFactory() .createAddress("sip:" + localAddress + ":" + localPort); ContactHeader contact = sipRaSbbInterface.getHeaderFactory() .createContactHeader(contactAddress); Response ok = sipRaSbbInterface.getMessageFactory().createResponse( Response.OK, serverTransaction.getRequest(), contentType, sdp); ok.setHeader(contact); serverTransaction.sendResponse(ok); }
private void finishSipSessionSetup(byte[] sdp) throws ParseException, SipException, InvalidArgumentException { ServerTransaction serverTransaction = (ServerTransaction) getServerTransactionACI() .getActivity(); ContentTypeHeader contentType = sipRaSbbInterface.getHeaderFactory() .createContentTypeHeader("application", "sdp"); String localAddress = sipRaSbbInterface.getListeningPoints()[0] .getIPAddress(); int localPort = sipRaSbbInterface.getListeningPoints()[0].getPort(); Address contactAddress = sipRaSbbInterface.getAddressFactory() .createAddress("sip:" + localAddress + ":" + localPort); ContactHeader contact = sipRaSbbInterface.getHeaderFactory() .createContactHeader(contactAddress); Response ok = sipRaSbbInterface.getMessageFactory().createResponse( Response.OK, serverTransaction.getRequest(), contentType, sdp); ok.setHeader(contact); serverTransaction.sendResponse(ok); }