-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- support subgroups and composite roles
- Loading branch information
vzakharchenko
committed
Jan 12, 2020
1 parent
71ff5bd
commit 1195219
Showing
34 changed files
with
370 additions
and
312 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 0 additions & 65 deletions
65
...askarius/keycloak/plugins/radius/radius/dictionary/ExternalDictionaryProviderFactory.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ua/zaskarius/keycloak/plugins/radius/radius/handlers/attributes/AttributeWalkerUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package ua.zaskarius.keycloak.plugins.radius.radius.handlers.attributes; | ||
|
||
import org.keycloak.models.GroupModel; | ||
import org.keycloak.models.RoleModel; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public final class AttributeWalkerUtils { | ||
|
||
private AttributeWalkerUtils() { | ||
} | ||
|
||
public static void groupWalker(GroupModel groupModel, Map<String, Set<String>> attributes) { | ||
Set<GroupModel> subGroups = groupModel.getSubGroups(); | ||
if (subGroups != null) { | ||
for (GroupModel subGroup : subGroups) { | ||
groupWalker(subGroup, attributes); | ||
} | ||
} | ||
Set<RoleModel> roleMappings = groupModel.getRoleMappings(); | ||
if (roleMappings != null) { | ||
for (RoleModel roleModel : roleMappings) { | ||
roleWalker(roleModel, attributes); | ||
} | ||
} | ||
Map<String, List<String>> modelAttributes = groupModel.getAttributes(); | ||
mergeMaps(modelAttributes, attributes); | ||
} | ||
|
||
|
||
private static void mergeMaps( | ||
Map<String, List<String>> modelAttributes1, | ||
Map<String, Set<String>> modelAttributes2 | ||
) { | ||
modelAttributes1.forEach((s, strings) -> { | ||
Set<String> set = modelAttributes2.get(s); | ||
if (set == null) { | ||
set = new HashSet<>(); | ||
modelAttributes2.put(s, set); | ||
} | ||
if (strings != null && !strings.isEmpty()) { | ||
set.addAll(strings); | ||
} | ||
}); | ||
} | ||
|
||
public static void roleWalker(RoleModel roleModel, Map<String, Set<String>> attributes) { | ||
if (roleModel.isComposite()) { | ||
Set<RoleModel> composites = roleModel.getComposites(); | ||
for (RoleModel r : composites) { | ||
roleWalker(r, attributes); | ||
} | ||
} | ||
mergeMaps(roleModel.getAttributes(), attributes); | ||
} | ||
} |
Oops, something went wrong.