Class: ItunesController::PasswordCommand
- Inherits:
-
ServerCommand
- Object
- ServerCommand
- ItunesController::PasswordCommand
- Defined in:
- lib/itunesController/controllserver.rb
Overview
The password command takes the format PASSWORD:<password> and is used to log the user in if the username and password are correct.
Instance Attribute Summary
Attributes inherited from ServerCommand
#name, #requiredLoginState, #singleThreaded
Instance Method Summary collapse
-
#initialize(state, itunes) ⇒ PasswordCommand
constructor
The constructor.
-
#processData(line, io) ⇒ Boolean, String
The line is processed to get the password.
Methods inherited from ServerCommand
#executeSingleThreaded, #processLine
Constructor Details
#initialize(state, itunes) ⇒ PasswordCommand
The constructor
224 225 226 |
# File 'lib/itunesController/controllserver.rb', line 224 def initialize(state,itunes) super(ItunesController::CommandName::PASSWORD,ServerState::DOING_AUTH,false,state,itunes) end |
Instance Method Details
#processData(line, io) ⇒ Boolean, String
The line is processed to get the password. Then the authentication deatials are checked. If they pass, then the user is now logged in and the server state changes to ItunesController::ServerState::AUTH with a reply to the client of “223 Logged in”. If the autentication check fails, then a reply “”501 Incorrect username/password“ is sent and the client is disconnected.
238 239 240 241 242 243 244 245 246 |
# File 'lib/itunesController/controllserver.rb', line 238 def processData(line,io) if (line =~ /^\:(.+)$/) if (checkAuth(@state.user,$1)) @state.state = ServerState::AUTHED return true,"223 Logged in\r\n" end end return false,"501 Incorrect username/password\r\n" end |