private static URI getURI(HeaderAddress header) { if (header == null) { return null; } Address address = header.getAddress(); if (address == null) { return null; } return address.getURI(); } }
final URI newURI = newRequestContactHeader.getAddress().getURI(); newContactHeader.getAddress().setDisplayName(newRequestContactHeader.getAddress().getDisplayName()); SipURI newContactSipURI = (SipURI) newContactHeader.getAddress().getURI(); ((SipURI)newContactHeader.getAddress().getURI()).setUser(newSipURI.getUser()); Iterator<String> uriParameters = newSipURI.getParameterNames(); while (uriParameters.hasNext()) {
public String toString() { // Returns the value of this address as a String. The resulting string // must be a valid value of a SIP From or To header. // To/From are parametrable. StringBuffer retval = new StringBuffer(); retval.append(address.toString()); //excluding the parameters already present in the address uri if ( parameters!= null) { for(Map.Entry<java.lang.String, String> entry : parameters.entrySet()) { if((!(address.getURI() instanceof Parameters)) || ((Parameters)address.getURI()).getParameter(entry.getKey()) == null) { String value = entry.getValue(); if(value != null && value.length() > 0) { retval.append(PARAM_SEPARATOR).append(entry.getKey()).append(PARAM_NAME_VALUE_SEPARATOR).append(value); } else { retval.append(PARAM_SEPARATOR).append(entry.getKey()); } } } } return retval.toString(); }
CallIdHeader callId = (CallIdHeader)request.getHeader(CallIdHeader.NAME); String username = getHash(callId.getCallId().getBytes()); SipURI uri = (SipURI)ch.getAddress().getURI(); try { uri.setUser(username); ch.getAddress().setDisplayName(null); } catch (ParseException e) { throw new IllegalStateException("Can't create contact header user part with MD5", e);
if(contactHeader != null && (((Parameters)contactHeader.getAddress().getURI()).getParameter("gruu") != null || ((Parameters)contactHeader.getAddress().getURI()).getParameter("gr") != null)) { if(logger.isDebugEnabled()) { logger.debug("not changing existing contact header " + contactHeader + " as it contains gruu"); final javax.sip.address.URI fromUri = fromHeader.getAddress().getURI(); String fromName = null; String displayName = fromHeader.getAddress().getDisplayName(); if(fromUri instanceof javax.sip.address.SipURI) { fromName = ((javax.sip.address.SipURI)fromUri).getUser(); boolean sipURI = contactHeader.getAddress().getURI().isSipURI(); if(sipURI) { javax.sip.address.SipURI contactSipUri = (javax.sip.address.SipURI) contactHeader.getAddress().getURI();
public void setDisplayName(String name) { if(SipServletMessageImpl.isSystemHeader(isModifiable)) { throw new IllegalStateException("this Address is used in a context where it cannot be modified"); } try { getAddress().setDisplayName(name); } catch (ParseException e) { throw new IllegalArgumentException("illegal name ", e); } }
public void writeExternal(ObjectOutput out) throws IOException { out.writeLong(calleeCSeq); out.writeLong(callerCSeq); out.writeUTF(calleeContact.toString()); out.writeUTF(callerContact.toString()); out.writeInt(calleeRouteSet.size()); Iterator<javax.sip.address.Address> i = calleeRouteSet.iterator(); while (i.hasNext()) { javax.sip.address.Address a = i.next(); out.writeUTF(a.toString()); } out.writeInt(callerRouteSet.size()); i = callerRouteSet.iterator(); while (i.hasNext()) { javax.sip.address.Address a = i.next(); out.writeUTF(a.toString()); } out.writeUTF(toHeader.getAddress().toString()); out.writeUTF(toHeader.getTag()); out.writeUTF(fromHeader.getAddress().toString()); out.writeUTF(fromHeader.getTag()); out.writeUTF(callId); }
public boolean equals(Object other) { if(other instanceof PServedUser) { final PServedUserHeader psu = (PServedUserHeader)other; return this.getAddress().equals(((PServedUser) other).getAddress()); } return false; }
ContactHeader contactHeader = null; FromHeader from = (FromHeader) methodRequest.getHeader(FromHeader.NAME); String displayName = from.getAddress().getDisplayName(); String userName = null; javax.sip.address.URI uri = from.getAddress().getURI(); if(uri.isSipURI()) { userName = ((javax.sip.address.SipURI)uri).getUser(); SipUri sipUri = (SipUri) sessionCreatingDialog.getRemoteTarget().getURI().clone(); sipUri.clearUriParms(); if(logger.isDebugEnabled()) { final AddressImpl currentLocalParty = (AddressImpl)this.getLocalParty().clone(); final AddressImpl currentRemoteParty = (AddressImpl)this.getRemoteParty().clone(); ((Parameters)currentRemoteParty .getAddress().getURI()).removeParameter("tag"); ((Parameters)currentLocalParty .getAddress().getURI()).removeParameter("tag"); final String originalCallId = ((CallIdHeader)originalRequest.getHeader(CallIdHeader.NAME)).getCallId(); sipServletRequest =(SipServletRequestImpl) sipFactory.createRequest( SipUri sipUri = (SipUri) sessionCreatingDialog.getRemoteTarget().getURI().clone(); sipUri.clearUriParms(); if(logger.isDebugEnabled()) { while (routeHeaders.hasNext()) { RouteHeader routeHeader = routeHeaders.next(); String routeServerId = ((javax.sip.address.SipURI)routeHeader .getAddress().getURI()). getParameter(MessageDispatcher.RR_PARAM_SERVER_NAME); String routeAppNameHashed = ((javax.sip.address.SipURI)routeHeader .getAddress().getURI()). getParameter(MessageDispatcher.RR_PARAM_APPLICATION_NAME);
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); } }
public boolean equals(Object other) { if (this==other) return true; if (other instanceof HeaderAddress && other instanceof Parameters) { final HeaderAddress o = (HeaderAddress) other; return this.getAddress().equals( o.getAddress() ) && this.equalParameters( (Parameters) o ); } return false; }
public int getExpires() { String expires = this.getParameter(EXPIRES_PARAM_NAME); if(expires != null) { // This is how the TCK expects to parse it. See AddressingServlet in TCK spec tests. return Integer.parseInt(expires); } else { // I think this is not needed. return ((SipURI)address.getURI()).getParameter(EXPIRES_PARAM_NAME) == null ? -1 : Integer.parseInt(((SipURI)address.getURI()).getParameter(EXPIRES_PARAM_NAME)); } } /*
String displayName = ((MessageExt)newRequest).getFromHeader().getAddress().getDisplayName(); if(newRequest.getHeader(ContactHeader.NAME) != null && ((ContactHeader)newRequest.getHeader(ContactHeader.NAME)).getAddress().getURI() instanceof javax.sip.address.SipURI) { fromName = ((javax.sip.address.SipURI)((MessageExt)newRequest).getFromHeader().getAddress().getURI()).getUser(); javax.sip.address.Address contactAddress = addressFactory.createAddress(sipURI); if(displayName != null && displayName.length() > 0) { contactAddress.setDisplayName(displayName);
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); }
dialogMetaData.put(REMOTE_TARGET, getRemoteTarget().toString()); } else { dialogMetaData.put(REMOTE_TARGET, null);
public Address getPoppedRoute() { if((this.poppedRoute == null && poppedRouteHeader != null) || (poppedRoute != null && poppedRouteHeader != null && !poppedRoute.getAddress().equals(poppedRouteHeader.getAddress()))) { this.poppedRoute = new AddressImpl(poppedRouteHeader.getAddress(), null, getTransaction() == null ? ModifiableRule.Modifiable : ModifiableRule.NotModifiable); } return poppedRoute; }
private String getCanonicalAddress(HeaderAddress header) { String addr = header.getAddress().getURI().toString(); int index = addr.indexOf(':'); index = addr.indexOf(':', index + 1); if (index != -1) { // Get rid of the port addr = addr.substring(0, index); } return addr; }
final URI contactURI = contactHeaders.next().getAddress().getURI(); String diaplayName = newFromHeader.getAddress().getDisplayName(); if(newFromHeader.getAddress().getURI() instanceof javax.sip.address.SipURI) { fromName = ((javax.sip.address.SipURI) newFromHeader.getAddress().getURI()).getUser(); javax.sip.address.Address contactAddress = sipFactoryImpl.getAddressFactory().createAddress(sipURI); if(diaplayName != null && diaplayName.length() > 0) { contactAddress.setDisplayName(diaplayName);