protected Session getSession(final HttpServerExchange exchange) { return Sessions.getOrCreateSession(exchange); }
/** * Gets the active session, returning null if one is not present. * @param exchange The exchange * @return The session */ public static Session getSession(final HttpServerExchange exchange) { return getSession(exchange, false); }
@Override protected String changeHttpSessionId(boolean create) { if (create) { Session session = Sessions.getOrCreateSession(exchange); return session.getId(); } else { Session session = Sessions.getSession(exchange); return session != null ? session.getId() : null; } }
@Override protected String changeHttpSessionId(boolean create) { if (create) { Session session = Sessions.getOrCreateSession(exchange); return session.getId(); } else { Session session = Sessions.getSession(exchange); return session != null ? session.getId() : null; } }
/** * Gets the active session, creating a new one if one does not exist * @param exchange The exchange * @return The session */ public static Session getOrCreateSession(final HttpServerExchange exchange) { return getSession(exchange, true); }
protected void storeInitialLocation(final HttpServerExchange exchange) { Session session = Sessions.getOrCreateSession(exchange); session.setAttribute(LOCATION_ATTRIBUTE, RedirectBuilder.redirect(exchange, exchange.getRelativePath())); }
protected void handleRedirectBack(final HttpServerExchange exchange) { final Session session = Sessions.getSession(exchange); if (session != null) { final String location = (String) session.removeAttribute(LOCATION_ATTRIBUTE); if(location != null) { exchange.addDefaultResponseListener(new DefaultResponseListener() { @Override public boolean handleDefaultResponse(final HttpServerExchange exchange) { exchange.getResponseHeaders().put(Headers.LOCATION, location); exchange.setStatusCode(StatusCodes.FOUND); exchange.endExchange(); return true; } }); } } }
protected Session getSession(final HttpServerExchange exchange) { return Sessions.getOrCreateSession(exchange); }
/** * Gets the active session, returning null if one is not present. * @param exchange The exchange * @return The session */ public static Session getSession(final HttpServerExchange exchange) { return getSession(exchange, false); }
protected Session getSession(final HttpServerExchange exchange) { return Sessions.getOrCreateSession(exchange); }
/** * Gets the active session, creating a new one if one does not exist * @param exchange The exchange * @return The session */ public static Session getOrCreateSession(final HttpServerExchange exchange) { return getSession(exchange, true); }
protected void storeInitialLocation(final HttpServerExchange exchange) { Session session = Sessions.getOrCreateSession(exchange); session.setAttribute(LOCATION_ATTRIBUTE, RedirectBuilder.redirect(exchange, exchange.getRelativePath())); }
/** * Gets the active session, returning null if one is not present. * @param exchange The exchange * @return The session */ public static Session getSession(final HttpServerExchange exchange) { return getSession(exchange, false); }
@Override public void saveAccountInfo(OidcKeycloakAccount account) { Session session = Sessions.getOrCreateSession(exchange); session.setAttribute(KeycloakUndertowAccount.class.getName(), account); session.setAttribute(KeycloakSecurityContext.class.getName(), account.getKeycloakSecurityContext()); sessionManagement.login(session.getSessionManager()); }
/** * Gets the active session, creating a new one if one does not exist * @param exchange The exchange * @return The session */ public static Session getOrCreateSession(final HttpServerExchange exchange) { return getSession(exchange, true); }
@Override public void saveAccountInfo(OidcKeycloakAccount account) { Session session = Sessions.getOrCreateSession(exchange); session.setAttribute(KeycloakUndertowAccount.class.getName(), account); session.setAttribute(KeycloakSecurityContext.class.getName(), account.getKeycloakSecurityContext()); sessionManagement.login(session.getSessionManager()); }
@Override public void logout() { Session session = Sessions.getSession(exchange); if (session == null) return; KeycloakUndertowAccount account = (KeycloakUndertowAccount)session.getAttribute(KeycloakUndertowAccount.class.getName()); if (account == null) return; session.removeAttribute(KeycloakUndertowAccount.class.getName()); session.removeAttribute(KeycloakSecurityContext.class.getName()); }
protected void storeInitialLocation(final HttpServerExchange exchange) { Session session = Sessions.getOrCreateSession(exchange); session.setAttribute(LOCATION_ATTRIBUTE, RedirectBuilder.redirect(exchange, exchange.getRelativePath())); }
@Override public void logout() { Session session = Sessions.getSession(exchange); if (session == null) return; KeycloakUndertowAccount account = (KeycloakUndertowAccount)session.getAttribute(KeycloakUndertowAccount.class.getName()); if (account == null) return; session.removeAttribute(KeycloakUndertowAccount.class.getName()); session.removeAttribute(KeycloakSecurityContext.class.getName()); }
protected void handleRedirectBack(final HttpServerExchange exchange) { final Session session = Sessions.getSession(exchange); if (session != null) { final String location = (String) session.removeAttribute(LOCATION_ATTRIBUTE); if(location != null) { exchange.addDefaultResponseListener(new DefaultResponseListener() { @Override public boolean handleDefaultResponse(final HttpServerExchange exchange) { exchange.getResponseHeaders().put(Headers.LOCATION, location); exchange.setStatusCode(StatusCodes.FOUND); exchange.endExchange(); return true; } }); } } }