当前位置: 首页>>代码示例>>Java>>正文


Java ConfigAttribute.getAttribute方法代码示例

本文整理汇总了Java中org.springframework.security.access.ConfigAttribute.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigAttribute.getAttribute方法的具体用法?Java ConfigAttribute.getAttribute怎么用?Java ConfigAttribute.getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.security.access.ConfigAttribute的用法示例。


在下文中一共展示了ConfigAttribute.getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decide

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
@Override
public void decide(Authentication authentication, Object o, Collection<ConfigAttribute> collection)
        throws AccessDeniedException, InsufficientAuthenticationException {
    if (collection == null) {
        return;
    }
    String needRole;
    //遍历需要的角色,如果一样,则通过
    CustomerUserDetail userDetail = (CustomerUserDetail) authentication.getPrincipal();
    List<Role> userRoleList = securityService.getUserRoleList(userDetail.getUsername(), userDetail.getAccountType());
    for (ConfigAttribute configAttribute : collection) {
        needRole = configAttribute.getAttribute();
        for (Role role : userRoleList) {
            if (needRole.equals(role.getRoleCode())) {
                return;
            }
        }
    }
    throw new AccessDeniedException("Cannot Access!");
}
 
开发者ID:DomKing,项目名称:busi-support,代码行数:21,代码来源:CustomerAccessDecisionManager.java

示例2: decide

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes)
		throws AccessDeniedException, InsufficientAuthenticationException {
	//System.err.println(" ---------------MaxAccessDecisionManager decide--------------- ");
	if(configAttributes == null) {
		return;
	}
	//所请求的资源拥有的权限(一个资源对多个权限)
	Iterator<ConfigAttribute> iterator = configAttributes.iterator();
	while(iterator.hasNext()) {
		ConfigAttribute configAttribute = iterator.next();
		//访问所请求资源所需要的权限
		String needPermission = configAttribute.getAttribute();
		//System.out.println("NEED-> "+needPermission);
		//用户所拥有的权限authentication
		for(GrantedAuthority ga : authentication.getAuthorities()) {
			//System.out.println("USER-> "+ga.getAuthority());
			if(needPermission.equals(ga.getAuthority())) {
				//System.out.println("pass");
				return;
			}
		}
	}
	//没有权限
	throw new AccessDeniedException("Access Denide!");
}
 
开发者ID:Fetax,项目名称:Fetax-AI,代码行数:26,代码来源:MainAccessDecisionManager.java

示例3: decide

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
@Override
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) throws AccessDeniedException, InsufficientAuthenticationException {
    if(null== configAttributes || configAttributes.size() <=0) {
        return;
    }
    ConfigAttribute c;
    String needRole;
    for(Iterator<ConfigAttribute> iter = configAttributes.iterator(); iter.hasNext(); ) {
        c = iter.next();
        needRole = c.getAttribute();
        for(GrantedAuthority ga : authentication.getAuthorities()) {
            if(needRole.trim().equals(ga.getAuthority())) {
                return;
            }
        }
    }
    throw new AccessDeniedException("no right");
}
 
开发者ID:finefuture,项目名称:data-migration,代码行数:19,代码来源:OwnAccessDecisionManager.java

示例4: decide

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
@Override
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) throws AccessDeniedException, InsufficientAuthenticationException {

    if(null== configAttributes || configAttributes.size() <=0) {
        return;
    }
    ConfigAttribute c;
    String needRole;
    for(Iterator<ConfigAttribute> iter = configAttributes.iterator(); iter.hasNext(); ) {
        c = iter.next();
        needRole = c.getAttribute();
        for(GrantedAuthority ga : authentication.getAuthorities()) {
            if(needRole.trim().equals(ga.getAuthority())) {
                return;
            }
        }
    }
    throw new AccessDeniedException("no right");
}
 
开发者ID:realxujiang,项目名称:itweet-boot,代码行数:20,代码来源:MyAccessDecisionManager.java

