private Result getUserLoginResult(HttpServletRequest request, HttpServletResponse response, OAuthMessage message, Consumer consumer, Principal user) { // if a user is provided, they must exist and be able to login if (user != null && !authenticationController.canLogin(user, request)) { LOG.info("Access denied because user:'{}' cannot login", user.getName()); sendError(response, HttpServletResponse.SC_UNAUTHORIZED, message); return new Result.Failure(new OAuthProblem.PermissionDenied(user.getName())); } LOG.info("Authenticated app '{}' as user '{}' successfully", consumer.getKey(), user == null ? "null" : user.getName()); return new Result.Success(user); }
return new Result.Success(new DefaultMessage("Successful addon oauth authentication"), principalOpt.orElse(null));
return new Result.Success(new DefaultMessage("Successful addon oauth authentication"), principalOpt.orElse(null));
private void impersonateSubject(FilterChain filterChain, HttpServletRequest request, HttpServletResponse response, UserProfile userProfile) throws IOException, ServletException { // Products use the username to set the authentication context. SimplePrincipal principal = new SimplePrincipal(userProfile.getUsername()); final Authenticator.Result authenticationResult = new Authenticator.Result.Success(createMessage("Successful three-legged-auth"), principal); authenticationListener.authenticationSuccess(authenticationResult, request, response); filterChain.doFilter(request, response); }
@Override public Result success(String message, Principal principal, Jwt authenticatedJwt) { return new Result.Success(createMessage(message), principal); }
private void actAsAddonUser(FilterChain filterChain, HttpServletRequest request, HttpServletResponse response, String addonKey) throws IOException, ServletException { try { final Principal principal = getPrincipal(addonKey); final Authenticator.Result authenticationResult = new Authenticator.Result.Success(createMessage("Successful two-legged-auth"), principal); authenticationListener.authenticationSuccess(authenticationResult, request, response); filterChain.doFilter(request, response); } catch (InvalidSubjectException e) { createAndSendFailure(e, response, HttpServletResponse.SC_UNAUTHORIZED, badCredentialsMessage); } }
private void actAsAddonUser(FilterChain filterChain, HttpServletRequest request, HttpServletResponse response, String addonKey) throws IOException, ServletException { try { final Principal principal = getPrincipal(addonKey); final Authenticator.Result authenticationResult = new Authenticator.Result.Success(createMessage("Successful two-legged-auth"), principal); authenticationListener.authenticationSuccess(authenticationResult, request, response); filterChain.doFilter(request, response); } catch (InvalidSubjectException e) { createAndSendFailure(e, response, HttpServletResponse.SC_UNAUTHORIZED, i18nResolver.getText(BAD_CREDENTIALS_KEY)); } }
private void impersonateSubject(FilterChain filterChain, HttpServletRequest request, HttpServletResponse response, UserProfile userProfile) throws IOException, ServletException { // Products use the username to set the authentication context. SimplePrincipal principal = new SimplePrincipal(userProfile.getUsername()); final Authenticator.Result authenticationResult = new Authenticator.Result.Success(createMessage("Successful three-legged-auth"), principal); authenticationListener.authenticationSuccess(authenticationResult, request, response); filterChain.doFilter(request, response); }