]> sjero.net Git - linphone/commitdiff
sal is code complete.
authorSimon Morlat <simon.morlat@linphone.org>
Sun, 7 Feb 2010 14:54:39 +0000 (15:54 +0100)
committerSimon Morlat <simon.morlat@linphone.org>
Sun, 7 Feb 2010 14:54:39 +0000 (15:54 +0100)
coreapi/authentication.c
coreapi/general_state.c
coreapi/sal_eXosip2.c
coreapi/siplogin.c

index e55ab495a4aac80d1843fcf5fbd93133d1365e3c..fc27142db18a06a799782e9c6fd17d1a3968a625 100644 (file)
  
 #include "linphonecore.h"
 #include "private.h"
-#include <eXosip2/eXosip.h>
-#include <osipparser2/osip_message.h>
 #include "lpconfig.h"
 
-extern LinphoneProxyConfig *linphone_core_get_proxy_config_from_rid(LinphoneCore *lc, int rid);
-
 /**
  * @addtogroup authentication
  * @{
@@ -211,21 +207,6 @@ LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *rea
        return ret;
 }
 
-static void refresh_exosip_auth_info(LinphoneCore *lc){
-       MSList *elem;
-       eXosip_lock();
-       eXosip_clear_authentication_info();
-       for (elem=lc->auth_info;elem!=NULL;elem=ms_list_next(elem)){
-               LinphoneAuthInfo *info=(LinphoneAuthInfo*)elem->data;
-               char *userid;
-               if (info->userid==NULL || info->userid[0]=='\0') userid=info->username;
-               else userid=info->userid;
-               eXosip_add_authentication_info(info->username,userid,
-                               info->passwd,info->ha1,info->realm);
-       }
-       eXosip_unlock();
-}
-
 /**
  * Adds authentication information to the LinphoneCore.
  * 
@@ -249,8 +230,23 @@ void linphone_core_add_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info)
        }else {
                lc->auth_info=ms_list_append(lc->auth_info,(void *)info);
        }
-       refresh_exosip_auth_info(lc);
-       /* if the user was prompted, re-allow automatic_action */
+       /* retry pending authentication operations */
+       for(elem=sal_get_pending_auths(lc->sal);elem!=NULL;elem=elem->next){
+               const char *username,*realm;
+               SalOp *op=(SalOp*)elem->data;
+               LinphoneAuthInfo *ai;
+               sal_op_get_auth_requested(op,&realm,&username);
+               ai=linphone_core_find_auth_info(lc,realm,username);
+               if (ai){
+                       SalAuthInfo sai;
+                       sai.username=ai->username;
+                       sai.userid=ai->userid;
+                       sai.realm=ai->realm;
+                       sai.password=ai->passwd;
+                       sal_op_authenticate(op,&sai);
+                       ai->usecount++;
+               }
+       }
 }
 
 
