use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class InternalSessionCache method put.
/**
* Stores the InternalSession in the cache. This will also store any associated references
* which have been stored on the Session:
*
* - Session Handle
* - Restricted Tokens
*
* Synchronized: makes updates to multiple data structures atomic.
*
* @param session Non null InternalSession to store.
*/
public synchronized void put(InternalSession session) {
Reject.ifNull(session);
cache.put(session.getID(), session);
// Session Handle
if (session.getSessionHandle() != null) {
handle.put(session.getSessionHandle(), session);
}
// Restricted Sessions
for (SessionID restrictedID : session.getRestrictedTokens()) {
restricted.put(restrictedID, session);
}
}
use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.
the class InternalSessionFactory method createSession.
/**
* Creates InternalSession which is always coupled with Http session This is
* only used in session failover mode to ensure that every internal session
* is associated with Http session used as fail-over store
*
* @param domain authentication domain passed to newInternalSession
*/
private InternalSession createSession(String domain) {
DataInputStream in = null;
try {
String query = "?" + GetHttpSession.OP + "=" + GetHttpSession.CREATE_OP;
if (domain != null) {
query += "&" + GetHttpSession.DOMAIN + "=" + URLEncDec.encode(domain);
}
String routingCookie = null;
URL url = serverConfig.createLocalServerURL("GetHttpSession" + query);
HttpURLConnection conn = httpConnectionFactory.createSessionAwareConnection(url, null, routingCookie);
in = new DataInputStream(conn.getInputStream());
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
return null;
}
SessionID sid = new SessionID(in.readUTF());
return cache.getBySessionID(sid);
} catch (Exception ex) {
sessionDebug.error("Failed to retrieve new session", ex);
} finally {
IOUtils.closeIfNotNull(in);
}
return null;
}
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);
}
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);
}
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);
}
Aggregations