iam_credentials.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 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 
20 
22 
23 #include <stdlib.h>
24 
25 #include <utility>
26 
27 #include "absl/strings/str_format.h"
28 #include "absl/strings/string_view.h"
29 
30 #include <grpc/support/log.h>
31 
39 
42  grpc_core::ClientMetadataHandle initial_metadata,
44  if (token_.has_value()) {
45  initial_metadata->Append(
47  [](absl::string_view, const grpc_core::Slice&) { abort(); });
48  }
49  initial_metadata->Append(
51  [](absl::string_view, const grpc_core::Slice&) { abort(); });
52  return grpc_core::Immediate(std::move(initial_metadata));
53 }
54 
56  const char* token, const char* authority_selector)
57  : token_(token == nullptr ? absl::optional<grpc_core::Slice>()
58  : grpc_core::Slice::FromCopiedString(token)),
59  authority_selector_(
60  grpc_core::Slice::FromCopiedString(authority_selector)),
61  debug_string_(absl::StrFormat(
62  "GoogleIAMCredentials{Token:%s,AuthoritySelector:%s}",
63  token != nullptr ? "present" : "absent", authority_selector)) {}
64 
66  static grpc_core::UniqueTypeName::Factory kFactory("Iam");
67  return kFactory.Create();
68 }
69 
71  const char* token, const char* authority_selector, void* reserved) {
74  "grpc_iam_credentials_create(token=%s, authority_selector=%s, "
75  "reserved=%p)",
76  3, (token, authority_selector, reserved));
77  GPR_ASSERT(reserved == nullptr);
78  GPR_ASSERT(token != nullptr);
79  GPR_ASSERT(authority_selector != nullptr);
80  return grpc_core::MakeRefCounted<grpc_google_iam_credentials>(
81  token, authority_selector)
82  .release();
83 }
trace.h
grpc_core::UniqueTypeName::Factory::Create
UniqueTypeName Create()
Definition: unique_type_name.h:67
GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY
#define GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY
Definition: src/core/lib/security/credentials/credentials.h:58
grpc_google_iam_credentials::token_
const absl::optional< grpc_core::Slice > token_
Definition: iam_credentials.h:60
grpc_call_credentials::GetRequestMetadataArgs
Definition: src/core/lib/security/credentials/credentials.h:196
grpc_core::Slice::Ref
Slice Ref() const
Definition: src/core/lib/slice/slice.h:368
log.h
metadata_batch.h
grpc_core::MetadataMap::Append
void Append(absl::string_view key, Slice value, MetadataParseErrorFn on_error)
Definition: metadata_batch.h:1156
absl::StrFormat
ABSL_MUST_USE_RESULT std::string StrFormat(const FormatSpec< Args... > &format, const Args &... args)
Definition: abseil-cpp/absl/strings/str_format.h:338
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::Slice
Definition: src/core/lib/slice/slice.h:282
grpc_google_iam_credentials::grpc_google_iam_credentials
grpc_google_iam_credentials(const char *token, const char *authority_selector)
Definition: iam_credentials.cc:55
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
grpc_google_iam_credentials::Type
static grpc_core::UniqueTypeName Type()
Definition: iam_credentials.cc:65
grpc_call_credentials
Definition: src/core/lib/security/credentials/credentials.h:189
grpc_google_iam_credentials::authority_selector_
const grpc_core::Slice authority_selector_
Definition: iam_credentials.h:61
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
absl::optional::has_value
constexpr bool has_value() const noexcept
Definition: abseil-cpp/absl/types/optional.h:461
grpc_core::ExecCtx
Definition: exec_ctx.h:97
promise.h
grpc_core::MetadataHandle< ClientMetadata >
grpc_core::UniqueTypeName
Definition: unique_type_name.h:56
grpc_core::ArenaPromise
Definition: arena_promise.h:152
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition: end2end_binder_transport_test.cc:75
poll.h
iam_credentials.h
grpc_google_iam_credentials::GetRequestMetadata
grpc_core::ArenaPromise< absl::StatusOr< grpc_core::ClientMetadataHandle > > GetRequestMetadata(grpc_core::ClientMetadataHandle initial_metadata, const GetRequestMetadataArgs *args) override
Definition: iam_credentials.cc:41
exec_ctx.h
ref_counted_ptr.h
GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY
#define GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY
Definition: src/core/lib/security/credentials/credentials.h:56
api_trace.h
grpc_google_iam_credentials_create
grpc_call_credentials * grpc_google_iam_credentials_create(const char *token, const char *authority_selector, void *reserved)
Definition: iam_credentials.cc:70
grpc_core::Immediate
promise_detail::Immediate< T > Immediate(T value)
Definition: promise/promise.h:73
absl
Definition: abseil-cpp/absl/algorithm/algorithm.h:31
grpc_core::UniqueTypeName::Factory
Definition: unique_type_name.h:60
GRPC_API_TRACE
#define GRPC_API_TRACE(fmt, nargs, args)
Definition: api_trace.h:48
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:02