Exemple #1
0
  def observable(self, **args):
    try:
      method = args.get('method', None)
      path = args.get('path')
      details = self.get_detail_value(args)
      inflated = self.get_inflated_value(args)
      headers = args.get('headers')
      requested_object = self.parse_path(path, method)
      json = args.get('json')
      # get the event
      observable_id = requested_object.get('event_id')
      if observable_id:
        observable = self.observable_controller.get_observable_by_uuid(observable_id)
        event = self.observable_controller.get_event_for_observable(observable)
        # check if event is viewable by the current user
        self.check_if_event_is_viewable(event)

        if requested_object['object_type'] is None:
          return self.__process_observable(method, event, observable, details, inflated, json, headers)
        elif requested_object['object_type'] == 'object':
          flat = self.get_flat_value(args)
          return self.__process_object(method, event, observable, requested_object, details, inflated, json, flat, headers)
        elif requested_object['object_type'] == 'observable':
          return self.__process_observable_child(method, event, observable, requested_object, details, inflated, json, headers)
        else:
          raise PathParsingException(u'{0} is not defined'.format(requested_object['object_type']))

      else:
        raise RestHandlerException(u'Invalid request - Observable cannot be called without ID')
    except ControllerNothingFoundException as error:
      raise RestHandlerNotFoundException(error)
    except ControllerException as error:
      raise RestHandlerException(error)
Exemple #2
0
 def mail(self, **args):
     try:
         method = args.get('method')
         json = args.get('json')
         path = args.get('path')
         details = self.get_detail_value(args)
         inflated = self.get_inflated_value(args)
         if method == 'GET':
             if len(path) > 0:
                 # if there is a uuid as next parameter then return single mail
                 uuid = path.pop(0)
                 mail = self.mail_controller.get_by_uuid(uuid)
                 return mail.to_dict(details, inflated)
             else:
                 # return all
                 mails = self.mail_controller.get_all()
                 result = list()
                 for mail in mails:
                     result.append(mail.to_dict(details, inflated))
                 return result
         elif method == 'PUT':
             if len(path) > 0:
                 uuid = path.pop(0)
                 mail = self.mail_controller.get_by_uuid(uuid)
                 mail.populate(json)
                 self.mail_controller.update_mail(mail, self.get_user())
                 return mail.to_dict(details, inflated)
             else:
                 raise RestHandlerException(
                     u'Cannot update user as no identifier was given')
         raise RestHandlerException(u'Unrecoverable error')
     except ControllerNothingFoundException as error:
         raise RestHandlerNotFoundException(error)
     except ControllerException as error:
         raise RestHandlerException(error)
Exemple #3
0
  def attributes(self, **args):
    try:
      result = list()
      # Add any
      result.append({'identifier': None, 'name': 'Any'})
      # Generic container fields
      result.append({'identifier': 'uuid', 'name': 'uuid'})
      result.append({'identifier': 'title', 'name': 'title'})
      result.append({'identifier': 'description', 'name': 'description'})

      attributes = self.search_controller.get_all_attributes()
      for attribtue in attributes:
        attr_dict = attribtue.to_dict(False, False)
        attr_dict['identifier'] = 'attribute:{0}'.format(attr_dict['identifier'])
        result.append(attr_dict)

      references = self.search_controller.get_all_references()
      for reference in references:
        ref_dict = reference.to_dict(False, False)
        ref_dict['identifier'] = 'reference:{0}'.format(ref_dict['identifier'])
        result.append(ref_dict)
      # Report fields
      return result
    except ControllerNothingFoundException as error:
      raise RestHandlerNotFoundException(error)
    except ControllerException as error:
      raise RestHandlerException(error)
