001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.eclipse.aether.transfer; 020 021/** 022 * Defines transport property keys specific to HTTP transporters. 023 * These keys can be used to expose additional information about the HTTP transport operation. 024 * Additionally it defines types for the values of these keys, such as {@link HttpVersion} and {@link SslProtocol}. 025 * @see TransferEvent#getTransportProperties() 026 * @since 2.0.21 027 */ 028public final class HttpTransportProperty { 029 030 private HttpTransportProperty() { 031 // Private constructor to prevent instantiation 032 } 033 034 /** 035 * Transport property keys specific to HTTP transporters. 036 * @see TransferEvent#getTransportProperties() 037 */ 038 public enum Key implements TransferEvent.TransportPropertyKey { 039 /** 040 * Transport property key for HTTP version. Value is a {@link HttpVersion} representing the HTTP version used. 041 */ 042 HTTP_VERSION, 043 /** 044 * Transport property key for SSL protocol. Value is a {@link SslProtocol} representing the SSL protocol used. 045 */ 046 SSL_PROTOCOL, 047 /** 048 * Transport property key for SSL cipher suite. Value is a String representing the SSL cipher suite used (e.g., "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"). 049 * @see <a href="https://docs.oracle.com/en/java/javase/11/docs/specs/security/standard-names.html#jsse-cipher-suite-names">JSSE Cipher Suite Names</a>. 050 */ 051 SSL_CIPHER_SUITE, 052 /** 053 * Transport property key for content coding (usually compression). Value is a String representing the compression algorithm used (e.g., "gzip", "br", or "zstd") 054 * @see <a href="https://www.iana.org/assignments/http-parameters/http-parameters.xhtml#content-coding">Content Coding Values</a> 055 */ 056 CONTENT_CODING, 057 } 058 059 /** 060 * HTTP version used for the HTTP transport. 061 */ 062 public enum HttpVersion { 063 /** HTTP/1.0. */ 064 HTTP_1_0("HTTP/1.0"), 065 /** HTTP/1.1. */ 066 HTTP_1_1("HTTP/1.1"), 067 /** HTTP/2. */ 068 HTTP_2("HTTP/2"), 069 /** HTTP/3. */ 070 HTTP_3("HTTP/3"); 071 072 private final String label; 073 074 HttpVersion(String label) { 075 this.label = label; 076 } 077 078 @Override 079 public String toString() { 080 return label; 081 } 082 } 083 084 /** 085 * SSL protocol including version used for the HTTP transport. 086 */ 087 public enum SslProtocol { 088 /** SSL 3.0. */ 089 SSL_3_0("SSLv3"), 090 /** TLS 1.0. */ 091 TLS_1_0("TLSv1"), 092 /** TLS 1.1. */ 093 TLS_1_1("TLSv1.1"), 094 /** TLS 1.2. */ 095 TLS_1_2("TLSv1.2"), 096 /** TLS 1.3. */ 097 TLS_1_3("TLSv1.3"); 098 099 private final String label; 100 101 SslProtocol(String label) { 102 this.label = label; 103 } 104 105 @Override 106 public String toString() { 107 return label; 108 } 109 110 /** 111 * Converts a standard SSL protocol name to the corresponding SslProtocol enum value. 112 * 113 * @param name the standard algorithm name of the SSL protocol (e.g., "TLSv1.2", "TLSv1.3") 114 * @return the corresponding SslProtocol enum value 115 * @see <a href="https://docs.oracle.com/en/java/javase/11/docs/specs/security/standard-names.html#sslcontext-algorithms">Standard Names for SSLContext Algorithms</a> 116 */ 117 public static SslProtocol fromStandardName(String name) { 118 switch (name) { 119 case "SSLv3": 120 return SSL_3_0; 121 case "TLSv1": 122 return TLS_1_0; 123 case "TLSv1.1": 124 return TLS_1_1; 125 case "TLSv1.2": 126 return TLS_1_2; 127 case "TLSv1.3": 128 return TLS_1_3; 129 default: 130 throw new IllegalArgumentException("Unknown SSL protocol: " + name); 131 } 132 } 133 } 134}