Search in sources :

Example 11 with SessionInfo

use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.

the class JwtSessionMapperTest method canRoundtripSessionInfoAsSignedPlaintextJwt.

@Test
public void canRoundtripSessionInfoAsSignedPlaintextJwt() throws IOException {
    // Given
    SessionInfo inputSessionInfo = newExampleSessionInfo();
    JwtSessionMapper jwtSessionMapper = new JwtSessionMapperBuilder().signedUsingHS256("SHARED_SECRET").build();
    // When
    String jwtString = jwtSessionMapper.asJwt(inputSessionInfo);
    SessionInfo outputSessionInfo = jwtSessionMapper.fromJwt(jwtString);
    // Then
    assertEquals(inputSessionInfo, outputSessionInfo);
}
Also used : SessionInfo(com.iplanet.dpro.session.share.SessionInfo) Test(org.testng.annotations.Test)

Example 12 with SessionInfo

use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.

the class SessionQueryManagerTest method shouldReturnAllSessionsReturnedByQueryTypes.

@Test
public void shouldReturnAllSessionsReturnedByQueryTypes() {
    // Given
    String badger = "Badger";
    String weasel = "Weasel";
    SessionInfo one = mock(SessionInfo.class);
    SessionInfo two = mock(SessionInfo.class);
    SessionQueryType typeOne = mock(SessionQueryType.class);
    given(typeOne.getAllSessions()).willReturn(Arrays.asList(new SessionInfo[] { one }));
    SessionQueryType typeTwo = mock(SessionQueryType.class);
    given(typeTwo.getAllSessions()).willReturn(Arrays.asList(new SessionInfo[] { two }));
    SessionQueryFactory mockFactory = mock(SessionQueryFactory.class);
    given(mockFactory.getSessionQueryType(badger)).willReturn(typeOne);
    given(mockFactory.getSessionQueryType(weasel)).willReturn(typeTwo);
    SessionQueryManager manager = new SessionQueryManager(mockFactory);
    // When
    Collection<SessionInfo> sessions = manager.getAllSessions(Arrays.asList(new String[] { badger, weasel }));
    // Then
    assertEquals(2, sessions.size());
    assertTrue(sessions.contains(one));
    assertTrue(sessions.contains(two));
}
Also used : SessionInfo(com.iplanet.dpro.session.share.SessionInfo) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 13 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 14 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 15 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)

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