Exemple #4
0
 def condition(self, **args):
     try:
         method = args.get('method')
         json = args.get('json')
         path = args.get('path')
         details = self.get_detail_value(args)
         inflated = self.get_inflated_value(args)
         if method == 'GET':
             if len(path) > 0:
                 uuid = path.pop(0)
                 condition = self.condition_controller.get_condition_by_uuid(
                     uuid)
                 return condition.to_dict(details, inflated)
             else:
                 conditions = self.condition_controller.get_all_conditions()
                 result = list()
                 for condition in conditions:
                     result.append(condition.to_dict(details, inflated))
                 return result
         elif method == 'POST':
             self.check_if_admin()
             if len(path) > 0:
                 raise RestHandlerException(
                     u'No post definied on the given path')
             else:
                 # Add new type
                 condition = Condition()
                 condition.populate(json)
                 # set the new checksum
                 self.condition_controller.insert_condition(condition)
                 return condition.to_dict(details, inflated)
         elif method == 'PUT':
             self.check_if_admin()
             if len(path) > 0:
                 # if there is a uuid as next parameter then return single user
                 uuid = path.pop(0)
                 condition = self.condition_controller.get_condition_by_uuid(
                     uuid)
                 condition.populate(json)
                 self.condition_controller.update_condition(condition)
                 return condition.to_dict(details, inflated)
             else:
                 raise RestHandlerException(
                     u'Cannot update condition as no identifier was given')
         elif method == 'DELETE':
             self.check_if_admin()
             if len(path) > 0:
                 # if there is a uuid as next parameter then return single user
                 uuid = path.pop(0)
                 self.condition_controller.remove_condition_by_uuid(uuid)
                 return 'OK'
             else:
                 raise RestHandlerException(
                     u'Cannot delete condition as no identifier was given')
     except ControllerNothingFoundException as error:
         raise RestHandlerNotFoundException(error)
     except ControllerException as error:
         raise RestHandlerException(error)
Exemple #5
0
 def types(self, **args):
   try:
     method = args.get('method')
     json = args.get('json')
     path = args.get('path')
     details = self.get_detail_value(args)
     inflated = self.get_inflated_value(args)
     if method == 'GET':
       if len(path) > 0:
         uuid = path.pop(0)
         type_ = self.attribute_definition_controller.get_type_by_uuid(uuid)
         return type_.to_dict(details, inflated)
       else:
         types = self.attribute_definition_controller.get_all_types()
         result = list()
         for type_ in types:
           result.append(type_.to_dict(details, inflated))
         return result
     elif method == 'POST':
       if len(path) > 0:
         raise RestHandlerException(u'No post definied on the given path')
       else:
         # Add new type
         type_ = AttributeType()
         type_.populate(json)
         # set the new checksum
         self.attribute_definition_controller.insert_type(type_)
         return type_.to_dict(details, inflated)
     elif method == 'PUT':
       if len(path) > 0:
         # if there is a uuid as next parameter then return single user
         uuid = path.pop(0)
         type_ = self.attribute_definition_controller.get_type_by_uuid(uuid)
         type_.populate(json)
         self.attribute_definition_controller.update_type(type_)
         return type_.to_dict(details, inflated)
       else:
         raise RestHandlerException(u'Cannot update type as no identifier was given')
     elif method == 'DELETE':
       if len(path) > 0:
         # if there is a uuid as next parameter then return single user
         uuid = path.pop(0)
         self.attribute_definition_controller.remove_type_by_uuid(uuid)
         return 'OK'
       else:
         raise RestHandlerException(u'Cannot delete type as no identifier was given')
     raise RestHandlerException(u'Unrecoverable error')
   except ControllerNothingFoundException as error:
     raise RestHandlerNotFoundException(error)
   except ControllerException as error:
     raise RestHandlerException(error)
Exemple #6
0
  def remove(self, **args):
    try:
      path = args.get('path')
      if len(path) > 0:
        uuid = path.pop(0)
        item = self.process_controller.get_process_item_by_uuid(uuid)
        user = self.get_user()

        self.process_controller.process_remove(item, user)
        return 'OK'
      else:
        raise RestHandlerException('No identifier provided')
    except ControllerNothingFoundException as error:
      raise RestHandlerNotFoundException(error)
    except ControllerException as error:
      raise RestHandlerException(error)
