本文整理汇总了Java中org.apache.shiro.authz.Permission.implies方法的典型用法代码示例。如果您正苦于以下问题:Java Permission.implies方法的具体用法?Java Permission.implies怎么用?Java Permission.implies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.shiro.authz.Permission
的用法示例。
在下文中一共展示了Permission.implies方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authorize
import org.apache.shiro.authz.Permission; //导入方法依赖的package包/类
@Override
public boolean authorize(final Object principal, final ResourcePermission context) {
if (principal == null)
return false;
User user = this.userNameToUser.get(principal.toString());
if (user == null)
return false; // this user is not authorized to do anything
// check if the user has this permission defined in the context
for (Role role : this.userNameToUser.get(user.name).roles) {
for (Permission permitted : role.permissions) {
if (permitted.implies(context)) {
return true;
}
}
}
return false;
}
示例2: getPermittedCommands
import org.apache.shiro.authz.Permission; //导入方法依赖的package包/类
public static List<TestCommand> getPermittedCommands(Permission permission) {
List<TestCommand> result = new ArrayList<>();
for (TestCommand testCommand : testCommands) {
ResourcePermission cPerm = testCommand.getPermission();
if (cPerm != null && permission.implies(cPerm)) {
result.add(testCommand);
}
}
return result;
}
示例3: getPermittedCommands
import org.apache.shiro.authz.Permission; //导入方法依赖的package包/类
public static List<MashTestCommand> getPermittedCommands(Permission permission) {
List<MashTestCommand> result = new ArrayList<>();
for (MashTestCommand mashCommand : mashCommands) {
ResourcePermission cPerm = mashCommand.getPermission();
if (cPerm != null && permission.implies(cPerm)) {
result.add(mashCommand);
}
}
return result;
}
示例4: isPermitted
import org.apache.shiro.authz.Permission; //导入方法依赖的package包/类
@Override
protected boolean isPermitted(Permission permission, AuthorizationInfo info) {
if (info == null || info instanceof AdvancedAuthorizationInfo && !((AdvancedAuthorizationInfo)info).authorized(project)) {
return false;
}
Collection<Permission> perms = getPermissions(info);
//提供给GlobalPermission使用.如果included = true,说明之前已经有GlobalPermission匹配过permission,且没有permission权限
boolean included = false;
if (CollectionUtils.isNotEmpty(perms)) {
for (Permission perm : perms) {
if (perm instanceof GlobalPermission) {
GlobalPermission gp = (GlobalPermission)perm;
//GlobalPermission包含permission
if (perm.implies(permission)) {
if (gp.isPermitted()) {
return true;
} else {
included = true;
}
}
} else if (perm.implies(permission)) {
return true;
}
}
}
//如果是系统一次性加载所有权限的模式且系统中不包含此验证permission则返回true,意思就是此permission不受权限管控,直接放行
return globalPermissionMode && !included;
}