Class: RExchange::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/rexchange/credentials.rb

Overview

Credentials are passed around between Folders to emulate a stateful connection with the RExchange::Session

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dav_uri = nil, owa_uri = nil, username = nil, password = nil) ⇒ Credentials

You must pass a dav_uri, owa_uri, a username and a password



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rexchange/credentials.rb', line 12

def initialize(dav_uri = nil, owa_uri = nil, username = nil, password = nil)
  owa_uri = nil if owa_uri && owa_uri.blank?
  @dav_uri = URI.parse(dav_uri) if dav_uri
  @owa_uri = URI.parse(owa_uri) if owa_uri
  @dav_use_ssl = @dav_uri.scheme ? (@dav_uri.scheme.downcase == 'https') : false
  @user = username || (@dav_uri && @dav_uri.userinfo ? @dav_uri.userinfo.split(':')[0] : nil) || (@owa_uri && @owa_uri.userinfo ? @owa_uri.userinfo.split(':')[0] : nil)
  @password = password || (@dav_uri && @dav_uri.userinfo ? @dav_uri.userinfo.split(':')[1] : nil) || (@owa_uri && @owa_uri.userinfo ? @owa_uri.userinfo.split(':')[1] : nil)
  @dav_port = (@dav_uri.port || @dav_uri.default_port) if @dav_uri
  @owa_port = (@owa_uri.port || @owa_uri.default_port) if @owa_uri
  if block_given?
    yield self
  else
    return self
  end
end

Instance Attribute Details

Returns the value of attribute auth_cookie.



9
10
11
# File 'lib/rexchange/credentials.rb', line 9

def auth_cookie
  @auth_cookie
end

#dav_uriObject (readonly)

Returns the value of attribute dav_uri.



8
9
10
# File 'lib/rexchange/credentials.rb', line 8

def dav_uri
  @dav_uri
end

#owa_uriObject (readonly)

Returns the value of attribute owa_uri.



8
9
10
# File 'lib/rexchange/credentials.rb', line 8

def owa_uri
  @owa_uri
end

#passwordObject (readonly)

Returns the value of attribute password.



8
9
10
# File 'lib/rexchange/credentials.rb', line 8

def password
  @password
end

#userObject (readonly)

Returns the value of attribute user.



8
9
10
# File 'lib/rexchange/credentials.rb', line 8

def user
  @user
end

Instance Method Details

#dav_use_ssl?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/rexchange/credentials.rb', line 28

def dav_use_ssl?
  @dav_use_ssl
end

#is_owa?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/rexchange/credentials.rb', line 32

def is_owa?
  @owa_uri && @owa_uri.scheme && @owa_uri.host
end