javax.servlet.sip
Interface SipURI

All Superinterfaces:
java.lang.Cloneable, URI

public interface SipURI
extends URI

Represents sip and sips URIs.

SIP and SIPS URIs are used for addressing. They are similar to email addresses in that they are of the form user@host where user is either a user name or telephone number, and host is a host or domain name, or a numeric IP address. Additionally, SIP and SIPS URIs may contain parameters and headers (although headers are not legal in all contexts).

Syntactically, SIP and SIPS URIs are identical except for the name of URI scheme. The semantics differs in that the SIPS scheme implies that the identified resource is to be contacted using TLS. The following quote is from RFC 3261:

"A SIPS URI specifies that the resource be contacted securely. This means, in particular, that TLS is to be used between the UAC and the domain that owns the URI. From there, secure communications are used to reach the user, where the specific security mechanism depends on the policy of the domain. Any resource described by a SIP URI can be "upgraded" to a SIPS URI by just changing the scheme, if it is desired to communicate with that resource securely."

Because sip and sips URIs are syntactically identical and because they're used the same way, they're both represented by the SipURI interface.

The string form of SIP and SIPS URIs may contain escaped characters. The SIP servlet container is responsible for unescaping those characters before presenting URIs to servlets. Likewise, string values passed to setters for various SIP(S) URI components may contain reserved or excluded characters that need escaping before being used. The container is responsible for escaping those values.

See Also:
Address, SipFactory.createSipURI(java.lang.String, java.lang.String), SipServletRequest.getRequestURI()

Method Summary
 java.lang.String getHeader(java.lang.String name)
          Returns the value of the specified header.
 java.util.Iterator getHeaderNames()
          Returns an Iterator over the names of all headers present in this SipURI.
 java.lang.String getHost()
          Returns the host part of this SipURI.
 boolean getLrParam()
          Returns true if the "lr" flag parameter is set, and false otherwise.
 java.lang.String getMAddrParam()
          Returns the value of the "maddr" parameter, or null if this is not set.
 java.lang.String getMethodParam()
          Returns the value of the "method" parameter, or null if this is not set.
 java.lang.String getParameter(java.lang.String name)
          Returns the value of the named parameter, or null if it is not set.
 java.util.Iterator getParameterNames()
          Returns an Iterator over the names (Strings) of all parameters present in this SipURI.
 int getPort()
          Returns the port number of this SipURI, or -1 if this is not set.
 java.lang.String getTransportParam()
          Returns the value of the "transport" parameter, or null if this is not set.
 int getTTLParam()
          Returns the value of the "ttl" parameter, or -1 if this is not set.
 java.lang.String getUser()
          Returns the user part of this SipURI.
 java.lang.String getUserParam()
          Returns the value of the "user" parameter, or null if this is not set.
 java.lang.String getUserPassword()
          Returns the password of this SipURI, or null if this is not set.
 boolean isSecure()
          Returns true if this SipURI is secure, that is, if this it represents a sips URI.
 void removeParameter(java.lang.String name)
          Removes the specified parameter.
 void setHeader(java.lang.String name, java.lang.String value)
          Sets the value of the specified header in this SipURI.
 void setHost(java.lang.String host)
          Sets the host part of this SipURI.
 void setLrParam(boolean flag)
          Sets or removes the "lr" parameter depending on the value of the flag.
 void setMAddrParam(java.lang.String maddr)
          Sets the value of the "maddr" parameter.
 void setMethodParam(java.lang.String method)
          Sets the value of the "method" parameter.
 void setParameter(java.lang.String name, java.lang.String value)
          Sets the value of the specified parameter.
 void setPort(int port)
          Sets the port number of this SipURI.
 void setSecure(boolean b)
          Sets the scheme of this URI to sip or sips depending on whether the argument is true or not.
 void setTransportParam(java.lang.String transport)
          Sets the value of the "transport" parameter.
 void setTTLParam(int ttl)
          Sets the value of the "ttl" parameter.
 void setUser(java.lang.String user)
          Sets the user part of this SipURI.
 void setUserParam(java.lang.String user)
          Sets the value of the "user" parameter.
 void setUserPassword(java.lang.String password)
          Sets the password of this SipURI.
 java.lang.String toString()
          Returns the String representation of this SipURI.
 
Methods inherited from interface javax.servlet.sip.URI
clone, getScheme, isSipURI
 

Method Detail

getUser

public java.lang.String getUser()
Returns the user part of this SipURI.
Returns:
the user part of this SipURI

setUser

public void setUser(java.lang.String user)
Sets the user part of this SipURI.
Parameters:
user - the new user part

getUserPassword

public java.lang.String getUserPassword()
Returns the password of this SipURI, or null if this is not set.
Returns:
the password of this SipURI

setUserPassword

public void setUserPassword(java.lang.String password)
Sets the password of this SipURI. The use of passwords in SIP or SIPS URIs is discouraged as sending passwords in clear text is a security risk.
Parameters:
password - the new password

getHost

public java.lang.String getHost()
Returns the host part of this SipURI.
Returns:
the host part of this SipURI

setHost

public void setHost(java.lang.String host)
Sets the host part of this SipURI. This should be a fully qualified domain name or a numeric IP address.
Parameters:
host - the new host name

getPort

public int getPort()
Returns the port number of this SipURI, or -1 if this is not set.
Returns:
the port number of this SipURI

setPort

public void setPort(int port)
Sets the port number of this SipURI.
Parameters:
port - the new port number. A negative value means the port number is not set and a subsequent call to getPort() should return -1.

isSecure

public boolean isSecure()
Returns true if this SipURI is secure, that is, if this it represents a sips URI. For "ordinary" sip URIs, false is returned.
Returns:
true if this SipURI represents a sips URI, and false if it represents a sip URI

setSecure

public void setSecure(boolean b)
Sets the scheme of this URI to sip or sips depending on whether the argument is true or not.
Parameters:
b - determines whether the scheme of this SipURI is set to sip or sips

getParameter

public java.lang.String getParameter(java.lang.String name)
Returns the value of the named parameter, or null if it is not set. A zero-length String indicates flag parameter.
Parameters:
name - a String specifying the parameter name
Returns:
the value of the specified parameter

setParameter

public void setParameter(java.lang.String name,
                         java.lang.String value)
Sets the value of the specified parameter. If the parameter already had a value it will be overwritten. A zero-length String indicates flag parameter.
Parameters:
name - parameter name
value - new parameter value

removeParameter

public void removeParameter(java.lang.String name)
Removes the specified parameter.
Parameters:
name - parameter name

getParameterNames

public java.util.Iterator getParameterNames()
Returns an Iterator over the names (Strings) of all parameters present in this SipURI.
Returns:
an Iterator over all parameter names

getTransportParam

public java.lang.String getTransportParam()
Returns the value of the "transport" parameter, or null if this is not set. This is equivalent to getParameter("transport").
Returns:
the value of the "transport" parameter

setTransportParam

public void setTransportParam(java.lang.String transport)
Sets the value of the "transport" parameter. This parameter specifies which transport protocol to use for sending requests and responses to this entity. The following values are defined: "udp", "tcp", "sctp", "tls", but other values may be used also

This method is equivalent to setParameter("transport", transport).

Parameters:
transport - new value for the "transport" parameter

getMAddrParam

public java.lang.String getMAddrParam()
Returns the value of the "maddr" parameter, or null if this is not set. This is equivalent to getParameter("maddr").
Returns:
the value of the "maddr" parameter

setMAddrParam

public void setMAddrParam(java.lang.String maddr)
Sets the value of the "maddr" parameter. This is equivalent to setParameter("maddr", maddr).
Parameters:
method - new value of the "maddr" parameter

getMethodParam

public java.lang.String getMethodParam()
Returns the value of the "method" parameter, or null if this is not set. This is equivalent to getParameter("method").
Returns:
the value of the "method" parameter

setMethodParam

public void setMethodParam(java.lang.String method)
Sets the value of the "method" parameter. This specifies which SIP method to use in requests directed at this SIP/SIPS URI.

This method is equivalent to setParameter("method", method).

Parameters:
method - new value of the "method" parameter

getTTLParam

public int getTTLParam()
Returns the value of the "ttl" parameter, or -1 if this is not set. This method is equivalent to getParameter("ttl").
Returns:
the value of the "ttl" parameter

setTTLParam

public void setTTLParam(int ttl)
Sets the value of the "ttl" parameter. The ttl parameter specifies the time-to-live value when packets are sent using UDP multicast.

This is equivalent to setParameter("ttl", ttl).

Parameters:
ttl - new value of the "ttl" parameter

getUserParam

public java.lang.String getUserParam()
Returns the value of the "user" parameter, or null if this is not set. This is equivalent to getParameter("user").
Returns:
the value of the "user" parameter

setUserParam

public void setUserParam(java.lang.String user)
Sets the value of the "user" parameter. This is equivalent to setParameter("user", user).
Parameters:
user - new value for the "user" parameter

getLrParam

public boolean getLrParam()
Returns true if the "lr" flag parameter is set, and false otherwise. This is equivalent to "".equals(getParameter("lr")).
Returns:
true if the "lr" flag parameter is set, and false otherwise

setLrParam

public void setLrParam(boolean flag)
Sets or removes the "lr" parameter depending on the value of the flag.
Parameters:
flag - specifies that the "lr" flag parameter is to be set (true) or removed (false)

getHeader

public java.lang.String getHeader(java.lang.String name)
Returns the value of the specified header. SIP/SIPS URIs may specify headers. As an example, the URI sip:joe@example.com?Priority=emergency has a header "Priority" whose value is "emergency".
Parameters:
name - the header name
Returns:
the value of the specified header in this SipURI

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Sets the value of the specified header in this SipURI.
Parameters:
name - header name
value - header value

getHeaderNames

public java.util.Iterator getHeaderNames()
Returns an Iterator over the names of all headers present in this SipURI.
Returns:
an Iterator over all header names

toString

public java.lang.String toString()
Returns the String representation of this SipURI.
Specified by:
toString in interface URI
Overrides:
toString in class java.lang.Object
Returns:
this sip or sips URI as a String


SIP Servlet API 1.0