public class MyFormAuthenticator extends FormAuthenticator{ @Override public boolean authenticate(Request request,HttpServletResponse response,LoginConfig config){ boolean success = super.authenticate(request,response,config); if(success){ Session session = request.getSessionInternal(false); // Use the existing session session.put .... // the action which you want to do } return success; }
@Override public void invoke(Request request, Response response) throws IOException, ServletException { getNext().invoke(request, response); Session session = request.getSessionInternal(); HttpSession deltaSession = (HttpSession) session; for (Enumeration<String> names = deltaSession.getAttributeNames(); names.hasMoreElements(); ) { String name = names.nextElement(); deltaSession.setAttribute(name, deltaSession.getAttribute(name)); } }
protected HttpSession getSession(boolean create) { Session session = request.getSessionInternal(create); if (session == null) return null; return session.getSession(); } }
/** * unlock the session associated with this request */ @Override public void unlockSession() { Session sess = getSessionInternal(false); // Now unlock the session if (sess != null) { sess.unlockForeground(); } }
@Override public void logout() { Session session = request.getSessionInternal(false); if (session != null) { cleanSession(session); } }
public boolean keycloakRestoreRequest(Request request) { try { return restoreRequest(request, request.getSessionInternal()); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public void logout() { Session session = request.getSessionInternal(false); if (session != null) { cleanSession(session); } }
public boolean keycloakRestoreRequest(Request request) { try { return restoreRequest(request, request.getSessionInternal()); } catch (IOException e) { throw new RuntimeException(e); } }
protected GenericPrincipal checkLoggedIn(Request request, HttpServletResponse response) { if (request.getPrincipal() != null) { return (GenericPrincipal) request.getPrincipal(); } else if (request.getSessionInternal() != null && request.getSessionInternal().getPrincipal() != null) { return (GenericPrincipal) request.getSessionInternal().getPrincipal(); } return null; }
private boolean dealWithFacebookPrincipal(Request request, Response response, Principal principal) throws IOException { String userName = principal.getName(); request.getSessionInternal().setNote(Constants.SESS_USERNAME_NOTE, userName); request.getSessionInternal().setNote(Constants.SESS_PASSWORD_NOTE, ""); request.setUserPrincipal(principal); if (saveRestoreRequest) { this.restoreRequest(request, request.getSessionInternal()); } registerWithAuthenticatorBase(request, response, principal, userName); request.getSession().setAttribute("STATE", STATES.FINISH.name()); return true; }
protected Principal getPrincipal(HttpServletRequest httpRequest) { Request request = getRequest(httpRequest); Session session = request.getSessionInternal(false); return (session != null ? session.getPrincipal() : null); }
private boolean isUserAuthenticated(Request request) { Session sessionInternal = request.getSessionInternal(false); String authMethod = getContext().getLoginConfig().getAuthMethod(); return (authMethod != null && "FORM".equals(authMethod)) && sessionInternal != null && sessionInternal.getNote(Constants.FORM_PRINCIPAL_NOTE) != null; }
private boolean isUserAuthenticated(Request request) { Session sessionInternal = request.getSessionInternal(false); String authMethod = getContext().getLoginConfig().getAuthMethod(); return (authMethod != null && "FORM".equals(authMethod)) && sessionInternal != null && sessionInternal.getNote(Constants.FORM_PRINCIPAL_NOTE) != null; }
@Override protected boolean signout(HttpServletRequest req, HttpServletResponse resp) { // Direct Logout Session session = request.getSessionInternal(); session.removeNote(FederationAuthenticator.FEDERATION_NOTE); session.setPrincipal(null); return super.signout(req, resp); } }
@Override protected boolean signout(HttpServletRequest req, HttpServletResponse resp) { // Direct Logout Session session = request.getSessionInternal(); session.removeNote(FederationAuthenticator.FEDERATION_NOTE); session.setPrincipal(null); return super.signout(req, resp); } }
private boolean isUserAuthenticated(Request request) { Session sessionInternal = request.getSessionInternal(false); String authMethod = getContext().getLoginConfig().getAuthMethod(); return (authMethod != null && "FORM".equals(authMethod)) && sessionInternal != null && sessionInternal.getNote(Constants.FORM_PRINCIPAL_NOTE) != null; }
@Override protected boolean signoutCleanup(HttpServletRequest req, HttpServletResponse resp) { // Cleanup session internal Session session = request.getSessionInternal(); session.removeNote(FederationAuthenticator.FEDERATION_NOTE); session.setPrincipal(null); super.signoutCleanup(req, resp); request.clearCookies(); return true; }
@Override protected boolean signoutCleanup(HttpServletRequest req, HttpServletResponse resp) { // Cleanup session internal Session session = request.getSessionInternal(); session.removeNote(FederationAuthenticator.FEDERATION_NOTE); session.setPrincipal(null); super.signoutCleanup(req, resp); request.clearCookies(); return true; }
/* */ public String encodeRedirectURL(String url) /* */ { /* 1080 */ if (isEncodeable(toAbsolute(url))) { /* 1081 */ return toEncoded(url, this.request.getSessionInternal().getIdInternal()); /* */ } /* 1083 */ return url; /* */ } /* */
@Test public void invokeInvalidSession() throws IOException, ServletException { when(this.request.getSessionInternal(false)).thenReturn(this.session); when(this.session.isValid()).thenReturn(false); this.valve.invoke(this.request, this.response); verify(this.next).invoke(this.request, this.response); verifyZeroInteractions(this.store); }