本文整理匯總了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;
}