⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 digestauthenticator.cxx

📁 这是国外的resip协议栈
💻 CXX
📖 第 1 页 / 共 2 页
字号:
                        {                           InfoLog(<<"...and this "                              "Identity-Info header was malformed!");                        }                        sipMessage->remove(h_IdentityInfo);                     }                                          sipMessage->header(h_IdentityInfo).uri() = http                         + DnsUtil::getLocalHostName()                         + post + realm;                     InfoLog (<< "Identity-Info=" << sipMessage->header(h_IdentityInfo).uri());                  }               }#endif            }            else            {               // !rwm! The user is trying to forge a request.  Respond with a 403               InfoLog (<< "User: " << user << " at realm: " << realm <<                            " trying to forge request from: " << sipMessage->header(h_From).uri());               rc.sendResponse(*auto_ptr<SipMessage>                               (Helper::makeResponse(*sipMessage, 403)));               return SkipAllChains;                           }                        return Continue;         case Helper::Expired:            InfoLog (<< "Authentication expired for " << user);            challengeRequest(rc, true);            return SkipAllChains;         case Helper::BadlyFormed:            InfoLog (<< "Authentication nonce badly formed for " << user);            if(mRejectBadNonces)            {               rc.sendResponse(*auto_ptr<SipMessage>                            (Helper::makeResponse(*sipMessage, 403, "Where on earth did you get that nonce?")));            }            else            {               challengeRequest(rc, true);            }            return SkipAllChains;      }   }   return Continue;}boolDigestAuthenticator::authorizedForThisIdentity(const resip::Data &user, const resip::Data &realm,                                                 resip::Uri &fromUri){   // !rwm! good enough for now.  TODO eventually consult a database to see what   // combinations of user/realm combos are authorized for an identity   if (fromUri.host() == realm)   {      return ((fromUri.user() == user) || (fromUri.user() == "anonymous"));   }   return false;}voidDigestAuthenticator::challengeRequest(repro::RequestContext &rc,                                      bool stale){   SipMessage &sipMessage = rc.getOriginalRequest();   Data realm = getRealm(rc);   SipMessage *challenge = Helper::makeProxyChallenge(sipMessage, realm,                                                       mUseAuthInt /*auth-int*/, stale);   rc.sendResponse(*challenge);   delete challenge;}repro::Processor::processor_action_tDigestAuthenticator::requestUserAuthInfo(repro::RequestContext &rc, resip::Data &realm){   Message *message = rc.getCurrentEvent();   SipMessage *sipMessage = dynamic_cast<SipMessage*>(message);   assert(sipMessage);   // Extract the user from the appropriate Proxy-Authorization header   Auths &authorizationHeaders = sipMessage->header(h_ProxyAuthorizations);    Auths::iterator i;   Data user;   for (i = authorizationHeaders.begin();        i != authorizationHeaders.end(); i++)   {      if (    i->exists(p_realm) &&               i->param(p_realm) == realm              &&  i->exists(p_username))      {         user = i->param(p_username);         InfoLog (<< "Request user auth info for "  << user                  << " at realm " << realm);         break;      }   }   if (!user.empty())   {      //database.requestUserAuthInfo(user, realm, rc.getTransactionId(), rc.getProxy());      UserInfoMessage* async = new UserInfoMessage(*this, rc.getTransactionId(), &(rc.getProxy()));      async->user()=user;      async->realm()=realm;      if(sipMessage->header(h_From).isWellFormed())      {         async->domain()=sipMessage->header(h_From).uri().host();      }      else      {         async->domain()=realm;      }      mAuthRequestDispatcher->post(std::auto_ptr<ApplicationMessage>(async));      return WaitingForEvent;   }   else   {      challengeRequest(rc, false);      return SkipAllChains;   }}resip::DataDigestAuthenticator::getRealm(RequestContext &rc){   Data realm;   Proxy &proxy = rc.getProxy();   SipMessage& sipMessage = rc.getOriginalRequest();   // (1) Check Preferred Identity   if (sipMessage.exists(h_PPreferredIdentities))   {      // !abr! Add this when we get a chance      // find the fist sip or sips P-Preferred-Identity header      // for (;;)      // {      //    if ((i->uri().scheme() == Symbols::SIP) || (i->uri().scheme() == Symbols::SIPS))      //    {      //       return i->uri().host();      //    }      // }   }   // (2) Check From domain   if (proxy.isMyDomain(sipMessage.header(h_From).uri().host()))   {      return sipMessage.header(h_From).uri().host();   }   // (3) Check Top Route Header   if (sipMessage.exists(h_Routes) &&         sipMessage.header(h_Routes).size()!=0 &&         sipMessage.header(h_Routes).front().isWellFormed())   {      // !abr! Add this when we get a chance   }   // (4) Punt: Use Request URI   return sipMessage.header(h_RequestLine).uri().host();}voidDigestAuthenticator::dump(std::ostream &os) const{   os << "DigestAuthentication monkey" << std::endl;}/* ==================================================================== * The Vovida Software License, Version 1.0  *  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved. *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: *  * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. *  * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. *  * 3. The names "VOCAL", "Vovida Open Communication Application Library", *    and "Vovida Open Communication Application Library (VOCAL)" must *    not be used to endorse or promote products derived from this *    software without prior written permission. For written *    permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor *    may "VOCAL" appear in their name, without prior written *    permission of Vovida Networks, Inc. *  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. *  * ==================================================================== *  * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc.  For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -