From b7e6239e50557e379f3c93a0b33b2eef57592679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Fri, 20 Dec 2024 23:42:48 +0200 Subject: [PATCH] Stop using deprecated bouncycastle apis --- .../java/org/eclipse/tycho/ReactorProject.java | 1 - .../org/eclipse/tycho/gpg/BouncyCastleSigner.java | 15 ++++++++++----- .../p2Repository/P2RepositoryFtpHandlerTest.java | 1 - .../tycho/plugins/p2/AbstractP2MetadataMojo.java | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tycho-api/src/main/java/org/eclipse/tycho/ReactorProject.java b/tycho-api/src/main/java/org/eclipse/tycho/ReactorProject.java index 9cc993dbc2..d1d04ea2f2 100644 --- a/tycho-api/src/main/java/org/eclipse/tycho/ReactorProject.java +++ b/tycho-api/src/main/java/org/eclipse/tycho/ReactorProject.java @@ -75,7 +75,6 @@ public interface ReactorProject extends IDependencyMetadata { /** * Returns the (editable) list of {@link DependencySeed}s for the given project. */ - @SuppressWarnings("unchecked") default List getDependencySeeds() { return computeContextValue(TychoConstants.CTX_DEPENDENCY_SEEDS, () -> new CopyOnWriteArrayList<>()); } diff --git a/tycho-gpg-plugin/src/main/java/org/eclipse/tycho/gpg/BouncyCastleSigner.java b/tycho-gpg-plugin/src/main/java/org/eclipse/tycho/gpg/BouncyCastleSigner.java index 6a544a2525..9449da32a5 100644 --- a/tycho-gpg-plugin/src/main/java/org/eclipse/tycho/gpg/BouncyCastleSigner.java +++ b/tycho-gpg-plugin/src/main/java/org/eclipse/tycho/gpg/BouncyCastleSigner.java @@ -33,6 +33,7 @@ import org.bouncycastle.bcpg.ArmoredOutputStream; import org.bouncycastle.bcpg.CompressionAlgorithmTags; import org.bouncycastle.bcpg.HashAlgorithmTags; +import org.bouncycastle.bcpg.PublicKeyPacket; import org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags; import org.bouncycastle.bcpg.sig.KeyFlags; import org.bouncycastle.crypto.generators.RSAKeyPairGenerator; @@ -138,7 +139,8 @@ public SignatureStore generateSignature(File file) throws PGPException, IOExcept var publicKey = secretKey.getPublicKey(); var signatureGenerator = new PGPSignatureGenerator( new JcaPGPContentSignerBuilder(publicKey.getAlgorithm(), HashAlgorithmTags.SHA256) - .setProvider(BouncyCastleProvider.PROVIDER_NAME)); + .setProvider(BouncyCastleProvider.PROVIDER_NAME), + publicKey); signatureGenerator.init(PGPSignature.BINARY_DOCUMENT, privateKey); var subpackets = new PGPSignatureSubpacketGenerator(); subpackets.setIssuerFingerprint(false, publicKey); @@ -244,7 +246,8 @@ private void init(String... userIDs) throws PGPException, IOException { var publicKeyRings = new ArrayList(); var secretKeyRings = new ArrayList(); for (var userID : userIDs) { - var signingKeyPair = new BcPGPKeyPair(PGPPublicKey.RSA_SIGN, keyPairGenerator.generateKeyPair(), now); + var signingKeyPair = new BcPGPKeyPair(PublicKeyPacket.VERSION_4, PGPPublicKey.RSA_GENERAL, + keyPairGenerator.generateKeyPair(), now); var signatureSubpacketGenerator = new PGPSignatureSubpacketGenerator(); signatureSubpacketGenerator.setKeyFlags(false, KeyFlags.SIGN_DATA | KeyFlags.CERTIFY_OTHER); signatureSubpacketGenerator.setPreferredSymmetricAlgorithms(false, @@ -254,15 +257,17 @@ private void init(String... userIDs) throws PGPException, IOException { signatureSubpacketGenerator.setPreferredCompressionAlgorithms(false, new int[] { CompressionAlgorithmTags.ZIP, CompressionAlgorithmTags.BZIP2 }); - var encryptionKeyPair = new BcPGPKeyPair(PGPPublicKey.RSA_ENCRYPT, keyPairGenerator.generateKeyPair(), now); + var encryptionKeyPair = new BcPGPKeyPair(PublicKeyPacket.VERSION_4, PGPPublicKey.RSA_GENERAL, + keyPairGenerator.generateKeyPair(), now); var encryptionSubpacketGenerator = new PGPSignatureSubpacketGenerator(); encryptionSubpacketGenerator.setKeyFlags(false, KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE); var digestCalculator = new BcPGPDigestCalculatorProvider().get(HashAlgorithmTags.SHA1); var signatureSubpacketVector = signatureSubpacketGenerator.generate(); - var contentSignerBuilder = new BcPGPContentSignerBuilder(PGPPublicKey.RSA_SIGN, HashAlgorithmTags.SHA256); + var contentSignerBuilder = new BcPGPContentSignerBuilder(PGPPublicKey.RSA_GENERAL, + HashAlgorithmTags.SHA256); var secretKeyEncryptorBuilder = new BcPBESecretKeyEncryptorBuilder(SymmetricKeyAlgorithmTags.AES_256); - var keyRingGenerator = new PGPKeyRingGenerator(PGPPublicKey.RSA_SIGN, signingKeyPair, userID, + var keyRingGenerator = new PGPKeyRingGenerator(PGPPublicKey.RSA_GENERAL, signingKeyPair, userID, digestCalculator, signatureSubpacketVector, null, contentSignerBuilder, secretKeyEncryptorBuilder.build(passphrase.toCharArray())); keyRingGenerator.addSubKey(encryptionKeyPair, encryptionSubpacketGenerator.generate(), null); diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryFtpHandlerTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryFtpHandlerTest.java index 5f916c721e..185220822e 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryFtpHandlerTest.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryFtpHandlerTest.java @@ -92,7 +92,6 @@ private FileEntry getFileEntry(final String path, final File file) throws IOExce return entry; } - @SuppressWarnings("TextBlockMigration") private String getFeatResponse() { return "Extensions supported:\r\n" + " MDTM\r\n" + diff --git a/tycho-p2-plugin/src/main/java/org/eclipse/tycho/plugins/p2/AbstractP2MetadataMojo.java b/tycho-p2-plugin/src/main/java/org/eclipse/tycho/plugins/p2/AbstractP2MetadataMojo.java index 7cb43b26ee..0d4b98853d 100644 --- a/tycho-p2-plugin/src/main/java/org/eclipse/tycho/plugins/p2/AbstractP2MetadataMojo.java +++ b/tycho-p2-plugin/src/main/java/org/eclipse/tycho/plugins/p2/AbstractP2MetadataMojo.java @@ -116,11 +116,11 @@ protected void addArguments(List arguments) throws IOException, Malforme arguments.add("-source"); arguments.add(getUpdateSiteLocation().getAbsolutePath()); arguments.add("-metadataRepository"); - arguments.add(getUpdateSiteLocation().toURL().toExternalForm()); + arguments.add(getUpdateSiteLocation().toURI().toString()); arguments.add("-metadataRepositoryName"); arguments.add(metadataRepositoryName); arguments.add("-artifactRepository"); - arguments.add(getUpdateSiteLocation().toURL().toExternalForm()); + arguments.add(getUpdateSiteLocation().toURI().toString()); arguments.add("-artifactRepositoryName"); arguments.add(artifactRepositoryName); arguments.add("-noDefaultIUs");