Search in sources :

Example 21 with SessionException

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;
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) URL(java.net.URL) SessionEncodeURL(com.iplanet.dpro.session.share.SessionEncodeURL)

Example 22 with SessionException

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;
}
Also used : JwtRuntimeException(org.forgerock.json.jose.exceptions.JwtRuntimeException) SessionInfo(com.iplanet.dpro.session.share.SessionInfo) SessionException(com.iplanet.dpro.session.SessionException)

Example 23 with SessionException

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;
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) Map(java.util.Map) SessionID(com.iplanet.dpro.session.SessionID) Session(com.iplanet.dpro.session.Session) InternalSession(com.iplanet.dpro.session.service.InternalSession)

Example 24 with SessionException

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;
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) Map(java.util.Map) SessionID(com.iplanet.dpro.session.SessionID) Session(com.iplanet.dpro.session.Session) InternalSession(com.iplanet.dpro.session.service.InternalSession)

Example 25 with SessionException

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.");
    }
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) SSOException(com.iplanet.sso.SSOException) Principal(java.security.Principal)

Aggregations

SessionException (com.iplanet.dpro.session.SessionException)60 SessionID (com.iplanet.dpro.session.SessionID)22 Session (com.iplanet.dpro.session.Session)18 SSOException (com.iplanet.sso.SSOException)15 SessionResponse (com.iplanet.dpro.session.share.SessionResponse)9 SessionInfo (com.iplanet.dpro.session.share.SessionInfo)8 URL (java.net.URL)8 Map (java.util.Map)7 Test (org.testng.annotations.Test)7 InternalSession (com.iplanet.dpro.session.service.InternalSession)6 SessionRequest (com.iplanet.dpro.session.share.SessionRequest)6 IdRepoException (com.sun.identity.idm.IdRepoException)6 CoreTokenException (org.forgerock.openam.cts.exceptions.CoreTokenException)6 DelegationException (com.sun.identity.delegation.DelegationException)5 InterruptedIOException (java.io.InterruptedIOException)5 ConnectException (java.net.ConnectException)5 HashSet (java.util.HashSet)5 Set (java.util.Set)5 TokenRestriction (com.iplanet.dpro.session.TokenRestriction)4 SSOToken (com.iplanet.sso.SSOToken)4