Exemple #7
0
 def activate(self, **args):
     details = self.get_detail_value(args)
     inflated = self.get_inflated_value(args)
     try:
         path = args.get('path')
         if len(path) > 0:
             uuid = path.pop(0)
             user = self.user_controller.get_user_by_uuid(uuid)
             self.user_controller.activate_user(user)
             return user.to_dict(details, inflated)
         else:
             raise RestHandlerException('No uuid given')
     except ControllerNothingFoundException as error:
         raise RestHandlerNotFoundException(error)
     except ControllerException as error:
         raise RestHandlerException(error)
Exemple #8
0
 def push(self, **args):
     try:
         path = args.get('path')
         if len(path) > 0:
             uuid = path.pop(0)
             server = self.sync_server_controller.get_server_by_uuid(uuid)
             if server.type == 'MISP':
                 return self.misp_adapter.push(server)
             elif server.type == 'Ce1sus':
                 return self.ce1sus_adapter.push(server)
             else:
                 raise RestHandlerException('Not Implemented')
     except ControllerNothingFoundException as error:
         raise RestHandlerNotFoundException(error)
     except (MISPAdapterException, ControllerException,
             Ce1susAdapterException) as error:
         raise RestHandlerException(error)
Exemple #9
0
 def resentmail(self, **args):
     try:
         path = args.get('path')
         if len(path) > 0:
             uuid = path.pop(0)
             user = self.user_controller.get_user_by_uuid(uuid)
             # set new random password for user
             user.plain_password = hashSHA1(u'{0}'.format(random.random()))
             self.user_controller.set_activation_str(user)
             self.user_controller.update_user(user)
             self.mail_controller.send_activation_mail(user)
             return 'Ok'
         else:
             raise RestHandlerException('No uuid given')
     except ControllerNothingFoundException as error:
         raise RestHandlerNotFoundException(error)
     except ControllerException as error:
         raise RestHandlerException(error)
Exemple #10
0
  def cancel(self, **args):
    try:
      path = args.get('path')
      details = self.get_detail_value(args)
      inflated = self.get_inflated_value(args)
      if len(path) > 0:
        uuid = path.pop(0)
        item = self.process_controller.get_process_item_by_uuid(uuid)
        user = self.get_user()

        self.process_controller.process_cancelled(item, user)
        return item.to_dict(details, inflated)
      else:
        raise RestHandlerException('No identifier provided')
    except ControllerNothingFoundException as error:
      raise RestHandlerNotFoundException(error)
    except ControllerException as error:
      raise RestHandlerException(error)
Exemple #11
0
  def processes(self, **args):
    try:
      path = args.get('path')
      details = self.get_detail_value(args)
      inflated = self.get_inflated_value(args)

      if len(path) > 0:
                # if there is a uuid as next parameter then return single user
        uuid = path.pop(0)
        process = self.process_controller.get_process_item_by_uuid(uuid)
        return process.to_dict(details, inflated)
      else:
        processes = self.process_controller.get_all_process_items()
        result = list()
        for process in processes:
          result.append(process.to_dict(details, inflated))
        return result
    except ControllerNothingFoundException as error:
      raise RestHandlerNotFoundException(error)
    except ControllerException as error:
      raise RestHandlerException(error)
Exemple #12
0
    def report(self, **args):
        try:
            method = args.get('method', None)
            path = args.get('path')
            details = self.get_detail_value(args)
            inflated = self.get_inflated_value(args)
            requested_object = self.parse_path(path, method)
            json = args.get('json')
            headers = args.get('headers')
            # get the event
            report_id = requested_object.get('event_id')
            if report_id:
                report = self.report_controller.get_report_by_uuid(report_id)
                event = report.event
                self.check_if_event_is_viewable(event)
                if requested_object['object_type'] is None:
                    # return the report
                    return self.__process_report(method, event, report,
                                                 details, inflated, json,
                                                 headers)
                elif requested_object['object_type'] == 'report':
                    return self.__process_child_report(method, event, report,
                                                       requested_object,
                                                       details, inflated, json,
                                                       headers)
                elif requested_object['object_type'] == 'reference':
                    return self.__process_reference(method, event, report,
                                                    requested_object, details,
                                                    inflated, json, headers)
                else:
                    raise PathParsingException(u'{0} is not defined'.format(
                        requested_object['object_type']))

            else:
                raise RestHandlerException(
                    u'Invalid request - Report cannot be called without ID')
        except ControllerNothingFoundException as error:
            raise RestHandlerNotFoundException(error)
        except ControllerException as error:
            raise RestHandlerException(error)
