當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。