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

[1943 byte] By [Kunnathura] at [2007-10-3 1:32:31]
# 1

u cant restrict the user to log in resource from session listiner because u get only httpSessionEvent object which gives u only current created session object reference.... U can use session listiner for counting number of active session in a context and use 1 common filter for every resource to check number of active session if the it is more then 10 then send custom response to them.

frank26a at 2007-7-14 18:30:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...