[java-identity-provider] branch main updated: IDP-2027 - Flow exception handling is breaking under Eclipse

Scott Cantor cantor.2 at osu.edu
Fri Oct 21 17:54:52 UTC 2022


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

scantor 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=a2206c25fcc6b3ca04ea4f46a1f49ceeb1091c2b

The following commit(s) were added to refs/heads/main by this push:
     new a2206c25f IDP-2027 - Flow exception handling is breaking under Eclipse
a2206c25f is described below

commit a2206c25fcc6b3ca04ea4f46a1f49ceeb1091c2b
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Fri Oct 21 13:53:13 2022 -0400

    IDP-2027 - Flow exception handling is breaking under Eclipse
    
    https://shibboleth.atlassian.net/browse/IDP-2027
---
 .../net/shibboleth/idp/conf/global-system.xml      |  3 ++
 .../idp/flows/admin/admin-abstract-flow.xml        |  2 +-
 .../idp/flows/authn/authn-abstract-flow.xml        |  6 ++-
 .../idp/flows/c14n/subject-c14n-abstract-flow.xml  |  6 ++-
 .../shibboleth/idp/flows/cas/cas-abstract-flow.xml |  3 +-
 .../client-storage/client-storage-read-flow.xml    |  4 +-
 .../client-storage/client-storage-write-flow.xml   |  4 +-
 .../flows/intercept/intercept-abstract-flow.xml    |  6 ++-
 .../shibboleth/idp/flows/logout/logout-flow.xml    |  3 +-
 .../idp/flows/logout/logout-propagation-flow.xml   |  3 +-
 .../flows/saml/logout/saml2-logoutprop-flow.xml    |  3 +-
 .../idp/flows/saml/saml-abstract-flow.xml          |  2 +-
 .../idp/profile/LogRuntimeException.java           | 43 ++++++++++++++++++++++
 13 files changed, 77 insertions(+), 11 deletions(-)

diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml
index a2c19aca1..f959d3cd5 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/global-system.xml
@@ -397,6 +397,9 @@
         p:useDefaultTimeZone="#{getObject('shibboleth.AuditDefaultTimeZone') ?: false}"
         p:fieldReplacements="#{getObject('shibboleth.AuditFieldReplacementMap')}" />
 
+    <!-- Bean used internally to flows to log uncaught exceptions. -->
+    <bean id="LogRuntimeException" class="net.shibboleth.idp.profile.LogRuntimeException" />
+
     <!-- Default attribute mapping support for registry service, exposed here for extension use. -->
 
     <bean id="shibboleth.RegistryNamingFunction" abstract="true"
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/admin/admin-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/admin/admin-abstract-flow.xml
index d6747a0cf..1129177de 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/admin/admin-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/admin/admin-abstract-flow.xml
@@ -102,7 +102,7 @@
 
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
         <transition to="HandleError" />
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/authn/authn-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/authn/authn-abstract-flow.xml
index 8a6784d0d..5fa91b3d2 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/authn/authn-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/authn/authn-abstract-flow.xml
@@ -53,7 +53,11 @@
     </subflow-state>
   
     <action-state id="LogRuntimeException">
-        <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.authn').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+        <on-entry>
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.authn', flowExecutionException)" />
+        </on-entry>
+        <evaluate expression="'RuntimeException'" />
+        
         <transition to="RuntimeException" />
     </action-state>
 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/c14n/subject-c14n-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/c14n/subject-c14n-abstract-flow.xml
index fcf7739fb..9701b875a 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/c14n/subject-c14n-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/c14n/subject-c14n-abstract-flow.xml
@@ -23,7 +23,11 @@
     <end-state id="SubjectCanonicalizationError" />
 
     <action-state id="LogRuntimeException">
-        <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.authn').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+        <on-entry>
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.authn', flowExecutionException)" />
+        </on-entry>
+        <evaluate expression="'RuntimeException'" />
+        
         <transition to="RuntimeException" />
     </action-state>
 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/cas/cas-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/cas/cas-abstract-flow.xml
index bfa336c6f..1b7b510ff 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/cas/cas-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/cas/cas-abstract-flow.xml
@@ -9,9 +9,10 @@
 
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.cas').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.cas', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
+        
         <transition to="HandleError" />
     </action-state>
 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-read-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-read-flow.xml
