/** * Extract the user authentication * @param request The request to extract from * @return The string to log for authenticated user. */ protected String getAuthentication(Request request) { Authentication authentication = request.getAuthentication(); if (authentication instanceof Authentication.User) return ((Authentication.User)authentication).getUserIdentity().getUserPrincipal().getName(); // TODO extract the user name if it is Authentication.Deferred and return as '?username' return null; }
@Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException { baseRequest.setHandled(true); try { Authentication authentication = digestAuthenticator.validateRequest(request, response, true); if (authentication instanceof Authentication.User) { response.setContentType("text/plain"); Authentication.User user = (Authentication.User) authentication; response.getWriter().println(user.getAuthMethod()); } else if (authentication instanceof Authentication.ResponseSent) { Authentication.ResponseSent responseSent = (Authentication.ResponseSent) authentication; } } catch (ServerAuthException e) { e.printStackTrace(); } } }
Authentication authentication = request.getAuthentication(); if (authentication instanceof Authentication.User) ((Authentication.User)authentication).logout();
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(ServletRequest) */ @Override public Authentication authenticate(ServletRequest request) { try { Authentication authentication = _authenticator.validateRequest(request,__deferredResponse,true); if (authentication!=null && (authentication instanceof Authentication.User) && !(authentication instanceof Authentication.ResponseSent)) { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); if (identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(ServletRequest) */ @Override public Authentication authenticate(ServletRequest request) { try { Authentication authentication = _authenticator.validateRequest(request,__deferredResponse,true); if (authentication!=null && (authentication instanceof Authentication.User) && !(authentication instanceof Authentication.ResponseSent)) { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); if (identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(ServletRequest) */ public Authentication authenticate(ServletRequest request) { try { Authentication authentication = _authenticator.validateRequest(request,__deferredResponse,true); if (authentication!=null && (authentication instanceof Authentication.User) && !(authentication instanceof Authentication.ResponseSent)) { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); if (identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(ServletRequest) */ @Override public Authentication authenticate(ServletRequest request) { try { Authentication authentication = _authenticator.validateRequest(request,__deferredResponse,true); if (authentication!=null && (authentication instanceof Authentication.User) && !(authentication instanceof Authentication.ResponseSent)) { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); if (identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(ServletRequest) */ public Authentication authenticate(ServletRequest request) { try { Authentication authentication = _authenticator.validateRequest(request,__deferredResponse,true); if (authentication!=null && (authentication instanceof Authentication.User) && !(authentication instanceof Authentication.ResponseSent)) { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); if (identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(ServletRequest) */ public Authentication authenticate(ServletRequest request) { try { Authentication authentication = _authenticator.validateRequest(request,__deferredResponse,true); if (authentication!=null && (authentication instanceof Authentication.User) && !(authentication instanceof Authentication.ResponseSent)) { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); if (identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } } catch (ServerAuthException e) { LOG.debug(e); } return this; }
public void logout() throws SecurityServiceException { ServletGraniteContext graniteContext = (ServletGraniteContext)GraniteContext.getCurrentInstance(); if (graniteContext instanceof HttpGraniteContext) { Request request = (Request)graniteContext.getRequest(); Authentication authentication = request.getAuthentication(); if (authentication instanceof Authentication.User) ((Authentication.User)authentication).logout(); if (request.getSession(false) != null) { endLogout(); request.getSession(false).invalidate(); } } else { HttpSession session = graniteContext.getSession(); if (session != null) { AuthenticationContext authenticationContext = (AuthenticationContext)session.getAttribute(AuthenticationContext.class.getName()); authenticationContext.logout(); session.removeAttribute(AuthenticationContext.class.getName()); endLogout(); session.invalidate(); } } }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ @Override public Authentication authenticate(ServletRequest request, ServletResponse response) { try { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); Authentication authentication = _authenticator.validateRequest(request,response,true); if (authentication instanceof Authentication.User && identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ @Override public Authentication authenticate(ServletRequest request, ServletResponse response) { try { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); Authentication authentication = _authenticator.validateRequest(request,response,true); if (authentication instanceof Authentication.User && identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ @Override public Authentication authenticate(ServletRequest request, ServletResponse response) { try { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); Authentication authentication = _authenticator.validateRequest(request,response,true); if (authentication instanceof Authentication.User && identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ public Authentication authenticate(ServletRequest request, ServletResponse response) { try { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); Authentication authentication = _authenticator.validateRequest(request,response,true); if (authentication instanceof Authentication.User && identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ @Override public Authentication authenticate(ServletRequest request, ServletResponse response) { try { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); Authentication authentication = _authenticator.validateRequest(request,response,true); if (authentication instanceof Authentication.User && identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ @Override public Authentication authenticate(ServletRequest request, ServletResponse response) { try { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); Authentication authentication = _authenticator.validateRequest(request,response,true); if (authentication instanceof Authentication.User && identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ public Authentication authenticate(ServletRequest request, ServletResponse response) { try { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); Authentication authentication = _authenticator.validateRequest(request,response,true); if (authentication instanceof Authentication.User && identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ public Authentication authenticate(ServletRequest request, ServletResponse response) { try { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); Authentication authentication = _authenticator.validateRequest(request,response,true); if (authentication instanceof Authentication.User && identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } catch (ServerAuthException e) { LOG.debug(e); } return this; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#authenticate(javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ public Authentication authenticate(ServletRequest request, ServletResponse response) { try { LoginService login_service= _authenticator.getLoginService(); IdentityService identity_service=login_service.getIdentityService(); Authentication authentication = _authenticator.validateRequest(request,response,true); if (authentication instanceof Authentication.User && identity_service!=null) _previousAssociation=identity_service.associate(((Authentication.User)authentication).getUserIdentity()); return authentication; } catch (ServerAuthException e) { LOG.debug(e); } return this; }
public void logout(Authentication.User user) { LOG.debug("logout {}",user); LoginService login_service=getLoginService(); if (login_service!=null) { login_service.logout(user.getUserIdentity()); } IdentityService identity_service=getIdentityService(); if (identity_service!=null) { // TODO recover previous from threadlocal (or similar) Object previous=null; identity_service.disassociate(previous); } }