Created
January 13, 2016 18:58
-
-
Save romartin/5cbf1a062c96061c6ea3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Check that roles registered in the framework are created as realm groups as well, if not they cannot be used, as it couldn't be assigned. | |
| protected Set<Role> getRegisteredRoles() { | |
| final Set<Role> result = new LinkedHashSet<Role>(); | |
| final Set<Role> registeredRoles = SecurityManagementUtils.getRegisteredRoles(); | |
| if ( null != registeredRoles && !registeredRoles.isEmpty() ) { | |
| GroupManager groupManager = userSystemManager.groups(); | |
| for (final Role registeredRole : registeredRoles) { | |
| try { | |
| // If the groupManager does not found the role name, it will throw an exception, | |
| // so the role will be not added into the resulting list. | |
| groupManager.get(registeredRole.getName()); | |
| result.add(registeredRole); | |
| } catch (GroupNotFoundException e) { | |
| // Registered role not found as realm group. | |
| } | |
| } | |
| } | |
| return result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment