88import org .apache .commons .lang3 .RandomStringUtils ;
99import org .apache .commons .lang3 .StringUtils ;
1010
11- import javax . naming . OperationNotSupportedException ;
11+ import java . lang . reflect . InvocationTargetException ;
1212import java .lang .reflect .Method ;
1313import java .lang .reflect .Modifier ;
1414import java .math .BigDecimal ;
@@ -80,7 +80,7 @@ public String parse(String expression, Map<String, String> context) {
8080 }
8181 }
8282
83- private Object eval (String expr , Map <String , String > ctx ) throws Exception {
83+ private Object eval (String expr , Map <String , String > ctx ) throws InvocationTargetException , IllegalAccessException {
8484 expr = expr == null ? "" : expr .trim ();
8585
8686 if (ctx .containsKey (expr )) {
@@ -332,19 +332,19 @@ private int findTopLevelDotBeforeMethodCall(String expr) {
332332 return -1 ;
333333 }
334334
335- private Object evalTypeChain (String expr , Map <String , String > ctx ) throws Exception {
335+ private Object evalTypeChain (String expr , Map <String , String > ctx ) throws InvocationTargetException , IllegalAccessException {
336336 int open = expr .indexOf ('(' );
337337 int close = findMatchingParen (expr , open );
338338 String fqcn = expr .substring (open + 1 , close ).trim ();
339339
340340 Class <?> type = ALLOWED_TYPES .get (fqcn );
341341 if (type == null ) {
342- throw new OperationNotSupportedException ("Type not allowed: " + fqcn );
342+ throw new SecurityException ("Type not allowed: " + fqcn );
343343 }
344344
345345 String rest = expr .substring (close + 1 ).trim ();
346346 if (!rest .startsWith ("." )) {
347- throw new IllegalArgumentException ("Expected method chain after T(" + fqcn + ")" );
347+ throw new SecurityException ("Expected method chain after T(" + fqcn + ")" );
348348 }
349349
350350 Object current = type ;
@@ -374,7 +374,7 @@ private Object evalTypeChain(String expr, Map<String, String> ctx) throws Except
374374 return current ;
375375 }
376376
377- private Object [] parseArgs (String argsInside , Map <String , String > ctx ) throws Exception {
377+ private Object [] parseArgs (String argsInside , Map <String , String > ctx ) throws InvocationTargetException , IllegalAccessException {
378378 if (argsInside .isEmpty ()) {
379379 return new Object [0 ];
380380 }
@@ -386,20 +386,20 @@ private Object[] parseArgs(String argsInside, Map<String, String> ctx) throws Ex
386386 return out ;
387387 }
388388
389- private Object invokeStaticAllowed (Class <?> cls , String method , Object [] args ) throws Exception {
389+ private Object invokeStaticAllowed (Class <?> cls , String method , Object [] args ) throws InvocationTargetException , IllegalAccessException {
390390 if (DENY_METHODS .contains (method )) {
391- throw new OperationNotSupportedException ("Method not allowed: " + method );
391+ throw new SecurityException ("Method not allowed: " + method );
392392 }
393393 Method m = findBestMethod (cls , method , true , args );
394394 return m .invoke (null , coerceArgs (m .getParameterTypes (), args ));
395395 }
396396
397- private Object invokeAnyAllowed (Object target , String method , Object [] args ) throws Exception {
397+ private Object invokeAnyAllowed (Object target , String method , Object [] args ) throws InvocationTargetException , IllegalAccessException {
398398 if (target == null ) {
399399 return null ;
400400 }
401401 if (DENY_METHODS .contains (method )) {
402- throw new OperationNotSupportedException ("Method not allowed: " + method );
402+ throw new SecurityException ("Method not allowed: " + method );
403403 }
404404
405405 if ("toString" .equals (method ) && args .length == 0 ) {
@@ -411,7 +411,7 @@ private Object invokeAnyAllowed(Object target, String method, Object[] args) thr
411411 return m .invoke (target , coerceArgs (m .getParameterTypes (), args ));
412412 }
413413
414- throw new OperationNotSupportedException ("Instance calls not allowed on: " + target .getClass ().getName ());
414+ throw new SecurityException ("Instance calls not allowed on: " + target .getClass ().getName ());
415415 }
416416
417417 private Method findBestMethod (Class <?> cls , String name , boolean wantStatic , Object [] args ) {
0 commit comments