Class: Wsaa::Client
- Inherits:
-
Object
- Object
- Wsaa::Client
- Defined in:
- lib/wsaa/client.rb
Overview
WSAA authentication client.
Orchestrates the authentication flow: builds TRA, signs it, calls WSAA, and caches credentials.
Instance Attribute Summary collapse
-
#configuration ⇒ Configuration
readonly
The client configuration.
Instance Method Summary collapse
-
#authenticate ⇒ Credentials
Authenticates with WSAA using cached credentials if available.
-
#authenticate! ⇒ Credentials
Authenticates with WSAA, ignoring any cached credentials.
-
#initialize(configuration) ⇒ Client
constructor
Creates a new Client.
Constructor Details
#initialize(configuration) ⇒ Client
Creates a new Client.
18 19 20 |
# File 'lib/wsaa/client.rb', line 18 def initialize(configuration) @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Configuration (readonly)
The client configuration.
11 12 13 |
# File 'lib/wsaa/client.rb', line 11 def configuration @configuration end |
Instance Method Details
#authenticate ⇒ Credentials
Authenticates with WSAA using cached credentials if available.
28 29 30 31 32 33 34 35 |
# File 'lib/wsaa/client.rb', line 28 def authenticate configuration.validate! cached = credential_store.read return cached if cached authenticate! end |
#authenticate! ⇒ Credentials
Authenticates with WSAA, ignoring any cached credentials.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/wsaa/client.rb', line 43 def authenticate! configuration.validate! tra = build_tra signed_tra = sign_tra(tra.to_xml) response = call_wsaa(signed_tra) credentials = parse_response(response, tra.expiration_time) credential_store.write(credentials) credentials end |