-
Notifications
You must be signed in to change notification settings - Fork 31
Switch to Java 21 build #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
openam-certs/src/main/java/com/sun/identity/security/cert/JdkProviderUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * The contents of this file are subject to the terms of the Common Development and | ||
| * Distribution License (the License). You may not use this file except in compliance with the | ||
| * License. | ||
| * | ||
| * You can obtain a copy of the License at legal/CDDLv1.1.txt. See the License for the | ||
| * specific language governing permission and limitations under the License. | ||
| * | ||
| * When distributing Covered Software, include this CDDL Header Notice in each file and include | ||
| * the License file at legal/CDDLv1.1.txt. If applicable, add the following below the CDDL | ||
| * Header, with the fields enclosed by brackets [] replaced by your own identifying | ||
| * information: "Portions copyright [year] [name of copyright owner]". | ||
| * | ||
| * Copyright Wren Security 2025 | ||
| */ | ||
| package com.sun.identity.security.cert; | ||
|
|
||
| import java.lang.reflect.Method; | ||
| import java.util.List; | ||
| import sun.security.x509.CRLDistributionPointsExtension; | ||
| import sun.security.x509.CertificateExtensions; | ||
| import sun.security.x509.DistributionPoint; | ||
| import sun.security.x509.GeneralNames; | ||
| import sun.security.x509.SubjectAlternativeNameExtension; | ||
| import sun.security.x509.X509CertInfo; | ||
|
|
||
| /** | ||
| * Utility methods for maintaining compatibility with older supported JDK versions. | ||
| */ | ||
| public final class JdkProviderUtils { | ||
|
|
||
| private static final int JAVA_VERSION = Runtime.version().feature(); | ||
|
|
||
| public static List<DistributionPoint> getDistributionPoints(CRLDistributionPointsExtension extension) throws Exception { | ||
| if (JAVA_VERSION < 20) { | ||
| Method getter = CRLDistributionPointsExtension.class.getMethod("get", String.class); | ||
| return (List<DistributionPoint>) getter.invoke(extension, "points"); | ||
| } | ||
| return extension.getDistributionPoints(); | ||
| } | ||
|
|
||
| public static CertificateExtensions getExtensions(X509CertInfo certInfo) throws Exception { | ||
| if (JAVA_VERSION < 20) { | ||
| Method getter = X509CertInfo.class.getMethod("get", String.class); | ||
| return (CertificateExtensions) getter.invoke(certInfo, X509CertInfo.EXTENSIONS); | ||
| } | ||
| return certInfo.getExtensions(); | ||
| } | ||
|
|
||
| public static SubjectAlternativeNameExtension getSanExtension(CertificateExtensions extensions) throws Exception { | ||
| if (JAVA_VERSION < 20) { | ||
| Method getter = CertificateExtensions.class.getMethod("get", String.class); | ||
| return (SubjectAlternativeNameExtension) getter.invoke(extensions, SubjectAlternativeNameExtension.NAME); | ||
| } | ||
| return (SubjectAlternativeNameExtension) extensions.getExtension(SubjectAlternativeNameExtension.NAME); | ||
| } | ||
|
|
||
| public static GeneralNames getSubjectNames(SubjectAlternativeNameExtension extension) throws Exception { | ||
| if (JAVA_VERSION < 20) { | ||
| Method getter = SubjectAlternativeNameExtension.class.getMethod("get", String.class); | ||
| return (GeneralNames) getter.invoke(extension, "subject_name"); | ||
| } | ||
| return extension.getNames(); | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach will not suffice. The new X509 implementation has been backported to Java 17 releases as well. We will need to go the "full reflection" path.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was not able to find any mention of this being changed / backported. Strange that I am getting linking error with Java 17 - https://github.com/WrenSecurity/wrenam/actions/runs/16508743719/job/46685928744
The difference in JVM is:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, it is there https://bugs.openjdk.org/browse/JDK-8296072. Even backported to Oracle's Java 11.