reSIProcate/repro  9694
ReproServerAuthManager.cxx
Go to the documentation of this file.
00001 #include <cassert>
00002 
00003 #include "resip/dum/DialogUsageManager.hxx"
00004 #include "repro/ReproServerAuthManager.hxx"
00005 #include "resip/dum/ServerAuthManager.hxx"
00006 #include "resip/dum/UserAuthInfo.hxx"
00007 #include "repro/UserStore.hxx"
00008 #include "repro/AclStore.hxx"
00009 
00010 #define RESIPROCATE_SUBSYSTEM Subsystem::REPRO
00011 
00012 using namespace resip;
00013 using namespace repro;
00014 
00015 
00016 ReproServerAuthManager::ReproServerAuthManager(DialogUsageManager& dum,
00017                                                Dispatcher* authRequestDispatcher,
00018                                                AclStore& aclDb,
00019                                                bool useAuthInt,
00020                                                bool rejectBadNonces):
00021    ServerAuthManager(dum, dum.dumIncomingTarget()),
00022    mDum(dum),
00023    mAuthRequestDispatcher(authRequestDispatcher),
00024    mAclDb(aclDb),
00025    mUseAuthInt(useAuthInt),
00026    mRejectBadNonces(rejectBadNonces)
00027 {
00028 }
00029 
00030 ReproServerAuthManager::~ReproServerAuthManager()
00031 {
00032 }
00033 
00034 bool 
00035 ReproServerAuthManager::useAuthInt() const
00036 {
00037    return mUseAuthInt;
00038 }
00039 
00040 bool
00041 ReproServerAuthManager::rejectBadNonces() const
00042 {
00043    return mRejectBadNonces;
00044 }
00045 
00046 ServerAuthManager::AsyncBool
00047 ReproServerAuthManager::requiresChallenge(const SipMessage& msg)
00048 {
00049    assert(msg.isRequest());
00050    if(!mAclDb.isRequestTrusted(msg))
00051    {
00052       return True;
00053    }
00054    else
00055    {
00056       return False;
00057    }
00058 }
00059 
00060 void 
00061 ReproServerAuthManager::requestCredential(const Data& user, 
00062                                           const Data& realm, 
00063                                           const SipMessage& msg,
00064                                           const Auth& auth,
00065                                           const Data& transactionId )
00066 {
00067    // Build a UserAuthInfo object and pass to UserAuthGrabber to have a1 password filled in
00068    UserAuthInfo* async = new UserAuthInfo(user,realm,transactionId,&mDum);
00069    std::auto_ptr<ApplicationMessage> app(async);
00070    mAuthRequestDispatcher->post(app);
00071 }
00072  
00073 
00074 /* ====================================================================
00075  * The Vovida Software License, Version 1.0 
00076  * 
00077  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00078  * 
00079  * Redistribution and use in source and binary forms, with or without
00080  * modification, are permitted provided that the following conditions
00081  * are met:
00082  * 
00083  * 1. Redistributions of source code must retain the above copyright
00084  *    notice, this list of conditions and the following disclaimer.
00085  * 
00086  * 2. Redistributions in binary form must reproduce the above copyright
00087  *    notice, this list of conditions and the following disclaimer in
00088  *    the documentation and/or other materials provided with the
00089  *    distribution.
00090  * 
00091  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00092  *    and "Vovida Open Communication Application Library (VOCAL)" must
00093  *    not be used to endorse or promote products derived from this
00094  *    software without prior written permission. For written
00095  *    permission, please contact vocal@vovida.org.
00096  *
00097  * 4. Products derived from this software may not be called "VOCAL", nor
00098  *    may "VOCAL" appear in their name, without prior written
00099  *    permission of Vovida Networks, Inc.
00100  * 
00101  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00102  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00103  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00104  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00105  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00106  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00107  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00108  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00109  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00110  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00111  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00112  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00113  * DAMAGE.
00114  * 
00115  * ====================================================================
00116  * 
00117  * This software consists of voluntary contributions made by Vovida
00118  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00119  * Inc.  For more information on Vovida Networks, Inc., please see
00120  * <http://www.vovida.org/>.
00121  *
00122  */