Class: Lapis::Yggdrasil::Messaging::AuthenticationRequest
- Defined in:
- lib/lapis/yggdrasil/messaging/authentication_request.rb
Overview
Message sent to attempt to authenticate.
Instance Method Summary collapse
-
#endpoint ⇒ String
Path on the server that handles the request.
-
#initialize(username, password, agent, client_token = nil) ⇒ AuthenticationRequest
constructor
Creates a new authentication request.
-
#to_json ⇒ String
Generates a JSON string that can be sent to an authentication server.
Constructor Details
#initialize(username, password, agent, client_token = nil) ⇒ AuthenticationRequest
Creates a new authentication request.
18 19 20 21 22 23 |
# File 'lib/lapis/yggdrasil/messaging/authentication_request.rb', line 18 def initialize(username, password, agent, client_token = nil) @username = username.dup.freeze @password = password.dup.freeze @agent = agent @client_token = client_token end |
Instance Method Details
#endpoint ⇒ String
Path on the server that handles the request.
27 28 29 |
# File 'lib/lapis/yggdrasil/messaging/authentication_request.rb', line 27 def endpoint '/authenticate' end |
#to_json ⇒ String
Generates a JSON string that can be sent to an authentication server.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/lapis/yggdrasil/messaging/authentication_request.rb', line 33 def to_json hash = { :agent => { :name => @agent.name, :version => @agent.version }, :username => @username, :password => @password } hash[:clientToken] = @client_token.to_s(false) if @client_token hash.to_json end |