Skip to content

Commit aedab4c

Browse files
gl-johnsonGitHub Enterprise
authored andcommitted
Merge pull request #17 from Conjur-Enterprise/CNJR-7854
CNJR-7854: Restore JDK8 compatibility
2 parents c156af3 + b7ed4b8 commit aedab4c

File tree

15 files changed

+93
-74
lines changed

15 files changed

+93
-74
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## [3.0.6] - 2024-02-20
10+
11+
### Fixed
12+
- Restored compatibility with Java 8 (CNJR-7854)
13+
914
## [3.0.5] - 2023-06-08
1015

1116
### Fixed

Dockerfile.test

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
FROM openjdk:23-slim
1+
ARG JDK_VERSION=23
2+
3+
FROM eclipse-temurin:${JDK_VERSION}-jdk
24

35
MAINTAINER Conjur Inc
46

57
RUN export DEBIAN_FRONTEND=noninteractive && \
68
apt-get update && \
7-
apt-get install -y vim wget curl git maven
8-
9-
RUN mkdir -p /conjurinc/api-java
9+
apt-get install -y --no-install-recommends vim wget curl git maven && \
10+
rm -rf /var/lib/apt/lists/*
1011

1112
WORKDIR /conjurinc/api-java
1213

13-
COPY . /conjurinc/api-java
14+
COPY . .
1415

15-
RUN mvn compile
16+
RUN mvn compile

Jenkinsfile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,31 @@ pipeline {
125125
}
126126
}
127127

128-
stage('Run tests and archive test results') {
128+
stage('Run tests (JDK8)') {
129129
environment {
130130
INFRAPOOL_REGISTRY_URL = "registry.tld"
131+
INFRAPOOL_JDK_VERSION = "8"
132+
}
133+
steps {
134+
script {
135+
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh './bin/test.sh'
136+
}
137+
}
138+
}
139+
140+
stage('Run tests and archive results (JDK23)') {
141+
environment {
142+
INFRAPOOL_REGISTRY_URL = "registry.tld"
143+
INFRAPOOL_JDK_VERSION = "23"
131144
}
132145
steps {
133146
script {
134147
lock("api-java-${env.NODE_NAME}") {
135148
INFRAPOOL_EXECUTORV2_AGENT_0.agentSh './bin/test.sh'
136-
INFRAPOOL_EXECUTORV2_AGENT_0.agentStash includes: 'target/surefire-reports/*.xml', name: 'test-results'
149+
INFRAPOOL_EXECUTORV2_AGENT_0.agentStash includes: 'target/surefire-reports/*.xml', name: "test-results"
137150
unstash 'test-results'
138151
}
139152
}
140-
141153
junit 'target/surefire-reports/*.xml'
142154
}
143155
}

bin/build-tools-image.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
set -euo pipefail
44

5-
# Build tools image
6-
#FROM maven:${maven_version}-openjdk-${java_version}-slim
5+
# This container is used to package the library - leave the Java version arg at
6+
# 8 to ensure we support Java 8 which has LTS until 2030
77
docker build \
8-
--build-arg maven_version=3.8.4 \
9-
--build-arg java_version=11 \
8+
--build-arg maven_version=3 \
9+
--build-arg java_version=8 \
1010
-t tools \
1111
-f tools.Dockerfile \
1212
.

bin/test.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ source bin/utils.sh
66
trap finish EXIT
77

88
export REGISTRY_URL=${INFRAPOOL_REGISTRY_URL:-"docker.io"}
9+
export JDK_VERSION=${INFRAPOOL_JDK_VERSION:-8}
910

1011
function main() {
1112
finish
@@ -33,7 +34,7 @@ function runOss () {
3334

3435
# Build DAP test container & start the cluster
3536
function createDAPTestEnvironment() {
36-
docker compose build --pull client cuke-master test-dap
37+
docker compose build --pull client cuke-master test-dap --build-arg JDK_VERSION="${JDK_VERSION:-8}"
3738
export CONJUR_APPLIANCE_URL="https://cuke-master"
3839
docker compose up -d client cuke-master test-dap
3940

@@ -94,6 +95,13 @@ function initializeDapCert() {
9495

9596
# Import cert converted above into keystore
9697
JAVA_PATH=$(docker exec ${dap_test_cid} sh -c 'echo $JAVA_HOME')
98+
99+
# If Java 8, append /jre to the path
100+
JAVA_VERSION=$(docker exec ${dap_test_cid} sh -c '$JAVA_HOME/bin/java -version 2>&1 | head -n 1')
101+
if [[ "$JAVA_VERSION" == *"1.8"* ]]; then
102+
JAVA_PATH="${JAVA_PATH}/jre"
103+
fi
104+
97105
import_command="keytool \
98106
-import \
99107
-alias cuke-master -v \

bin/utils.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function createOssEnvironment() {
66
echo '------------------------------------------------------------'
77

88
# Build OSS test container & start the cluster
9-
docker compose build --pull client conjur postgres test test-https conjur-proxy-nginx
9+
docker compose build --pull client conjur postgres test test-https conjur-proxy-nginx --build-arg JDK_VERSION="${JDK_VERSION:-8}"
1010
export CONJUR_APPLIANCE_URL="http://conjur"
1111
docker compose up -d client conjur postgres test-https
1212

@@ -81,6 +81,13 @@ function initializeOssCert() {
8181

8282
# Import cert converted above into keystore
8383
JAVA_PATH=$(docker exec ${conjur_test_cid} sh -c 'echo $JAVA_HOME')
84+
85+
# If Java 8, append /jre to the path
86+
JAVA_VERSION=$(docker exec ${dap_test_cid} sh -c '$JAVA_HOME/bin/java -version 2>&1 | head -n 1')
87+
if [[ "$JAVA_VERSION" == *"1.8"* ]]; then
88+
JAVA_PATH="${JAVA_PATH}/jre"
89+
fi
90+
8491
import_command="keytool \
8592
-import \
8693
-alias cucumber \

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ services:
5858
build:
5959
context: .
6060
dockerfile: Dockerfile.test
61+
args:
62+
JDK_VERSION: ${JDK_VERSION:-8}
6163
volumes:
6264
- ./target:/conjurinc/api-java/target
6365
environment:
@@ -69,6 +71,8 @@ services:
6971
build:
7072
context: .
7173
dockerfile: Dockerfile.test
74+
args:
75+
JDK_VERSION: ${JDK_VERSION:-8}
7276
volumes:
7377
- ./target:/conjurinc/api-java/target
7478
- ./test-cert:/test-cert
@@ -84,6 +88,8 @@ services:
8488
build:
8589
context: .
8690
dockerfile: Dockerfile.test
91+
args:
92+
JDK_VERSION: ${JDK_VERSION:-8}
8793
volumes:
8894
- ./target:/conjurinc/api-java/target
8995
- ./test-cert:/test-cert

pom.xml

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -150,34 +150,23 @@
150150

151151
<properties>
152152
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
153+
<jaxrs.version>2.1.1</jaxrs.version>
153154
</properties>
154155
<dependencies>
155-
156-
<!-- JAXRS Implementation -->
157-
<dependency>
158-
<groupId>jakarta.ws.rs</groupId>
159-
<artifactId>jakarta.ws.rs-api</artifactId>
160-
<version>3.1.0</version>
161-
</dependency>
162-
<dependency>
163-
<groupId>jakarta.activation</groupId>
164-
<artifactId>jakarta.activation-api</artifactId>
165-
<version>2.1.2</version>
166-
</dependency>
167-
<dependency>
168-
<groupId>org.glassfish.jersey.core</groupId>
169-
<artifactId>jersey-client</artifactId>
170-
<version>3.1.5</version>
171-
</dependency>
156+
<!--
157+
JAXRS Implementation
158+
You can change any of this, for example if you use Jersey 2.0 or a different implementation
159+
(codehaus has one, I think).
160+
-->
172161
<dependency>
173-
<groupId>org.glassfish.jersey.inject</groupId>
174-
<artifactId>jersey-hk2</artifactId>
175-
<version>3.1.5</version>
162+
<groupId>javax.ws.rs</groupId>
163+
<artifactId>javax.ws.rs-api</artifactId>
164+
<version>${jaxrs.version}</version>
176165
</dependency>
177166
<dependency>
178-
<groupId>org.glassfish.jersey.media</groupId>
179-
<artifactId>jersey-media-json-binding</artifactId>
180-
<version>3.1.2</version>
167+
<groupId>org.apache.cxf</groupId>
168+
<artifactId>cxf-rt-rs-client</artifactId>
169+
<version>3.5.10</version>
181170
</dependency>
182171

183172
<!-- JSON support -->
@@ -207,13 +196,6 @@
207196
<version>4.13.1</version>
208197
<scope>test</scope>
209198
</dependency>
210-
211-
<!-- must include JAXB manually post Java 9 -->
212-
<dependency>
213-
<groupId>jakarta.xml.bind</groupId>
214-
<artifactId>jakarta.xml.bind-api</artifactId>
215-
<version>4.0.1</version>
216-
</dependency>
217199
</dependencies>
218200

219201
<build>
@@ -231,15 +213,14 @@
231213
<plugin>
232214
<groupId>org.apache.maven.plugins</groupId>
233215
<artifactId>maven-surefire-plugin</artifactId>
234-
<version>2.20</version>
216+
<version>2.22.2</version>
235217
<configuration>
236218
<systemPropertyVariables>
237219
<CONJUR_ACCOUNT>${env.CONJUR_ACCOUNT}</CONJUR_ACCOUNT>
238220
<CONJUR_APPLIANCE_URL>${env.CONJUR_APPLIANCE_URL}</CONJUR_APPLIANCE_URL>
239221
<CONJUR_AUTHN_LOGIN>${env.CONJUR_AUTHN_LOGIN}</CONJUR_AUTHN_LOGIN>
240222
<CONJUR_AUTHN_API_KEY>${env.CONJUR_AUTHN_API_KEY}</CONJUR_AUTHN_API_KEY>
241223
</systemPropertyVariables>
242-
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED</argLine>
243224
</configuration>
244225
</plugin>
245226

src/main/java/com/cyberark/conjur/api/clients/AuthnClient.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import static com.cyberark.conjur.util.EncodeUriComponent.encodeUriComponent;
44

55
import javax.net.ssl.SSLContext;
6-
import jakarta.ws.rs.WebApplicationException;
7-
import jakarta.ws.rs.client.Client;
8-
import jakarta.ws.rs.client.ClientBuilder;
9-
import jakarta.ws.rs.client.Entity;
10-
import jakarta.ws.rs.client.WebTarget;
11-
import jakarta.ws.rs.core.Response;
6+
import javax.ws.rs.WebApplicationException;
7+
import javax.ws.rs.client.Client;
8+
import javax.ws.rs.client.ClientBuilder;
9+
import javax.ws.rs.client.Entity;
10+
import javax.ws.rs.client.WebTarget;
11+
import javax.ws.rs.core.Response;
1212

1313
import com.cyberark.conjur.api.AuthnProvider;
1414
import com.cyberark.conjur.api.Credentials;

src/main/java/com/cyberark/conjur/api/clients/ResourceClient.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.cyberark.conjur.api.clients;
22

33
import javax.net.ssl.SSLContext;
4-
import jakarta.ws.rs.WebApplicationException;
5-
import jakarta.ws.rs.client.Client;
6-
import jakarta.ws.rs.client.ClientBuilder;
7-
import jakarta.ws.rs.client.Entity;
8-
import jakarta.ws.rs.client.WebTarget;
9-
import jakarta.ws.rs.core.Response;
4+
import javax.ws.rs.WebApplicationException;
5+
import javax.ws.rs.client.Client;
6+
import javax.ws.rs.client.ClientBuilder;
7+
import javax.ws.rs.client.Entity;
8+
import javax.ws.rs.client.WebTarget;
9+
import javax.ws.rs.core.Response;
1010

1111
import com.cyberark.conjur.api.Credentials;
1212
import com.cyberark.conjur.api.Endpoints;

0 commit comments

Comments
 (0)