Skip to content

Commit

Permalink
KNOX-2923 - Support for JDK 17 (#762)
Browse files Browse the repository at this point in the history
* KNOX-2923 - Support for JDK 17

* KNOX-2923 - Fix issues with JDK 8 build and add JDK 17 support to knoxcli

* KNOX-2923 - Fix the error in CI/CD  -URI is not hierarchical

* KNOX-2923 - Fix an issue where maven builds were failing on JDK 8

* KNOX-2923 - Use jetbrains repo to fetch pty4j artifacts
  • Loading branch information
moresandeep authored Jun 26, 2023
1 parent 8f1fe56 commit 2886e70
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SimpleLdapServerTest {

@BeforeClass
public static void setUpBeforeClass() throws Exception {
ldifFile = new File( ClassLoader.getSystemResource( "users.ldif" ).toURI() );
ldifFile = new File( SimpleLdapServerTest.class.getResource( "/users.ldif" ).toURI());
ldapTransport = new TcpTransport( 0 );
ldap = new SimpleLdapDirectoryServer( "dc=hadoop,dc=apache,dc=org", ldifFile, ldapTransport );
ldap.start();
Expand Down
29 changes: 29 additions & 0 deletions gateway-demo-ldap/src/test/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<Configuration>
<Appenders>
<Console name="stdout" target="SYSTEM_OUT">
<PatternLayout pattern="%d{ISO8601} %-5p %m%n" />
</Console>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="stdout"/>
</Root>
</Loggers>
</Configuration>
44 changes: 44 additions & 0 deletions gateway-demo-ldap/src/test/resources/users.ldif
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: 1

dn: dc=hadoop,dc=apache,dc=org
objectclass: organization
objectclass: dcObject
o: Hadoop at Apache.org
dc: hadoop
description: Makers of Hadoop

# entry for a sample people container
# please replace with site specific values
dn: ou=people,dc=hadoop,dc=apache,dc=org
objectclass:top
objectclass:organizationalUnit
ou: people

# entry for a sample end user
# please replace with site specific values
dn: uid=guest,ou=people,dc=hadoop,dc=apache,dc=org
objectclass:top
objectclass:person
objectclass:organizationalPerson
objectclass:inetOrgPerson
cn: Guest
sn: User
uid: guest
userPassword:guest-password

8 changes: 8 additions & 0 deletions gateway-release-common/home/bin/knox-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ function buildAppJavaOpts {
addAppJavaOpts "${APP_JAVA_LIB_PATH}"
fi

# Add properties to enable Knox to run on JDK 17
JAVA_VERSION=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
CHECK_VERSION_17="17"
if [[ "$JAVA_VERSION" == *"$CHECK_VERSION_17"* ]]; then
echo "Java version is $CHECK_VERSION_17. Adding properties to enable Knox to run on JDK 17"
addAppJavaOpts " --add-exports java.base/sun.security.x509=ALL-UNNAMED --add-exports java.base/sun.security.pkcs=ALL-UNNAMED --add-exports java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens java.base/sun.security.util=ALL-UNNAMED"
fi

# echo "APP_JAVA_OPTS =" "${APP_JAVA_OPTS[@]}"
}

Expand Down
8 changes: 8 additions & 0 deletions gateway-release/home/bin/knoxcli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ function buildAppJavaOpts {
addAppJavaOpts "${APP_JAVA_LIB_PATH}"
fi

# Add properties to enable Knox to run on JDK 17
JAVA_VERSION=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
CHECK_VERSION_17="17"
if [[ "$JAVA_VERSION" == *"$CHECK_VERSION_17"* ]]; then
echo "Java version is $CHECK_VERSION_17. Adding properties to enable Knox to run on JDK 17"
addAppJavaOpts " --add-exports java.base/sun.security.x509=ALL-UNNAMED --add-exports java.base/sun.security.pkcs=ALL-UNNAMED --add-exports java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens java.base/sun.security.util=ALL-UNNAMED"
fi

# echo "APP_JAVA_OPTS =" "${APP_JAVA_OPTS[@]}"
}

Expand Down
6 changes: 6 additions & 0 deletions gateway-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,12 @@
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>

<dependency>
<groupId>org.apache.knox</groupId>
<artifactId>gateway-util-configinjector</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static X509Certificate generateCertificate(String dn, KeyPair pair, int d

// AlgorithmId algo = new AlgorithmId(AlgorithmId.md5WithRSAEncryption_oid);
Class<?> algorithmIdClass = Class.forName(getAlgorithmIdModuleName());
Field md5WithRSAField = algorithmIdClass.getDeclaredField("md5WithRSAEncryption_oid");
Field md5WithRSAField = algorithmIdClass.getDeclaredField("RSAEncryption_oid");
md5WithRSAField.setAccessible(true);
Class<?> objectIdentifierClass = Class.forName(getObjectIdentifierModuleName());

Expand Down
12 changes: 9 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@
<protobuf.version>3.16.3</protobuf.version>
<powermock.version>2.0.9</powermock.version>
<purejavacomm.version>0.0.11.1</purejavacomm.version>
<!-- After JDK 11 we can use 0.12.4 from maven central -->
<pty4j.version>0.11.4</pty4j.version>
<rest-assured.version>4.3.3</rest-assured.version>
<shiro.version>1.10.0</shiro.version>
Expand Down Expand Up @@ -288,9 +289,9 @@
</properties>
<repositories>
<repository>
<id>jcenter</id>
<name>jcenter</name>
<url>https://jcenter.bintray.com</url>
<id>jetbrains-pty4j</id>
<name>jetbrains-intellij-dependencies</name>
<url>https://packages.jetbrains.team/maven/p/ij/intellij-dependencies</url>
</repository>
</repositories>
<profiles>
Expand Down Expand Up @@ -400,6 +401,7 @@
</profile>
</profiles>


<build>
<pluginManagement>
<plugins>
Expand Down Expand Up @@ -524,6 +526,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- For JDK 17 builds uncomment the following lines, make sure to remove space between - - (double dash) -->
<!--
<argLine>@{argLine} - -add-exports java.base/sun.security.x509=ALL-UNNAMED - -add-exports java.base/sun.security.pkcs=ALL-UNNAMED - - add-exports java.naming/com.sun.jndi.ldap=ALL-UNNAMED - -add-opens java.base/sun.security.util=ALL-UNNAMED</argLine>
-->
<excludedGroups>
org.apache.knox.test.category.SlowTests,org.apache.knox.test.category.ManualTests,org.apache.knox.test.category.VerifyTest,org.apache.knox.test.category.ReleaseTest
</excludedGroups>
Expand Down

0 comments on commit 2886e70

Please sign in to comment.