16 jmethodID constructor;
17 jmethodID getIdentityMethod;
18 jmethodID verifyMethod;
22 clazz =
jni::getClass(env,
"com/facebook/fizz/JavaCryptoPeerCert");
35 jobject_ = env->NewObject(clazz, constructor, byteArray);
36 env->DeleteLocalRef(byteArray);
46 auto jIdentity = (jstring)env->CallObjectMethod(
jobject_, getIdentityMethod);
47 auto cIdentity = env->GetStringUTFChars(jIdentity, JNI_FALSE );
49 env->ReleaseStringUTFChars(jIdentity, cIdentity);
67 algorithm =
"SHA256withECDSA";
70 throw std::runtime_error(
"Unsupported signature scheme");
72 auto jAlgorithm = env->NewStringUTF(algorithm.c_str());
77 env->CallObjectMethod(
78 jobject_, verifyMethod, jAlgorithm, jSignData, jSignature);
80 env->DeleteLocalRef(jSignature);
81 env->DeleteLocalRef(jSignData);
82 env->DeleteLocalRef(jAlgorithm);
std::unique_ptr< X509, X509Deleter > X509UniquePtr
jclass getClass(JNIEnv *env, const std::string &name)
constexpr detail::Map< Move > move
void maybeThrowException(JNIEnv *env, bool shouldDetach)
void releaseEnv(bool shouldDetach)
JNIEnv * getEnv(bool *shouldDetach)
jmethodID getMethodID(JNIEnv *env, jclass clazz, const std::string &name, const std::string &signature)
void verify(SignatureScheme scheme, CertificateVerifyContext context, folly::ByteRange toBeSigned, folly::ByteRange signature) const override
std::unique_ptr< folly::IOBuf > Buf
JavaCryptoPeerCert(Buf certData)
std::string getIdentity() const override
static Buf prepareSignData(CertificateVerifyContext context, folly::ByteRange toBeSigned)
jbyteArray createByteArray(JNIEnv *env, folly::ByteRange byteRange)
static void onLoad(JNIEnv *env)
folly::ssl::X509UniquePtr getX509() const override