|
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. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package sun.security.ssl; |
|
27 |
|
28 /** |
|
29 * Enum for SSL/(D)TLS content types. |
|
30 */ |
|
31 enum ContentType { |
|
32 INVALID ((byte)0, "invalid", |
|
33 ProtocolVersion.PROTOCOLS_OF_13), |
|
34 CHANGE_CIPHER_SPEC ((byte)20, "change_cipher_spec", |
|
35 ProtocolVersion.PROTOCOLS_TO_12), |
|
36 ALERT ((byte)21, "alert", |
|
37 ProtocolVersion.PROTOCOLS_TO_13), |
|
38 HANDSHAKE ((byte)22, "handshake", |
|
39 ProtocolVersion.PROTOCOLS_TO_13), |
|
40 APPLICATION_DATA ((byte)23, "application_data", |
|
41 ProtocolVersion.PROTOCOLS_TO_13); |
|
42 |
|
43 final byte id; |
|
44 final String name; |
|
45 final ProtocolVersion[] supportedProtocols; |
|
46 |
|
47 private ContentType(byte id, String name, |
|
48 ProtocolVersion[] supportedProtocols) { |
|
49 this.id = id; |
|
50 this.name = name; |
|
51 this.supportedProtocols = supportedProtocols; |
|
52 } |
|
53 |
|
54 static ContentType valueOf(byte id) { |
|
55 for (ContentType ct : ContentType.values()) { |
|
56 if (ct.id == id) { |
|
57 return ct; |
|
58 } |
|
59 } |
|
60 |
|
61 return null; |
|
62 } |
|
63 |
|
64 static String nameOf(byte id) { |
|
65 for (ContentType ct : ContentType.values()) { |
|
66 if (ct.id == id) { |
|
67 return ct.name; |
|
68 } |
|
69 } |
|
70 |
|
71 return "<UNKNOWN CONTENT TYPE: " + (id & 0x0FF) + ">"; |
|
72 } |
|
73 } |