Search in sources :

Example 16 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 17 with SessionInfo

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

the class StatelessSessionFactory method getSessionInfo.

/**
     * Will create the SessionInfo from the JWT contained within the
     * SessionID.
     *
     * Side Effect: Will cache the generated JWT and SessionInfo combination.
     *
     * @param sessionID Maybe null SessionID.
     *
     * @return SessionInfo Non null SessionInfo which corresponds to the SessionID.
     *
     * @throws SessionException If there was any problem with getting the SessionInfo
     * from the JWT within with SessionID
     */
public SessionInfo getSessionInfo(SessionID sessionID) throws SessionException {
    String jwt = getJWTFromSessionID(sessionID, true);
    if (cache.contains(jwt)) {
        return cache.getSessionInfo(jwt);
    }
    SessionInfo sessionInfo;
    try {
        sessionInfo = getJwtSessionMapper().fromJwt(jwt);
    } catch (JwtRuntimeException e) {
        throw new SessionException(e);
    }
    cache.cache(sessionInfo, jwt);
    return sessionInfo;
}
Also used : JwtRuntimeException(org.forgerock.json.jose.exceptions.JwtRuntimeException) SessionInfo(com.iplanet.dpro.session.share.SessionInfo) SessionException(com.iplanet.dpro.session.SessionException)

Example 18 with SessionInfo

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

the class StatelessSessionFactory method generate.

/**
     * @param internalSession Non null Internal Session to convert to a StatelessSession.
     * @return Non null StatelessSession.
     * @throws SessionException If anything unexpected failed.
     */
public StatelessSession generate(InternalSession internalSession) throws SessionException {
    SessionInfo sessionInfo = internalSession.toSessionInfo(false);
    sessionInfo.getProperties().put(org.forgerock.openam.session.SessionConstants.SESSION_HANDLE_PROP, internalSession.getSessionHandle());
    return generate(sessionInfo);
}
Also used : SessionInfo(com.iplanet.dpro.session.share.SessionInfo)

Example 19 with SessionInfo

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

the class StatelessJWTCacheTest method shouldRespondToServiceListenersNotification.

@Test
public void shouldRespondToServiceListenersNotification() {
    given(mockConfig.getJWTCacheSize()).willReturn(1);
    cache = new StatelessJWTCache(mockConfig, mockListeners);
    SessionInfo mockSessionInfo = mock(SessionInfo.class);
    cache.cache(mockSessionInfo, "badger");
    // When
    for (Action action : actions) {
        action.performUpdate();
    }
    // Then
    assertThat(cache.contains(mockSessionInfo)).isFalse();
}
Also used : Action(com.iplanet.services.naming.ServiceListeners.Action) SessionInfo(com.iplanet.dpro.session.share.SessionInfo) Test(org.testng.annotations.Test)

Example 20 with SessionInfo

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

the class JwtSessionMapperTest method newExampleSessionInfo.

private SessionInfo newExampleSessionInfo() {
    SessionInfo sessionInfo = new SessionInfo();
    sessionInfo.setSessionID("AQIC5wM2LY4SfczvH7ej82FoQ5tx4Ixjpd4sBrP5aYHXvf0.*AAJTSQACMDMAAlNLABQtNDE0OTU2OTM4NjY2Mzk3Mjg3MgACUzEAAjAx*");
    sessionInfo.setSessionType("user");
    sessionInfo.setClientID("id=amadmin,ou=user,dc=openam,dc=forgerock,dc=org");
    sessionInfo.setClientDomain("dc=openam,dc=forgerock,dc=org");
    sessionInfo.setMaxTime(120);
    sessionInfo.setMaxIdle(30);
    sessionInfo.setMaxCaching(3);
    sessionInfo.setTimeIdle(11);
    sessionInfo.setTimeLeft(7189);
    //        sessionInfo.expiry="9223372036854775807";
    sessionInfo.setState("valid");
    sessionInfo.getProperties().put("CharSet", "UTF-8");
    sessionInfo.getProperties().put("UserId", "amadmin");
    sessionInfo.getProperties().put("FullLoginURL", "/openam/UI/Login?realm=%2F");
    sessionInfo.getProperties().put("successURL", "/openam/console");
    sessionInfo.getProperties().put("cookieSupport", "true");
    sessionInfo.getProperties().put("AuthLevel", "0");
    sessionInfo.getProperties().put("SessionHandle", "shandle:AQIC5wM2LY4Sfcz2r0heYum8JSnH9eXYDQ0lx9-s9ZE7ma8.*AAJTSQACMDMAAlMxAAIwMQACU0sAFC00MTQ5NTY5Mzg2NjYzOTcyODcy*");
    sessionInfo.getProperties().put("UserToken", "amadmin");
    sessionInfo.getProperties().put("loginURL", "/openam/UI/Login");
    sessionInfo.getProperties().put("Principals", "amadmin");
    sessionInfo.getProperties().put("Service", "ldapService");
    sessionInfo.getProperties().put("sun.am.UniversalIdentifier", "id=amadmin,ou=user,dc=openam,dc=forgerock,dc=org");
    sessionInfo.getProperties().put("amlbcookie", "01");
    sessionInfo.getProperties().put("Organization", "dc=openam,dc=forgerock,dc=org");
    sessionInfo.getProperties().put("Locale", "en_GB");
    sessionInfo.getProperties().put("HostName", "127.0.0.1");
    sessionInfo.getProperties().put("AuthType", "DataStore");
    sessionInfo.getProperties().put("Host", "127.0.0.1");
    sessionInfo.getProperties().put("UserProfile", "Required");
    sessionInfo.getProperties().put("AMCtxId", "13452a66dc3c54bc01");
    sessionInfo.getProperties().put("clientType", "genericHTML");
    sessionInfo.getProperties().put("authInstant", "2015-01-14T12:00:44Z");
    sessionInfo.getProperties().put("Principal", "id=amadmin,ou=user,dc=openam,dc=forgerock,dc=org");
    return sessionInfo;
}
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