Class: Aurora::Server::Token
- Inherits:
-
Object
- Object
- Aurora::Server::Token
- Defined in:
- lib/aurora/server/token.rb
Instance Attribute Summary collapse
-
#lifetime ⇒ Object
– Constants and Attributes ++.
-
#token ⇒ Object
– Constants and Attributes ++.
Instance Method Summary collapse
-
#initialize(user, pass, lifetime = 5*60) ⇒ Token
constructor
Takes the lifetime of the token.
-
#to_json ⇒ Object
Creates JSON format of Token.
Constructor Details
#initialize(user, pass, lifetime = 5*60) ⇒ Token
Takes the lifetime of the token
16 17 18 19 20 21 22 |
# File 'lib/aurora/server/token.rb', line 16 def initialize(user, pass, lifetime=5*60) @lifetime = lifetime @token = Digest::MD5.hexdigest("#{user}:#{pass}").split(/(....)/)[1..-1].map{|node|node="-" if node==""; node}.to_s.upcase @@tokens ||= [] @@tokens << self end |
Instance Attribute Details
#lifetime ⇒ Object
– Constants and Attributes ++
9 10 11 |
# File 'lib/aurora/server/token.rb', line 9 def lifetime @lifetime end |
#token ⇒ Object
– Constants and Attributes ++
9 10 11 |
# File 'lib/aurora/server/token.rb', line 9 def token @token end |
Instance Method Details
#to_json ⇒ Object
Creates JSON format of Token
25 26 27 28 29 30 |
# File 'lib/aurora/server/token.rb', line 25 def to_json { :token => @token, :lifetime => @lifetime }.to_json end |