Class: XmlSig::SignedInfo

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#canonicalization_methodObject

Returns the value of attribute canonicalization_method.



4
5
6
# File 'lib/xml_sig/signed_info.rb', line 4

def canonicalization_method
  @canonicalization_method
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/xml_sig/signed_info.rb', line 3

def id
  @id
end

#signature_methodObject

Returns the value of attribute signature_method.



5
6
7
# File 'lib/xml_sig/signed_info.rb', line 5

def signature_method
  @signature_method
end

Instance Method Details

#referencesObject



7
8
9
# File 'lib/xml_sig/signed_info.rb', line 7

def references
  @references ||= []
end

#to_xml(xml = Builder::XmlMarkup.new) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/xml_sig/signed_info.rb', line 17

def to_xml(xml=Builder::XmlMarkup.new)
  attributes = {}
  attributes['Id'] = id unless id.nil?
  xml.tag!('ds:SignedInfo', attributes) {
    xml << canonicalization_method.to_xml unless canonicalization_method.nil?
    xml << signature_method.to_xml unless signature_method.nil?
    references.each { |reference| xml << reference.to_xml }
  }
end

#validateObject

Raises:

  • (ValidationError)


11
12
13
14
15
# File 'lib/xml_sig/signed_info.rb', line 11

def validate
  raise ValidationError, "Canonicalization method is required" if canonicalization_method.nil?
  raise ValidationError, "Signature method is required" if signature_method.nil?
  raise ValidationError, "At least one reference is required" if references.empty?
end