Project

General

Profile

« Previous | Next » 

Revision eb6e0359

Added by Marc Dequènes about 14 years ago

  • ID eb6e0359e66f7e92e69b30eaa3795818d2e29ab0

[evol] translation rework: new mechanism to handle translated/untranslated strings, make use of translation parameters, moved I18n class, translations update

View differences:

lib/cyborghood/mail.rb
class Mail < Delegator
include ActionMailer::Quoting
include ActionMailer::Utils
include GetText
include CHTranslation
MAX_DRIFT_TIME = 3600
......
def process
if is_marked?
return MailReport.new(:error => "Replay detected.")
return MailReport.new(:error => _("Replay detected."))
end
return process_signed() if is_pgp_signed?
return process_encrypted() if is_pgp_encrypted?
MailReport.new(:error => "Mail not RFC3156 compliant.")
MailReport.new(:error => _("Mail not RFC3156 compliant."))
end
def create_reply
......
def process_signed
sigs_check = verify_pgp_signature()
return MailReport.new(:error => "Mail not formatted correctly (signed part).") if sigs_check.nil? or sigs_check.size != 1
return MailReport.new(:error => _("Mail not formatted correctly (signed part).")) if sigs_check.nil? or sigs_check.size != 1
sig_check = sigs_check.first
return MailReport.new(:error => "Mail content tampered or badly signed: " + sig_check.to_s) unless sig_check.status == 0
return MailReport.new(:error => _("Mail content tampered or badly signed: %{sig_err}", :sig_err => sig_check.to_s)) unless sig_check.status == 0
logger.info "Mail content was properly signed by key #{sig_check.fingerprint}"
user = Person.find_by_fingerprint(sig_check.fingerprint)
return MailReport.new(:error => "Mail is from an unknown person.", :warn_sender => true) if user.nil?
return MailReport.new(:error => _("Mail is from an unknown person."), :warn_sender => true) if user.nil?
logger.info "Mail is from user #{user.uid} (#{user.cn})"
self.user = user
......
logger.debug "Signature drift time: #{drift}"
unless drift.abs < MAX_DRIFT_TIME
if drift > 0
return MailReport.new(:error => N_("The signature was made too long ago (check your system clock). Rejected message to avoid replay attacks."), :user => user)
return MailReport.new(:error => _("The signature was made too long ago (check your system clock). Rejected message to avoid replay attacks."), :user => user)
else
# mark message to prevent later replay of the message
mark_processed(sig_check.timestamp)
return MailReport.new(:error => N_("The signature was made in the future (check your system clock). Rejected message to avoid replay attacks."), :user => user)
return MailReport.new(:error => _("The signature was made in the future (check your system clock). Rejected message to avoid replay attacks."), :user => user)
end
end
......
end
end
MailReport.new(:error => "Mail not formatted correctly (encrypted part).")
MailReport.new(:error => _("Mail not formatted correctly (encrypted part)."))
end
def mark_dir

Also available in: Unified diff