当前位置: 首页>>代码示例>>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;未经允许,请勿转载。