Class: OmniAuth::Suomifi::Test::Utility
- Inherits:
-
Object
- Object
- OmniAuth::Suomifi::Test::Utility
- Defined in:
- lib/omniauth-suomifi/test/utility.rb
Class Method Summary collapse
- .encrypted_signed_xml(raw_xml_file, opts) ⇒ Object
- .encrypted_signed_xml_from_string(raw_xml, opts) ⇒ Object
- .inflate_xml(encoded_deflated_xml) ⇒ Object
- .sign_xml_element(element, sign_certificate, sign_key) ⇒ Object
- .template_filepath(filename) ⇒ Object
Class Method Details
.encrypted_signed_xml(raw_xml_file, opts) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/omniauth-suomifi/test/utility.rb', line 12 def self.encrypted_signed_xml(raw_xml_file, opts) xml_source = XmlEncryptor.encrypted_xml( raw_xml_file, opts[:certificate], opts[:sign_certificate], opts[:sign_private_key] ) sign_xml_element( xml_source, opts[:sign_certificate], opts[:sign_private_key] ) end |
.encrypted_signed_xml_from_string(raw_xml, opts) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/omniauth-suomifi/test/utility.rb', line 26 def self.encrypted_signed_xml_from_string(raw_xml, opts) xml_source = XmlEncryptor.encrypted_xml_from_string( raw_xml, opts[:certificate], opts[:sign_certificate], opts[:sign_private_key] ) sign_xml_element( xml_source, opts[:sign_certificate], opts[:sign_private_key] ) end |
.inflate_xml(encoded_deflated_xml) ⇒ Object
7 8 9 10 |
# File 'lib/omniauth-suomifi/test/utility.rb', line 7 def self.inflate_xml(encoded_deflated_xml) deflated_xml = Base64.decode64(encoded_deflated_xml) Zlib::Inflate.new(-Zlib::MAX_WBITS).inflate(deflated_xml) end |
.sign_xml_element(element, sign_certificate, sign_key) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/omniauth-suomifi/test/utility.rb', line 40 def self.sign_xml_element(element, sign_certificate, sign_key) doc = XMLSecurity::Document.new(element) doc.sign_document( sign_key, sign_certificate, XMLSecurity::Document::RSA_SHA256, XMLSecurity::Document::SHA256 ) # Move the signature to the correct position, otherwise schema # validation does not work because the internal logic of ruby-saml # cannot handle custom element names (saml2:Issuer instead of # saml:Issuer). signature = doc.delete_element('//ds:Signature') issuer = doc.elements['//saml2:Issuer'] doc.root.insert_after(issuer, signature) doc.to_s end |
.template_filepath(filename) ⇒ Object
59 60 61 |
# File 'lib/omniauth-suomifi/test/utility.rb', line 59 def self.template_filepath(filename) File.(File.join('templates', filename), __dir__) end |