Class: Bosh::Cli::Client::Uaa::AuthInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/cli/client/uaa/auth_info.rb

Defined Under Namespace

Classes: ValidationError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(director, env, ssl_ca_file) ⇒ AuthInfo

Returns a new instance of AuthInfo.



12
13
14
15
16
# File 'lib/cli/client/uaa/auth_info.rb', line 12

def initialize(director, env, ssl_ca_file)
  @director = director
  @client_id, @client_secret = env['BOSH_CLIENT'], env['BOSH_CLIENT_SECRET']
  @ssl_ca_file = ssl_ca_file
end

Instance Attribute Details

#client_idObject (readonly)

Returns the value of attribute client_id.



10
11
12
# File 'lib/cli/client/uaa/auth_info.rb', line 10

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



10
11
12
# File 'lib/cli/client/uaa/auth_info.rb', line 10

def client_secret
  @client_secret
end

#ssl_ca_fileObject (readonly)

Returns the value of attribute ssl_ca_file.



10
11
12
# File 'lib/cli/client/uaa/auth_info.rb', line 10

def ssl_ca_file
  @ssl_ca_file
end

Instance Method Details

#client_auth?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
# File 'lib/cli/client/uaa/auth_info.rb', line 18

def client_auth?
  if @client_id.nil? && !@client_secret.nil?
    raise ValidationError.new('BOSH_CLIENT is missing')
  end
  if @client_secret.nil? && !@client_id.nil?
    raise ValidationError.new('BOSH_CLIENT_SECRET is missing')
  end

  !@client_id.nil? && !@client_secret.nil?
end

#uaa?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/cli/client/uaa/auth_info.rb', line 29

def uaa?
  auth_info['type'] == 'uaa'
end

#urlObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cli/client/uaa/auth_info.rb', line 33

def url
  url = auth_info.fetch('options', {}).fetch('url', nil)

  if url
    unless URI.parse(url).instance_of?(URI::HTTPS)
      raise ValidationError.new('HTTPS protocol is required')
    end
  end

  url
end