Skip to content

Commit

Permalink
merge of the actual 3.x into 3.1 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
senivam authored Apr 18, 2023
2 parents aa7253a + 8bd08b2 commit 71aedfc
Show file tree
Hide file tree
Showing 413 changed files with 4,907 additions and 810 deletions.
8 changes: 4 additions & 4 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ aopalliance Version 1
* Project: http://aopalliance.sourceforge.net
* Copyright: Material in the public domain is not protected by copyright

Bean Validation API 3.0.0
Bean Validation API 3.0.2
* License: Apache License, 2.0
* Project: https://projects.eclipse.org/projects/ee4j.bean-validation
* Copyright: 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag.

Hibernate Validator CDI, 7.0.0.Final
Hibernate Validator CDI, 8.0.0.Final
* License: Apache License, 2.0
* Project: https://beanvalidation.org/
* Repackaged in org.glassfish.jersey.server.validation.internal.hibernate
Expand All @@ -65,7 +65,7 @@ jakarta.inject Version: 1
* License: Apache License, 2.0
* Copyright (C) 2009 The JSR-330 Expert Group

Javassist Version 3.25.0-GA
Javassist Version 3.29.0-GA
* License: Apache License, 2.0
* Project: http://www.javassist.org/
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
Expand Down Expand Up @@ -95,7 +95,7 @@ KineticJS, v4.7.1
* Project: http://www.kineticjs.com, https://github.com/ericdrowell/KineticJS
* Copyright: Eric Rowell

org.objectweb.asm Version 9.3
org.objectweb.asm Version 9.4
* License: Modified BSD (https://asm.ow2.io/license.html)
* Copyright (c) 2000-2011 INRIA, France Telecom. All rights reserved.

Expand Down
2 changes: 1 addition & 1 deletion archetypes/jersey-example-java8-webapp/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2015, 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
</profiles>

<properties>
<java.version>1.8</java.version>
<java.version>11</java.version>
<jersey.config.test.container.port>8080</jersey.config.test.container.port>
</properties>
</project>
2 changes: 1 addition & 1 deletion archetypes/jersey-heroku-webapp/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,19 @@
<war>\${project.build.directory}/\${project.build.finalName}.war</war>
</configuration>
</plugin>
<plugin>
<!-- Surefire support for JUnit-5 -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.mvn.plugin.version}</version>
</plugin>
</plugins>
</build>

<properties>
<jersey.version>${project.version}</jersey.version>
<jetty.version>11.0.14</jetty.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jetty.version>11.0.0.beta3</jetty.version>
<surefire.mvn.plugin.version>3.0.0-M7</surefire.mvn.plugin.version>
</properties>
</project>
2 changes: 1 addition & 1 deletion archetypes/jersey-quickstart-grizzly2/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,19 @@
<mainClass>\${package}.Main</mainClass>
</configuration>
</plugin>
<plugin>
<!-- Surefire support for JUnit-5 -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.mvn.plugin.version}</version>
</plugin>
</plugins>
</build>

<properties>
<jersey.version>${project.version}</jersey.version>
<junit-jupiter.version>5.9.1</junit-jupiter.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<surefire.mvn.plugin.version>3.0.0-M7</surefire.mvn.plugin.version>
</properties>
</project>
2 changes: 1 addition & 1 deletion archetypes/jersey-quickstart-webapp/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
2 changes: 1 addition & 1 deletion archetypes/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
6 changes: 3 additions & 3 deletions bundles/apidocs/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -63,12 +63,12 @@
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-apache-connector</artifactId>
<version>${project.version}</version>
<exclusions>
<!--<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</exclusions>-->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
Expand Down
2 changes: 1 addition & 1 deletion bundles/examples/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
2 changes: 1 addition & 1 deletion bundles/jaxrs-ri/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
2 changes: 1 addition & 1 deletion bundles/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
14 changes: 1 addition & 13 deletions connectors/apache-connector/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2011, 2023 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -40,18 +40,6 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons.codec.version}</version>
<scope>test</scope>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.URI;
import java.util.ArrayList;
import java.util.LinkedList;
Expand All @@ -46,13 +47,15 @@

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;

import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.ClientRequest;
import org.glassfish.jersey.client.ClientResponse;
import org.glassfish.jersey.client.RequestEntityProcessing;
import org.glassfish.jersey.client.innate.ClientProxy;
import org.glassfish.jersey.client.innate.http.SSLParamConfigurator;
import org.glassfish.jersey.client.spi.AsyncConnectorCallback;
import org.glassfish.jersey.client.spi.Connector;
import org.glassfish.jersey.internal.util.PropertiesHelper;
Expand Down Expand Up @@ -103,6 +106,7 @@
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.impl.io.ChunkedOutputStream;
import org.apache.http.io.SessionOutputBuffer;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.TextUtils;
import org.apache.http.util.VersionInfo;

Expand Down Expand Up @@ -180,6 +184,7 @@
class ApacheConnector implements Connector {

private static final Logger LOGGER = Logger.getLogger(ApacheConnector.class.getName());
private static final String JERSEY_REQUEST_ATTR_NAME = "JerseyRequestAttribute";
private static final VersionInfo vi;
private static final String release;

Expand Down Expand Up @@ -255,10 +260,16 @@ class ApacheConnector implements Connector {
}
}

final boolean useSystemProperties =
PropertiesHelper.isProperty(config.getProperties(), ApacheClientProperties.USE_SYSTEM_PROPERTIES);

final SSLContext sslContext = client.getSslContext();
final HttpClientBuilder clientBuilder = HttpClientBuilder.create();

