Module: Saml::XMLHelpers
- Extended by:
- ActiveSupport::Concern
- Included in:
- Assertion, ComplexTypes::RequestAbstractType, Elements::EncryptedID, Elements::EntitiesDescriptor, Elements::EntityAttributes, Elements::EntityDescriptor, Elements::MDExtensions, Elements::PublicationInfo, Elements::SAMLPExtensions
- Defined in:
- lib/saml/xml_helpers.rb
Instance Method Summary collapse
Instance Method Details
#add_signature ⇒ Object
5 6 7 8 9 |
# File 'lib/saml/xml_helpers.rb', line 5 def add_signature self.signature = Saml::Elements::Signature.new(uri: "##{self._id}") x509certificate = OpenSSL::X509::Certificate.new(provider.certificate) rescue nil self.signature.key_info = Saml::Elements::KeyInfo.new(x509certificate.to_pem) if x509certificate end |
#to_soap(options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/saml/xml_helpers.rb', line 33 def to_soap( = {}) builder = Nokogiri::XML::Builder.new body = self.to_xml(builder) builder = Nokogiri::XML::Builder.new(:encoding => "UTF-8") builder.Envelope(:'xmlns:soapenv' => "http://schemas.xmlsoap.org/soap/envelope/") do |xml| xml.parent.namespace = xml.parent.namespace_definitions.find { |n| n.prefix == 'soapenv' } if = [:header] xml.Header('xmlns:wsa' => 'http://schemas.xmlsoap.org/ws/2004/08/addressing') do |xml| xml['wsa'].MessageID([:wsa_message_id].presence || "uuid:#{SecureRandom.uuid}") xml['wsa'].Action([:wsa_action]) xml['wsa'].To([:wsa_to]) if [:wsa_to] if [:wsa_address] xml['wsa'].ReplyTo do |xml| xml['wsa'].Address([:wsa_address]) end end end end xml.Body do |xml| xml.parent.add_child body.doc.root end end builder.to_xml(()) end |
#to_xml(*args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/saml/xml_helpers.rb', line 11 def to_xml(*args) = args. builder, default_namespace, instruct = args instruct = true if instruct.nil? write_xml = builder.nil? ? true : false builder ||= Nokogiri::XML::Builder.new builder.doc.encoding = "UTF-8" result = if use_parsed? && respond_to?(:xml_value) builder << xml_value builder else super(builder, default_namespace) end if write_xml instruct ? result.to_xml(()) : result.doc.root else result end end |