1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/android/cert_verify_result_android.h"
6
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h"
9
10 // Must come after all headers that specialize FromJniType() / ToJniType().
11 #include "net/net_jni_headers/AndroidCertVerifyResult_jni.h"
12
13 using base::android::AttachCurrentThread;
14 using base::android::JavaArrayOfByteArrayToStringVector;
15 using base::android::JavaRef;
16 using base::android::ScopedJavaLocalRef;
17
18 namespace net::android {
19
ExtractCertVerifyResult(const JavaRef<jobject> & result,CertVerifyStatusAndroid * status,bool * is_issued_by_known_root,std::vector<std::string> * verified_chain)20 void ExtractCertVerifyResult(const JavaRef<jobject>& result,
21 CertVerifyStatusAndroid* status,
22 bool* is_issued_by_known_root,
23 std::vector<std::string>* verified_chain) {
24 JNIEnv* env = AttachCurrentThread();
25
26 *status = static_cast<CertVerifyStatusAndroid>(
27 Java_AndroidCertVerifyResult_getStatus(env, result));
28
29 *is_issued_by_known_root =
30 Java_AndroidCertVerifyResult_isIssuedByKnownRoot(env, result);
31
32 ScopedJavaLocalRef<jobjectArray> chain_byte_array =
33 Java_AndroidCertVerifyResult_getCertificateChainEncoded(env, result);
34 JavaArrayOfByteArrayToStringVector(env, chain_byte_array, verified_chain);
35 }
36
37 } // namespace net::android
38