1 
2 #include "AmUACAuth.h"
3 
UACAuthCred()4 UACAuthCred::UACAuthCred() { }
UACAuthCred(const string & realm,const string & user,const string & pwd)5 UACAuthCred::UACAuthCred(const string& realm,
6 			 const string& user,
7 			 const string& pwd)
8   : realm(realm), user(user), pwd(pwd) { }
9 
10 
11 
AmUACAuth()12 AmUACAuth::AmUACAuth() { }
13 
~AmUACAuth()14 AmUACAuth::~AmUACAuth() { }
15 
16 
unpackCredentials(const AmArg & arg)17 UACAuthCred* AmUACAuth::unpackCredentials(const AmArg& arg) {
18   UACAuthCred* cred = NULL;
19   if (arg.getType() == AmArg::AObject) {
20     AmObject* cred_obj = arg.asObject();
21     if (cred_obj)
22       cred = dynamic_cast<UACAuthCred*>(cred_obj);
23   }
24   return cred;
25 }
26 
27 
enable(AmSession * s)28 bool AmUACAuth::enable(AmSession* s) {
29   bool res = false;
30 
31   AmSessionEventHandlerFactory* uac_auth_f =
32     AmPlugIn::instance()->getFactory4Seh("uac_auth");
33   if (uac_auth_f != NULL) {
34     AmSessionEventHandler* h = uac_auth_f->getHandler(s);
35     if (h != NULL ) {
36       DBG("enabling SIP UAC auth for new session.\n");
37       s->addHandler(h);
38       res = true;
39     } else {
40       WARN("trying to get auth handler for invalid session "
41 	   "(derived from CredentialHolder?)\n");
42     }
43   } else {
44     WARN("uac_auth interface not accessible. "
45 	  "Load uac_auth for authenticated calls.\n");
46   }
47   return res;
48 }
49