File: mime_signed_message.rb

package info (click to toggle)
ruby-mail-gpg 0.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 328 kB
  • sloc: ruby: 2,289; makefile: 6
file content (28 lines) | stat: -rw-r--r-- 767 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'mail/gpg/verified_part'

module Mail
  module Gpg
    class MimeSignedMessage < Mail::Message

      def self.setup(signed_mail, options = {})
        content_part, signature = signed_mail.parts
        success, vr = SignPart.verify_signature(content_part, signature, options)
        self.new do
          verify_result vr
          signed_mail.header.fields.each do |field|
            header[field.name] = field.value
          end
          content_part.header.fields.each do |field|
            header[field.name] = field.value
          end
          if content_part.multipart?
            content_part.parts.each{|part| add_part part}
          else
            body content_part.body.raw_source
          end
        end
      end
    end
  end
end