void AdminConnection::processLogin(){ InputFrame::Ptr recvframe( new InputFrame(version, paddingfilter) ); if (readFrame(recvframe)) { try { if(recvframe->getType() == ft02_Login){ std::string username, password; if ( getAuth( recvframe, username, password ) ) { bool authenticated = false; try{ if(username == Settings::getSettings()->get("admin_user") && password == Settings::getSettings()->get("admin_pass")) authenticated = true; }catch(std::exception e){ } if(authenticated){ sendOK( recvframe, "Welcome" ); INFO("Admin login ok by %s", username.c_str()); logextid = Logger::getLogger()->addLog( LogSink::Ptr( new AdminLogger( boost::dynamic_pointer_cast<AdminConnection>(shared_from_this()) ) ) ); status = READY; } else { throw FrameException( fec_FrameError, "Admin Login Error - bad username or password"); // TODO - should be a const or enum, Login error } } }else{ throw FrameException( fec_FrameError, "Wrong type of frame in this state, wanted login"); } } catch ( FrameException& exception ) { // This might be overkill later, but now let's log it DEBUG( "AdminConnection caught FrameException : %s", exception.what() ); sendFail( recvframe, exception.getErrorCode(), exception.getErrorMessage() ); } } }
void AdminConnection::processNormalFrame() { InputFrame::Ptr frame( new InputFrame(version,paddingfilter) ); if (readFrame(frame)) { try { switch (frame->getType()) { case ftad_CommandDesc_Get: processDescribeCommand(frame); break; case ftad_CommandTypes_Get: processGetCommandTypes(frame); break; case ftad_Command: processCommand(frame); break; default: WARNING("AdminConnection: Discarded frame, not processed, was type %d", frame->getType()); throw FrameException( fec_ProtocolError, "Did not understand that frame type."); break; } } catch ( FrameException& exception ) { // This might be overkill later, but now let's log it DEBUG( "AdminConnection caught FrameException : %s", exception.what() ); sendFail( frame, exception.getErrorCode(), exception.getErrorMessage() ); } } else { DEBUG("noFrame :("); // client closed } }
void ClientOpt::sendMessageFail() { emit sendFail(); }