How to restrict no of users to log in resource using session filter
Hi all,
I am using NTLMAuthenticatication to restrict the resource to only windows network users.
I am using one sessionListener class to know how many sessions are created.
My sample listener class looks like this:
--
public class SessionListen implements HttpSessionListener {
private int sessionCount;
public SessionListen() {
this.sessionCount = 0;
}
public void sessionCreated(HttpSessionEvent se) {
HttpSession session = se.getSession();
session.setMaxInactiveInterval(120);
synchronized (this) {
// to set how many active session id in UserManager class
UserManager.getUMInstance().submissionCount ++;
sessionCount++;
}
String id = session.getId();
Date now = new Date();
String message = new StringBuffer("New Session created on ").append(
now.toString()).append("\nID: ").append(id).append("\n")
.append("There are now ").append("" + sessionCount).append(
" live sessions in the application.").toString();
// System.out.println(message);
}
public void sessionDestroyed(HttpSessionEvent se) {
HttpSession session = se.getSession();
String id = session.getId();
synchronized (this) {
--sessionCount;
--UserManager.getUMInstance().submissionCount;
}
String message = new StringBuffer("Session destroyed"
+ "\nValue of destroyed session ID is").append("" + id).append(
"\n").append("There are now ").append("" + sessionCount)
.append(" live sessions in the application.").toString();
// System.out.println(message);
}
}
-
My Question is that I need to restrict only 10 windows users has to access th resource.
Is there any solution? If so, anyone can give sample code for this to solve this issue.
Please do favour with me
Thanks and Regards,
Sreekanth

