Search in sources :

Example 6 with SessionInfo

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;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SessionInfo(com.iplanet.dpro.session.share.SessionInfo) SessionException(com.iplanet.dpro.session.SessionException) SessionResponse(com.iplanet.dpro.session.share.SessionResponse) LinkedList(java.util.LinkedList) URL(java.net.URL) SessionRequest(com.iplanet.dpro.session.share.SessionRequest)

Example 7 with SessionInfo

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);
}
Also used : StatelessSession(org.forgerock.openam.sso.providers.stateless.StatelessSession) SessionInfo(com.iplanet.dpro.session.share.SessionInfo)

Example 8 with SessionInfo

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);
}
Also used : StatelessSession(org.forgerock.openam.sso.providers.stateless.StatelessSession) SessionInfo(com.iplanet.dpro.session.share.SessionInfo)

Example 9 with SessionInfo

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;
}
Also used : SessionInfo(com.iplanet.dpro.session.share.SessionInfo)

Example 10 with SessionInfo

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;
        }
    }
}
Also used : SessionInfo(com.iplanet.dpro.session.share.SessionInfo)

Aggregations

SessionInfo (com.iplanet.dpro.session.share.SessionInfo)42 Test (org.testng.annotations.Test)18 SessionException (com.iplanet.dpro.session.SessionException)8 SessionID (com.iplanet.dpro.session.SessionID)6 SessionResponse (com.iplanet.dpro.session.share.SessionResponse)5 SessionRequest (com.iplanet.dpro.session.share.SessionRequest)4 InternalSession (com.iplanet.dpro.session.service.InternalSession)3 Session (com.iplanet.dpro.session.Session)2 TokenRestriction (com.iplanet.dpro.session.TokenRestriction)2 SSOException (com.iplanet.sso.SSOException)2 URL (java.net.URL)2 KeyPair (java.security.KeyPair)2 HashMap (java.util.HashMap)2 SigningManager (org.forgerock.json.jose.jws.SigningManager)2 StatelessSession (org.forgerock.openam.sso.providers.stateless.StatelessSession)2 ThreadPoolException (com.iplanet.am.util.ThreadPoolException)1 SessionTimedOutException (com.iplanet.dpro.session.SessionTimedOutException)1 SessionOperations (com.iplanet.dpro.session.operations.SessionOperations)1 Action (com.iplanet.services.naming.ServiceListeners.Action)1 SSOToken (com.iplanet.sso.SSOToken)1