actframework / act-aaa-plugin

Use OSGL aaa library to mange Authentication/Authorization/Accounting for ActFramework Application
Apache License 2.0
6 stars 2 forks source link

AAAServiceFinder.ensureAAAIntegration swallows exceptions #43

Closed DeveloperClaus closed 4 years ago

DeveloperClaus commented 4 years ago

Starting from the https://github.com/act-gallery/bookmark example I modify the acl.yaml it the way, that I change to order of user (type role) to be the second (after root) instead of the last entry in that file, so that it comes before any permission, then the following exception is thrown:

org.osgl.exception.ConfigurationException: Cannot find permission[create-bookmark] when loading principal[user]
    at org.osgl.util.E.invalidConfiguration(E.java:297)
    at org.osgl.util.E.invalidConfigurationIf(E.java:324)
    at act.aaa.AAAService.loadRole(AAAService.java:596)

That is good, because it helps to find the cause of the error. However this exception is not shown on the console, I only saw it while debugging.. When I just start the application, I get this exception:

java.lang.NullPointerException: null
    at act.aaa.DynamicPermissionCheckHelperBase.permissions(DynamicPermissionCheckHelperBase.java:59)
    at org.osgl.aaa.AAA.registerDynamicPermissionChecker(AAA.java:103)

At least I get an exception and so I know that something is wrong. But since you already have the more precise exception, it is a pity that all I see is that NPE.

Similar I can make another change in the original acl.yaml. I change the part for the user to:

user:
  type: role
  permissions: create-bookmark

So in other words, the permissions was just a String and not a List<String>. That only leads to the same NPE. The ClassCastException that was originally there was surpressed, and a specific ConfigurationException was not there, either.

So in AAAServiceFinder.ensureAAAIntegration it probably is no good idea to try-finally without a catch-block that re-throws the exception.

greenlaw110 commented 4 years ago

Added a warn log when exception encountered, and now it will print out the error correctly: image