Search in sources :

Example 1 with JASPICSecurityContextFactory

use of org.wildfly.extension.undertow.security.jaspi.JASPICSecurityContextFactory in project wildfly by wildfly.

the class UndertowDeploymentInfoService method handleJASPIMechanism.

/**
     * <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) {
    if (securityDomain == null) {
        return;
    }
    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));
    }
}
Also used : JASPICAuthenticationMechanism(org.wildfly.extension.undertow.security.jaspi.JASPICAuthenticationMechanism) JASPICSecureResponseHandler(org.wildfly.extension.undertow.security.jaspi.JASPICSecureResponseHandler) ApplicationPolicy(org.jboss.security.config.ApplicationPolicy) JASPIAuthenticationInfo(org.jboss.security.auth.login.JASPIAuthenticationInfo) LoginConfig(io.undertow.servlet.api.LoginConfig) JASPICSecurityContextFactory(org.wildfly.extension.undertow.security.jaspi.JASPICSecurityContextFactory)

Aggregations

LoginConfig (io.undertow.servlet.api.LoginConfig)1 JASPIAuthenticationInfo (org.jboss.security.auth.login.JASPIAuthenticationInfo)1 ApplicationPolicy (org.jboss.security.config.ApplicationPolicy)1 JASPICAuthenticationMechanism (org.wildfly.extension.undertow.security.jaspi.JASPICAuthenticationMechanism)1 JASPICSecureResponseHandler (org.wildfly.extension.undertow.security.jaspi.JASPICSecureResponseHandler)1 JASPICSecurityContextFactory (org.wildfly.extension.undertow.security.jaspi.JASPICSecurityContextFactory)1