<?xml version="1.0" encoding="utf-8"?>

<!--
    This is the configuration file for the jiplet container application. 
    This file is needed for the standalone configuration as well as when 
    the jiplet container is running as a JBOSS service. This file defines 
    the SIP connectors used by the jiplet container and their properties.
    
    SIP connectors specify addresses and ports that the jiplet container  
    uses to send and receive SIP messages. The jiplet container, by default,  
    defines a single connector listening on TCP and UDP ports 5060 (standard SIP
    ports) using the machine host address, but additional addresses and/or ports  
    can be defined on a connector to make use of multiple interfaces or to support
    different types of transport (udp, etc).
    
    All of the jiplet contexts, or applications, deployed in a jiplet container may
    use the same connector, so it may not be necessary to define multiple connectors.
    However, you may decide to use multiple connectors for reasons explained below.
-->

<server
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="server_2.0.xsd">

    <!--
        The following element defines all the connectors. It must
        contain the "connector" element that defines the properties
        of a connector.
    -->
    <connectors>
        
        <!-- Add one or more connectors below -->
        
        <!--
            Each connector has a "name" attribute that defines the
            name of the connector. This name must be referred to 
            from the jiplet descriptor to specify the connectors.
            
            The "default" attribute specifies if this is the default 
            connector. If set to true and if a jiplet defined in
            a jiplet descriptor does not define a connector, the
            default connector is used.
            
            The "min-threads" and "max-threads" attributes define the
            number of threads in the pool that handles SIP messages
            and events. When the system starts up, the system starts
            up min-threads number of threads to handle SIP messages/
            events. These threads always hang around and therefore,
            are permanent in nature. If all permanent threads are 
            used up, temporary threads are created to handle the
            request. These threads are disposed of after the 
            jiplet has handled the event. If max-threads are already
            created, the SIP message/event is not responded to. How 
            you want to configure these parameters will depend on your
            system traffic.   
            
            Defining multiple connectors may not be required since any number of
            jiplet contexts can share the same connector. However, there are some
            reasons why you might define multiple connectors:
               a) to partition SIP traffic on a per-customer/domain or network basis
            in order to provide varying quality of service. The SIP connectors used
            for a higher quality of service would have more permanent threads 
            assigned than other connectors, and perhaps more temporary 
            threads as well.
               b) to simplify the context mappings that you will have to define. 
            Context mappings are used by the jiplet container to route received
            SIP request messages to the correct context, or application. (See the
            jip.xml configuration file for details on how to define the mappings.)
            Simpler mappings make for a more efficient jiplet container.
               c) to use different SIP stack providers or stack properties. Some
            jiplet applications may require certain stack properties to be set.
            
            Note that you can define multiple connectors even if you 
            have only one physical network interface. It can be done by
            assigning multiple IP addresses to the IP hardware interface.
            
            If you do use multiple IP addresses when configuring a connector, 
            the IP networking (IP routing tables) on the system running the Jiplet 
            Container may need to be modified so that the system can do IP forwarding 
            between those interfaces used for SIP messaging. Otherwise, SIP messages 
            may not be able to be proxied across the different network interfaces.
            
        -->
        <connector name="sip-connector" default="true"
            min-threads="5" max-threads="100">
            
            <!--
                The element below specifies the SIP stack provider. By
                default, we use the NIST JAIN SIP stack but you can
                change it if you want a different stack. The provider
                name must be entered as per the vendor's specification. 
            -->       
            <jip-stack>gov.nist</jip-stack>
            
            <!--
                The port list below specifies the IP addresses, port numbers and types
                of protocol (ie, udp) that this connector should use for SIP messaging. 
                Any number of these can be listed; more than one IP address is allowed.
                See the example below. There must be at least one entry in the list. 
                
                If you have other connectors besides this one defined, make sure that 
                you don't have duplicate jip-port entries because only one connector can 
                bind to a unique combination of address, port, and type.
                
                The "default" attribute is optional and indicates which jip-port the
                jiplet container should use for VIA and other headers when
                proxying a request or when sending out miscellaneous requests. 
                This default jip-port is the one that will be used to send 
                such requests and therefore it should use a network interface
                that connects to other SIP networks so that the
                messages can reach their destinations. This interface must be
                accessible from the other SIP networks as well.
                
                If there is no "default" specified, the first entry in the list is
                used as the default.
                
                The "address" attribute is optional for an entry in the list.
                If an entry doesn't specify the "address" attribute, the 
				the host name/address as set on your system is used. This may
                not work very well if you have more than one IP interface. 
                Therefore, you may want to specify this parameter explicitly.
                
                Example:
                  <jip-ports>
                      <jip-port address="192.168.1.100" type="udp" port="5060"/>                
                      <jip-port address="192.168.1.100" type="tcp" port="5060"/>
                      <jip-port address="192.168.1.101" type="udp" port="5060" default="true"/>                
                      <jip-port address="192.168.1.101" type="tcp" port="5060"/>
                  </jip-ports>
                  
            -->
            <jip-ports>
                <jip-port type="udp" port="5060"/>                
                <jip-port type="tcp" port="5060"/>
            </jip-ports>
            
            <!--
                You can specify the SIP stack properties supported by the 
                SIP stack vendor. These properties are passed on to the
                SIP stack during initialization.
              -->
            <jip-properties>
               <!-- 
                    Add one or more properties here. These propeties
                    will be passed to the JAIN SIP stack. 
               -->
               <jip-property key="javax.sip.STACK_NAME" value="jain-sip-nist-stack"/>
               
               <!--
                NOTE: If the javax.sip.IP_ADDRESS property is included in the property
                list below, it is ignored by the Jiplet Container. The IP address(es) 
                used by this connector are solely determined by the jip-ports list 
                above. Please see the comments there.
                -->
                
               <jip-property key="javax.sip.RETRANSMISSION_FILTER" value="true"/>
               <jip-property key="gov.nist.javax.sip.TRACE_LEVEL" value="0"/>
               <jip-property key="gov.nist.javax.sip.DEBUG_LOG" value="proxyserver_log.txt"/>
               <jip-property key="gov.nist.javax.sip.READ_TIMEOUT" value="1000"/>
               <jip-property key="gov.nist.javax.sip.CACHE_SERVER_CONNECTIONS" value="true"/>
            </jip-properties>
        </connector>        
    </connectors>
    
    <!--
        Realms are protected domains. They are used for specifying authentication
        and authorization databases. If a jiplet is configured to use a realm
        (see jip.xml for details), the jiplet container authenticates SIP 
        request message that are meant for the jiplet prior to passing it on
        to the jiplet for handling. The jiplet container throws authentication
        challenges if necessary, authenticates credentials received in the message
        and check if the user has the necessary privilege to access the jiplet.
        
        The jiplet container supports definitions of multiple realms in this file.
        Each realm is defined as a <realm> element inside the <reals> element.
        The jiplet container provides a number of pre-defined realms like a
        MemoryRealm and JdbcRealm (explained below). However, it is possible to
        define your own realm as well to provide customized authentication
        and authorization logic (see the Jiplet developer guide for details).
        
        The attribute "auth-cache-period" defines the caching period in seconds.
        The container stores auth credentials received from the SIP end points
        for a given period of time and uses the cache to authnticate users. That
        way, a database lookup is avoided. However, caching does cost memory and
        therfore, a balance has to be struck. This parameter is used to specify
        how long a record should be cached. The auth record is removed from the
        cache after n seconds of message inactivity where n is the cache period.
        
        The attribute "auth-on-logout" specifies if the jiplet container must
        perform authenitcation check on a REGISTER message with EXPIRES header
        containing 0 (basically, a logout). We strongly recommend that you set
        this value to "true". However, it appears that Microsft messenger cannot
        handle an AUTH challenge during a logout. So, if you want the server to
        support logout with the messenger, you may not have much option other than 
        to set this value to "false". Setting this attribute to "false" does have 
        serious security implications. That is a rogue SIP REGISTER message
        impersonating an authorized user can log him/her out.
        
        Each realm has its own set of parameters and are explained below.   
    -->
    <realms auth-cache-period="1800" 
        auth-on-logout="true">
        
        <!--
            The following specifies the memory realm. The memory realm provides
            a memory-resident authentication/authorization database. The database
            is read from a file that resides in the conf directory. The file
            name is specified by the realm-param named user-db-file. The file
            contains user names, passwords and roles (privilege levels) information.
            This file is read during init time and is stored in the memory.
            When a SIP request message is received, the auth information provided
            by the message is authenticated from this data.
            
            Attributes:
                name: name of the realm. The name must be unique. This realm
                name is sent by the jiplet container wile sending a
                challenge.
                
                classname: name of the class that implements this realm.
                
                default: whether this realm is the default realm or not.
            
            The realm-params element is used to specify parameters that are
            specific for this realm.
            
            Memory realm params:
                nonce-private-key: A secret key that is used by the jiplet
                container to create a nonce when sending a challenge.
                
                user-db-file: name of the file containing the auth information.
                
                domain-uri: Name of the domain that is sent by the jiplet
                container when sending a challenge.  
        --> 
        <realm name="subscribers.cafesip.org" 
            classname="org.cafesip.jiplet.realms.MemoryRealm"
            default="true">
            <realm-params>
                <realm-param>
                   <realm-param-name>nonce-private-key</realm-param-name>
                   <realm-param-value>spice</realm-param-value>                    
                </realm-param>
                
                <realm-param>
                   <realm-param-name>user-db-file</realm-param-name>
                   <realm-param-value>jiplet-users.xml</realm-param-value>                    
                </realm-param>

                <realm-param>
                   <realm-param-name>domain-uri</realm-param-name>
                   <realm-param-value>sip:cafesip.org</realm-param-value>                    
                </realm-param>
                
            </realm-params>
        </realm>
        
        <!--
            The following specifies the JDBC realm. This realm provides a
            authentication/authorization database that resides in a SQL
            server. The database contains user name, password and role
            information. When a SIP request message is received, the auth 
            information provided by the message is authenticated from this data
            by performing a SQL query.
            
            Attributes:
                name: name of the realm. The name must be unique. This realm
                name is sent by the jiplet container wile sending a
                challenge.
                
                classname: name of the class that implements this realm.
                
                default: whether this realm is the default realm or not.
            
            The realm-params element is used to specify parameters that are
            specific for this realm.

            JDBC realm param:
                nonce-private-key: A secret key that is used by the jiplet
                container to create a nonce when sending a challenge.
                
                domain-uri: Name of the domain that is sent by the jiplet
                container when sending a challenge.  
                
                jdbc-driver: The JDBC driver class name. The following value
                has been set for the MySQL database. For other databases,
                you will have to specify a different name. You will also
                have to copy the JDBC driver jar files into common/lib
                directory. See the jiplet developer guide for details.        
            
                jdbc-url: The URL for the JDBC-compliant database. The URL
                must be specified using a string that follows the JDBC conventions
                and supported by the JDBC driver. 
                
                jdbc-user: The database user name. The user must have 
                proper privileges to create table, write and read data
                to and from this table.
                
                jdbc-password: The database password. If a password is not
                required (bad idea), this param does not have to specified.
                
            Uncomment the following to activate this realm. Make changes
            as required.
                             
        <realm name="subscribers.cafesip.org" 
            classname="org.cafesip.jiplet.realms.JdbcRealm"
            default="false">
            <realm-params>
                <realm-param>
                   <realm-param-name>nonce-private-key</realm-param-name>
                   <realm-param-value>spice</realm-param-value>                    
                </realm-param>
                
                <realm-param>
                   <realm-param-name>jdbc-driver</realm-param-name>
                   <realm-param-value>com.mysql.jdbc.Driver</realm-param-value>                    
                </realm-param>

                <realm-param>
                   <realm-param-name>jdbc-url</realm-param-name>
                   <realm-param-value>jdbc:mysql://localhost/test</realm-param-value>                    
                </realm-param>

                <realm-param>
                   <realm-param-name>jdbc-user</realm-param-name>
                   <realm-param-value>anonymous</realm-param-value>                    
                </realm-param>

                <realm-param>
                   <realm-param-name>jdbc-password</realm-param-name>
                   <realm-param-value>anonymous</realm-param-value>                    
                </realm-param>
                
                <realm-param>
                   <realm-param-name>domain-uri</realm-param-name>
                   <realm-param-value>sip:cafesip.org</realm-param-value>                    
                </realm-param>
                
            </realm-params>
        </realm>
        -->        
    </realms>
      
</server>