Class: Zm::Client::SoapAccountConnector

Inherits:
SoapBaseConnector show all
Defined in:
lib/zm/client/connector/soap_account.rb

Constant Summary

Constants inherited from SoapBaseConnector

Zm::Client::SoapBaseConnector::BASESPACE, Zm::Client::SoapBaseConnector::HTTP_HEADERS

Instance Attribute Summary

Attributes inherited from SoapBaseConnector

#cache, #context, #logger, #timeout

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SoapBaseConnector

#http_client!, #invoke, #target_invoke, #verbose!

Constructor Details

#initialize(url) ⇒ SoapAccountConnector

Returns a new instance of SoapAccountConnector.



29
30
31
# File 'lib/zm/client/connector/soap_account.rb', line 29

def initialize(url)
  super(url, SoapAccountConstants::)
end

Class Method Details

.create(config) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/zm/client/connector/soap_account.rb', line 10

def create(config)
  new(
    config.zimbra_public_url
  ).tap do |trans|
    trans.logger = config.logger
    trans.cache = config.cache
    trans.timeout = config.timeout
  end
end

Instance Method Details

#auth_password(content, by, password) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/zm/client/connector/soap_account.rb', line 51

def auth_password(content, by, password)
  soap_request = SoapElement.(SoapAccountConstants::AUTH_REQUEST)
   = SoapElement.create(SoapConstants::)
                            .add_attribute(SoapConstants::BY, by)
                            .add_content(content)
  soap_request.add_node()
  soap_request.add_attribute('password', password)

  (soap_request)
end

#auth_preauth(content, by, expires, domainkey) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/zm/client/connector/soap_account.rb', line 33

def auth_preauth(content, by, expires, domainkey)
  ts = (Time.now.to_i * 1000)
  preauth = compute_preauth(content, by, ts, expires, domainkey)

  soap_request = SoapElement.(SoapAccountConstants::AUTH_REQUEST)
   = SoapElement.create(SoapConstants::)
                            .add_attribute(SoapConstants::BY, by)
                            .add_content(content)
  soap_request.add_node()
  node_preauth = SoapElement.create(SoapConstants::PREAUTH)
                            .add_attribute(SoapConstants::TIMESTAMP, ts)
                            .add_attribute(SoapConstants::EXPIRES, expires)
                            .add_content(preauth)
  soap_request.add_node(node_preauth)

  (soap_request)
end

#do_login(soap_request) ⇒ Object



62
63
64
# File 'lib/zm/client/connector/soap_account.rb', line 62

def (soap_request)
  invoke(soap_request)[:AuthResponse][:authToken].first[:_content]
end

#tokenObject



21
22
23
# File 'lib/zm/client/connector/soap_account.rb', line 21

def token
  context.to_hash[:authToken]
end

#token=(value) ⇒ Object



25
26
27
# File 'lib/zm/client/connector/soap_account.rb', line 25

def token=(value)
  context.token(value)
end