Exemple #13
0
  def search(self, **args):
    try:
      json = args.get('json', None)
      if json:
        needle = json.get('value', None)
        if needle and len(needle) > 2:
          operator = json.get('operator', None)
          if operator in ['<', '<=', '==', '>=', '>', 'like']:
            definition_id = json.get('field', None)

            return self.__prossess_search(needle, operator, definition_id)

          else:
            raise RestHandlerException(u'Operator "{0}" is unsupported'.format(operator))
        else:
          raise RestHandlerException(u'Search value "{0}" is too short'.format(needle))
      else:
        raise RestHandlerException(u'Post does not hold any body')
    except ControllerNothingFoundException as error:
      raise RestHandlerNotFoundException(error)
    except ControllerException as error:
      raise RestHandlerException(error)
Exemple #14
0
    def event(self, **args):
        try:
            method = args.get('method', None)
            path = args.get('path')
            details = self.get_detail_value(args)
            inflated = self.get_inflated_value(args)
            requested_object = self.parse_path(path, method)
            json = args.get('json')
            headers = args.get('headers')
            # get the event
            event_id = requested_object.get('event_id')
            if event_id:
                event = self.event_controller.get_event_by_uuid(event_id)
                # check if event is viewable by the current user
                self.check_if_event_is_viewable(event)

                if requested_object['object_type'] is None:
                    # return the event
                    return self.__process_event(method, event, details,
                                                inflated, json, headers)
                elif requested_object['object_type'] == 'observable':
                    return self.__process_observable(method, event,
                                                     requested_object, details,
                                                     inflated, json, headers)
                elif requested_object['object_type'] == 'indicator':
                    return self.__process_indicator(method, event,
                                                    requested_object, details,
                                                    inflated, json, headers)
                elif requested_object[
                        'object_type'] == 'observable_composition':
                    return self.__process_composed_observable(
                        method, event, requested_object, details, inflated,
                        json)
                elif requested_object['object_type'] == 'changegroup':
                    self.check_if_admin()
                    return self.__change_event_group(method, event, json)
                elif requested_object['object_type'] == 'comment':
                    return self.__process_commment(method, event,
                                                   requested_object, details,
                                                   inflated, json, headers)
                elif requested_object['object_type'] == 'publish':
                    return self.__publish_event(method, event,
                                                requested_object, details,
                                                inflated, json, headers)
                elif requested_object['object_type'] == 'validate':
                    return self.__process_event_validate(
                        method, event, requested_object, details, inflated,
                        json)
                elif requested_object['object_type'] == 'group':
                    return self.__process_event_group(method, event,
                                                      requested_object,
                                                      details, inflated, json)
                elif requested_object['object_type'] == 'relations':
                    return self.__process_event_relations(
                        method, event, requested_object, details, inflated,
                        json)
                elif requested_object['object_type'] == 'report':
                    return self.__process_event_report(method, event,
                                                       requested_object,
                                                       details, inflated, json,
                                                       headers)
                else:
                    raise PathParsingException(u'{0} is not defined'.format(
                        requested_object['object_type']))

            else:
                # This can only happen when a new event is inserted
                if method == 'POST':
                    # populate event
                    user = self.get_user()
                    event = self.assembler.assemble_event(
                        json, user, True, self.is_rest_insert(headers))
                    self.event_controller.insert_event(user, event, True, True)

                    return self.__return_event(event, details, inflated)
                else:
                    raise RestHandlerException(
                        u'Invalid request - Event cannot be called without ID')
        except ControllerNothingFoundException as error:
            raise RestHandlerNotFoundException(error)
        except ControllerException as error:
            raise RestHandlerException(error)
