2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2017-08-14 11:56:23 +00:00
|
|
|
class Sequencer
|
|
|
|
class Unit
|
|
|
|
module Exchange
|
2017-12-20 15:08:37 +00:00
|
|
|
class Connection < Sequencer::Unit::Common::Provider::Fallback
|
2017-08-14 11:56:23 +00:00
|
|
|
|
|
|
|
uses :ews_config
|
|
|
|
provides :ews_connection
|
|
|
|
|
2017-11-30 12:44:41 +00:00
|
|
|
private
|
2017-08-14 11:56:23 +00:00
|
|
|
|
2017-12-20 15:08:37 +00:00
|
|
|
def ews_connection
|
2021-07-05 13:38:40 +00:00
|
|
|
require 'viewpoint' # Only load this gem when it is really used.
|
2017-11-30 12:44:41 +00:00
|
|
|
Viewpoint::EWSClient.new(
|
|
|
|
config[:endpoint],
|
|
|
|
config[:user],
|
|
|
|
config[:password],
|
|
|
|
additional_opts
|
|
|
|
)
|
2017-11-03 10:40:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def config
|
|
|
|
@config ||= begin
|
|
|
|
ews_config || ::Import::Exchange.config
|
|
|
|
end
|
|
|
|
end
|
2017-08-14 11:56:23 +00:00
|
|
|
|
2017-11-03 10:40:11 +00:00
|
|
|
def additional_opts
|
|
|
|
@additional_opts ||= begin
|
|
|
|
http_opts
|
2017-08-14 11:56:23 +00:00
|
|
|
end
|
|
|
|
end
|
2017-11-03 10:40:11 +00:00
|
|
|
|
|
|
|
def http_opts
|
|
|
|
return {} if config[:disable_ssl_verify].blank?
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-11-03 10:40:11 +00:00
|
|
|
{
|
|
|
|
http_opts: {
|
|
|
|
ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2017-08-14 11:56:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|