public interface SipServletMessage extends Cloneable, AttributeStore
The Servlet API is defined with an implicit assumption that servlets
receives requests from clients, inspects various aspects of the
corresponding ServletRequest
object, and generates a
response by setting various attributes of a ServletResponse
object. This model fits HTTP well, because HTTP servlets always execute
origin servers; they execute only to process incoming requests
and never initiates HTTP requests of their own.
SIP services, on the other hand, does need to be able to initiate requests of their own. This implies that SIP request and response classes are more symmetric, that is, requests must be writable as well as readable, and likewise, responses must be readable as well as writable.
The SipServletMessage
interface defines a number of
methods which are common to SipServletRequest
and
SipServletResponse
, for example setters and getters for
message headers and content.
System Headers
Applications must not add, delete, or modify so-called "system"
headers. These are header fields that the servlet container manages:
From, To, Call-ID, CSeq, Via, Route (except through
pushRoute
), Record-Route, Path. Contact is a system header field
in messages other than REGISTER requests and responses, 3xx and 485
responses, and 200/OPTIONS responses. Additionally, for containers
implementing the reliable provisional responses extension, RAck and RSeq
are considered system headers also. Note that From and To are system header
fields only with respect to their tags (i.e., tag parameters on these headers
are not allowed to be modified but modifications are allowed to the other parts).
Implicit Transaction State
SipServletMessage
objects always implicitly
belong to a SIP transaction, and the transaction state machine
(as defined by the SIP specification) constrains
what messages can legally be sent at various points of processing. If a
servlet attempts to send a message which would violate the SIP
specification (for example, the transaction state machine), the container
throws an IllegalStateException
.
Modifier and Type | Interface and Description |
---|---|
static class |
SipServletMessage.HeaderForm
Type header forms.
|
Modifier and Type | Method and Description |
---|---|
void |
addAcceptLanguage(Locale locale)
Adds an acceptable
Locale of this user agent. |
void |
addAddressHeader(String name,
Address addr,
boolean first)
Adds the specified
Address as a new value of the
named header field. |
void |
addHeader(String name,
String value)
Adds a header with the given name and value.
|
void |
addParameterableHeader(String name,
Parameterable param,
boolean first)
Adds the specified
Parameterable as a new value of the
named header field. |
Locale |
getAcceptLanguage()
Returns the preferred
Locale that the UA originating
this message will accept content in, based on the Accept-Language
header. |
Iterator<Locale> |
getAcceptLanguages()
Returns an
Iterator over Locale objects
indicating, in decreasing order starting with the preferred locale,
the locales that are acceptable to the sending UA based on the
Accept-Language header. |
Set<Locale> |
getAcceptLanguageSet()
Returns a
Set of Locale objects
indicating, in decreasing order starting with the preferred locale,
the locales that are acceptable to the sending UA based on the
Accept-Language header. |
Address |
getAddressHeader(String name)
Returns the value of the specified header as a
Address object. |
List<Address> |
getAddressHeaderList(String name)
Returns a
List of all Address
header field values for the specified header. |
ListIterator<Address> |
getAddressHeaders(String name)
Returns a
ListIterator over all Address
header field values for the specified header. |
SipApplicationSession |
getApplicationSession()
Returns the application session to which this message belongs.
|
SipApplicationSession |
getApplicationSession(boolean create)
Returns the app session to which this message belongs.
|
Enumeration<String> |
getAttributeNames()
Deprecated.
As of release 2.0, replaced by
AttributeStore.getAttributeNameSet() |
String |
getCallId()
Returns the value of the Call-ID header in this
SipServletMessage . |
String |
getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in
this message.
|
Object |
getContent()
Returns the content as a Java object.
|
Locale |
getContentLanguage()
Returns the locale of this message.
|
int |
getContentLength()
Returns the length in number of bytes of the content part of this
message.
|
String |
getContentType()
Returns the value of the Content-Type header field.
|
int |
getExpires()
Returns the value of the Expires header.
|
Address |
getFrom()
Returns the value of the From header.
|
String |
getHeader(String name)
Returns the value of the specified header as a
String . |
SipServletMessage.HeaderForm |
getHeaderForm() |
List<String> |
getHeaderList(String name)
Returns all the values of the specified header as a
List of
String objects. |
List<String> |
getHeaderNameList()
Returns an immutable
List of all the header names this
message contains in the long format. |
Iterator<String> |
getHeaderNames()
Returns an
Iterator over all the header names this
message contains in the long format. |
ListIterator<String> |
getHeaders(String name)
Returns all the values of the specified header as a
ListIterator over a number of
String objects. |
String |
getInitialRemoteAddr()
Returns the IP address of the upstream/downstream hop from which
this message was initially received by the container.
Unlike getRemoteAddr() , this method
returns the same value regardless of which application invokes it
in the same application composition chain of a specific application router. |
int |
getInitialRemotePort()
Returns the port number of the upstream/downstream hop from which
this message initially received by the container.
|
String |
getInitialTransport()
Returns the name of the protocol with which this message was initially
received by the container,
e.g.
|
String |
getLocalAddr()
Returns the IP address of the interface this message was received on.
|
int |
getLocalPort()
Returns the local port this message was received on.
|
SipWebSocketContext |
getLocalSipWebSocketContext()
Returns the instance of
SipWebSocketContext associated with
the SIP WebSocket connection on which this message has arrived or sent. |
String |
getMethod()
Returns the SIP method of this message.
|
Parameterable |
getParameterableHeader(String name)
Returns the value of the specified header field as a
Parameterable object. |
List<? extends Parameterable> |
getParameterableHeaderList(String name)
Returns a
List of all Parameterable
header field values for the specified header name. |
ListIterator<? extends Parameterable> |
getParameterableHeaders(String name)
Returns a
ListIterator over all Parameterable
header field values for the specified header name. |
String |
getProtocol()
Returns the name and version of the protocol of this message.
|
byte[] |
getRawContent()
Returns message content as a byte array.
|
String |
getRemoteAddr()
Returns the IP address of the next upstream/downstream hop from which
this message was received.
|
int |
getRemotePort()
Returns the port number of the next upstream/downstream hop from which
this message was received.
|
String |
getRemoteUser()
Returns the login of the user sending this message, if the
user has been authenticated, or null if the user has not been
authenticated.
|
SipSession |
getSession()
Returns the
SipSession to which this message belongs. |
SipSession |
getSession(boolean create)
Returns the
SipSession to which this message belongs. |
SessionKeepAlive.Preference |
getSessionKeepAlivePreference()
Return the session keep alive preference as in the SIP message.
|
Address |
getTo()
Returns the value of the To header.
|
String |
getTransport()
Returns the name of the protocol with which this message was received,
e.g.
|
Principal |
getUserPrincipal()
Returns a
java.security.Principal object containing
the name of the authenticated user agent sending this message. |
boolean |
isCommitted()
Returns true if this message is committed, that is, if one
of the following conditions is true:
This message is an incoming request for which a final response
has already been generated
This message is an outgoing request which has already been sent
This message is an incoming non-reliable provisional response received
by a servlet acting as a UAC
This message is an incoming reliable provisional response for which PRACK
has already been generated.
|
boolean |
isInternallyRouted()
This method returns true if the message was sent by a local application.
|
boolean |
isSecure()
Returns a boolean indicating whether this message was received over
a secure channel, such as TLS.
|
boolean |
isUserInRole(String role)
Returns a boolean indicating whether the authenticated user is
included in the specified logical "role".
|
void |
pushLocalPath()
Adds a Path header for this servlet container to this message.
|
void |
pushPath(Address uri)
Adds a Path header field value to this message.
|
void |
removeHeader(String name)
Removes the specified header.
|
void |
send()
Sends this
SipServletMessage . |
void |
setAcceptLanguage(Locale locale)
Sets the preferred
Locale that this user agent will
accept content, reason phrases, warnings, etc. |
void |
setAddressHeader(String name,
Address addr)
Sets the header with the specified name to have the value
specified by the address argument.
|
void |
setCharacterEncoding(String enc)
Overrides the name of the character encoding that will be used to
convert the body of this message from bytes to characters or vice
versa.
|
void |
setContent(Object content,
String contentType)
Sets the content of this message to the specified
Object . |
void |
setContentLanguage(Locale locale)
Sets the locale of this message, setting the headers (Content-Language
and the Content-Type's charset) as appropriate.
|
void |
setContentLength(int len)
Sets the value of the Content-Length header.
|
void |
setContentType(String type)
Sets the content type of the response being sent to the client.
|
void |
setExpires(int seconds)
Sets the value of the Expires header in this message.
|
void |
setHeader(String name,
String value)
Sets a header with the given name and value.
|
void |
setHeaderForm(SipServletMessage.HeaderForm form)
Indicates which of the compact or long form should the headers in this
message have.
|
void |
setParameterableHeader(String name,
Parameterable param)
Sets the header with the specified name to have the value
specified by the address argument.
|
clearAttributes, getAttribute, getAttributeNameSet, removeAttribute, setAttribute
Address getFrom()
Address getTo()
String getMethod()
SipServletMessage
String getProtocol()
For this version of the SIP Servlet API this is always "SIP/2.0".
String
containing the protocol name and
version numberString getHeader(String name)
String
.
If the message did not include a header of the specified name,
this method returns null. If the message included a header of
the specified name with no value, this method returns an empty
String
. If multiple headers exist, the first
one is returned. The header name is case insensitive.
Either the long or compact name can be used to access the header field, as both are treated as equivalent. The list of assigned compact form is available in the IANA registry at http://www.iana.org/assignments/sip-parameters
For example,
getHeader("Content-Type"); getHeader("c");will both return the same value.
name
- a String
specifying the header name, either
the long or compact formString
containing the value of the
requested header, or null if the message does not have a
header of that nameNullPointerException
- if the name
is null.ListIterator<String> getHeaders(String name)
Returns all the values of the specified header as a
ListIterator over a number of String
objects. The
values returned by the Iterator follow the order in which they
appear in the message header.
Either the long or compact name can be used to access the header field, as both are treated as equivalent. The list of assigned compact form is available in the IANA registry at http://www.iana.org/assignments/sip-parameters
Some headers, such as Accept-Language can be sent by clients as several headers each with a different value rather than sending the header as a comma separated list.
If the message did not include any headers of the specified name,
this method returns an empty Iterator. If the message included headers of
the specified name with no values, this method returns an Iterator over empty
String
s. The header name is case
insensitive.
Note: This is a fail-fast iterator and can throw ConcurrentModificationException if the underlying implementation does not allow modification after the iterator is created.
Attempts to modify the specified header field through the
returned list iterator must fail with an
IllegalArgumentException
if the header field is a
system header.
name
- a String
specifying the header name, either
the long or compact formListIterator
over the String
values of the specified header fieldNullPointerException
- if the name
is null.List<String> getHeaderList(String name)
Returns all the values of the specified header as a
List of String
objects. The List
follow the order
in which they appear in the message header.
Either the long or compact name can be used to access the header field, as both are treated as equivalent. The list of assigned compact form is available in the IANA registry at http://www.iana.org/assignments/sip-parameters
Some headers, such as Accept-Language can be sent by clients as several headers each with a different value rather than sending the header as a comma separated list.
If the message did not include any headers of the specified name,
this method returns null. If the message included headers of
the specified name with no values, this method returns a an empty List
.
The header name is case insensitive.
Attempts to modify the specified header field through the
returned list must fail with an
IllegalArgumentException
if the header field is a
system header.
name
- a String
specifying the header name, either
the long or compact formList
of the String
values of the specified header fieldNullPointerException
- if the name
is null.Iterator<String> getHeaderNames()
Iterator
over all the header names this
message contains in the long format. If the message has no headers, this method
returns an empty Iterator
.
Note: This is a fail-fast iterator and can throw ConcurrentModificationException if the underlying implementation does not allow modification after the iterator is created.
Some servlet containers do not allow servlets to access headers using this method, in which case this method returns null.
Iterator
over the names of all header fields
present within this message; if the message has no header fields,
an empty enumeration; if the servlet container does not
allow servlets to use this method, nullList<String> getHeaderNameList()
List
of all the header names this
message contains in the long format. If the message has no headers, this method
returns an empty List
.List
of the names of all header fields
present within this message.void setHeader(String name, String value)
Either the long or compact name can be used to access the header
field, as both are treated as equivalent. The applications choice of
long or compact form shall take effect only of the HeaderForm
parameter is set to SipServletMessage.HeaderForm.DEFAULT
.
Note: applications should never attempt to set the From, To, Call-ID, CSeq, Via, Record-Route, and Route headers. Also, setting of the Contact header is subject to the constraints mentioned in the introduction.
name
- a String
specifying the header name, either
the long or compact formvalue
- the header valueIllegalArgumentException
- if the specified header field
is a system headerNullPointerException
- if the name
or value
is nullvoid addHeader(String name, String value)
Either the long or compact name can be used to access the header field, as both are treated as equivalent. The list of assigned compact form is available in the IANA registry at http://www.iana.org/assignments/sip-parameters
Note: applications should never attempt to set the From, To, Call-ID, CSeq, Via, Record-Route, and Route headers. Also, setting of the Contact header is subject to the constraints mentioned in the introduction.
name
- a String
specifying the header name, either
the long or compact formvalue
- the additional header valueIllegalArgumentException
- if the specified header field
is a system header or if it cannot
legally appear in this messagevoid removeHeader(String name)
Either the long or compact name can be used to access the header field, as both are treated as equivalent.
name
- a String
specifying the header name, either
the long or compact formIllegalArgumentException
- if the specified header field
is a system headerAddress getAddressHeader(String name) throws ServletParseException
Address
object.
This method can be used with headers which are defined to contain
one or more entries matching
(name-addr | addr-spec) *(SEMI generic-param)
as defined in RFC 3261. This includes, for example, Contact and Route.
Either the long or compact name can be used to access the header field, as both are treated as equivalent.
If there is more than one header field value the first is returned.
name
- a case insensitive String
specifying
the name of the header, either the long or compact formAddress
ServletParseException
- if the specified header field
cannot be parsed as a SIP address objectNullPointerException
- if the name
is null.ListIterator<Address> getAddressHeaders(String name) throws ServletParseException
ListIterator
over all Address
header field values for the specified header. The values returned
by the Iterator follow the order in which they appear in the message
header.
This method can be used with headers which are defined to contain
one or more entries matching
(name-addr | addr-spec) *(SEMI generic-param)
as defined in RFC 3261. This includes, for example, Contact and Route.
Either the long or compact name can be used to access the header field, as both are treated as equivalent.
If the message did not include any headers of the specified name,
this method returns an empty Iterator. If the message included headers of
the specified name with no values, this method returns an Iterator over empty
String
s.
Attempts to modify the specified header field through the
returned list iterator must fail with an
IllegalArgumentException
if the header field is a
system header. For non-system headers the
argument to the add
and set
methods
of the iterator returned by getAddressHeaders
must
be Address
objects.
Note: This is a fail-fast iterator and can throw ConcurrentModificationException if the underlying implementation does not allow modification after the iterator is created.
name
- a case insensitive String
specifying
the name of the header field, either the long or compact formListIterator
over the Address
values of the specified header fieldServletParseException
- if the specified header field
cannot be parsed as a SIP address objectNullPointerException
- if the name
is null.List<Address> getAddressHeaderList(String name) throws ServletParseException
List
of all Address
header field values for the specified header. The values returned
in the List
follow the order in which they appear in the message
header.
This method can be used with headers which are defined to contain
one or more entries matching
(name-addr | addr-spec) *(SEMI generic-param)
as defined in RFC 3261. This includes, for example, Contact and Route.
Either the long or compact name can be used to access the header field, as both are treated as equivalent.
If the message did not include any headers of the specified name,
this method returns null. If the message included headers of
the specified name with no values, this method returns an empty List
.
Attempts to modify the specified header field through the
returned list must fail with an
IllegalArgumentException
if the header field is a
system header.
name
- a case insensitive String
specifying
the name of the header field, either the long or compact formList
of the Address
values of the specified header fieldServletParseException
- if the specified header field
cannot be parsed as a SIP address objectNullPointerException
- if the name
is null.void setAddressHeader(String name, Address addr)
This method can be used with headers which are defined to contain
one or more entries matching
(name-addr | addr-spec) *(SEMI generic-param)
as defined in RFC 3261. This includes, for example, Contact and Route.
Either the long or compact name can be used to access the header field, as both are treated as equivalent.
name
- the long or compact name of the header to setaddr
- the assigned address valueIllegalArgumentException
- if the specified header isn't
defined to hold address values or if the specified header field
is a system headervoid addAddressHeader(String name, Address addr, boolean first)
Address
as a new value of the
named header field. The address is added as the last
header field value.
This method can be used with headers which are defined to contain
one or more entries matching
(name-addr | addr-spec) *(SEMI generic-param)
as defined in RFC 3261. This includes, for example, Contact and Route.
Either the long or compact name can be used to access the header field, as both are treated as equivalent.
name
- the long or compact name of the header to setaddr
- the additional address valuefirst
- if true, the address is added as the first value of
the specified header field, otherwise it will be the lastIllegalArgumentException
- if the specified header isn't
defined to hold address values or if the specified header field
is a system headerParameterable getParameterableHeader(String name) throws ServletParseException
Parameterable
object.
This method can be used with headers which are defined to contain
one or more entries matching
field-value *(;parameter-name=parameter-value)
as defined in RFC 3261. This includes, for example, Event and Via.
Either the long or compact name can be used to access the header field, as both are treated as equivalent.
If there is more than one header field value the first is returned.
name
- a case insensitive String
specifying
the name of the header, either the long or compact formParameterable
ServletParseException
- if the specified header field cannot be
parsed as a SIP parameterable objectNullPointerException
- if the name
is null.ListIterator<? extends Parameterable> getParameterableHeaders(String name) throws ServletParseException
ListIterator
over all Parameterable
header field values for the specified header name. The values returned
by the Iterator follow the order in which they appear in the message
header.
This method can be used with headers which are defined to contain
one or more entries matching
field-value *(;parameter-name=parameter-value)
as defined in RFC 3261. This includes, for example, Event and Via.
Either the long or compact name can be used to access the header field, as both are treated as equivalent.
If the message did not include any headers of the specified name,
this method returns an empty Iterator. If the message included headers of
the specified name with no values, this method returns an Iterator over empty
String
s.
Attempts to modify the specified header field through the
returned list iterator must fail with an
IllegalArgumentException
if the header field is a
system header.
Note: This is a fail-fast iterator and can throw ConcurrentModificationException if the underlying implementation does not allow modification after the iterator is created.
name
- a case insensitive String
specifying
the name of the header field, either the long or compact formListIterator
over the Parameterable
values of the specified header fieldServletParseException
- if the specified header field cannot be
parsed as a SIP parameterable objectNullPointerException
- if the name
is null.List<? extends Parameterable> getParameterableHeaderList(String name) throws ServletParseException
List
of all Parameterable
header field values for the specified header name. The values returned
in the List
follow the order in which they appear in the message
header.
This method can be used with headers which are defined to contain
one or more entries matching
field-value *(;parameter-name=parameter-value)
as defined in RFC 3261. This includes, for example, Event and Via.
Either the long or compact name can be used to access the header field, as both are treated as equivalent.
If the message did not include any headers of the specified name,
this method returns null. If the message included headers of
the specified name with no values, this method returns an empty List
.
Attempts to modify the specified header field through the
returned list must fail with an
IllegalArgumentException
if the header field is a
system header.
name
- a case insensitive String
specifying
the name of the header field, either the long or compact formList
of the Parameterable
values of the specified header fieldServletParseException
- if the specified header field cannot be
parsed as a SIP parameterable objectNullPointerException
- if the name
is null.void setParameterableHeader(String name, Parameterable param)
This method can be used with headers which are defined to contain
one or more entries matching
field-value *(;parameter-name=parameter-value)
as defined in RFC 3261. This includes, for example, Event and Via.
Either the long or compact name can be used to access the header field, as both are treated as equivalent.
name
- the long or compact name of the header to setparam
- the assigned Parameterable valueIllegalArgumentException
- if the specified header isn't
defined to hold Parameterable values or if the specified header field
is a system headervoid addParameterableHeader(String name, Parameterable param, boolean first)
Parameterable
as a new value of the
named header field. The parameterable is added as the last
header field value.
This method can be used with headers which are defined to contain
one or more entries matching
field-value *(;parameter-name=parameter-value)
as defined in RFC 3261. This includes, for example, Event and Via.
Either the long or compact name can be used to access the header field, as both are treated as equivalent.
name
- the long or compact name of the header to setparam
- the additional parameterable valuefirst
- if true, the parameterable is added as the first value of
the specified header field, otherwise it will be the lastIllegalArgumentException
- if the specified header isn't
defined to hold Parameterable values or if the specified header field
is a system headerString getCallId()
SipServletMessage
.SipServletMessage
int getExpires()
void setExpires(int seconds)
setHeader("Expires", String.valueOf(seconds));
seconds
- the value of the Expires header measured in secondsString getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this message. This method returns null if the message does not specify a character encoding.
The message character encoding is used when converting
between bytes and characters. If the character encoding hasn't
been set explicitly UTF-8
will be used for this
purpose.
For more information about character encodings and MIME see RFC 2045 (http://www.ietf.org/rfc/rfc2045.txt).
String
specifying the name of the charset,
for example, UTF-8
void setCharacterEncoding(String enc) throws UnsupportedEncodingException
Explicitly setting a message's character encoding potentially
affects the behavior of subsequent calls to getContent()
and setContent(java.lang.Object, java.lang.String)
.
This method must be called prior to calling either of those methods.
enc
- name of the chararacter encodingUnsupportedEncodingException
- if this is not a valid encodingint getContentLength()
String getContentType()
String
containing the name of the
MIME type of this message, or null if the body is emptybyte[] getRawContent() throws IOException
IOException
- if an IOException occurredObject getContent() throws IOException, UnsupportedEncodingException
String
object for MIME type text/plain
as for other text/*
MIME types for which the
container doesn't have specific knowledge.
It is encouraged that the object returned for "multipart" MIME
content is a javax.mail.Multipart
object. A byte array
is returned for content-types that are unknown to the container.
The message's character encoding is used when the MIME type indicates that the content consists of character data.
Note: This method, together with setContent
,
is modelled over similar methods
in the JavaMail API. Whereas the JavaMail API mandates the use of
the Java Activation Framework (JAF) as the underlying data handling
system, the SIP servlet API doesn't currently require JAF.
byte[]
object containing the raw content
if the MIME type isn't known to the platformIOException
- if an IOException
occurredUnsupportedEncodingException
- if the content is textual in
character but this message's character encoding is not
supported by the platformvoid setContent(Object content, String contentType) throws UnsupportedEncodingException
Object
.
This method only works if the implementation "knows about" the
specified object and MIME type. Containers are required to handle
byte[]
content with any MIME type.
Furthermore, containers are required to handle String
content
when used with a text/*
content type. When invoked
with non-String objects and a text/*
content type,
containers may invoke toString()
on the content
Object
in order to obtain the body's character data.
It is also recommended that implementations know how to handle
javax.mail.Multipart
content when used together with
"multipart" MIME types.
When converting String
content, this method may
use the the message's character encoding
(as set by setCharacterEncoding(java.lang.String)
, setContentType(java.lang.String)
or setContentLanguage(java.util.Locale)
) to map the String
to
a byte array.
Note: This method, together with
getContent()
, is modelled over a similar method
in the JavaMail API. Whereas the JavaMail API mandates the use of
the Java Activation Framework (JAF) as the underlying data handling
system, the SIP servlet API doesn't currently require JAF.
content
- an object representing the message contentcontentType
- MIME type of the objectUnsupportedEncodingException
- if the content is textual in
nature and this message's character encoding is unsupported by
the serverIllegalArgumentException
- if the platform doesn't know how to
serrialize content of the specified MIME typeIllegalStateException
- if the message has already been sent
or if it's read-onlyvoid setContentLength(int len)
Applications are discouraged from setting the Content-Length
directly using this method; they should instead use the
setContent
methods which guarantees that the
Content-Length is computed and set correctly.
len
- an integer specifying the length of the content being
sent to the peer; sets the Content-Length headerIllegalStateException
- if this is an incoming message or if
it has already been sentvoid setContentType(String type)
text/html; charset=UTF-8
. This will
cause the message's current character encoding to be set.
If obtaining a PrintWriter
or calling
setContent
, this method should be
called first.
type
- a String
specifying the MIME type of
the content@Deprecated Enumeration<String> getAttributeNames()
AttributeStore.getAttributeNameSet()
SipSession getSession()
SipSession
to which this message belongs.
If the session didn't already exist it is created. This method is
equivalent to calling getSession(true)
.SipSession
to which this
SipServletMessage
belongsSipSession getSession(boolean create)
SipSession
to which this message belongs.create
- indicates whether the session is created if it doesn't
already existSipSession
to which this
SipServletMessage
belongs, or null if one hasn't
been created and create
is falseSipApplicationSession getApplicationSession()
SipServletMessage
belongsSipApplicationSession getApplicationSession(boolean create)
create
- if true the session is created if it didn't
already exist, otherwise null is returnedLocale getAcceptLanguage()
Locale
that the UA originating
this message will accept content in, based on the Accept-Language
header. If this message doesn't contain an Accept-Language header,
this method returns null. Note that this behavior is different from
v1.0 where the default locale for the server would have been returned.Locale
for the sending user agentIterator<Locale> getAcceptLanguages()
Iterator
over Locale
objects
indicating, in decreasing order starting with the preferred locale,
the locales that are acceptable to the sending UA based on the
Accept-Language header. If this message doesn't provide an
Accept-Language header, this method returns an empty
Iterator
. Note that this behavior is different from
v1.0 where an Iterator
containing the default locale for
the server would have been returned.Iterator
over preferred locales for the
UA originating this messageSet<Locale> getAcceptLanguageSet()
Set
of Locale
objects
indicating, in decreasing order starting with the preferred locale,
the locales that are acceptable to the sending UA based on the
Accept-Language header. If this message doesn't provide an
Accept-Language header, this method returns an empty
Set
.Set
of preferred locales for the
UA originating this messagevoid setAcceptLanguage(Locale locale)
Locale
that this user agent will
accept content, reason phrases, warnings, etc. in. The language
identified by the Locale
will be listed in an
Accept-Language header.
A null argument is valid and removes and existing Accept-Language headers.
locale
- the preferred locale of this user agentvoid addAcceptLanguage(Locale locale)
Locale
of this user agent. The
language identified by the Locale
will be listed in
an Accept-Language header with a lower q-value than any existing
Accept-Language value, meaning the locale is less preferred than
those already identified in this message.locale
- a locale acceptable to this user agentvoid setContentLanguage(Locale locale)
setContent
.locale
- the locale of this messageLocale getContentLanguage()
Locale
identified by the Content-Language header
of the message, or null if the Content-Language header is not present.Locale
of this message, or null if none.void pushPath(Address uri)
uri
- The address that is added as a Route header valueIllegalStateException
- if invoked on non-REGISTER Request,
non-REGISTER response or non-200 class REGISTER response.void pushLocalPath()
IllegalStateException
- if invoked on non-REGISTER Request,
non-REGISTER response or non-200 class REGISTER response.void send() throws IOException
SipServletMessage
.IOException
- if a transport error occurs when trying to
send this messageIllegalStateException
- if this message cannot legally be sent
in the current state of the underlying SIP transactionboolean isSecure()
boolean isCommitted()
String getRemoteUser()
String
specifying the login of the user
sending this message, or null if the user has not been
authenticatedboolean isUserInRole(String role)
role
- a String
specifying the name of the rolePrincipal getUserPrincipal()
java.security.Principal
object containing
the name of the authenticated user agent sending this message.
If the user agent has not been authenticated, the method returns null.java.security.Principal
representing the
sending user, or null if the user has not been authenticatedSessionKeepAlive.Preference getSessionKeepAlivePreference()
Preference
object.SessionKeepAlive.Preference
String getLocalAddr()
int getLocalPort()
String getRemoteAddr()
String
containing the IP address of the
sender of this message, or null if the message is a locally generated
one such as application created outgoing messages and container
generated responses.int getRemotePort()
String getTransport()
String getInitialRemoteAddr()
getRemoteAddr()
, this method
returns the same value regardless of which application invokes it
in the same application composition chain of a specific application router.String
containing the IP address of the
sender of this message, or null if the message is a locally generated
one such as application created outgoing messages and container
generated responses.int getInitialRemotePort()
getRemotePort()
, this method
returns the same value regardless of which application invokes it
in the same application composition chain of a specific application router.String getInitialTransport()
SipWebSocketContext getLocalSipWebSocketContext()
SipWebSocketContext
associated with
the SIP WebSocket connection on which this message has arrived or sent.
In this version of SIP servlet specification, the SIP WebSocket
connection is always established from the websocket client to the SIP
container.SipWebSocketContext
.SipWebSocketContext
boolean isInternallyRouted()
void setHeaderForm(SipServletMessage.HeaderForm form)
setUseCompactForm
method or set it to use SipServletMessage.HeaderForm.DEFAULT
and instead set the non-system
headers directly using the compact or long form setHeader(String, String)
.
eg.
SipServletMessage message; ..... message.setHeader("s", "Meeting at 5pm"); // Subject header compact form message.setHeader("Allow-Events", "telephone-event"); // Long form .....For applications to set each header individually the value of the
HeaderForm
MUST be SipServletMessage.HeaderForm.DEFAULT
The list of assigned compact form is available in the IANA registry at
http://www.iana.org/assignments/sip-parametersform
- form desired by the applicationSipServletMessage.HeaderForm getHeaderForm()
SipServletMessage.HeaderForm.DEFAULT
Copyright © 1996-2015, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.