當前位置: 首頁>>代碼示例>>Java>>正文


Java GrantedAuthority.getAuthority方法代碼示例

本文整理匯總了Java中org.springframework.security.core.GrantedAuthority.getAuthority方法的典型用法代碼示例。如果您正苦於以下問題:Java GrantedAuthority.getAuthority方法的具體用法?Java GrantedAuthority.getAuthority怎麽用?Java GrantedAuthority.getAuthority使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.security.core.GrantedAuthority的用法示例。


在下文中一共展示了GrantedAuthority.getAuthority方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: compare

import org.springframework.security.core.GrantedAuthority; //導入方法依賴的package包/類
public int compare(GrantedAuthority g1, GrantedAuthority g2) {
    if (g2.getAuthority() == null) {
        return -1;
    }

    if (g1.getAuthority() == null) {
        return 1;
    }

    return g1.getAuthority().compareTo(g2.getAuthority());
}
 
開發者ID:PacktPublishing,項目名稱:Spring-5.0-Cookbook,代碼行數:12,代碼來源:AppUserDetails.java

示例2: buildRoleCode

import org.springframework.security.core.GrantedAuthority; //導入方法依賴的package包/類
public static String buildRoleCode(GrantedAuthority role) {
	String result = role.getAuthority();
	if (role instanceof SysRole) {
		result = RoleType.SYS_ROLE.name() + ":" + result;
	}
	else {
		result = RoleType.APP_ROLE.name() + ":" + result;
	}
	return result;
}
 
開發者ID:melthaw,項目名稱:spring-backend-boilerplate,代碼行數:11,代碼來源:RbacUtils.java

示例3: hasRole

import org.springframework.security.core.GrantedAuthority; //導入方法依賴的package包/類
public boolean hasRole(Authentication authentication, String role) {
   Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
   for(GrantedAuthority authority : authorities) {
      String authorityRole = authority.getAuthority();
      if(authorityRole.equals(role)){
         return true;
      }
   }
   return false;
}
 
開發者ID:chen0040,項目名稱:spring-boot-slingshot,代碼行數:11,代碼來源:SpringAuthentication.java

示例4: authenticate

import org.springframework.security.core.GrantedAuthority; //導入方法依賴的package包/類
public Authentication authenticate(Authentication auth) throws AuthenticationException {
	JaasAuthenticationToken ret = (JaasAuthenticationToken)super.authenticate(auth);
	for (GrantedAuthority role: ret.getAuthorities()) {
		UniTimeUserContext user = new UniTimeUserContext(role.getAuthority(), ret.getName(), null, null);
		return new JaasAuthenticationToken(user, ret.getCredentials(), new ArrayList<GrantedAuthority>(user.getAuthorities()), ret.getLoginContext());
	}
	return null;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:9,代碼來源:JaasAuthenticationProvider.java


注:本文中的org.springframework.security.core.GrantedAuthority.getAuthority方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。