Class: Ape::WsseCredentials
- Inherits:
-
Object
- Object
- Ape::WsseCredentials
- Defined in:
- lib/ape/auth/wsse_credentials.rb
Instance Method Summary collapse
- #add_credentials(req, auth, user, password) ⇒ Object
-
#initialize ⇒ WsseCredentials
constructor
A new instance of WsseCredentials.
- #wsse_auth(user, password) ⇒ Object
Constructor Details
#initialize ⇒ WsseCredentials
Returns a new instance of WsseCredentials.
6 7 8 |
# File 'lib/ape/auth/wsse_credentials.rb', line 6 def initialize @credentials = nil end |
Instance Method Details
#add_credentials(req, auth, user, password) ⇒ Object
10 11 12 13 14 |
# File 'lib/ape/auth/wsse_credentials.rb', line 10 def add_credentials(req, auth, user, password) wsse_auth(user, password) unless @credentials req['X-WSSE'] = @credentials req['Authorization'] = auth end |
#wsse_auth(user, password) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/ape/auth/wsse_credentials.rb', line 16 def wsse_auth(user, password) nonce = Array.new(10){ rand(0x1000000) }.pack('I*') nonce_b64 = [nonce].pack("m").chomp now = Time.now.gmtime.strftime("%FT%TZ") digest = [Digest::SHA1.digest(nonce_b64 + now + password)].pack("m").chomp @credentials = %Q<UsernameToken Username="#{user}", PasswordDigest="#{digest}", Nonce="#{nonce_b64}", Created="#{now}"> end |