@@ -259,7 +255,6 @@ void linphone_core_add_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info)
  * from the auth_info_requested callback of LinphoneCoreVTable.
 **/
 void linphone_core_abort_authentication(LinphoneCore *lc,  LinphoneAuthInfo *info){
-       if (lc->automatic_action>0) lc->automatic_action--;
 }
 
 /**
@@ -280,8 +275,6 @@ void linphone_core_remove_auth_info(LinphoneCore *lc, LinphoneAuthInfo *info){
        for (elem=lc->auth_info,i=0;elem!=NULL;elem=ms_list_next(elem),i++){
                linphone_auth_info_write_config(lc->config,(LinphoneAuthInfo*)elem->data,i);
        }
-       refresh_exosip_auth_info(lc);
-       
 }
 
 /**
@@ -297,9 +290,6 @@ const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc){
 void linphone_core_clear_all_auth_info(LinphoneCore *lc){
        MSList *elem;
        int i;
-       eXosip_lock();
-       eXosip_clear_authentication_info();
-       eXosip_unlock();
        for(i=0,elem=lc->auth_info;elem!=NULL;elem=ms_list_next(elem),i++){
                LinphoneAuthInfo *info=(LinphoneAuthInfo*)elem->data;
                linphone_auth_info_destroy(info);
@@ -309,84 +299,6 @@ void linphone_core_clear_all_auth_info(LinphoneCore *lc){
        lc->auth_info=NULL;
 }
 
-void linphone_authentication_ok(LinphoneCore *lc, eXosip_event_t *ev){
-       char *prx_realm=NULL,*www_realm=NULL;
-       osip_proxy_authorization_t *prx_auth;
-       osip_authorization_t *www_auth;
-       osip_message_t *msg=ev->request;
-       char *username;
-       LinphoneAuthInfo *as=NULL;
-
-       username=osip_uri_get_username(msg->from->url);
-       osip_message_get_proxy_authorization(msg,0,&prx_auth);
-       osip_message_get_authorization(msg,0,&www_auth);
-       if (prx_auth!=NULL)
-               prx_realm=osip_proxy_authorization_get_realm(prx_auth);
-       if (www_auth!=NULL)
-               www_realm=osip_authorization_get_realm(www_auth);
-       
-       if (prx_realm==NULL && www_realm==NULL){
-               ms_message("No authentication info in the request, ignoring");
-               return;
-       }
-       /* see if we already have this auth information , not to ask it everytime to the user */
-       if (prx_realm!=NULL)
-               as=linphone_core_find_auth_info(lc,prx_realm,username);
-       if (www_realm!=NULL) 
-               as=linphone_core_find_auth_info(lc,www_realm,username);
-       if (as){
-               ms_message("Authentication for user=%s realm=%s is working.",username,prx_realm ? prx_realm : www_realm);
-               as->works=TRUE;
-       }
-}
-
-
-void linphone_core_find_or_ask_for_auth_info(LinphoneCore *lc,const char *username,const char* realm, int tid)
-{
-       LinphoneAuthInfo *as=linphone_core_find_auth_info(lc,realm,username);
-       if ( as==NULL || (as!=NULL && as->works==FALSE && as->first_time==FALSE)){
-               if (lc->vtable.auth_info_requested!=NULL){
-                       lc->vtable.auth_info_requested(lc,realm,username);
-                       lc->automatic_action++;/*suspends eXosip_automatic_action until the user supplies a password */
-               }
-       }
-       if (as) as->first_time=FALSE;
-}
-
-void linphone_process_authentication(LinphoneCore *lc, eXosip_event_t *ev)
-{
-       char *prx_realm=NULL,*www_realm=NULL;
-       osip_proxy_authenticate_t *prx_auth;
-       osip_www_authenticate_t *www_auth;
-       osip_message_t *resp=ev->response;
-       char *username;
-
-       /*
-       if (strcmp(ev->request->sip_method,"REGISTER")==0) {
-               gstate_new_state(lc, GSTATE_REG_FAILED, "Authentication required");
-       }
-       */
-
-       username=osip_uri_get_username(resp->from->url);
-       prx_auth=(osip_proxy_authenticate_t*)osip_list_get(&resp->proxy_authenticates,0);
-       www_auth=(osip_proxy_authenticate_t*)osip_list_get(&resp->www_authenticates,0);
-       if (prx_auth!=NULL)
-               prx_realm=osip_proxy_authenticate_get_realm(prx_auth);
-       if (www_auth!=NULL)
-               www_realm=osip_www_authenticate_get_realm(www_auth);
-       
-       if (prx_realm==NULL && www_realm==NULL){
-               ms_warning("No realm in the server response.");
-               return;
-       }
-       /* see if we already have this auth information , not to ask it everytime to the user */
-       if (prx_realm!=NULL) 
-               linphone_core_find_or_ask_for_auth_info(lc,username,prx_realm,ev->tid);
-       if (www_realm!=NULL) 
-               linphone_core_find_or_ask_for_auth_info(lc,username,www_realm,ev->tid);
-}
-
-
 /**
  * @}
 **/
index 7cf7137731f102bbb7d3f702272861bdaf19b185..210037887791f7319d20f4e48e9ce38b8e7f6883 100644 (file)
@@ -24,7 +24,7 @@
 
 
 #include "linphonecore.h"
-
+#include "private.h"
 #if 0
 static const char *_gstates_text[] = {
   "GSTATE_POWER_OFF",         /* 0 */
index 88e5027518209c051af2693f9e03d6acff39200a..e76f2c2488d583b906e8faff6176ab58269bd4af 100644 (file)
@@ -465,11 +465,12 @@ void sal_op_authenticate(SalOp *h, const SalAuthInfo *info){
                const char *userid;
                if (info->userid==NULL || info->userid[0]=='\0') userid=info->username;
                else userid=info->userid;
-               eXosip_lock();
                eXosip_add_authentication_info (info->username,userid,
                                       info->password, NULL,info->realm);
+               eXosip_lock();
                eXosip_default_action(h->pending_auth);
                eXosip_unlock();
+               eXosip_clear_authentication_info();
                eXosip_event_free(h->pending_auth);
                h->pending_auth=NULL;
        }
index 528e3f3286ea5050c7d986f2a27a1d41a8e22b14..0037fa1d6d7fa9b72a5436454273e1bfdf04e36d 100644 (file)
@@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #endif
 
 #include "linphonecore.h"
+#include "private.h"
 #include <ctype.h>
 
 static void sip_login_init_instance(SipSetupContext *ctx){