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