@Override public String readAttribute(final HttpServerExchange exchange) { SecurityContext sc = exchange.getSecurityContext(); if (sc == null || !sc.isAuthenticated()) { return null; } return sc.getAuthenticatedAccount().getPrincipal().getName(); }
if (sc.isAuthenticated()) { sb.append(" authType=" + sc.getMechanismName() + "\n"); sb.append(" principle=" + sc.getAuthenticatedAccount().getPrincipal() + "\n");
if (sc.isAuthenticated()) { sb.append(" authType=" + sc.getMechanismName() + "\n"); sb.append(" principle=" + sc.getAuthenticatedAccount().getPrincipal() + "\n");
if (sc == null || !sc.isAuthenticated()) { jdbcLogAttribute.user = null; } else {
private static String getUsername(final SecurityContext securityContext) { if (!securityContext.isAuthenticated()) return null; final Account account = securityContext.getAuthenticatedAccount(); if (account == null) return null; final Principal principal = account.getPrincipal(); if (principal == null) return null; return principal.getName(); }
@Override public String readAttribute(final HttpServerExchange exchange) { SecurityContext sc = exchange.getSecurityContext(); if (sc == null || !sc.isAuthenticated()) { return null; } return sc.getAuthenticatedAccount().getPrincipal().getName(); }
@Override public String readAttribute(final HttpServerExchange exchange) { SecurityContext sc = exchange.getSecurityContext(); if (sc == null || !sc.isAuthenticated()) { return null; } return sc.getAuthenticatedAccount().getPrincipal().getName(); }
if (sc.isAuthenticated()) { sb.append(" authType=" + sc.getMechanismName() + "\n"); sb.append(" principle=" + sc.getAuthenticatedAccount().getPrincipal() + "\n");
if (sc.isAuthenticated()) { sb.append(" authType=" + sc.getMechanismName() + "\n"); sb.append(" principle=" + sc.getAuthenticatedAccount().getPrincipal() + "\n");
if (sc.isAuthenticated()) { sb.append(" authType=" + sc.getMechanismName() + "\n"); sb.append(" principle=" + sc.getAuthenticatedAccount().getPrincipal() + "\n");
sb.append("--------------------------RESPONSE--------------------------\n"); if (sc != null) { if (sc.isAuthenticated()) { sb.append(" authType=").append(sc.getMechanismName()).append("\n"); sb.append(" username=").append(sc.getAuthenticatedAccount().getPrincipal().getName())
if (sc.isAuthenticated()) { sb.append(" authType=" + sc.getMechanismName() + "\n"); sb.append(" principle=" + sc.getAuthenticatedAccount().getPrincipal() + "\n");
@Override public void login(final String username, final String password) throws ServletException { if (username == null || password == null) { throw UndertowServletMessages.MESSAGES.loginFailed(); } SecurityContext sc = exchange.getSecurityContext(); if (sc.isAuthenticated()) { throw UndertowServletMessages.MESSAGES.userAlreadyLoggedIn(); } boolean login = false; try { login = sc.login(username, password); } catch (SecurityException se) { if (se.getCause() instanceof ServletException) throw (ServletException) se.getCause(); throw new ServletException(se); } if (!login) { throw UndertowServletMessages.MESSAGES.loginFailed(); } }
if (sc == null || !sc.isAuthenticated()) { jdbcLogAttribute.user = null; } else {
@Override public boolean authenticate(final HttpServletResponse response) throws IOException, ServletException { if (response.isCommitted()) { throw UndertowServletMessages.MESSAGES.responseAlreadyCommited(); } SecurityContext sc = exchange.getSecurityContext(); sc.setAuthenticationRequired(); // TODO: this will set the status code and headers without going through any potential // wrappers, is this a problem? if (sc.authenticate()) { if (sc.isAuthenticated()) { return true; } else { throw UndertowServletMessages.MESSAGES.authenticationFailed(); } } else { if(!exchange.isResponseStarted() && exchange.getStatusCode() == 200) { throw UndertowServletMessages.MESSAGES.authenticationFailed(); } else { return false; } } }
if (sc == null || !sc.isAuthenticated()) { jdbcLogAttribute.user = null; } else {
/** * * @param exchange * @param context * @throws Exception */ @Override public void handleRequest(HttpServerExchange exchange, RequestContext context) throws Exception { if (enabled) { if (exchange.getSecurityContext() != null && exchange.getSecurityContext().isAuthenticated()) { Account authenticatedAccount = exchange.getSecurityContext().getAuthenticatedAccount(); char[] token = cacheSessionToken(authenticatedAccount); injectTokenHeaders(exchange, new HeadersManager(exchange), token); } } next(exchange, context); }