1/* 2 * Copyright (c) 2006, 2015, 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 26package sun.security.ssl; 27 28import java.util.ArrayList; 29import java.util.List; 30 31final class ExtensionType { 32 33 final int id; 34 final String name; 35 36 private ExtensionType(int id, String name) { 37 this.id = id; 38 this.name = name; 39 } 40 41 @Override 42 public String toString() { 43 return name; 44 } 45 46 static List<ExtensionType> knownExtensions = new ArrayList<>(15); 47 48 static ExtensionType get(int id) { 49 for (ExtensionType ext : knownExtensions) { 50 if (ext.id == id) { 51 return ext; 52 } 53 } 54 return new ExtensionType(id, "type_" + id); 55 } 56 57 private static ExtensionType e(int id, String name) { 58 ExtensionType ext = new ExtensionType(id, name); 59 knownExtensions.add(ext); 60 return ext; 61 } 62 63 // extensions defined in RFC 3546 64 static final ExtensionType EXT_SERVER_NAME = 65 e(0x0000, "server_name"); // IANA registry value: 0 66 static final ExtensionType EXT_MAX_FRAGMENT_LENGTH = 67 e(0x0001, "max_fragment_length"); // IANA registry value: 1 68 static final ExtensionType EXT_CLIENT_CERTIFICATE_URL = 69 e(0x0002, "client_certificate_url"); // IANA registry value: 2 70 static final ExtensionType EXT_TRUSTED_CA_KEYS = 71 e(0x0003, "trusted_ca_keys"); // IANA registry value: 3 72 static final ExtensionType EXT_TRUNCATED_HMAC = 73 e(0x0004, "truncated_hmac"); // IANA registry value: 4 74 static final ExtensionType EXT_STATUS_REQUEST = 75 e(0x0005, "status_request"); // IANA registry value: 5 76 77 // extensions defined in RFC 4681 78 static final ExtensionType EXT_USER_MAPPING = 79 e(0x0006, "user_mapping"); // IANA registry value: 6 80 81 // extensions defined in RFC 5081 82 static final ExtensionType EXT_CERT_TYPE = 83 e(0x0009, "cert_type"); // IANA registry value: 9 84 85 // extensions defined in RFC 4492 (ECC) 86 static final ExtensionType EXT_ELLIPTIC_CURVES = 87 e(0x000A, "elliptic_curves"); // IANA registry value: 10 88 static final ExtensionType EXT_EC_POINT_FORMATS = 89 e(0x000B, "ec_point_formats"); // IANA registry value: 11 90 91 // extensions defined in RFC 5054 92 static final ExtensionType EXT_SRP = 93 e(0x000C, "srp"); // IANA registry value: 12 94 95 // extensions defined in RFC 5246 96 static final ExtensionType EXT_SIGNATURE_ALGORITHMS = 97 e(0x000D, "signature_algorithms"); // IANA registry value: 13 98 99 // extension defined in RFC 7301 (ALPN) 100 static final ExtensionType EXT_ALPN = 101 e(0x0010, "application_layer_protocol_negotiation"); 102 // IANA registry value: 16 103 104 // extensions defined in RFC 6961 105 static final ExtensionType EXT_STATUS_REQUEST_V2 = 106 e(0x0011, "status_request_v2"); // IANA registry value: 17 107 108 // extensions defined in RFC 5746 109 static final ExtensionType EXT_RENEGOTIATION_INFO = 110 e(0xff01, "renegotiation_info"); // IANA registry value: 65281 111} 112