forked from pEp.foundation/pEpJNIAdapter
C++ impl of export_key()
parent
46ba24e930
commit
866dc60439
|
@ -48,9 +48,9 @@ ifndef JAVA_HOME
|
|||
endif
|
||||
|
||||
# Guessing USE_JAVAH
|
||||
# cant be guessed earlier, because we depend on JAVA_HOME which can be set in the local.conf
|
||||
# cant be guessed earlier, because it depends on JAVA_HOME which can be set in the local.conf
|
||||
# Old versions of a Java distribution have a `javah` binary, new version do not and the replacement is "javac -h"
|
||||
# TODO: dont check for presence of javah, but check if javac -h is supported, because some java (RHEL) has javah but supports javac -h
|
||||
# TODO: dont check for presence of javah, but check if javac -h is supported, because some java (RHEL) has javah but supports javac -h (and javac -h is preferred)
|
||||
ifndef USE_JAVAH
|
||||
DUMMY:=$(shell which $(JAVA_HOME)/bin/javah)
|
||||
ifeq ($(.SHELLSTATUS),0)
|
||||
|
@ -84,6 +84,7 @@ export YML_PATH=$(YML2_PATH)
|
|||
|
||||
# BEGIN // kryptic hack to to replace a space with a newline
|
||||
# $(subst ${ },${space}, whatever)
|
||||
# maybe not well known: define/endef is custom makefile function definition
|
||||
null :=
|
||||
space := ${null} ${null}
|
||||
${space} := ${space}
|
||||
|
|
|
@ -512,5 +512,32 @@ JNIEXPORT void JNICALL Java_foundation_pEp_jniadapter_Engine__1config_1passphras
|
|||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jbyteArray JNICALL Java_foundation_pEp_jniadapter_Engine__1export_1key (JNIEnv *env,
|
||||
jobject obj,
|
||||
jbyteArray fpr)
|
||||
{
|
||||
std::mutex *mutex_local = nullptr;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> l(global_mutex);
|
||||
pEpLog("called with lock_guard");
|
||||
mutex_local = get_engine_java_object_mutex(env, obj);
|
||||
}
|
||||
std::lock_guard<std::mutex> l(*mutex_local);
|
||||
|
||||
const char *_fpr = to_string(env, fpr);
|
||||
char *buff = nullptr;
|
||||
size_t size = 0;
|
||||
|
||||
PEP_STATUS status = passphraseWrap(::export_key, session(), _fpr, &buff, &size);
|
||||
|
||||
if (status != PEP_STATUS_OK) {
|
||||
throw_pEp_Exception(env, status);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return from_string(env, buff);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
|
Loading…
Reference in New Issue