class PkiExpress::SignatureFinisher
Attributes
output_file_path[R]
transfer_file_id[R]
Public Class Methods
new(config=PkiExpressConfig.new)
click to toggle source
Calls superclass method
PkiExpress::PkiExpressOperator::new
# File lib/pki_express/signature_finisher.rb, line 5 def initialize(config=PkiExpressConfig.new) super(config) @file_to_sign_path = nil @transfer_file_id = nil @data_file_path = nil @output_file_path = nil @signature = nil end
Public Instance Methods
complete(get_cert=true)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 271 def complete(get_cert=true) unless @file_to_sign_path raise 'The file to be signed was not set' end unless @transfer_file_id raise 'The transfer data file was not set' end unless @signature raise 'The signature was not set' end unless @output_file_path raise 'The output destination was not set' end args = [ @file_to_sign_path, File.expand_path(@transfer_file_id, @config.transfer_data_folder), @signature, @output_file_path, ] if @data_file_path args.append('--data-file') args.append(@data_file_path) end if get_cert # This operation can only be used on version greater than 1.8 of the # PKI Express. @version_manager.require_version('1.8') # Invoke command. result = invoke(Commands::COMPLETE_SIG, args) # Parse output and return model. model = parse_output(result) return PKCertificate.new(model.fetch(:signer)) end # Invoke command. invoke(Commands::COMPLETE_SIG, args) end
data_file()
click to toggle source
region The “data_file” accessors
# File lib/pki_express/signature_finisher.rb, line 108 def data_file _get_data_file end
data_file=(content_raw)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 121 def data_file=(content_raw) _set_data_file(content_raw) end
data_file_base64()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 138 def data_file_base64 _get_data_file_base64 end
data_file_base64=(content_base64)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 152 def data_file_base64=(content_base64) _set_data_file_base64(content_base64) end
data_file_path()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 171 def data_file_path _get_data_file_path end
data_file_path=(path)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 180 def data_file_path=(path) _set_data_file_path(path) end
file_to_sign()
click to toggle source
region The “file_to_sign” accessors
# File lib/pki_express/signature_finisher.rb, line 16 def file_to_sign _get_file_to_sign end
file_to_sign=(content_raw)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 29 def file_to_sign=(content_raw) _set_file_to_sign(content_raw) end
file_to_sign_base64()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 46 def file_to_sign_base64 _get_file_to_sign_base64 end
file_to_sign_base64=(content_base64)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 60 def file_to_sign_base64=(content_base64) _set_file_to_sign_base64(content_base64) end
file_to_sign_path()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 79 def file_to_sign_path _get_file_to_sign_path end
file_to_sign_path=(path)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 88 def file_to_sign_path=(path) _set_file_to_sign_path(path) end
output_file_path=(value)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 264 def output_file_path=(value) unless value raise 'The provided "output_file_path" is not valid' end @output_file_path = value end
signature()
click to toggle source
region The “signature” accessors
# File lib/pki_express/signature_finisher.rb, line 200 def signature _get_signature end
signature=(content_raw)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 209 def signature=(content_raw) _set_signature(content_raw) end
signature_base64()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 221 def signature_base64 _get_signature_base64 end
signature_base64=(content_base64)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 233 def signature_base64=(content_base64) _set_signature_base64(content_base64) end
transfer_file_id=(value)
click to toggle source
endregion
# File lib/pki_express/signature_finisher.rb, line 254 def transfer_file_id=(value) unless value raise 'The provided "transfer_file_id" is not valid' end unless File.exist?(File.expand_path(value, @config.transfer_data_folder)) raise 'The provided "transfer_file_id" does not exist' end @transfer_file_id = value end
Private Instance Methods
_get_data_file()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 112 def _get_data_file unless @data_file_path return nil end File.read(@data_file_path) end
_get_data_file_base64()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 142 def _get_data_file_base64 unless @data_file_path return nil end content = File.read(@data_file_path) Base64.encode64(content) end
_get_data_file_path()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 175 def _get_data_file_path @data_file_path end
_get_file_to_sign()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 20 def _get_file_to_sign unless @file_to_sign_path return nil end File.read(@file_to_sign_path) end
_get_file_to_sign_base64()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 50 def _get_file_to_sign_base64 unless @file_to_sign_path return nil end content = File.read(@file_to_sign_path) Base64.encode64(content) end
_get_file_to_sign_path()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 83 def _get_file_to_sign_path @file_to_sign_path end
_get_signature()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 204 def _get_signature @signature end
_get_signature_base64()
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 225 def _get_signature_base64 unless @signature return nil end Base64.encode64(@signature) end
_set_data_file(content_raw)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 125 def _set_data_file(content_raw) unless content_raw raise 'The provided "data_file" is not valid' end temp_file_path = self.create_temp_file File.open(temp_file_path, 'wb') do |f| f.write(content_raw) end @data_file_path = temp_file_path end
_set_data_file_base64(content_base64)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 156 def _set_data_file_base64(content_base64) unless content_base64 raise 'The provided "data_file_base64" is not valid' end begin content_raw = Base64.decode64(content_base64) rescue Error raise 'The provided "data_file_base64" is not Base64-encoded' end _set_data_file(content_raw) end
_set_data_file_path(path)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 184 def _set_data_file_path(path) unless path raise 'The provided "data_file_path" is not valid' end unless File.exists?(path) raise 'The provided "data_file_path" does not exist' end @data_file_path = path end
_set_file_to_sign(content_raw)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 33 def _set_file_to_sign(content_raw) unless content_raw raise 'The provided "file_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 @file_to_sign_path = temp_file_path end
_set_file_to_sign_base64(content_base64)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 64 def _set_file_to_sign_base64(content_base64) unless content_base64 raise 'The provided "file_to_sign_base64" is not valid' end begin content_raw = Base64.decode64(content_base64) rescue Error raise 'The provided "file_to_sign_base64" is not Base64-encoded' end _set_file_to_sign(content_raw) end
_set_file_to_sign_path(path)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 92 def _set_file_to_sign_path(path) unless path raise 'The provided "file_to_sign_path" is not valid' end unless File.exists?(path) raise 'The provided "file_to_sign_path" does not exist' end @file_to_sign_path = path end
_set_signature(content_raw)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 213 def _set_signature(content_raw) unless content_raw raise 'The provided "signature" is not valid' end @signature = content_raw end
_set_signature_base64(content_base64)
click to toggle source
# File lib/pki_express/signature_finisher.rb, line 237 def _set_signature_base64(content_base64) unless content_base64 raise 'The provided "signature_base64" is not valid' end begin content_raw = Base64.decode64(content_base64) rescue Error raise 'The provided "signature_base64" is not Base64-encoded' end _set_signature(content_raw) end