[java-idp-oidc] branch main updated: JOIDC-183 - Some sort of weird dependency/classpath issue with json-web-key-generator-0.8.2-jar-with-dependencies.jar

Henri Mikkonen henri.mikkonen at iki.fi
Mon Mar 18 14:04:49 UTC 2024


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

hjmikkon pushed a commit to branch main
in repository java-idp-oidc.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-oidc.git;a=commit;h=30e2b773e786c93bc941f4619da1ff8f68cf282e

The following commit(s) were added to refs/heads/main by this push:
     new 30e2b773 JOIDC-183 - Some sort of weird dependency/classpath issue with json-web-key-generator-0.8.2-jar-with-dependencies.jar
30e2b773 is described below

commit 30e2b773e786c93bc941f4619da1ff8f68cf282e
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Mon Mar 18 15:58:12 2024 +0200

    JOIDC-183 - Some sort of weird dependency/classpath issue with json-web-key-generator-0.8.2-jar-with-dependencies.jar
    
    https://shibboleth.atlassian.net/browse/JOIDC-183
    
    Relocated the JAR-file from bin/lib into bin/net.shibboleth.idp.oidc.op/lib
    
    Extended OIDCOPModule.enable(..) to check if the file exists in the old location
    and delete if found. In those cases, the resource is added to the map of results,
    with ResourceResult.REMOVED. Log on WARN if the file was found but it could not
    be deleted.
---
 .../idp/plugin/oidc/op/OIDCOPModule.java           | 40 ++++++++++++++++++++++
 .../shibboleth/idp/plugin/oidc/op/bin/jwtgen.bat   |  2 +-
 .../shibboleth/idp/plugin/oidc/op/bin/jwtgen.sh    |  2 +-
 .../idp/plugin/oidc/op/module.properties           |  2 +-
 4 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/OIDCOPModule.java b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/OIDCOPModule.java
index f8f574a8..1754f373 100644
--- a/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/OIDCOPModule.java
+++ b/idp-oidc-extension-impl/src/main/java/net/shibboleth/idp/plugin/oidc/op/OIDCOPModule.java
@@ -15,16 +15,33 @@
 package net.shibboleth.idp.plugin.oidc.op;
 
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
+
+import javax.annotation.Nonnull;
+
+import org.slf4j.Logger;
 
 import net.shibboleth.idp.module.IdPModule;
 import net.shibboleth.idp.module.impl.PluginIdPModule;
+import net.shibboleth.profile.module.ModuleContext;
 import net.shibboleth.profile.module.ModuleException;
+import net.shibboleth.shared.annotation.constraint.NotLive;
+import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.primitive.LoggerFactory;
 
 /**
  * {@link IdPModule} implementation.
  */
 public final class OIDCOPModule extends PluginIdPModule {
 
+    /** The JWK generator JAR file that will be deleted from its old location if exists there. */
+    @Nonnull private final String JWK_JAR_FILENAME = "json-web-key-generator-0.8.2-jar-with-dependencies.jar";
+
+    /** Class logger. */
+    @Nonnull private Logger log = LoggerFactory.getLogger(OIDCOPModule.class);
+
     /**
      * Constructor.
      *  
@@ -35,4 +52,27 @@ public final class OIDCOPModule extends PluginIdPModule {
         super(OIDCOPModule.class);
     }
 
+    /** {@inheritDoc} */
+    @Override
+    @Nonnull @Unmodifiable @NotLive public Map<ModuleResource,ResourceResult> enable(
+            @Nonnull final ModuleContext moduleContext) throws ModuleException {
+        final Map<ModuleResource,ResourceResult> results = super.enable(moduleContext);
+
+        final Path oldJwkJarRelativePath = Path.of("bin", "lib", JWK_JAR_FILENAME);
+        final Path oldJwkJarFullPath = Path.of(moduleContext.getInstallLocation()).resolve(oldJwkJarRelativePath);
+        assert oldJwkJarRelativePath != null;
+        try {
+            if (Files.deleteIfExists(oldJwkJarFullPath)) {
+                log.debug("The old JAR file {} was successfully deleted.", oldJwkJarFullPath);
+                final BasicModuleResource oldJwkJarResource = new BasicModuleResource(
+                        "/net/shibboleth/idp/plugin/oidc/op/bin/lib/" + JWK_JAR_FILENAME,
+                        oldJwkJarRelativePath, false, false, false, false, false);
+                results.put(oldJwkJarResource, ResourceResult.REMOVED);
+            }
+        } catch (IOException e) {
+            log.warn("The resource {} could not be removed", oldJwkJarFullPath, e);
+        }
+
+        return results;
+    }
 }
\ No newline at end of file
diff --git a/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/bin/jwtgen.bat b/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/bin/jwtgen.bat
index 8dd753f1..b002df31 100644
--- a/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/bin/jwtgen.bat
+++ b/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/bin/jwtgen.bat
@@ -1,4 +1,4 @@
 @echo off
 setlocal
 
-"%~dp0\runclass.bat" -jar %~dp0\lib\json-web-key-generator-0.8.2-jar-with-dependencies.jar %*
+"%~dp0\runclass.bat" -jar %~dp0\net.shibboleth.idp.oidc.op\lib\json-web-key-generator-0.8.2-jar-with-dependencies.jar %*
diff --git a/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/bin/jwtgen.sh b/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/bin/jwtgen.sh
index d7b97b7a..289f9d0f 100755
--- a/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/bin/jwtgen.sh
+++ b/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/bin/jwtgen.sh
@@ -4,4 +4,4 @@ declare LOCATION
 
 LOCATION=$(dirname $0)
 
-$LOCATION/runclass.sh '-jar' $LOCATION/lib/json-web-key-generator-0.8.2-jar-with-dependencies.jar  "$@"
\ No newline at end of file
+$LOCATION/runclass.sh '-jar' $LOCATION/net.shibboleth.idp.oidc.op/lib/json-web-key-generator-0.8.2-jar-with-dependencies.jar  "$@"
diff --git a/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/module.properties b/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/module.properties
index 231c4465..8c7ec470 100644
--- a/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/module.properties
+++ b/idp-oidc-extension-impl/src/main/resources/net/shibboleth/idp/plugin/oidc/op/module.properties
@@ -52,7 +52,7 @@ idp.oidc.OP.4.10.replace = true
 idp.oidc.OP.4.10.nonwindows = false
 
 idp.oidc.OP.4.11.src = /net/shibboleth/idp/plugin/oidc/op/bin/lib/json-web-key-generator-0.8.2-jar-with-dependencies.jar
-idp.oidc.OP.4.11.dest = bin/lib/json-web-key-generator-0.8.2-jar-with-dependencies.jar
+idp.oidc.OP.4.11.dest = bin/net.shibboleth.idp.oidc.op/lib/json-web-key-generator-0.8.2-jar-with-dependencies.jar
 
 idp.oidc.OP.4.12.src = /net/shibboleth/idp/plugin/oidc/op/bin/issue-access-token.sh
 idp.oidc.OP.4.12.dest = bin/issue-access-token.sh

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


More information about the commits mailing list