class PkiExpress::PadesSignatureStarter
Attributes
certification_level[RW]
custom_signature_field_name[RW]
suppress_default_visual_representation[RW]
Public Class Methods
new(config=PkiExpressConfig.new)
click to toggle source
Calls superclass method
# File lib/pki_express/pades_signature_starter.rb, line 6 def initialize(config=PkiExpressConfig.new) super(config) @pdf_to_sign_path = nil @vr_json_path = nil @suppress_default_visual_representation = false @custom_signature_field_name = nil @certification_level = nil end
Public Instance Methods
pdf_to_sign()
click to toggle source
region The “pdf_to_sign” accessors
# File lib/pki_express/pades_signature_starter.rb, line 17 def pdf_to_sign _get_pdf_to_sign end
pdf_to_sign=(content_raw)
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 30 def pdf_to_sign=(content_raw) _set_pdf_to_sign(content_raw) end
pdf_to_sign_base64()
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 47 def pdf_to_sign_base64 _get_pdf_to_sign_base64 end
pdf_to_sign_base64=(content_base64)
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 61 def pdf_to_sign_base64=(content_base64) _set_pdf_to_sign_base64(content_base64) end
pdf_to_sign_path()
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 80 def pdf_to_sign_path _get_pdf_to_sign_path end
pdf_to_sign_path=(path)
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 89 def pdf_to_sign_path=(path) _set_pdf_to_sign_path(path) end
start()
click to toggle source
endregion
# File lib/pki_express/pades_signature_starter.rb, line 193 def start unless @pdf_to_sign_path raise 'The PDF to be signed was not set' end unless @certificate_path raise 'The certificate was not set' end # Generate transfer file. transfer_file_id = get_transfer_filename args = [ @pdf_to_sign_path, @certificate_path, File.expand_path(transfer_file_id, @config.transfer_data_folder), ] # Verify and add common options between signers. verify_and_add_common_options(args) if @vr_json_path args.append('--visual-rep') args.append(@vr_json_path) end if @custom_signature_field_name args.append('--custom-signature-field-name') args.append(@custom_signature_field_name) # This option can only be used on versions greater than 1.15.0 of the # PKI Express. @version_manager.require_version('1.15') end if @certification_level args.append('--certification-level') args.append(@certification_level) # This option can only be used on versions greater than 1.16.0 of the # PKI Express. @version_manager.require_version('1.16') end if @suppress_default_visual_representation args.append('--suppress-default-visual-rep') # This option can only be used on versions greater than 1.13.1 of the # PKI Express. @version_manager.require_version('1.13.1') end # Invoke command. result = invoke(Commands::START_PADES, args) # Parse output and return model. model = parse_output(result) SignatureStartResult.new(model, transfer_file_id) end
visual_representation()
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 162 def visual_representation _get_visual_representation end
visual_representation=(vr)
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 177 def visual_representation=(vr) _set_visual_representation(vr) end
visual_representation_content_raw()
click to toggle source
region set_visual_representation
# File lib/pki_express/pades_signature_starter.rb, line 108 def visual_representation_content_raw _get_visual_representation_content_raw end
visual_representation_content_raw=(content_raw)
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 121 def visual_representation_content_raw=(content_raw) _set_visual_representation_content_raw(content_raw) end
visual_representation_path()
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 138 def visual_representation_path _get_visual_representation_path end
visual_representation_path=(path)
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 147 def visual_representation_path=(path) _set_visual_representation_path(path) end
Private Instance Methods
_get_pdf_to_sign()
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 21 def _get_pdf_to_sign unless @pdf_to_sign_path return nil end File.read(@pdf_to_sign_path) end
_get_pdf_to_sign_base64()
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 51 def _get_pdf_to_sign_base64 unless @pdf_to_sign_path return nil end content = File.read(@pdf_to_sign_path) Base64.encode64(content) end
_get_pdf_to_sign_path()
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 84 def _get_pdf_to_sign_path @pdf_to_sign_path end
_get_visual_representation()
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 166 def _get_visual_representation unless @vr_json_path return nil end content = File.read(@vr_json_path) JSON.parse(content) end
_get_visual_representation_content_raw()
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 112 def _get_visual_representation_content_raw unless @vr_json_path return nil end File.read(@vr_json_path) end
_get_visual_representation_path()
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 142 def _get_visual_representation_path @vr_json_path end
_set_pdf_to_sign(content_raw)
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 34 def _set_pdf_to_sign(content_raw) unless content_raw raise 'The provided "pdf_to_sign" is not valid' end temp_file_path = self.create_temp_file File.open(temp_file_path, 'wb') do |f| f.write(content_raw) end @pdf_to_sign_path = temp_file_path end
_set_pdf_to_sign_base64(content_base64)
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 65 def _set_pdf_to_sign_base64(content_base64) unless content_base64 raise 'The provided "pdf_to_sign_base64" is not valid' end begin content_raw = Base64.decode64(content_base64) rescue Error raise 'The provided "pdf_to_sign_base64" is not Base64-encoded' end _set_pdf_to_sign(content_raw) end
_set_pdf_to_sign_path(path)
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 93 def _set_pdf_to_sign_path(path) unless path raise 'The provided "pdf_to_sign_path" is not valid' end unless File.exists?(path) raise 'The provided "pdf_to_sign_path" does not exist' end @pdf_to_sign_path = path end
_set_visual_representation(vr)
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 181 def _set_visual_representation(vr) temp_file_path = self.create_temp_file json = JSON.pretty_generate(vr.to_model) File.open(temp_file_path, 'w') do |f| f.write(json) end @vr_json_path = temp_file_path end
_set_visual_representation_content_raw(content_raw)
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 125 def _set_visual_representation_content_raw(content_raw) unless content_raw raise 'The provided "visual_representation" is not valid' end temp_file_path = self.create_temp_file File.open(temp_file_path, 'wb') do |f| f.write(content_raw) end @vr_json_path = temp_file_path end
_set_visual_representation_path(path)
click to toggle source
# File lib/pki_express/pades_signature_starter.rb, line 151 def _set_visual_representation_path(path) unless path raise 'The provided "visual_representation_path" is not valid' end unless File.exists?(path) raise 'The provided "visual_representation_path" does not exist' end @vr_json_path = path end