test_class.file: model/src/test/java/com/abiquo/server/core/enterprise/UserDAOTest.java
test_class.identifier: UserDAOTest
test_class.superclass: extends DefaultDAOTestBase<UserDAO, User>
test_case.body: @Test
      public void userIsAllowedToUserOwnEnterpriseVDCRestricted()
      {
          Map<String, Object> map = setupSysadminUserAndNormalUser(false);
          User user = (User) map.get("user");
          String[] ps = (String[]) map.get("user.privileges");
          VirtualDatacenter vdc = (VirtualDatacenter) map.get("user.virtualdatacenter");
  
          UserDAO dao = createDaoForRollbackTransaction();
  
          boolean isAllowed =
              dao.isUserAllowedToUseVirtualDatacenter(user.getNick(), user.getAuthType().name(), ps,
                  vdc.getId());
          Assert.assertTrue(isAllowed);
      }
test_case.class_method_signature: UserDAOTest.userIsAllowedToUserOwnEnterpriseVDCRestricted()
test_case.full_signature: @Test public void userIsAllowedToUserOwnEnterpriseVDCRestricted()
test_case.identifier: userIsAllowedToUserOwnEnterpriseVDCRestricted
test_case.invocations: setupSysadminUserAndNormalUser get get get createDaoForRollbackTransaction isUserAllowedToUseVirtualDatacenter getNick name getAuthType getId assertTrue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void userIsAllowedToUserOwnEnterpriseVDCRestricted()
focal_class.declarator: USER_ALLOWED_VDC_SQL =
          "select 1 from user u where u.user = :username and u.authType = :authtype and (('ENTERPRISE_ADMINISTER_ALL' in (:privileges) or 'USERS_MANAGE_OTHER_ENTERPRISES' in (:privileges) or 'PHYS_DC_RETRIEVE_DETAILS' in (:privileges)) or u.idEnterprise = (select vdc.idEnterprise from virtualdatacenter vdc where vdc.idVirtualDatacenter = :idvdc and (u.availableVirtualDatacenters is null or u.availableVirtualDatacenters REGEXP CONCAT('.*[,]?',:idvdc,'($|[,].*$)'))))"
focal_class.modifier: private static final
focal_class.original_string: private static final String USER_ALLOWED_VDC_SQL =
          "select 1 from user u where u.user = :username and u.authType = :authtype and (('ENTERPRISE_ADMINISTER_ALL' in (:privileges) or 'USERS_MANAGE_OTHER_ENTERPRISES' in (:privileges) or 'PHYS_DC_RETRIEVE_DETAILS' in (:privileges)) or u.idEnterprise = (select vdc.idEnterprise from virtualdatacenter vdc where vdc.idVirtualDatacenter = :idvdc and (u.availableVirtualDatacenters is null or u.availableVirtualDatacenters REGEXP CONCAT('.*[,]?',:idvdc,'($|[,].*$)'))))";
focal_class.type: String
focal_class.var_name: USER_ALLOWED_VDC_SQL
focal_class.declarator: USER_ALLOWED_ENTERPRSE_SQL =
          "select 1 from user u where u.user = :username and u.authType = :authtype "
              + "and (('ENTERPRISE_ADMINISTER_ALL' in (:privileges) or 'USERS_MANAGE_OTHER_ENTERPRISES' in (:privileges) or 'PHYS_DC_RETRIEVE_DETAILS' in (:privileges)) or u.idEnterprise = :identerprise)"
focal_class.modifier: private static final
focal_class.original_string: private static final String USER_ALLOWED_ENTERPRSE_SQL =
          "select 1 from user u where u.user = :username and u.authType = :authtype "
              + "and (('ENTERPRISE_ADMINISTER_ALL' in (:privileges) or 'USERS_MANAGE_OTHER_ENTERPRISES' in (:privileges) or 'PHYS_DC_RETRIEVE_DETAILS' in (:privileges)) or u.idEnterprise = :identerprise)";
