Class: SamlIdp::SignedInfoBuilder

Inherits:
Object
  • Object
show all
Includes:
Algorithmable
Defined in:
lib/saml_idp/signed_info_builder.rb

Constant Summary collapse

SIGNATURE_METHODS =
{
  "sha1" => "http://www.w3.org/2000/09/xmldsig#rsa-sha1",
  "sha224" => "http://www.w3.org/2001/04/xmldsig-more#rsa-sha224",
  "sha256" => "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",
  "sha384" => "http://www.w3.org/2001/04/xmldsig-more#rsa-sha384",
  "sha512" => "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512",
}
DIGEST_METHODS =
{
  "sha1" => "http://www.w3.org/2000/09/xmldsig#sha1",
  "sha224" => "http://www.w3.org/2001/04/xmldsig-more#sha224",
  "sha256" => "http://www.w3.org/2001/04/xmlenc#sha256",
  "sha384" => "http://www.w3.org/2001/04/xmldsig-more#sha384",
  "sha512" => "http://www.w3.org/2001/04/xmlenc#sha512",
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reference_id, digest_value, raw_algorithm) ⇒ SignedInfoBuilder

Returns a new instance of SignedInfoBuilder.



26
27
28
29
30
# File 'lib/saml_idp/signed_info_builder.rb', line 26

def initialize(reference_id, digest_value, raw_algorithm)
  self.reference_id = reference_id
  self.digest_value = digest_value
  self.raw_algorithm = raw_algorithm
end

Instance Attribute Details

#digest_valueObject

Returns the value of attribute digest_value.



23
24
25
# File 'lib/saml_idp/signed_info_builder.rb', line 23

def digest_value
  @digest_value
end

#raw_algorithmObject

Returns the value of attribute raw_algorithm.



24
25
26
# File 'lib/saml_idp/signed_info_builder.rb', line 24

def raw_algorithm
  @raw_algorithm
end

#reference_idObject

Returns the value of attribute reference_id.



22
23
24
# File 'lib/saml_idp/signed_info_builder.rb', line 22

def reference_id
  @reference_id
end

Instance Method Details

#rawObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/saml_idp/signed_info_builder.rb', line 32

def raw
  builder = Builder::XmlMarkup.new
  builder.tag! "ds:SignedInfo", "xmlns:ds" => "http://www.w3.org/2000/09/xmldsig#" do |signed_info|
    signed_info.tag!("ds:CanonicalizationMethod", Algorithm: "http://www.w3.org/2001/10/xml-exc-c14n#") {}
    signed_info.tag!("ds:SignatureMethod", Algorithm: signature_method ) {}
    signed_info.tag! "ds:Reference", URI: reference_string do |reference|
      reference.tag! "ds:Transforms" do |transforms|
        transforms.tag!("ds:Transform", Algorithm: "http://www.w3.org/2000/09/xmldsig#enveloped-signature") {}
        transforms.tag!("ds:Transform", Algorithm: "http://www.w3.org/2001/10/xml-exc-c14n#") {}
      end
      reference.tag!("ds:DigestMethod", Algorithm: digest_method) {}
      reference.tag! "ds:DigestValue", digest_value
    end
  end
end

#signedObject



48
49
50
# File 'lib/saml_idp/signed_info_builder.rb', line 48

def signed
  encoded.gsub(/\n/, "")
end