8#if defined(HAVE_CONFIG_H)
29#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
32 : mProxyConfig(proxyConfig),
35 mEnableCertAuth(mProxyConfig.getConfigBool(
"EnableCertificateAuthenticator", false)),
36 mEnableDigestAuth(!mProxyConfig.getConfigBool(
"DisableAuth", false)),
37 mEnableRADIUS(mProxyConfig.getConfigBool(
"EnableRADIUS", false)),
38 mRADIUSConfiguration(mProxyConfig.getConfigData(
"RADIUSConfiguration",
"")),
39 mStaticRealm(mProxyConfig.getConfigData(
"StaticRealm",
"")),
40 mDigestChallengeThirdParties(!mEnableCertAuth),
44 std::vector<resip::Data> digestTypeStrings;
45 if (mProxyConfig.
getConfigValue(
"DigestChallengeAlgorithms", digestTypeStrings))
48 for (
auto it = digestTypeStrings.begin(); it != digestTypeStrings.end(); ++it)
52 InfoLog(<<
"Adding algorithm=" << *it <<
" for digest challenges");
53 mChallengeDigestTypes.push_back(digestType);
64ReproAuthenticatorFactory::init()
66 if(!mAuthRequestDispatcher.get())
68 int numAuthGrabberWorkerThreads = mProxyConfig.
getConfigInt(
"NumAuthGrabberWorkerThreads", 2);
69 if(numAuthGrabberWorkerThreads < 1)
71 numAuthGrabberWorkerThreads = 1;
74 mAuthRequestDispatcher.reset(
new Dispatcher(std::move(grabber), &mSipStack, numAuthGrabberWorkerThreads));
78 loadCommonNameMappings();
82ReproAuthenticatorFactory::loadCommonNameMappings()
85 if(!mCommonNameMappings.empty())
89 if(mappingsFileName.
empty())
92 InfoLog(<<
"trying to load common name mappings from file: " << mappingsFileName);
94 ifstream mappingsFile(mappingsFileName.
c_str());
97 ErrLog(<<
"failed to open mappings file: " << mappingsFileName <<
", aborting");
98 throw std::runtime_error(
"Error opening/reading mappings file");
102 while(getline(mappingsFile, sline))
110 const char * anchor = pb.position();
111 if(pb.eof() || *anchor ==
'#')
continue;
114 pb.skipToOneOf(
"\t");
116 if(mCommonNameMappings.find(cn) != mCommonNameMappings.end())
118 ErrLog(<<
"CN '" << cn <<
"' repeated in mappings file");
119 throw std::runtime_error(
"CN repeated in mappings file");
130 anchor = pb.position();
131 pb.skipToOneOf(
",\r\n ");
132 pb.
data(value, anchor);
135 StackLog(<<
"Loading CN '" << cn <<
"', found mapping '" << value <<
"'");
136 permitted.insert(value);
142 DebugLog(<<
"Loaded mapping for CN '" << cn <<
"', " << permitted.size() <<
" mapping(s)");
143 mCommonNameMappings[cn] = permitted;
147std::shared_ptr<DumFeature>
151 if(!mCertificateAuthManager.get())
158 return mCertificateAuthManager;
161std::unique_ptr<Processor>
171std::shared_ptr<ServerAuthManager>
175 if(!mServerAuthManager.get())
179#ifdef USE_RADIUS_CLIENT
180 mServerAuthManager.reset(
new ReproRADIUSServerAuthManager(*mDum,
184 mRADIUSConfiguration,
185 mDigestChallengeThirdParties,
187 mChallengeDigestTypes));
189 ErrLog(<<
"can't create ReproRADIUSServerAuthManager, not compiled with RADIUS support");
199 mDigestChallengeThirdParties,
201 mChallengeDigestTypes));
204 return mServerAuthManager;
207std::unique_ptr<Processor>
213#ifdef USE_RADIUS_CLIENT
214 return std::unique_ptr<Processor>(
new RADIUSAuthenticator(mProxyConfig, mRADIUSConfiguration, mStaticRealm));
216 ErrLog(<<
"can't create RADIUSAuthenticator, not compiled with RADIUS support");
230 return mAuthRequestDispatcher.get();
#define resip_assert(x)
This file needs to work for both C and C++ code.
virtual std::shared_ptr< resip::DumFeature > getCertificateAuthManager()
virtual resip::Dispatcher * getDispatcher()
ReproAuthenticatorFactory(ProxyConfig &proxyConfig, resip::SipStack &sipStack, resip::DialogUsageManager *dum)
virtual std::shared_ptr< resip::ServerAuthManager > getServerAuthManager()
virtual std::unique_ptr< Processor > getCertificateAuthenticator()
virtual ~ReproAuthenticatorFactory()
virtual std::unique_ptr< Processor > getDigestAuthenticator()
The Store contains differnt types of stores such as user, route, etc.
int getConfigInt(const resip::Data &name, int defaultValue) const
resip::Data getConfigData(const resip::Data &name, const resip::Data &defaultValue, bool useDefaultIfEmpty=false) const
bool getConfigBool(const resip::Data &name, bool defaultValue) const
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
const char * c_str() const
Returns a null-terminated string representing.
bool empty() const noexcept
Checks whether the Data is empty.
const char * data() const noexcept
Returns a pointer to the contents of this Data.
TargetCommand::Target & dumIncomingTarget()
A generic thread-bank class.
static bool isDigestAlgorithmSupported(const Auth &auth, DigestType &digestType)
Provides string-parsing functionality with protection from buffer overflow.
bool getConfigValue(const resip::Data &name, resip::Uri &value)
This is the primary point of interaction between the app-layer and the stack.
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
std::set< Data > PermittedFromAddresses