Search in sources :

Example 16 with SessionException

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

the class RemoteOperations method setProperty.

/**
     * Perform a remote setProperty on the Session using the remote Service URL.
     *
     * {@inheritDoc}
     */
public void setProperty(Session session, String name, String value) throws SessionException {
    if (debug.messageEnabled()) {
        debug.message(MessageFormat.format("Remote setProperty {0} {1}={2}", session, name, value));
    }
    SessionID sessionID = session.getID();
    SessionRequest sreq = new SessionRequest(SessionRequest.SetProperty, sessionID.toString(), false);
    sreq.setPropertyName(name);
    sreq.setPropertyValue(value);
    if (SystemProperties.isServerMode() && InternalSession.isProtectedProperty(name)) {
        try {
            SSOToken admSSOToken = SessionUtils.getAdminToken();
            sreq.setRequester(RestrictedTokenContext.marshal(admSSOToken));
        } catch (SSOException e) {
            throw new SessionException(e);
        } catch (Exception e) {
            throw new SessionException(e);
        }
        if (debug.messageEnabled()) {
            debug.message("Session.setProperty: " + "added admSSOToken in sreq to set " + "externalProtectedProperty in remote server");
        }
    }
    requests.sendRequestWithRetry(session.getSessionServiceURL(), sreq, session);
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SessionException(com.iplanet.dpro.session.SessionException) SSOException(com.iplanet.sso.SSOException) SessionID(com.iplanet.dpro.session.SessionID) SessionRequest(com.iplanet.dpro.session.share.SessionRequest) SSOException(com.iplanet.sso.SSOException) SessionException(com.iplanet.dpro.session.SessionException)

Example 17 with SessionException

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

the class SessionCommand method destroySession.

private void destroySession(Session session, SessionData sData) throws CLIException {
    try {
        Session sess = sData.session;
        String[] params = { sData.userId };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_SESSION_DESTROY", params);
        session.destroySession(sess);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_SESSION_DESTROY", params);
    } catch (SessionException se) {
        String[] params = { sData.userId, se.getMessage() };
        debugError("SessionCommand.destroySession", se);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_SESSION_DESTROY", params);
    }
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) Session(com.iplanet.dpro.session.Session)

Example 18 with SessionException

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

the class SessionCommand method displaySessions.

private List displaySessions(SSOToken ssoToken) throws CLIException {
    String origHost = getStringOptionValue(ARGUMENT_HOST_NAME);
    String host = trimTrailingSlash(origHost);
    StringTokenizer st = new StringTokenizer(host, ":");
    if (st.countTokens() != 3) {
        Object[] params = { origHost };
        throw new CLIException(MessageFormat.format(getResourceString("session-invalid-host-name"), params), ExitCodes.INVALID_OPTION_VALUE);
    }
    curSessionID = new SessionID(ssoToken.getTokenID().toString());
    String filter = getStringOptionValue(IArgument.FILTER);
    if ((filter == null) || (filter.trim().length() == 0)) {
        filter = "*";
    }
    try {
        curSession = sessionCache.getSession(curSessionID);
        return getSessionList(host, filter);
    } catch (SessionException se) {
        throw new CLIException(se, ExitCodes.SESSION_BASED_LOGIN_FAILED);
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) SessionException(com.iplanet.dpro.session.SessionException) SessionID(com.iplanet.dpro.session.SessionID)

Example 19 with SessionException

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

the class SMSessionCache method retainSessionsWithUserID.

/**
     * Returns a map of user ID to session object for session that contains
     * user ID.
     */
private Map retainSessionsWithUserID(Collection sessions, SMProfileModelImpl modelImpl) {
    Map results = new HashMap(sessions.size() * 2);
    for (Iterator iter = sessions.iterator(); iter.hasNext(); ) {
        Session sess = (Session) iter.next();
        try {
            String userId = sess.getProperty(SMProfileModelImpl.USER_ID);
            if (userId != null) {
                String id = sess.getID().toString();
                SMSessionData sData = new SMSessionData();
                sData.setUserId(userId);
                sData.setId(id);
                sData.setTimeRemain(sess.getTimeLeft() / 60);
                sData.setMaxSessionTime(sess.getMaxSessionTime());
                sData.setIdleTime(sess.getIdleTime() / 60);
                sData.setMaxIdleTime(sess.getMaxIdleTime());
                results.put(userId + id, sData);
            }
        } catch (SessionException se) {
            debug.warning("SMSessionCache.retainSessionsWithUserID", se);
        }
    }
    return results;
}
Also used : HashMap(java.util.HashMap) Iterator(java.util.Iterator) SessionException(com.iplanet.dpro.session.SessionException) Map(java.util.Map) HashMap(java.util.HashMap) Session(com.iplanet.dpro.session.Session)

Example 20 with SessionException

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

the class SMProfileModelImpl method initSessionsList.

/**
     * Initializes sessions list.
     *
     * @param pattern user id pattern to search for.
     * @throws AMConsoleException if unable to initialized the session list.
     */
private void initSessionsList(String pattern) throws AMConsoleException {
    pattern = pattern.toLowerCase();
    String[] params = { serverName, pattern };
    logEvent("ATTEMPT_GET_CURRENT_SESSIONS", params);
    try {
        Session session = sessionCache.getSession(new SessionID(getUserSSOToken().getTokenID().toString()));
        SearchResults result = session.getValidSessions(serverName, pattern);
        Map<String, Session> sessions = (Map<String, Session>) result.getResultAttributes();
        String errorMessage = AMAdminUtils.getSearchResultWarningMessage(result, this);
        smSessionCache = new SMSessionCache(sessions.values(), errorMessage, this);
        logEvent("SUCCEED_GET_CURRENT_SESSIONS", params);
    } catch (SessionException se) {
        String strError = getErrorString(se);
        String[] paramsEx = { serverName, pattern, strError };
        logEvent("SESSION_EXCEPTION_GET_CURRENT_SESSIONS", paramsEx);
        throw new AMConsoleException(strError);
    }
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) SearchResults(com.sun.identity.common.SearchResults) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) SessionID(com.iplanet.dpro.session.SessionID) HashMap(java.util.HashMap) Map(java.util.Map) Session(com.iplanet.dpro.session.Session)

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