Search in sources :

Example 56 with SessionException

use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.

the class SMProfileModelImpl method invalidateSessions.

public List<String> invalidateSessions(List<String> list, String pattern) throws AMConsoleException {
    List<String> failList = Collections.emptyList();
    if ((list != null) && !list.isEmpty()) {
        Session session = getCurrentSession();
        Map<String, Session> validSessions = getValidSessions(session, pattern);
        list.retainAll(validSessions.keySet());
        if (!list.isEmpty()) {
            String currentSessionHandler = null;
            try {
                currentSessionHandler = session.getProperty(SESSION_HANDLE_PROP);
            } catch (SessionException se) {
                throw new AMConsoleException(getErrorString(se));
            }
            String[] params = new String[2];
            params[0] = serverName;
            String curSessionId = null;
            failList = new ArrayList<String>(list.size());
            for (String sessionId : list) {
                Session s = validSessions.get(sessionId);
                params[1] = sessionId;
                boolean isCurrentSession = false;
                try {
                    isCurrentSession = currentSessionHandler.equals(s.getProperty(SESSION_HANDLE_PROP));
                } catch (SessionException se) {
                    logEvent("SESSION_EXCEPTION_INVALIDATE_SESSIONS", params);
                    throw new AMConsoleException(getErrorString(se));
                }
                if (isCurrentSession) {
                    curSessionId = sessionId;
                    validSession = false;
                } else {
                    try {
                        logEvent("ATTEMPT_INVALIDATE_SESSIONS", params);
                        session.destroySession(s);
                        logEvent("SUCCEED_INVALIDATE_SESSIONS", params);
                    } catch (SessionException se) {
                        String[] paramsEx = { serverName, sessionId, getErrorString(se) };
                        logEvent("SESSION_EXCEPTION_INVALIDATE_SESSIONS", paramsEx);
                        try {
                            failList.add(s.getProperty(USER_ID));
                        } catch (SessionException e) {
                            debug.error("SMProfileModelImpl.invalidateSessions", e);
                        }
                        debug.error("SMProfileModelImpl.invalidateSessions", se);
                    }
                }
            }
            if (!validSession) {
                params[1] = curSessionId;
                logEvent("ATTEMPT_INVALIDATE_SESSIONS", params);
                try {
                    session.destroySession(session);
                    logEvent("SUCCEED_INVALIDATE_SESSIONS", params);
                } catch (SessionException se) {
                    String[] paramsEx = { serverName, curSessionId, getErrorString(se) };
                    logEvent("SESSION_EXCEPTION_INVALIDATE_SESSIONS", paramsEx);
                }
            }
        }
    }
    return failList;
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) Session(com.iplanet.dpro.session.Session)

Example 57 with SessionException

use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.

the class SSOProviderImpl method logout.

@Override
public void logout(final SSOToken token) throws SSOException {
    try {
        Session session = sessionCache.getSession(new SessionID(token.getTokenID().toString()));
        session.logout();
    } catch (SessionException e) {
        if (debug.messageEnabled()) {
            debug.message("Logout: ", e);
        }
        throw new SSOException(e);
    }
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) SSOException(com.iplanet.sso.SSOException) SessionID(com.iplanet.dpro.session.SessionID) Session(com.iplanet.dpro.session.Session)

Example 58 with SessionException

use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.

the class AuthD method initAuthSession.

private Session initAuthSession() throws SSOException, SessionException {
    final Session authSession = getSessionService().getAuthenticationSession(defaultOrg, null);
    if (authSession == null) {
        debug.error("AuthD failed to get auth session");
        throw new SessionException(BUNDLE_NAME, "gettingSessionFailed", null);
    }
    String clientID = authSession.getClientID();
    authSession.setProperty("Principal", clientID);
    authSession.setProperty("Organization", defaultOrg);
    authSession.setProperty("Host", authSession.getID().getSessionServer());
    if (LDAPUtils.isDN(clientID)) {
        String id = "id=" + rdnValueFromDn(clientID) + ",ou=user," + ServiceManager.getBaseDN();
        authSession.setProperty(Constants.UNIVERSAL_IDENTIFIER, id);
    }
    return authSession;
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) Session(com.iplanet.dpro.session.Session) HttpSession(javax.servlet.http.HttpSession) InternalSession(com.iplanet.dpro.session.service.InternalSession)

Example 59 with SessionException

use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.

the class StatelessOperationsTest method shouldNotBlacklistSessionOnDestroyIfNotAllowed.

@Test(expectedExceptions = SessionException.class, expectedExceptionsMessageRegExp = "test")
public void shouldNotBlacklistSessionOnDestroyIfNotAllowed() throws Exception {
    // Given
    Session requester = mock(Session.class);
    SessionException ex = new SessionException("test");
    willThrow(ex).given(mockSessionService).checkPermissionToDestroySession(requester, sid);
    // When
    try {
        statelessOperations.destroy(requester, mockSession);
    } finally {
        // Then
        verifyZeroInteractions(mockSessionBlacklist);
    }
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) Session(com.iplanet.dpro.session.Session) StatelessSession(org.forgerock.openam.sso.providers.stateless.StatelessSession) Test(org.testng.annotations.Test)

Example 60 with SessionException

use of com.iplanet.dpro.session.SessionException in project OpenAM by OpenRock.

the class CTSSessionBlacklistTest method shouldPropagateSessionExceptions.

@Test(expectedExceptions = SessionException.class)
public void shouldPropagateSessionExceptions() throws Exception {
    // Given
    given(mockSession.getBlacklistExpiryTime(anyLong())).willThrow(new SessionException("test"));
    // When
    testBlacklist.blacklist(mockSession);
// Then - exception
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) Test(org.testng.annotations.Test)

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