diff --git a/src/basic_api.cc b/src/basic_api.cc index ff3be92..50781b4 100644 --- a/src/basic_api.cc +++ b/src/basic_api.cc @@ -497,5 +497,34 @@ JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_Engine__1config_1passphras } } + +JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_Engine__1config_1passphrase_1for_1new_1keys( + JNIEnv *env, + jobject obj, + jboolean enable, + jbyteArray passphrase + ) +{ + std::mutex *mutex_local = nullptr; + { + std::lock_guard l(global_mutex); + pEpLog("called with lock_guard"); + mutex_local = get_engine_java_object_mutex(env, obj); + } + std::lock_guard l(*mutex_local); + + bool _enable = (bool) enable; + const char *_passphrase = to_string(env, passphrase); + + PEP_STATUS status = ::config_passphrase_for_new_keys(session(),_enable,cache.add_stored(_passphrase)); + if ((status > PEP_STATUS_OK && status < PEP_UNENCRYPTED) || + status < PEP_STATUS_OK || + status >= PEP_TRUSTWORD_NOT_FOUND) { + throw_pEp_Exception(env, status); + return ; + } + +} + } // extern "C" diff --git a/src/pEp.yml2 b/src/pEp.yml2 index dfa6cbe..ca00095 100644 --- a/src/pEp.yml2 +++ b/src/pEp.yml2 @@ -241,10 +241,6 @@ namespace pEp { in CipherSuite suite ); - method config_passphrase_for_new_keys( - in bool enable, - in string passphrase - ); // "basic" methods are generated on the java side, but // on the C++ side, manually implemented in basic_api.cc @@ -267,6 +263,7 @@ namespace pEp { basic string getUserDirectory(); basic string getMachineDirectory(); basic void config_passphrase(string passphrase); + basic void config_passphrase_for_new_keys(bool enable, string passphrase); }; struct message {