本文整理了Java中org.apache.shiro.subject.Subject.isPermittedAll()
方法的一些代码示例,展示了Subject.isPermittedAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Subject.isPermittedAll()
方法的具体详情如下:
包路径:org.apache.shiro.subject.Subject
类名称:Subject
方法名:isPermittedAll
[英]Returns true if this Subject implies all of the specified permissions, false otherwise.
More specifically, this method determines if all of the given Permissions are Permission#implies(Permission) permissions already associated with this Subject.
[中]如果此主题包含所有指定的权限,则返回true,否则返回false。
更具体地说,此方法确定所有给定权限是否都是权限#暗示(权限)已与此主题关联的权限。
代码示例来源:origin: apache/shiro
public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException {
Subject subject = getSubject(request, response);
String[] perms = (String[]) mappedValue;
boolean isPermitted = true;
if (perms != null && perms.length > 0) {
if (perms.length == 1) {
if (!subject.isPermitted(perms[0])) {
isPermitted = false;
}
} else {
if (!subject.isPermittedAll(perms)) {
isPermitted = false;
}
}
}
return isPermitted;
}
}
代码示例来源:origin: tomoya92/pybbs
public boolean hasAllPermission(String... name) {
return SecurityUtils.getSubject().isPermittedAll(name);
}
}
代码示例来源:origin: org.seedstack.seed/seed-security-core
@Override
public boolean isPermittedAll(String... permissions) {
return SecurityUtils.getSubject().isPermittedAll(permissions);
}
代码示例来源:origin: com.wuyushuo/vplus-data
/**
* 检查用户是有具有多个Permission
* @param permissions 权限
* @return 是否有权限
*/
public static boolean isPermittedAll(final Collection<Permission> permissions) {
boolean flag = false;
Subject subject = SecurityUtils.getSubject();
if (subject != null) {
flag = subject.isPermittedAll(permissions);
}
return flag;
}
代码示例来源:origin: org.seedstack.seed/seed-security-core
private boolean hasAllPermissions(String[] permissions) {
return SecurityUtils.getSubject().isPermittedAll(permissions);
}
代码示例来源:origin: liolay/shiro-spring-boot-starter
public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException {
Subject subject = this.getSubject(request, response);
String[] perms = (String[]) mappedValue;
boolean isPermitted = true;
if (perms != null && perms.length > 0) {
if (perms.length == 1) {
if (!subject.isPermitted(perms[0])) {
isPermitted = false;
}
} else if (!subject.isPermittedAll(perms)) {
isPermitted = false;
}
}
return isPermitted;
}
代码示例来源:origin: com.quhaodian/user_hibernate
public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException {
Subject subject = getSubject(request, response);
String[] perms = (String[]) mappedValue;
boolean isPermitted = true;
if (perms != null && perms.length > 0) {
if (perms.length == 1) {
if (!subject.isPermitted(perms[0])) {
isPermitted = false;
}
} else {
if (!subject.isPermittedAll(perms)) {
isPermitted = false;
}
}
}
return isPermitted;
}
}
代码示例来源:origin: com.haoxuer.discover/discover-common-user-hibernate
public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException {
Subject subject = getSubject(request, response);
String[] perms = (String[]) mappedValue;
boolean isPermitted = true;
if (perms != null && perms.length > 0) {
if (perms.length == 1) {
if (!subject.isPermitted(perms[0])) {
isPermitted = false;
}
} else {
if (!subject.isPermittedAll(perms)) {
isPermitted = false;
}
}
}
return isPermitted;
}
}
代码示例来源:origin: com.quhaodian.discover/discover-user
public boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws IOException {
Subject subject = getSubject(request, response);
String[] perms = (String[]) mappedValue;
boolean isPermitted = true;
if (perms != null && perms.length > 0) {
if (perms.length == 1) {
if (!subject.isPermitted(perms[0])) {
isPermitted = false;
}
} else {
if (!subject.isPermittedAll(perms)) {
isPermitted = false;
}
}
}
return isPermitted;
}
}
代码示例来源:origin: juzu/juzu
private boolean hasPermissions(Request request, JSON config) {
if (!SecurityUtils.getSubject().isAuthenticated()) {
return false;
}
JSON foo = config.getJSON("permissions");
Logical logical = Logical.valueOf(foo.getString("logical"));
List<String> permissions = (List<String>)foo.get("value");
if (permissions.size() == 1) {
return ShiroTools.isPermitted(permissions.get(0));
} else if (permissions.size() > 1) {
switch (logical) {
case AND :
return SecurityUtils.getSubject().isPermittedAll(permissions.toArray(new String[permissions.size()]));
case OR :
return ShiroTools.isPermitted(permissions.toArray(new String[permissions.size()]));
}
}
return false;
}
代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.shiro-core
private void handleRequiresPermissions( Subject subject )
{
if ( requiresPermissions != null ) {
LOGGER.debug( "SecurityConcern::RequiresPermissions" );
String permsString = requiresPermissions.value();
Set<String> permissions = PermissionUtils.toPermissionStrings( permsString );
if ( permissions.size() == 1 ) {
if ( !subject.isPermitted( permissions.iterator().next() ) ) {
String msg = "Calling Subject does not have required permission [" + permsString + "]. "
+ "Method invocation denied.";
throw new UnauthorizedException( msg );
}
} else {
String[] permStrings = new String[ permissions.size() ];
permStrings = permissions.toArray( permStrings );
if ( !subject.isPermittedAll( permStrings ) ) {
String msg = "Calling Subject does not have required permissions [" + permsString + "]. "
+ "Method invocation denied.";
throw new UnauthorizedException( msg );
}
}
} else {
LOGGER.debug( "SecurityConcern::RequiresPermissions: not concerned" );
}
}
代码示例来源:origin: apache/attic-polygene-java
private void handleRequiresPermissions( Subject subject )
{
if ( requiresPermissions != null ) {
LOGGER.debug( "SecurityConcern::RequiresPermissions" );
String permsString = requiresPermissions.value();
Set<String> permissions = PermissionUtils.toPermissionStrings( permsString );
if ( permissions.size() == 1 ) {
if ( !subject.isPermitted( permissions.iterator().next() ) ) {
String msg = "Calling Subject does not have required permission [" + permsString + "]. "
+ "Method invocation denied.";
throw new UnauthorizedException( msg );
}
} else {
String[] permStrings = new String[ permissions.size() ];
permStrings = permissions.toArray( permStrings );
if ( !subject.isPermittedAll( permStrings ) ) {
String msg = "Calling Subject does not have required permissions [" + permsString + "]. "
+ "Method invocation denied.";
throw new UnauthorizedException( msg );
}
}
} else {
LOGGER.debug( "SecurityConcern::RequiresPermissions: not concerned" );
}
}
代码示例来源:origin: sonia.scm/scm-test
when(subject.isPermitted(any(Permission.class))).thenReturn(Boolean.TRUE);
when(subject.isPermitted(any(String.class))).thenReturn(Boolean.TRUE);
when(subject.isPermittedAll(anyCollectionOf(Permission.class))).thenReturn(
Boolean.TRUE);
when(subject.isPermittedAll()).thenReturn(Boolean.TRUE);
when(subject.hasRole(Role.ADMIN)).thenReturn(Boolean.TRUE);
when(subject.hasRole(Role.USER)).thenReturn(Boolean.TRUE);
代码示例来源:origin: xpoft/spring-vaadin
if (logical == Logical.AND && subject.isPermittedAll(permissions))
if (logical == Logical.OR && subject.isPermittedAll(permissions))
代码示例来源:origin: org.apache.activemq/activemq-shiro
protected void assertAuthorized(DestinationAction action, String verbText) {
if (!isEnabled() || isSystemBroker(action)) {
return;
}
final Subject subject = getSubject(action.getConnectionContext());
Collection<Permission> perms = this.actionPermissionResolver.getPermissions(action);
if (!subject.isPermittedAll(perms)) {
String msg = createUnauthorizedMessage(subject, action, verbText);
throw new UnauthorizedException(msg);
}
}
代码示例来源:origin: org.apache.camel/camel-shiro
if (!policy.getPermissionsList().isEmpty()) {
if (policy.isAllPermissionsRequired()) {
authorized = currentUser.isPermittedAll(policy.getPermissionsList());
} else {
for (Permission permission : policy.getPermissionsList()) {
代码示例来源:origin: huangjian888/jeeweb-mybatis-springboot
boolean hasPermissionAll = getSubject().isPermittedAll(newPerms);
if(!hasPermissionAll){
onAccessDenied(request,response);
内容来源于网络,如有侵权,请联系作者删除!