Class: Kraut::Application
- Inherits:
-
Object
- Object
- Kraut::Application
- Defined in:
- lib/kraut/application.rb
Overview
Kraut::Application
Represents an application registered with Crowd.
Class Attribute Summary collapse
-
.authenticated_at ⇒ Object
Returns the value of attribute authenticated_at.
-
.name ⇒ Object
Returns the value of attribute name.
-
.password ⇒ Object
Returns the value of attribute password.
-
.token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
-
.authenticate(name, password) ⇒ Object
Authenticates an application with a given
name
andpassword
. -
.authentication_required?(timeout = 10) ⇒ Boolean
Returns whether the application needs to (re-)authenticate itself.
Class Attribute Details
.authenticated_at ⇒ Object
Returns the value of attribute authenticated_at.
20 21 22 |
# File 'lib/kraut/application.rb', line 20 def authenticated_at @authenticated_at end |
.name ⇒ Object
Returns the value of attribute name.
20 21 22 |
# File 'lib/kraut/application.rb', line 20 def name @name end |
.password ⇒ Object
Returns the value of attribute password.
20 21 22 |
# File 'lib/kraut/application.rb', line 20 def password @password end |
.token ⇒ Object
Returns the value of attribute token.
20 21 22 |
# File 'lib/kraut/application.rb', line 20 def token @token end |
Class Method Details
.authenticate(name, password) ⇒ Object
Authenticates an application with a given name
and password
.
12 13 14 15 16 17 18 |
# File 'lib/kraut/application.rb', line 12 def authenticate(name, password) response = Client.request :authenticate_application, :in0 => { "aut:credential" => { "aut:credential" => password }, "aut:name" => name } self.authenticated_at = Time.now self.name, self.password, self.token = name, password, response[:out][:token] end |
.authentication_required?(timeout = 10) ⇒ Boolean
Returns whether the application needs to (re-)authenticate itself. Defaults to a timeout
of 10 minutes.
24 25 26 |
# File 'lib/kraut/application.rb', line 24 def authentication_required?(timeout = 10) !authenticated_at || authenticated_at < Time.now - (60 * timeout) end |