Java Code Examples for io.undertow.security.api.SecurityContext#setAuthenticationRequired()
The following examples show how to use
io.undertow.security.api.SecurityContext#setAuthenticationRequired() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpServletRequestImpl.java From quarkus-http with Apache License 2.0 | 6 votes |
@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; } } }
Example 2
Source File: HttpServletRequestImpl.java From lams with GNU General Public License v2.0 | 6 votes |
@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; } } }
Example 3
Source File: AuthenticationConstraintHandler.java From quarkus-http with Apache License 2.0 | 5 votes |
/** * @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange) */ @Override public void handleRequest(HttpServerExchange exchange) throws Exception { if (isAuthenticationRequired(exchange)) { SecurityContext context = exchange.getSecurityContext(); UndertowLogger.SECURITY_LOGGER.debugf("Setting authentication required for exchange %s", exchange); context.setAuthenticationRequired(); } next.handleRequest(exchange); }
Example 4
Source File: AuthenticationConstraintHandler.java From lams with GNU General Public License v2.0 | 5 votes |
/** * @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange) */ @Override public void handleRequest(HttpServerExchange exchange) throws Exception { if (isAuthenticationRequired(exchange)) { SecurityContext context = exchange.getSecurityContext(); UndertowLogger.SECURITY_LOGGER.debugf("Setting authentication required for exchange %s", exchange); context.setAuthenticationRequired(); } next.handleRequest(exchange); }