diff --git a/console/linphonec.c b/console/linphonec.c
index 37d3c5f78..0de61a36b 100644
--- a/console/linphonec.c
+++ b/console/linphonec.c
@@ -109,7 +109,7 @@ static char **linephonec_readline_completion(const char *text,
#endif
/* These are callback for linphone core */
-static void linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method);
+static void linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm, const char *username, const char *domain);
static void linphonec_display_refer (LinphoneCore * lc, const char *refer_to);
static void linphonec_display_something (LinphoneCore * lc, const char *something);
static void linphonec_display_url (LinphoneCore * lc, const char *something, const char *url);
@@ -249,7 +249,7 @@ linphonec_display_url (LinphoneCore * lc, const char *something, const char *url
* Linphone core callback
*/
static void
-linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method)
+linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm, const char *username, const char *domain)
{
/* no prompt possible when using pipes or tcp mode*/
if (unix_socket){
diff --git a/coreapi/authentication.c b/coreapi/authentication.c
index 4ea91d1cc..ec956f5f1 100644
--- a/coreapi/authentication.c
+++ b/coreapi/authentication.c
@@ -50,10 +50,10 @@ LinphoneAuthInfo *linphone_auth_info_clone(const LinphoneAuthInfo *ai){
if (ai->ha1) obj->ha1 = ms_strdup(ai->ha1);
if (ai->realm) obj->realm = ms_strdup(ai->realm);
if (ai->domain) obj->domain = ms_strdup(ai->domain);
- if (ai->tls_cert) obj->domain = ms_strdup(ai->tls_cert);
- if (ai->tls_key) obj->domain = ms_strdup(ai->tls_key);
- if (ai->tls_cert_path) obj->domain = ms_strdup(ai->tls_cert_path);
- if (ai->tls_key_path) obj->domain = ms_strdup(ai->tls_key_path);
+ if (ai->tls_cert) obj->tls_cert = ms_strdup(ai->tls_cert);
+ if (ai->tls_key) obj->tls_key = ms_strdup(ai->tls_key);
+ if (ai->tls_cert_path) obj->tls_cert_path = ms_strdup(ai->tls_cert_path);
+ if (ai->tls_key_path) obj->tls_key_path = ms_strdup(ai->tls_key_path);
return obj;
}
@@ -402,8 +402,7 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info)
bool_t updating=FALSE;
if (info->ha1==NULL && info->passwd==NULL){
- ms_error("linphone_core_add_auth_info(): info supplied with empty password or ha1.");
- return;
+ ms_warning("linphone_core_add_auth_info(): info supplied with empty password or ha1.");
}
/* find if we are attempting to modify an existing auth info */
ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,info->realm,info->username,info->domain);
diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c
index 10f1a99e7..81ef9242c 100644
--- a/coreapi/callbacks.c
+++ b/coreapi/callbacks.c
@@ -977,9 +977,13 @@ static void auth_failure(SalOp *op, SalAuthInfo* info) {
ai = (LinphoneAuthInfo*)_linphone_core_find_auth_info(lc, info->realm, info->username, info->domain, TRUE);
if (ai){
LinphoneAuthMethod method = info->mode == SalAuthModeHttpDigest ? LinphoneAuthHttpDigest : LinphoneAuthTls;
+ LinphoneAuthInfo *auth_info = linphone_core_create_auth_info(lc, info->username, NULL, NULL, NULL, info->realm, info->domain);
ms_message("%s/%s/%s/%s authentication fails.", info->realm, info->username, info->domain, info->mode == SalAuthModeHttpDigest ? "HttpDigest" : "Tls");
/*ask again for password if auth info was already supplied but apparently not working*/
- linphone_core_notify_auth_info_requested(lc, info->realm, info->username, info->domain, method);
+ linphone_core_notify_authentication_requested(lc, auth_info, method);
+ linphone_auth_info_destroy(auth_info);
+ // Deprecated
+ linphone_core_notify_auth_info_requested(lc, info->realm, info->username, info->domain);
}
}
}
@@ -1238,7 +1242,11 @@ static bool_t auth_requested(Sal* sal, SalAuthInfo* sai) {
return TRUE;
} else {
LinphoneAuthMethod method = sai->mode == SalAuthModeHttpDigest ? LinphoneAuthHttpDigest : LinphoneAuthTls;
- linphone_core_notify_auth_info_requested(lc, sai->realm, sai->username, sai->domain, method);
+ LinphoneAuthInfo *ai = linphone_core_create_auth_info(lc, sai->username, NULL, NULL, NULL, sai->realm, sai->domain);
+ linphone_core_notify_authentication_requested(lc, ai, method);
+ linphone_auth_info_destroy(ai);
+ // Deprecated
+ linphone_core_notify_auth_info_requested(lc, sai->realm, sai->username, sai->domain);
if (fill_auth_info(lc, sai)) {
return TRUE;
}
diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java
index 68a3dea65..16c7cedbc 100644
--- a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java
+++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java
@@ -33,6 +33,7 @@ import org.linphone.core.LinphoneCore.GlobalState;
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
+import org.linphone.core.LinphoneAuthInfo;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener;
@@ -298,10 +299,16 @@ public class TutorialBuddyStatus implements LinphoneCoreListener {
@Override
public void authInfoRequested(LinphoneCore lc, String realm,
- String username, String Domain, LinphoneCore.AuthMethod method) {
+ String username, String domain) {
// TODO Auto-generated method stub
}
+
+ @Override
+ public void authenticationRequested(LinphoneCore lc,
+ LinphoneAuthInfo authInfo, LinphoneCore.AuthMethod method) {
+ // TODO Auto-generated method stub
+ }
@Override
public void fileTransferProgressIndication(LinphoneCore lc,
diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java
index 315821406..d3a21f9ce 100644
--- a/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java
+++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java
@@ -33,6 +33,7 @@ import org.linphone.core.LinphoneCore.GlobalState;
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
+import org.linphone.core.LinphoneAuthInfo;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener;
@@ -77,7 +78,8 @@ public class TutorialChatRoom implements LinphoneCoreListener, LinphoneChatMessa
public void show(LinphoneCore lc) {}
public void byeReceived(LinphoneCore lc, String from) {}
- public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain, LinphoneCore.AuthMethod method) {}
+ public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) {}
+ public void authenticationRequested(LinphoneCore lc, LinphoneAuthInfo authInfo, LinphoneCore.AuthMethod method) {}
public void displayStatus(LinphoneCore lc, String message) {}
public void displayMessage(LinphoneCore lc, String message) {}
public void displayWarning(LinphoneCore lc, String message) {}
diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java
index 4bcaf9451..45b044456 100644
--- a/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java
+++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java
@@ -33,6 +33,7 @@ import org.linphone.core.LinphoneCore.GlobalState;
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
+import org.linphone.core.LinphoneAuthInfo;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener;
@@ -71,7 +72,8 @@ public class TutorialHelloWorld implements LinphoneCoreListener {
public void show(LinphoneCore lc) {}
public void byeReceived(LinphoneCore lc, String from) {}
- public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain, LinphoneCore.AuthMethod method) {}
+ public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) {}
+ public void authenticationRequested(LinphoneCore lc, LinphoneAuthInfo authInfo, LinphoneCore.AuthMethod method) {}
public void displayStatus(LinphoneCore lc, String message) {}
public void displayMessage(LinphoneCore lc, String message) {}
public void displayWarning(LinphoneCore lc, String message) {}
diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java
index 2b1a2d868..d561156cd 100644
--- a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java
+++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java
@@ -33,6 +33,7 @@ import org.linphone.core.LinphoneCore.GlobalState;
import org.linphone.core.LinphoneCore.LogCollectionUploadState;
import org.linphone.core.LinphoneCore.RegistrationState;
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
+import org.linphone.core.LinphoneAuthInfo;
import org.linphone.core.LinphoneCoreException;
import org.linphone.core.LinphoneCoreFactory;
import org.linphone.core.LinphoneCoreListener;
@@ -82,7 +83,8 @@ public class TutorialRegistration implements LinphoneCoreListener {
public void show(LinphoneCore lc) {}
public void byeReceived(LinphoneCore lc, String from) {}
- public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain, LinphoneCore.AuthMethod method) {}
+ public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) {}
+ public void authenticationRequested(LinphoneCore lc, LinphoneAuthInfo authInfo, LinphoneCore.AuthMethod method) {}
public void displayStatus(LinphoneCore lc, String message) {}
public void displayMessage(LinphoneCore lc, String message) {}
public void displayWarning(LinphoneCore lc, String message) {}
diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h
index 6594a6be7..f3e4a2fc9 100644
--- a/coreapi/linphonecore.h
+++ b/coreapi/linphonecore.h
@@ -2025,10 +2025,19 @@ typedef void (*LinphoneCoreNewSubscriptionRequestedCb)(LinphoneCore *lc, Linphon
* @param lc the LinphoneCore
* @param realm the realm (domain) on which authentication is required.
* @param username the username that needs to be authenticated.
+ * @param domain the domain on which authentication is required.
+ * Application shall reply to this callback using linphone_core_add_auth_info().
+ */
+typedef void (*LinphoneCoreAuthInfoRequestedCb)(LinphoneCore *lc, const char *realm, const char *username, const char *domain);
+
+/**
+ * Callback for requesting authentication information to application or user.
+ * @param lc the LinphoneCore
+ * @param auth_info a LinphoneAuthInfo pre-filled with username, realm and domain values as much as possible
* @param method the type of authentication requested
* Application shall reply to this callback using linphone_core_add_auth_info().
*/
-typedef void (*LinphoneCoreAuthInfoRequestedCb)(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method);
+typedef void (*LinphoneCoreAuthenticationRequestedCb)(LinphoneCore *lc, LinphoneAuthInfo *auth_info, LinphoneAuthMethod method);
/**
* Callback to notify a new call-log entry has been added.
@@ -2209,7 +2218,8 @@ typedef struct _LinphoneCoreVTable{
LinphoneCoreNotifyPresenceReceivedCb notify_presence_received; /**< Notify received presence events*/
LinphoneCoreNotifyPresenceReceivedForUriOrTelCb notify_presence_received_for_uri_or_tel; /**< Notify received presence events*/
LinphoneCoreNewSubscriptionRequestedCb new_subscription_requested; /**< Notify about pending presence subscription request */
- LinphoneCoreAuthInfoRequestedCb auth_info_requested; /**< Ask the application some authentication information */
+ LINPHONE_DEPRECATED LinphoneCoreAuthInfoRequestedCb auth_info_requested; /**< @deprecated Use authentication_requested instead. Ask the application some authentication information */
+ LinphoneCoreAuthenticationRequestedCb authentication_requested; /**< Ask the application some authentication information */
LinphoneCoreCallLogUpdatedCb call_log_updated; /**< Notifies that call log list has been updated */
LinphoneCoreMessageReceivedCb message_received; /**< a message is received, can be text or external body*/
LinphoneCoreIsComposingReceivedCb is_composing_received; /**< An is-composing notification has been received */
@@ -2228,7 +2238,7 @@ typedef struct _LinphoneCoreVTable{
LINPHONE_DEPRECATED DisplayMessageCb display_message;/**< @deprecated Callback to display a message to the user */
LINPHONE_DEPRECATED DisplayMessageCb display_warning;/**< @deprecated Callback to display a warning to the user */
LINPHONE_DEPRECATED DisplayUrlCb display_url; /**< @deprecated */
- LINPHONE_DEPRECATED ShowInterfaceCb show; /**< @deprecated Notifies the application that it should show up*/
+ LINPHONE_DEPRECATED ShowInterfaceCb show; /**< vNotifies the application that it should show up*/
LINPHONE_DEPRECATED LinphoneCoreTextMessageReceivedCb text_received; /**< @deprecated, use #message_received instead
A text message has been received */
LINPHONE_DEPRECATED LinphoneCoreFileTransferRecvCb file_transfer_recv; /**< @deprecated Callback to store file received attached to a #LinphoneChatMessage */
LINPHONE_DEPRECATED LinphoneCoreFileTransferSendCb file_transfer_send; /**< @deprecated Callback to collect file chunk to be sent for a #LinphoneChatMessage */
diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc
index edae069f0..be7fea373 100644
--- a/coreapi/linphonecore_jni.cc
+++ b/coreapi/linphonecore_jni.cc
@@ -247,7 +247,8 @@ public:
/*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
- authInfoRequestedId = env->GetMethodID(listenerClass,"authInfoRequested","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/linphone/core/LinphoneCore$AuthMethod;)V");
+ authInfoRequestedId = env->GetMethodID(listenerClass,"authInfoRequested","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
+ authenticationRequestedId = env->GetMethodID(listenerClass,"authenticationRequested","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneAuthInfo;Lorg/linphone/core/LinphoneCore$AuthMethod;)V");
/*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
@@ -287,6 +288,9 @@ public:
chatMessageStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneChatMessage$State"));
chatMessageStateFromIntId = env->GetStaticMethodID(chatMessageStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneChatMessage$State;");
+
+ authInfoClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneAuthInfoImpl"));
+ authInfoCtrId = env->GetMethodID(authInfoClass,"", "(J)V");
proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl"));
proxyCtrId = env->GetMethodID(proxyClass,"", "(Lorg/linphone/core/LinphoneCoreImpl;J)V");
@@ -359,6 +363,7 @@ public:
env->DeleteGlobalRef(registrationStateClass);
env->DeleteGlobalRef(callStateClass);
env->DeleteGlobalRef(chatMessageStateClass);
+ env->DeleteGlobalRef(authInfoClass);
env->DeleteGlobalRef(proxyClass);
env->DeleteGlobalRef(callClass);
env->DeleteGlobalRef(chatMessageClass);
@@ -391,6 +396,7 @@ public:
jmethodID infoReceivedId;
jmethodID subscriptionStateId;
jmethodID authInfoRequestedId;
+ jmethodID authenticationRequestedId;
jmethodID publishStateId;
jmethodID notifyRecvId;
@@ -426,6 +432,9 @@ public:
jclass ecCalibratorStatusClass;
jmethodID ecCalibrationStatusId;
jmethodID ecCalibratorStatusFromIntId;
+
+ jclass authInfoClass;
+ jmethodID authInfoCtrId;
jclass proxyClass;
jmethodID proxyCtrId;
@@ -517,6 +526,16 @@ jobject getProxy(JNIEnv *env, LinphoneProxyConfig *proxy, jobject core){
return jobj;
}
+jobject getAuthInfo(JNIEnv *env, LinphoneCore *lc, LinphoneAuthInfo *authInfo, jobject core){
+ jobject jobj = 0;
+
+ if (authInfo && lc) {
+ LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
+ jobj = env->NewObject(ljb->authInfoClass, ljb->authInfoCtrId, core, (jlong)authInfo);
+ }
+ return jobj;
+}
+
jobject getCall(JNIEnv *env, LinphoneCall *call){
jobject jobj=0;
@@ -770,6 +789,10 @@ public:
if (ljb->authInfoRequestedId) {
vTable->auth_info_requested = authInfoRequested;
}
+
+ if (ljb->authenticationRequestedId) {
+ vTable->authentication_requested = authenticationRequested;
+ }
if (ljb->notifyPresenceReceivedId) {
vTable->notify_presence_received = notify_presence_received;
@@ -864,7 +887,7 @@ public:
env->DeleteLocalRef(msg);
}
}
- static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method) {
+ static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
JNIEnv *env = 0;
jint result = jvm->AttachCurrentThread(&env,NULL);
if (result != 0) {
@@ -883,8 +906,7 @@ public:
lcData->core,
r,
u,
- d,
- env->CallStaticObjectMethod(ljb->authMethodClass,ljb->authMethodFromIntId,(jint)method)
+ d
);
handle_possible_java_exception(env, lcData->listener);
if (r) {
@@ -897,6 +919,25 @@ public:
env->DeleteLocalRef(d);
}
}
+ static void authenticationRequested(LinphoneCore *lc, LinphoneAuthInfo *auth_info, LinphoneAuthMethod method) {
+ JNIEnv *env = 0;
+ jint result = jvm->AttachCurrentThread(&env,NULL);
+ if (result != 0) {
+ ms_error("cannot attach VM");
+ return;
+ }
+
+ LinphoneJavaBindings *ljb = (LinphoneJavaBindings *)linphone_core_get_user_data(lc);
+ LinphoneCoreVTable *table = linphone_core_get_current_vtable(lc);
+ LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_v_table_get_user_data(table);
+ env->CallVoidMethod(lcData->listener,
+ ljb->authenticationRequestedId,
+ lcData->core,
+ getAuthInfo(env, lc, auth_info, lcData->core),
+ env->CallStaticObjectMethod(ljb->authMethodClass,ljb->authMethodFromIntId,(jint)method)
+ );
+ handle_possible_java_exception(env, lcData->listener);
+ }
static void setCoreIfNotDone(JNIEnv *env, jobject jcore, LinphoneCore *lc){
jclass objClass = env->GetObjectClass(jcore);
jfieldID myFieldID = env->GetFieldID(objClass, "nativePtr", "J");
diff --git a/coreapi/private.h b/coreapi/private.h
index 72d814d38..208b8b980 100644
--- a/coreapi/private.h
+++ b/coreapi/private.h
@@ -1501,7 +1501,8 @@ void linphone_core_notify_display_url(LinphoneCore *lc, const char *message, con
void linphone_core_notify_notify_presence_received(LinphoneCore *lc, LinphoneFriend * lf);
void linphone_core_notify_notify_presence_received_for_uri_or_tel(LinphoneCore *lc, LinphoneFriend *lf, const char *uri_or_tel, const LinphonePresenceModel *presence_model);
void linphone_core_notify_new_subscription_requested(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
-void linphone_core_notify_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method);
+void linphone_core_notify_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain);
+void linphone_core_notify_authentication_requested(LinphoneCore *lc, LinphoneAuthInfo *auth_info, LinphoneAuthMethod method);
void linphone_core_notify_call_log_updated(LinphoneCore *lc, LinphoneCallLog *newcl);
void linphone_core_notify_text_message_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message);
void linphone_core_notify_message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message);
diff --git a/coreapi/vtables.c b/coreapi/vtables.c
index dc14ff48a..93f9861cc 100644
--- a/coreapi/vtables.c
+++ b/coreapi/vtables.c
@@ -143,8 +143,13 @@ void linphone_core_notify_new_subscription_requested(LinphoneCore *lc, LinphoneF
cleanup_dead_vtable_refs(lc);
}
-void linphone_core_notify_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method) {
- NOTIFY_IF_EXIST(auth_info_requested, lc, realm, username, domain, method);
+void linphone_core_notify_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
+ NOTIFY_IF_EXIST(auth_info_requested, lc, realm, username, domain);
+ cleanup_dead_vtable_refs(lc);
+}
+
+void linphone_core_notify_authentication_requested(LinphoneCore *lc, LinphoneAuthInfo *ai, LinphoneAuthMethod method) {
+ NOTIFY_IF_EXIST(authentication_requested, lc, ai, method);
cleanup_dead_vtable_refs(lc);
}
diff --git a/gtk/main.c b/gtk/main.c
index 06d2f71ff..b690d8bdf 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -68,7 +68,7 @@ static void linphone_gtk_global_state_changed(LinphoneCore *lc, LinphoneGlobalSt
static void linphone_gtk_registration_state_changed(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState rs, const char *msg);
static void linphone_gtk_notify_recv(LinphoneCore *lc, LinphoneFriend * fid);
static void linphone_gtk_new_unknown_subscriber(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
-static void linphone_gtk_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method);
+static void linphone_gtk_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain);
static void linphone_gtk_configuring_status(LinphoneCore *lc, LinphoneConfiguringState status, const char *message);
static void linphone_gtk_call_log_updated(LinphoneCore *lc, LinphoneCallLog *cl);
static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cs, const char *msg);
@@ -1135,7 +1135,7 @@ void linphone_gtk_password_ok(GtkWidget *w){
gtk_widget_destroy(window);
}
-static void linphone_gtk_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method){
+static void linphone_gtk_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain){
GtkWidget *w=linphone_gtk_create_window("password", the_ui);
GtkWidget *label=linphone_gtk_get_widget(w,"message");
LinphoneAuthInfo *info;
diff --git a/java/common/org/linphone/core/LinphoneCoreListener.java b/java/common/org/linphone/core/LinphoneCoreListener.java
index 550aeefdb..bea8238af 100644
--- a/java/common/org/linphone/core/LinphoneCoreListener.java
+++ b/java/common/org/linphone/core/LinphoneCoreListener.java
@@ -27,9 +27,19 @@ import java.nio.ByteBuffer;
*/
public interface LinphoneCoreListener {
- /**< Ask the application some authentication information
- * @return */
- void authInfoRequested(LinphoneCore lc, String realm, String username, String Domain, LinphoneCore.AuthMethod method);
+ /**
+ * @deprecated
+ * Ask the application some authentication information
+ **/
+ void authInfoRequested(LinphoneCore lc, String realm, String username, String domain);
+
+ /**
+ * Ask the application some authentication information
+ * @param lc the LinphoneCore
+ * @param authInfo a LinphoneAuthInfo pre-filled with username, realm and domain values as much as possible
+ * @param method the type of authentication requested (HttpDigest, Tls, ...)
+ **/
+ void authenticationRequested(LinphoneCore lc, LinphoneAuthInfo authInfo, LinphoneCore.AuthMethod method);
/**
* Call stats notification
diff --git a/java/common/org/linphone/core/LinphoneCoreListenerBase.java b/java/common/org/linphone/core/LinphoneCoreListenerBase.java
index 7cce6f56b..7ccc81621 100644
--- a/java/common/org/linphone/core/LinphoneCoreListenerBase.java
+++ b/java/common/org/linphone/core/LinphoneCoreListenerBase.java
@@ -13,10 +13,16 @@ public class LinphoneCoreListenerBase implements LinphoneCoreListener {
@Override
public void authInfoRequested(LinphoneCore lc, String realm,
- String username, String Domain, LinphoneCore.AuthMethod method) {
+ String username, String domain) {
// TODO Auto-generated method stub
}
+
+ @Override
+ public void authenticationRequested(LinphoneCore lc,
+ LinphoneAuthInfo authInfo, LinphoneCore.AuthMethod method) {
+ // TODO Auto-generated method stub
+ }
@Override
public void callStatsUpdated(LinphoneCore lc, LinphoneCall call,
diff --git a/tester/accountmanager.c b/tester/accountmanager.c
index cfda89562..fe56707ae 100644
--- a/tester/accountmanager.c
+++ b/tester/accountmanager.c
@@ -117,7 +117,7 @@ static void account_created_on_server_cb(LinphoneCore *lc, LinphoneProxyConfig *
// TEMPORARY CODE: remove function below when flexisip is updated, this is not needed anymore!
// The new flexisip now answer "200 Test account created" when creating a test account, and do not
// challenge authentication anymore! so this code is not used for newer version
-static void account_created_auth_requested_cb(LinphoneCore *lc, const char *username, const char *realm, const char *domain, LinphoneAuthMethod method){
+static void account_created_auth_requested_cb(LinphoneCore *lc, const char *username, const char *realm, const char *domain){
Account *account=(Account*)linphone_core_get_user_data(lc);
account->created=1;
}
diff --git a/tester/message_tester.c b/tester/message_tester.c
index 1915cd577..39878951c 100644
--- a/tester/message_tester.c
+++ b/tester/message_tester.c
@@ -277,7 +277,7 @@ static void text_message_within_call_dialog(void) {
}
static LinphoneAuthInfo* text_message_with_credential_from_auth_cb_auth_info;
-static void text_message_with_credential_from_auth_cb_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method) {
+static void text_message_with_credential_from_auth_cb_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
ms_message("text_message_with_credential_from_auth_callback:Auth info requested for user id [%s] at realm [%s]\n"
,username
,realm);
diff --git a/tester/register_tester.c b/tester/register_tester.c
index 5f0349b09..d5cd8b725 100644
--- a/tester/register_tester.c
+++ b/tester/register_tester.c
@@ -22,26 +22,28 @@
#include "liblinphone_tester.h"
-
-static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method) {
+static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
LinphoneAuthInfo *info;
- info=linphone_auth_info_new(test_username,NULL,test_password,NULL,realm,domain); /*create authentication structure from identity*/
- linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
+ info=linphone_auth_info_new(test_username,NULL,test_password,NULL,realm,domain);
+ linphone_core_add_auth_info(lc,info);
}
-
+static void authentication_requested(LinphoneCore *lc, LinphoneAuthInfo *auth_info, LinphoneAuthMethod method) {
+ linphone_auth_info_set_passwd(auth_info, test_password);
+ linphone_core_add_auth_info(lc, auth_info); /*add authentication info to LinphoneCore*/
+}
static LinphoneCoreManager* create_lcm_with_auth(unsigned int with_auth) {
- LinphoneCoreManager* lcm=linphone_core_manager_new(NULL);
+ LinphoneCoreManager* lcm = linphone_core_manager_new(NULL);
if (with_auth) {
LinphoneCoreVTable* vtable = linphone_core_v_table_new();
- vtable->auth_info_requested=auth_info_requested;
- linphone_core_add_listener(lcm->lc,vtable);
+ vtable->authentication_requested = authentication_requested;
+ linphone_core_add_listener(lcm->lc, vtable);
}
/*to allow testing with 127.0.0.1*/
- linphone_core_set_network_reachable(lcm->lc,TRUE);
+ linphone_core_set_network_reachable(lcm->lc, TRUE);
return lcm;
}
@@ -1024,6 +1026,70 @@ static void tls_auth_info_client_cert_api_path(void) {
}
}
+static void authentication_requested_2(LinphoneCore *lc, LinphoneAuthInfo *auth_info, LinphoneAuthMethod method) {
+ char *cert = bc_tester_res("certificates/client/cert.pem");
+ char *key = bc_tester_res("certificates/client/key.pem");
+ BC_ASSERT_EQUAL(method, LinphoneAuthTls, int, "%i");
+ linphone_auth_info_set_tls_cert_path(auth_info, cert);
+ linphone_auth_info_set_tls_key_path(auth_info, key);
+ linphone_core_add_auth_info(lc, auth_info);
+ ms_free(cert);
+ ms_free(key);
+}
+
+static void tls_auth_info_client_cert_cb(void) {
+ if (transport_supported(LinphoneTransportTls)) {
+ LinphoneCoreManager *lcm;
+ LinphoneCoreVTable* vtable = linphone_core_v_table_new();
+ stats* counters;
+
+ lcm = linphone_core_manager_new(NULL);
+
+ vtable->authentication_requested=authentication_requested_2;
+ linphone_core_add_listener(lcm->lc,vtable);
+
+ counters= get_stats(lcm->lc);
+ counters->number_of_auth_info_requested=0;
+ register_with_refresh(lcm,FALSE,auth_domain,"sip2.linphone.org:5063;transport=tls");
+ BC_ASSERT_EQUAL(counters->number_of_auth_info_requested,1, int, "%d");
+ linphone_core_manager_destroy(lcm);
+ }
+}
+
+static void authentication_requested_3(LinphoneCore *lc, LinphoneAuthInfo *auth_info, LinphoneAuthMethod method) {
+ char *cert_path = bc_tester_res("certificates/client/cert.pem");
+ char *key_path = bc_tester_res("certificates/client/key.pem");
+ char *cert = read_file(cert_path);
+ char *key = read_file(key_path);
+ BC_ASSERT_EQUAL(method, LinphoneAuthTls, int, "%i");
+ linphone_auth_info_set_tls_cert(auth_info, cert);
+ linphone_auth_info_set_tls_key(auth_info, key);
+ linphone_core_add_auth_info(lc, auth_info);
+ ms_free(cert);
+ ms_free(key);
+ ms_free(cert_path);
+ ms_free(key_path);
+}
+
+static void tls_auth_info_client_cert_cb_2(void) {
+ if (transport_supported(LinphoneTransportTls)) {
+ LinphoneCoreManager *lcm;
+ LinphoneCoreVTable* vtable = linphone_core_v_table_new();
+ stats* counters;
+
+ lcm = linphone_core_manager_new(NULL);
+
+ vtable->authentication_requested=authentication_requested_3;
+ linphone_core_add_listener(lcm->lc,vtable);
+
+ counters= get_stats(lcm->lc);
+ counters->number_of_auth_info_requested=0;
+ register_with_refresh(lcm,FALSE,auth_domain,"sip2.linphone.org:5063;transport=tls");
+ BC_ASSERT_EQUAL(counters->number_of_auth_info_requested,1, int, "%d");
+ linphone_core_manager_destroy(lcm);
+ }
+}
+
test_t register_tests[] = {
TEST_NO_TAG("Simple register", simple_register),
TEST_NO_TAG("Simple register unregister", simple_unregister),
@@ -1065,6 +1131,8 @@ test_t register_tests[] = {
TEST_NO_TAG("Global TLS client certificate authentication using API 2", tls_auth_global_client_cert_api_path),
TEST_NO_TAG("AuthInfo TLS client certificate authentication using API", tls_auth_info_client_cert_api),
TEST_NO_TAG("AuthInfo TLS client certificate authentication using API 2", tls_auth_info_client_cert_api_path),
+ TEST_NO_TAG("AuthInfo TLS client certificate authentication in callback", tls_auth_info_client_cert_cb),
+ TEST_NO_TAG("AuthInfo TLS client certificate authentication in callback 2", tls_auth_info_client_cert_cb_2),
};
test_suite_t register_test_suite = {"Register", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,
diff --git a/tester/tester.c b/tester/tester.c
index 1339cc91a..e284e42eb 100644
--- a/tester/tester.c
+++ b/tester/tester.c
@@ -98,7 +98,7 @@ LinphoneAddress * create_linphone_address(const char * domain) {
return addr;
}
-static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method) {
+static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
stats* counters;
ms_message("Auth info requested for user id [%s] at realm [%s]\n"
,username
diff --git a/tools/lpsendmsg.c b/tools/lpsendmsg.c
index 16c506b6e..a1ae45bdc 100644
--- a/tools/lpsendmsg.c
+++ b/tools/lpsendmsg.c
@@ -68,7 +68,7 @@ static void on_msg_state_changed(LinphoneChatMessage *msg, LinphoneChatMessageSt
}
}
-static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method){
+static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain){
running = FALSE;
if (passwd){
fprintf(stderr, "Server rejected the supplied username or password\n");