use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.
the class AuthClientUtils method getCookieURL.
public static String getCookieURL(SessionID sessionID) {
String cookieURL = null;
try {
URL sessionServerURL = sessionServiceURLService.getSessionServiceURL(sessionID);
cookieURL = sessionServerURL.getProtocol() + "://" + sessionServerURL.getHost() + ":" + Integer.toString(sessionServerURL.getPort()) + serviceURI;
} catch (SessionException se) {
if (utilDebug.messageEnabled()) {
utilDebug.message("LoginServlet error in Session : ", se);
}
}
return cookieURL;
}
use of com.iplanet.dpro.session.SessionException 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.SessionException in project OpenAM by OpenRock.
the class DestroyNextExpiringAction method action.
@Override
public boolean action(InternalSession is, Map<String, Long> sessions) {
String nextExpiringSessionID = null;
long smallestExpTime = Long.MAX_VALUE;
for (Map.Entry<String, Long> entry : sessions.entrySet()) {
String sid = entry.getKey();
long expirationTime = entry.getValue();
if (expirationTime < smallestExpTime) {
smallestExpTime = expirationTime;
nextExpiringSessionID = sid;
}
}
if (nextExpiringSessionID != null) {
SessionID sessID = new SessionID(nextExpiringSessionID);
try {
Session s = sessionCache.getSession(sessID);
s.destroySession(s);
} catch (SessionException e) {
if (debug.messageEnabled()) {
debug.message("Failed to destroy the next " + "expiring session.", e);
}
// in this case
return true;
}
}
return false;
}
use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.
the class DestroyOldestAction method action.
@Override
public boolean action(InternalSession is, Map<String, Long> sessions) {
long smallestExpTime = Long.MAX_VALUE;
String oldestSessionID = null;
for (Map.Entry<String, Long> entry : sessions.entrySet()) {
try {
Session session = sessionCache.getSession(new SessionID(entry.getKey()));
session.refresh(false);
long expTime = session.getTimeLeft();
if (expTime < smallestExpTime) {
smallestExpTime = expTime;
oldestSessionID = entry.getKey();
}
} catch (SessionException ssoe) {
if (debug.warningEnabled()) {
debug.warning("Failed to create SSOToken", ssoe);
}
// in this case
return true;
}
}
if (oldestSessionID != null) {
SessionID sessID = new SessionID(oldestSessionID);
try {
Session s = sessionCache.getSession(sessID);
s.destroySession(s);
} catch (SessionException e) {
if (debug.messageEnabled()) {
debug.message("Failed to destroy the next expiring session.", e);
}
// in this case
return true;
}
}
return false;
}
use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.
the class StatelessSSOProvider method createSSOToken.
private SSOToken createSSOToken(SessionID sessionId) throws SSOException {
StatelessSession session;
try {
session = statelessSessionFactory.generate(sessionId);
} catch (SessionException e) {
throw new SSOException(e);
}
final StatelessSSOToken ssoToken = new StatelessSSOToken(session);
if (isValidToken(ssoToken, false)) {
return ssoToken;
} else {
Principal principal = null;
try {
principal = ssoToken.getPrincipal();
} catch (SSOException e) {
debug.warning("Could not obtain token principal for invalid token: " + e.getMessage(), e);
}
throw new SSOException("Token for principal " + (principal != null ? principal.getName() : null) + " invalid.");
}
}
Aggregations