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

#context

Attributes included from ZmLogger

#logger, #logger_file_path, #logger_level

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SoapBaseConnector

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

Methods included from ZmLogger

#init_logger

Constructor Details

#initialize(scheme, host, port) ⇒ SoapAccountConnector

Returns a new instance of SoapAccountConnector.



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

def initialize(scheme, host, port)
  super(scheme, host, port, SoapAccountConstants::ACCOUNT_SERVICE_URI)
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)
  trans = new(
    config.zimbra_public_scheme,
    config.zimbra_public_host,
    config.zimbra_public_port
  )
  trans.logger = config.logger
  trans
end

Instance Method Details

#auth_password(content, by, password) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/zm/client/connector/soap_account.rb', line 48

def auth_password(content, by, password)
  soap_request = SoapElement.(SoapAccountConstants::AUTH_REQUEST)
   = SoapElement.create(SoapConstants::ACCOUNT).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
# 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::ACCOUNT).add_attribute(SoapConstants::BY,
                                                                          by).add_content(content)
  soap_request.add_node()
  node_preauth = SoapElement.create(SoapConstants::PREAUTH).add_attribute(SoapConstants::TIMESTAMP,
                                                                          ts).add_content(preauth)
  soap_request.add_node(node_preauth)

  (soap_request)
end

#do_login(soap_request) ⇒ Object



58
59
60
# File 'lib/zm/client/connector/soap_account.rb', line 58

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