OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 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, |
| 22 // Certificate domain name doesn't match host name. |
| 23 VERIFY_BAD_HOSTNAME, |
| 24 // Certificate verification was failed. There is no detail error information |
| 25 // given by Android API. |
| 26 VERIFY_NO_TRUSTED_ROOT, |
| 27 // Error occurs when invoke JNI methods. |
| 28 VERIFY_INVOCATION_ERROR, |
| 29 }; |
| 30 |
| 31 // |cert_chain| is DER encoded chain of certificates, with the server's own |
| 32 // certificate listed first. |
| 33 // |hostname| is validated against the supplied cert. |auth_type| is as per |
| 34 // the Java X509Certificate.checkServerTrusted method. |
| 35 |
| 36 VerifyResult VerifyX509CertChain(const std::vector<std::string>& cert_chain, |
| 37 const std::string& hostname, |
| 38 const std::string& auth_type); |
| 39 |
| 40 // Helper for the <keygen> handler. Passes the DER-encoded key pair via |
| 41 // JNI to the Credentials store. |
| 42 bool StoreKeyPair(const uint8* public_key, |
| 43 size_t public_len, |
| 44 const uint8* private_key, |
| 45 size_t private_len); |
| 46 |
| 47 // Get the mime type (if any) that is associated with the file extension. |
| 48 // Returns true if a corresponding mime type exists. |
| 49 bool GetMimeTypeFromExtension(const std::string& extension, |
| 50 std::string* result); |
| 51 |
| 52 // Register JNI methods |
| 53 bool RegisterNetworkLibrary(JNIEnv* env); |
| 54 |
| 55 } // namespace android |
| 56 } // namespace net |
| 57 |
| 58 #endif // NET_ANDROID_NETWORK_LIBRARY_H_ |
OLD | NEW |