Brekeke SIP Server Wiki

4. Methods

This section explains all methods that a plug-in must implement. These methods are declared in UserDir interface.

 

1. init

Method:

public void init( Envrnmt env, Logging log ) throws Exception

Description: init() method is called when Brekeke SIP Server starts. Please include any kind of initialization regarding the plug-in such as connecting a database or setting log levels.

Parameters:

  • env – Envrnmt object
  • log – Logging object

 

2. close

Method:

 public void close() throws Exception

Description: close() method is called while Brekeke SIP Server is shutting down. Please include any kind of endings regarding the plug-in such as disconnection with database.

 

3. lookup

Method:

public UserRecord lookup( String username, String method, String destination, String authinfo ) throws Exception

Description:

lookup method is called when Brekeke SIP Server needs to do authentication. User name, SIP method name of the request, destination SIP-URI and Proxy-Authorization header value or Authorization header value are passed as argument.

User name is supposed to be used as a search key for a user directory. SIP method name and destination URI can be used for the information to make a decision. Put the search result of the user into a UserRecord object as a return value.

You must set username variable in UserRecord object. If the authorization is done here, and Brekeke SIP Server does not need to do an authorization, you do not need to set password variable however you must set bAuthorized = true. Otherwise, a plain password must be set in password variable. If the password in the user directory is encrypted, it must be decrypted.

Return value is a UserRecord object. If you want to fail the authentication regardless of the search result, return null.

If an exception occurs, Brekeke SIP Server fails the authentication and does not execute the request.

Parameters:         

  • username – User name of the user who sent the request
  • method – SIP method name of the request
  • destination – Destination SIP-URI of the request
  • authinfo – Proxy-Authorization header value (INVITE) or Authorization header value (REGISTER)

Returns:   

  • UserRecord object
  • null for authorization failure

 

4. append

Method:

public boolean append( UserRecord record ) throws Exception

Description: Brekeke SIP Server does not call this append method. This is supposed to be called from other tools. When this method is called, add the record to the user directory.

Parameters:  record – UserRecord object

Returns:

  • true if successful
  • false if not successful

 

5. remove

Method:

public boolean remove( UserRecord record ) throws Exception

Description: Brekeke SIP Server does not call this remove method. This is supposed to be called from other tools. When this method is called, remove the record from the user directory.

Parameters: record – UserRecord object

Returns:

  • true if successful
  • false if not successful

 

6. remove

Method:

public boolean remove( String username ) throws Exception

Description: Brekeke SIP Server does not call this remove method. This is supposed to be called from other tools. When this method is called, remove the record of given user name from the user directory.

Parameters: username – user name

Returns:

  • true if successful
  • false if not successful

 

7. getCount()

Method:

public int getCount() throws Exception

Description: When this method is called, return the number of users in the user directory.

Returns: the number of users in the user directory

 

 

Related Links:

 

Yes No
Suggest Edit