From 77848d635b76d8294697ffaf11acf51256df2a5b Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 27 Apr 2020 00:58:28 +0200 Subject: Decouple BouncyCastle from JGit Core Motivation: BouncyCastle serves as 'default' implementation of the GPG Signer. If a client application does not use it there is no need to pull in this dependency, especially since BouncyCastle is a large library. Move the classes depending on BouncyCastle to an OSGi fragment extending the org.eclipse.jgit bundle. They are moved to a distinct internal package in order to avoid split packages. This doesn't break public API since these classes were already in an internal package before this change. Add a new feature org.eclipse.jgit.gpg.bc to enable installation. With that users can now decide if they want to install it. Attempts to sign a commit if org.eclipse.jgit.gpg.bc isn't available will result in ServiceUnavailableException being thrown. Bug: 559106 Change-Id: I42fd6c00002e17aa9a7be96ae434b538ea86ccf8 Also-by: Michael Dardis Signed-off-by: Michael Dardis Signed-off-by: Matthias Sohn Signed-off-by: David Ostrovsky --- .../internal/BouncyCastleGpgKeyLocatorTest.java | 134 --------------------- 1 file changed, 134 deletions(-) delete mode 100644 org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocatorTest.java (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocatorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocatorTest.java deleted file mode 100644 index e93091d67d..0000000000 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/internal/BouncyCastleGpgKeyLocatorTest.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (C) 2019, Thomas Wolf and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Distribution License v. 1.0 which is available at - * https://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: BSD-3-Clause - */ -package org.eclipse.jgit.lib.internal; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.Locale; - -import org.junit.Test; - -public class BouncyCastleGpgKeyLocatorTest { - - private static final String USER_ID = "Heinrich Heine "; - - private static boolean match(String userId, String pattern) { - return BouncyCastleGpgKeyLocator.containsSigningKey(userId, pattern); - } - - @Test - public void testFullMatch() throws Exception { - assertTrue(match(USER_ID, - "=Heinrich Heine ")); - assertFalse(match(USER_ID, "=Heinrich Heine")); - assertFalse(match(USER_ID, "= ")); - assertFalse(match(USER_ID, "=heinrichh@uni-duesseldorf.de")); - } - - @Test - public void testEmpty() throws Exception { - assertFalse(match(USER_ID, "")); - assertFalse(match(USER_ID, null)); - assertFalse(match("", "")); - assertFalse(match(null, "")); - assertFalse(match(null, null)); - assertFalse(match("", "something")); - assertFalse(match(null, "something")); - } - - @Test - public void testFullEmail() throws Exception { - assertTrue(match(USER_ID, "")); - assertTrue(match(USER_ID + " ", "")); - assertFalse(match(USER_ID, "<>")); - assertFalse(match(USER_ID, "")); - assertFalse(match(USER_ID, "")); - assertFalse(match(USER_ID, "")); - assertFalse(match(USER_ID, "")); - assertFalse(match(USER_ID, "")); - assertFalse(match(USER_ID.substring(0, USER_ID.length() - 1), - "")); - assertFalse(match("", "<>")); - assertFalse(match("", "")); - } - - @Test - public void testPartialEmail() throws Exception { - assertTrue(match(USER_ID, "@heinrichh@uni-duesseldorf.de")); - assertTrue(match(USER_ID, "@heinrichh")); - assertTrue(match(USER_ID, "@duesseldorf")); - assertTrue(match(USER_ID, "@uni-d")); - assertTrue(match(USER_ID, "@h")); - assertTrue(match(USER_ID, "@.")); - assertTrue(match(USER_ID, "@h@u")); - assertFalse(match(USER_ID, "@ ")); - assertFalse(match(USER_ID, "@")); - assertFalse(match(USER_ID, "@Heine")); - assertFalse(match(USER_ID, "@HeinrichH")); - assertFalse(match(USER_ID, "@Heinrich")); - assertFalse(match("", "@")); - assertFalse(match("", "@h")); - } - - private void substringTests(String prefix) throws Exception { - assertTrue(match(USER_ID, prefix + "heinrichh@uni-duesseldorf.de")); - assertTrue(match(USER_ID, prefix + "heinrich")); - assertTrue(match(USER_ID, prefix + "HEIN")); - assertTrue(match(USER_ID, prefix + "Heine <")); - assertTrue(match(USER_ID, prefix + "UNI")); - assertTrue(match(USER_ID, prefix + "uni")); - assertTrue(match(USER_ID, prefix + "rich He")); - assertTrue(match(USER_ID, prefix + "h@u")); - assertTrue(match(USER_ID, prefix + USER_ID)); - assertTrue(match(USER_ID, prefix + USER_ID.toUpperCase(Locale.ROOT))); - assertFalse(match(USER_ID, prefix + "")); - assertFalse(match(USER_ID, prefix + " ")); - assertFalse(match(USER_ID, prefix + "yy")); - assertFalse(match("", prefix + "")); - assertFalse(match("", prefix + "uni")); - } - - @Test - public void testSubstringPlain() throws Exception { - substringTests(""); - } - - @Test - public void testSubstringAsterisk() throws Exception { - substringTests("*"); - } - - @Test - public void testExplicitFingerprint() throws Exception { - assertFalse(match("John Fade ", "0xfade")); - assertFalse(match("John Fade <0xfade@example.com>", "0xfade")); - assertFalse(match("", "0xfade")); - } - - @Test - public void testImplicitFingerprint() throws Exception { - assertTrue(match("John Fade ", "fade")); - assertTrue(match("John Fade <0xfade@example.com>", "fade")); - assertTrue(match("John Fade ", "FADE")); - assertTrue(match("John Fade <0xfade@example.com>", "FADE")); - } - - @Test - public void testZeroX() throws Exception { - assertTrue(match("John Fade <0xfade@example.com>", "0x")); - assertTrue(match("John Fade <0xfade@example.com>", "*0x")); - assertTrue(match("John Fade <0xfade@example.com>", "*0xfade")); - assertTrue(match("John Fade <0xfade@example.com>", "*0xFADE")); - assertTrue(match("John Fade <0xfade@example.com>", "@0xfade")); - assertFalse(match("John Fade <0xfade@example.com>", "@0xFADE")); - assertFalse(match("", "0x")); - } -} -- cgit v1.2.3