public class NorthboundUtils {
-
+
/**
* Returns whether the current user has the required privilege on the
* specified container
- *
+ *
* @param userName
* The user name
* @param containerName
* @param required
* Operation to be performed - READ/WRITE
* @param bundle
- * Class from where the function is invoked
+ * Class from where the function is invoked
* @return The Status of the request, either Success or Unauthorized
*/
public static boolean isAuthorized(String userName, String containerName,
Privilege required,Object bundle) {
-
+
if (containerName.equals(GlobalConstants.DEFAULT.toString())) {
IUserManager auth = (IUserManager) ServiceHelper.getGlobalInstance(
IUserManager.class, bundle);
-
+
switch (required) {
case WRITE:
return (auth.getUserLevel(userName).ordinal() <= UserLevel.NETWORKADMIN.ordinal());
case READ:
- return (auth.getUserLevel(userName).ordinal() <= UserLevel.NETWORKOPERATOR.ordinal());
+ return (auth.getUserLevel(userName).ordinal() <= UserLevel.NETWORKOPERATOR.ordinal());
default:
return false;
}
}
return true;
}
-
+
}