Class: PDFWalker::Walker::SignWizard

Inherits:
Assistant
  • Object
show all
Includes:
SignatureDialogs
Defined in:
lib/pdfwalker/signing.rb

Constant Summary collapse

INTRO_PAGE =
0
KEY_SELECT_PAGE =
1
PKCS12_IMPORT_PAGE =
2
KEYPAIR_IMPORT_PAGE =
3
SIGNATURE_INFO_PAGE =
4
SIGNATURE_RESULT_PAGE =
5

Instance Method Summary collapse

Constructor Details

#initialize(parent, pdf) ⇒ SignWizard

Returns a new instance of SignWizard.



399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/pdfwalker/signing.rb', line 399

def initialize(parent, pdf)
    super()

    @parent = parent

    @pkey, @cert, @ca = nil, nil, []

    create_intro_page
    create_key_selection_page
    create_pkcs12_import_page
    create_keypair_import_page
    create_signature_info_page
    create_termination_page

    set_forward_page_func { |current_page|
        case current_page
        when KEY_SELECT_PAGE
            if @p12button.active? then PKCS12_IMPORT_PAGE else KEYPAIR_IMPORT_PAGE end

        when PKCS12_IMPORT_PAGE, KEYPAIR_IMPORT_PAGE
            SIGNATURE_INFO_PAGE

        else current_page.succ
        end
    }

    signal_connect('delete_event') { self.destroy }
    signal_connect('cancel') { self.destroy }
    signal_connect('close') { self.destroy }

    signal_connect('apply') {
        location = @location.text.empty? ? nil : @location.text
        contact = @email.text.empty? ? nil : @email.text
        reason = @reason.text.empty? ? nil : @reason.text

        begin
            pdf.sign(@cert, @pkey,
                     ca: @ca,
                     location: location,
                     contact: contact,
                     reason: reason)

            set_page_title(@lastpage, "Document has been signed")
            @msg_status.text = "The document has been signed.\n You should consider saving it now."

            @parent.reload
        rescue
            @parent.error("#{$!}: #{$!.backtrace.join($/)}")

            set_page_title(@lastpage, "Document has not been signed")
            @msg_status.text = "An error occured during the signature process."
        end
    }

    set_modal(true)

    show_all
end