OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_ANDROID_NETWORK_LIBRARY_H_ | 5 #ifndef NET_ANDROID_NETWORK_LIBRARY_H_ |
6 #define NET_ANDROID_NETWORK_LIBRARY_H_ | 6 #define NET_ANDROID_NETWORK_LIBRARY_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "net/base/mime_util.h" |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 namespace android { | 17 namespace android { |
17 | 18 |
18 enum VerifyResult { | 19 enum VerifyResult { |
19 // Certificate verification was successful. | 20 // Certificate verification was successful. |
20 VERIFY_OK, | 21 VERIFY_OK, |
21 // Certificate verification was failed. There is no detail error information | 22 // Certificate verification was failed. There is no detail error information |
22 // given by Android API. | 23 // given by Android API. |
23 VERIFY_NO_TRUSTED_ROOT, | 24 VERIFY_NO_TRUSTED_ROOT, |
24 // Error occurs when invoke JNI methods. | 25 // Error occurs when invoke JNI methods. |
25 VERIFY_INVOCATION_ERROR, | 26 VERIFY_INVOCATION_ERROR, |
26 }; | 27 }; |
27 | 28 |
28 // |cert_chain| is DER encoded chain of certificates, with the server's own | 29 // |cert_chain| is DER encoded chain of certificates, with the server's own |
29 // certificate listed first. | 30 // certificate listed first. |
30 // |auth_type| is as per the Java X509Certificate.checkServerTrusted method. | 31 // |auth_type| is as per the Java X509Certificate.checkServerTrusted method. |
31 | 32 |
32 VerifyResult VerifyX509CertChain(const std::vector<std::string>& cert_chain, | 33 VerifyResult VerifyX509CertChain(const std::vector<std::string>& cert_chain, |
33 const std::string& auth_type); | 34 const std::string& auth_type); |
34 | 35 |
35 // Helper for the <keygen> handler. Passes the DER-encoded key pair via | 36 // Helper for the <keygen> handler. Passes the DER-encoded key pair via |
36 // JNI to the Credentials store. | 37 // JNI to the Credentials store. |
37 bool StoreKeyPair(const uint8* public_key, | 38 bool StoreKeyPair(const uint8* public_key, |
38 size_t public_len, | 39 size_t public_len, |
39 const uint8* private_key, | 40 const uint8* private_key, |
40 size_t private_len); | 41 size_t private_len); |
41 | 42 |
| 43 // Helper used to pass the DER-encoded bytes of an X.509 certificate or |
| 44 // a PKCS#12 keychain to the CertInstaller activity. |
| 45 void StoreCertificate(net::CertificateType cert_type, |
| 46 const void* data, |
| 47 size_t data_len); |
| 48 |
42 // Returns true if it can determine that only loopback addresses are configured. | 49 // Returns true if it can determine that only loopback addresses are configured. |
43 // i.e. if only 127.0.0.1 and ::1 are routable. | 50 // i.e. if only 127.0.0.1 and ::1 are routable. |
44 // Also returns false if it cannot determine this. | 51 // Also returns false if it cannot determine this. |
45 bool HaveOnlyLoopbackAddresses(); | 52 bool HaveOnlyLoopbackAddresses(); |
46 | 53 |
47 // Return a string containing a list of network interfaces, each item is a | 54 // Return a string containing a list of network interfaces, each item is a |
48 // network name and address pair. | 55 // network name and address pair. |
49 // e.g. "eth0,10.0.0.2;eth0,fe80::5054:ff:fe12:3456" is a result string | 56 // e.g. "eth0,10.0.0.2;eth0,fe80::5054:ff:fe12:3456" is a result string |
50 // containing two items. | 57 // containing two items. |
51 std::string GetNetworkList(); | 58 std::string GetNetworkList(); |
52 | 59 |
53 // Get the mime type (if any) that is associated with the file extension. | 60 // Get the mime type (if any) that is associated with the file extension. |
54 // Returns true if a corresponding mime type exists. | 61 // Returns true if a corresponding mime type exists. |
55 bool GetMimeTypeFromExtension(const std::string& extension, | 62 bool GetMimeTypeFromExtension(const std::string& extension, |
56 std::string* result); | 63 std::string* result); |
57 | 64 |
58 // Register JNI methods | 65 // Register JNI methods |
59 bool RegisterNetworkLibrary(JNIEnv* env); | 66 bool RegisterNetworkLibrary(JNIEnv* env); |
60 | 67 |
61 } // namespace android | 68 } // namespace android |
62 } // namespace net | 69 } // namespace net |
63 | 70 |
64 #endif // NET_ANDROID_NETWORK_LIBRARY_H_ | 71 #endif // NET_ANDROID_NETWORK_LIBRARY_H_ |
OLD | NEW |