/** * <p>Adds to the deployment the {@link org.wildfly.extension.undertow.security.jaspi.JASPICAuthenticationMechanism}, if necessary. The handler will be added if the security domain * is configured with JASPI authentication.</p> * * @param deploymentInfo */ private void handleJASPIMechanism(final DeploymentInfo deploymentInfo) { ApplicationPolicy applicationPolicy = SecurityConfiguration.getApplicationPolicy(this.securityDomain); if (applicationPolicy != null && JASPIAuthenticationInfo.class.isInstance(applicationPolicy.getAuthenticationInfo())) { String authMethod = null; LoginConfig loginConfig = deploymentInfo.getLoginConfig(); if (loginConfig != null && loginConfig.getAuthMethods().size() > 0) { authMethod = loginConfig.getAuthMethods().get(0).getName(); } deploymentInfo.setJaspiAuthenticationMechanism(new JASPICAuthenticationMechanism(securityDomain, authMethod)); deploymentInfo.setSecurityContextFactory(new JASPICSecurityContextFactory(this.securityDomain)); deploymentInfo.addOuterHandlerChainWrapper(next -> new JASPICSecureResponseHandler(next)); } }
List<AuthMethodConfig> authMethod = authMethod(loginConfig.getAuthMethod()); if (loginConfig.getFormLoginConfig() != null) { d.setLoginConfig(new LoginConfig(loginConfig.getRealmName(), loginConfig.getFormLoginConfig().getLoginPage(), loginConfig.getFormLoginConfig().getErrorPage())); } else { d.setLoginConfig(new LoginConfig(loginConfig.getRealmName())); d.getLoginConfig().addLastAuthMethod(method);
private String getRealmName(final DeploymentInfo deploymentInfo) { LoginConfig loginConfig = deploymentInfo.getLoginConfig(); return loginConfig != null ? loginConfig.getRealmName() : null; }
String realm = loginConfig.getRealmName(); if (realm != null) tempBaseConfiguration.put(CONFIG_REALM, realm); String loginPage = loginConfig.getLoginPage(); if (loginPage != null) tempBaseConfiguration.put(CONFIG_LOGIN_PAGE, loginPage); String errorPage = loginConfig.getErrorPage(); if (errorPage != null) tempBaseConfiguration.put(CONFIG_ERROR_PAGE, errorPage); final List<AuthMethodConfig> authMethods = loginConfig.getAuthMethods(); if (authMethods.isEmpty()) { throw new IllegalStateException("No authentication mechanisms have been selected.");
if ( loginConfig != null ) logger.debug( "Login Config with realm: {} and mechanism: {} from: {}", loginConfig.getRealmName(), loginConfig.getAuthMethods(), from ); if ( into.getLoginConfig() != null )
/** * Adds an authentication mechanism directly to the deployment. This mechanism will be first in the list. * * In general you should just use {@link #addAuthenticationMechanism(String, io.undertow.security.api.AuthenticationMechanismFactory)} * and allow the user to configure the methods they want by name. * * This method is essentially a convenience method, if is the same as registering a factory under the provided name that returns * and authentication mechanism, and then adding it to the login config list. * * If you want your mechanism to be the only one in the deployment you should first invoke {@link #clearLoginMethods()}. * * @param name The authentication mechanism name * @param mechanism The mechanism * @return this deployment info */ public DeploymentInfo addFirstAuthenticationMechanism(final String name, final AuthenticationMechanism mechanism) { authenticationMechanisms.put(name, new ImmediateAuthenticationMechanismFactory(mechanism)); if(loginConfig == null) { loginConfig = new LoginConfig(null); } loginConfig.addFirstAuthMethod(new AuthMethodConfig(name)); return this; }
public static LoginConfig loginConfig(final String realmName) { return new LoginConfig(realmName); }
public LoginConfig(String mechanismName, String realmName, String loginPage, String errorPage) { this.realmName = realmName; this.loginPage = loginPage; this.errorPage = errorPage; addFirstAuthMethod(mechanismName); }
protected String getErrorPage(DeploymentInfo deploymentInfo) { LoginConfig loginConfig = deploymentInfo.getLoginConfig(); String errorPage = null; if (loginConfig != null) { errorPage = loginConfig.getErrorPage(); } return errorPage; }
final LoginConfig loginConfig = Servlets.loginConfig(connector.realm); for (String authmethod : StringUtils.split(connector.authentication, ',')) loginConfig.addLastAuthMethod(authmethod); context.setLoginConfig(loginConfig);
authMethods = loginConfig.getAuthMethods(); properties.put(AuthenticationMechanismFactory.REALM, loginConfig.getRealmName()); properties.put(AuthenticationMechanismFactory.ERROR_PAGE, loginConfig.getErrorPage()); properties.put(AuthenticationMechanismFactory.LOGIN_PAGE, loginConfig.getLoginPage()); properties.putAll(method.getProperties());
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()); }
public static LoginConfig loginConfig(String mechanismName, final String realmName) { return new LoginConfig(mechanismName, realmName); }
public SipLoginConfig(String mechanismName, String realmName, String loginPage, String errorPage) { super(realmName, loginPage, errorPage); super.addFirstAuthMethod(mechanismName); }
protected String getErrorPage(DeploymentInfo deploymentInfo) { LoginConfig loginConfig = deploymentInfo.getLoginConfig(); String errorPage = null; if (loginConfig != null) { errorPage = loginConfig.getErrorPage(); } return errorPage; }
authMethods = loginConfig.getAuthMethods(); properties.put(AuthenticationMechanismFactory.REALM, loginConfig.getRealmName()); properties.put(AuthenticationMechanismFactory.ERROR_PAGE, loginConfig.getErrorPage()); properties.put(AuthenticationMechanismFactory.LOGIN_PAGE, loginConfig.getLoginPage()); properties.putAll(method.getProperties());
/** * Removes all configured authentication mechanisms from the deployment. * * @return this deployment info */ public DeploymentInfo clearLoginMethods() { if(loginConfig != null) { loginConfig.getAuthMethods().clear(); } return this; }
/** * Adds an authentication mechanism directly to the deployment. This mechanism will be last in the list. * * In general you should just use {@link #addAuthenticationMechanism(String, io.undertow.security.api.AuthenticationMechanismFactory)} * and allow the user to configure the methods they want by name. * * This method is essentially a convenience method, if is the same as registering a factory under the provided name that returns * and authentication mechanism, and then adding it to the login config list. * * If you want your mechanism to be the only one in the deployment you should first invoke {@link #clearLoginMethods()}. * * @param name The authentication mechanism name * @param mechanism The mechanism * @return */ public DeploymentInfo addLastAuthenticationMechanism(final String name, final AuthenticationMechanism mechanism) { authenticationMechanisms.put(name, new ImmediateAuthenticationMechanismFactory(mechanism)); if(loginConfig == null) { loginConfig = new LoginConfig(null); } loginConfig.addLastAuthMethod(new AuthMethodConfig(name)); return this; }
final LoginConfig loginConfig = new LoginConfig( KEYCLOAK_LOGIN_MECHANISM, config.getRealm() ); loginConfig.addFirstAuthMethod( BASIC_LOGIN_MECHANISM );
public static LoginConfig loginConfig(String realmName, String loginPage, String errorPage) { return new LoginConfig(realmName, loginPage, errorPage); }