Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for certificate signing stuff in Akami. #264

Merged
merged 2 commits into from
Jun 6, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/savon/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def request(*args, &block)

response = SOAP::Request.new(http, soap).response
set_cookie response.http.headers

if wsse.verify_response
WSSE::VerifySignature.new(response.http.body).verify!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code has been removed(refer: d31be3e) from the master branch, so are we still able to verify the response, and if so, can you please guide me?

end

response
end

Expand Down
15 changes: 14 additions & 1 deletion lib/savon/soap/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,20 @@ def response
# Configures a given +http+ from the +soap+ object.
def configure(http)
http.url = soap.endpoint
http.body = soap.to_xml

if soap.signature?
# First generate the document so that Signature can digest sections
soap.wsse.signature.document = soap.to_xml(true)

# Then re-generate the document so that Signature can sign the digest
soap.wsse.signature.document = soap.to_xml(true)

# The third time we generate the document, we should have a signature
http.body = soap.to_xml(true)
else
http.body = soap.to_xml
end

http.headers["Content-Type"] = ContentType[soap.version]
http.headers["Content-Length"] = soap.to_xml.bytesize.to_s
http
Expand Down
20 changes: 17 additions & 3 deletions lib/savon/soap/xml.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "builder"
require "gyoku"
require "rexml/document"
require "nori"

require "savon/soap"
Expand Down Expand Up @@ -119,6 +120,10 @@ def namespace_identifier
# Accessor for the <tt>Savon::WSSE</tt> object.
attr_accessor :wsse

def signature?
wsse.respond_to?(:signature?) && wsse.signature?
end

# Returns the SOAP request encoding. Defaults to "UTF-8".
def encoding
@encoding ||= "UTF-8"
Expand Down Expand Up @@ -148,14 +153,23 @@ def xml(directive_tag = :xml, attrs = {})
attr_writer :xml

# Returns the XML for a SOAP request.
def to_xml
def to_xml(clear_cache = false)
if clear_cache
@xml = nil
@header_for_xml = nil
end

@xml ||= tag(builder, :Envelope, complete_namespaces) do |xml|
tag(xml, :Header) { xml << header_for_xml } unless header_for_xml.empty?

# TODO: Maybe there should be some sort of plugin architecture where
# classes like WSSE::Signature can hook into this process.
body_attributes = (signature? ? wsse.signature.body_attributes : {})

if input.nil?
tag(xml, :Body)
tag(xml, :Body, body_attributes)
else
tag(xml, :Body) { xml.tag!(*add_namespace_to_input) { xml << body_to_xml } }
tag(xml, :Body, body_attributes) { xml.tag!(*add_namespace_to_input) { xml << body_to_xml } }
end
end
end
Expand Down