/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2015 Red Hat, Inc., and individual contributors
 * as indicated by the @author tags.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.wildfly.security.auth.server;

import org.wildfly.common.Assert;
import org.wildfly.security.http.HttpServerAuthenticationMechanismFactory;

/**
 * A HTTP authentication mechanism configuration, the configuration is associated with the {@link SecurityDomain} and
 * {@link HttpServerAuthenticationMechanismFactory} for obtaining configured mechanisms.
 *
 * @author <a href="mailto:darran.lofthouse@jboss.com">Darran Lofthouse</a>
 */
public final class SecurityDomainHttpConfiguration {

    private final SecurityDomain securityDomain;
    private final HttpServerAuthenticationMechanismFactory mechanismFactory;

    public SecurityDomainHttpConfiguration(final SecurityDomain securityDomain, final HttpServerAuthenticationMechanismFactory mechanismFactory) {
        this.securityDomain = Assert.checkNotNullParam("securityDomain", securityDomain);
        // TODO - This will be wrapped to be mechanism specific.
        this.mechanismFactory = Assert.checkNotNullParam("mechanismFactory", mechanismFactory);
    }

    /**
     * Get the {@link SecurityDomain} associated with this configuration.
     *
     * @return the {@link SecurityDomain} associated with this configuration.
     */
    public SecurityDomain getSecurityDomain() {
        return securityDomain;
    }

    /**
     * Get the {@link HttpServerAuthenticationMechanismFactory} associated with this configuration.
     *
     * @return the {@link HttpServerAuthenticationMechanismFactory} associated with this configuration.
     */
    public HttpServerAuthenticationMechanismFactory getMechanismFactory() {
        return mechanismFactory;
    }

}

@@ -743,16 +743,70 @@
 erver;%0A%0A
+import java.util.Collections;%0Aimport java.util.List;%0A%0A
 import o
@@ -905,16 +905,81 @@
 Factory;
+%0Aimport org.wildfly.security.util._private.UnmodifiableArrayList;
 %0A%0A/**%0A *
@@ -2456,10 +2456,692 @@
 %0A    %7D%0A%0A
+    /**%0A     * Get the list of HTTP server mechanism names that are provided by the given factory and allowed by this%0A     * configuration.%0A     *%0A     * @return the list of mechanism names%0A     */%0A    public List%3CString%3E getMechanismNames() %7B%0A        final String%5B%5D names = mechanismFactory.getMechanismNames(Collections.emptyMap());%0A        // todo: filter down based on additional selection criteria%0A        if (names == null %7C%7C names.length == 0) %7B%0A            return Collections.emptyList();%0A        %7D else if (names.length == 1) %7B%0A            return Collections.singletonList(names%5B0%5D);%0A        %7D else %7B%0A            return new UnmodifiableArrayList%3C%3E(names);%0A        %7D%0A    %7D%0A%0A
 %7D%0A

Enable HTTP authentication mechanism names to be obtained from the SecurityDomainHttpConfiguration.