Exemple #15
0
    def attribute(self, **args):
        try:
            method = args.get('method')
            path = args.get('path')
            json = args.get('json')
            details = self.get_detail_value(args)
            inflated = self.get_inflated_value(args)
            if method == 'GET':
                if len(path) > 0:
                    # if there is a uuid as next parameter then return single user
                    uuid = path.pop(0)
                    # TODO: add inflate
                    definition = self.attribute_definition_controller.get_attribute_definitions_by_uuid(
                        uuid)
                    if len(path) > 0:
                        type_ = uuid = path.pop(0)
                        if type_ == 'object':
                            if len(path) > 0:
                                raise RestHandlerException(
                                    u'Use the object api instead')
                            else:
                                result = list()
                                for obj in definition.objects:
                                    result.append(
                                        obj.to_dict(details, inflated))
                                return result
                        else:
                            raise RestHandlerException(
                                u'"{0}" is not supported'.format(type_))
                    else:
                        return definition.to_dict(details, inflated)
                else:
                    # else return all

                    definitions = self.attribute_definition_controller.get_all_attribute_definitions(
                    )
                    result = list()
                    for definition in definitions:
                        result.append(definition.to_dict(details, inflated))
                    return result
            elif method == 'POST':
                self.check_if_admin()
                if len(path) > 0:
                    uuid = path.pop(0)
                    definition = self.attribute_definition_controller.get_attribute_definitions_by_uuid(
                        uuid)
                    if len(path) > 0:
                        type_ = path.pop(0)
                        if type_ == 'object':
                            # get the object definition
                            if isinstance(json, list):
                                # TODO: add support for lists
                                raise RestHandlerException(
                                    u'POST of attribute objects does not support lists'
                                )
                            uuid = json.get('identifier', None)
                            if uuid:
                                obj = self.object_definition_controller.get_object_definitions_by_uuid(
                                    uuid)
                                definition.objects.append(obj)
                                self.attribute_definition_controller.update_attribute_definition(
                                    definition, self.get_user())
                                return 'OK'
                            else:
                                raise RestHandlerException(
                                    u'No id was specified in the json post')
                        else:
                            raise RestHandlerException(
                                u'"{0}" is not supported'.format(type_))
                    else:
                        raise RestHandlerException(
                            u'If an id was specified you also must specify on which type it is associated'
                        )
                else:
                    # Add new user
                    attr_def = self.assembler.assemble_attribute_definition(
                        json)
                    # set the new checksum
                    self.attribute_definition_controller.insert_attribute_definition(
                        attr_def, self.get_user())
                    return attr_def.to_dict(details, inflated)
            elif method == 'PUT':
                self.check_if_admin()
                # update user
                if len(path) > 0:
                    # if there is a uuid as next parameter then return single user
                    uuid = path.pop(0)
                    attr_def = self.attribute_definition_controller.get_attribute_definitions_by_uuid(
                        uuid)
                    self.assembler.update_attribute_definition(attr_def, json)

                    # set the new checksum
                    self.attribute_definition_controller.update_attribute_definition(
                        attr_def, self.get_user())
                    return attr_def.to_dict(details, inflated)
                else:
                    raise RestHandlerException(
                        u'Cannot update user as no identifier was given')

            elif method == 'DELETE':
                self.check_if_admin()
                # Remove user
                if len(path) > 0:
                    # if there is a uuid as next parameter then return single user
                    uuid = path.pop(0)
                    if len(path) > 0:
                        type_ = path.pop(0)
                        if len(path) > 0:
                            definition = self.attribute_definition_controller.get_attribute_definitions_by_uuid(
                                uuid)
                            uuid = path.pop(0)
                            obj = self.object_definition_controller.get_object_definitions_by_uuid(
                                uuid)
                            definition.objects.remove(obj)
                            self.attribute_definition_controller.update_attribute_definition(
                                definition, self.get_user())

                        else:
                            raise RestHandlerException(
                                u'If an id was specified you also must specify on which type it is associated'
                            )
                    else:
                        self.attribute_definition_controller.remove_definition_by_uuid(
                            uuid)

                    return 'OK'
                else:
                    raise RestHandlerException(
                        u'Cannot delete user as no identifier was given')
            raise RestHandlerException(u'Unrecoverable error')
        except ControllerNothingFoundException as error:
            raise RestHandlerNotFoundException(error)
        except ControllerException as error:
            raise RestHandlerException(error)
