use of org.apache.catalina.Session in project Payara by payara.
the class Response method toEncoded.
/**
* Return the specified URL with the specified session identifier
* suitably encoded.
*
* @param url URL to be encoded with the session id
* @param sessionId Session id to be included in the encoded URL
* @param sessionVersion Session version to be included in the encoded URL
*/
private String toEncoded(String url, String sessionId, String sessionVersion) {
if (url == null || sessionId == null)
return url;
String path = url;
String query = "";
String anchor = "";
int question = url.indexOf('?');
if (question >= 0) {
path = url.substring(0, question);
query = url.substring(question);
}
int pound = path.indexOf('#');
if (pound >= 0) {
anchor = path.substring(pound);
path = path.substring(0, pound);
}
StringBuilder sb = new StringBuilder(path);
if (sb.length() > 0) {
// jsessionid can't be first.
StandardContext ctx = (StandardContext) getContext();
String sessionParamName = ctx != null ? ctx.getSessionParameterName() : Globals.SESSION_PARAMETER_NAME;
sb.append(";").append(sessionParamName).append("=");
sb.append(sessionId);
if (ctx != null && ctx.getJvmRoute() != null) {
sb.append('.').append(ctx.getJvmRoute());
}
// START SJSAS 6337561
String jrouteId = request.getHeader(Constants.PROXY_JROUTE);
if (jrouteId != null) {
sb.append(":");
sb.append(jrouteId);
}
// END SJSAS 6337561
final Session session = request.getSessionInternal(false);
if (session != null) {
String replicaLocation = (String) session.getNote(Globals.JREPLICA_SESSION_NOTE);
if (replicaLocation != null) {
sb.append(Globals.JREPLICA_PARAMETER);
sb.append(replicaLocation);
}
}
if (sessionVersion != null) {
sb.append(Globals.SESSION_VERSION_PARAMETER);
sb.append(sessionVersion);
}
}
sb.append(anchor);
sb.append(query);
return sb.toString();
}
use of org.apache.catalina.Session in project Payara by payara.
the class PESessionLocker method getSession.
private Session getSession(ServletRequest request) {
javax.servlet.http.HttpServletRequest httpReq = (javax.servlet.http.HttpServletRequest) request;
javax.servlet.http.HttpSession httpSess = httpReq.getSession(false);
if (httpSess == null) {
return null;
}
String id = httpSess.getId();
Manager mgr = _context.getManager();
Session sess = null;
try {
sess = mgr.findSession(id);
} catch (java.io.IOException ex) {
}
return sess;
}
use of org.apache.catalina.Session in project Payara by payara.
the class ReplicationManagerBase method removeSessionFromManagerCache.
public void removeSessionFromManagerCache(Session session) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("in " + this.getClass().getName() + ">>removeSessionFromManagerCache:session = " + session);
}
if (session == null) {
return;
}
Session removed = null;
removed = sessions.remove(session.getIdInternal());
if (removed != null && _logger.isLoggable(Level.FINE)) {
_logger.fine("Remove from manager cache id=" + session.getId());
}
}
use of org.apache.catalina.Session in project Payara by payara.
the class ReplicationStore method loadFromBackingStore.
private Session loadFromBackingStore(String id, String version) throws IOException, ClassNotFoundException, BackingStoreException {
SimpleMetadata metaData = getSimpleMetadataBackingStore().load(id, version);
if (_logger.isLoggable(Level.FINEST)) {
_logger.finest("ReplicationStore>>loadFromBackingStore:id=" + id + ", metaData=" + metaData);
}
Session session = getSession(metaData);
if (_logger.isLoggable(Level.FINEST)) {
_logger.finest("ReplicationStore->Session is " + session);
}
return session;
}
use of org.apache.catalina.Session in project keycloak by keycloak.
the class CatalinaSessionTokenStore method saveAccountInfo.
@Override
public void saveAccountInfo(OidcKeycloakAccount account) {
RefreshableKeycloakSecurityContext securityContext = (RefreshableKeycloakSecurityContext) account.getKeycloakSecurityContext();
Set<String> roles = account.getRoles();
GenericPrincipal principal = principalFactory.createPrincipal(request.getContext().getRealm(), account.getPrincipal(), roles);
SerializableKeycloakAccount sAccount = new SerializableKeycloakAccount(roles, account.getPrincipal(), securityContext);
Session session = request.getSessionInternal(true);
session.setPrincipal(principal);
session.setAuthType("KEYCLOAK");
session.getSession().setAttribute(SerializableKeycloakAccount.class.getName(), sAccount);
session.getSession().setAttribute(KeycloakSecurityContext.class.getName(), account.getKeycloakSecurityContext());
String username = securityContext.getToken().getSubject();
log.fine("userSessionManagement.login: " + username);
this.sessionManagement.login(session);
}
Aggregations