@@ -0,0 +1,2526 @@
+/*%0A * JBoss, Home of Professional Open Source.%0A * Copyright 2017 Red Hat, Inc., and individual contributors%0A * as indicated by the @author tags.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.wildfly.security.http.util;%0A%0Aimport static org.wildfly.common.Assert.checkNotNullParam;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Comparator;%0Aimport java.util.Map;%0A%0Aimport javax.security.auth.callback.CallbackHandler;%0A%0Aimport org.wildfly.security.http.HttpAuthenticationException;%0Aimport org.wildfly.security.http.HttpServerAuthenticationMechanism;%0Aimport org.wildfly.security.http.HttpServerAuthenticationMechanismFactory;%0A%0A/**%0A * A %7B@link HttpServerAuthenticationMechanismFactory%7D which sorts the mechanism names returned using the provided%0A * %7B@link Comparator%3CString%3E%7D.%0A *%0A * @author %3Ca href=%22mailto:darran.lofthouse@jboss.com%22%3EDarran Lofthouse%3C/a%3E%0A */%0Apublic final class SortedServerMechanismFactory implements HttpServerAuthenticationMechanismFactory %7B%0A%0A    private final HttpServerAuthenticationMechanismFactory delegate;%0A    private final Comparator%3CString%3E mechanismNameComparator;%0A%0A    public SortedServerMechanismFactory(final HttpServerAuthenticationMechanismFactory delegate, final Comparator%3CString%3E mechanismNameComparator) %7B%0A        this.delegate = checkNotNullParam(%22delegate%22, delegate);%0A        this.mechanismNameComparator = checkNotNullParam(%22mechanismNameComparator%22, mechanismNameComparator);%0A    %7D%0A%0A    @Override%0A    public String%5B%5D getMechanismNames(Map%3CString, ?%3E properties) %7B%0A        String%5B%5D mechanismNames = delegate.getMechanismNames(properties);%0A        Arrays.sort(mechanismNames, mechanismNameComparator);%0A        return mechanismNames;%0A    %7D%0A%0A    @Override%0A    public HttpServerAuthenticationMechanism createAuthenticationMechanism(String mechanismName, Map%3CString, ?%3E properties,%0A            CallbackHandler callbackHandler) throws HttpAuthenticationException %7B%0A        return delegate.createAuthenticationMechanism(mechanismName, properties, callbackHandler);%0A    %7D%0A%0A%7D%0A

Add a sorted mechanism factory for HTTP authentication mechanisms.