-
-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
suggestion: allow to query enforcer for number of expected parameters for enforce call #33
Comments
Hi @DemianTinkiel , you can call jcasbin/src/test/java/org/casbin/jcasbin/main/EnforcerUnitTest.java Lines 214 to 220 in 7db9d32
Of course, we can do better by checking it in |
I see. Sure I'll submit a pr tomorrow (dev laptop currently unavailable). However in the case of |
@hsluoyz I'm creating the PR now but looking at |
I didn't quite get your idea. Can be be more specific? |
update: reading the Syntax for Models, it sounds like lets say I do Enforcer e = new Enforcer("examples/rbac_model.conf");
e.enforce("user501", "data9"); //Not enough params throw meaningful exception then getModel().model.get("p").get("p").tokens.length; |
@hsluoyz I submitted a PR perhaps that would make it more clear as to what I mean. |
Yes. You can do it with |
what I see is that the check should be done against |
I think you are right. You should check |
I've updated the PR #34 What is your release cycle? ie. when can I use a new version in maven that has these changes? |
codeclimate is not a hard requirement. Never mind.
I will make a release right after your PRs are finished. |
Given the different styles of supported models and the fact that the data source might be unknown/out of our control it would be useful to be able to determine the number of parameters required for a call to `enforcer#enforce(...)#.
Or at least fail with something better than
Method threw 'java.lang.ArrayIndexOutOfBoundsException' exception.
e.g.
would thrown an exception for
but would succeed for
I thought I could guess it from
enforcer.getAllActions()
but in the 1st case this returnsactions:[data1, data1, data2, data2]
while in the 2nd it (correctly) returns
actions:[read, write, write]
I think this particular scenario would be solvable with
enforcer.getAllDomains()
but is not very scalable as a solution for future changes.The text was updated successfully, but these errors were encountered: