/[resiprocate]/main/resip/dum/ServerAuthManager.hxx
ViewVC logotype

Contents of /main/resip/dum/ServerAuthManager.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10848 - (show annotations) (download)
Sun Jan 12 10:43:21 2014 UTC (5 years, 10 months ago) by Dpocock
File MIME type: text/plain
File size: 6078 byte(s)
resip/dum: add support for statically configured auth realm
1 #if !defined(RESIP_SERVERAUTHMANAGER_HXX)
2 #define RESIP_SERVERAUTHMANAGER_HXX
3
4 #include <map>
5
6 #include "resip/stack/Auth.hxx"
7 #include "resip/stack/SipMessage.hxx"
8 #include "DumFeature.hxx"
9
10 namespace resip
11 {
12 class UserAuthInfo;
13 class DialogUsageManager;
14
15
16 class ServerAuthManager : public DumFeature
17 {
18 public:
19 enum Result
20 {
21 //Authorized,
22 RequestedInfo,
23 RequestedCredentials,
24 Challenged,
25 Skipped,
26 Rejected
27 };
28
29 ServerAuthManager(DialogUsageManager& dum, TargetCommand::Target& target, bool challengeThirdParties = true, const resip::Data& staticRealm = "");
30 virtual ~ServerAuthManager();
31
32 virtual ProcessingResult process(Message* msg);
33
34 // can return Authorized, Rejected or Skipped
35 //Result handleUserAuthInfo(Message* msg);
36
37 // returns the SipMessage that was authorized if succeeded or returns 0 if
38 // rejected.
39 virtual SipMessage* handleUserAuthInfo(UserAuthInfo* auth);
40
41 // can return Challenged, RequestedCredentials, Rejected, Skipped
42 virtual Result handle(SipMessage* sipMsg);
43
44 protected:
45
46 enum AsyncBool
47 {
48 True, // response is true
49 False, // response is false
50 Async // response will be sent asynchronously
51 };
52
53 enum AuthFailureReason
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;
73 MessageMap mMessages;
74
75 /// should return true if the request must be challenged
76 /// The default is to challenge all requests - override this class to change this beviour
77 virtual AsyncBool requiresChallenge(const SipMessage& msg);
78
79 /// should return true if the passed in user is authorized for the provided uri
80 virtual bool authorizedForThisIdentity(const resip::Data &user,
81 const resip::Data &realm,
82 resip::Uri &fromUri);
83
84 /// returns the realm to be used for the challenge
85 virtual const Data& getChallengeRealm(const SipMessage& msg);
86
87 /// should return true if realm passed in is ours and we can challenge
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'
95 Result issueChallengeIfRequired(SipMessage *sipMsg);
96
97 // sends a 407 challenge to the UAC who sent sipMsg
98 void issueChallenge(SipMessage *sipMsg);
99
100 virtual void onAuthSuccess(const SipMessage& msg);
101 virtual void onAuthFailure(AuthFailureReason reason, const SipMessage& msg);
102
103 private:
104 bool mChallengeThirdParties;
105 resip::Data mStaticRealm;
106 };
107
108
109 }
110
111 #endif
112
113 /* ====================================================================
114 * The Vovida Software License, Version 1.0
115 *
116 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
117 *
118 * Redistribution and use in source and binary forms, with or without
119 * modification, are permitted provided that the following conditions
120 * are met:
121 *
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions and the following disclaimer.
124 *
125 * 2. Redistributions in binary form must reproduce the above copyright
126 * notice, this list of conditions and the following disclaimer in
127 * the documentation and/or other materials provided with the
128 * distribution.
129 *
130 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
131 * and "Vovida Open Communication Application Library (VOCAL)" must
132 * not be used to endorse or promote products derived from this
133 * software without prior written permission. For written
134 * permission, please contact vocal@vovida.org.
135 *
136 * 4. Products derived from this software may not be called "VOCAL", nor
137 * may "VOCAL" appear in their name, without prior written
138 * permission of Vovida Networks, Inc.
139 *
140 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
141 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
142 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
143 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
144 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
145 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
146 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
147 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
148 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
149 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
150 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
151 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
152 * DAMAGE.
153 *
154 * ====================================================================
155 *
156 * This software consists of voluntary contributions made by Vovida
157 * Networks, Inc. and many individuals on behalf of Vovida Networks,
158 * Inc. For more information on Vovida Networks, Inc., please see
159 * <http://www.vovida.org/>.
160 *
161 */

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