/** * <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)); } }
Deque<String> val = entry.getValue(); if (val.isEmpty()) { authMethodConfig.getProperties().put(entry.getKey(), ""); } else { authMethodConfig.getProperties().put(entry.getKey(), val.getFirst());
private static AuthMethodConfig createAuthMethodConfig(String part, Map<String, String> replacements) throws UnsupportedEncodingException { String name = URLDecoder.decode(part, UTF_8); if (replacements.containsKey(name)) { return new AuthMethodConfig(replacements.get(name)); } return new AuthMethodConfig(name); }
String name = c.getName(); if (availableMechanisms.contains(name) == false) { throw new IllegalStateException(String.format("The required mechanism '%s' is not available in mechanisms %s from the HttpAuthenticationFactory.", name, availableMechanisms)); Map<String, String> additionalProperties = c.getProperties(); if (additionalProperties != null) { mechanismConfiguration = new HashMap<>(baseConfiguration);
@Override public LoginConfig clone() { LoginConfig lc = new LoginConfig(realmName, loginPage, errorPage); for(AuthMethodConfig method : authMethods) { lc.authMethods.add(method.clone()); } return lc; } }
AuthenticationMechanismFactory factory = factoryMap.get(method.getName()); if(factory == null) { throw UndertowServletMessages.MESSAGES.unknownAuthenticationMechanism(method.getName()); mechName = method.getName(); properties.put(AuthenticationMechanismFactory.ERROR_PAGE, loginConfig.getErrorPage()); properties.put(AuthenticationMechanismFactory.LOGIN_PAGE, loginConfig.getLoginPage()); properties.putAll(method.getProperties()); String name = method.getName().toUpperCase(Locale.US);
AuthenticationMechanismFactory factory = factoryMap.get(method.getName()); if(factory == null) { throw UndertowServletMessages.MESSAGES.unknownAuthenticationMechanism(method.getName()); mechName = method.getName(); properties.put(AuthenticationMechanismFactory.ERROR_PAGE, loginConfig.getErrorPage()); properties.put(AuthenticationMechanismFactory.LOGIN_PAGE, loginConfig.getLoginPage()); properties.putAll(method.getProperties()); String name = method.getName().toUpperCase(Locale.US);
/** * Returns true if the specified mechanism is present in the login config * @param mechanismName The mechanism name * @return true if the mechanism is enabled */ public boolean isAuthenticationMechanismPresent(final String mechanismName) { if(loginConfig != null) { for(AuthMethodConfig method : loginConfig.getAuthMethods()) { if(method.getName().equalsIgnoreCase(mechanismName)) { return true; } } } return false; }
Deque<String> val = entry.getValue(); if (val.isEmpty()) { authMethodConfig.getProperties().put(entry.getKey(), ""); } else { authMethodConfig.getProperties().put(entry.getKey(), val.getFirst());
/** * Convert the authentication method name from the format specified in the web.xml to the format used by * {@link javax.servlet.http.HttpServletRequest}. * <p/> * If the auth method is not recognised then it is returned as-is. * * @return The converted auth method. * @throws NullPointerException if no configuredMethod is supplied. */ private static List<AuthMethodConfig> authMethod(String configuredMethod) { if (configuredMethod == null) { return Collections.singletonList(new AuthMethodConfig(HttpServletRequest.BASIC_AUTH)); } return AuthMethodParser.parse(configuredMethod, Collections.singletonMap("CLIENT-CERT", HttpServletRequest.CLIENT_CERT_AUTH)); }
AuthenticationMechanismFactory factory = factoryMap.get(method.getName()); if(factory == null) { throw UndertowServletMessages.MESSAGES.unknownAuthenticationMechanism(method.getName()); mechName = method.getName(); properties.put(AuthenticationMechanismFactory.ERROR_PAGE, loginConfig.getErrorPage()); properties.put(AuthenticationMechanismFactory.LOGIN_PAGE, loginConfig.getLoginPage()); properties.putAll(method.getProperties()); String name = method.getName().toUpperCase(Locale.US);
public boolean isAuthenticationMechanismPresent(DeploymentInfo deploymentInfo, final String mechanismName) { LoginConfig loginConfig = deploymentInfo.getLoginConfig(); if (loginConfig != null) { for (AuthMethodConfig method : loginConfig.getAuthMethods()) { if (method.getName().equalsIgnoreCase(mechanismName)) { return true; } } } return false; }
Deque<String> val = entry.getValue(); if (val.isEmpty()) { authMethodConfig.getProperties().put(entry.getKey(), ""); } else { authMethodConfig.getProperties().put(entry.getKey(), val.getFirst());
@Override public AuthMethodConfig clone() { return new AuthMethodConfig(name, properties); } }
public boolean isAuthenticationMechanismPresent(DeploymentInfo deploymentInfo, final String mechanismName) { LoginConfig loginConfig = deploymentInfo.getLoginConfig(); if (loginConfig != null) { for (AuthMethodConfig method : loginConfig.getAuthMethods()) { if (method.getName().equalsIgnoreCase(mechanismName)) { return true; } } } return false; }
public LoginConfig addLastAuthMethod(String authMethodConfig) { authMethods.addLast(new AuthMethodConfig(authMethodConfig)); return this; }
/** * <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)); } }
public LoginConfig addFirstAuthMethod(String authMethodConfig) { authMethods.addFirst(new AuthMethodConfig(authMethodConfig)); return this; }
/** * <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)); } }
private static AuthMethodConfig createAuthMethodConfig(String part, Map<String, String> replacements) throws UnsupportedEncodingException { String name = URLDecoder.decode(part, UTF_8); if (replacements.containsKey(name)) { return new AuthMethodConfig(replacements.get(name)); } return new AuthMethodConfig(name); }