use of io.undertow.servlet.spec.HttpSessionImpl in project undertow by undertow-io.
the class SessionListenerBridge method doDestroy.
private void doDestroy(Session session) {
final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
applicationListeners.sessionDestroyed(httpSession);
//we make a defensive copy here, as there is no guarantee that the underlying session map
//is a concurrent map, and as a result a concurrent modification exception may be thrown
HashSet<String> names = new HashSet<>(session.getAttributeNames());
for (String attribute : names) {
session.removeAttribute(attribute);
}
}
use of io.undertow.servlet.spec.HttpSessionImpl in project undertow by undertow-io.
the class ServletFormAuthenticationMechanism method handleRedirectBack.
@Override
protected void handleRedirectBack(final HttpServerExchange exchange) {
final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
HttpServletResponse resp = (HttpServletResponse) servletRequestContext.getServletResponse();
HttpSessionImpl httpSession = servletRequestContext.getCurrentServletContext().getSession(exchange, false);
if (httpSession != null) {
Session session;
if (System.getSecurityManager() == null) {
session = httpSession.getSession();
} else {
session = AccessController.doPrivileged(new HttpSessionImpl.UnwrapSessionAction(httpSession));
}
String path = (String) session.getAttribute(SESSION_KEY);
if (path != null) {
try {
resp.sendRedirect(path);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
}
use of io.undertow.servlet.spec.HttpSessionImpl in project undertow by undertow-io.
the class SessionListenerBridge method attributeAdded.
@Override
public void attributeAdded(final Session session, final String name, final Object value) {
if (name.startsWith(IO_UNDERTOW)) {
return;
}
final HttpSessionImpl httpSession = SecurityActions.forSession(session, servletContext, false);
applicationListeners.httpSessionAttributeAdded(httpSession, name, value);
if (value instanceof HttpSessionBindingListener) {
((HttpSessionBindingListener) value).valueBound(new HttpSessionBindingEvent(httpSession, name, value));
}
}
use of io.undertow.servlet.spec.HttpSessionImpl in project undertow by undertow-io.
the class ServletFormAuthenticationMechanism method storeInitialLocation.
@Override
protected void storeInitialLocation(final HttpServerExchange exchange) {
if (!saveOriginalRequest) {
return;
}
final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
HttpSessionImpl httpSession = servletRequestContext.getCurrentServletContext().getSession(exchange, true);
Session session;
if (System.getSecurityManager() == null) {
session = httpSession.getSession();
} else {
session = AccessController.doPrivileged(new HttpSessionImpl.UnwrapSessionAction(httpSession));
}
SessionManager manager = session.getSessionManager();
if (seenSessionManagers.add(manager)) {
manager.registerSessionListener(LISTENER);
}
session.setAttribute(SESSION_KEY, RedirectBuilder.redirect(exchange, exchange.getRelativePath()));
SavedRequest.trySaveRequest(exchange);
}
use of io.undertow.servlet.spec.HttpSessionImpl in project undertow by undertow-io.
the class ServletSingleSignOnAuthenticationMechanism method getSession.
@Override
protected Session getSession(HttpServerExchange exchange) {
ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
final HttpSessionImpl session = servletRequestContext.getCurrentServletContext().getSession(exchange, true);
if (System.getSecurityManager() == null) {
return session.getSession();
} else {
return AccessController.doPrivileged(new HttpSessionImpl.UnwrapSessionAction(session));
}
}
Aggregations