示例5: decide

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
@Override
public void decide(Authentication authentication, Object o, Collection<ConfigAttribute> collection)
        throws AccessDeniedException, InsufficientAuthenticationException {
    if (collection == null) {
        return;
    }
    String needRole;
    //遍历需要的角色,如果一样,则通过,避免角色信息变了,从数据库取
    CustomerUserDetail userDetail = (CustomerUserDetail) authentication.getPrincipal();
    List<Role> roleList = securityService.getUserRoleList(userDetail.getUsername(), userDetail.getAccountType());
    for (ConfigAttribute configAttribute : collection) {
        needRole = configAttribute.getAttribute();
        for (Role aRoleList : roleList) {
            if (aRoleList != null && needRole.equals(aRoleList.getRoleCode())) {
                return;
            }
        }
    }
    throw new AccessDeniedException("Cannot Access!");
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:21,代码来源:CustomerAccessDecisionManager.java

示例6: decide

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
@Override
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) throws AccessDeniedException, InsufficientAuthenticationException {
    if (configAttributes == null) {
        return;
    }

    for (ConfigAttribute ca : configAttributes) {
        String needRole = ca.getAttribute();
        //ga 为用户所被赋予的权限。 needRole 为访问相应的资源应该具有的权限。
        for (GrantedAuthority ga : authentication.getAuthorities()) {
            if (needRole.trim().equals(ga.getAuthority().trim())) {
                return;
            }
        }
    }

    throw new AccessDeniedException("没有权限进行操作!");
}
 
开发者ID:jeikerxiao,项目名称:SpringBootStudy,代码行数:19,代码来源:DemoAccessDecisionManager.java

示例7: decide

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
/**
 * @param authentication
 * @param object
 * @param configAttributes
 * @throws org.springframework.security.access.AccessDeniedException
 * @throws org.springframework.security.authentication.InsufficientAuthenticationException
 */
@Override
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) {
    if (null == configAttributes || configAttributes.size() <= 0) {
        return;
    }

    for (ConfigAttribute attr : configAttributes) {
        String attribute = attr.getAttribute();
        for (GrantedAuthority ga : authentication.getAuthorities()) {
            if (attribute.equals(ga.getAuthority())) {
                return;
            }
        }
    }

    throw new AccessDeniedException("no right");
}
 
开发者ID:microacup,项目名称:microbbs,代码行数:25,代码来源:MyAccessDecisionManager.java

示例8: decide

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
@Override
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) throws AccessDeniedException, InsufficientAuthenticationException {
	if (configAttributes == null) {
		return;
	}
	Iterator<ConfigAttribute> iterator = configAttributes.iterator();
	while (iterator.hasNext()) {
		ConfigAttribute configAttribute = iterator.next();
		String needPermission = configAttribute.getAttribute();
		for (GrantedAuthority grantedAuthority : authentication.getAuthorities()) {
			if (needPermission.equals(grantedAuthority.getAuthority())) {
				return;
			}
		}
	}
	throw new AccessDeniedException("权限不足!");
}
 
开发者ID:xiaolongzuo,项目名称:zxl,代码行数:18,代码来源:ResourceAccessDecisionManager.java

示例9: decide

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
@Override
public void decide(Authentication authentication, Object object,
		Collection<ConfigAttribute> configAttributes)
		throws AccessDeniedException, InsufficientAuthenticationException {
	if (configAttributes == null)
		return;
	// 所请求的资源拥有的权限(一个资源对多个权限)
	Iterator<ConfigAttribute> iterator = configAttributes.iterator();
	while (iterator.hasNext()) {
		ConfigAttribute configAttribute = iterator.next();
		// 访问所请求资源所需要的权限
		String needPermission = configAttribute.getAttribute();
		// 用户所拥有的权限authentication
		for (GrantedAuthority ga : authentication.getAuthorities())
			if (needPermission.equals(ga.getAuthority()))
				return;
	}
	// 没有权限
	throw new AccessDeniedException("拒绝访问。");
}
 
开发者ID:cjm0000000,项目名称:mmt,代码行数:21,代码来源:MMTAccessDecisionManager.java

