Class: Bosh::Cli::Client::Uaa::AccessInfo
- Inherits:
-
Object
- Object
- Bosh::Cli::Client::Uaa::AccessInfo
show all
- Defined in:
- lib/cli/client/uaa/access_info.rb
Constant Summary
collapse
- EXPIRATION_DEADLINE_IN_SECONDS =
30
Instance Method Summary
collapse
Constructor Details
#initialize(token_info, token_decoder) ⇒ AccessInfo
Returns a new instance of AccessInfo.
8
9
10
11
|
# File 'lib/cli/client/uaa/access_info.rb', line 8
def initialize(token_info, token_decoder)
@token_info = token_info
@token_decoder = token_decoder
end
|
Instance Method Details
13
14
15
|
# File 'lib/cli/client/uaa/access_info.rb', line 13
def
@token_info.
end
|
#expires_soon? ⇒ Boolean
25
26
27
28
|
# File 'lib/cli/client/uaa/access_info.rb', line 25
def expires_soon?
expiration = token_data[:exp] || token_data['exp']
(Time.at(expiration).to_i - Time.now.to_i) < EXPIRATION_DEADLINE_IN_SECONDS
end
|
#refresh_token ⇒ Object
17
18
19
|
# File 'lib/cli/client/uaa/access_info.rb', line 17
def refresh_token
@token_info.info[:refresh_token] || @token_info.info['refresh_token']
end
|
34
35
36
37
38
39
|
# File 'lib/cli/client/uaa/access_info.rb', line 34
def to_hash
{
'access_token' => ,
'refresh_token' => refresh_token
}
end
|
#token_data ⇒ Object
30
31
32
|
# File 'lib/cli/client/uaa/access_info.rb', line 30
def token_data
@token_data ||= @token_decoder.decode(@token_info)
end
|
#was_issued_for?(other_username) ⇒ Boolean
21
22
23
|
# File 'lib/cli/client/uaa/access_info.rb', line 21
def was_issued_for?(other_username)
username == other_username
end
|