index 38f80a5f3..f5a19a2cd 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-read-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-read-flow.xml
@@ -33,9 +33,11 @@
     <!-- Passthrough state if an exception is thrown. -->
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
+        
+        <transition to="RuntimeException" />
     </action-state>
 
     <!-- Successful completion of subflow. -->
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-write-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-write-flow.xml
index d84bfaedc..b5af21831 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-write-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/client-storage/client-storage-write-flow.xml
@@ -40,9 +40,11 @@
     <!-- Passthrough state if an exception is thrown. -->
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
+        
+        <transition to="RuntimeException" />
     </action-state>
 
     <!-- Successful completion of subflow. -->
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/intercept/intercept-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/intercept/intercept-abstract-flow.xml
index c417975ab..c2c9eb1db 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/intercept/intercept-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/intercept/intercept-abstract-flow.xml
@@ -28,7 +28,11 @@
     <end-state id="UpdateSecurityParameters" />
 
     <action-state id="LogRuntimeException">
-        <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.profile.interceptor').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+        <on-entry>
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.profile.interceptor', flowExecutionException)" />
+        </on-entry>
+        <evaluate expression="'RuntimeException'" />
+        
         <transition to="RuntimeException" />
     </action-state>
 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-flow.xml
index 2fedfb40c..63a52f46f 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-flow.xml
@@ -154,9 +154,10 @@
 
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
+        
         <transition to="HandleErrorWithView" />
     </action-state>
 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-propagation-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-propagation-flow.xml
index b85ddcb20..0c7f88689 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-propagation-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/logout/logout-propagation-flow.xml
@@ -63,9 +63,10 @@
 
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
+        
         <transition to="LogoutFailed" />
     </action-state>
 
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/logout/saml2-logoutprop-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/logout/saml2-logoutprop-flow.xml
index d3f8d308b..3f8173b44 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/logout/saml2-logoutprop-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/logout/saml2-logoutprop-flow.xml
@@ -92,9 +92,10 @@
 
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.saml.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.saml.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
+        
         <transition to="proceed" />
     </action-state>
     
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml-abstract-flow.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml-abstract-flow.xml
index 1af33aaf7..953d6f3a0 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml-abstract-flow.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/flows/saml/saml-abstract-flow.xml
@@ -142,7 +142,7 @@
 
     <action-state id="LogRuntimeException">
         <on-entry>
-            <evaluate expression="T(org.slf4j.LoggerFactory).getLogger('net.shibboleth.idp.saml.profile').error('Uncaught runtime exception', flowExecutionException.getCause() ?: flowExecutionException)" />
+            <evaluate expression="LogRuntimeException.log('net.shibboleth.idp.saml.profile', flowExecutionException)" />
         </on-entry>
         <evaluate expression="'RuntimeException'" />
         <transition to="HandleError" />
diff --git a/idp-profile-api/src/main/java/net/shibboleth/idp/profile/LogRuntimeException.java b/idp-profile-api/src/main/java/net/shibboleth/idp/profile/LogRuntimeException.java
new file mode 100644
index 000000000..a264025e3
--- /dev/null
+++ b/idp-profile-api/src/main/java/net/shibboleth/idp/profile/LogRuntimeException.java
@@ -0,0 +1,43 @@
+/*
+ * 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.shibboleth.idp.profile;
+
+import javax.annotation.Nonnull;
+
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
+import org.slf4j.LoggerFactory;
+
+/**
+ * Dedicated bean used to log flow exceptions, to get around issues with Spring Expressions
+ * referencing class objects under certain conditions that are so far not understood.
+ */
+public class LogRuntimeException {
+ 
+    /**
+     * Log a message about the caught exception to a particular category.
+     * 
+     * @param category category to log under
+     * @param e exception to log
+     */
+    public void log(@Nonnull @NotEmpty final String category, @Nonnull final Exception e) {
+        LoggerFactory.getLogger(category).error("Uncaught runtime exception",
+                e.getCause() != null ? e.getCause() : e);
+    }
+
+}
\ No newline at end of file

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


More information about the commits mailing list