Class: Akami::WSSE

Inherits:
Object
  • Object
show all
Defined in:
lib/akami/wsse.rb,
lib/akami/wsse/certs.rb,
lib/akami/wsse/signature.rb,
lib/akami/wsse/verify_signature.rb

Overview

Akami::WSSE

Building Web Service Security.

Defined Under Namespace

Classes: Certs, InvalidSignature, Signature, VerifySignature

Constant Summary collapse

WSE_NAMESPACE =

Namespace for WS Security Secext.

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

Namespace for WS Security Utility.

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

PasswordText URI.

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

PasswordDigest URI.

"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest"
BASE64_URI =
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



51
52
53
# File 'lib/akami/wsse.rb', line 51

def created_at
  @created_at
end

#digest=(value) ⇒ Object (writeonly)

Sets the attribute digest

Parameters:

  • value

    the value to set the attribute digest to.



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

def digest=(value)
  @digest = value
end

#expires_atObject

Returns the value of attribute expires_at.



51
52
53
# File 'lib/akami/wsse.rb', line 51

def expires_at
  @expires_at
end

#passwordObject

Returns the value of attribute password.



51
52
53
# File 'lib/akami/wsse.rb', line 51

def password
  @password
end

#signatureObject

Returns the value of attribute signature.



51
52
53
# File 'lib/akami/wsse.rb', line 51

def signature
  @signature
end

#usernameObject

Returns the value of attribute username.



51
52
53
# File 'lib/akami/wsse.rb', line 51

def username
  @username
end

#verify_responseObject

Returns the value of attribute verify_response.



51
52
53
# File 'lib/akami/wsse.rb', line 51

def verify_response
  @verify_response
end

Instance Method Details

#[](key) ⇒ Object

Returns a value from the WSSE Hash.



34
35
36
# File 'lib/akami/wsse.rb', line 34

def [](key)
  hash[key]
end

#[]=(key, value) ⇒ Object

Sets a value on the WSSE Hash.



39
40
41
# File 'lib/akami/wsse.rb', line 39

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

#body_attributesObject

Hook for Soap::XML that allows us to add attributes to the env:Body tag



84
85
86
87
88
89
90
# File 'lib/akami/wsse.rb', line 84

def body_attributes
  if signature?
    signature.body_attributes
  else
    {}
  end
end

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

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



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

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)


62
63
64
# File 'lib/akami/wsse.rb', line 62

def digest?
  !!@digest
end

#sign_with=(klass) ⇒ Object



53
54
55
# File 'lib/akami/wsse.rb', line 53

def sign_with=(klass)
  @signature = klass
end

#signature?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/akami/wsse.rb', line 57

def signature?
  !!@signature
end

#timestamp=(timestamp) ⇒ Object

Sets whether to generate a wsu:Timestamp header.



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

def timestamp=(timestamp)
  @wsu_timestamp = timestamp
end

#timestamp?Boolean

Returns whether to generate a wsu:Timestamp header.

Returns:

  • (Boolean)


74
75
76
# File 'lib/akami/wsse.rb', line 74

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

#to_xmlObject

Returns the XML for a WSSE header.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/akami/wsse.rb', line 93

def to_xml
  if signature? and signature.have_document?
    Gyoku.xml wsse_signature.merge!(hash)
  elsif username_token? && timestamp?
    Gyoku.xml wsse_username_token.merge!(wsu_timestamp) {
      |key, v1, v2| v1.merge!(v2) {
        |key, v1, v2| v1.merge!(v2)
      }
    }
  elsif username_token?
    Gyoku.xml wsse_username_token.merge!(hash)
  elsif timestamp?
    Gyoku.xml wsu_timestamp.merge!(hash)
  else
    ""
  end
end

#username_token?Boolean

Returns whether to generate a wsse:UsernameToken header.

Returns:

  • (Boolean)


69
70
71
# File 'lib/akami/wsse.rb', line 69

def username_token?
  username && password
end