I have a string based permission check, like:
if (currentUser.isPermitted("admin:write")) {
log.info("Yes ["+ currentUser.getPrincipal() +"] have write
permisiion");
} else {
log.info("Sorry, user ["+ currentUser.getPrincipal() +"]
doesn't have write permisiion.");
}
I have gone through this link:
https://shiro.apache.org/authorization.html#Authorization-ObjectbasedPermissionChecks
and i want that, Instead of passing String in isPermitted() method, I want to
pass permission object as a argument in isPermitted method,
For this I am doing:
//getting apache.shiro.dto.Rolespermission cannot be cast to
org.apache.shiro.authz.Permission exception in below line
Permission rolePerm = (Permission) new Rolespermission("access", "admin");
//check whether user with role admin has access permission or
not
if (currentUser.isPermitted(rolePerm)) {
log.info("Yes ["+ currentUser.getPrincipal() +"] have
access permisiion");
} else {
log.info("Sorry, user ["+ currentUser.getPrincipal() +"]
doesn't have access permisiion.");
}
My Rolespermission is just a bean class.
public class Rolespermission {
private String permission;
private String roleName;
public Rolespermission(String permission, String roleName) {
this.permission = permission;
this.roleName = roleName;
}
//getter setter
}
I am getting apache.shiro.dto.Rolespermission cannot be cast to
org.apache.shiro.authz.Permission exception while construction Permission
object.
Can anyone please help me how to make Permissionobject?