Пример #1
0
    def clean_sha_b(self):
        """
        The sha_b value is only a part of a SHA1 hexdigest. So we need to add
        some characers to use the rypt.validate_sha_value() method.
        """
        sha_b = self.cleaned_data["sha_b"]

        # Fill with null, to match the full SHA1 hexdigest length.
        fill_len = crypt.HASH_LEN - (crypt.HASH_LEN / 2)
        temp_value = ("0" * fill_len) + sha_b

        if crypt.validate_sha_value(temp_value) != True:
            raise forms.ValidationError(u"sha_b is not a valid SHA value.")

        return sha_b
Пример #2
0
def verify_email(request, hash):
    """ check a email hash """
    context, preferences = _get_context_pref()

    if not crypt.validate_sha_value(hash):
        LogEntry.objects.log_action(app_label="kurs_anmeldung", action="error",
            message="Wrong hash value %r" % hash
        )
        context["error"] = u"Hash wert im Link ist ungültig!"
        return context

    try:
        entry = KursAnmeldung.objects.get(verify_hash=hash)
    except Exception, err:
        msg = "Link ist ungültig!"
        LogEntry.objects.log_action(app_label="kurs_anmeldung", action="error",
            message="Can't get KursAnmeldung entry from hash value: %r" % hash
        )
        if settings.DEBUG:
            msg += " (Original error was: %s)" % err
        context["error"] = msg
        return context
Пример #3
0
def verify_email(request, hash):
    """ check a email hash """
    context, preferences = _get_context_pref()

    if not crypt.validate_sha_value(hash):
        LogEntry.objects.log_action(app_label="kurs_anmeldung",
                                    action="error",
                                    message="Wrong hash value %r" % hash)
        context["error"] = u"Hash wert im Link ist ungültig!"
        return context

    try:
        entry = KursAnmeldung.objects.get(verify_hash=hash)
    except Exception, err:
        msg = "Link ist ungültig!"
        LogEntry.objects.log_action(
            app_label="kurs_anmeldung",
            action="error",
            message="Can't get KursAnmeldung entry from hash value: %r" % hash)
        if settings.DEBUG:
            msg += " (Original error was: %s)" % err
        context["error"] = msg
        return context
Пример #4
0
    def clean_sha_a2(self):
        sha_a2 = self.cleaned_data["sha_a2"]
        if crypt.validate_sha_value(sha_a2) != True:
            raise forms.ValidationError(u"sha_a2 is not valid SHA value.")

        return sha_a2
Пример #5
0
 def _sha_validate1(self, sha_value, key):
     if crypt.validate_sha_value(sha_value) != True:
         raise forms.ValidationError(u"%s is not valid SHA value." % key)
     return sha_value
Пример #6
0
 def _validate_sha1(self, sha_value, key):
     if crypt.validate_sha_value(sha_value) != True:
         raise forms.ValidationError(u"%s is not valid SHA value." % key)
     return sha_value