Class: ADAL::UserCredential

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/adal/user_credential.rb

Overview

A convenience class for username and password credentials.

Defined Under Namespace

Modules: AccountType Classes: UnsupportedAccountTypeError

Constant Summary

Constants included from Logging

Logging::DEFAULT_LOG_LEVEL, Logging::DEFAULT_LOG_OUTPUT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#logger

Constructor Details

#initialize(username, password, authority_host = Authority::WORLD_WIDE_AUTHORITY) ⇒ UserCredential

Constructs a new UserCredential.

Parameters:

  • String

    username

  • String

    password



63
64
65
66
67
68
69
# File 'lib/adal/user_credential.rb', line 63

def initialize(
  username, password, authority_host = Authority::WORLD_WIDE_AUTHORITY)
  @username = username
  @password = password
  @authority_host = authority_host
  @discovery_path = "/common/userrealm/#{URI.escape @username}"
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



54
55
56
# File 'lib/adal/user_credential.rb', line 54

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



53
54
55
# File 'lib/adal/user_credential.rb', line 53

def username
  @username
end

Instance Method Details

#account_typeObject

Determines the account type based on a Home Realm Discovery request.

Returns:

  • UserCredential::AccountType



75
76
77
# File 'lib/adal/user_credential.rb', line 75

def 
  realm_discovery_response['account_type']
end

#request_paramsObject

The OAuth parameters that respresent this UserCredential.

Returns:

  • Hash



83
84
85
86
87
88
89
90
91
92
# File 'lib/adal/user_credential.rb', line 83

def request_params
  case 
  when AccountType::MANAGED
    managed_request_params
  when AccountType::FEDERATED
    federated_request_params
  else
    fail UnsupportedAccountTypeError, 
  end
end

#to_sObject

:nocov:



95
96
97
# File 'lib/adal/user_credential.rb', line 95

def to_s
  "UserCredential[Username: #{@username}, AccountType: #{}]"
end