apricoteatsgorilla 0.5.10 → 0.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +0 -0
- data/README.rdoc +0 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/apricoteatsgorilla.gemspec +3 -1
- data/lib/apricoteatsgorilla.rb +0 -0
- data/lib/apricoteatsgorilla/apricoteatsgorilla.rb +0 -0
- data/lib/apricoteatsgorilla/wsse.rb +69 -0
- data/lib/apricoteatsgorilla/xml_node.rb +0 -0
- data/spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb +0 -0
- data/spec/apricoteatsgorilla/hash_to_xml_spec.rb +0 -0
- data/spec/apricoteatsgorilla/soap_envelope_spec.rb +0 -0
- data/spec/apricoteatsgorilla/wsse_spec.rb +0 -0
- data/spec/apricoteatsgorilla/xml_node_spec.rb +0 -0
- data/spec/apricoteatsgorilla/xml_to_hash_spec.rb +0 -0
- data/spec/spec_helper.rb +0 -0
- metadata +3 -1
data/.gitignore
CHANGED
File without changes
|
data/README.rdoc
CHANGED
File without changes
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.12
|
data/apricoteatsgorilla.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{apricoteatsgorilla}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Harrington"]
|
@@ -23,10 +23,12 @@ Gem::Specification.new do |s|
|
|
23
23
|
"apricoteatsgorilla.gemspec",
|
24
24
|
"lib/apricoteatsgorilla.rb",
|
25
25
|
"lib/apricoteatsgorilla/apricoteatsgorilla.rb",
|
26
|
+
"lib/apricoteatsgorilla/wsse.rb",
|
26
27
|
"lib/apricoteatsgorilla/xml_node.rb",
|
27
28
|
"spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb",
|
28
29
|
"spec/apricoteatsgorilla/hash_to_xml_spec.rb",
|
29
30
|
"spec/apricoteatsgorilla/soap_envelope_spec.rb",
|
31
|
+
"spec/apricoteatsgorilla/wsse_spec.rb",
|
30
32
|
"spec/apricoteatsgorilla/xml_node_spec.rb",
|
31
33
|
"spec/apricoteatsgorilla/xml_to_hash_spec.rb",
|
32
34
|
"spec/spec_helper.rb"
|
data/lib/apricoteatsgorilla.rb
CHANGED
File without changes
|
File without changes
|
@@ -0,0 +1,69 @@
|
|
1
|
+
%w(base64 digest/sha1).each do |gem|
|
2
|
+
require gem
|
3
|
+
end
|
4
|
+
|
5
|
+
class WSSE
|
6
|
+
|
7
|
+
# Namespace for WS Security Secext.
|
8
|
+
WSENamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
|
9
|
+
|
10
|
+
# Namespace for WS Security Utility.
|
11
|
+
WSUNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
|
12
|
+
|
13
|
+
class << self
|
14
|
+
|
15
|
+
# Returns the header for the SOAP request. Takes +wsse+ details for adding
|
16
|
+
# WSSE authentication. Defaults to returning +nil+ if +wsse+ is missing.
|
17
|
+
def soap_header(username, password, digest = false)
|
18
|
+
created_at = Time.now.strftime(ApricotEatsGorilla::SOAPDateTimeFormat)
|
19
|
+
|
20
|
+
xml_node("wsse:Security", "xmlns:wsse" => WSENamespace) do
|
21
|
+
xml_node("wsse:UsernameToken", "xmlns:wsu" => WSUNamespace) do
|
22
|
+
xml_node("wsse:Username") { username } <<
|
23
|
+
password_node(password, created_at, digest) <<
|
24
|
+
xml_node("wsse:Nonce") { nonce(created_at) } <<
|
25
|
+
xml_node("wsu:Created") { created_at }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns the password node for WSSE authentication. Takes the +wsse+ details,
|
31
|
+
# a +created+ Time object and a +nonce+. Creates a passwordText or passwordDigest
|
32
|
+
# node based on the +wsse[:password_digest]+ flag.
|
33
|
+
def password_node(password, created_at, digest = false)
|
34
|
+
if digest
|
35
|
+
attributes = { "Type" => "wsse:PasswordDigest" }
|
36
|
+
token = nonce(created_at) + created_at + password
|
37
|
+
password = Base64.encode64(Digest::SHA1.hexdigest(token)).chomp!
|
38
|
+
else
|
39
|
+
attributes = nil
|
40
|
+
end
|
41
|
+
xml_node("wsse:Password", attributes) { password }
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# Returns an XML tag with a given +name+. Accepts a +block+ for tag content.
|
47
|
+
# Defaults to returning an empty-element tag in case no block was given.
|
48
|
+
# Also accepts a Hash of +attributes+ to be added to the XML tag.
|
49
|
+
def xml_node(name, attributes = nil)
|
50
|
+
node = XMLNode.new(name.to_s)
|
51
|
+
node.attributes = attributes
|
52
|
+
node.body = yield if block_given?
|
53
|
+
|
54
|
+
node.to_tag
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns a random WSSE nonce. Expects +Time.now+ for +created+.
|
58
|
+
def nonce(random = nil)
|
59
|
+
random ||= Time.now.to_i
|
60
|
+
Digest::SHA1.hexdigest(random_string + random.to_s)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns a random string of a given +length+. Defaults to 100 characters.
|
64
|
+
def random_string(length = 100)
|
65
|
+
(0...length).map { ("a".."z").to_a[rand(26)] }.join
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apricoteatsgorilla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Harrington
|
@@ -48,10 +48,12 @@ files:
|
|
48
48
|
- apricoteatsgorilla.gemspec
|
49
49
|
- lib/apricoteatsgorilla.rb
|
50
50
|
- lib/apricoteatsgorilla/apricoteatsgorilla.rb
|
51
|
+
- lib/apricoteatsgorilla/wsse.rb
|
51
52
|
- lib/apricoteatsgorilla/xml_node.rb
|
52
53
|
- spec/apricoteatsgorilla/apricoteatsgorilla_spec.rb
|
53
54
|
- spec/apricoteatsgorilla/hash_to_xml_spec.rb
|
54
55
|
- spec/apricoteatsgorilla/soap_envelope_spec.rb
|
56
|
+
- spec/apricoteatsgorilla/wsse_spec.rb
|
55
57
|
- spec/apricoteatsgorilla/xml_node_spec.rb
|
56
58
|
- spec/apricoteatsgorilla/xml_to_hash_spec.rb
|
57
59
|
- spec/spec_helper.rb
|