Search in sources :

Example 36 with SessionID

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

the class CTSOperations method logout.

/**
     * Performs a remote logout of the session.
     *
     * @param session Non null Session to use for the delete.
     * @throws SessionException If we somehow passed a local session into this function
     */
public void logout(Session session) throws SessionException {
    // See OPENAM-4543.  The check for a local session should be removed if it proves to be a performance
    // bottleneck.  As Peter points out, because we "know" this is a remote session, we will force checkSessionLocal
    // to look in three hashtables, then do a couple of string compares... all for peace of mind.
    //
    SessionID sessionID = session.getID();
    if (sessionService.checkSessionLocal(sessionID)) {
        throw new SessionException("CTSOperations received a local session (only remote sessions expected)");
    }
    remote.logout(session);
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) SessionID(com.iplanet.dpro.session.SessionID)

Example 37 with SessionID

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

the class RemoteOperations method refresh.

/**
     *
     * @param session The Session to update.
     * @param reset If true, then update the last modified timestamp of the Session.
     * @return
     * @throws SessionException
     */
public SessionInfo refresh(Session session, boolean reset) throws SessionException {
    SessionID sessionID = session.getID();
    if (debug.messageEnabled()) {
        debug.message(MessageFormat.format("Remote fetch SessionInfo for {0}\n" + "Reset: {1}", sessionID, reset));
    }
    SessionRequest sreq = new SessionRequest(SessionRequest.GetSession, sessionID.toString(), reset);
    SessionResponse sres = requests.sendRequestWithRetry(session.getSessionServiceURL(), sreq, session);
    if (sres.getException() != null) {
        throw new SessionException(SessionBundle.rbName, INVALID_SESSION_STATE, null);
    }
    List<SessionInfo> infos = sres.getSessionInfo();
    if (infos.size() != 1) {
        throw new SessionException(SessionBundle.rbName, UNEXPECTED_SESSION, null);
    }
    return infos.get(0);
}
Also used : SessionException(com.iplanet.dpro.session.SessionException) SessionInfo(com.iplanet.dpro.session.share.SessionInfo) SessionResponse(com.iplanet.dpro.session.share.SessionResponse) SessionID(com.iplanet.dpro.session.SessionID) SessionRequest(com.iplanet.dpro.session.share.SessionRequest)

Example 38 with SessionID

use of com.iplanet.dpro.session.SessionID 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 39 with SessionID

use of com.iplanet.dpro.session.SessionID 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 40 with SessionID

use of com.iplanet.dpro.session.SessionID 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

SessionID (com.iplanet.dpro.session.SessionID)105 Test (org.testng.annotations.Test)44 SessionException (com.iplanet.dpro.session.SessionException)31 SSOToken (com.iplanet.sso.SSOToken)23 InternalSession (com.iplanet.dpro.session.service.InternalSession)18 SSOException (com.iplanet.sso.SSOException)18 AuthContextLocalWrapper (org.forgerock.openam.core.rest.authn.core.wrappers.AuthContextLocalWrapper)17 HttpServletResponse (javax.servlet.http.HttpServletResponse)16 HttpServletRequest (javax.servlet.http.HttpServletRequest)15 Session (com.iplanet.dpro.session.Session)14 URL (java.net.URL)9 Map (java.util.Map)9 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)8 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 SMSException (com.sun.identity.sm.SMSException)4 Token (org.forgerock.openam.cts.api.tokens.Token)4 SessionIDExtensions (com.iplanet.dpro.session.SessionIDExtensions)3 TokenRestriction (com.iplanet.dpro.session.TokenRestriction)3 SessionInfo (com.iplanet.dpro.session.share.SessionInfo)3