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

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

Defined Under Namespace

Classes: AccessInfo, ClientTokenIssuer, PasswordTokenIssuer, Prompt, TokenDecoder

Instance Method Summary collapse

Constructor Details

#initialize(options, ssl_ca_file) ⇒ Uaa

Returns a new instance of Uaa.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cli/client/uaa.rb', line 10

def initialize(options, ssl_ca_file)
  url = options.fetch('url')
  unless URI.parse(url).instance_of?(URI::HTTPS)
    err('Failed to connect to UAA, HTTPS protocol is required')
  end
  @ssl_ca_file = ssl_ca_file

  token_decoder = TokenDecoder.new
  if ENV['BOSH_CLIENT'] && ENV['BOSH_CLIENT_SECRET']
    @token_issuer = ClientTokenIssuer.new(url, ssl_ca_file, token_decoder)
  else
    @token_issuer = PasswordTokenIssuer.new(url, ssl_ca_file, token_decoder)
  end
end

Instance Method Details

#login(credentials) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/cli/client/uaa.rb', line 32

def (credentials)
  @token_issuer.access_info(credentials)
rescue CF::UAA::TargetError => e
  err("Failed to log in: #{e.info['error_description']}")
rescue CF::UAA::BadResponse
  nil
end

#promptsObject



25
26
27
28
29
30
# File 'lib/cli/client/uaa.rb', line 25

def prompts
  @token_issuer.prompts
rescue CF::UAA::SSLException => e
  raise e unless @ssl_ca_file.nil?
  err('Invalid SSL Cert. Use --ca-cert to specify SSL certificate')
end