INNER CODE UNIT · Java
doGetAuthorizationInfo
bujiio/buji-pac4j · src/main/java/io/buji/pac4j/realm/Pac4jRealm.java:103
protected AuthorizationInfo doGetAuthorizationInfo(final PrincipalCollection principals) {
final Set<String> roles = new HashSet<>();
final Set<String> permissions = new HashSet<>();
final Pac4jPrincipal principal = principals.oneByType(Pac4jPrincipal.class);
if (principal != null) {
final List<UserProfile> profiles = principal.getProfiles();
for (final UserProfile profile : profiles) {
if (profile != null) {
roles.addAll(profile.getRoles());
// assuming: profile.addAttribute(Pac4jRealm.SHIRO_PERMISSIONS, Arrays.asList("PERM1", "PERM2"));
val perm = profile.getAttribute(SHIRO_PERMISSIONS);
if (perm instanceof List) {
permissions.addAll((List) perm);
} else if (perm instanceof Set) {
permissions.addAll((Set) perm);
}
}
}