| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <jni.h> | 9 #include <jni.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 namespace android { | 17 namespace android { |
| 18 | 18 |
| 19 enum VerifyResult { | 19 enum VerifyResult { |
| 20 // Certificate verification was successful. | 20 // Certificate verification was successful. |
| 21 VERIFY_OK, | 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 | 22 // Certificate verification was failed. There is no detail error information |
| 25 // given by Android API. | 23 // given by Android API. |
| 26 VERIFY_NO_TRUSTED_ROOT, | 24 VERIFY_NO_TRUSTED_ROOT, |
| 27 // Error occurs when invoke JNI methods. | 25 // Error occurs when invoke JNI methods. |
| 28 VERIFY_INVOCATION_ERROR, | 26 VERIFY_INVOCATION_ERROR, |
| 29 }; | 27 }; |
| 30 | 28 |
| 31 // |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 |
| 32 // certificate listed first. | 30 // certificate listed first. |
| 33 // |hostname| is validated against the supplied cert. |auth_type| is as per | 31 // |auth_type| is as per the Java X509Certificate.checkServerTrusted method. |
| 34 // the Java X509Certificate.checkServerTrusted method. | |
| 35 | 32 |
| 36 VerifyResult VerifyX509CertChain(const std::vector<std::string>& cert_chain, | 33 VerifyResult VerifyX509CertChain(const std::vector<std::string>& cert_chain, |
| 37 const std::string& hostname, | |
| 38 const std::string& auth_type); | 34 const std::string& auth_type); |
| 39 | 35 |
| 40 // 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 |
| 41 // JNI to the Credentials store. | 37 // JNI to the Credentials store. |
| 42 bool StoreKeyPair(const uint8* public_key, | 38 bool StoreKeyPair(const uint8* public_key, |
| 43 size_t public_len, | 39 size_t public_len, |
| 44 const uint8* private_key, | 40 const uint8* private_key, |
| 45 size_t private_len); | 41 size_t private_len); |
| 46 | 42 |
| 47 // Get the mime type (if any) that is associated with the file extension. | 43 // Get the mime type (if any) that is associated with the file extension. |
| 48 // Returns true if a corresponding mime type exists. | 44 // Returns true if a corresponding mime type exists. |
| 49 bool GetMimeTypeFromExtension(const std::string& extension, | 45 bool GetMimeTypeFromExtension(const std::string& extension, |
| 50 std::string* result); | 46 std::string* result); |
| 51 | 47 |
| 52 // Register JNI methods | 48 // Register JNI methods |
| 53 bool RegisterNetworkLibrary(JNIEnv* env); | 49 bool RegisterNetworkLibrary(JNIEnv* env); |
| 54 | 50 |
| 55 } // namespace android | 51 } // namespace android |
| 56 } // namespace net | 52 } // namespace net |
| 57 | 53 |
| 58 #endif // NET_ANDROID_NETWORK_LIBRARY_H_ | 54 #endif // NET_ANDROID_NETWORK_LIBRARY_H_ |
| OLD | NEW |