Skip to content

Refactored to remove duplicated code and cleaned up warnings for unused imports and deprecated methods.#770

Merged
kaikramer merged 1 commit intokaikramer:mainfrom
jonwltn:refactoring
Mar 20, 2026
Merged

Refactored to remove duplicated code and cleaned up warnings for unused imports and deprecated methods.#770
kaikramer merged 1 commit intokaikramer:mainfrom
jonwltn:refactoring

Conversation

@jonwltn
Copy link
Contributor

@jonwltn jonwltn commented Mar 19, 2026

This PR consists of several refactorings:

  • Normalize provider use for EC key pairs.
  • Move common key selector code into an abstract super class.
  • Remove unused imports.
  • Removed used of deprecated constructors and methods.
  • CMS signing optimizations and fixed typo.
  • Remove unncessary storePassphraseAction.setEnabled call.
  • Consolidated duplicate download and view code.

…ed imports and deprecated methods.

Normalize provider use for EC key pairs.

Move common key selector code into an abstract super class.

Remove unused imports.

Removed used of deprecated constructors and methods.

CMS signing improvements and fixed typo.

Remove unncessary storePassphraseAction.setEnabled call.

Remove duplicate download and view code.
// counter signer vector if it does not already exist, and then it adds the counter signer.
signer = SignerInformation.addCounterSigners(signer, counterSigners);

generator.addCertificates(new JcaCertStore(Arrays.asList(certificateChain)));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added the certs for every countersignature. Now the certs are added to the store one time no matter how many countersigners there are.

* @throws URISyntaxException If the CRL URL is malformed.
* @throws CryptoException If the CRL cannot be loaded.
*/
public static void downloadCrl(URL url, Window window) throws IOException, URISyntaxException, CryptoException {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made these methods static and public for re-use.

* enabling/disabling the combo automatically.
* </p>
*/
public abstract class KeySelector implements Serializable {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved all the common code for the ML-DSA, ML-KEM, and SLH-DSA key selectors into this super class. They're essentially identical.

// Get a key pair generator
KeyPairGenerator keyPairGen;

if (provider == null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle the null provider here to simply the if/else if tree.


try {
URL url = new URL(tsaUrl);
URL url = new URI(tsaUrl).toURL();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced all occurrences of "new URL" with "new URI().toURL()". Added the URISyntaxException to the throws for all relevant methods.

@kaikramer
Copy link
Owner

All changes look good to me, thanks for the code quality improvements!

@kaikramer kaikramer merged commit abc74fe into kaikramer:main Mar 20, 2026
4 checks passed
@jonwltn jonwltn deleted the refactoring branch March 21, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants