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);
}
}
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);
}
use of com.iplanet.dpro.session.share.SessionRequest 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);
}
use of com.iplanet.dpro.session.share.SessionRequest in project OpenAM by OpenRock.
the class RemoteOperations method logout.
/**
* Performs a logout operation by making a remote request based
* on the Sessions service URL.
*
* @param session Session to logout.
*/
public void logout(Session session) throws SessionException {
if (debug.messageEnabled()) {
debug.message(MessageFormat.format("Remote logout {0}", session.getID().toString()));
}
SessionRequest sreq = new SessionRequest(SessionRequest.Logout, session.getID().toString(), false);
requests.sendRequestWithRetry(session.getSessionServiceURL(), sreq, session);
}
use of com.iplanet.dpro.session.share.SessionRequest in project OpenAM by OpenRock.
the class RemoteOperations method destroy.
/**
* Destroys the Session via the Session remote service URL.
*
* @param requester {@inheritDoc}
* @param session {@inheritDoc}
* @throws SessionException {@inheritDoc}
*/
public void destroy(Session requester, Session session) throws SessionException {
if (debug.messageEnabled()) {
debug.message(MessageFormat.format("Remote destroy {0}", session));
}
SessionRequest sreq = new SessionRequest(SessionRequest.DestroySession, requester.getID().toString(), false);
sreq.setDestroySessionID(session.getID().toString());
requests.sendRequestWithRetry(session.getSessionServiceURL(), sreq, session);
}
Aggregations