• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 //
3 // Copyright 2020 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 
19 #ifndef GRPC_SRC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_FACTORY_H
20 #define GRPC_SRC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_FACTORY_H
21 
22 #include <grpc/credentials.h>
23 #include <grpc/grpc_security.h>
24 #include <grpc/support/port_platform.h>
25 
26 #include <string>
27 
28 #include "absl/strings/string_view.h"
29 #include "src/core/util/json/json.h"
30 #include "src/core/util/json/json_args.h"
31 #include "src/core/util/ref_counted.h"
32 #include "src/core/util/ref_counted_ptr.h"
33 #include "src/core/util/validation_errors.h"
34 
35 namespace grpc_core {
36 
37 // Factories for plugins. Each plugin implementation should create its own
38 // factory implementation and register an instance with the registry.
39 class CertificateProviderFactory {
40  public:
41   // Interface for configs for CertificateProviders.
42   class Config : public RefCounted<Config> {
43    public:
44     ~Config() override = default;
45 
46     // Name of the type of the CertificateProvider. Unique to each type of
47     // config.
48     virtual absl::string_view name() const = 0;
49 
50     virtual std::string ToString() const = 0;
51   };
52 
53   virtual ~CertificateProviderFactory() = default;
54 
55   // Name of the plugin.
56   virtual absl::string_view name() const = 0;
57 
58   virtual RefCountedPtr<Config> CreateCertificateProviderConfig(
59       const Json& config_json, const JsonArgs& args,
60       ValidationErrors* errors) = 0;
61 
62   // Create a CertificateProvider instance from config.
63   virtual RefCountedPtr<grpc_tls_certificate_provider>
64   CreateCertificateProvider(RefCountedPtr<Config> config) = 0;
65 };
66 
67 }  // namespace grpc_core
68 
69 #endif  // GRPC_SRC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_FACTORY_H
70