focal_class.type: String
focal_class.var_name: USER_ALLOWED_ENTERPRSE_SQL
focal_class.file: model/src/main/java/com/abiquo/server/core/enterprise/UserDAO.java
focal_class.identifier: UserDAO
focal_class.class_method_signature: UserDAO.UserDAO()
focal_class.full_signature: public  UserDAO()
focal_class.identifier: UserDAO
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  UserDAO()
focal_class.class_method_signature: UserDAO.UserDAO(final EntityManager entityManager)
focal_class.full_signature: public  UserDAO(final EntityManager entityManager)
focal_class.identifier: UserDAO
focal_class.modifiers: public
focal_class.parameters: (final EntityManager entityManager)
focal_class.signature:  UserDAO(final EntityManager entityManager)
focal_class.class_method_signature: UserDAO.sameEnterprise(final Enterprise enterprise)
focal_class.full_signature: public static Criterion sameEnterprise(final Enterprise enterprise)
focal_class.identifier: sameEnterprise
focal_class.modifiers: public static
focal_class.parameters: (final Enterprise enterprise)
focal_class.return: Criterion
focal_class.signature: Criterion sameEnterprise(final Enterprise enterprise)
focal_class.class_method_signature: UserDAO.sameId(final Integer userId)
focal_class.full_signature: public static Criterion sameId(final Integer userId)
focal_class.identifier: sameId
focal_class.modifiers: public static
focal_class.parameters: (final Integer userId)
focal_class.return: Criterion
focal_class.signature: Criterion sameId(final Integer userId)
focal_class.class_method_signature: UserDAO.sameNick(final String nick)
focal_class.full_signature: public static Criterion sameNick(final String nick)
focal_class.identifier: sameNick
focal_class.modifiers: public static
focal_class.parameters: (final String nick)
focal_class.return: Criterion
focal_class.signature: Criterion sameNick(final String nick)
focal_class.class_method_signature: UserDAO.sameRole(final Role role)
focal_class.full_signature: public static Criterion sameRole(final Role role)
focal_class.identifier: sameRole
focal_class.modifiers: public static
focal_class.parameters: (final Role role)
focal_class.return: Criterion
focal_class.signature: Criterion sameRole(final Role role)
focal_class.class_method_signature: UserDAO.filterBy(final String filter)
focal_class.full_signature: private Criterion filterBy(final String filter)
focal_class.identifier: filterBy
focal_class.modifiers: private
focal_class.parameters: (final String filter)
focal_class.return: Criterion
focal_class.signature: Criterion filterBy(final String filter)
focal_class.class_method_signature: UserDAO.findByRole(final Role role)
focal_class.full_signature: public Collection<User> findByRole(final Role role)
focal_class.identifier: findByRole
focal_class.modifiers: public
focal_class.parameters: (final Role role)
focal_class.return: Collection<User>
focal_class.signature: Collection<User> findByRole(final Role role)
focal_class.class_method_signature: UserDAO.findByEnterprise(final Enterprise enterprise)
focal_class.full_signature: public Collection<User> findByEnterprise(final Enterprise enterprise)
focal_class.identifier: findByEnterprise
focal_class.modifiers: public
focal_class.parameters: (final Enterprise enterprise)
focal_class.return: Collection<User>
focal_class.signature: Collection<User> findByEnterprise(final Enterprise enterprise)
focal_class.class_method_signature: UserDAO.findByEnterprise(final Integer userId, final Enterprise enterprise)
focal_class.full_signature: public User findByEnterprise(final Integer userId, final Enterprise enterprise)
focal_class.identifier: findByEnterprise
focal_class.modifiers: public
focal_class.parameters: (final Integer userId, final Enterprise enterprise)
focal_class.return: User
focal_class.signature: User findByEnterprise(final Integer userId, final Enterprise enterprise)
focal_class.class_method_signature: UserDAO.find(final Enterprise enterprise, final String filter,
          final String orderBy, final boolean desc)
focal_class.full_signature: public Collection<User> find(final Enterprise enterprise, final String filter,
          final String orderBy, final boolean desc)
