/[resiprocate]/main/resip/dum/UserProfile.cxx
ViewVC logotype

Contents of /main/resip/dum/UserProfile.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9891 - (show annotations) (download)
Thu Oct 25 18:46:33 2012 UTC (7 years ago) by sgodin
File MIME type: text/plain
File size: 6835 byte(s)
 -added new UserProfile setting to DUM:  
  DigestCacheUseLimit is used to indicate the maximum number of times a particular 
  Proxy or WWW Authorization header will be used in requests within a dialogset.  
  When this limit is   reached then the next request in the DiaglogSet will go out 
  without digest credentials.  This setting can be used to work around bugs/limitations 
  in third-party implementations that have difficulty properly dealing with
  cached credentials.  A setting of 0 (default) will disable the limit and all requests 
  in a Dialogset will have the same cached Authorization header on them, until they are 
  re-challenged by the far end.  A setting of 1 disables caching entirely and future 
  requests within the dialog set will go out without any authorization headers.

Other Changes
 -resip ClientAuthManager - refactored dialogSetDestroyed and clearAuthenticationState to 
  be more logical
 -resip ClientPagerMessage - modified to allow onSuccess and onFailure callbacks even if queue
  of message contents is not used - allows you to call ClientPagerMessage::getMessageRequest,
  build the request yourself (even one without a body), send using DUM::send and still have 
  your callbacks invoked
