Search in sources :

Example 6 with SessionRequest

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

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

the class SessionPLLSender method sendPLLRequest.

/**
     * Returns a Session Response object based on the XML document received from
     * remote Session Server. This is in response to a request that we send to
     * the session server.
     *
     * @param svcurl The URL of the Session Service.
     * @param sreq The Session Request XML document.
     * @return a Vector of responses from the remote server
     * @exception com.iplanet.dpro.session.SessionException if there was an error in sending the XML
     *            document or if the response has multiple components.
     */
public SessionResponse sendPLLRequest(URL svcurl, SessionRequest sreq) throws SessionException {
    try {
        String cookies = sessionCookies.getCookieName() + "=" + sreq.getSessionID();
        if (!SystemProperties.isServerMode()) {
            SessionID sessionID = new SessionID(sreq.getSessionID());
            cookies = cookies + ";" + sessionCookies.getLBCookie(sessionID);
        }
        final Request req = new Request(sreq.toXMLString());
        final RequestSet set = new RequestSet(SESSION_SERVICE);
        set.addRequest(req);
        final Vector responses = PLLClient.send(svcurl, cookies, set);
        if (responses.size() != 1) {
            throw new SessionException(SessionBundle.rbName, "unexpectedResponse", null);
        }
        final Response res = (Response) responses.elementAt(0);
        return SessionResponse.parseXML(res.getContent());
    } catch (Exception e) {
        throw new SessionException(e);
    }
}
Also used : Response(com.iplanet.services.comm.share.Response) SessionResponse(com.iplanet.dpro.session.share.SessionResponse) RequestSet(com.iplanet.services.comm.share.RequestSet) SessionRequest(com.iplanet.dpro.session.share.SessionRequest) Request(com.iplanet.services.comm.share.Request) SessionException(com.iplanet.dpro.session.SessionException) SessionID(com.iplanet.dpro.session.SessionID) Vector(java.util.Vector) SessionException(com.iplanet.dpro.session.SessionException)

Example 8 with SessionRequest

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

the class SessionPollerSender method run.

public void run() {
    try {
        SessionRequest sreq = new SessionRequest(SessionRequest.GetSession, sid.toString(), false);
        SessionResponse sres = pllSender.sendPLLRequest(session.getSessionServiceURL(), sreq);
        if (sres.getException() != null) {
            sessionCache.removeSID(sid);
            return;
        }
        List<SessionInfo> infos = sres.getSessionInfo();
        if (infos.size() == 1) {
            info = infos.get(0);
        }
    } catch (Exception ex) {
        sessionCache.removeSID(sid);
        if (debug.messageEnabled())
            debug.message("Could not connect to the session server" + ex.getMessage());
    }
    if (info != null) {
        if (debug.messageEnabled()) {
            debug.message("Updating" + info.toXMLString());
        }
        try {
            if (info.getState().equals("invalid") || info.getState().equals("destroyed")) {
                sessionCache.removeSID(sid);
            } else {
                long oldMaxCachingTime = session.getMaxCachingTime();
                long oldMaxIdleTime = session.getMaxIdleTime();
                long oldMaxSessionTime = session.getMaxSessionTime();
                session.update(info);
                if ((!session.isScheduled()) || (oldMaxCachingTime > session.getMaxCachingTime()) || (oldMaxIdleTime > session.getMaxIdleTime()) || (oldMaxSessionTime > session.getMaxSessionTime())) {
                    session.scheduleToTimerPool();
                }
            }
        } catch (SessionException se) {
            sessionCache.removeSID(sid);
            debug.error("Exception encountered while update in polling", se);
        }
    } else {
        sessionCache.removeSID(sid);
    }
    session.setIsPolling(false);
}
Also used : SessionInfo(com.iplanet.dpro.session.share.SessionInfo) SessionException(com.iplanet.dpro.session.SessionException) SessionResponse(com.iplanet.dpro.session.share.SessionResponse) SessionRequest(com.iplanet.dpro.session.share.SessionRequest) SessionException(com.iplanet.dpro.session.SessionException)

Example 9 with SessionRequest

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

the class SessionCount method getSessionsFromPeerServers.

/*
     * Get user sessions from session repository
     */
