• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H
16 #define GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H
17 
18 #include <grpc/support/port_platform.h>
19 
20 #include <memory>
21 
22 #include "src/core/lib/security/authorization/mock_cel/evaluator_core.h"
23 
24 namespace grpc_core {
25 namespace mock_cel {
26 
27 // This is a temporary stub implementation of CEL APIs.
28 // Once gRPC imports the CEL library, this file will be removed.
29 
30 // CelExpressionBuilder implementation.
31 // Builds instances of CelExpressionFlatImpl.
32 class FlatExprBuilder : public CelExpressionBuilder {
33  public:
34   FlatExprBuilder() = default;
35 
CreateExpression(const google_api_expr_v1alpha1_Expr * expr,const google_api_expr_v1alpha1_SourceInfo * source_info)36   absl::StatusOr<std::unique_ptr<CelExpression>> CreateExpression(
37       const google_api_expr_v1alpha1_Expr* expr,
38       const google_api_expr_v1alpha1_SourceInfo* source_info) const override {
39     ExecutionPath path;
40     return absl::make_unique<CelExpressionFlatImpl>(nullptr, path, 0,
41                                                     std::set<std::string>{});
42   }
43 
CreateExpression(const google_api_expr_v1alpha1_Expr * expr,const google_api_expr_v1alpha1_SourceInfo * source_info,std::vector<absl::Status> * warnings)44   absl::StatusOr<std::unique_ptr<CelExpression>> CreateExpression(
45       const google_api_expr_v1alpha1_Expr* expr,
46       const google_api_expr_v1alpha1_SourceInfo* source_info,
47       std::vector<absl::Status>* warnings) const override {
48     ExecutionPath path;
49     return absl::make_unique<CelExpressionFlatImpl>(nullptr, path, 0,
50                                                     std::set<std::string>{});
51   }
52 };
53 
54 }  // namespace mock_cel
55 }  // namespace grpc_core
56 
57 #endif  // GRPC_CORE_LIB_SECURITY_AUTHORIZATION_MOCK_CEL_FLAT_EXPR_BUILDER_H
58