org.mobicents.slee.util
Class SipUtilsImpl

java.lang.Object
  extended by org.mobicents.slee.util.SipUtilsImpl
All Implemented Interfaces:
SipUtils

public class SipUtilsImpl
extends java.lang.Object
implements SipUtils


Constructor Summary
SipUtilsImpl(net.java.slee.resource.sip.SleeSipProvider sipProvider, javax.sip.header.HeaderFactory headerFactory, javax.sip.message.MessageFactory messageFactory, javax.sip.address.AddressFactory addressFactory)
           
 
Method Summary
 javax.sip.message.Request buildAck(javax.sip.Dialog dialog, java.lang.Object content)
          Build an ACK request based on a dialog and an optional content.
 javax.sip.message.Request buildInvite(javax.sip.address.Address fromAddress, javax.sip.address.Address toAddress, byte[] content, int cSeq)
          Sends an SIP invite request from caller to callee
 javax.sip.message.Request buildInvite(javax.sip.address.Address fromAddress, javax.sip.address.Address toAddress, byte[] content, int cSeq, java.lang.String callId)
           
 javax.sip.message.Request buildRequestWithAuthorizationHeader(javax.sip.ResponseEvent event, java.lang.String password)
          Build the request associated with the event again but this time include an authorization header or proxy authorization header based on the Digest Scheme presented in RFC 2069.
 javax.sip.address.SipURI convertAddressToSipURI(javax.sip.address.Address address)
           
 javax.sip.address.Address convertURIToAddress(java.lang.String uri)
           
 javax.sip.address.SipURI convertURIToSipURI(java.lang.String uri)
           
 javax.sip.header.ContactHeader createLocalContactHeader(java.lang.String user)
          Add a contact header (which is mandatory for INVITE's).
 javax.sip.header.ViaHeader createLocalViaHeader()
          Create a ViaHeader based on the local ip of the sip stack, the port and transport based on the sip providers first listening point.
 java.lang.String generateTag()
          Generates a tag to be used e.g.
 javax.sip.Dialog getDialog(javax.sip.RequestEvent event)
          Returns the Dialog for a RequestEvent.
 javax.sip.Dialog getDialog(javax.sip.ResponseEvent event)
          Returns the Dialog for a ResponseEvent.
 java.lang.String[] parseSipUri(java.lang.String sipURI)
          Parses a String in the format "sip:user@host" and returns a String array containing user in index 0 and host in index 1.
 void sendCancel(javax.sip.ClientTransaction ct)
          Sends a sip CANCEL request in the context of the transaction that is to be cancelled.
 void sendOk(javax.sip.message.Request request)
          Sends a sip OK request
 void sendStatefulOk(javax.sip.RequestEvent event)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SipUtilsImpl

public SipUtilsImpl(net.java.slee.resource.sip.SleeSipProvider sipProvider,
                    javax.sip.header.HeaderFactory headerFactory,
                    javax.sip.message.MessageFactory messageFactory,
                    javax.sip.address.AddressFactory addressFactory)
Method Detail

getDialog

public javax.sip.Dialog getDialog(javax.sip.ResponseEvent event)
                           throws javax.sip.SipException
Description copied from interface: SipUtils
Returns the Dialog for a ResponseEvent. Use this method e.g. if automatic dialog support is disabled in the sip stack that is used.

Specified by:
getDialog in interface SipUtils
Returns:
Throws:
javax.sip.SipException

getDialog

public javax.sip.Dialog getDialog(javax.sip.RequestEvent event)
                           throws javax.sip.SipException
Description copied from interface: SipUtils
Returns the Dialog for a RequestEvent. Use this method e.g. if automatic dialog support is disabled in the sip stack that is used.

Specified by:
getDialog in interface SipUtils
Returns:
Throws:
javax.sip.SipException

generateTag

public java.lang.String generateTag()
Description copied from interface: SipUtils
Generates a tag to be used e.g. as a from header tag parameter making up a part of the dialog id.

Specified by:
generateTag in interface SipUtils
Returns:
Returns a generated tag as a String

convertURIToAddress

public javax.sip.address.Address convertURIToAddress(java.lang.String uri)
Specified by:
convertURIToAddress in interface SipUtils

convertURIToSipURI

public javax.sip.address.SipURI convertURIToSipURI(java.lang.String uri)
Specified by:
convertURIToSipURI in interface SipUtils

parseSipUri

public java.lang.String[] parseSipUri(java.lang.String sipURI)
                               throws java.net.URISyntaxException
Description copied from interface: SipUtils
Parses a String in the format "sip:user@host" and returns a String array containing user in index 0 and host in index 1.

Specified by:
parseSipUri in interface SipUtils
Returns:
A String array containing the user (index 0) and host (index 1)
Throws:
java.net.URISyntaxException - If the URI is malformed

convertAddressToSipURI

public javax.sip.address.SipURI convertAddressToSipURI(javax.sip.address.Address address)
                                                throws java.text.ParseException
Specified by:
convertAddressToSipURI in interface SipUtils
Throws:
java.text.ParseException

sendCancel

public void sendCancel(javax.sip.ClientTransaction ct)
                throws javax.sip.SipException
Description copied from interface: SipUtils
Sends a sip CANCEL request in the context of the transaction that is to be cancelled.

Specified by:
sendCancel in interface SipUtils
Parameters:
ct - The client transaction that was used to send e.g. the initial INVITE that is to be cancelled.
Throws:
javax.sip.SipException

buildInvite

public javax.sip.message.Request buildInvite(javax.sip.address.Address fromAddress,
                                             javax.sip.address.Address toAddress,
                                             byte[] content,
                                             int cSeq)
                                      throws java.text.ParseException,
                                             javax.sip.InvalidArgumentException
Description copied from interface: SipUtils
Sends an SIP invite request from caller to callee

Specified by:
buildInvite in interface SipUtils
Parameters:
fromAddress - The originator address
toAddress - The destination address
content - The SDP content (use null if not present)
cSeq - The sequence number of the INVITE
Returns:
The INVITE request
Throws:
java.text.ParseException - If illegal address format
javax.sip.InvalidArgumentException - If cSeq invalid number

buildInvite

public javax.sip.message.Request buildInvite(javax.sip.address.Address fromAddress,
                                             javax.sip.address.Address toAddress,
                                             byte[] content,
                                             int cSeq,
                                             java.lang.String callId)
                                      throws java.text.ParseException,
                                             javax.sip.InvalidArgumentException
Throws:
java.text.ParseException
javax.sip.InvalidArgumentException

createLocalContactHeader

public javax.sip.header.ContactHeader createLocalContactHeader(java.lang.String user)
                                                        throws java.text.ParseException
Description copied from interface: SipUtils
Add a contact header (which is mandatory for INVITE's). The Contact header field value contains the URI at which the User Agent would like to receive requests, and this URI MUST be valid even if used in subsequent requests outside of any dialogs.

Specified by:
createLocalContactHeader in interface SipUtils
Returns:
A Contact Header based on the local ip of the sip stack, the port and transport based on the sip providers first listening point.
Throws:
java.text.ParseException

createLocalViaHeader

public javax.sip.header.ViaHeader createLocalViaHeader()
                                                throws java.text.ParseException,
                                                       javax.sip.InvalidArgumentException
Description copied from interface: SipUtils
Create a ViaHeader based on the local ip of the sip stack, the port and transport based on the sip providers first listening point. The Via header field indicates the transport used for the transaction and identifies the location where the response is to be sent.

Specified by:
createLocalViaHeader in interface SipUtils
Returns:
A new via header
Throws:
java.text.ParseException
javax.sip.InvalidArgumentException

buildRequestWithAuthorizationHeader

public javax.sip.message.Request buildRequestWithAuthorizationHeader(javax.sip.ResponseEvent event,
                                                                     java.lang.String password)
                                                              throws javax.sip.TransactionUnavailableException
Description copied from interface: SipUtils
Build the request associated with the event again but this time include an authorization header or proxy authorization header based on the Digest Scheme presented in RFC 2069.

Specified by:
buildRequestWithAuthorizationHeader in interface SipUtils
Parameters:
event - The event containing the 401 Unauthorized or 407 Proxy Authentication Required response and the request that generated this response.
password - The password used to authenticate the user
Returns:
The request including authentication.
Throws:
javax.sip.TransactionUnavailableException

buildAck

public javax.sip.message.Request buildAck(javax.sip.Dialog dialog,
                                          java.lang.Object content)
                                   throws javax.sip.SipException
Description copied from interface: SipUtils
Build an ACK request based on a dialog and an optional content.

Specified by:
buildAck in interface SipUtils
Parameters:
dialog - The dialog to which this ACK should be connected
content - The content to append to the ACK Request (use null if no content)
Returns:
The generated ACK Request
Throws:
javax.sip.SipException

sendOk

public void sendOk(javax.sip.message.Request request)
            throws java.text.ParseException,
                   javax.sip.SipException
Description copied from interface: SipUtils
Sends a sip OK request

Specified by:
sendOk in interface SipUtils
Parameters:
request - The request to which the OK is sent
Throws:
java.text.ParseException
javax.sip.SipException

sendStatefulOk

public void sendStatefulOk(javax.sip.RequestEvent event)
                    throws java.text.ParseException,
                           javax.sip.SipException,
                           javax.sip.InvalidArgumentException
Specified by:
sendStatefulOk in interface SipUtils
Throws:
java.text.ParseException
javax.sip.SipException
javax.sip.InvalidArgumentException


Copyright © 2010. All Rights Reserved.