focal_class.identifier: find
focal_class.modifiers: public
focal_class.parameters: (final Enterprise enterprise, final String filter,
          final String orderBy, final boolean desc)
focal_class.return: Collection<User>
focal_class.signature: Collection<User> find(final Enterprise enterprise, final String filter,
          final String orderBy, final boolean desc)
focal_class.class_method_signature: UserDAO.find(final Enterprise enterprise, final Role role, final String filter,
          final String orderBy, final boolean desc, final boolean connected, final Integer offset,
          final Integer numResults)
focal_class.full_signature: public Collection<User> find(final Enterprise enterprise, final Role role, final String filter,
          final String orderBy, final boolean desc, final boolean connected, final Integer offset,
          final Integer numResults)
focal_class.identifier: find
focal_class.modifiers: public
focal_class.parameters: (final Enterprise enterprise, final Role role, final String filter,
          final String orderBy, final boolean desc, final boolean connected, final Integer offset,
          final Integer numResults)
focal_class.return: Collection<User>
focal_class.signature: Collection<User> find(final Enterprise enterprise, final Role role, final String filter,
          final String orderBy, final boolean desc, final boolean connected, final Integer offset,
          final Integer numResults)
focal_class.class_method_signature: UserDAO.createCriteria(final Enterprise enterprise, final Role role,
          final String[] filters, final String orderBy, final boolean desc, final boolean connected)
focal_class.full_signature: private Criteria createCriteria(final Enterprise enterprise, final Role role,
          final String[] filters, final String orderBy, final boolean desc, final boolean connected)
focal_class.identifier: createCriteria
focal_class.modifiers: private
focal_class.parameters: (final Enterprise enterprise, final Role role,
          final String[] filters, final String orderBy, final boolean desc, final boolean connected)
focal_class.return: Criteria
focal_class.signature: Criteria createCriteria(final Enterprise enterprise, final Role role,
          final String[] filters, final String orderBy, final boolean desc, final boolean connected)
focal_class.class_method_signature: UserDAO.existAnyUserWithNick(final String nick)
focal_class.full_signature: public boolean existAnyUserWithNick(final String nick)
focal_class.identifier: existAnyUserWithNick
focal_class.modifiers: public
focal_class.parameters: (final String nick)
focal_class.return: boolean
focal_class.signature: boolean existAnyUserWithNick(final String nick)
focal_class.class_method_signature: UserDAO.existAnyOtherUserWithNick(final User user, final String nick)
focal_class.full_signature: public boolean existAnyOtherUserWithNick(final User user, final String nick)
focal_class.identifier: existAnyOtherUserWithNick
focal_class.modifiers: public
focal_class.parameters: (final User user, final String nick)
focal_class.return: boolean
focal_class.signature: boolean existAnyOtherUserWithNick(final User user, final String nick)
focal_class.class_method_signature: UserDAO.getAbiquoUserByLogin(final String login)
focal_class.full_signature: public User getAbiquoUserByLogin(final String login)
focal_class.identifier: getAbiquoUserByLogin
focal_class.modifiers: public
focal_class.parameters: (final String login)
focal_class.return: User
focal_class.signature: User getAbiquoUserByLogin(final String login)
focal_class.class_method_signature: UserDAO.getUserByAuth(final String login, final AuthType authType)
focal_class.full_signature: public User getUserByAuth(final String login, final AuthType authType)
focal_class.identifier: getUserByAuth
focal_class.modifiers: public
focal_class.parameters: (final String login, final AuthType authType)
focal_class.return: User
focal_class.signature: User getUserByAuth(final String login, final AuthType authType)
focal_class.class_method_signature: UserDAO.sameAuthType(final AuthType authType)
focal_class.full_signature: public static Criterion sameAuthType(final AuthType authType)
focal_class.identifier: sameAuthType
focal_class.modifiers: public static
focal_class.parameters: (final AuthType authType)
focal_class.return: Criterion
focal_class.signature: Criterion sameAuthType(final AuthType authType)
focal_class.class_method_signature: UserDAO.existAnyUserWithNickAndAuth(final String nick, final AuthType authType)
focal_class.full_signature: public boolean existAnyUserWithNickAndAuth(final String nick, final AuthType authType)
focal_class.identifier: existAnyUserWithNickAndAuth
focal_class.modifiers: public
focal_class.parameters: (final String nick, final AuthType authType)
focal_class.return: boolean
focal_class.signature: boolean existAnyUserWithNickAndAuth(final String nick, final AuthType authType)
focal_class.class_method_signature: UserDAO.existAnyUserWithRole(final Role role)
focal_class.full_signature: public boolean existAnyUserWithRole(final Role role)
focal_class.identifier: existAnyUserWithRole
focal_class.modifiers: public
focal_class.parameters: (final Role role)
focal_class.return: boolean
focal_class.signature: boolean existAnyUserWithRole(final Role role)
focal_class.class_method_signature: UserDAO.isUserAllowedToUseVirtualDatacenter(final String username,
          final String authtype, final String[] privileges, final Integer idVdc)
