[asterisk-scf-commits] asterisk-scf/release/sip.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Aug 30 12:44:45 CDT 2011


branch "master" has been updated
       via  6635bf7183e7868f54c35dbcf1bf5f2d05777b84 (commit)
      from  fdf2ec9681b3ac0b879dd445bba76cb9baa22745 (commit)

Summary of changes:
 src/AuthManager.cpp |   32 ++++++++++++++++++++++----------
 src/AuthManager.h   |    4 ++++
 src/PJSipModule.cpp |   15 ++++++++++++---
 3 files changed, 38 insertions(+), 13 deletions(-)


- Log -----------------------------------------------------------------
commit 6635bf7183e7868f54c35dbcf1bf5f2d05777b84
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Aug 30 14:48:43 2011 -0300

    Use pjsip to create a challenge for authentication.

diff --git a/src/AuthManager.cpp b/src/AuthManager.cpp
index f91994e..0bd0d15 100644
--- a/src/AuthManager.cpp
+++ b/src/AuthManager.cpp
@@ -143,13 +143,6 @@ std::vector<AuthHookPrx> AuthInstance::getHooks()
     return mImpl->hooks;
 }
 
-static pj_status_t lookup_cred(pj_pool_t *, const pj_str_t *,
-        const pj_str_t *, pjsip_cred_info *)
-{
-    // Return non-success for now just so it doesn't seem like authentication is actually succeeding.
-    return !PJ_SUCCESS;
-}
-
 bool AuthInstance::authenticate(pjsip_rx_data *rdata)
 {
     //For each server auth, we need to call pjsip_auth_srv_verify(), which will then
@@ -195,7 +188,13 @@ void AuthInstance::addDigests(pjsip_tx_data *tdata, const DigestChallengeSeq &di
         pjsip_auth_srv *authServer = PJ_POOL_ZALLOC_T(mImpl->mPool, pjsip_auth_srv);
         pj_str_t realm;
         pj_cstr(&realm, (*digest)->realm.c_str());
-        pjsip_auth_srv_init(mImpl->mPool, authServer, &realm, lookup_cred, 0);
+        pjsip_auth_srv_init(mImpl->mPool, authServer, &realm, NULL, 0);
+
+        pj_strdup2(mImpl->mPool, &authServer->cred_info.username, (*digest)->username.c_str());
+        authServer->cred_info.data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
+        pj_strdup2(mImpl->mPool, &authServer->cred_info.data, (*digest)->password.c_str());
+        pj_strdup2(mImpl->mPool, &authServer->cred_info.realm, (*digest)->realm.c_str());
+
         pj_str_t nonce, opaque, *noncePtr = NULL, *opaquePtr = NULL;
         if (!(*digest)->opaque.empty())
         {
@@ -396,6 +395,20 @@ void AuthManager::destroyAuthInstance(const boost::shared_ptr<AuthInstance> &ins
     }
 }
 
+void AuthManager::destroyAuthInstance(const AuthInstance* instance)
+{
+    boost::lock_guard<boost::mutex> lock(mImpl->mAuthInstancesLock);
+    for (std::vector<boost::shared_ptr<AuthInstance> >::iterator iter = mImpl->mAuthInstances.begin();
+	 iter != mImpl->mAuthInstances.end(); ++ iter)
+    {
+        if ((*iter).get() == instance)
+        {
+            mImpl->mAuthInstances.erase(iter);
+            break;
+        }
+    }
+}
+
 void AuthManager::scheduleAuthTimeout(const boost::shared_ptr<AuthInstance> &instance)
 {
     instance->scheduleAuthTimeout(mImpl->mCounter++);
@@ -403,8 +416,7 @@ void AuthManager::scheduleAuthTimeout(const boost::shared_ptr<AuthInstance> &ins
 
 void AuthManager::authTimeout(pj_timer_heap_t *, pj_timer_entry *entry)
 {
-    boost::shared_ptr<AuthInstance> killMe(static_cast<AuthInstance *>(entry->user_data));
-    destroyAuthInstance(killMe);
+    destroyAuthInstance(static_cast<AuthInstance *>(entry->user_data));
 }
 
 void AuthManager::addAuthHook(const AsteriskSCF::SIP::ExtensionPoint::V1::AuthHookPrx &hook,
diff --git a/src/AuthManager.h b/src/AuthManager.h
index 07930ab..f113ea0 100644
--- a/src/AuthManager.h
+++ b/src/AuthManager.h
@@ -158,6 +158,10 @@ public:
      */
     void destroyAuthInstance(const boost::shared_ptr<AuthInstance> &instance);
     /**
+     * Destroy an AuthInstance
+     */
+    void destroyAuthInstance(const AuthInstance* instance);
+    /**
      * This is the callback that scheduleAuthDestruction sets up.
      *
      * Do not call this method directly.
diff --git a/src/PJSipModule.cpp b/src/PJSipModule.cpp
index 12497e4..5a85362 100644
--- a/src/PJSipModule.cpp
+++ b/src/PJSipModule.cpp
@@ -160,17 +160,26 @@ TransactionState PJSipTransactionModInfo::transactionStateTranslate(pjsip_tsx_st
 
 void PJSipModule::addAuthHook(const AsteriskSCF::SIP::ExtensionPoint::V1::AuthHookPrx &hook, int priority, const AsteriskSCF::SIP::ExtensionPoint::V1::RequestTypeSeq &types)
 {
-    mAuthManager->addAuthHook(hook, priority, types);
+    if (mAuthManager.get())
+    {
+        mAuthManager->addAuthHook(hook, priority, types);
+    }
 }
 
 void PJSipModule::removeAuthHook(const AsteriskSCF::SIP::ExtensionPoint::V1::AuthHookPrx &hook)
 {
-    mAuthManager->removeAuthHook(hook);
+    if (mAuthManager.get())
+    {
+        mAuthManager->removeAuthHook(hook);
+    }
 }
 
 void PJSipModule::clearAuthHooks()
 {
-    mAuthManager->clearAuthHooks();
+    if (mAuthManager.get())
+    {
+        mAuthManager->clearAuthHooks();
+    }
 }
 
 };

-----------------------------------------------------------------------


-- 
asterisk-scf/release/sip.git



More information about the asterisk-scf-commits mailing list