clientBuilder.setConnectionManager(getConnectionManager(client, config, sslContext));
if (useSystemProperties) {
clientBuilder.useSystemProperties();
}
clientBuilder.setConnectionManager(getConnectionManager(client, config, sslContext, useSystemProperties));
clientBuilder.setConnectionManagerShared(
PropertiesHelper.getValue(config.getProperties(), ApacheClientProperties.CONNECTION_MANAGER_SHARED, false, null));
clientBuilder.setSSLContext(sslContext);
Expand Down Expand Up @@ -337,7 +348,8 @@ class ApacheConnector implements Connector {

private HttpClientConnectionManager getConnectionManager(final Client client,
final Configuration config,
final SSLContext sslContext) {
final SSLContext sslContext,
final boolean useSystemProperties) {
final Object cmObject = config.getProperties().get(ApacheClientProperties.CONNECTION_MANAGER);

// Connection manager from configuration.
Expand All @@ -355,9 +367,6 @@ private HttpClientConnectionManager getConnectionManager(final Client client,
}
}

final boolean useSystemProperties =
PropertiesHelper.isProperty(config.getProperties(), ApacheClientProperties.USE_SYSTEM_PROPERTIES);

// Create custom connection manager.
return createConnectionManager(
client,
Expand All @@ -381,15 +390,15 @@ private HttpClientConnectionManager createConnectionManager(

final LayeredConnectionSocketFactory sslSocketFactory;
if (sslContext != null) {
sslSocketFactory = new SSLConnectionSocketFactory(
sslSocketFactory = new SniSSLConnectionSocketFactory(
sslContext, supportedProtocols, supportedCipherSuites, hostnameVerifier);
} else {
if (useSystemProperties) {
sslSocketFactory = new SSLConnectionSocketFactory(
sslSocketFactory = new SniSSLConnectionSocketFactory(
(SSLSocketFactory) SSLSocketFactory.getDefault(),
supportedProtocols, supportedCipherSuites, hostnameVerifier);
} else {
sslSocketFactory = new SSLConnectionSocketFactory(
sslSocketFactory = new SniSSLConnectionSocketFactory(
SSLContexts.createDefault(),
hostnameVerifier);
}
Expand Down Expand Up @@ -450,14 +459,16 @@ public CookieStore getCookieStore() {
public ClientResponse apply(final ClientRequest clientRequest) throws ProcessingException {
final HttpUriRequest request = getUriHttpRequest(clientRequest);
final Map<String, String> clientHeadersSnapshot = writeOutBoundHeaders(clientRequest, request);
final HttpHost httpHost = getHost(request);

try {
final CloseableHttpResponse response;
final HttpClientContext context = HttpClientContext.create();

if (preemptiveBasicAuth) {
final AuthCache authCache = new BasicAuthCache();
final BasicScheme basicScheme = new BasicScheme();
authCache.put(getHost(request), basicScheme);
authCache.put(httpHost, basicScheme);
context.setAuthCache(authCache);
}

Expand All @@ -468,7 +479,8 @@ public ClientResponse apply(final ClientRequest clientRequest) throws Processing
context.setCredentialsProvider(credentialsProvider);
}

response = client.execute(getHost(request), request, context);
context.setAttribute(JERSEY_REQUEST_ATTR_NAME, clientRequest);
response = client.execute(httpHost, request, context);
HeaderUtils.checkHeaderChanges(clientHeadersSnapshot, clientRequest.getHeaders(),
this.getClass().getName(), clientRequest.getConfiguration());

Expand Down Expand Up @@ -821,4 +833,56 @@ protected OutputStream createOutputStream(final long len, final SessionOutputBuf
return super.createOutputStream(len, outbuffer);
}
}

private static final class SniSSLConnectionSocketFactory extends SSLConnectionSocketFactory {

private final ThreadLocal<HttpContext> httpContexts = new ThreadLocal<>();

public SniSSLConnectionSocketFactory(final SSLContext sslContext,
final String[] supportedProtocols,
final String[] supportedCipherSuites,
final HostnameVerifier hostnameVerifier) {
super(sslContext, supportedProtocols, supportedCipherSuites, hostnameVerifier);
}

public SniSSLConnectionSocketFactory(final javax.net.ssl.SSLSocketFactory socketFactory,
final String[] supportedProtocols,
final String[] supportedCipherSuites,
final HostnameVerifier hostnameVerifier) {
super(socketFactory, supportedProtocols, supportedCipherSuites, hostnameVerifier);
}

public SniSSLConnectionSocketFactory(
final SSLContext sslContext, final HostnameVerifier hostnameVerifier) {
super(sslContext, hostnameVerifier);
}

@Override
public Socket createLayeredSocket(
final Socket socket,
final String target,
final int port,
final HttpContext context) throws IOException {
httpContexts.set(context);
try {
return super.createLayeredSocket(socket, target, port, context);
} finally {
httpContexts.remove();
}
}

@Override
protected void prepareSocket(SSLSocket socket) throws IOException {
HttpContext context = httpContexts.get();

if (context != null) {
Object objectRequest = context.getAttribute(JERSEY_REQUEST_ATTR_NAME);
if (objectRequest != null) {
ClientRequest clientRequest = (ClientRequest) objectRequest;
SSLParamConfigurator sniConfig = SSLParamConfigurator.builder().request(clientRequest).build();
sniConfig.setSNIServerName(socket);
}
}
}
}
}
Loading

0 comments on commit 71aedfc

Please sign in to comment.