test/jdk/javax/net/ssl/TLSCommon/Protocol.java
branchJDK-8145252-TLS13-branch
changeset 56542 56aaa6cb3693
equal deleted inserted replaced
56541:92cbbfc996f3 56542:56aaa6cb3693
       
     1 /*
       
     2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 public enum Protocol {
       
    25 
       
    26     SSLV2HELLO(0x0002, "SSLv2Hello"),
       
    27     SSLV3     (0x0300, "SSLv3"),
       
    28     TLSV1     (0x0301, "TLSv1"),
       
    29     TLSV1_1   (0x0302, "TLSv1.1"),
       
    30     TLSV1_2   (0x0303, "TLSv1.2"),
       
    31     TLSV1_3   (0x0304, "TLSv1.3"),
       
    32 
       
    33     DTLS1_3   (0xFEFC, "DTLSv1.3"),
       
    34     DTLS1_2   (0xFEFD, "DTLSv1.2"),
       
    35     DTLS1_0   (0xFEFF, "DTLSv1.0");
       
    36 
       
    37     public final int id;
       
    38     public final String name;
       
    39 
       
    40     private Protocol(int id, String name) {
       
    41         this.id = id;
       
    42         this.name = name;
       
    43     }
       
    44 
       
    45     public String toString() {
       
    46         return name;
       
    47     }
       
    48 
       
    49     public static Protocol protocol(String name) {
       
    50         for (Protocol protocol : values()) {
       
    51             if (protocol.name.equals(name)) {
       
    52                 return protocol;
       
    53             }
       
    54         }
       
    55 
       
    56         return null;
       
    57     }
       
    58 }