本文整理汇总了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());
}
示例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;
}
示例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;
}
示例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;
}