Home | History | Annotate | Download | only in base
      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_BASE_ANDROID_NETWORK_LIBRARY_H_
      6 #define NET_BASE_ANDROID_NETWORK_LIBRARY_H_
      7 #pragma once
      8 
      9 #include <string>
     10 #include <vector>
     11 
     12 #include "base/basictypes.h"
     13 
     14 namespace net {
     15 
     16 class AndroidNetworkLibrary {
     17  public:
     18   static void RegisterSharedInstance(AndroidNetworkLibrary* lib);
     19   static void UnregisterSharedInstance();
     20   static AndroidNetworkLibrary* GetSharedInstance();
     21 
     22   enum VerifyResult {
     23     VERIFY_OK,
     24     VERIFY_BAD_HOSTNAME,
     25     VERIFY_NO_TRUSTED_ROOT,
     26     VERIFY_INVOCATION_ERROR,
     27   };
     28   // |cert_chain| is DER encoded chain of certificates, with the server's own
     29   // certificate listed first.
     30   // |hostname| is validated against the supplied cert. |auth_type| is as per
     31   // the Java X509Certificate.checkServerTrusted method.
     32   virtual VerifyResult VerifyX509CertChain(
     33       const std::vector<std::string>& cert_chain,
     34       const std::string& hostname,
     35       const std::string& auth_type) = 0;
     36 
     37  protected:
     38   friend class LibHolder;
     39   AndroidNetworkLibrary();
     40   virtual ~AndroidNetworkLibrary();  // use UnregisterSharedInstance()
     41 
     42   DISALLOW_COPY_AND_ASSIGN(AndroidNetworkLibrary);
     43 };
     44 
     45 }  // namespace net
     46 
     47 #endif  // NET_BASE_ANDROID_NETWORK_LIBRARY_H_
     48