-
Notifications
You must be signed in to change notification settings - Fork 3
feat(sdk): replace ayza libraries with TrustProvider on JCA #366
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
Draft
mkleene
wants to merge
17
commits into
main
Choose a base branch
from
remove-ayza
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
baf0b02
remove bouncycastle
mkleene d0f1d76
remove bouncycastle
mkleene 12aa78b
Merge remote-tracking branch 'origin/remove-bouncycastle' into remove…
mkleene a7991ca
we do not need this
mkleene 21fd9fb
centralize PEM parsing logic
mkleene dcb5d17
remove unused imports
mkleene 9c79376
Apply suggestion from @gemini-code-assist[bot]
mkleene c689eb8
extract constant
mkleene 1a34351
Merge remote-tracking branch 'origin/remove-bouncycastle' into remove…
mkleene df105d0
rename
mkleene 8247667
feat(sdk): replace ayza libraries with TrustProvider on JCA
mkleene 5b74337
sonarcloud
mkleene 1a573c7
Merge branch 'remove-bouncycastle' into remove-ayza
mkleene 6fc81f1
fix provider stuff
mkleene 827a5c3
make sure we get the right provider in tests
mkleene 6905740
Merge branch 'remove-bouncycastle' into remove-ayza
mkleene d8a14d5
try this way
mkleene 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
122 changes: 122 additions & 0 deletions
122
sdk/src/main/java/io/opentdf/platform/sdk/CompositeX509ExtendedTrustManager.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,122 @@ | ||
| package io.opentdf.platform.sdk; | ||
|
|
||
| import javax.net.ssl.SSLEngine; | ||
| import javax.net.ssl.X509ExtendedTrustManager; | ||
| import java.net.Socket; | ||
| import java.security.cert.CertificateException; | ||
| import java.security.cert.X509Certificate; | ||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.LinkedHashSet; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
| final class CompositeX509ExtendedTrustManager extends X509ExtendedTrustManager { | ||
|
|
||
| private final List<X509ExtendedTrustManager> delegates; | ||
| private final X509Certificate[] acceptedIssuers; | ||
|
|
||
| CompositeX509ExtendedTrustManager(List<X509ExtendedTrustManager> delegates) { | ||
| if (delegates == null || delegates.isEmpty()) { | ||
| throw new IllegalArgumentException("at least one trust manager is required"); | ||
| } | ||
| this.delegates = Collections.unmodifiableList(new ArrayList<>(delegates)); | ||
| Set<X509Certificate> issuers = new LinkedHashSet<>(); | ||
| for (X509ExtendedTrustManager tm : this.delegates) { | ||
| X509Certificate[] tmIssuers = tm.getAcceptedIssuers(); | ||
| if (tmIssuers != null) { | ||
| Collections.addAll(issuers, tmIssuers); | ||
| } | ||
| } | ||
| this.acceptedIssuers = issuers.toArray(new X509Certificate[0]); | ||
| } | ||
|
|
||
| @Override | ||
| public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { | ||
| CertificateException last = null; | ||
| for (X509ExtendedTrustManager tm : delegates) { | ||
| try { | ||
| tm.checkClientTrusted(chain, authType); | ||
| return; | ||
| } catch (CertificateException e) { | ||
| last = e; | ||
| } | ||
| } | ||
| throw last; | ||
| } | ||
|
|
||
| @Override | ||
| public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException { | ||
| CertificateException last = null; | ||
| for (X509ExtendedTrustManager tm : delegates) { | ||
| try { | ||
| tm.checkClientTrusted(chain, authType, socket); | ||
| return; | ||
| } catch (CertificateException e) { | ||
| last = e; | ||
| } | ||
| } | ||
| throw last; | ||
| } | ||
|
|
||
| @Override | ||
| public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException { | ||
| CertificateException last = null; | ||
| for (X509ExtendedTrustManager tm : delegates) { | ||
| try { | ||
| tm.checkClientTrusted(chain, authType, engine); | ||
| return; | ||
| } catch (CertificateException e) { | ||
| last = e; | ||
| } | ||
| } | ||
| throw last; | ||
| } | ||
|
|
||
| @Override | ||
| public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { | ||
| CertificateException last = null; | ||
| for (X509ExtendedTrustManager tm : delegates) { | ||
| try { | ||
| tm.checkServerTrusted(chain, authType); | ||
| return; | ||
| } catch (CertificateException e) { | ||
| last = e; | ||
| } | ||
| } | ||
| throw last; | ||
| } | ||
|
|
||
| @Override | ||
| public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException { | ||
| CertificateException last = null; | ||
| for (X509ExtendedTrustManager tm : delegates) { | ||
| try { | ||
| tm.checkServerTrusted(chain, authType, socket); | ||
| return; | ||
| } catch (CertificateException e) { | ||
| last = e; | ||
| } | ||
| } | ||
| throw last; | ||
| } | ||
|
|
||
| @Override | ||
| public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException { | ||
| CertificateException last = null; | ||
| for (X509ExtendedTrustManager tm : delegates) { | ||
| try { | ||
| tm.checkServerTrusted(chain, authType, engine); | ||
| return; | ||
| } catch (CertificateException e) { | ||
| last = e; | ||
| } | ||
| } | ||
| throw last; | ||
| } | ||
|
|
||
| @Override | ||
| public X509Certificate[] getAcceptedIssuers() { | ||
| return acceptedIssuers.clone(); | ||
| } | ||
| } |
Oops, something went wrong.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: opentdf/java-sdk
Length of output: 1159
🏁 Script executed:
Repository: opentdf/java-sdk
Length of output: 2443
🏁 Script executed:
Repository: opentdf/java-sdk
Length of output: 169
Preserve the existing Surefire
argLineinstead of replacing it.The hardcoded
argLineat line 471 overwrites theargLineproperty injected by JaCoCo'sprepare-agentexecution, preventing coverage data collection when the test profile is active.Suggested fix
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> - <argLine>-Djava.security.properties=${test.java.security.file}</argLine> + <argLine>@{argLine} -Djava.security.properties=${test.java.security.file}</argLine> </configuration> </plugin>📝 Committable suggestion
🤖 Prompt for AI Agents