|
This document covers the details of the Login and Logout notification feature.
Writing a class implementing ClientConnectionObserver interface
Handling send Notification for Custom Authentication Module Implementation
Conditions for which Web NMS notifies the registered module/application
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.
Implementing User Login and Logout Notification
Writing a class implementing ClientConnectionObserver interface
Handling send Notification for Custom Authentication Module Implementation
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); } } } |
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);
} |
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 |
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.
Conditions for which Web NMS notifies the registered module
Login success
When the user successfully login, by specifying valid user name and password, to connect the Client with the Server.
Login failure due to the below mentioned reasons
Specifying the correct user name, but a wrong password.
Specifying the wrong user name.
Expiry of account with a particular user name.
Expiry of password.
Disabled user account.
Forced out user account.
When the user's failed login attempts exceed the maximum number of login attempts permitted.
Logout
By clicking the Exit button in Application/Applet/Web Start Client.
By clicking the Close button in Application/Applet/Web Start Client.
By clicking the Logout link in Web Client.
Client related conditions
When there is no Keep Alive from Client.
When there is an exception while listening for request from Client.
FE Server related conditions
When all clients connected to a FE Server are logged out, due to the following reasons.
The BE server reconnection with the FE Server.
There is no Keep Alive from a particular FE Server.
There is an error while connecting the FE server with the BE Server.
When the FE Server Queue for sending data exceeds maximum size.
When there is an exception while sending data from FE Server to the Client.
Notification shall be sent to all clients connected to the FE Server, when FE server is killed or closed.
When there is a communication failure, while an updated request is sent for updating the custom view.
Notification shall be sent to all clients connected to the FE Server, when an error occurs while receiving request from FE Server.
Notification shall be sent, when an error occurs while closing socket connection to the FE Server.
Refer the Javadocs
For interface:
Interface ClientConnectionObserver
For methods:
com.adventnet.nms.commonbe.GenericBEAPI.registerClientConnectionObserver
com.adventnet.nms.commonbe.GenericBEAPI.deregisterClientConnectionObserver
com.adventnet.nms.security.authentication.NmsAuthenticationAPI.notify

|