blob: 5e2b8ecbfd081f5bfed575d2276edc089bdb91da [file] [log] [blame]
[email protected]b47feba2012-04-24 01:34:411// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]6dbdaa82011-08-11 16:05:562// 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
16namespace net {
17namespace android {
18
19enum VerifyResult {
20 // Certificate verification was successful.
21 VERIFY_OK,
[email protected]6dbdaa82011-08-11 16:05:5622 // 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]b47feba2012-04-24 01:34:4131// |auth_type| is as per the Java X509Certificate.checkServerTrusted method.
[email protected]6dbdaa82011-08-11 16:05:5632
33VerifyResult VerifyX509CertChain(const std::vector<std::string>& cert_chain,
[email protected]6dbdaa82011-08-11 16:05:5634 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.
38bool 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.
45bool GetMimeTypeFromExtension(const std::string& extension,
46 std::string* result);
47
48// Register JNI methods
49bool RegisterNetworkLibrary(JNIEnv* env);
50
51} // namespace android
52} // namespace net
53
54#endif // NET_ANDROID_NETWORK_LIBRARY_H_