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));
}
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;
}
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);
}
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();
}
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;
}
Aggregations