reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ClientAuthManager.hxx
Go to the documentation of this file.
1#if !defined(RESIP_CLIENTAUTHMANAGER_HXX)
2#define RESIP_CLIENTAUTHMANAGER_HXX
3
6
7#include <map>
8#include <functional>
9
10namespace resip
11{
12
13class Auth;
14class SipMessage;
15class ClientAuthExtension;
16
17
19{
20 public:
22 virtual ~ClientAuthManager() {}
23
24 // For any response received by the UAC, handle will be
25 // called. origRequest is the request that generated the 401/407.
26 // return true if the challenge can be handled with an updated request.
27 // This will increment the CSeq on origRequest
28 virtual bool handle(UserProfile& userProfile, SipMessage& origRequest, const SipMessage& response);
29
30 //
31 virtual void addAuthentication(SipMessage& origRequest);
32 virtual void clearAuthenticationState(const DialogSetId& dsId);
33
34 private:
35 friend class DialogSet;
36 virtual void dialogSetDestroyed(const DialogSetId& dsId);
37
38// class CompareAuth : public std::binary_function<const Auth&, const Auth&, bool>
39// {
40// public:
41// bool operator()(const Auth& lhs, const Auth& rhs) const;
42// };
43
44 class RealmState
45 {
46 public:
47 RealmState();
48
49 void clear();
50
51 bool handleAuth(UserProfile& userProfile, const Auth& auth, bool isProxyCredential);
52 void authSucceeded();
53
54 void addAuthentication(SipMessage& origRequest);
55 void transitionToFailedIfInitial();
56
57 private:
58 typedef enum
59 {
60 Initial,
61 Cached,
62 Current,
63 TryOnce,
64 Failed
65 } State;
66
67 void transition(State s);
68 static const Data& getStateString(State s);
69 bool findCredential(UserProfile& userProfile, const Auth& auth);
71 bool mIsProxyCredential;
72
73 State mState;
74 unsigned int mNonceCount;
75 Auth mAuth;
76
77 // .dcm. only one credential per realm per challenge supported
78 // typedef std::map<Auth, UserProfile::DigestCredential, CompareAuth > CredentialMap;
79 // CredentialMap proxyCredentials;
80 // CredentialMap wwwCredentials;
81 };
82
83 class AuthState
84 {
85 public:
86 AuthState();
87 bool handleChallenge(UserProfile& userProfile, const SipMessage& challenge);
88 bool handleChallenge(UserProfile& userProfile, const Auths& auths, bool isProxyCredential);
89 void addAuthentication(SipMessage& origRequest);
90 void authSucceeded();
91
92 private:
93 typedef std::map<Data, RealmState> RealmStates;
94 RealmStates mRealms;
95 bool mFailed;
96 unsigned long mCacheUseLimit;
97 unsigned long mCacheUseCount;
98 };
99
100 typedef std::map<DialogSetId, AuthState> AttemptedAuthMap;
101 AttemptedAuthMap mAttemptedAuths;
102};
103
104}
105
106#endif
107
108/* ====================================================================
109 * The Vovida Software License, Version 1.0
110 *
111 * Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
112 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
113 *
114 * Redistribution and use in source and binary forms, with or without
115 * modification, are permitted provided that the following conditions
116 * are met:
117 *
118 * 1. Redistributions of source code must retain the above copyright
119 * notice, this list of conditions and the following disclaimer.
120 *
121 * 2. Redistributions in binary form must reproduce the above copyright
122 * notice, this list of conditions and the following disclaimer in
123 * the documentation and/or other materials provided with the
124 * distribution.
125 *
126 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
127 * and "Vovida Open Communication Application Library (VOCAL)" must
128 * not be used to endorse or promote products derived from this
129 * software without prior written permission. For written
130 * permission, please contact vocal@vovida.org.
131 *
132 * 4. Products derived from this software may not be called "VOCAL", nor
133 * may "VOCAL" appear in their name, without prior written
134 * permission of Vovida Networks, Inc.
135 *
136 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
137 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
138 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
139 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
140 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
141 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
142 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
143 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
144 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
145 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
146 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
147 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
148 * DAMAGE.
149 *
150 * ====================================================================
151 *
152 * This software consists of voluntary contributions made by Vovida
153 * Networks, Inc. and many individuals on behalf of Vovida Networks,
154 * Inc. For more information on Vovida Networks, Inc., please see
155 * <http://www.vovida.org/>.
156 *
157 */
Data RealmStates[]
Represents the "credentials" and "challenge" elements in the SIP grammar.
Definition Auth.hxx:18
virtual bool handle(UserProfile &userProfile, SipMessage &origRequest, const SipMessage &response)
virtual void addAuthentication(SipMessage &origRequest)
virtual void clearAuthenticationState(const DialogSetId &dsId)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Represents a SIP message.
dcm! – add UnusedChecking(_enum) below;
ParserContainer< Auth > Auths
Definition Headers.hxx:268
void list()
Definition userAdmin.cxx:66