Browse Source

JNI code done, now passphrase comes from java level throug callback

JNI-114
heck 2 years ago
parent
commit
095eb8075b
2 changed files with 25 additions and 1 deletions
  1. +4
    -0
      src/foundation/pEp/jniadapter/AbstractEngine.java
  2. +21
    -1
      src/foundation_pEp_jniadapter_AbstractEngine.cc

+ 4
- 0
src/foundation/pEp/jniadapter/AbstractEngine.java View File

@ -186,6 +186,10 @@ abstract class AbstractEngine extends UniquelyIdentifiable implements AutoClosea
return 0;
}
public byte[] passphraseRequiredFromC() {
return toUTF8("passphrase_alice");
}
public int messageToSendCallFromC (Message message) {
System.out.println("pEpSync" + "messageToSendCallFromC: " + messageToSendCallback );
if (messageToSendCallback != null) {


+ 21
- 1
src/foundation_pEp_jniadapter_AbstractEngine.cc View File

@ -26,6 +26,7 @@ jmethodID messageConstructorMethodID = nullptr;
jmethodID messageToSendMethodID = nullptr;
jmethodID notifyHandShakeMethodID = nullptr;
jmethodID needsFastPollMethodID = nullptr;
jmethodID passphraseRequiredMethodID = nullptr;
jmethodID method_values = nullptr;
jobject objj = nullptr;
@ -86,6 +87,10 @@ void jni_init() {
engineClass,
"notifyHandshakeCallFromC",
"(Lfoundation/pEp/jniadapter/_Identity;Lfoundation/pEp/jniadapter/_Identity;Lfoundation/pEp/jniadapter/SyncHandshakeSignal;)I");
passphraseRequiredMethodID = _env->GetMethodID(
engineClass,
"passphraseRequiredFromC",
"()[B");
method_values = JNISync::env()->GetStaticMethodID(signalClass, "values",
"()[Lfoundation/pEp/jniadapter/SyncHandshakeSignal;");
@ -94,7 +99,22 @@ void jni_init() {
char* JNIAdapter::passphraseRequiredCallback() {
pEpLog("called");
return "passphrase_alice";
assert(objj && passphraseRequiredMethodID);
jobject ppJO = JNISync::env()->CallObjectMethod(objj, passphraseRequiredMethodID);
if (JNISync::env()->ExceptionCheck()) {
JNISync::env()->ExceptionDescribe();
JNISync::env()->ExceptionClear();
}
jbyteArray ppJBA = reinterpret_cast<jbyteArray>(ppJO);
char* passphrase_ = to_string( JNISync::env(), ppJBA);
pEpLog("fromJava: " << passphrase_);
JNISync::env()->DeleteLocalRef(ppJO);
return passphrase_;
}
PEP_STATUS messageToSend(message *msg)


Loading…
Cancel
Save