Class: Pantry::Commands::CreateClient

Inherits:
Pantry::Command show all
Defined in:
lib/pantry/commands/create_client.rb

Overview

Ask the server to generate a new set of keys Prints a yaml file that contains the required keys for a client to properly conenct and authenticate to the server

Instance Method Summary collapse

Methods inherited from Pantry::Command

command, #finished, #finished?, #initialize, message_type, #prepare_message, #receive_client_response, #receive_response, #send_request, #send_request!, #server_or_client, #server_or_client=, #to_message, #wait_for_finish

Constructor Details

This class inherits a constructor from Pantry::Command

Instance Method Details

#perform(message) ⇒ Object



12
13
14
# File 'lib/pantry/commands/create_client.rb', line 12

def perform(message)
  server.create_client
end

#receive_server_response(message) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/pantry/commands/create_client.rb', line 16

def receive_server_response(message)
  keys = message.body[0]
  Pantry.ui.say("New Client Credentials")
  Pantry.ui.say("Store this in the Client's Pantry.root/security/curve/client_keys.yml")
  Pantry.ui.say(YAML.dump({
    "server_public_key" => keys[:server_public_key],
    "public_key" => keys[:public_key],
    "private_key" => keys[:private_key]
  }))
end