|
|
@ -14,10 +14,12 @@ tstylesheet { |
|
|
|
#include <pEp/key_reset.h> |
|
|
|
#include <pEp/Adapter.hh> |
|
|
|
#include <pEp/pEpLog.hh> |
|
|
|
#include <pEp/passphrase_cache.hh> |
|
|
|
|
|
|
|
#include "foundation_pEp_jniadapter_«@name».h" |
|
|
|
#include "throw_pEp_exception.hh" |
|
|
|
#include "jniutils.hh" |
|
|
|
#include <pEp/passphrase_cache.hh> |
|
|
|
#include "passphrase_callback.hh" |
|
|
|
|
|
|
|
using pEp::Adapter::session; |
|
|
|
using pEp::passphrase_cache; |
|
|
@ -69,29 +71,32 @@ tstylesheet { |
|
|
|
when "@cached = 'true'" { |
|
|
|
|| |
|
|
|
pEpLog("cached passphrase mode"); |
|
|
|
bool retryAfterCallback = false; |
|
|
|
bool retryAgain = false; |
|
|
|
int maxRetries = 3; |
|
|
|
int retryCount = 0; |
|
|
|
PEP_STATUS status; |
|
|
|
do { |
|
|
|
// the actual target function |
|
|
|
pEpLog("calling passphrase_cache.api(::«@name»())"); |
|
|
|
status = passphrase_cache.api(::«@name»,session()`apply "parm", mode=call`); |
|
|
|
|
|
|
|
if(status == PEP_PASSPHRASE_REQUIRED || PEP_WRONG_PASSPHRASE ) { |
|
|
|
pEpLog("PassReq OR Wrong"); |
|
|
|
// call the app |
|
|
|
const char * _passphrase = "passphrase_alice"; |
|
|
|
PEP_STATUS status = ::config_passphrase(session(),passphrase_cache.add(_passphrase)); |
|
|
|
retryCount++; |
|
|
|
if(retryCount > maxRetries) { |
|
|
|
retryAfterCallback = false; |
|
|
|
pEpLog("PEP_STATUS:" << status); |
|
|
|
if(status == PEP_PASSPHRASE_REQUIRED || status == PEP_WRONG_PASSPHRASE ) { |
|
|
|
pEpLog("none of the cached passphrases worked"); |
|
|
|
if(retryCount < maxRetries) { |
|
|
|
// call the app |
|
|
|
char* _passphrase = passphraseRequiredCallback(); |
|
|
|
pEpLog("callback returned, config_passphrase() with new passphrase"); |
|
|
|
PEP_STATUS status = ::config_passphrase(session(),passphrase_cache.add(_passphrase)); |
|
|
|
retryAgain = true; |
|
|
|
retryCount++; |
|
|
|
} else { |
|
|
|
retryAfterCallback = true; |
|
|
|
pEpLog("max retries reached:" << maxRetries); |
|
|
|
retryAgain = false; |
|
|
|
} |
|
|
|
} else { |
|
|
|
retryAfterCallback = false; |
|
|
|
retryAgain = false; |
|
|
|
} |
|
|
|
} while (retryAfterCallback); |
|
|
|
} while (retryAgain); |
|
|
|
|
|
|
|
|| |
|
|
|
} otherwise { |
|
|
|