Revision: 41618
          http://brlcad.svn.sourceforge.net/brlcad/?rev=41618&view=rev
Author:   davidloman
Date:     2010-12-15 17:17:23 +0000 (Wed, 15 Dec 2010)

Log Message:
-----------
Add in a slew of needed null checks, c++->C comment conversions and 
disconnect() on failure calls.

Modified Paths:
--------------
    rt^3/trunk/src/GS/SessionManager.cxx

Modified: rt^3/trunk/src/GS/SessionManager.cxx
===================================================================
--- rt^3/trunk/src/GS/SessionManager.cxx        2010-12-15 17:04:43 UTC (rev 
41617)
+++ rt^3/trunk/src/GS/SessionManager.cxx        2010-12-15 17:17:23 UTC (rev 
41618)
@@ -142,38 +142,49 @@
  */
 void SessionManager::handleNewSessionReqMsg(NewSessionReqMsg* msg)
 {
+       log->logINFO("SessionManager", "Recv'ed NewSessionReqMsg.");
+
+       /* Check for a good pointer to msg */
+       if (msg == NULL) {
+               log->logERROR("SessionManager", "handleNewSessionReMsg(): NULL 
NewSessionReqMsg!");
+               return;
+       }
+
+       /* Get values from msg */
        Portal* origin = msg->getOrigin();
        QString uname = msg->getUName();
        QString passwd = msg->getPasswd();
 
-       //validate incoming data
+       /* Validate data */
        if (origin == 0) {
                //TODO Figure out how to how to handle NULL Portal
                log->logERROR("SessionManager", "handleNewSessionReMsg(): NULL 
Portal!");
                return;
        }
 
+       /* Quick LEN check on strings. */
        if (uname.length() <=0 || passwd.length() <= 0) {
-               log->logINFO("SessionManager", "Auth FAILED.  Zero len uname or 
passwd.");
+               log->logINFO("SessionManager", "Auth FAILED.  Zero len uname or 
passwd. Disconnecting.");
                GenericOneByteMsg* fail = new GenericOneByteMsg(FAILURE, 
ACCOUNT_VALIDATION_FAIL);
-               origin->send(fail);
+               origin->sendThenDisconnect(fail);
                return;
        }
 
-       //try to validate creds
-       Account* a = AccountManager::getInstance()->login(msg->getUName(), 
msg->getPasswd(), msg->getOrigin());
+       /* Attempt to validate creds */
+       Account* a = AccountManager::getInstance()->login(uname, passwd, 
origin);
 
        if (a == 0) {
-               //Account validation failed
+               /* Account validation failed */
+               log->logINFO("SessionManager", "Auth FAILED.  Bad uname or 
passwd. Disconnecting.");
                GenericOneByteMsg* fail = new GenericOneByteMsg(FAILURE, 
ACCOUNT_VALIDATION_FAIL);
-               origin->send(fail);
+               origin->sendThenDisconnect(fail);
                return;
        }
 
-       //Make new session
+       /* Make new session */
        Session* s = this->newSession(a);
 
-       //tell client about it.
+       /* Tell client about it. */
        SessionInfoMsg* info = s->generateSessionInfoMsg();
        origin->send(info);
 }
@@ -183,15 +194,21 @@
 {
        Portal* origin = msg->getOrigin();
 
-       //validate incoming data
+       /* validate incoming data */
        if (origin == 0) {
                //TODO Figure out how to how to handle NULL Portal
                log->logERROR("SessionManager", "handleDisconnectReqMsg(): NULL 
Portal!");
                return;
        }
 
+       /* Remove Session */
        Session* s = this->getSession(origin);
        this->remCache(s);
+
+       /* Remove Account */
+       Account* a = s->getAccount();
+       AccountManager::getInstance()->logout(a);
+       delete a;
 }
 
 // Local Variables: ***


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to