use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.
the class JwtSessionMapperTest method throwsExceptionIfSignatureVerificationOfPlaintextJwtFails.
@Test(expectedExceptions = JwtRuntimeException.class)
public void throwsExceptionIfSignatureVerificationOfPlaintextJwtFails() {
// Given
SessionInfo inputSessionInfo = newExampleSessionInfo();
JwtSessionMapper jwtSessionMapper = new JwtSessionMapper(JwsAlgorithm.HS256, new SigningManager().newHmacSigningHandler("SHARED_SECRET".getBytes(Charset.forName("UTF-8"))), // Possibly a little kludgy but the code flow should be the same
new SigningManager().newHmacSigningHandler("INVALID_KEY".getBytes(Charset.forName("UTF-8"))), null);
// When
String plaintextJwt = jwtSessionMapper.asJwt(inputSessionInfo);
jwtSessionMapper.fromJwt(plaintextJwt);
// Then
// expect InvalidJwtException
}
use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.
the class JwtSessionMapperTest method canRoundtripSessionInfoAsSignedEncryptedJwtUsingDifferentAlgs.
@Test
public void canRoundtripSessionInfoAsSignedEncryptedJwtUsingDifferentAlgs() throws IOException {
// Given
SessionInfo inputSessionInfo = newExampleSessionInfo();
KeyPair keyPair = newKeyPair();
JwtSessionMapper jwtSessionMapper = new JwtSessionMapperBuilder().signedUsingHS256("SHARED_SECRET").encryptedUsingKeyPair(keyPair).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 Session method getValidSessions.
/**
* Returns all the valid sessions for a particular Session Service URL. If a
* user is not allowed to access the Sessions of the input Session Server,
* it will return null.
*
* @param svcurl Session Service URL.
* @exception SessionException
*/
private SearchResults getValidSessions(URL svcurl, String pattern) throws SessionException {
try {
int[] status = { 0 };
List<SessionInfo> infos = null;
boolean isLocal = false;
if (sessionService != null && sessionService.isLocalSessionService(svcurl)) {
infos = sessionService.getValidSessions(this, pattern, status);
isLocal = true;
} else {
SessionRequest sreq = new SessionRequest(SessionRequest.GetValidSessions, sessionID.toString(), false);
if (pattern != null) {
sreq.setPattern(pattern);
}
SessionResponse sres = requests.getSessionResponseWithRetry(svcurl, sreq, this);
infos = sres.getSessionInfo();
status[0] = sres.getStatus();
}
Map<String, Session> sessions = new HashMap<String, Session>();
Session session = null;
for (SessionInfo info : infos) {
SessionID sid = new SessionID(info.getSessionID());
session = new Session(sid, isLocal);
session.sessionServiceURL = svcurl;
session.update(info);
sessions.put(info.getSessionID(), session);
}
return new SearchResults(sessions.size(), sessions.keySet(), status[0], sessions);
} catch (Exception ex) {
sessionDebug.error("Session:getValidSession : ", ex);
throw new SessionException(SessionBundle.rbName, "getValidSessionsError", null);
}
}
use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.
the class SessionNotificationHandler method processNotification.
/**
* Process the notification.
*
* @param snot Session Notification object.
*/
private void processNotification(SessionNotification snot, boolean isLocal) {
SessionInfo info = snot.getSessionInfo();
sessionDebug.message("SESSION NOTIFICATION : " + info.toXMLString());
if (!info.getState().equals("valid")) {
if (isLocal) {
sessionCache.removeLocalSID(info);
} else {
sessionCache.removeRemoteSID(info);
}
return;
}
SessionID sid = new SessionID(info.getSessionID());
Session session = sessionCache.readSession(sid);
try {
if (session == null) {
// a new session is created
return;
}
session.update(info);
} catch (Exception e) {
sessionDebug.error("SessionNotificationHandler:processNotification : ", e);
sessionCache.removeSID(sid);
return;
}
SessionEvent evt = new SessionEvent(session, snot.getNotificationType(), snot.getNotificationTime());
SessionEvent.invokeListeners(evt);
}
use of com.iplanet.dpro.session.share.SessionInfo in project OpenAM by OpenRock.
the class MonitoredOperations method refresh.
/**
* {@inheritDoc}
*/
@Override
public SessionInfo refresh(Session session, boolean reset) throws SessionException {
final long start = System.nanoTime();
final SessionInfo response = sessionOperations.refresh(session, reset);
sessionMonitoringStore.storeRefreshTime(System.nanoTime() - start, monitorType);
return response;
}
Aggregations