Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

In this tutorial, we'll who how to add SIP Digest authentication to the MyServlet servlet when receiving REGISTER and INVITE requests.
To add declarative security, add the following declarations in your sip.xml file:

Code Block
xml
xml
titlesip.xmlxml
<?xml version="1.0" encoding="UTF-8"?>
<sip-app  xmlns="http://www.jcp.org/xml/ns/sipservlet"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.jcp.org/xml/ns/sipservlet http://www.jcp.org/xml/ns/sipservlet/sip-app_1_1.xsd"
          version="1.1">

  <!-- Ensure that all REGISTER and INVITE requests processed by servlet MyServlet are authentified -->
  <security-constraint>
    <resource-collection>
      <resource-name>Protected Resource</resource-name>
      <servlet-name>MyServlet</servlet-name>
      <sip-method>INVITE</sip-method>
      <sip-method>REGISTER</sip-method>
    </resource-collection>
    <auth-constraint>
      <role-name>*</role-name>
    </auth-constraint>
  </security-constraint>

  <!--  Use realm name cipango.org and digest for authentication -->
  <login-config>
    <auth-method>DIGEST</auth-method>
    <realm-name>cipango.org</realm-name>
  </login-config>

  [...]

</sip-app>

Next step is to declare users and their credentials. To do so, we add the following jetty-web.xml configuration file to our application (in the same directory as sip.xml). In this file we configure a LoginService which is responsible for user management.

Code Block
xml
xml
titlejetty-web.xmlxml
<?xml version="1.0" encoding="ISO-8859-1"?>
<Configure class="org.cipango.sipapp.SipAppContext">
  <Get name="sipSecurityHandler">
    <Set name="loginService">
      <New class="org.eclipse.jetty.security.HashLoginService">
            <Set name="name">cipango.org</Set>
            <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
      </New>
    </Set>
  </Get>

</Configure>

...