use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.
the class RemoteSessionQuery method getAllSessions.
/**
* Generates a SessionRequest and uses this to query the remote server.
*
* @return Non null but possibly empty collection of Sessions. If the server is down, then this will
* also return no sessions.
*/
public Collection<SessionInfo> getAllSessions() {
List<SessionInfo> sessions = new LinkedList<SessionInfo>();
try {
URL svcurl = sessionServiceUrlService.getSessionServiceURL(serverId);
SSOToken adminToken = getAdminToken();
String sid = adminToken.getTokenID().toString();
SessionRequest sreq = new SessionRequest(SessionRequest.GetValidSessions, sid, false);
SessionResponse sres = getSessionResponse(svcurl, sreq);
List<SessionInfo> infoList = sres.getSessionInfo();
if (debug.messageEnabled()) {
debug.message(MessageFormat.format("Query returned {0} SessionInfos.", infoList.size()));
}
sessions.addAll(infoList);
} catch (SessionException e) {
debug.warning("Failed to fetch sessions from " + serverId, e);
}
return sessions;
}
use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.
the class StatelessOperations method logout.
@Override
public void logout(final Session session) throws SessionException {
if (session instanceof StatelessSession) {
SessionInfo sessionInfo = statelessSessionFactory.getSessionInfo(session.getID());
sessionLogging.logEvent(sessionInfo, SessionEvent.LOGOUT);
// Required since not possible to mock SessionAuditor in test case
if (sessionAuditor != null) {
sessionAuditor.auditActivity(sessionInfo, AM_SESSION_LOGGED_OUT);
}
}
sessionBlacklist.blacklist(session);
}
use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.
the class StatelessOperations method destroy.
@Override
public void destroy(final Session requester, final Session session) throws SessionException {
sessionService.checkPermissionToDestroySession(requester, session.getID());
if (session instanceof StatelessSession) {
SessionInfo sessionInfo = statelessSessionFactory.getSessionInfo(session.getID());
sessionLogging.logEvent(sessionInfo, SessionEvent.DESTROY);
// Required since not possible to mock SessionAuditor in test case
if (sessionAuditor != null) {
sessionAuditor.auditActivity(sessionInfo, AM_SESSION_DESTROYED);
}
}
sessionBlacklist.blacklist(session);
}
use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.
the class InternalSession method activate.
/**
* Changes the state of the session to ACTIVE after creation.
* @param userDN
* @param stateless Indicates that the log in session is a stateless session.
* @return <code> true </code> if the session is successfully activated
* after creation , <code>false</code> otherwise
*/
public boolean activate(String userDN, boolean stateless) {
if (userDN == null) {
return false;
}
// Exceeded max active sessions, but allow if the user is super-admin
if ((sessionService.hasExceededMaxSessions()) && (!userDN.equalsIgnoreCase(superUserDN))) {
sessionLogging.logSystemMessage(LOG_MSG_SESSION_MAX_LIMIT_REACHED, java.util.logging.Level.INFO);
return false;
}
SessionInfo sessionInfo = toSessionInfo();
// checking Session Quota Constraints
if ((serviceConfig.isSessionConstraintEnabled()) && !shouldIgnoreSessionQuotaChecking(userDN)) {
if (SessionConstraint.checkQuotaAndPerformAction(this)) {
if (debug.messageEnabled()) {
debug.message("Session Quota exhausted!");
}
sessionLogging.logEvent(sessionInfo, SessionEvent.QUOTA_EXHAUSTED);
return false;
}
}
setLatestAccessTime();
setState(VALID);
if (reschedulePossible && !stateless) {
reschedule();
}
sessionLogging.logEvent(sessionInfo, SessionEvent.SESSION_CREATION);
sessionAuditor.auditActivity(sessionInfo, AM_SESSION_CREATED);
sessionService.sendEvent(this, SessionEvent.SESSION_CREATION);
if (!stateless && (!isAppSession() || serviceConfig.isReturnAppSessionEnabled())) {
sessionService.incrementActiveSessions();
}
return true;
}
use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.
the class InternalSession method shouldDestroy.
/**
* Checks whether the sesion should be destroyed or not.
*/
boolean shouldDestroy() {
if (willExpireFlag == false) {
return false;
}
SessionInfo sessionInfo = toSessionInfo();
if (!isTimedOut()) {
if (isInvalid()) {
if (checkInvalidSessionDefaultIdleTime()) {
setState(DESTROYED);
sessionService.sendEvent(this, SessionEvent.DESTROY);
return true;
} else {
return false;
}
}
if (getTimeLeft() == 0) {
changeStateAndNotify(SessionEvent.MAX_TIMEOUT);
sessionAuditor.auditActivity(sessionInfo, AM_SESSION_MAX_TIMED_OUT);
return false;
}
if (getIdleTime() >= maxIdleTime * 60 && sessionState != INACTIVE) {
changeStateAndNotify(SessionEvent.IDLE_TIMEOUT);
sessionAuditor.auditActivity(sessionInfo, AM_SESSION_IDLE_TIMED_OUT);
return false;
}
return false;
} else {
// do something special for the timed out sessions
if (getTimeLeftBeforePurge() <= 0) {
// destroy the session
sessionLogging.logEvent(sessionInfo, SessionEvent.DESTROY);
sessionAuditor.auditActivity(sessionInfo, AM_SESSION_DESTROYED);
setState(DESTROYED);
sessionService.sendEvent(this, SessionEvent.DESTROY);
return true;
} else {
return false;
}
}
}
Aggregations