Class: Savon::WSSE

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

Overview

Savon::WSSE

Represents parameters for 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"

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.digest=(value) ⇒ Object (writeonly)

Sets whether to use WSSE digest by default.



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

def digest=(value)
  @digest = value
end

.passwordObject

Returns the default WSSE password.



35
36
37
# File 'lib/savon/wsse.rb', line 35

def password
  @password
end

.usernameObject

Returns the default WSSE username.



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

def username
  @username
end

Instance Attribute Details

#digest=(value) ⇒ Object (writeonly)

Sets whether to use WSSE digest.



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

def digest=(value)
  @digest = value
end

Class Method Details

.digest?Boolean

Returns whether to use WSSE digest by default.

Returns:

  • (Boolean)


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

def digest?
  @digest
end

Instance Method Details

#digest?Boolean

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

Returns:

  • (Boolean)


79
80
81
# File 'lib/savon/wsse.rb', line 79

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

#headerObject

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



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/savon/wsse.rb', line 85

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
    end
  end
end

#passwordObject

Returns the WSSE password. Defaults to the global default.



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

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

#password=(password) ⇒ Object

Sets the WSSE password.



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

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 default.



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

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

#username=(username) ⇒ Object

Sets the WSSE username.



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

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