take account optionally from config file (overrides P-App-Param

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1252 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 18 years ago
parent 71fb353d9c
commit 5898f6807f

@ -34,9 +34,13 @@
#include "AmAudio.h"
#include "AmPlugIn.h"
#include "AmMediaProcessor.h"
//#include "AmConfigReader.h"
#include "AmConfigReader.h"
#include "AmSessionContainer.h"
string AuthB2BFactory::user;
string AuthB2BFactory::domain;
string AuthB2BFactory::pwd;
EXPORT_SESSION_FACTORY(AuthB2BFactory,MOD_NAME);
AuthB2BFactory::AuthB2BFactory(const string& _app_name)
@ -48,9 +52,16 @@ AuthB2BFactory::AuthB2BFactory(const string& _app_name)
int AuthB2BFactory::onLoad()
{
// AmConfigReader cfg;
// if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
// return -1;
AmConfigReader cfg;
if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) {
INFO("No configuration for auth_b2b present (%s)\n",
(AmConfig::ModConfigPath + string(MOD_NAME ".conf")).c_str()
);
} else {
user = cfg.getParameter("user");
domain = cfg.getParameter("domain");
pwd = cfg.getParameter("pwd");
}
// user_timer_fact = AmPlugIn::instance()->getFactory4Di("user_timer");
// if(!user_timer_fact) {
@ -101,16 +112,22 @@ void AuthB2BDialog::onInvite(const AmSipRequest& req)
setReceiving(false);
AmMediaProcessor::instance()->removeSession(this);
string app_param = getHeader(req.hdrs, PARAM_HDR);
if (AuthB2BFactory::user.empty()) {
string app_param = getHeader(req.hdrs, PARAM_HDR);
if (!app_param.length()) {
AmSession::Exception(500, "auth_b2b: parameters not found");
if (!app_param.length()) {
AmSession::Exception(500, "auth_b2b: parameters not found");
}
domain = get_header_keyvalue(app_param,"d");
user = get_header_keyvalue(app_param,"u");
password = get_header_keyvalue(app_param,"p");
} else {
domain = AuthB2BFactory::domain;
user = AuthB2BFactory::user;
password = AuthB2BFactory::pwd;
}
domain = get_header_keyvalue(app_param,"d");
user = get_header_keyvalue(app_param,"u");
password = get_header_keyvalue(app_param,"p");
from = "sip:"+user+"@"+domain;
to = "sip:"+req.user+"@"+domain;

@ -44,6 +44,10 @@ class AuthB2BFactory: public AmSessionFactory
int onLoad();
AmSession* onInvite(const AmSipRequest& req);
static string user;
static string domain;
static string pwd;
};
class AuthB2BDialog : public AmB2BCallerSession

@ -0,0 +1,7 @@
# Account to use on the outgoing call leg. If this is not set,
# the account is taken from P-App-Param header (see Readme.auth_b2b)
#
# user=someuser
# domain=somedomain.net
# pwd=sompwd
Loading…
Cancel
Save