Beispiel #1
0
    def __init__(self, token_kind, uses=MAX_USES):
        """
        token_kind assumes currently only value 'submission.

        we plan to add other kinds like 'file'.

        """

        if reactor_override:
            reactor = reactor_override
        else:
            reactor = None

        self.kind = token_kind

        # both 'validity' variables need to be expressed in seconds
        self.start_validity_secs = GLSettings.memory_copy.submission_minimum_delay
        self.end_validity_secs = GLSettings.memory_copy.submission_maximum_ttl

        # Remind: this is just for developers, because if a clean house
        # is a sign of a waste life, a Token object without shortcut
        # is a sign of a psycho life. (vecnish!)
        if GLSettings.devel_mode:
            self.start_validity_secs = 0

        self.remaining_uses = uses

        # creation_date of token assignment
        self.creation_date = datetime.utcnow()

        # to keep track of the file uploaded associated
        self.uploaded_files = []

        self.id = rstr.xeger(r'[A-Za-z0-9]{42}')

        # initialization of token configuration
        self.human_captcha = False
        self.graph_captcha = False
        self.proof_of_work = False

        self.generate_token_challenge()

        TempObj.__init__(
            self,
            TokenList.token_dict,
            # token ID:
            self.id,
            # seconds of validity:
            self.start_validity_secs + self.end_validity_secs,
            reactor)
Beispiel #2
0
    def __init__(self, token_kind, context_id):
        """
        token_kind assumes currently only value 'submission.

        we plan to add other kinds like 'file'.

        """

        if reactor_override:
            reactor = reactor_override
        else:
            reactor = None

        self.kind = token_kind

        # both 'validity' variables need to be expressed in seconds
        self.start_validity_secs = GLSettings.memory_copy.submission_minimum_delay
        self.end_validity_secs = GLSettings.memory_copy.submission_maximum_ttl

        # Remind: this is just for developers, because if a clean house
        # is a sign of a waste life, a Token object without shortcut
        # is a sign of a psycho life. (vecnish!)
        if GLSettings.devel_mode:
            self.start_validity_secs = 0

        self.remaining_allowed_attempts = Token.MAXIMUM_ATTEMPTS_PER_TOKEN

        # creation_date of token assignment
        self.creation_date = datetime.utcnow()

        # in the future, difficulty can be trimmed on context basis too
        self.context_associated = context_id

        # to keep track of the file uploaded associated
        self.uploaded_files = []

        self.token_id = rstr.xeger(r'[A-Za-z0-9]{42}')

        # initialization
        self.human_captcha = False
        self.graph_captcha = False
        self.proof_of_work = False

        TempObj.__init__(self,
                         TokenList.token_dict,
                         # token ID:
                         self.token_id,
                         # seconds of validity:
                         self.start_validity_secs + self.end_validity_secs,
                         reactor)
Beispiel #3
0
    def __init__(self, token_kind, uses = MAX_USES):
        """
        token_kind assumes currently only value 'submission.

        we plan to add other kinds like 'file'.

        """

        if reactor_override:
            reactor = reactor_override
        else:
            reactor = None

        self.kind = token_kind

        # both 'validity' variables need to be expressed in seconds
        self.start_validity_secs = GLSettings.memory_copy.submission_minimum_delay
        self.end_validity_secs = GLSettings.memory_copy.submission_maximum_ttl

        # Remind: this is just for developers, because if a clean house
        # is a sign of a waste life, a Token object without shortcut
        # is a sign of a psycho life. (vecnish!)
        if GLSettings.devel_mode:
            self.start_validity_secs = 0

        self.remaining_uses = uses

        # creation_date of token assignment
        self.creation_date = datetime.utcnow()

        # to keep track of the file uploaded associated
        self.uploaded_files = []

        self.id = generateRandomKey(42)

        # initialization of token configuration
        self.human_captcha = False
        self.graph_captcha = False
        self.proof_of_work = False

        self.generate_token_challenge()

        TempObj.__init__(self,
                         TokenList.token_dict,
                         # token ID:
                         self.id,
                         # seconds of validity:
                         self.start_validity_secs + self.end_validity_secs,
                         reactor)
Beispiel #4
0
    def __init__(self, event_obj, request_time, debug=False):
        self.debug = debug
        self.creation_date = datetime_now()
        self.event_id = EventTrackQueue.event_number()
        self.event_type = event_obj['name']
        self.request_time = request_time

        if self.debug:
            log.debug("Creation of Event %s" % self.serialize_event())

        TempObj.__init__(self,
                         EventTrackQueue.queue,
                         self.event_id,
                         10, # seconds of validity
                         reactor_override)

        self.expireCallbacks.append(self.synthesis)
