+
+ @Override
+ public List<UserLevel> getUserLevels(String username) {
+ // Returns the controller well-know user levels for the passed user
+ List<String> rolesNames = null;
+ List<UserLevel> levels = new ArrayList<UserLevel>();
+
+ if (activeUsers.containsKey(username)) {
+ List<String> roles = activeUsers.get(username).getUserRoles();
+ rolesNames = (roles == null || roles.isEmpty()) ? null : roles;
+ } else if (localUserConfigList.containsKey(username)) {
+ UserConfig config = localUserConfigList.get(username);
+ rolesNames = (config == null) ? null : config.getRoles();
+ }
+
+ if (rolesNames == null) {
+ return levels;
+ }
+
+ // Check against the well known controller roles first
+ if (rolesNames.contains(UserLevel.SYSTEMADMIN.toString())) {
+ levels.add(UserLevel.SYSTEMADMIN);
+ }
+ if (rolesNames.contains(UserLevel.NETWORKADMIN.toString())) {
+ levels.add(UserLevel.NETWORKADMIN);
+ }
+ if (rolesNames.contains(UserLevel.NETWORKOPERATOR.toString())) {
+ levels.add(UserLevel.NETWORKOPERATOR);
+ }
+ // Check if container user now
+ if (containerAuthorizationClient != null) {
+ for (String roleName : rolesNames) {
+ if (containerAuthorizationClient.isApplicationRole(roleName)) {
+ levels.add(UserLevel.CONTAINERUSER);
+ break;
+ }
+ }
+ }
+ // Finally check if application user
+ if (applicationAuthorizationClients != null) {
+ for (String roleName : rolesNames) {
+ for (IResourceAuthorization client : this.applicationAuthorizationClients) {
+ if (client.isApplicationRole(roleName)) {
+ levels.add(UserLevel.APPUSER);
+ break;
+ }
+ }
+ }
+ }
+ return levels;
+ }
+