focal_class.full_signature: @SuppressWarnings("rawtypes") public boolean isUserAllowedToUseVirtualDatacenter(final String username,
          final String authtype, final String[] privileges, final Integer idVdc)
focal_class.identifier: isUserAllowedToUseVirtualDatacenter
focal_class.modifiers: @SuppressWarnings("rawtypes") public
focal_class.parameters: (final String username,
          final String authtype, final String[] privileges, final Integer idVdc)
focal_class.return: boolean
focal_class.signature: boolean isUserAllowedToUseVirtualDatacenter(final String username,
          final String authtype, final String[] privileges, final Integer idVdc)
focal_class.class_method_signature: UserDAO.isUserAllowedToEnterprise(final String username, final String authtype,
          final String[] privileges, final Integer ident)
focal_class.full_signature: @SuppressWarnings("rawtypes") public boolean isUserAllowedToEnterprise(final String username, final String authtype,
          final String[] privileges, final Integer ident)
focal_class.identifier: isUserAllowedToEnterprise
focal_class.modifiers: @SuppressWarnings("rawtypes") public
focal_class.parameters: (final String username, final String authtype,
          final String[] privileges, final Integer ident)
focal_class.return: boolean
focal_class.signature: boolean isUserAllowedToEnterprise(final String username, final String authtype,
          final String[] privileges, final Integer ident)
focal_class.superclass: extends DefaultDAOBase<Integer, User>
focal_method.body: @SuppressWarnings("rawtypes")
      public boolean isUserAllowedToUseVirtualDatacenter(final String username,
          final String authtype, final String[] privileges, final Integer idVdc)
      {
  
          Query query = getSession().createSQLQuery(USER_ALLOWED_VDC_SQL);
          query.setParameter("username", username);
          query.setParameter("authtype", authtype);
          query.setParameterList("privileges", privileges);
          query.setParameter("idvdc", idVdc);
          List result = query.list();
  
          if (result == null || result.isEmpty())
          {
              return false;
          }
          else
          {
              return true;
          }
      }
focal_method.class_method_signature: UserDAO.isUserAllowedToUseVirtualDatacenter(final String username,
          final String authtype, final String[] privileges, final Integer idVdc)
focal_method.full_signature: @SuppressWarnings("rawtypes") public boolean isUserAllowedToUseVirtualDatacenter(final String username,
          final String authtype, final String[] privileges, final Integer idVdc)
focal_method.identifier: isUserAllowedToUseVirtualDatacenter
focal_method.invocations: createSQLQuery getSession setParameter setParameter setParameterList setParameter list isEmpty
focal_method.modifiers: @SuppressWarnings("rawtypes") public
focal_method.parameters: (final String username,
          final String authtype, final String[] privileges, final Integer idVdc)
focal_method.return: boolean
focal_method.signature: boolean isUserAllowedToUseVirtualDatacenter(final String username,
          final String authtype, final String[] privileges, final Integer idVdc)