static BOOL android_authenticate(freerdp* instance, char** username, char** password, char** domain) { DEBUG_ANDROID("Authenticate user:"******" Username: %s", *username); DEBUG_ANDROID(" Domain: %s", *domain); JNIEnv* env; jboolean attached = jni_attach_thread(&env); jobject jstr1 = create_string_builder(env, *username); jobject jstr2 = create_string_builder(env, *domain); jobject jstr3 = create_string_builder(env, *password); jboolean res = freerdp_callback_bool_result("OnAuthenticate", "(ILjava/lang/StringBuilder;Ljava/lang/StringBuilder;Ljava/lang/StringBuilder;)Z", instance, jstr1, jstr2, jstr3); if (res == JNI_TRUE) { // read back string values free(*username); *username = get_string_from_string_builder(env, jstr1); free(*domain); *domain = get_string_from_string_builder(env, jstr2); free(*password); *password = get_string_from_string_builder(env, jstr3); } if (attached == JNI_TRUE) jni_detach_thread(); return ((res == JNI_TRUE) ? TRUE : FALSE); }
static BOOL android_authenticate_int(freerdp* instance, char** username, char** password, char** domain, const char* cb_name) { JNIEnv* env; jboolean attached = jni_attach_thread(&env); jobject jstr1 = create_string_builder(env, *username); jobject jstr2 = create_string_builder(env, *domain); jobject jstr3 = create_string_builder(env, *password); jboolean res; res = freerdp_callback_bool_result( cb_name, "(ILjava/lang/StringBuilder;" "Ljava/lang/StringBuilder;" "Ljava/lang/StringBuilder;)Z", instance, jstr1, jstr2, jstr3); if (res == JNI_TRUE) { // read back string values free(*username); *username = get_string_from_string_builder(env, jstr1); free(*domain); *domain = get_string_from_string_builder(env, jstr2); free(*password); *password = get_string_from_string_builder(env, jstr3); } if (attached == JNI_TRUE) jni_detach_thread(); return ((res == JNI_TRUE) ? TRUE : FALSE); }
static BOOL android_verify_certificate(freerdp* instance, char* subject, char* issuer, char* fingerprint) { DEBUG_ANDROID("Certificate details:"); DEBUG_ANDROID("\tSubject: %s", subject); DEBUG_ANDROID("\tIssuer: %s", issuer); DEBUG_ANDROID("\tThumbprint: %s", fingerprint); DEBUG_ANDROID("The above X.509 certificate could not be verified, possibly because you do not have " "the CA certificate in your certificate store, or the certificate has expired." "Please look at the documentation on how to create local certificate store for a private CA.\n"); JNIEnv* env; jboolean attached = jni_attach_thread(&env); jstring jstr1 = (*env)->NewStringUTF(env, subject); jstring jstr2 = (*env)->NewStringUTF(env, issuer); jstring jstr3 = (*env)->NewStringUTF(env, fingerprint); jboolean res = freerdp_callback_bool_result("OnVerifyCertificate", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z", instance, jstr1, jstr2, jstr3); if (attached == JNI_TRUE) jni_detach_thread(); return ((res == JNI_TRUE) ? TRUE : FALSE); }