Exemple #16
0
    def user(self, **args):
        try:
            method = args.get('method')
            path = args.get('path')
            details = self.get_detail_value(args)
            inflated = self.get_inflated_value(args)
            json = args.get('json')
            if method == 'GET':

                if len(path) > 0:
                    # if there is a uuid as next parameter then return single user
                    uuid = path.pop(0)

                    user = self.user_controller.get_user_by_uuid(uuid)
                    if details:
                        password = '******'
                        if is_plugin_available('ldap', self.config):
                            ldap_password_identifier = get_plugin_function(
                                'ldap', 'get_ldap_pwd_identifier', self.config,
                                'internal_plugin')()

                            if user.password == ldap_password_identifier:
                                password = ldap_password_identifier

                        user.password = password

                        return user.to_dict(details, inflated)
                    else:
                        return user.to_dict(details, inflated)
                else:
                    # else return all
                    users = self.user_controller.get_all_users()
                    result = list()
                    for user in users:
                        if details:
                            password = AdminUserHandler.PASSWORD_MASK
                            if is_plugin_available('ldap', self.config):
                                ldap_password_identifier = get_plugin_function(
                                    'ldap', 'get_ldap_pwd_identifier',
                                    self.config, 'internal_plugin')()
                                password = ldap_password_identifier
                            user.password = password
                            result.append(user.to_dict(details, inflated))
                        else:
                            result.append(user.to_dict(details, inflated))
                    return result
            elif method == 'POST':
                # Add new user
                user = self.assembler.assemble_user(json)
                user.password = hashSHA1(user.plain_password, user.username)
                self.user_controller.insert_user(user)
                return user.to_dict(details, inflated)
            elif method == 'PUT':
                # update user
                if len(path) > 0:
                    # if there is a uuid as next parameter then return single user
                    uuid = path.pop(0)
                    user = self.user_controller.get_user_by_uuid(uuid)
                    user = self.assembler.update_user(user, json)
                    self.user_controller.update_user(user)
                    return user.to_dict(details, inflated)
                else:
                    raise RestHandlerException(
                        u'Cannot update user as no identifier was given')

            elif method == 'DELETE':
                # Remove user
                if len(path) > 0:
                    # if there is a uuid as next parameter then return single user
                    uuid = path.pop(0)
                    self.user_controller.remove_user_by_uuid(uuid)
                    return 'Deleted user'
                else:
                    raise RestHandlerException(
                        u'Cannot delete user as no identifier was given')
            raise RestHandlerException(u'Unrecoverable error')
        except ControllerNothingFoundException as error:
            raise RestHandlerNotFoundException(error)
        except ControllerException as error:
            raise RestHandlerException(error)
