本文整理了Java中javax.sip.address.Address.getURI()
方法的一些代码示例,展示了Address.getURI()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getURI()
方法的具体详情如下:
包路径:javax.sip.address.Address
类名称:Address
方法名:getURI
暂无
代码示例来源:origin: sip3io/tapir
private static URI getURI(HeaderAddress header) {
if (header == null) {
return null;
}
Address address = header.getAddress();
if (address == null) {
return null;
}
return address.getURI();
}
}
代码示例来源:origin: org.mobicents.examples/mobicents-slee-example-sip-jdbc-registrar-sbb
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;
}
代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl
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));
}
}
/*
代码示例来源:origin: org.jitsi/jain-sip-ri-ossonly
/**
* Compare two address specs for equality.
*
* @param other Object to compare this this address
*
* @return boolean
*
*/
public boolean equals(Object other) {
if (this==other) return true;
if (other instanceof Address) {
final Address o = (Address) other;
// Don't compare display name (?)
return this.getURI().equals( o.getURI() );
}
return false;
}
代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl
public float getQ() {
String q = this.getParameter(Q_PARAM_NAME);
if(q != null) { // This is how the TCK expects to parse it. See AddressingServlet in TCK spec tests.
return Float.parseFloat(q);
} else { // I think this is not needed.
return ((SipURI)address.getURI()).getParameter(Q_PARAM_NAME) == null ? (float) -1.0 :
Float.parseFloat(((SipURI)address.getURI()).getParameter(Q_PARAM_NAME));
}
}
/*
代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl
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();
}
代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl
/**
* {@inheritDoc}
*/
public void pushRoute(Address address) {
checkReadOnly();
if(address.getURI() instanceof TelURL) {
throw new IllegalArgumentException("Cannot push a TelUrl as a route !");
}
javax.sip.address.SipURI sipUri = (javax.sip.address.SipURI) ((AddressImpl) address)
.getAddress().getURI();
pushRoute(sipUri);
}
代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl
public void setExpires(int seconds) throws IllegalArgumentException {
javax.sip.address.URI uri = this.getAddress().getURI();
if (uri instanceof SipURI) {
/*
SipURI sipUri = (SipURI) uri;
try {
sipUri.setParameter(EXPIRES_PARAM_NAME, Integer.toString(seconds));
} catch (ParseException e) {
throw new IllegalArgumentException("Problem setting parameter",
e);
}*/
if(seconds == -1) {
this.removeParameter(EXPIRES_PARAM_NAME);
return;
}
this.setParameter(EXPIRES_PARAM_NAME, Integer.toString(seconds));
} else {
throw new IllegalArgumentException(
"Can only set parameter for Sip URI");
}
}
/*
代码示例来源:origin: org.mobicents.examples/call-controller2-sbbs
/**
* 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;
}
代码示例来源:origin: org.mobicents.examples/call-controller2-sbbs
/**
* Fetch audio file string for callee, used to check for recorded message.
* @return
*/
private String getAudioFileString() {
FromHeader fromHeader = (FromHeader) this.getInviteRequest().getHeader(
FromHeader.NAME);
return getAudioFileString(((SipURI) fromHeader.getAddress().getURI()).getUser());
}
代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl
public URI getURI() {
final javax.sip.address.URI localUri = getAddress().getURI();
if (localUri instanceof javax.sip.address.SipURI)
return new SipURIImpl((javax.sip.address.SipURI) localUri, isModifiable);
else if (localUri instanceof javax.sip.address.TelURL)
return new TelURLImpl((javax.sip.address.TelURL) localUri);
else if (localUri instanceof javax.sip.address.URI) {
URI uri = new GenericURIImpl((javax.sip.address.URI) localUri);
// setting the value to make sure jain sip runs scheme validation on it
((Parameterable)uri).setValue(localUri.toString());
return uri;
}
else
throw new IllegalArgumentException("unsupported operation - unknown scheme");
}
/*
代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl
public static void optimizeRouteHeaderAddressForInternalRoutingrequest(SipConnector sipConnector, Request request, MobicentsSipSession session, SipFactoryImpl sipFactoryImpl, String transport) {
RouteHeader rh = (RouteHeader) request.getHeader(RouteHeader.NAME);
javax.sip.address.URI uri = null;
if(rh != null) {
uri = rh.getAddress().getURI();
} else {
uri = request.getRequestURI();
}
if(uri.isSipURI()) {
javax.sip.address.SipURI sipUri = (javax.sip.address.SipURI) uri;
optimizeUriForInternalRoutingRequest(sipConnector, sipUri, session, sipFactoryImpl, transport);
}
}
代码示例来源:origin: org.mobicents.examples/sip11-loadtest-with-dialogs-sbb
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;
}
代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl
/**
* 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;
}
代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl
public void proxyTo(final URI uri) {
if(uri == null) {
throw new NullPointerException("URI can't be null");
}
if(!JainSipUtils.checkScheme(uri.toString())) {
// Fix for Issue http://code.google.com/p/mobicents/issues/detail?id=2327, checking the route header
RouteHeader routeHeader = (RouteHeader) originalRequest.getMessage().getHeader(RouteHeader.NAME);
if(routeHeader == null || (routeHeader != null && !JainSipUtils.checkScheme(routeHeader.getAddress().getURI().toString()))) {
throw new IllegalArgumentException("Scheme " + uri.getScheme() + " is not supported");
}
}
final ProxyBranchImpl branch = new ProxyBranchImpl(uri, this);
branch.setRecordRoute(recordRoutingEnabled);
branch.setRecurse(recurse);
this.proxyBranches.put(uri, branch);
startProxy();
}
代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl
public static String findRouteOrRequestUriTransport(Request request) {
RouteHeader route = (RouteHeader) request.getHeader(RouteHeader.NAME);
if(route != null) {
URI uri = route.getAddress().getURI();
return findURITransport(uri, request.getContentLength().getContentLength());
}
URI ruri = request.getRequestURI();
return findURITransport(ruri, request.getContentLength().getContentLength());
}
// https://github.com/Mobicents/sip-servlets/issues/62
代码示例来源:origin: org.mobicents.examples/sip-wake-up-sbb
/**
* Event handler from the timer event, which signals that a message must be
* sent back to the UA
*
* @param event
* @param aci
*/
public void onTimerEvent(TimerEvent event, ActivityContextInterface aci) {
// detaching so the null AC is claimed after the event handling
aci.detach(sbbContext.getSbbLocalObject());
try {
DataSourceChildSbbLocalInterface child = (DataSourceChildSbbLocalInterface) getLocationChildRelation().create();
child.getBindings(getSender().getURI().toString());
} catch (Exception e) {
tracer.severe("failed to create sip registrar child sbb, to lookup the sender's contacts",e);
return;
}
}
代码示例来源:origin: org.mobicents.examples/restcomm-slee-example-sip11-b2b-sbb
private void forwardRequest(RequestEvent event, DialogActivity out)
throws SipException {
final Request incomingRequest = event.getRequest();
if (tracer.isInfoEnabled()) {
tracer.info("Forwarding request " + incomingRequest.getMethod()
+ " to dialog " + out);
}
// Copies the request, setting the appropriate headers for the dialog.
Request outgoingRequest = out.createRequest(incomingRequest);
outgoingRequest.setRequestURI(out.getRemoteParty().getURI());
// Send the request on the dialog activity
final ClientTransaction ct = out.sendRequest(outgoingRequest);
// Record an association with the original server transaction,
// so we can retrieve it when forwarding the response.
out.associateServerTransaction(ct, event.getServerTransaction());
}
代码示例来源:origin: org.jitsi/jain-sip-ri-ossonly
/**
* Performs strict router fix according to RFC3261 section 16.6 step 6
*
* pre: top route header in request has no 'lr' parameter in URI post:
* request-URI added as last route header, new req-URI = top-route-URI
*/
public void fixStrictRouting(SIPRequest req) {
RouteList routes = req.getRouteHeaders();
Route first = (Route) routes.getFirst();
SipUri firstUri = (SipUri) first.getAddress().getURI();
routes.removeFirst();
// Add request-URI as last Route entry
AddressImpl addr = new AddressImpl();
addr.setAddess(req.getRequestURI()); // don't clone it
Route route = new Route(addr);
routes.add(route); // as last one
req.setRequestURI(firstUri);
if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
logger.logDebug("post: fixStrictRouting" + req);
}
}
代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl
public static void optimizeViaHeaderAddressForStaticAddress(SipConnector sipConnector, Request request, SipFactoryImpl sipFactoryImpl, String transport) throws ParseException, InvalidArgumentException {
javax.sip.address.URI uri = request.getRequestURI();
ViaHeader viaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);
RouteHeader route = (RouteHeader) request.getHeader(RouteHeader.NAME);
if(route != null) {
uri = route.getAddress().getURI();
}
if(uri.isSipURI()) {
javax.sip.address.SipURI sipUri = (javax.sip.address.SipURI) uri;
String host = sipUri.getHost();
int port = sipUri.getPort();
if(sipFactoryImpl.getSipApplicationDispatcher().isExternal(host, port, transport)) {
viaHeader.setHost(sipConnector.getStaticServerAddress());
viaHeader.setPort(sipConnector.getStaticServerPort());
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!