Class: Savon::WSSE

Inherits:
Object
  • Object
show all
Defined in:
lib/savon/wsse.rb

Overview

Savon::WSSE

Provides WSSE authentication.

Constant Summary collapse

WSENamespace =

Namespace for WS Security Secext.

"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
WSUNamespace =

Namespace for WS Security Utility.

"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
PasswordTextURI =

URI for “wsse:Password/@Type” #PasswordText.

"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"
PasswordDigestURI =

URI for “wsse:Password/@Type” #PasswordDigest.

"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



45
46
47
# File 'lib/savon/wsse.rb', line 45

def created_at
  @created_at
end

#digest=(value) ⇒ Object (writeonly)

Sets the attribute digest

Parameters:

  • value

    the value to set the attribute digest to.



52
53
54
# File 'lib/savon/wsse.rb', line 52

def digest=(value)
  @digest = value
end

#expires_atObject

Returns the value of attribute expires_at.



45
46
47
# File 'lib/savon/wsse.rb', line 45

def expires_at
  @expires_at
end

#passwordObject

Returns the value of attribute password.



45
46
47
# File 'lib/savon/wsse.rb', line 45

def password
  @password
end

#usernameObject

Returns the value of attribute username.



45
46
47
# File 'lib/savon/wsse.rb', line 45

def username
  @username
end

Instance Method Details

#[](key) ⇒ Object

Returns a value from the WSSE Hash.



28
29
30
# File 'lib/savon/wsse.rb', line 28

def [](key)
  hash[key]
end

#[]=(key, value) ⇒ Object

Sets a value on the WSSE Hash.



33
34
35
# File 'lib/savon/wsse.rb', line 33

def []=(key, value)
  hash[key] = value
end

#credentials(username, password, digest = false) ⇒ Object

Sets authentication credentials for a wsse:UsernameToken header. Also accepts whether to use WSSE digest authentication.



39
40
41
42
43
# File 'lib/savon/wsse.rb', line 39

def credentials(username, password, digest = false)
  self.username = username
  self.password = password
  self.digest = digest
end

#digest?Boolean

Returns whether to use WSSE digest. Defaults to false.

Returns:

  • (Boolean)


48
49
50
# File 'lib/savon/wsse.rb', line 48

def digest?
  !!@digest
end

#timestamp=(timestamp) ⇒ Object

Sets whether to generate a wsse:Timestamp header.



65
66
67
# File 'lib/savon/wsse.rb', line 65

def timestamp=(timestamp)
  @wsse_timestamp = timestamp
end

#timestamp?Boolean

Returns whether to generate a wsse:Timestamp header.

Returns:

  • (Boolean)


60
61
62
# File 'lib/savon/wsse.rb', line 60

def timestamp?
  created_at || expires_at || @wsse_timestamp
end

#to_xmlObject

Returns the XML for a WSSE header.



70
71
72
73
74
75
76
77
78
# File 'lib/savon/wsse.rb', line 70

def to_xml
  if username_token?
    Gyoku.xml wsse_username_token.merge!(hash)
  elsif timestamp?
    Gyoku.xml wsse_timestamp.merge!(hash)
  else
    ""
  end
end

#username_token?Boolean

Returns whether to generate a wsse:UsernameToken header.

Returns:

  • (Boolean)


55
56
57
# File 'lib/savon/wsse.rb', line 55

def username_token?
  username && password
end