View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.eclipse.aether.transport.jdk;
20  
21  import org.eclipse.aether.ConfigurationProperties;
22  import org.eclipse.aether.RepositorySystemSession;
23  
24  /**
25   * JDK Transport configuration keys.
26   *
27   * @since 2.0.0
28   */
29  public final class JdkTransporterConfigurationKeys {
30      private JdkTransporterConfigurationKeys() {}
31  
32      private static final String CONFIG_PROPS_PREFIX =
33              ConfigurationProperties.PREFIX_TRANSPORT + JdkTransporterFactory.NAME + ".";
34  
35      /**
36       * Use string representation of HttpClient version enum "HTTP_2" or "HTTP_1_1" to set default HTTP protocol to use.
37       *
38       * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
39       * @configurationType {@link java.lang.String}
40       * @configurationDefaultValue {@link #DEFAULT_HTTP_VERSION}
41       * @configurationRepoIdSuffix Yes
42       * @deprecated Use {@link ConfigurationProperties#HTTP_VERSION} instead. This property is kept for backward compatibility and will be removed in future versions.
43       */
44      @Deprecated
45      public static final String CONFIG_PROP_HTTP_VERSION = CONFIG_PROPS_PREFIX + "httpVersion";
46  
47      public static final String DEFAULT_HTTP_VERSION = "HTTP_1_1";
48  
49      /**
50       * The hard limit of maximum concurrent requests JDK transport can do. This is a workaround for the fact, that in
51       * HTTP/2 mode, JDK HttpClient initializes this value to Integer.MAX_VALUE (!) and lowers it on first response
52       * from the remote server (but it may be too late). See JDK bug
53       * <a href="https://bugs.openjdk.org/browse/JDK-8225647">JDK-8225647</a> for details.
54       *
55       * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
56       * @configurationType {@link java.lang.Integer}
57       * @configurationDefaultValue {@link #DEFAULT_MAX_CONCURRENT_REQUESTS}
58       * @configurationRepoIdSuffix Yes
59       */
60      public static final String CONFIG_PROP_MAX_CONCURRENT_REQUESTS = CONFIG_PROPS_PREFIX + "maxConcurrentRequests";
61  
62      public static final int DEFAULT_MAX_CONCURRENT_REQUESTS = 100;
63  
64      /**
65       * If enabled, restores the legacy behavior where the transporter's {@link java.net.Authenticator} handed out
66       * the repository (or proxy) credentials to any host that issued an authentication challenge - including hosts
67       * reached by following a redirect off the repository. When disabled (the default), credentials are only
68       * returned when the challenging origin (protocol, host and port) matches the repository base URI, or, for
69       * proxy challenges, the configured proxy address.
70       *
71       * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
72       * @configurationType {@link java.lang.Boolean}
73       * @configurationDefaultValue {@link #DEFAULT_UNSCOPED_AUTHENTICATION}
74       * @configurationRepoIdSuffix Yes
75       * @since 2.0.23
76       */
77      public static final String CONFIG_PROP_UNSCOPED_AUTHENTICATION = CONFIG_PROPS_PREFIX + "unscopedAuthentication";
78  
79      public static final boolean DEFAULT_UNSCOPED_AUTHENTICATION = false;
80  
81      /**
82       * If enabled (default), operator-configured request headers ({@code aether.transport.http.headers}) and
83       * preemptively applied {@code Authorization} are only sent on requests targeting the repository origin (the
84       * scheme, host and port the repository URL denotes). The JDK {@link java.net.http.HttpClient} re-sends all
85       * user-set headers on every redirect hop it follows - including hops that leave the repository origin - so
86       * with this enabled the transporter configures the client with {@code Redirect.NEVER} and follows redirects
87       * itself, dropping those headers on any hop that leaves the origin. Disable only when a redirect target
88       * legitimately requires the configured headers; disabling restores the JDK client's own redirect handling
89       * ({@code Redirect.NORMAL}) and the legacy header replay.
90       *
91       * @configurationSource {@link RepositorySystemSession#getConfigProperties()}
92       * @configurationType {@link java.lang.Boolean}
93       * @configurationDefaultValue {@link #DEFAULT_ORIGIN_SCOPED_HEADERS}
94       * @configurationRepoIdSuffix Yes
95       * @since 2.0.23
96       */
97      public static final String CONFIG_PROP_ORIGIN_SCOPED_HEADERS = CONFIG_PROPS_PREFIX + "originScopedHeaders";
98  
99      public static final boolean DEFAULT_ORIGIN_SCOPED_HEADERS = true;
100 }