Skip to content
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

Not able to use loadFilteredPolicy with JdbcAdatper in Jcasbin #128

Closed
shreyasGit opened this issue Jan 27, 2021 · 12 comments · Fixed by #129
Closed

Not able to use loadFilteredPolicy with JdbcAdatper in Jcasbin #128

shreyasGit opened this issue Jan 27, 2021 · 12 comments · Fixed by #129
Assignees
Labels

Comments

@shreyasGit
Copy link

shreyasGit commented Jan 27, 2021

i think theres an issue in Jcasbin java version 1.6.3 and older , it does not support filtering on jdbc adapter, when i try to use https://github.com/jcasbin/casbin-spring-boot-starter with jcasbin, i see that in CoreEnforcer , it expects FilterAdapter only from file_adapter package, else throws this eroor.in short cannot use any jdbc adapter with Jcasbin

* loadFilteredPolicy reloads a filtered policy from file/database.
 *
 * @param filter the filter used to specify which type of policy should be loaded.
 */
public void loadFilteredPolicy(Object filter) {
    model.clearPolicy();
    FilteredAdapter filteredAdapter;
    if (adapter instanceof FilteredAdapter) {
        filteredAdapter = (FilteredAdapter) adapter;
    } else {
        throw new CasbinAdapterException("Filtered policies are not supported by this adapter.");
    }

in above code FilteredAdapter should be referenced from org.casbin.jcasbin.persist package which is a parent interface.
Due to this when i try to use any jdbcadapter to filter policies i get an error "Filtered policies are not supported by this adapter."

@hsluoyz hsluoyz self-assigned this Jan 27, 2021
@hsluoyz hsluoyz added the bug label Jan 27, 2021
@hsluoyz
Copy link
Member

hsluoyz commented Jan 27, 2021

@shy1st plz take a look.

@hsluoyz
Copy link
Member

hsluoyz commented Jan 28, 2021

@shreyasGit
Copy link
Author

this is not fixednow i get following error
Exception in thread "main" java.lang.ClassCastException: org.casbin.adapter.JdbcAdapter cannot be cast to org.casbin.jcasbin.persist.file_adapter.FilteredAdapter
at org.casbin.jcasbin.main.CoreEnforcer.loadFilteredPolicy(CoreEnforcer.java:241)
at com.sas.mkt.example.controller.DumpDataUtil.main(DumpDataUtil.java:58)

  if (adapter instanceof org.casbin.jcasbin.persist.FilteredAdapter) {
        filteredAdapter = (FilteredAdapter) adapter;

the cast is not needed

@shy1st
Copy link
Contributor

shy1st commented Feb 2, 2021

@shreyasGit Would you mind show me your code of how you create the JdbcAdapter?

@hsluoyz
Copy link
Member

hsluoyz commented Feb 5, 2021

ping @shreyasGit

@hsluoyz
Copy link
Member

hsluoyz commented Feb 7, 2021

@shreyasGit @shy1st I think I found the cause.

The latest version of casbin-spring-boot-starter was released 15 days ago: https://github.com/jcasbin/casbin-spring-boot-starter/releases/tag/0.0.11

However, latest jCasbin was released 10 days ago: https://github.com/casbin/jcasbin/releases/tag/v1.6.4

So we need to update casbin-spring-boot-starter's POM dependency to use jCasbin v1.6.4. @shy1st can you make a PR for it?

@shy1st
Copy link
Contributor

shy1st commented Feb 7, 2021

@hsluoyz yes,I can.

@shy1st
Copy link
Contributor

shy1st commented Feb 9, 2021

@shreyasGit @shy1st I think I found the cause.

The latest version of casbin-spring-boot-starter was released 15 days ago: https://github.com/jcasbin/casbin-spring-boot-starter/releases/tag/0.0.11

However, latest jCasbin was released 10 days ago: https://github.com/casbin/jcasbin/releases/tag/v1.6.4

So we need to update casbin-spring-boot-starter's POM dependency to use jCasbin v1.6.4. @shy1st can you make a PR for it?

@hsluoyz Please see: jcasbin/casbin-spring-boot-starter#26

@hsluoyz
Copy link
Member

hsluoyz commented Feb 9, 2021

@shy1st merged, plz make a new release of https://github.com/jcasbin/casbin-spring-boot-starter

@hsluoyz
Copy link
Member

hsluoyz commented Feb 10, 2021

@shreyasGit can you see if v0.0.12 fixed this issue? https://github.com/jcasbin/casbin-spring-boot-starter/releases/tag/0.0.12

@shy1st
Copy link
Contributor

shy1st commented Feb 11, 2021

The v0.0.12 of the casbin-spring-boot-starter had released in the maven repository.

@hsluoyz
Copy link
Member

hsluoyz commented Mar 7, 2021

@shreyasGit fixed in: #153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants