reSIProcate/repro  9694
UserAuthGrabber.hxx
Go to the documentation of this file.
00001 #ifndef USER_AUTH_GRABBER
00002 #define USER_AUTH_GRABBER 1
00003 
00004 #include "repro/Worker.hxx"
00005 #include "repro/AbstractDb.hxx"
00006 #include "repro/UserStore.hxx"
00007 #include "resip/stack/Message.hxx"
00008 #include "repro/UserInfoMessage.hxx"
00009 #include "resip/dum/UserAuthInfo.hxx"
00010 
00011 #define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
00012 
00013 
00014 namespace repro
00015 {
00016 
00017 class UserAuthGrabber : public Worker
00018 {
00019    public:
00020       UserAuthGrabber(repro::UserStore& userStore ):
00021          mUserStore(userStore)
00022       {}
00023       
00024       virtual ~UserAuthGrabber(){}
00025       
00026       virtual bool process(resip::ApplicationMessage* msg)
00027       {
00028          repro::UserInfoMessage* uinf = dynamic_cast<UserInfoMessage*>(msg);    // auth for repro's DigestAuthenticator
00029          resip::UserAuthInfo* uainf = dynamic_cast<resip::UserAuthInfo*>(msg);  // auth for DUM's ServerAuthManager
00030          if(uinf)
00031          {
00032             uinf->mRec.passwordHash = mUserStore.getUserAuthInfo(uinf->user(), uinf->realm());
00033             DebugLog(<<"Grabbed user info for " 
00034                            << uinf->user() <<"@"<<uinf->realm()
00035                            << " : " << uinf->A1());
00036             return true;
00037          }
00038          else if(uainf)
00039          {
00040             uainf->setA1(mUserStore.getUserAuthInfo(uainf->getUser(), uainf->getRealm()));
00041             if(uainf->getA1().empty())
00042             {
00043                uainf->setMode(resip::UserAuthInfo::UserUnknown);
00044             }
00045             DebugLog(<<"Grabbed user info for " 
00046                            << uainf->getUser() <<"@"<<uainf->getRealm()
00047                            << " : " << uainf->getA1());
00048             return true;
00049          }
00050          else
00051          {
00052             WarningLog(<<"Did not recognize message type...");
00053          }
00054          return false;
00055       }
00056       
00057       virtual UserAuthGrabber* clone() const
00058       {
00059          return new UserAuthGrabber(mUserStore);
00060       }
00061       
00062    protected:
00063       UserStore& mUserStore;
00064 };
00065 
00066 }
00067 #endif
00068 
00069 /* ====================================================================
00070  * The Vovida Software License, Version 1.0 
00071  * 
00072  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00073  * 
00074  * Redistribution and use in source and binary forms, with or without
00075  * modification, are permitted provided that the following conditions
00076  * are met:
00077  * 
00078  * 1. Redistributions of source code must retain the above copyright
00079  *    notice, this list of conditions and the following disclaimer.
00080  * 
00081  * 2. Redistributions in binary form must reproduce the above copyright
00082  *    notice, this list of conditions and the following disclaimer in
00083  *    the documentation and/or other materials provided with the
00084  *    distribution.
00085  * 
00086  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00087  *    and "Vovida Open Communication Application Library (VOCAL)" must
00088  *    not be used to endorse or promote products derived from this
00089  *    software without prior written permission. For written
00090  *    permission, please contact vocal@vovida.org.
00091  *
00092  * 4. Products derived from this software may not be called "VOCAL", nor
00093  *    may "VOCAL" appear in their name, without prior written
00094  *    permission of Vovida Networks, Inc.
00095  * 
00096  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00097  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00098  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00099  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00100  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00101  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00102  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00103  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00104  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00105  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00106  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00107  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00108  * DAMAGE.
00109  * 
00110  * ====================================================================
00111  * 
00112  * This software consists of voluntary contributions made by Vovida
00113  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00114  * Inc.  For more information on Vovida Networks, Inc., please see
00115  * <http://www.vovida.org/>.
00116  *
00117  */