Support for Diameter Sh API in sailfin

Sailfin project will soon support Diameter protocol and will have API's to enable applications to use Sh,Ro,Rf functionality. As we progress towards providing Diameter support in Sailfin, we have released Sh API's to solicit your valuable feedback. In course of time we will publish API's for Ro and Rf applications too.

Javadocs for Sh API is published here. I will keep writing here on Sh API', to start with let us quickly look at a simple sample on how to use Sh API in a SIP Servlet.








public class RegisterServlet extends SipServlet {
     protected void doInvite(SipServletRequest req) throws ServletException, IOException {

      
       ProfileData data = readUserState(req.getSubscriberURI().toString());
       SipServletResponse resp = req.createResponse(180);
       req.setExpires(2000000);
       resp.send();
     }

     private ProfileData readUserState(String user) {
      try {
        InitialContext context = new InitialContext();
        //configuration of HSS server is configured using Sailfin Admin UI.
        UserProfileServer connectionFactory = (UserProfileServer) context.lookup("eis/SH");
        UserProfileConnection connection = connectionFactory.createConnection();
        // Configure Key specifying information to read.
        ReadProfileKey rpk = new ReadProfileKey();
        rpk.addDataReference(DataReference.IMS_USER_STATE);
        eg:"sip:bob-AT-open-ims-DOT-test"
        UserIdentity uID = new UserIdentity(user, UserIdentityType.PUBLIC_USER_ID);
        rpk.setUserIdentity(uID);
        //validate if the constructed key is correct and all information needed is provided.
        rpk.validate();
        //perform a read operation from HSS server in synchronous mode.
        UserProfileReadResponse urr = connection.read(rpk, false);
        ProfileData data = urr.getProfileData();
        //read the information as bytes,XMLStream or JAXBObject
        System.out.println("User Profile data is" + new String(data.toBytes()));
        return data;
      } catch (KeyValidationException ex) {
       Logger.getLogger(RegisterServlet.class.getName()).log(Level.SEVERE, null, ex);
      } catch (ConnectException ex) {
       Logger.getLogger(RegisterServlet.class.getName()).log(Level.SEVERE, null, ex);
      } catch (NamingException ex) {
       Logger.getLogger(RegisterServlet.class.getName()).log(Level.SEVERE, null, ex);
      }
      return null;
}
}

We encourage users to look at Javadocs and provide us feedback. Please write to us at dev-AT-sailfin.dev.java.net

Comments:

Hi Gopal,

I am only really starting to look at this area. I have played with HSS in Ericssons SDS. What HSS do you use? Any good open source one.

Thanks,
Cormac

Posted by Cormac on April 16, 2009 at 01:18 PM IST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

venu

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today