use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.
the class JwtSessionMapperTest method canRoundtripSessionInfoAsPlaintextJson.
@Test
public void canRoundtripSessionInfoAsPlaintextJson() throws IOException {
// Given
SessionInfo inputSessionInfo = newExampleSessionInfo();
JwtSessionMapper jwtSessionMapper = new JwtSessionMapperBuilder().build();
// When
String jsonString = jwtSessionMapper.asJson(inputSessionInfo);
SessionInfo outputSessionInfo = jwtSessionMapper.fromJson(jsonString);
// Then
assertEquals(inputSessionInfo, outputSessionInfo);
}
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 SessionPollerSender method run.
public void run() {
try {
SessionRequest sreq = new SessionRequest(SessionRequest.GetSession, sid.toString(), false);
SessionResponse sres = pllSender.sendPLLRequest(session.getSessionServiceURL(), sreq);
if (sres.getException() != null) {
sessionCache.removeSID(sid);
return;
}
List<SessionInfo> infos = sres.getSessionInfo();
if (infos.size() == 1) {
info = infos.get(0);
}
} catch (Exception ex) {
sessionCache.removeSID(sid);
if (debug.messageEnabled())
debug.message("Could not connect to the session server" + ex.getMessage());
}
if (info != null) {
if (debug.messageEnabled()) {
debug.message("Updating" + info.toXMLString());
}
try {
if (info.getState().equals("invalid") || info.getState().equals("destroyed")) {
sessionCache.removeSID(sid);
} else {
long oldMaxCachingTime = session.getMaxCachingTime();
long oldMaxIdleTime = session.getMaxIdleTime();
long oldMaxSessionTime = session.getMaxSessionTime();
session.update(info);
if ((!session.isScheduled()) || (oldMaxCachingTime > session.getMaxCachingTime()) || (oldMaxIdleTime > session.getMaxIdleTime()) || (oldMaxSessionTime > session.getMaxSessionTime())) {
session.scheduleToTimerPool();
}
}
} catch (SessionException se) {
sessionCache.removeSID(sid);
debug.error("Exception encountered while update in polling", se);
}
} else {
sessionCache.removeSID(sid);
}
session.setIsPolling(false);
}
use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.
the class CTSOperationsTest method shouldReadTokenFromRemoteWhenCTSFails.
@Test
public void shouldReadTokenFromRemoteWhenCTSFails() throws CoreTokenException, SessionException {
// Given
given(mockCTS.read(anyString())).willThrow(new ReadFailedException("id", new IOException()));
SessionInfo mockSessionInfo = mock(SessionInfo.class);
given(mockRemote.refresh(mockSession, false)).willReturn(mockSessionInfo);
// When
SessionInfo result = ctsOperations.refresh(mockSession, false);
// Then
assertThat(result).isEqualTo(mockSessionInfo);
}
use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.
the class LocalOperationsTest method shouldReturnSessionInfoOnRefresh.
@Test
public void shouldReturnSessionInfoOnRefresh() throws SessionException {
// Given
SessionInfo mockSessionInfo = mock(SessionInfo.class);
given(mockService.getSessionInfo(any(SessionID.class), anyBoolean())).willReturn(mockSessionInfo);
// When
SessionInfo result = local.refresh(mock(Session.class), true);
// Then
assertThat(result).isEqualTo(mockSessionInfo);
}
Aggregations