private AuthenticationResult authenticateConnection(final DruidConnection connection) { Map<String, Object> context = connection.context(); for (Authenticator authenticator : authenticators) { AuthenticationResult authenticationResult = authenticator.authenticateJDBCContext(context); if (authenticationResult != null) { return authenticationResult; } } return null; }
private void handleUnauthenticatedRequest( final HttpServletResponse response ) throws IOException { // Since this is the last filter in the chain, some previous authentication filter // should have placed an authentication result in the request. // If not, send an authentication challenge. Set<String> supportedAuthSchemes = new HashSet<>(); for (Authenticator authenticator : authenticators) { String challengeHeader = authenticator.getAuthChallengeHeader(); if (challengeHeader != null) { supportedAuthSchemes.add(challengeHeader); } } for (String authScheme : supportedAuthSchemes) { response.addHeader("WWW-Authenticate", authScheme); } QueryInterruptedException unauthorizedError = new QueryInterruptedException( QueryInterruptedException.UNAUTHORIZED, null, null, DruidNode.getDefaultHost() ); unauthorizedError.setStackTrace(new StackTraceElement[0]); OutputStream out = response.getOutputStream(); sendJsonError(response, HttpServletResponse.SC_UNAUTHORIZED, jsonMapper.writeValueAsString(unauthorizedError), out); out.close(); return; }
public static void addAuthenticationFilterChain( ServletContextHandler root, List<Authenticator> authenticators ) { for (Authenticator authenticator : authenticators) { FilterHolder holder = new FilterHolder( new AuthenticationWrappingFilter(authenticator.getFilter()) ); if (authenticator.getInitParameters() != null) { holder.setInitParameters(authenticator.getInitParameters()); } root.addFilter( holder, "/*", null ); } }
.get(authenticationResult.getAuthenticatedBy()); if (authenticator != null) { authenticator.decorateProxyRequest( clientRequest, proxyResponse,
.get(authenticationResult.getAuthenticatedBy()); if (authenticator != null) { authenticator.decorateProxyRequest( clientRequest, proxyResponse,
public static void addAuthenticationFilterChain( ServletContextHandler root, List<Authenticator> authenticators ) { for (Authenticator authenticator : authenticators) { FilterHolder holder = new FilterHolder( new AuthenticationWrappingFilter(authenticator.getFilter()) ); if (authenticator.getInitParameters() != null) { holder.setInitParameters(authenticator.getInitParameters()); } root.addFilter( holder, "/*", null ); } }
private AuthenticationResult authenticateConnection(final DruidConnection connection) { Map<String, Object> context = connection.context(); for (Authenticator authenticator : authenticators) { AuthenticationResult authenticationResult = authenticator.authenticateJDBCContext(context); if (authenticationResult != null) { return authenticationResult; } } return null; }
private void handleUnauthenticatedRequest( final HttpServletResponse response ) throws IOException { // Since this is the last filter in the chain, some previous authentication filter // should have placed an authentication result in the request. // If not, send an authentication challenge. Set<String> supportedAuthSchemes = Sets.newHashSet(); for (Authenticator authenticator : authenticators) { String challengeHeader = authenticator.getAuthChallengeHeader(); if (challengeHeader != null) { supportedAuthSchemes.add(challengeHeader); } } for (String authScheme : supportedAuthSchemes) { response.addHeader("WWW-Authenticate", authScheme); } QueryInterruptedException unauthorizedError = new QueryInterruptedException( QueryInterruptedException.UNAUTHORIZED, null, null, DruidNode.getDefaultHost() ); unauthorizedError.setStackTrace(new StackTraceElement[0]); OutputStream out = response.getOutputStream(); sendJsonError(response, Response.SC_UNAUTHORIZED, jsonMapper.writeValueAsString(unauthorizedError), out); out.close(); return; }