protected ServletKeycloakAuthMech createAuthenticationMechanism(DeploymentInfo deploymentInfo, AdapterDeploymentContext deploymentContext, UndertowUserSessionManagement userSessionManagement, NodesRegistrationManagement nodesRegistrationManagement) { log.debug("creating ServletKeycloakAuthMech"); String errorPage = getErrorPage(deploymentInfo); return new ServletKeycloakAuthMech(deploymentContext, userSessionManagement, nodesRegistrationManagement, deploymentInfo.getConfidentialPortManager(), errorPage); }
private static InputStream getConfigInputStream(ServletContext context) { InputStream is = getJSONFromServletContext(context); if (is == null) { String path = context.getInitParameter("keycloak.config.file"); if (path == null) { log.debug("using /WEB-INF/keycloak.json"); is = context.getResourceAsStream("/WEB-INF/keycloak.json"); } else { try { is = new FileInputStream(path); } catch (FileNotFoundException e) { throw new RuntimeException(e); } } } return is; }
@Override @SuppressWarnings("UseSpecificCatch") public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { if (!isAuthenticationMechanismPresent(deploymentInfo, "KEYCLOAK")) { log.debug("auth-method is not keycloak!"); return; InputStream is = getConfigInputStream(servletContext); final KeycloakDeployment deployment; if (is == null) { UndertowUserSessionManagement userSessionManagement = new UndertowUserSessionManagement(); final NodesRegistrationManagement nodesRegistrationManagement = new NodesRegistrationManagement(); final ServletKeycloakAuthMech mech = createAuthenticationMechanism(deploymentInfo, deploymentContext, userSessionManagement, nodesRegistrationManagement);
public void customize(DeploymentInfo deploymentInfo) { io.undertow.servlet.api.LoginConfig loginConfig = new io.undertow.servlet.api.LoginConfig(keycloakProperties.getRealm()); loginConfig.addFirstAuthMethod("KEYCLOAK"); deploymentInfo.setLoginConfig(loginConfig); deploymentInfo.addInitParameter("keycloak.config.resolver", KeycloakSpringBootConfigResolverWrapper.class.getName()); deploymentInfo.addSecurityConstraints(getSecurityConstraints()); deploymentInfo.addServletExtension(new KeycloakServletExtension()); }
@Override @SuppressWarnings("UseSpecificCatch") public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { if (!isAuthenticationMechanismPresent(deploymentInfo, "KEYCLOAK")) { log.debug("auth-method is not keycloak!"); return; InputStream is = getConfigInputStream(servletContext); final KeycloakDeployment deployment; if (is == null) { UndertowUserSessionManagement userSessionManagement = new UndertowUserSessionManagement(); final NodesRegistrationManagement nodesRegistrationManagement = new NodesRegistrationManagement(); final ServletKeycloakAuthMech mech = createAuthenticationMechanism(deploymentInfo, deploymentContext, userSessionManagement, nodesRegistrationManagement);
protected ServletKeycloakAuthMech createAuthenticationMechanism(DeploymentInfo deploymentInfo, AdapterDeploymentContext deploymentContext, UndertowUserSessionManagement userSessionManagement, NodesRegistrationManagement nodesRegistrationManagement) { log.debug("creating ServletKeycloakAuthMech"); String errorPage = getErrorPage(deploymentInfo); return new ServletKeycloakAuthMech(deploymentContext, userSessionManagement, nodesRegistrationManagement, deploymentInfo.getConfidentialPortManager(), errorPage); }
private static InputStream getConfigInputStream(ServletContext context) { InputStream is = getJSONFromServletContext(context); if (is == null) { String path = context.getInitParameter("keycloak.config.file"); if (path == null) { log.debug("using /WEB-INF/keycloak.json"); is = context.getResourceAsStream("/WEB-INF/keycloak.json"); } else { try { is = new FileInputStream(path); } catch (FileNotFoundException e) { throw new RuntimeException(e); } } } return is; }