5.24.5 User Login and Logout Notifications

 

This document covers the details of the Login and Logout notification feature.



 

Overview

 

There is a need to monitor user authentication activity, like login, login failure, and logout. In Web NMS to monitor and notify the user authentications, authentication failures, a new feature is added. This feature enables Web NMS to notify the registered module/application whenever a user login, fail to login and logout due to various reasons including certain failure conditions related to Client and FE Server.

 

Description of User Login and Logout Notification feature

 

The user should implement the ClientConnectionObserver interface and should register with the GenericBEAPI using

{GenericBEAPI.registerClientConnectionObserver(ClientConnectionObserver co)} method to listen for notification. The interface needs to be implemented for getting notification when a user tries to Login, Logout and Login Failure using Application, Applet, Web Start and Web Client. When the user performs login or logout, the handleClientConnection method of each of the observer will be called with the information about the change, in the order they got registered. If you do not want to receive notification, you can do so by deregistering the ClientConnectionObserver using {GenericBEAPI.deregisterClientConnectionObserver(ClientConnectionObserver co)} method.

 

This interface can listen for notifications through RMI too. To use RMI, get the GenericBEAPI reference through RMI and register. The Object registering also has to export itself by invoking the java.rmi.server.UnicastRemoteObject.exportObj.

 

The interface shall extend Remote Method Invocation and this interface shall be implemented for getting Notification. It shall also contain the properties related to client.

 

ClientObserver interface{

public void handleClientConnection(String TypeOfNotification,Properties prop){

}

}

 

 

TypeOfNotification shall include:

 

String Value

Defiition

Login_Success

Implies that a user has performed a login to the client and the user login successfully

Login_Failure

Implies that a user has performed a login to the client and the user was not able to Login.

Logout

Implies either the user has logout from the client or the client has been terminated by other source.

 

prop shall include:

 

Property Key

Property Value

CLIENT_IPADDRESS

The IP address of the client that is trying to connect or that is connected with the server.

FE_SERVER_PORT

The port in which the server is listening for the Client.

FE_SERVER_NAMES

The host name of the server.

CLIENT_TYPE

The type of client.

SERVER_TYPE

The type of Server, whether BE or FE.

USER_NAME

The name of the user who is trying to connect or who has been connected.

REQUEST_TIME

The time in which the Request was generated by the Client. The time would correspond to the BE Server.

OPERATION_INFO

Information related to Login Failure or Logout.

 

The String Values and Property Keys are constants.

Top

 

Implementing User Login and Logout Notification

 

 

Writing a class implementing ClientConnectionObserver interface

 

Code snippet for SampleClientConnectionObserver class implementing ClientConnectionObserver:

 

import java.util.*;

import java.rmi.*;

import java.io.*;

import com.adventnet.nms.util.ClientConnectionObserver;

 

public class SampleClientConnectionObserver implements ClientConnectionObserver

{

public void handleClientConnection(String TypeOfNotification,Properties prop)

{

try

{

if(TypeOfNotification.equalsIgnoreCase("Login_Success"))

{

//perform Login Success Operation here

}

else if(TypeOfNotification.equalsIgnoreCase("Login_Failure"))

{

//perform Login Failure Operation here

}

else if(TypeOfNotification.equalsIgnoreCase("Logout"))

{

//perform Logout operation here

}

}

catch(Exception e)

{

System.out.println("Exception in handleClient Connection"+e);

}

}

}

 

 

Top

 

Registering and de-registering the class as an Observer

 

Code snippet for registering as a ClientConnectionObserver:

 

try

{

//Get The GenericBE handle

GenericBEAPI genericApi = (GenericBEAPI)Naming.lookup("//localhost:1099/GenericBEAPI");//using RMI

 

// OR in the Same JVM

GenericBEAPI genericApi=(GenericBEAPI)GenericBEAPIImpl.getInstance();

System.out.println("successfully got the handle");

java.rmi.server.UnicastRemoteObject.exportObject(toReg);// In case of RMI

//Register as ClientConnectionObserver

 

boolean result=genericApi.registerClientConnectionObserver(toReg);

System.out.println("registed as ClientConnectionObserver"+result);

}

catch( Exception e)

{

System.out.println("Exception occured while registering clientConnectionObserver"+e);

 

}

 

Code snippet for de-registering as ClientConnectionObserver:

 

try

{

//Get The GenericBE handle

GenericBEAPI genericApi = (GenericBEAPI)Naming.lookup("//localhost:1099/GenericBEAPI");//using RMI

// OR in the Same JVM

 

GenericBEAPI genericApi=(GenericBEAPI)GenericBEAPIImpl.getInstance();

System.out.println("successfully got the handle");

java.rmi.server.UnicastRemoteObject.exportObject(toReg);// In case of RMI

//DeRegister as ClientConnectionObserver

 

boolean result=genericApi.deregisterClientConnectionObserver(toReg);

System.out.println("Deregisted as ClientConnectionObserver"+result);

}

catch( Exception e)

{

System.out.println("Exception occured while Deregistering clientConnectionObserver"+e);

 

}

 

 

Top

 

Handling send Notification for Custom Authentication Module Implementation

 

If you are using custom authentication module, you have to handle sending notification for login failure scenario.

 

Web NMS Framework takes care of sending notification for login and logout, while custom Authentication is implemented. However developer has to take care of generating notification during login failure. To achieve this we have provided a new method called notify(String type_of_notification, Properties prop) in NmsAuthenticationAPI.  Set the type of notification as Login_Failure (for login failure cases) and generate the properties.

     

An example has been provided with respect to Radius implementation:

 

In RadiusAuthenticationImpl.java the verifyCredentials() method (code snippet) should be as given below:

 

public boolean verifyCredentials(String user, String key) throws RemoteException, AuthenticationException
    {
        System.out.println("CORRECT :::::::::::");
        String password = null;
        if ( crypto != null )
        {
            try
            {
                //decrypt the password before authentication with RADIUS server
                password = crypto.deCrypt(key);
            }
            catch (CryptoGraphException e)
            {
                e.printStackTrace();
            }
        }
        //authenticate the user using RADIUS server and return the status
        boolean result=RadiusUtil.getInstance().authenticateUser(user,password);
        if(!result)
        {
                Properties prop=new Properties();
                //Set the properties here
               
                super.notify("Login_Failure",prop);
        }
        return result;
    }

 

In the above code, the developer has to set the appropriate properties which he wants to send it in the Login failure notification.

Also the developer should ensure that he handles the properties while receiving notification.

 

Top

 

Conditions for which Web NMS notifies the registered module

    

Login success

Login failure due to the below mentioned reasons

Logout

Client related conditions

FE Server related conditions

 

Top

 

Javadocs

 

Refer the Javadocs

 

For interface:

 

Interface ClientConnectionObserver

 

For methods:

com.adventnet.nms.commonbe.GenericBEAPI.registerClientConnectionObserver API

 

com.adventnet.nms.commonbe.GenericBEAPI.deregisterClientConnectionObserver API

 

com.adventnet.nms.security.authentication.NmsAuthenticationAPI.notify API

 

 

Top

 



Copyright © 2011, ZOHO Corp. All Rights Reserved.