Exemple #17
0
    def group(self, **args):
        try:
            method = args.get('method')
            path = args.get('path')
            details = self.get_detail_value(args)
            json = args.get('json')
            inflated = self.get_inflated_value(args)
            if method == 'GET':

                if len(path) > 0:
                    # if there is a uuid as next parameter then return single group
                    uuid = path.pop(0)

                    group = self.group_controller.get_group_by_uuid(uuid)

                    if len(path) > 0:
                        # check if the next path
                        children = path.pop(0)
                        if children == 'children':
                            # return the children of the group

                            result = list()
                            for child in group.children:
                                result.append(child.to_dict(details, inflated))
                            return result

                    return group.to_dict(details, inflated)
                else:
                    # else return all
                    groups = self.group_controller.get_all_groups()
                    result = list()
                    for group in groups:
                        result.append(group.to_dict(details, inflated))
                    return result

            elif method == 'POST':
                self.check_if_admin()
                if len(path) > 0:
                    uuid = path.pop(0)
                    group = self.group_controller.get_group_by_uuid(uuid)
                    if len(path) > 0:
                        type_ = path.pop(0)
                        if type_ == 'children':
                            # get the object definition
                            if isinstance(json, list):
                                # TODO: add support for lists
                                raise RestHandlerException(
                                    u'POST of group children does not support lists'
                                )
                            uuid = json.get('identifier', None)
                            if uuid:
                                child = self.group_controller.get_group_by_uuid(
                                    uuid)
                                group.children.append(child)
                                self.group_controller.update_group(group)
                                return 'OK'
                            else:
                                raise RestHandlerException(
                                    u'No id was specified in the json post')
                        else:
                            raise RestHandlerException(
                                u'"{0}" is not supported'.format(type_))
                    else:
                        raise RestHandlerException(
                            u'If an id was specified you also must specify on which type it is associated'
                        )
                else:
                    # Add new group
                    group = Group()
                    group.populate(json)
                    self.group_controller.insert_group(group)
                    return group.to_dict(details, inflated)
            elif method == 'PUT':
                self.check_if_admin()
                # update group
                if len(path) > 0:
                    # if there is a uuid as next parameter then return single group
                    uuid = path.pop(0)
                    group = self.group_controller.get_group_by_uuid(uuid)
                    group.populate(json)
                    self.group_controller.update_group(group)
                    return group.to_dict(details, inflated)
                else:
                    raise RestHandlerException(
                        u'Cannot update group as no identifier was given')

            elif method == 'DELETE':
                self.check_if_admin()
                # Remove group
                if len(path) > 0:
                    # if there is a uuid as next parameter then return single group
                    uuid = path.pop(0)
                    if len(path) > 0:
                        type_ = path.pop(0)
                        if len(path) > 0:
                            group = self.group_controller.get_group_by_uuid(
                                uuid)
                            uuid = path.pop(0)
                            child = self.group_controller.get_group_by_uuid(
                                uuid)
                            group.children.remove(child)
                            self.group_controller.update_group(group)
                        else:
                            raise RestHandlerException(
                                u'If an id was specified you also must specify on which type it is associated'
                            )
                    else:
                        self.group_controller.remove_group_by_uuid(uuid)
                    return 'OK'
                else:
                    raise RestHandlerException(
                        u'Cannot delete group as no identifier was given')
            raise RestHandlerException(u'Unrecoverable error')
        except ControllerNothingFoundException as error:
            raise RestHandlerNotFoundException(error)
        except ControllerException as error:
            raise RestHandlerException(error)
    def reference(self, **args):
        try:
            method = args.get('method')
            json = args.get('json')
            path = args.get('path')
            details = self.get_detail_value(args)
            inflated = self.get_inflated_value(args)
            if method == 'GET':
                if len(path) > 0:
                    # if there is a uuid as next parameter then return single mail
                    uuid = path.pop(0)
                    reference = self.reference_controller.get_reference_definitions_by_uuid(
                        uuid)
                    return reference.to_dict(details, inflated)
                else:
                    # return all
                    references = self.reference_controller.get_reference_definitions_all(
                    )
                    result = list()
                    for reference in references:
                        result.append(reference.to_dict(details, inflated))
                    return result
            elif method == 'PUT':
                self.check_if_admin()
                if len(path) > 0:
                    uuid = path.pop(0)
                    reference = self.reference_controller.get_reference_definitions_by_uuid(
                        uuid)
                    reference = self.assembler.update_reference_definition(
                        reference, json)
                    self.reference_controller.update_reference_definition(
                        reference, self.get_user())
                    return reference.to_dict(details, inflated)
                else:
                    raise RestHandlerException(
                        u'Cannot update reference as no identifier was given')
            elif method == 'POST':
                self.check_if_admin()
                if len(path) > 0:
                    raise RestHandlerException(
                        u'Cannot insert reference as an identifier was given')
                else:
                    reference = self.assembler.assemble_reference_definition(
                        json)
                    self.reference_controller.insert_reference_definition(
                        reference, self.get_user())
                    return reference.to_dict(details, inflated)

            elif method == 'DELETE':
                self.check_if_admin()
                if len(path) > 0:
                    uuid = path.pop(0)
                    self.reference_controller.remove_reference_definition_by_uuid(
                        uuid)
                else:
                    raise RestHandlerException(
                        u'Cannot remove reference as no identifier was given')
            raise RestHandlerException(u'Unrecoverable error')
        except ControllerNothingFoundException as error:
            raise RestHandlerNotFoundException(error)
        except ControllerException as error:
            raise RestHandlerException(error)