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/support/port_platform.h> 23 24 #include <string> 25 26 #include "absl/strings/string_view.h" 27 28 #include <grpc/grpc_security.h> 29 30 #include "src/core/lib/gprpp/ref_counted.h" 31 #include "src/core/lib/gprpp/ref_counted_ptr.h" 32 #include "src/core/lib/gprpp/validation_errors.h" 33 #include "src/core/lib/json/json.h" 34 #include "src/core/lib/json/json_args.h" 35 36 namespace grpc_core { 37 38 // Factories for plugins. Each plugin implementation should create its own 39 // factory implementation and register an instance with the registry. 40 class CertificateProviderFactory { 41 public: 42 // Interface for configs for CertificateProviders. 43 class Config : public RefCounted<Config> { 44 public: 45 ~Config() override = default; 46 47 // Name of the type of the CertificateProvider. Unique to each type of 48 // config. 49 virtual absl::string_view name() const = 0; 50 51 virtual std::string ToString() const = 0; 52 }; 53 54 virtual ~CertificateProviderFactory() = default; 55 56 // Name of the plugin. 57 virtual absl::string_view name() const = 0; 58 59 virtual RefCountedPtr<Config> CreateCertificateProviderConfig( 60 const Json& config_json, const JsonArgs& args, 61 ValidationErrors* errors) = 0; 62 63 // Create a CertificateProvider instance from config. 64 virtual RefCountedPtr<grpc_tls_certificate_provider> 65 CreateCertificateProvider(RefCountedPtr<Config> config) = 0; 66 }; 67 68 } // namespace grpc_core 69 70 #endif // GRPC_SRC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_FACTORY_H 71