1
2 #include "resip/dum/Profile.hxx"
3 #include "resip/dum/UserProfile.hxx"
4 #include "rutil/Logger.hxx"
5 #include "rutil/Inserter.hxx"
6 #include "resip/stack/SipMessage.hxx"
7 #include "rutil/MD5Stream.hxx"
8
9 using namespace resip;
10 #define RESIPROCATE_SUBSYSTEM Subsystem::DUM
11
12 const resip::NameAddr UserProfile::mAnonymous("\"Anonymous\" <sip:anonymous@anonymous.invalid>", true /* preCacheAor */);
13
14 UserProfile::UserProfile() : Profile(),
15 mGruuEnabled(false),
16 mRegId(0),
17 mClientOutboundEnabled(false),
18 mDigestCacheUseLimit(0)
19 {
20 //InfoLog (<< "************ UserProfile created (no base)!: " << *this);
21 }
22
23 UserProfile::UserProfile(SharedPtr<Profile> baseProfile) : Profile(baseProfile),
24 mGruuEnabled(false),
25 mRegId(0),
26 mClientOutboundEnabled(false),
27 mDigestCacheUseLimit(0)
28 {
29 //InfoLog (<< "************ UserProfile created (with base)!: " << *this);
30 }
31
32 UserProfile::~UserProfile()
33 {
34 //InfoLog (<< "************ UserProfile destroyed!: " << *this);
35 }
36
37 SharedPtr<UserProfile>
38 UserProfile::getAnonymousUserProfile() const
39 {
40 SharedPtr<UserProfile> anon(this->clone());
41 anon->setDefaultFrom(mAnonymous);
42 return anon;
43 }
44
45 UserProfile*
46 UserProfile::clone() const
47 {
48 return new UserProfile(*this);
49 }
50
51 bool
52 UserProfile::isAnonymous() const
53 {
54 return (mDefaultFrom.uri().getAor() == mAnonymous.uri().getAor());
55 }
56
57 void
58 UserProfile::setDefaultFrom(const NameAddr& from)
59 {
60 mDefaultFrom = from;
61 }
62
63 NameAddr&
64 UserProfile::getDefaultFrom()
65 {
66 return mDefaultFrom;
67 }
68
69 void
70 UserProfile::setServiceRoute(const NameAddrs& sRoute)
71 {
72 mServiceRoute = sRoute;
73 }
74
75 NameAddrs&
76 UserProfile::getServiceRoute()
77 {
78 return mServiceRoute;
79 }
80
81 bool
82 UserProfile::hasInstanceId()
83 {
84 return !mInstanceId.empty();
85 }
86
87 void
88 UserProfile::setInstanceId(const Data& id)
89 {
90 mInstanceId = id;
91 }
92
93 const Data&
94 UserProfile::getInstanceId() const
95 {
96 return mInstanceId;
97 }
98
99 void
100 UserProfile::addGruu(const Data& aor, const NameAddr& contact)
101 {
102 }
103
104 bool
105 UserProfile::hasGruu(const Data& aor) const
106 {
107 return false;
108 }
109
110 bool
111 UserProfile::hasGruu(const Data& aor, const Data& instance) const
112 {
113 return false;
114 }
115
116 NameAddr&
117 UserProfile:: getGruu(const Data& aor)
118 {
119 assert(0);
120 static NameAddr gruu;
121 return gruu;
122 }
123
124 NameAddr&
125 UserProfile:: getGruu(const Data& aor, const NameAddr& contact)
126 {
127 assert(0);
128 static NameAddr gruu;
129 return gruu;
130 }
131
132 void
133 UserProfile::clearDigestCredentials()
134 {
135 mDigestCredentials.clear();
136 }
137
138 void
139 UserProfile::setDigestCredential( const Data& realm, const Data& user, const Data& password, bool isPasswordA1Hash)
140 {
141 DigestCredential cred(realm, user, password, isPasswordA1Hash);
142
143 DebugLog (<< "Adding credential: " << cred);
144 mDigestCredentials.erase(cred);
145 mDigestCredentials.insert(cred);
146 }
147
148 static const UserProfile::DigestCredential emptyDigestCredential;
149 const UserProfile::DigestCredential&
150 UserProfile::getDigestCredential( const Data& realm )
151 {
152 if(mDigestCredentials.empty())
153 {
154 // !jf! why not just throw here?
155 return emptyDigestCredential;
156 }
157
158 DigestCredentials::const_iterator it = mDigestCredentials.find(DigestCredential(realm));
159 if (it == mDigestCredentials.end())
160 {
161 DebugLog(<< "Didn't find credential for realm: " << realm << " " << *mDigestCredentials.begin());
162 return *mDigestCredentials.begin();
163 }
164 else
165 {
166 DebugLog(<< "Found credential for realm: " << *it << realm);
167 return *it;
168 }
169 }
170
171 UserProfile::DigestCredential::DigestCredential(const Data& r, const Data& u, const Data& pwd, bool pwdA1Hash) :
172 realm(r),
173 user(u),
174 password(pwd),
175 isPasswordA1Hash(pwdA1Hash)
176 {
177 }
178
179 UserProfile::DigestCredential::DigestCredential() :
180 realm(Data::Empty),
181 user(Data::Empty),
182 password(Data::Empty),
183 isPasswordA1Hash(false)
184 {
185 }
186
187 UserProfile::DigestCredential::DigestCredential(const Data& pRealm) :
188 realm(pRealm),
189 user(Data::Empty),
190 password(Data::Empty),
191 isPasswordA1Hash(false)
192 {
193 }
194
195 bool
196 UserProfile::DigestCredential::operator<(const DigestCredential& rhs) const
197 {
198 return realm < rhs.realm;
199 }
200
201 EncodeStream&
202 resip::operator<<(EncodeStream& strm, const UserProfile& profile)
203 {
204 strm << "UserProfile: " << profile.mDefaultFrom << Inserter(profile.mDigestCredentials);
205 return strm;
206 }
207
208 EncodeStream&
209 resip::operator<<(EncodeStream& strm, const UserProfile::DigestCredential& cred)
210 {
211 strm << "realm=" << cred.realm << " user=" << cred.user ;
212 return strm;
213 }
214
215
216 /* ====================================================================
217 * The Vovida Software License, Version 1.0
218 *
219 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
220 *
221 * Redistribution and use in source and binary forms, with or without
222 * modification, are permitted provided that the following conditions
223 * are met:
224 *
225 * 1. Redistributions of source code must retain the above copyright
226 * notice, this list of conditions and the following disclaimer.
227 *
228 * 2. Redistributions in binary form must reproduce the above copyright
229 * notice, this list of conditions and the following disclaimer in
230 * the documentation and/or other materials provided with the
231 * distribution.
232 *
233 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
234 * and "Vovida Open Communication Application Library (VOCAL)" must
235 * not be used to endorse or promote products derived from this
236 * software without prior written permission. For written
237 * permission, please contact vocal@vovida.org.
238 *
239 * 4. Products derived from this software may not be called "VOCAL", nor
240 * may "VOCAL" appear in their name, without prior written
241 * permission of Vovida Networks, Inc.
242 *
243 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
244 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
245 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
246 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
247 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
248 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
249 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
250 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
251 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
252 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
253 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
254 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
255 * DAMAGE.
256 *
257 * ====================================================================
258 *
259 * This software consists of voluntary contributions made by Vovida
260 * Networks, Inc. and many individuals on behalf of Vovida Networks,
261 * Inc. For more information on Vovida Networks, Inc., please see
262 * <http://www.vovida.org/>.
263 *
264 */

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27