private static Map getSessionsFromPeerServers(String uuid) {
    Map sessions = getSessionsFromLocalServer(uuid);
    String localServerID = serverConfig.getLocalServerID();
    Set serverIDs = null;
    try {
        serverIDs = WebtopNaming.getSiteNodes(localServerID);
    } catch (Exception e) {
        debug.error("Failed to get the serverIDs from " + "WebtopNaming.", e);
        return sessions;
    }
    for (Iterator m = serverIDs.iterator(); m.hasNext(); ) {
        String serverID = (String) m.next();
        if (serverID.equals(localServerID)) {
            continue;
        }
        try {
            URL svcurl = SESSION_SERVICE_URL_SERVICE.getSessionServiceURL(serverID);
            SessionRequest sreq = new SessionRequest(SessionRequest.GetSessionCount, getAdminToken().getTokenID().toString(), false);
            sreq.setUUID(uuid);
            SessionResponse sres = getSessionResponse(svcurl, sreq);
            sessions.putAll(sres.getSessionsForGivenUUID());
        } catch (SessionException se) {
            if (debug.messageEnabled()) {
                debug.message("SessionConstraint: " + "peer AM server is down...");
            }
        }
    }
    return sessions;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Iterator(java.util.Iterator) SessionException(com.iplanet.dpro.session.SessionException) SessionResponse(com.iplanet.dpro.session.share.SessionResponse) HashMap(java.util.HashMap) Map(java.util.Map) SessionException(com.iplanet.dpro.session.SessionException) URL(java.net.URL) SessionRequest(com.iplanet.dpro.session.share.SessionRequest)

Example 10 with SessionRequest

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

the class Session method getValidSessions.

/**
     * Returns all the valid sessions for a particular Session Service URL. If a
     * user is not allowed to access the Sessions of the input Session Server,
     * it will return null.
     *
     * @param svcurl Session Service URL.
     * @exception SessionException
     */
private SearchResults getValidSessions(URL svcurl, String pattern) throws SessionException {
    try {
        int[] status = { 0 };
        List<SessionInfo> infos = null;
        boolean isLocal = false;
        if (sessionService != null && sessionService.isLocalSessionService(svcurl)) {
            infos = sessionService.getValidSessions(this, pattern, status);
            isLocal = true;
        } else {
            SessionRequest sreq = new SessionRequest(SessionRequest.GetValidSessions, sessionID.toString(), false);
            if (pattern != null) {
                sreq.setPattern(pattern);
            }
            SessionResponse sres = requests.getSessionResponseWithRetry(svcurl, sreq, this);
            infos = sres.getSessionInfo();
            status[0] = sres.getStatus();
        }
        Map<String, Session> sessions = new HashMap<String, Session>();
        Session session = null;
        for (SessionInfo info : infos) {
            SessionID sid = new SessionID(info.getSessionID());
            session = new Session(sid, isLocal);
            session.sessionServiceURL = svcurl;
            session.update(info);
            sessions.put(info.getSessionID(), session);
        }
        return new SearchResults(sessions.size(), sessions.keySet(), status[0], sessions);
    } catch (Exception ex) {
        sessionDebug.error("Session:getValidSession : ", ex);
        throw new SessionException(SessionBundle.rbName, "getValidSessionsError", null);
    }
}
Also used : HashMap(java.util.HashMap) SessionInfo(com.iplanet.dpro.session.share.SessionInfo) SearchResults(com.sun.identity.common.SearchResults) SessionRequest(com.iplanet.dpro.session.share.SessionRequest) ThreadPoolException(com.iplanet.am.util.ThreadPoolException) SSOException(com.iplanet.sso.SSOException) SessionResponse(com.iplanet.dpro.session.share.SessionResponse)

Aggregations

SessionRequest (com.iplanet.dpro.session.share.SessionRequest)11 SessionException (com.iplanet.dpro.session.SessionException)7 SessionResponse (com.iplanet.dpro.session.share.SessionResponse)7 SessionInfo (com.iplanet.dpro.session.share.SessionInfo)4 SessionID (com.iplanet.dpro.session.SessionID)3 SSOException (com.iplanet.sso.SSOException)3 SSOToken (com.iplanet.sso.SSOToken)3 ThreadPoolException (com.iplanet.am.util.ThreadPoolException)2 Response (com.iplanet.services.comm.share.Response)2 URL (java.net.URL)2 HashMap (java.util.HashMap)2 Request (com.iplanet.services.comm.share.Request)1 RequestSet (com.iplanet.services.comm.share.RequestSet)1 SSOTokenManager (com.iplanet.sso.SSOTokenManager)1 SearchResults (com.sun.identity.common.SearchResults)1 RestrictedTokenAction (com.sun.identity.session.util.RestrictedTokenAction)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1