示例10: supports

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
@Override
public boolean supports( ConfigAttribute configAttribute )
{
    boolean result = configAttribute.getAttribute() != null
        && configAttribute.getAttribute().startsWith( attributePrefix );

    LOG.debug( "Supports configAttribute: " + configAttribute + ", " + result + " (" + getClass().getSimpleName()
        + ")" );

    return result;
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:12,代码来源:AbstractPrefixedAccessDecisionVoter.java

示例11: decide

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) 
				throws AccessDeniedException, InsufficientAuthenticationException {
		if(configAttributes == null) {
			return;
		}
		//所请求的资源拥有的权限(一个资源对多个权限)
		Iterator<ConfigAttribute> iterator = configAttributes.iterator();
		
		while(iterator.hasNext()) {
			ConfigAttribute configAttribute = iterator.next();
			//访问所请求资源所需要的权限
			String needPermission = configAttribute.getAttribute();
			
			//用户所拥有的权限authentication
			for(GrantedAuthority ga : authentication.getAuthorities()) {
				if(needPermission.equals(ga.getAuthority())) {
					LoginInfo loginUser = UserContextHolder.getUser();
					Permission per = permissionManager.getById(needPermission);
					loginUser.setPermission(per.getApplication().getName()+"-"+per.getName()+per.getUrl());
					UserContextHolder.setUser(loginUser);
					//添加日志					
//					Log log = new Log();
//					log.setDf("0");
//					log.setIp(loginUser.getIp());
//					log.setPermission(per.getApplication().getName()+"-"+per.getName()+per.getUrl());
//					log.setTs(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
//					log.setType("APP_LOG001");
//					log.setUsername(loginUser.getUserName());
//					logManager.save(log);
					
					return;
				}
			}
		}
		//没有权限
		throw new AccessDeniedException(" 没有权限访问! ");
	}
 
开发者ID:545473750,项目名称:zswxsqxt,代码行数:38,代码来源:MyAccessDecisionManager.java

示例12: supports

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
public boolean supports(ConfigAttribute attribute) {
	if (denyAccess.equals(attribute.getAttribute()) || (attribute.getAttribute() != null)
			&& attribute.getAttribute().startsWith(scopePrefix)) {
		return true;
	}
	else {
		return false;
	}
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:10,代码来源:ScopeVoter.java

示例13: vote

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
@Override
public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> attributes) {
  int amount = this.defaultAmount;
  if (attributes != null) {
    for (ConfigAttribute attribute : attributes) {
      if (attribute.getAttribute() != null && attribute.getAttribute().startsWith(PREFIX + SEPARATOR)) {
        String amountAttributeValue = StringUtils.splitByWholeSeparatorPreserveAllTokens(attribute.getAttribute(), SEPARATOR)[1];
        try {
          // should be minimum zero
          amount = Math.max(0, Integer.parseInt(amountAttributeValue));
        } catch (NumberFormatException nfe) {
          LOGGER.debug(String.format("%s is NaN. Defaulting to %s for amount.", amountAttributeValue, defaultAmount), nfe);
        }
      }
    }
  }
  if (amount == 0) {
    return ACCESS_GRANTED;
  }
  int result = ACCESS_DENIED;
  T key = keyFactory.create(SecurityContextHolder.getContext());
  try {
    if (leakyBucketService.add(key, amount)) {
      result = ACCESS_GRANTED;
    }
  } catch (IllegalArgumentException iae) {
    // this should never occur since amount is minimum zero (Math.max)
    LOGGER.error(String.format("Illegal amount of tokens added to bucket: %s", amount),iae);
    throw iae;
  }
  if (result == ACCESS_DENIED) {
    throw new RDAPErrorException(TOO_MANY_REQUESTS_HTTP_CODE, "Too many requests");
  }
  return result;
}
 
开发者ID:DNSBelgium,项目名称:rdap,代码行数:36,代码来源:LeakyBucketVoter.java

示例14: getAttributeValue

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
public String getAttributeValue(ConfigAttribute attribute) {
    if (attribute instanceof WebExpressionConfigAttribute) {
        return ((WebExpressionConfigAttribute) attribute).getAuthorizeExpression().getExpressionString();
    } else {
        return attribute.getAttribute();
    }
}
 
开发者ID:maxdelo77,项目名称:replyit-master-3.2-final,代码行数:8,代码来源:PermissionVoter.java

示例15: supports

import org.springframework.security.access.ConfigAttribute; //导入方法依赖的package包/类
public boolean supports(ConfigAttribute attribute) {
    return attribute.getAttribute() != null;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:4,代码来源:PermissionVoter.java


注:本文中的org.springframework.security.access.ConfigAttribute.getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。