|
|
@ -17,6 +17,8 @@ tstylesheet { |
|
|
|
|| |
|
|
|
#include <cassert> |
|
|
|
#include <pEp/mime.h> |
|
|
|
#include <pEp/map_asn1.h> |
|
|
|
#include <pEp/message_codec.h> |
|
|
|
#include <pEp/pEpLog.hh> |
|
|
|
#include "jniutils.hh" |
|
|
|
#include "throw_pEp_exception.hh" |
|
|
@ -113,6 +115,60 @@ tstylesheet { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
JNIEXPORT jbyteArray JNICALL Java_foundation_pEp_jniadapter_Message__1encodeASN1XER(JNIEnv *env, jobject obj) |
|
|
|
{ |
|
|
|
pEpLog("called"); |
|
|
|
message* _obj = nullptr; |
|
|
|
try { |
|
|
|
_obj = message_ptr(env, obj); |
|
|
|
} catch(...) { |
|
|
|
jclass ex = env->FindClass("java/lang/IllegalStateException"); |
|
|
|
assert(ex); |
|
|
|
env->ThrowNew(ex, nullptr); |
|
|
|
return static_cast<jbyteArray>(NULL); |
|
|
|
} |
|
|
|
|
|
|
|
// create ASN1Message |
|
|
|
ASN1Message_t *pm = ::ASN1Message_from_message(_obj, NULL, true, 0); |
|
|
|
if (pm == nullptr) { |
|
|
|
jclass ex = env->FindClass("java/lang/IllegalStateException"); |
|
|
|
assert(ex); |
|
|
|
env->ThrowNew(ex, nullptr); |
|
|
|
return static_cast<jbyteArray>(NULL); |
|
|
|
} |
|
|
|
|
|
|
|
// encode PER |
|
|
|
char *data_per = nullptr; |
|
|
|
size_t data_size_per = 0; |
|
|
|
PEP_STATUS status = ::encode_ASN1Message_message(pm, &data_per, &data_size_per); |
|
|
|
if (status) { |
|
|
|
throw_pEp_Exception(env, status); |
|
|
|
} |
|
|
|
if (data_per == nullptr) { |
|
|
|
jclass ex = env->FindClass("java/lang/IllegalStateException"); |
|
|
|
assert(ex); |
|
|
|
env->ThrowNew(ex, nullptr); |
|
|
|
return static_cast<jbyteArray>(NULL); |
|
|
|
} |
|
|
|
|
|
|
|
// encode PER to XER |
|
|
|
char *data_xer = nullptr; |
|
|
|
status = ::PER_to_XER_ASN1Message_msg(data_per, data_size_per, &data_xer); |
|
|
|
if (status) { |
|
|
|
throw_pEp_Exception(env, status); |
|
|
|
} |
|
|
|
if (data_xer == nullptr) { |
|
|
|
jclass ex = env->FindClass("java/lang/IllegalStateException"); |
|
|
|
assert(ex); |
|
|
|
env->ThrowNew(ex, nullptr); |
|
|
|
return static_cast<jbyteArray>(NULL); |
|
|
|
} |
|
|
|
|
|
|
|
jbyteArray result = from_string(env, data_xer); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|| |
|
|
|
apply "*[name(.)!='enum']", 0, mode=entry { |
|
|
|
with "name", "@name"; |
|
|
|