[java-identity-provider COMMIT] in /trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile: context/navigate/...

noreply at shibboleth.net noreply at shibboleth.net
Wed Jul 6 21:44:58 EDT 2016


Author: scantor
Date: Wed Jul  6 21:44:58 2016
New Revision: 8283

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=8283&view=rev
Log:
Add better error handling control to script and expression primitives.

Modified:
    trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/ScriptedContextLookupFunction.java
    trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/SpringExpressionContextLookupFunction.java
    trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/ScriptedPredicate.java
    trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/SpringExpressionPredicate.java

Modified: trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/ScriptedContextLookupFunction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/ScriptedContextLookupFunction.java?rev=8283&r1=8282&r2=8283&view=diff
==============================================================================
--- trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/ScriptedContextLookupFunction.java	(original)
+++ trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/ScriptedContextLookupFunction.java	Wed Jul  6 21:44:58 2016
@@ -66,6 +66,9 @@
 
     /** The custom object we can be injected into the script. */
     @Nullable private Object customObject;
+    
+    /** Whether to raise runtime exceptions if a script fails. */
+    private boolean hideExceptions;
 
     /**
      * Constructor.
@@ -123,6 +126,15 @@
      */
     @Nullable public void setCustomObject(final Object object) {
         customObject = object;
+    }
+
+    /**
+     * Set whether to hide exceptions in script execution (default is false).
+     * 
+     * @param flag flag to set
+     */
+    public void setHideExceptions(final boolean flag) {
+        hideExceptions = flag;
     }
 
     /** {@inheritDoc} */
@@ -149,7 +161,10 @@
 
         } catch (final ScriptException e) {
             log.error("{} Error while executing Function script", logPrefix, e);
-            return null;
+            if (hideExceptions) {
+                return null;
+            }
+            throw new RuntimeException(e);
         }
     }
 

Modified: trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/SpringExpressionContextLookupFunction.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/SpringExpressionContextLookupFunction.java?rev=8283&r1=8282&r2=8283&view=diff
==============================================================================
--- trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/SpringExpressionContextLookupFunction.java	(original)
+++ trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/context/navigate/SpringExpressionContextLookupFunction.java	Wed Jul  6 21:44:58 2016
@@ -57,6 +57,10 @@
 
     /** A custom object that can be injected into the expression. */
     @Nullable private Object customObject;
+        
+    /** Whether to raise runtime exceptions if an expression fails. */
+    private boolean hideExceptions;
+
 
     /**
      * Constructor.
@@ -101,6 +105,15 @@
         customObject = object;
     }
 
+    /**
+     * Set whether to hide exceptions in expression execution (default is false).
+     * 
+     * @param flag flag to set
+     */
+    public void setHideExceptions(final boolean flag) {
+        hideExceptions = flag;
+    }
+
     /** {@inheritDoc} */
     @Override public Object apply(@Nullable final T context) {
 
@@ -124,7 +137,10 @@
             
         } catch (final ParseException|EvaluationException e) {
             log.error("Error evaluating Spring expression", e);
-            return null;
+            if (hideExceptions) {
+                return null;
+            }
+            throw e;
         }
     }
 

Modified: trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/ScriptedPredicate.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/ScriptedPredicate.java?rev=8283&r1=8282&r2=8283&view=diff
==============================================================================
--- trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/ScriptedPredicate.java	(original)
+++ trunk/idp-profile-api/src/main/java/net/shibboleth/idp/profile/logic/ScriptedPredicate.java	Wed Jul  6 21:44:58 2016
@@ -56,6 +56,12 @@
 
     /** A custom object to inject into the script. */
     @Nullable private Object customObject;
+    
+    /** Whether to raise runtime exceptions if a script fails. */
+    private boolean hideExceptions;
+    
+    /** Value to return from predicate when an error occurs. */
+    private boolean returnOnError;
 
     /**
      * Constructor.
@@ -94,6 +100,24 @@
      */
     public void setCustomObject(final Object object) {

[... 105 lines stripped ...]


More information about the commits mailing list