/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2014 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.ssl;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * The protocol type for SSL/TLS cipher suite selection and protocol selection.
 *
 * @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
 */
public enum Protocol {
    /**
     * The SSL version 2 protocol.
     */
    SSLv2 ("SSLv2"),
    /**
     * The SSL version 3 protocol.
     */
    SSLv3 ("SSLv3"),
    /**
     * The TLS version 1.0 protocol.
     */
    TLSv1 ("TLSv1"),
    /**
     * The TLS version 1.1 protocol.  Note that there are no cipher suites which are specifically defined in this protocol.
     */
    TLSv1_1 ("TLSv1.1"),
    /**
     * The TLS version 1.2 protocol.
     */
    TLSv1_2 ("TLSv1.2"),
    /**
     * The TLS version 1.3 protocol.
     */
    TLSv1_3 ("TLSv1.3"),
    ;

    static final int fullSize = values().length;

    static final Map<String, Protocol> map;

    static {
        map = new HashMap<>();
        Protocol[] protocols = values();
        for (int i = 0; i < fullSize; i++) {
            map.put(protocols[i].name, protocols[i]);
        }
    }

    public final String name;

    Protocol(String name) {
        this.name = name;
    }

    /**
     * Gets an enum item for given protocol name.
     *
     * @param name the protocol name
     * @return an enum item
     */
    public static Protocol forName(final String name) {
        return map.get(name);
    }

    /**
     * Determine whether the given set is "full" (meaning it contains all possible values).
     *
     * @param protocols the set
     * @return {@code true} if the set is full, {@code false} otherwise
     */
    public static boolean isFull(final EnumSet<Protocol> protocols) {
        return protocols != null && protocols.size() == fullSize;
    }

    /**
     * Determine whether this instance is equal to one of the given instances.
     *
     * @param value1 the first instance
     * @param value2 the second instance
     * @return {@code true} if one of the instances matches this one, {@code false} otherwise
     */
    public boolean in(final Protocol value1, final Protocol value2) {
        return this == value1 || this == value2;
    }

    /**
     * Determine whether this instance is equal to one of the given instances.
     *
     * @param value1 the first instance
     * @param value2 the second instance
     * @param value3 the third instance
     * @return {@code true} if one of the instances matches this one, {@code false} otherwise
     */
    public boolean in(final Protocol value1, final Protocol value2, final Protocol value3) {
        return this == value1 || this == value2 || this == value3;
    }

    /**
     * Determine whether this instance is equal to one of the given instances.
     *
     * @param values the values to match against
     * @return {@code true} if one of the instances matches this one, {@code false} otherwise
     */
    public boolean in(final Protocol... values) {
        if (values != null) for (Protocol value : values) {
            if (this == value) return true;
        }
        return false;
    }
}

@@ -788,16 +788,41 @@
 ashMap;%0A
+import java.util.Locale;%0A
 import j
@@ -835,16 +835,16 @@
 il.Map;%0A
-
 %0A/**%0A * 
@@ -1086,17 +1086,17 @@
 v2 (%22SSL
-v
+V
 2%22),%0A   
@@ -1158,17 +1158,17 @@
 v3 (%22SSL
-v
+V
 3%22),%0A   
@@ -1232,17 +1232,17 @@
 v1 (%22TLS
-v
+V
 1%22),%0A   
@@ -1395,17 +1395,17 @@
 _1 (%22TLS
-v
+V
 1.1%22),%0A 
@@ -1473,17 +1473,17 @@
 _2 (%22TLS
-v
+V
 1.2%22),%0A 
@@ -1551,17 +1551,17 @@
 _3 (%22TLS
-v
+V
 1.3%22),%0A 
@@ -2140,32 +2140,32 @@
  String name) %7B%0A
-
         return m
@@ -2175,16 +2175,44 @@
 get(name
+.toUpperCase(Locale.ENGLISH)
 );%0A    %7D

Make Protocol.forName() case insensitive to allow TLS to work properly when using the Bouncy Castle JSSE provider