reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ServerAuthManager.hxx
Go to the documentation of this file.
1#if !defined(RESIP_SERVERAUTHMANAGER_HXX)
2#define RESIP_SERVERAUTHMANAGER_HXX
3
4#include <map>
5#include <vector>
6
7#include "rutil/AsyncBool.hxx"
11#include "DumFeature.hxx"
12
13namespace resip
14{
15class UserAuthInfo;
16class DialogUsageManager;
17
18
20{
21 public:
31
33 TargetCommand::Target& target,
34 bool challengeThirdParties = true,
35 const resip::Data& staticRealm = "",
36 const std::vector<DigestType>& challengeDigestTypes = std::vector<DigestType>());
37 virtual ~ServerAuthManager();
38
39 virtual ProcessingResult process(Message* msg);
40
41 // can return Authorized, Rejected or Skipped
42 //Result handleUserAuthInfo(Message* msg);
43
44 // returns the SipMessage that was authorized if succeeded or returns 0 if
45 // rejected.
47
48 // can return Challenged, RequestedCredentials, Rejected, Skipped
49 virtual Result handle(SipMessage* sipMsg);
50
51 protected:
52
54 {
55 InvalidRequest, // some aspect of the request (e.g. nonce)
56 // is not valid/tampered with
57 BadCredentials, // credentials didn't match
58 Error // processing/network error
59 };
60
61 // this call back should async cause a post of UserAuthInfo
62 virtual void requestCredential(const Data& user,
63 const Data& realm,
64 const SipMessage& msg,
65 const Auth& auth, // the auth line we have chosen to authenticate against
66 const Data& transactionToken ) = 0;
67
68 virtual bool useAuthInt() const;
69 virtual bool proxyAuthenticationMode() const;
70 virtual bool rejectBadNonces() const;
71
72 typedef std::map<Data, SipMessage*> MessageMap;
74
77 virtual AsyncBool requiresChallenge(const SipMessage& msg);
78
80 virtual bool authorizedForThisIdentity(const resip::Data &user,
81 const resip::Data &realm,
82 resip::Uri &fromUri);
83
85 virtual const Data& getChallengeRealm(const SipMessage& msg);
86
88 virtual bool isMyRealm(const Data& realm);
89
90 // Either
91 // a) issues a challenge if necessary and returns `Challenged'
92 // b) returns `Skipped' if no challenge necessary
93 // c) waits asynchronously to find out if challenge required,
94 // and returns `RequestedInfo'
96
97 // sends a 407 challenge to the UAC who sent sipMsg
98 void issueChallenge(SipMessage *sipMsg, bool stale=false);
99
100 virtual void onAuthSuccess(const SipMessage& msg);
101 virtual void onAuthFailure(AuthFailureReason reason, const SipMessage& msg);
102
105 std::vector<DigestType> mChallengeDigestTypes; // Ordered list of digest types to use in challenges
106};
107
108
109}
110
111#endif
112
113/* ====================================================================
114 * The Vovida Software License, Version 1.0
115 *
116 * Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
117 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
118 *
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 *
123 * 1. Redistributions of source code must retain the above copyright
124 * notice, this list of conditions and the following disclaimer.
125 *
126 * 2. Redistributions in binary form must reproduce the above copyright
127 * notice, this list of conditions and the following disclaimer in
128 * the documentation and/or other materials provided with the
129 * distribution.
130 *
131 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
132 * and "Vovida Open Communication Application Library (VOCAL)" must
133 * not be used to endorse or promote products derived from this
134 * software without prior written permission. For written
135 * permission, please contact vocal@vovida.org.
136 *
137 * 4. Products derived from this software may not be called "VOCAL", nor
138 * may "VOCAL" appear in their name, without prior written
139 * permission of Vovida Networks, Inc.
140 *
141 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
142 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
143 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
144 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
145 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
146 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
147 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
148 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
149 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
150 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
151 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
152 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
153 * DAMAGE.
154 *
155 * ====================================================================
156 *
157 * This software consists of voluntary contributions made by Vovida
158 * Networks, Inc. and many individuals on behalf of Vovida Networks,
159 * Inc. For more information on Vovida Networks, Inc., please see
160 * <http://www.vovida.org/>.
161 *
162 */
Represents the "credentials" and "challenge" elements in the SIP grammar.
Definition Auth.hxx:18
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
The base-class used for message-passing.
Definition Message.hxx:21
virtual bool isMyRealm(const Data &realm)
should return true if realm passed in is ours and we can challenge
Result issueChallengeIfRequired(SipMessage *sipMsg)
virtual SipMessage * handleUserAuthInfo(UserAuthInfo *auth)
std::vector< DigestType > mChallengeDigestTypes
virtual Result handle(SipMessage *sipMsg)
virtual const Data & getChallengeRealm(const SipMessage &msg)
returns the realm to be used for the challenge
virtual bool proxyAuthenticationMode() const
virtual void onAuthSuccess(const SipMessage &msg)
virtual bool useAuthInt() const
std::map< Data, SipMessage * > MessageMap
virtual AsyncBool requiresChallenge(const SipMessage &msg)
should return true if the request must be challenged The default is to challenge all requests - overr...
virtual bool rejectBadNonces() const
virtual void onAuthFailure(AuthFailureReason reason, const SipMessage &msg)
virtual ProcessingResult process(Message *msg)
void issueChallenge(SipMessage *sipMsg, bool stale=false)
virtual bool authorizedForThisIdentity(const resip::Data &user, const resip::Data &realm, resip::Uri &fromUri)
should return true if the passed in user is authorized for the provided uri
virtual void requestCredential(const Data &user, const Data &realm, const SipMessage &msg, const Auth &auth, const Data &transactionToken)=0
Represents a SIP message.
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
Definition Uri.hxx:22
dcm! – add UnusedChecking(_enum) below;