[java-idp-plugin-duo] branch main updated: Improve plugin description, add auto-version information
Phil Smart
philip.smart at jisc.ac.uk
Wed Sep 2 14:18:58 UTC 2020
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch main
in repository java-idp-plugin-duo.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-duo.git;a=commit;h=d9fdace0c463cb1affcff4bae798040bb10d8968
The following commit(s) were added to refs/heads/main by this push:
new d9fdace Improve plugin description, add auto-version information
d9fdace is described below
commit d9fdace0c463cb1affcff4bae798040bb10d8968
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Wed Sep 2 15:18:52 2020 +0100
Improve plugin description, add auto-version information
---
.../shbboleth/idp/plugin/authn/duo/Version.java | 49 ++++++++++++++++++++++
.../idp/plugin/authn/duo/DuoOIDCDescription.java | 29 +++++++++++--
.../main/resources/META-INF/plugins/plugin.props | 12 +++---
.../idp/plugin/authn/duo/PluginTest.java | 28 ++++++++++++-
4 files changed, 106 insertions(+), 12 deletions(-)
diff --git a/idp-duo-api/src/main/java/net/shbboleth/idp/plugin/authn/duo/Version.java b/idp-duo-api/src/main/java/net/shbboleth/idp/plugin/authn/duo/Version.java
new file mode 100644
index 0000000..7f7b7b0
--- /dev/null
+++ b/idp-duo-api/src/main/java/net/shbboleth/idp/plugin/authn/duo/Version.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shbboleth.idp.plugin.authn.duo;
+
+import javax.annotation.Nullable;
+
+/** Class for getting and printing the version of the IdP. */
+public final class Version {
+
+ /** IdP version. */
+ @Nullable private static final String VERSION = Version.class.getPackage().getImplementationVersion();
+
+ /** Constructor. */
+ private Version() {
+ }
+
+ /**
+ * Main entry point to program.
+ *
+ * @param args command line arguments
+ */
+ public static void main(final String[] args) {
+ System.out.println(VERSION);
+ }
+
+ /**
+ * Get the version of the IdP.
+ *
+ * @return version of the IdP
+ */
+ @Nullable public static String getVersion() {
+ return VERSION;
+ }
+}
\ No newline at end of file
diff --git a/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/DuoOIDCDescription.java b/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/DuoOIDCDescription.java
index 3566bfd..698a8f5 100644
--- a/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/DuoOIDCDescription.java
+++ b/idp-duo-impl/src/main/java/net/shibboleth/idp/plugin/authn/duo/DuoOIDCDescription.java
@@ -24,9 +24,13 @@ import java.util.List;
import javax.annotation.Nonnull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
+import net.shbboleth.idp.plugin.authn.duo.Version;
import net.shibboleth.idp.plugin.AbstractPluginDescription;
+import net.shibboleth.idp.plugin.PluginVersion;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
@@ -34,10 +38,27 @@ import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
* Details about the Duo OIDC 2FA plugin.
*/
public class DuoOIDCDescription extends AbstractPluginDescription{
+
+ /** The version of this plugin. */
+ @Nonnull final private PluginVersion myVersion;
+
+ /** Constructor.*/
+ public DuoOIDCDescription() {
+ final String versionAsString = Version.getVersion();
+ if (versionAsString == null) {
+ final Logger log = LoggerFactory.getLogger(DuoOIDCDescription.class);
+ myVersion = new PluginVersion(0,0,1);
+ log.warn("{} must be run from a jar, taking a version of {}.{}.{}", DuoOIDCDescription.class,
+ myVersion.getMajor(),myVersion.getMinor(),myVersion.getPatch());
+
+ } else {
+ myVersion = new PluginVersion(versionAsString);
+ }
+ }
@Override
@Nonnull @NotEmpty public String getPluginId() {
- return "net.shibboleth.idp.plugin.authn.duo";
+ return "net.shibboleth.idp.plugin.duo";
}
/** {@inheritDoc} */
@@ -49,17 +70,17 @@ public class DuoOIDCDescription extends AbstractPluginDescription{
@Override
public int getMajorVersion() {
- return 0;
+ return myVersion.getMajor();
}
@Override
public int getMinorVersion() {
- return 0;
+ return myVersion.getMinor();
}
@Override
public int getPatchVersion() {
- return 1;
+ return myVersion.getPatch();
}
diff --git a/idp-duo-impl/src/main/resources/META-INF/plugins/plugin.props b/idp-duo-impl/src/main/resources/META-INF/plugins/plugin.props
index 9cdf9ab..37110e8 100644
--- a/idp-duo-impl/src/main/resources/META-INF/plugins/plugin.props
+++ b/idp-duo-impl/src/main/resources/META-INF/plugins/plugin.props
@@ -1,10 +1,10 @@
-net.shibboleth.idp.plugin.authn.duo.versions=0.0.1
+net.shibboleth.idp.plugin.duo.versions=0.0.1
#
# Duo
# 0.0.1
#
-net.shibboleth.idp.plugin.authn.duo.idpVersionMax.0.0.1=5.0.0
-net.shibboleth.idp.plugin.authn.duo.idpVersionMin.0.0.1=4.1.0
-net.shibboleth.idp.plugin.authn.duo.supportLevel.0.0.1 = Current
-net.shibboleth.idp.plugin.authn.duo.downloadURL.0.0.1 = https://build.shibboleth.net/nexus/service/local/repositories/releases/<FINISH>
-net.shibboleth.idp.plugin.authn.duo.baseName.0.0.1 = idp-plugin-duo-0.1.0
\ No newline at end of file
+net.shibboleth.idp.plugin.duo.idpVersionMax.0.0.1=5.0.0
+net.shibboleth.idp.plugin.duo.idpVersionMin.0.0.1=4.1.0
+net.shibboleth.idp.plugin.duo.supportLevel.0.0.1 = Current
+net.shibboleth.idp.plugin.duo.downloadURL.0.0.1 = https://build.shibboleth.net/nexus/service/local/repositories/releases/<FINISH>
+net.shibboleth.idp.plugin.duo.baseName.0.0.1 = idp-plugin-duo-0.1.0
\ No newline at end of file
diff --git a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/PluginTest.java b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/PluginTest.java
index 9df36f0..40d6478 100644
--- a/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/PluginTest.java
+++ b/idp-duo-impl/src/test/java/net/shibboleth/idp/plugin/authn/duo/PluginTest.java
@@ -24,12 +24,20 @@ import net.shibboleth.idp.plugin.PluginSupport.SupportLevel;
import net.shibboleth.idp.plugin.PluginVersion;
import net.shibboleth.idp.plugin.impl.PluginState;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Properties;
import java.util.ServiceLoader;
import org.testng.annotations.BeforeClass;
@@ -44,11 +52,11 @@ public class PluginTest {
* Find the plugin.
*/
@BeforeClass
- public void beforeMethod() {
+ public void setupPlugin() {
final ServiceLoader<PluginDescription> loader = ServiceLoader.load(PluginDescription.class);
for (final PluginDescription service : loader) {
- if ("net.shibboleth.idp.plugin.authn.duo".contentEquals(service.getPluginId())) {
+ if ("net.shibboleth.idp.plugin.duo".contentEquals(service.getPluginId())) {
duo = service;
break;
}
@@ -56,6 +64,22 @@ public class PluginTest {
assertNotNull(duo);
}
+
+ @Test
+ public void testFiles() throws IOException {
+ final Path distDir = Path.of("../idp-duo-distribution/src/main/resources");
+ assertTrue(Files.exists(distDir));
+ for (final Path p : duo.getFilePathsToCopy()) {
+ assertTrue(Files.exists(distDir.resolve(p)));
+ }
+ final File propFile = distDir.resolve("bootstrap").resolve("id.property").toFile();
+ assertTrue(propFile.exists());
+ Properties props = new Properties(2);
+ try(final BufferedInputStream stream = new BufferedInputStream(new FileInputStream(propFile))) {
+ props.load(stream);
+ assertEquals(StringSupport.trimOrNull(props.getProperty("pluginid")), duo.getPluginId());
+ }
+ }
/** Test the plugin state. */
@Test
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list