Beispiel #5
0
    def __init__(self, receiver_id, debug=False):
        self.debug = debug
        self.creation_date = datetime_now()
        self.receiver_id = receiver_id

        if receiver_id in LastHourMailQueue.receivers_in_threshold:
            log.err("Implementation error ? Receiver %s already present" % receiver_id)

        TempObj.__init__(self,
                         LastHourMailQueue.blocked_in_queue,
                         random.randint(0, 0xffff),
                         # seconds of validity:
                         GLSettings.memory_copy.notification_suspension_time,
                         reactor_override)

        log.info("Temporary disable emails for receiver %s for four hours" % self.receiver_id)
        LastHourMailQueue.receivers_in_threshold.append(receiver_id)
        self.expireCallbacks.append(self.reactivate_receiver_mails)
Beispiel #6
0
    def __init__(self, receiver_id, debug=False):
        self.debug = debug
        self.creation_date = datetime_now()
        self.receiver_id = receiver_id

        if receiver_id in LastHourMailQueue.receivers_in_threshold:
            log.err("Implementation error ? Receiver %s already present" % receiver_id)

        TempObj.__init__(self,
                         LastHourMailQueue.blocked_in_queue,
                         random.randint(0, 0xffff),
                         # seconds of validity:
                         GLSettings.memory_copy.notification_suspension_time,
                         reactor_override)

        log.info("Temporary disable emails for receiver %s for four hours" % self.receiver_id)
        LastHourMailQueue.receivers_in_threshold.append(receiver_id)
        self.expireCallbacks.append(self.reactivate_receiver_mails)
Beispiel #7
0
    def __init__(self, event_obj, request_time, debug=False):
        self.debug = debug
        self.creation_date = datetime_now()
        self.event_id = EventTrackQueue.event_number()
        self.event_type = event_obj['name']
        self.request_time = request_time

        if self.debug:
            log.debug("Creation of Event %s" % self.serialize_event())

        TempObj.__init__(
            self,
            EventTrackQueue.queue,
            self.event_id,
            # seconds of validity:
            GLSettings.anomaly_delta,
            reactor_override)

        self.expireCallbacks.append(self.synthesis)
Beispiel #8
0
    def __init__(self, event_obj, request_time, debug=False):
        self.debug = debug
        self.creation_date = datetime_now()
        self.event_id = EventTrackQueue.event_number()
        self.event_type = event_obj['name']
        self.request_time = request_time

        if self.debug:
            log.debug("Creation of Event %s" % self.serialize_event())

        TempObj.__init__(
            self,
            EventTrackQueue.queue,
            self.event_id,
            # seconds of validity:
            ANOMALY_WINDOW_SECONDS,
            reactor)

        self.expireCallbacks.append(self.synthesis)
Beispiel #9
0
    def __init__(self, receiver_id, receiver_name, debug=False):

        self.debug = debug
        self.creation_date = datetime_now()
        self.receiver_id = receiver_id
        self.event_id = LastHourMailQueue.get_incremental_number()

        # This variable is just used for debug/log purpose
        self.receiver_name = receiver_name

        TempObj.__init__(self,
                         LastHourMailQueue.event_queue,
                         self.event_id,
                         # seconds of validity:
                         3600,
                         reactor_override)

        LastHourMailQueue.per_receiver_lastmails.setdefault(receiver_id, 0)
        LastHourMailQueue.per_receiver_lastmails[receiver_id] += 1

        self.expireCallbacks.append(self.manage_mail_expiration)
Beispiel #10
0
    def __init__(self, receiver_id, receiver_name, debug=False):

        self.debug = debug
        self.creation_date = datetime_now()
        self.receiver_id = receiver_id
        self.event_id = LastHourMailQueue.get_incremental_number()

        # This variable is just used for debug/log purpose
        self.receiver_name = receiver_name

        TempObj.__init__(self,
                         LastHourMailQueue.event_queue,
                         self.event_id,
                         # seconds of validity:
                         3600,
                         reactor_override)

        LastHourMailQueue.per_receiver_lastmails.setdefault(receiver_id, 0)
        LastHourMailQueue.per_receiver_lastmails[receiver_id] += 1

        self.expireCallbacks.append(self.manage_mail_expiration)