Merge "Refactored ModuleBuilder to avoid name conflicts. Fixed implementation of...
authorGiovanni Meo <gmeo@cisco.com>
Wed, 5 Jun 2013 14:38:51 +0000 (14:38 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 5 Jun 2013 14:38:51 +0000 (14:38 +0000)
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/ARP.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/IPv4.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/LLDPTLV.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/packet/Packet.java
opendaylight/security/src/main/java/org/opendaylight/controller/security/ControllerCustomRealm.java
opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java
opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/IUserManager.java
opendaylight/usermanager/src/main/java/org/opendaylight/controller/usermanager/internal/UserManagerImpl.java

index f3aa35f637bdc2e0346beffe8899d0b56b6bb24c..dd51e85f20ee4bd9b6ba2d9e64ac0965a1fc33b2 100644 (file)
@@ -13,8 +13,6 @@ import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 
@@ -249,11 +247,27 @@ public class ARP extends Packet {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result
+                + ((fieldValues == null) ? 0 : fieldValues.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        ARP other = (ARP) obj;
+        if (fieldValues == null) {
+            if (other.fieldValues != null)
+                return false;
+        } else if (!fieldValues.equals(other.fieldValues))
+            return false;
+        return true;
     }
 }
index c7b97e9d483370d536559f2618507c3cc0279673..44318aab8c5c1626eb787b960acfaa3ede7bea29 100644 (file)
@@ -542,10 +542,12 @@ public class IPv4 extends Packet {
          * Deriving the Total Length here
          */
         int payloadLength = 0;
-        try {
-            payloadLength = payload.serialize().length;
-        } catch (PacketException e) {
-            logger.error("", e);
+        if (payload != null) {
+            try {
+                payloadLength = payload.serialize().length;
+            } catch (PacketException e) {
+                logger.error("", e);
+            }
         }
 
         this.setTotalLength((short) (this.getHeaderLen() + payloadLength));
index 9254e824c57494a528a8e40bcf2052e0e7ab5fdd..bf674022596d8eb09df2b99bdb72314bdbdaf2cc 100644 (file)
@@ -10,13 +10,11 @@ package org.opendaylight.controller.sal.packet;
 
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
-import java.util.HashMap;
-
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
+
 import org.apache.commons.lang3.tuple.MutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.opendaylight.controller.sal.utils.HexEncode;
@@ -144,12 +142,28 @@ public class LLDPTLV extends Packet {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result
+                + ((fieldValues == null) ? 0 : fieldValues.hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        LLDPTLV other = (LLDPTLV) obj;
+        if (fieldValues == null) {
+            if (other.fieldValues != null)
+                return false;
+        } else if (!fieldValues.equals(other.fieldValues))
+            return false;
+        return true;
     }
 
     @Override
@@ -164,7 +178,7 @@ public class LLDPTLV extends Packet {
 
     /**
      * Returns the size in bits of the whole TLV
-     * 
+     *
      * @return int - size in bits of full TLV
      */
     public int getTLVSize() {
@@ -176,7 +190,7 @@ public class LLDPTLV extends Packet {
     /**
      * Creates the ChassisID TLV value including the subtype and ChassisID
      * string
-     * 
+     *
      * @param nodeId
      *            node identifier string
      * @return the ChassisID TLV value in byte array
@@ -204,7 +218,7 @@ public class LLDPTLV extends Packet {
 
     /**
      * Creates the PortID TLV value including the subtype and PortID string
-     * 
+     *
      * @param portId
      *            port identifier string
      * @return the PortID TLV value in byte array
@@ -221,7 +235,7 @@ public class LLDPTLV extends Packet {
 
     /**
      * Creates the custom TLV value including OUI, subtype and custom string
-     * 
+     *
      * @param portId
      *            port identifier string
      * @return the custom TLV value in byte array
@@ -241,7 +255,7 @@ public class LLDPTLV extends Packet {
 
     /**
      * Retrieves the string from TLV value and returns it in HexString format
-     * 
+     *
      * @param tlvValue
      *            the TLV value
      * @param tlvLen
@@ -257,7 +271,7 @@ public class LLDPTLV extends Packet {
 
     /**
      * Retrieves the string from TLV value
-     * 
+     *
      * @param tlvValue
      *            the TLV value
      * @param tlvLen
@@ -274,7 +288,7 @@ public class LLDPTLV extends Packet {
     /**
      * Retrieves the custom string from the Custom TLV value which includes OUI,
      * subtype and custom string
-     * 
+     *
      * @param customTlvValue
      *            the custom TLV value
      * @param customTlvLen
index b19c0f862b9e559219d5a00e8a3d289122a6c1a8..58b5d3914aa2dc199111dd2f2dc1ff8d5289dcc0 100644 (file)
@@ -77,7 +77,7 @@ public abstract class Packet {
     /**
      * This method deserializes the data bits obtained from the wire into the
      * respective header and payload which are of type Packet
-     * 
+     *
      * @param byte[] data - data from wire to deserialize
      * @param int bitOffset bit position where packet header starts in data
      *        array
@@ -151,7 +151,7 @@ public abstract class Packet {
     /**
      * This method serializes the header and payload from the respective
      * packet class, into a single stream of bytes to be sent on the wire
-     * 
+     *
      * @return The byte array representing the serialized Packet
      * @throws PacketException
      */
@@ -206,7 +206,7 @@ public abstract class Packet {
      * byte stream which cannot be done or cannot be done efficiently during the
      * normal Packet.serialize() path. An example is the checksum computation
      * for IPv4
-     * 
+     *
      * @param byte[] - serialized bytes
      * @throws PacketException
      */
@@ -221,7 +221,7 @@ public abstract class Packet {
      * of checksum varies based on the protocol, this method is overridden.
      * Currently only IPv4 and ICMP do checksum computation and validation. TCP
      * and UDP need to implement these if required.
-     * 
+     *
      * @param byte[] data The byte stream representing the Ethernet frame
      * @param int startBitOffset The bit offset from where the byte array corresponding to this Packet starts in the frame
      * @throws PacketException
@@ -233,7 +233,7 @@ public abstract class Packet {
 
     /**
      * Gets the header length in bits
-     * 
+     *
      * @return int the header length in bits
      */
     public int getHeaderSize() {
@@ -256,7 +256,7 @@ public abstract class Packet {
      * This method fetches the start bit offset for header field specified by
      * 'fieldname'. The offset is present in the hdrFieldCoordMap of the
      * respective packet class
-     * 
+     *
      * @param String
      *            fieldName
      * @return Integer - startOffset of the requested field
@@ -269,7 +269,7 @@ public abstract class Packet {
      * This method fetches the number of bits for header field specified by
      * 'fieldname'. The numBits are present in the hdrFieldCoordMap of the
      * respective packet class
-     * 
+     *
      * @param String
      *            fieldName
      * @return Integer - number of bits of the requested field
@@ -297,7 +297,7 @@ public abstract class Packet {
     /**
      * Returns the raw payload carried by this packet in case payload was not
      * parsed. Caller can call this function in case the getPaylod() returns null.
-     * 
+     *
      * @return The raw payload if not parsable as an array of bytes, null otherwise
      */
     public byte[] getRawPayload() {
@@ -306,7 +306,7 @@ public abstract class Packet {
 
     /**
      * Set a raw payload in the packet class
-     * 
+     *
      * @param payload The raw payload as byte array
      */
     public void setRawPayload(byte[] payload) {
@@ -319,8 +319,8 @@ public abstract class Packet {
      * packet received from wire is not equal to the checksum read from the
      * stream. For the Packet class which do not have a checksum field, this
      * function will always return false.
-     * 
-     * 
+     *
+     *
      * @return true if the deserialized packet's recomputed checksum is not
      *         equal to the packet carried checksum
      */
index f2e339f0c71dbc927ad1fe93964e61bdb3813bca..a988673c7ef91b2f9d2297c4808b44b98986b63b 100644 (file)
@@ -31,8 +31,9 @@ public class ControllerCustomRealm  extends RealmBase {
                 .getGlobalInstance(IUserManager.class, this);
         if (userManager != null) {
             return userManager.getPassword(username);
-        } else
+        } else {
             throw new RuntimeException("User Manager reference is null");
+        }
     }
 
     @Override
@@ -40,14 +41,14 @@ public class ControllerCustomRealm  extends RealmBase {
         IUserManager userManager = (IUserManager) ServiceHelper
                 .getGlobalInstance(IUserManager.class, this);
         if (userManager != null) {
-            final List<String> levels = new ArrayList<String>(); 
-            UserLevel level = userManager.getUserLevel(username);
-            if (level == null) level = UserLevel.NOUSER;
-            levels.add(level.toString());
-            return new GenericPrincipal(username, "", levels);
-        } else
+            List<String> controllerRoles = new ArrayList<String>();
+            for (UserLevel level : userManager.getUserLevels(username)) {
+                controllerRoles.add(level.toString());
+            }
+            return new GenericPrincipal(username, "", controllerRoles);
+        } else {
             throw new RuntimeException("User Manager reference is null");
-
+        }
     }
 
     @Override
@@ -66,8 +67,9 @@ public class ControllerCustomRealm  extends RealmBase {
                 logger.error("Authentication failed for user " + username);
                 return null;
             }
-        } else
+        } else {
             throw new RuntimeException("User Manager reference is null");
+        }
     }
 
 }
index 1b1a47bf231b6613ae49fbe247552ea136c0e1f0..8ea2190f4aca09b1bc37b4889d61e4101904f82a 100644 (file)
@@ -1646,7 +1646,8 @@ CommandProvider {
 
     @Override
     public byte[] getNodeMAC(Node node) {
-        MacAddress mac = (MacAddress) nodeProps.get(MacAddress.name);
+        MacAddress mac = (MacAddress) this.getNodeProp(node,
+                MacAddress.name);
         return (mac != null) ? mac.getMacAddress() : null;
     }
 
index 0ec9445b1eea24c10559a91bbbbe57a19c7f6b7f..ed23b5f067c45ebd000ac52fffc919e9707800ef 100644 (file)
@@ -28,7 +28,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Returns the list of roles associated to the passed user name
-     * 
+     *
      * @param userName
      * @return the role associated to the user name
      */
@@ -37,7 +37,7 @@ public interface IUserManager extends UserDetailsService {
     /**
      * Authenticate user with AAA server and return authentication and
      * authorization info
-     * 
+     *
      * @param username
      *            the username
      * @param password
@@ -49,7 +49,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Add/remove AAA server
-     * 
+     *
      * @param configObject
      *            {@link org.opendaylight.controller.usermanager.internal.ServerConfig}
      *            Server Configuration
@@ -60,7 +60,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Remove AAA server
-     * 
+     *
      * @param configObject
      *            refer to
      *            {@link org.opendaylight.controller.usermanager.internal.ServerConfig}
@@ -72,7 +72,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Add a local user
-     * 
+     *
      * @param configObject
      *            {@link org.opendaylight.controller.usermanager.internal.UserConfig}
      *            User Configuration
@@ -83,7 +83,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Remove a local user
-     * 
+     *
      * @param configObject
      *            {@link org.opendaylight.controller.usermanager.internal.UserConfig}
      *            UserConfig
@@ -94,7 +94,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Remove a local user
-     * 
+     *
      * @param userName
      *            the user name
      * @return {@link org.opendaylight.controller.sal.utils.Status}
@@ -105,7 +105,7 @@ public interface IUserManager extends UserDetailsService {
     /**
      * Add the authorization information for a user that gets authenticated
      * remotely
-     * 
+     *
      * @param AAAconf
      *            {@link org.opendaylight.controller.usermanager.internal.AuthorizationConfig}
      *            Authorization Resources
@@ -117,7 +117,7 @@ public interface IUserManager extends UserDetailsService {
     /**
      * Remove the authorization information for a user that gets authenticated
      * remotely
-     * 
+     *
      * @param AAAconf
      *            {@link org.opendaylight.controller.usermanager.internal.AuthorizationConfig}
      *            Authorization Resource
@@ -128,7 +128,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Return the list of authorization resources
-     * 
+     *
      * @return {@link org.opendaylight.controller.usermanager.internal.AuthorizationConfig}
      *         List of Authorization Resource
      */
@@ -136,14 +136,14 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Returns a list of AAA Providers.
-     * 
+     *
      * @return Set of provider names.
      */
     public Set<String> getAAAProviderNames();
 
     /**
      * Change the current password for a locally configured user
-     * 
+     *
      * @param user
      *            the username
      * @param curPasssword
@@ -158,7 +158,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Return a list of AAA servers currently configured
-     * 
+     *
      * @return {@link org.opendaylight.controller.usermanager.internal.ServerConfig}
      *         List of ServerConfig
      */
@@ -166,7 +166,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Return a list of local users
-     * 
+     *
      * @return {@link org.opendaylight.controller.usermanager.internal.UserConfig}
      *         List of UserConfig
      */
@@ -174,7 +174,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Save the local users to disk
-     * 
+     *
      * @return {@link org.opendaylight.controller.sal.utils.Status}
      *         status of this action
      */
@@ -182,7 +182,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Save the AAA server configurations to disk
-     * 
+     *
      * @return {@link org.opendaylight.controller.sal.utils.Status}
      *         status of this action
      */
@@ -190,7 +190,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Save the Authorization configurations to disk
-     * 
+     *
      * @return {@link org.opendaylight.controller.sal.utils.Status}
      *         status code
      */
@@ -198,7 +198,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Remove user profile when user logs out
-     * 
+     *
      * @param username
      *            the user name
      */
@@ -206,7 +206,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Remove user profile when user times out
-     * 
+     *
      * @param username
      *            the user name
      */
@@ -214,24 +214,24 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Get the list of users currently logged in
-     * 
+     *
      * @return the list of users along with their administrative roles
      */
     public Map<String, List<String>> getUserLoggedIn();
 
     /**
      * Get date and time user was successfully authenticated
-     * 
+     *
      * @param user
      * @return Date in String format
      */
     public String getAccessDate(String user);
 
     /**
-     * Returns the user level for the passed user name. It checks the roles
+     * Returns the highest user level for the passed user name. It checks the roles
      * assigned to this user and checks against the well known Controller user
      * roles to determines the highest user level associated with the user
-     * 
+     *
      * @param userName
      *            the user name
      * @return {@link org.opendaylight.controller.sal.authorization.UserLevel}
@@ -239,9 +239,21 @@ public interface IUserManager extends UserDetailsService {
      */
     public UserLevel getUserLevel(String userName);
 
+    /**
+     * Returns the list of user level for the passed user name. It checks the roles
+     * assigned to this user and checks against the well known Controller user
+     * roles to determines the corresponding list of user level associated with the user
+     *
+     * @param userName
+     *            the user name
+     * @return
+     *          the list of user level for this user
+     */
+    public List<UserLevel> getUserLevels(String userName);
+
     /**
      * Returns the Security Context
-     * 
+     *
      * @returns {@link org.springframework.security.web.context.SecurityContextRepository}
      *          Security Context
      */
@@ -249,7 +261,7 @@ public interface IUserManager extends UserDetailsService {
 
     /**
      * Returns the Session Manager Interface Handler
-     * 
+     *
      * @return {@link org.opendaylight.controller.usermanager.ISessionManager}
      *         session manager interface handler
      */
@@ -257,7 +269,7 @@ public interface IUserManager extends UserDetailsService {
 
     /* non-Javadoc
      * Returns the password for a given user
-     * 
+     *
      * @param username
      *            the user name
      * @return password for the username
index 69c9a1a2a615ee0c435b5fe8fccc7402e019568a..5ddf6be6c54914e9f0cf0047c0dd272ea7813590 100644 (file)
@@ -83,11 +83,11 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
     private ConcurrentMap<String, UserConfig> localUserConfigList;
     private ConcurrentMap<String, ServerConfig> remoteServerConfigList;
     // local authorization info for remotely authenticated users
-    private ConcurrentMap<String, AuthorizationConfig> authorizationConfList; 
+    private ConcurrentMap<String, AuthorizationConfig> authorizationConfList;
     private ConcurrentMap<String, AuthenticatedUser> activeUsers;
     private ConcurrentMap<String, IAAAProvider> authProviders;
     private ConcurrentMap<Long, String> localUserListSaveConfigEvent,
-            remoteServerSaveConfigEvent, authorizationSaveConfigEvent;
+    remoteServerSaveConfigEvent, authorizationSaveConfigEvent;
     private IClusterGlobalServices clusterGlobalService = null;
     private SecurityContextRepository securityContextRepo = new UserSecurityContextRepository();
     private IContainerAuthorization containerAuthorizationClient;
@@ -115,6 +115,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
         return authProviders.get(name);
     }
 
+    @Override
     public Set<String> getAAAProviderNames() {
         return authProviders.keySet();
     }
@@ -272,13 +273,13 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
                 } else if (rcResponse.getStatus() == AuthResultEnum.AUTH_REJECT) {
                     logger.info(
                             "Remote Authentication Rejected User: \"{}\", from Server: {}, Reason:{}",
-                            new Object[] {userName, aaaServer.getAddress(),
-                            rcResponse.getStatus().toString()});
+                            new Object[] { userName, aaaServer.getAddress(),
+                                    rcResponse.getStatus().toString() });
                 } else {
                     logger.info(
                             "Remote Authentication Failed for User: \"{}\", from Server: {}, Reason:{}",
-                            new Object[] {userName, aaaServer.getAddress(),
-                            rcResponse.getStatus().toString()});
+                            new Object[] { userName, aaaServer.getAddress(),
+                                    rcResponse.getStatus().toString() });
                 }
             }
         }
@@ -363,7 +364,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
         putUserInActiveList(userName, result);
         if (authorized) {
             logger.info("User \"{}\" authorized for the following role(s): {}",
-                        userName, result.getUserRoles());
+                    userName, result.getUserRoles());
         } else {
             logger.info("User \"{}\" Not Authorized for any role ", userName);
         }
@@ -390,6 +391,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
         activeUsers.remove(user);
     }
 
+    @Override
     public Status saveLocalUserList() {
         // Publish the save config event to the cluster nodes
         localUserListSaveConfigEvent.put(new Date().getTime(), SAVE);
@@ -402,6 +404,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
                 localUserConfigList), usersFileName);
     }
 
+    @Override
     public Status saveAAAServerList() {
         // Publish the save config event to the cluster nodes
         remoteServerSaveConfigEvent.put(new Date().getTime(), SAVE);
@@ -414,6 +417,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
                 remoteServerConfigList), serversFileName);
     }
 
+    @Override
     public Status saveAuthorizationList() {
         // Publish the save config event to the cluster nodes
         authorizationSaveConfigEvent.put(new Date().getTime(), SAVE);
@@ -628,7 +632,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
             return status;
         }
         // Trigger cluster update
-        localUserConfigList.put(user, targetConfigEntry); 
+        localUserConfigList.put(user, targetConfigEntry);
 
         logger.info("Password changed for User \"{}\"", user);
 
@@ -703,7 +707,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
         String userName = ci.nextArgument();
         String password = ci.nextArgument();
         String role = ci.nextArgument();
-        
+
         List<String> roles = new ArrayList<String>();
         while (role != null) {
             if (!role.trim().isEmpty()) {
@@ -734,7 +738,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
         if (target == null) {
             ci.println("User not found");
             return;
-        }       
+        }
         ci.println(this.removeLocalUser(target));
     }
 
@@ -815,7 +819,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
     /**
      * Function called by the dependency manager when all the required
      * dependencies are satisfied
-     * 
+     *
      */
     void init() {
     }
@@ -824,7 +828,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
      * Function called by the dependency manager when at least one dependency
      * become unsatisfied or when the component is shutting down because for
      * example bundle is being stopped.
-     * 
+     *
      */
     void destroy() {
     }
@@ -832,7 +836,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
     /**
      * Function called by dependency manager after "init ()" is called and after
      * the services provided by the class are registered in the service registry
-     * 
+     *
      */
     void start() {
         authProviders = new ConcurrentHashMap<String, IAAAProvider>();
@@ -855,7 +859,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
      * Function called by the dependency manager before the services exported by
      * the component are unregistered, this will be followed by a "destroy ()"
      * calls
-     * 
+     *
      */
     void stop() {
     }
@@ -919,6 +923,58 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
         return UserLevel.NOUSER;
     }
 
+
+    @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;
+    }
+
     @Override
     public Status saveConfiguration() {
         boolean success = true;
@@ -958,8 +1014,9 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
                     .getPassword(), enabled, accountNonExpired,
                     credentialsNonExpired, accountNonLocked,
                     user.getGrantedAuthorities(getUserLevel(username)));
-        } else
+        } else {
             throw new UsernameNotFoundException("User not found " + username);
+        }
     }
 
     @Override
@@ -1011,9 +1068,10 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
                             .getName())));
             return authentication;
 
-        } else
+        } else {
             throw new BadCredentialsException(
                     "Username or credentials did not match");
+        }
 
     }
 
@@ -1057,6 +1115,7 @@ public class UserManagerImpl implements IUserManager, IObjectReader,
         this.sessionMgr = sessionMgr;
     }
 
+    @Override
     public String getPassword(String username) {
         return localUserConfigList.get(username).getPassword();
     }