[email protected] | b47feba | 2012-04-24 01:34:41 | [diff] [blame^] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 6dbdaa8 | 2011-08-11 16:05:56 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef NET_ANDROID_NETWORK_LIBRARY_H_ |
| 6 | #define NET_ANDROID_NETWORK_LIBRARY_H_ |
| 7 | #pragma once |
| 8 | |
| 9 | #include <jni.h> |
| 10 | |
| 11 | #include <string> |
| 12 | #include <vector> |
| 13 | |
| 14 | #include "base/basictypes.h" |
| 15 | |
| 16 | namespace net { |
| 17 | namespace android { |
| 18 | |
| 19 | enum VerifyResult { |
| 20 | // Certificate verification was successful. |
| 21 | VERIFY_OK, |
[email protected] | 6dbdaa8 | 2011-08-11 16:05:56 | [diff] [blame] | 22 | // Certificate verification was failed. There is no detail error information |
| 23 | // given by Android API. |
| 24 | VERIFY_NO_TRUSTED_ROOT, |
| 25 | // Error occurs when invoke JNI methods. |
| 26 | VERIFY_INVOCATION_ERROR, |
| 27 | }; |
| 28 | |
| 29 | // |cert_chain| is DER encoded chain of certificates, with the server's own |
| 30 | // certificate listed first. |
[email protected] | b47feba | 2012-04-24 01:34:41 | [diff] [blame^] | 31 | // |auth_type| is as per the Java X509Certificate.checkServerTrusted method. |
[email protected] | 6dbdaa8 | 2011-08-11 16:05:56 | [diff] [blame] | 32 | |
| 33 | VerifyResult VerifyX509CertChain(const std::vector<std::string>& cert_chain, |
[email protected] | 6dbdaa8 | 2011-08-11 16:05:56 | [diff] [blame] | 34 | const std::string& auth_type); |
| 35 | |
| 36 | // Helper for the <keygen> handler. Passes the DER-encoded key pair via |
| 37 | // JNI to the Credentials store. |
| 38 | bool StoreKeyPair(const uint8* public_key, |
| 39 | size_t public_len, |
| 40 | const uint8* private_key, |
| 41 | size_t private_len); |
| 42 | |
| 43 | // Get the mime type (if any) that is associated with the file extension. |
| 44 | // Returns true if a corresponding mime type exists. |
| 45 | bool GetMimeTypeFromExtension(const std::string& extension, |
| 46 | std::string* result); |
| 47 | |
| 48 | // Register JNI methods |
| 49 | bool RegisterNetworkLibrary(JNIEnv* env); |
| 50 | |
| 51 | } // namespace android |
| 52 | } // namespace net |
| 53 | |
| 54 | #endif // NET_ANDROID_NETWORK_LIBRARY_H_ |