@Override public Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory) throws ServerAuthException { return ((Request)request).getAuthentication(); }
@Override public Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory) throws ServerAuthException { return ((Request)request).getAuthentication(); }
private OsgiAuth getOsgiAuth() { OsgiAuth auth; if (request.getAuthentication() instanceof OsgiAuth) { auth = (OsgiAuth) request.getAuthentication(); } else { auth = new OsgiAuth(); request.setAuthentication(auth); } return auth; }
try Authentication authentication = baseRequest.getAuthentication(); if (authentication==null || authentication==Authentication.NOT_CHECKED) authentication=authenticator==null?Authentication.UNAUTHENTICATED:authenticator.validateRequest(request, response, isAuthMandatory); Authentication auth=baseRequest.getAuthentication(); if (auth instanceof Authentication.User)
@Override public void prelogin(HttpSession session, Object httpRequest, String servletName) { if (session == null) // Cannot prelogin() without a session return; if (session.getAttribute(AuthenticationContext.class.getName()) instanceof Jetty8AuthenticationContext) return; Request request = (Request)httpRequest; Authentication authentication = request.getAuthentication(); UserIdentity.Scope scope = request.getUserIdentityScope(); Jetty8AuthenticationContext authorizationContext = new Jetty8AuthenticationContext(scope, authentication); session.setAttribute(AuthenticationContext.class.getName(), authorizationContext); }
/** * 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; }
Authentication authentication = request.getAuthentication(); UserIdentity.Scope scope = request.getUserIdentityScope();
@Override public Principal getPrincipal() { Authentication authentication = request.getAuthentication(); if (authentication instanceof Authentication.User) { return ((Authentication.User) authentication).getUserIdentity() .getUserPrincipal(); } return null; }
Authentication authentication = jettyRequest.getAuthentication(); User userAuth = (User) authentication; UserIdentity userIdentity = userAuth.getUserIdentity();
@Override public void handle(final String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { if (baseRequest.getAuthentication() == null || baseRequest.getAuthentication().equals( Authentication.UNAUTHENTICATED)) { response.sendError(Response.SC_UNAUTHORIZED, "Permission denied."); baseRequest.setHandled(true); return; } if (target.equals("/status")) { this.monitoringService.handle(request, response); } else if (target.equals("/tenant")) { this.tenantService.handle(request, response); } else if (target.equals("/admin")) { this.adminService.handle(request, response); } else { response.sendError(Response.SC_NOT_FOUND, target + " is not a service offered by OVX"); } baseRequest.setHandled(true); }
private void _login(Request req, Response resp, Credentials credentials) throws ServletException { HttpSession session = req.getSession(); if(session.getAttribute(SessionAuthentication.__J_AUTHENTICATED) == null) { synchronized (session) { if(session.getAttribute(SessionAuthentication.__J_AUTHENTICATED) == null) { req.login(credentials.getUsername(), credentials.getPassword()); session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, req.getAuthentication()); } } } }
protected Authentication register(Request request, KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal) { request.setAttribute(AdapterDeploymentContext.class.getName(), deploymentContext); Authentication authentication = request.getAuthentication(); if (!(authentication instanceof KeycloakAuthentication)) { UserIdentity userIdentity = createIdentity(principal); authentication = createAuthentication(userIdentity, request); request.setAuthentication(authentication); } return authentication; }
protected Authentication register(Request request, KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal) { request.setAttribute(AdapterDeploymentContext.class.getName(), deploymentContext); Authentication authentication = request.getAuthentication(); if (!(authentication instanceof KeycloakAuthentication)) { UserIdentity userIdentity = createIdentity(principal); authentication = createAuthentication(userIdentity, request); request.setAuthentication(authentication); } return authentication; }
Authentication authentication = jettyRequest.getAuthentication(); User userAuth = (User) authentication; UserIdentity userIdentity = userAuth.getUserIdentity();
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(); } } }
if (graniteContext instanceof HttpGraniteContext) { Request request = (Request)graniteContext.getRequest(); Authentication authentication = request.getAuthentication(); if (authentication instanceof Authentication.User) ((Authentication.User)authentication).logout();
public Principal login(Object credentials, String charset) throws SecurityServiceException { String[] decoded = decodeBase64Credentials(credentials, charset); ServletGraniteContext graniteContext = (ServletGraniteContext)GraniteContext.getCurrentInstance(); Principal principal = null; if (graniteContext instanceof HttpGraniteContext) { HttpServletRequest httpRequest = graniteContext.getRequest(); Request request = (Request)httpRequest; Authentication authentication = request.getAuthentication(); UserIdentity.Scope scope = request.getUserIdentityScope(); Jetty8AuthenticationContext authenticationContext = new Jetty8AuthenticationContext(scope, authentication); principal = authenticationContext.authenticate(decoded[0], decoded[1]); if (principal != null) graniteContext.getSession().setAttribute(AuthenticationContext.class.getName(), authenticationContext); } else { AuthenticationContext authenticationContext = (AuthenticationContext)graniteContext.getSession().getAttribute(AuthenticationContext.class.getName()); if (authenticationContext != null) principal = authenticationContext.authenticate(decoded[0], decoded[1]); else return null; } if (principal == null) throw SecurityServiceException.newInvalidCredentialsException("Wrong username or password"); graniteContext.setPrincipal(principal); endLogin(credentials, charset); return principal; }
public Principal login(Object credentials, String charset) throws SecurityServiceException { String[] decoded = decodeBase64Credentials(credentials, charset); ServletGraniteContext graniteContext = (ServletGraniteContext)GraniteContext.getCurrentInstance(); Principal principal = null; if (graniteContext instanceof HttpGraniteContext) { HttpServletRequest httpRequest = graniteContext.getRequest(); Request request = (Request)httpRequest; Authentication authentication = request.getAuthentication(); UserIdentity.Scope scope = request.getUserIdentityScope(); Jetty9AuthenticationContext authenticationContext = new Jetty9AuthenticationContext(scope, authentication); principal = authenticationContext.authenticate(decoded[0], decoded[1]); if (principal != null) graniteContext.getSession().setAttribute(AuthenticationContext.class.getName(), authenticationContext); } else { AuthenticationContext authenticationContext = (AuthenticationContext)graniteContext.getSession().getAttribute(AuthenticationContext.class.getName()); if (authenticationContext != null) principal = authenticationContext.authenticate(decoded[0], decoded[1]); else return null; } if (principal == null) throw SecurityServiceException.newInvalidCredentialsException("Wrong username or password"); graniteContext.setPrincipal(principal); endLogin(credentials, charset); return principal; }
@Override public void log(Request request, Response response) { try { if (!enabled) { return; } StorageService s = storage.getService(); if (s == null) { return; } if (ignorePathMap != null && ignorePathMap.getMatch(request.getRequestURI()) != null) return; String output = "{ " + "\"host\": \"" + host + "\", " + "\"@timestamp\": \"" + InsightUtils.formatDate(request.getTimeStamp()) + "\", " + "\"remote\": \"" + request.getRemoteAddr() + "\", " + "\"user\": \"" + (request.getAuthentication() instanceof Authentication.User ? ((Authentication.User)request.getAuthentication()).getUserIdentity().getUserPrincipal().getName() : "") + "\", " + "\"method\": \"" + request.getMethod() + "\", " + "\"uri\": \"" + request.getUri().toString() + "\", " + "\"protocol\": \"" + request.getProtocol() + "\", " + "\"status\": \"" + response.getStatus() + "\", " + "\"responseLength\": \"" + response.getContentCount() + "\" " + " }"; s.store(type, request.getTimeStamp(), output); } catch (Exception e) { LOG.warn(e); } }
Authentication authentication = request.getAuthentication(); String remoteUser; if (authentication instanceof Authentication.User) {