|
| 1 | +/* |
| 2 | + * Copyright (c) 2021 Contributors to the Eclipse Foundation. |
| 3 | + * |
| 4 | + * This program and the accompanying materials are made available under the |
| 5 | + * terms of the Eclipse Public License v. 2.0, which is available at |
| 6 | + * http://www.eclipse.org/legal/epl-2.0. |
| 7 | + * |
| 8 | + * This Source Code may also be made available under the following Secondary |
| 9 | + * Licenses when the conditions for such availability set forth in the |
| 10 | + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, |
| 11 | + * version 2 with the GNU Classpath Exception, which is available at |
| 12 | + * https://www.gnu.org/software/classpath/license.html. |
| 13 | + * |
| 14 | + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 |
| 15 | + */ |
| 16 | +package jakarta.servlet; |
| 17 | + |
| 18 | +/** |
| 19 | + * Provides information about the connection made to the Servlet container. This interface is intended primarily for |
| 20 | + * debugging purposes and as such provides the raw information as seen by the container. Unless explicitly stated |
| 21 | + * otherwise in the Javadoc for a method, no adjustment is made for the presence of reverse proxies or similar |
| 22 | + * configurations. |
| 23 | + * |
| 24 | + * @since Servlet 6.0 |
| 25 | + */ |
| 26 | +public interface ServletConnection { |
| 27 | + |
| 28 | + /** |
| 29 | + * Obtain a unique (within the lifetime of the JVM) identifier string for the network connection to the JVM that is |
| 30 | + * being used for the {@code ServletRequest} from which this {@code ServletConnection} was obtained. |
| 31 | + * <p> |
| 32 | + * There is no defined format for this string. The format is implementation dependent. |
| 33 | + * |
| 34 | + * @return A unique identifier for the network connection |
| 35 | + */ |
| 36 | + String getConnectionId(); |
| 37 | + |
| 38 | + /** |
| 39 | + * Obtain a unique (within the lifetime of the JVM) identifier string for the {@code ServletRequest} from which this |
| 40 | + * {@code ServletConnection} was obtained. |
| 41 | + * <p> |
| 42 | + * There is no defined format for this string. The format is implementation dependent. |
| 43 | + * |
| 44 | + * @return A unique identifier for the servlet request |
| 45 | + */ |
| 46 | + String getRequestId(); |
| 47 | + |
| 48 | + /** |
| 49 | + * Obtain the name of the protocol as presented to the JVM after the removal, if present, of any TLS encryption. This |
| 50 | + * may not be the same as the protocol seen by the application. For example, a reverse proxy may present AJP whereas the |
| 51 | + * application will see HTTP 1.1. |
| 52 | + * <p> |
| 53 | + * If the protocol has an entry in the <a href= |
| 54 | + * "https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids">IANA |
| 55 | + * registry for ALPN names then the identification sequence, in string form, must be returned. Registered identification |
| 56 | + * sequences MUST only be used for the associated protocol. Return values for other protocols are implementation |
| 57 | + * dependent. Unknown protocols should return the string "unknown". |
| 58 | + * |
| 59 | + * @return The name of the protocol presented to the JVM after decryption of TLS, if any. |
| 60 | + */ |
| 61 | + String getProtocol(); |
| 62 | + |
| 63 | + /** |
| 64 | + * Obtain the connection identifier for the network connection to the JVM that is being used for the |
| 65 | + * {@code ServletRequest} from which this {@code ServletConnection} was obtained as defined by the protocol in use. Note |
| 66 | + * that some protocols do not define such an identifier. |
| 67 | + * |
| 68 | + * @return The connection identifier if one is defined, otherwise an empty string |
| 69 | + */ |
| 70 | + String getProtocolConnectionId(); |
| 71 | + |
| 72 | + /** |
| 73 | + * Obtain the request identifier for the {@code ServletRequest} from which this {@code ServletConnection} was obtained |
| 74 | + * as defined by the protocol in use. Note that some protocols do not define such an identifier. |
| 75 | + * |
| 76 | + * @return The request identifier if one is defined, otherwise an empty string |
| 77 | + */ |
| 78 | + String getProtocolRequestId(); |
| 79 | + |
| 80 | + /** |
| 81 | + * Determine whether or not the incoming network connection to the JVM used TLS or not. Note that where a reverse proxy |
| 82 | + * is used, the application may have a different view as to whether TLS is being used due to the use of headers like |
| 83 | + * {@code X-Forwarded-Proto} |
| 84 | + * |
| 85 | + * @return {@code true} if the incoming network connection used TLS, otherwise {@code false} |
| 86 | + */ |
| 87 | + boolean getTLS(); |
| 88 | +} |
0 commit comments