[java-identity-provider] branch main updated: Cleanup gpg terminology Eschew 'certificates' in favor of 'keys'

Rod Widdowson rdw at steadingsoftware.com
Thu Nov 26 11:12:48 UTC 2020


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=b7218f964ce7463c1165fbcd39f6f33f3d406226

The following commit(s) were added to refs/heads/main by this push:
       new  b7218f964 Cleanup gpg terminology Eschew 'certificates' in favor of 'keys'
b7218f964 is described below

commit b7218f964ce7463c1165fbcd39f6f33f3d406226
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Nov 26 11:12:36 2020 +0000

    Cleanup gpg terminology
    Eschew 'certificates' in favor of 'keys'
---
 .../idp/installer/plugin/impl/PluginInstaller.java | 32 +++++++-----------
 .../installer/plugin/impl/PluginInstallerCLI.java  |  7 ++--
 .../idp/installer/plugin/impl/TrustStore.java      | 38 +++++++++++-----------
 .../installer/plugin/impl/PluginInstallerTest.java | 16 ++-------
 4 files changed, 36 insertions(+), 57 deletions(-)

diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
index 6f20f744a..812dbf3f4 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstaller.java
@@ -109,11 +109,8 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
     /** The plugin's story about itself. */
     private IdPPlugin description;
 
-    /** The callback before we install a certificate into the TrustStore. */
-    @Nonnull private Predicate<String> acceptCert = Predicates.alwaysFalse();
-
-    /** The callback before we download a file. */
-    @Nonnull private Predicate<String> acceptDownload = Predicates.alwaysFalse();
+    /** The callback before we install a key into the TrustStore. */
+    @Nonnull private Predicate<String> acceptKey = Predicates.alwaysFalse();
 
     /** The actual distribution. */
     private Path distribution;
@@ -173,18 +170,11 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
         truststore = StringSupport.trimOrNull(loc);
     }
 
-    /** Set the acceptCert predicate.
-     * @param what what to set.
-     */
-    public void setAcceptCert(@Nonnull final Predicate<String> what) {
-        acceptCert = Constraint.isNotNull(what, "Accept Certificate Predicate should be non-null");
-    }
-
-    /** Set the acceptCert predicate.
+    /** Set the acceptKey predicate.
      * @param what what to set.
      */
-    public void setAcceptDownload(@Nonnull final Predicate<String> what) {
-        acceptDownload  = Constraint.isNotNull(what, "Accept Download Predicate should be non-null");
+    public void setAcceptKey(@Nonnull final Predicate<String> what) {
+        acceptKey = Constraint.isNotNull(what, "Accept Key Predicate should be non-null");
     }
 
     /** Set the httpClient.
@@ -735,17 +725,17 @@ public final class PluginInstaller extends AbstractInitializableComponent implem
             final Signature sig = TrustStore.signatureOf(sigStream);
             if (!trust.contains(sig)) {
                 LOG.info("TrustStore does not contain signature {}", sig);
-                final File certs = distribution.resolve("bootstrap").resolve("keys.txt").toFile();
-                if (!certs.exists()) {
+                final File keys = distribution.resolve("bootstrap").resolve("keys.txt").toFile();
+                if (!keys.exists()) {
                     LOG.info("No embedded keys file, signature check fails");
-                    throw new BuildException("No Certificate found to check signiture o distribution");
+                    throw new BuildException("No key found to check signiture of distribution");
                 }
                 try (final InputStream keysStream = new BufferedInputStream(
-                        new FileInputStream(certs))) {
-                    trust.importCertificateFromStream(sig, keysStream, acceptCert);
+                        new FileInputStream(keys))) {
+                    trust.importKeyFromStream(sig, keysStream, acceptKey);
                 }
                 if (!trust.contains(sig)) {
-                    LOG.info("Certificate not added to Trust Store");
+                    LOG.info("Key not added to Trust Store");
                     throw new BuildException("Could not check signature of distribution");
                 }
             }
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
index 33a1ba090..ee53545ba 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerCLI.java
@@ -178,8 +178,7 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
             final PluginInstallerArguments args) throws ComponentInitializationException {
         inst.setIdpHome(Path.of(getApplicationContext().getEnvironment().getProperty("idp.home")));
         if (!args.isUnattended()) {
-            inst.setAcceptCert(new InstallerQuery("Accept this Certificate"));
-            inst.setAcceptDownload(new InstallerQuery("Download from"));
+            inst.setAcceptKey(new InstallerQuery("Accept this Key"));
         }
         inst.setTrustore(args.getTruststore());
         if (getHttpClient()!= null) {
@@ -460,8 +459,8 @@ public final class PluginInstallerCLI extends AbstractIdPHomeAwareCommandLine<Pl
         }
 
         /** {@inheritDoc} */
-        public boolean test(final String certString) {
-            System.console().printf("%s:\n%s [yN] ", promptText, certString);
+        public boolean test(final String keyString) {
+            System.console().printf("%s:\n%s [yN] ", promptText, keyString);
             System.console().flush();
             final String result  = StringSupport.trimOrNull(System.console().readLine());
             return result != null && "y".equalsIgnoreCase(result.substring(0, 1));
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/TrustStore.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/TrustStore.java
index 612fed327..5e92a6986 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/TrustStore.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/plugin/impl/TrustStore.java
@@ -202,46 +202,46 @@ import net.shibboleth.utilities.java.support.component.ComponentSupport;
         }
     }
     
-    /** Load up the provided store and if the certificate is found and the
+    /** Load up the provided store and if the key is found and the
      * Predicate allows it add it to the store which we will then save.
      *
-     * @param sigForCert the signature we are looking for a cert for.
-     * @param certStream where to load the cert from
-     * @param accept whether we actually want to install this certificate
+     * @param sigForKey the signature we are looking for a key for.
+     * @param keyStream where to load the key from
+     * @param accept whether we actually want to install this key
      * @throws IOException if the load or save fails
      */
-    public void importCertificateFromStream(final Signature sigForCert,
-                            final InputStream certStream,
+    public void importKeyFromStream(final Signature sigForKey,
+                            final InputStream keyStream,
                             final Predicate<String> accept) throws IOException {
-        final PGPPublicKeyRingCollection providedStore = loadStoreFrom(certStream);
+        final PGPPublicKeyRingCollection providedStore = loadStoreFrom(keyStream);
 
         try {
-            final PGPPublicKey cert = providedStore.getPublicKey(sigForCert.getSignature().getKeyID());
-            if (cert == null) {
-                log.info("Provided certificate stream did not contain a certificate for {}", sigForCert);
+            final PGPPublicKey key = providedStore.getPublicKey(sigForKey.getSignature().getKeyID());
+            if (key == null) {
+                log.info("Provided key stream did not contain a key for {}", sigForKey);
                 return;
             }
             final StringBuilder builder = new StringBuilder("Signature:\t").
-                    append(sigForCert.toString()).
+                    append(sigForKey.toString()).
                     append("\nFingerPrint:\t").
-                    append((new String(Hex.encode(cert.getFingerprint()))).toUpperCase());
-            final Iterator<String> namesIterator = cert.getUserIDs();
+                    append((new String(Hex.encode(key.getFingerprint()))).toUpperCase());
+            final Iterator<String> namesIterator = key.getUserIDs();
             while (namesIterator.hasNext()) {
                 builder.append("\nUsername:\t").append(namesIterator.next());
             }
             builder.append('\n');
-            final String certInfo = builder.toString();
-            log.debug("Asking to import certificate\n{}", certInfo);
-            if (!accept.test(certInfo)) {
-                log.info("Certificate import barred by user");
+            final String keyInfo = builder.toString();
+            log.debug("Asking to import key\n{}", keyInfo);
+            if (!accept.test(keyInfo)) {
+                log.info("Key import barred by user");
                 return;
             }
             keyRings = PGPPublicKeyRingCollection.addPublicKeyRing(
                     keyRings,
-                    new PGPPublicKeyRing(Collections.singletonList(cert)));
+                    new PGPPublicKeyRing(Collections.singletonList(key)));
             saveStoreInternal();
         } catch (final PGPException e) {
-            log.warn("Couldn't locate certificate", e);
+            log.warn("Couldn't locate key", e);
         }
     }
 
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
index 394dfd122..7ae8aabdb 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/installer/plugin/impl/PluginInstallerTest.java
@@ -51,13 +51,6 @@ public class PluginInstallerTest extends BasePluginTest {
         }
     };
 
-    private final Predicate<String> loggingAcceptDownLoad = new  Predicate<>() {
-        public boolean test(String what) {
-            log.debug("Accepting the download from {} ", what);
-            return true;
-        }
-    };
-
     @BeforeClass public void setup() throws IOException {
         if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
             Security.addProvider(new BouncyCastleProvider());
@@ -90,8 +83,7 @@ public class PluginInstallerTest extends BasePluginTest {
     @Test(enabled = false) public void testUnpackZip() throws ComponentInitializationException, IOException {
         try (final PluginInstaller inst = new PluginInstaller()) {
             inst.setIdpHome(getIdpHome());
-            inst.setAcceptCert(loggingAcceptCert);
-            inst.setAcceptDownload(loggingAcceptDownLoad);
+            inst.setAcceptKey(loggingAcceptCert);
             inst.initialize();
             final URL where = new URL("https://build.shibboleth.net/nexus/service/local/repositories/releases/content/net/shibboleth/idp/plugin/scripting/idp-plugin-nashorn-dist/0.1.0/");
             inst.setPluginId("net.shibboleth.idp.plugin.nashorn");
@@ -102,8 +94,7 @@ public class PluginInstallerTest extends BasePluginTest {
     @Test(enabled = false) public void testUnpackZipFile() throws ComponentInitializationException, IOException {
         try (final PluginInstaller inst = new PluginInstaller()) {
             inst.setIdpHome(getIdpHome());
-            inst.setAcceptCert(loggingAcceptCert);
-            inst.setAcceptDownload(loggingAcceptDownLoad);
+            inst.setAcceptKey(loggingAcceptCert);
             inst.initialize();
             final Path dir = Path.of("H:\\Perforce\\Juno\\New\\plugins\\java-idp-plugin-scripting\\rhino-dist\\target");
             inst.installPlugin(dir,"shibboleth-idp-plugin-rhino-0.1.4-SNAPSHOT.zip", true);
@@ -115,8 +106,7 @@ public class PluginInstallerTest extends BasePluginTest {
         try (final PluginInstaller inst = new PluginInstaller()) {
             inst.setPluginId("net.shibboleth.idp.plugin.rhino");
             inst.setIdpHome(getIdpHome());
-            inst.setAcceptCert(loggingAcceptCert);
-            inst.setAcceptDownload(loggingAcceptDownLoad);
+            inst.setAcceptKey(loggingAcceptCert);
             inst.initialize();
             final URL where = new URL("https://build.shibboleth.net/nexus/service/local/repositories/releases/content/net/shibboleth/idp/plugin/scripting/idp-plugin-rhino-dist/0.1.0/");
             inst.installPlugin(where,"idp-plugin-rhino-dist-0.1.0.zip", true);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list