class CFoundry::AuthToken
Constants
- JSON_HASH
Attributes
auth_header[RW]
refresh_token[R]
Public Class Methods
from_hash(hash)
click to toggle source
# File lib/cfoundry/auth_token.rb, line 11 def from_hash(hash) new( hash[:token], hash[:refresh_token] ) end
from_uaa_token_info(token_info)
click to toggle source
# File lib/cfoundry/auth_token.rb, line 4 def from_uaa_token_info(token_info) new( token_info.auth_header, token_info.info[:refresh_token] ) end
new(auth_header, refresh_token = nil)
click to toggle source
# File lib/cfoundry/auth_token.rb, line 19 def initialize(auth_header, refresh_token = nil) @auth_header = auth_header @refresh_token = refresh_token end
Public Instance Methods
auth_header=(auth_header)
click to toggle source
# File lib/cfoundry/auth_token.rb, line 49 def auth_header=(auth_header) @token_data = nil @auth_header = auth_header end
expiration()
click to toggle source
# File lib/cfoundry/auth_token.rb, line 54 def expiration token_data[:exp].nil? ? Time.at(0) : Time.at(token_data[:exp]) end
expires_soon?()
click to toggle source
# File lib/cfoundry/auth_token.rb, line 58 def expires_soon? (expiration.to_i - Time.now.to_i) < 60 end
to_hash()
click to toggle source
# File lib/cfoundry/auth_token.rb, line 27 def to_hash { :token => auth_header, :refresh_token => @refresh_token } end
token_data()
click to toggle source
TODO: rename to data
# File lib/cfoundry/auth_token.rb, line 37 def token_data return @token_data if @token_data return {} unless @auth_header data_json = @auth_header.split(" ", 2).last return {} unless data_json @token_data = JWT.decode(data_json, nil, false)[0].symbolize_keys rescue {} end