Class: Jrxades::XmlSig

Inherits:
Object
  • Object
show all
Defined in:
lib/jrxades/xml_sig.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_file_path, output_file_path, key_store_path, pass_phrase_for_key_store = nil, pass_phrase_for_key = nil) ⇒ XmlSig

Returns a new instance of XmlSig.



12
13
14
15
16
17
18
19
# File 'lib/jrxades/xml_sig.rb', line 12

def initialize(input_file_path, output_file_path, key_store_path, pass_phrase_for_key_store=nil, pass_phrase_for_key=nil)
  self.key_store_path = key_store_path
  self.pass_phrase_for_key_store = pass_phrase_for_key_store || ''
  self.pass_phrase_for_key = pass_phrase_for_key || ''
  self.output_path = File.dirname(output_file_path)
  self.out_file_name = File.basename(output_file_path)
  self.input_file_path = input_file_path
end

Instance Attribute Details

#input_file_pathObject

Returns the value of attribute input_file_path.



10
11
12
# File 'lib/jrxades/xml_sig.rb', line 10

def input_file_path
  @input_file_path
end

#key_store_pathObject

Returns the value of attribute key_store_path.



10
11
12
# File 'lib/jrxades/xml_sig.rb', line 10

def key_store_path
  @key_store_path
end

#out_file_nameObject

Returns the value of attribute out_file_name.



10
11
12
# File 'lib/jrxades/xml_sig.rb', line 10

def out_file_name
  @out_file_name
end

#output_pathObject

Returns the value of attribute output_path.



10
11
12
# File 'lib/jrxades/xml_sig.rb', line 10

def output_path
  @output_path
end

#pass_phrase_for_keyObject

Returns the value of attribute pass_phrase_for_key.



10
11
12
# File 'lib/jrxades/xml_sig.rb', line 10

def pass_phrase_for_key
  @pass_phrase_for_key
end

#pass_phrase_for_key_storeObject

Returns the value of attribute pass_phrase_for_key_store.



10
11
12
# File 'lib/jrxades/xml_sig.rb', line 10

def pass_phrase_for_key_store
  @pass_phrase_for_key_store
end

Instance Method Details

#key_data_valid?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
# File 'lib/jrxades/xml_sig.rb', line 25

def key_data_valid?
  begin
    sign_test
  rescue Exception => e
    raise Jrxades::Exceptions::XmlSigException.new(e)
  end
end

#signObject



21
22
23
# File 'lib/jrxades/xml_sig.rb', line 21

def sign
  XAdESBESSignature.firmar(input_file_path, key_store_path, pass_phrase_for_key_store, output_path, out_file_name)
end