Class: Savon::WSSE

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

Overview

Savon::WSSE

Represents parameters for WSSE authentication.

Constant Summary collapse

BaseAddress =

Base address for WSSE docs.

"http://docs.oasis-open.org/wss/2004/01"
WSENamespace =

Namespace for WS Security Secext.

BaseAddress + "/oasis-200401-wss-wssecurity-secext-1.0.xsd"
WSUNamespace =

Namespace for WS Security Utility.

BaseAddress + "/oasis-200401-wss-wssecurity-utility-1.0.xsd"
PasswordTextURI =

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

BaseAddress + "/oasis-200401-wss-username-token-profile-1.0#PasswordText"
PasswordDigestURI =

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

BaseAddress + "/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"
@@username =

Global WSSE username.

nil
@@password =

Global WSSE password.

nil
@@digest =

Global setting of whether to use WSSE digest.

false

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#digest=(value) ⇒ Object (writeonly)

Sets whether to use WSSE digest per request.



87
88
89
# File 'lib/savon/wsse.rb', line 87

def digest=(value)
  @digest = value
end

Class Method Details

.digest=(digest) ⇒ Object

Global setting of whether to use WSSE digest.



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

def self.digest=(digest)
  @@digest = digest
end

.digest?Boolean

Returns the global setting of whether to use WSSE digest.

Returns:

  • (Boolean)


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

def self.digest?
  @@digest
end

.passwordObject

Returns the global WSSE password.



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

def self.password
  @@password
end

.password=(password) ⇒ Object

Sets the global WSSE password.



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

def self.password=(password)
  @@password = password.to_s if password.respond_to? :to_s
  @@password = nil if password.nil?
end

.usernameObject

Returns the global WSSE username.



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

def self.username
  @@username
end

.username=(username) ⇒ Object

Sets the global WSSE username.



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

def self.username=(username)
  @@username = username.to_s if username.respond_to? :to_s
  @@username = nil if username.nil?
end

Instance Method Details

#digest?Boolean

Returns whether to use WSSE digest. Defaults to the global setting.

Returns:

  • (Boolean)


90
91
92
# File 'lib/savon/wsse.rb', line 90

def digest?
  @digest || self.class.digest?
end

#headerObject

Returns the XML for a WSSE header or an empty String unless both username and password were specified.



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/savon/wsse.rb', line 96

def header
  return "" unless username && password

  builder = Builder::XmlMarkup.new
  builder.wsse :Security, "xmlns:wsse" => WSENamespace do |xml|
    xml.wsse :UsernameToken, "xmlns:wsu" => WSUNamespace do
      xml.wsse :Username, username
      xml.wsse :Nonce, nonce
      xml.wsu :Created, timestamp
      xml.wsse :Password, password_node, :Type => password_type
    end
  end
end

#passwordObject

Returns the WSSE password. Defaults to the global setting.



82
83
84
# File 'lib/savon/wsse.rb', line 82

def password
  @password || self.class.password
end

#password=(password) ⇒ Object

Sets the WSSE password per request.



76
77
78
79
# File 'lib/savon/wsse.rb', line 76

def password=(password)
  @password = password.to_s if password.respond_to? :to_s
  @password = nil if password.nil?
end

#usernameObject

Returns the WSSE username. Defaults to the global setting.



71
72
73
# File 'lib/savon/wsse.rb', line 71

def username
  @username || self.class.username
end

#username=(username) ⇒ Object

Sets the WSSE username per request.



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

def username=(username)
  @username = username.to_s if username.respond_to? :to_s
  @username = nil if username.nil?
end