|
reSIProcate/DialogUsageManager
9694
|
00001 #if !defined(RESIP_SERVERAUTHMANAGER_HXX) 00002 #define RESIP_SERVERAUTHMANAGER_HXX 00003 00004 #include <map> 00005 00006 #include "resip/stack/Auth.hxx" 00007 #include "resip/stack/SipMessage.hxx" 00008 #include "DumFeature.hxx" 00009 00010 namespace resip 00011 { 00012 class UserAuthInfo; 00013 class DialogUsageManager; 00014 00015 00016 class ServerAuthManager : public DumFeature 00017 { 00018 public: 00019 enum Result 00020 { 00021 //Authorized, 00022 RequestedInfo, 00023 RequestedCredentials, 00024 Challenged, 00025 Skipped, 00026 Rejected 00027 }; 00028 00029 ServerAuthManager(DialogUsageManager& dum, TargetCommand::Target& target); 00030 virtual ~ServerAuthManager(); 00031 00032 virtual ProcessingResult process(Message* msg); 00033 00034 // can return Authorized, Rejected or Skipped 00035 //Result handleUserAuthInfo(Message* msg); 00036 00037 // returns the SipMessage that was authorized if succeeded or returns 0 if 00038 // rejected. 00039 virtual SipMessage* handleUserAuthInfo(UserAuthInfo* auth); 00040 00041 // can return Challenged, RequestedCredentials, Rejected, Skipped 00042 virtual Result handle(SipMessage* sipMsg); 00043 00044 protected: 00045 00046 enum AsyncBool 00047 { 00048 True, // response is true 00049 False, // response is false 00050 Async // response will be sent asynchronously 00051 }; 00052 00053 enum AuthFailureReason 00054 { 00055 InvalidRequest, // some aspect of the request (e.g. nonce) 00056 // is not valid/tampered with 00057 BadCredentials, // credentials didn't match 00058 Error // processing/network error 00059 }; 00060 00061 // this call back should async cause a post of UserAuthInfo 00062 virtual void requestCredential(const Data& user, 00063 const Data& realm, 00064 const SipMessage& msg, 00065 const Auth& auth, // the auth line we have chosen to authenticate against 00066 const Data& transactionToken ) = 0; 00067 00068 virtual bool useAuthInt() const; 00069 virtual bool proxyAuthenticationMode() const; 00070 virtual bool rejectBadNonces() const; 00071 00072 typedef std::map<Data, SipMessage*> MessageMap; 00073 MessageMap mMessages; 00074 00077 virtual AsyncBool requiresChallenge(const SipMessage& msg); 00078 00080 virtual bool authorizedForThisIdentity(const resip::Data &user, 00081 const resip::Data &realm, 00082 resip::Uri &fromUri); 00083 00085 virtual const Data& getChallengeRealm(const SipMessage& msg); 00086 00088 virtual bool isMyRealm(const Data& realm); 00089 00090 // Either 00091 // a) issues a challenge if necessary and returns `Challenged' 00092 // b) returns `Skipped' if no challenge necessary 00093 // c) waits asynchronously to find out if challenge required, 00094 // and returns `RequestedInfo' 00095 Result issueChallengeIfRequired(SipMessage *sipMsg); 00096 00097 // sends a 407 challenge to the UAC who sent sipMsg 00098 void issueChallenge(SipMessage *sipMsg); 00099 00100 virtual void onAuthSuccess(const SipMessage& msg); 00101 virtual void onAuthFailure(AuthFailureReason reason, const SipMessage& msg); 00102 }; 00103 00104 00105 } 00106 00107 #endif 00108 00109 /* ==================================================================== 00110 * The Vovida Software License, Version 1.0 00111 * 00112 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00113 * 00114 * Redistribution and use in source and binary forms, with or without 00115 * modification, are permitted provided that the following conditions 00116 * are met: 00117 * 00118 * 1. Redistributions of source code must retain the above copyright 00119 * notice, this list of conditions and the following disclaimer. 00120 * 00121 * 2. Redistributions in binary form must reproduce the above copyright 00122 * notice, this list of conditions and the following disclaimer in 00123 * the documentation and/or other materials provided with the 00124 * distribution. 00125 * 00126 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00127 * and "Vovida Open Communication Application Library (VOCAL)" must 00128 * not be used to endorse or promote products derived from this 00129 * software without prior written permission. For written 00130 * permission, please contact vocal@vovida.org. 00131 * 00132 * 4. Products derived from this software may not be called "VOCAL", nor 00133 * may "VOCAL" appear in their name, without prior written 00134 * permission of Vovida Networks, Inc. 00135 * 00136 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00137 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00138 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00139 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00140 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00141 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00142 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00143 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00144 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00145 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00146 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00147 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00148 * DAMAGE. 00149 * 00150 * ==================================================================== 00151 * 00152 * This software consists of voluntary contributions made by Vovida 00153 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00154 * Inc. For more information on Vovida Networks, Inc., please see 00155 * <http://www.vovida.org/>. 00156 * 00157 */
1.7.5.1