reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
UserAuthGrabber.cxx
Go to the documentation of this file.
8#include "rutil/Logger.hxx"
10
11#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
12
13using namespace repro;
14using namespace resip;
15
17 mDataStore(dataStore)
18{
19}
20
24
25bool
27{
28 repro::UserInfoMessage* uinf = dynamic_cast<UserInfoMessage*>(msg); // auth for repro's DigestAuthenticator
29 if (uinf)
30 {
33 DebugLog(<< "Grabbed user info for " << uinf->user() << "@" << uinf->realm() << " : " << uinf->A1());
34 return true;
35 }
36
37 resip::UserAuthInfo* uainf = dynamic_cast<resip::UserAuthInfo*>(msg); // auth for DUM's ServerAuthManager
38 if (uainf)
39 {
40 uainf->setA1(mDataStore.mUserStore.getUserAuthInfo(uainf->getUser(), uainf->getRealm()));
41 if (uainf->getA1().empty())
42 {
44 }
45 DebugLog(<< "Grabbed user info for " << uainf->getUser() << "@" << uainf->getRealm() << " : " << uainf->getA1());
46 return true;
47 }
48
49 repro::TlsPeerIdentityInfo* tpaInfo = dynamic_cast<repro::TlsPeerIdentityInfo*>(msg);
50 if (tpaInfo)
51 {
53 DebugLog(<< "Looked up authorization for " << tpaInfo << " result = " << tpaInfo->authorized());
54 return true;
55 }
56
57 resip::TlsPeerIdentityInfoMessage* tpaInfoMessage = dynamic_cast<resip::TlsPeerIdentityInfoMessage*>(msg);
58 if (tpaInfoMessage)
59 {
60 tpaInfoMessage->authorized() = mDataStore.mTlsPeerIdentityStore.isAuthorized(tpaInfoMessage->peerNames(), tpaInfoMessage->identities());
61 DebugLog(<< "Looked up authorization for " << tpaInfoMessage << " result = " << tpaInfoMessage->authorized());
62 return true;
63 }
64
65 repro::PresenceUserExists* pue = dynamic_cast<repro::PresenceUserExists*>(msg); // user exists query for Presence server
66 if (pue)
67 {
69 DebugLog(<< "Checking existence for " << pue->getUser() << "@" << pue->getDomain() << " : user " << (pue->getUserExists() ? "exists" : "does not exist"));
70 return true;
71 }
72
73 WarningLog(<< "Did not recognize message type...");
74 return false;
75}
76
79{
80 return new UserAuthGrabber(mDataStore);
81}
82
83/* ====================================================================
84 * The Vovida Software License, Version 1.0
85 *
86 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
87 *
88 * Redistribution and use in source and binary forms, with or without
89 * modification, are permitted provided that the following conditions
90 * are met:
91 *
92 * 1. Redistributions of source code must retain the above copyright
93 * notice, this list of conditions and the following disclaimer.
94 *
95 * 2. Redistributions in binary form must reproduce the above copyright
96 * notice, this list of conditions and the following disclaimer in
97 * the documentation and/or other materials provided with the
98 * distribution.
99 *
100 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
101 * and "Vovida Open Communication Application Library (VOCAL)" must
102 * not be used to endorse or promote products derived from this
103 * software without prior written permission. For written
104 * permission, please contact vocal@vovida.org.
105 *
106 * 4. Products derived from this software may not be called "VOCAL", nor
107 * may "VOCAL" appear in their name, without prior written
108 * permission of Vovida Networks, Inc.
109 *
110 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
111 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
112 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
113 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
114 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
115 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
116 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
117 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
118 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
119 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
120 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
121 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
122 * DAMAGE.
123 *
124 * ====================================================================
125 *
126 * This software consists of voluntary contributions made by Vovida
127 * Networks, Inc. and many individuals on behalf of Vovida Networks,
128 * Inc. For more information on Vovida Networks, Inc., please see
129 * <http://www.vovida.org/>.
130 *
131 */
#define DebugLog(args_)
Definition Logger.hxx:128
#define WarningLog(args_)
Definition Logger.hxx:134
virtual void setUserExists(bool exists)
virtual const resip::Data getUser()
virtual const resip::Data getDomain()
The Store contains differnt types of stores such as user, route, etc.
Definition Store.hxx:21
TlsPeerIdentityStore mTlsPeerIdentityStore
Definition Store.hxx:35
UserStore mUserStore
Definition Store.hxx:34
const std::set< resip::Data > & identities() const
const std::set< resip::Data > & peerNames() const
bool isAuthorized(const std::set< resip::Data > &peerNames, const std::set< resip::Data > &identities) const
virtual bool process(resip::ApplicationMessage *msg)
UserAuthGrabber(repro::Store &dataStore)
virtual UserAuthGrabber * clone() const
const resip::Data & A1() const
AbstractDb::UserRecord mRec
const resip::Data & user() const
void setMode(const resip::UserAuthInfo::InfoMode m)
const resip::Data & realm() const
static Key buildKey(const resip::Data &user, const resip::Data &domain)
resip::Data getUserAuthInfo(const resip::Data &user, const resip::Data &realm) const
Definition UserStore.cxx:42
AbstractDb::UserRecord getUserInfo(const Key &key) const
Definition UserStore.cxx:36
A base-class for messages used by applications.
bool empty() const noexcept
Checks whether the Data is empty.
Definition Data.hxx:591
const std::set< resip::Data > & identities() const
const std::set< resip::Data > & peerNames() const
void setMode(InfoMode mode, int32_t errorCode=0, const resip::Data &statusText=resip::Data::Empty)
const resip::Data & getUser() const
const resip::Data & getRealm() const
void setA1(const resip::Data &a1)
const resip::Data & getA1() const
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;