| // Copyright 2026 Google LLC | |
| // | |
| // Licensed under the Apache License, Version 2.0 (the "License"); | |
| // you may not use this file except in compliance with the License. | |
| // You may obtain a copy of the License at | |
| // | |
| // https://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, | |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| // See the License for the specific language governing permissions and | |
| // limitations under the License. | |
| // | |
| #ifndef THIRD_PARTY_CREDENTIO_TSP_STATUS_CODES_H_ | |
| #define THIRD_PARTY_CREDENTIO_TSP_STATUS_CODES_H_ | |
| #include <cstdint> | |
| #include "absl/log/log.h" | |
| #include "absl/status/statusor.h" | |
| #include "absl/strings/str_cat.h" | |
| namespace credentio { | |
| // The status codes as defined by RFC 3161 section 2.4.2. | |
| enum class TspPkiStatus { | |
| kGranted = 0, | |
| kGrantedWithMods = 1, | |
| kRejection = 2, | |
| kWaiting = 3, | |
| kRevocationWarning = 4, | |
| kRevocationNotification = 5, | |
| }; | |
| template <typename Sink> | |
| inline void AbslStringify(Sink& sink, TspPkiStatus status) { | |
| switch (status) { | |
| case TspPkiStatus::kGranted: | |
| sink.Append("granted"); | |
| return; | |
| case TspPkiStatus::kGrantedWithMods: | |
| sink.Append("grantedWithMods"); | |
| return; | |
| case TspPkiStatus::kRejection: | |
| sink.Append("rejection"); | |
| return; | |
| case TspPkiStatus::kWaiting: | |
| sink.Append("waiting"); | |
| return; | |
| case TspPkiStatus::kRevocationWarning: | |
| sink.Append("revocationWarning"); | |
| return; | |
| case TspPkiStatus::kRevocationNotification: | |
| sink.Append("revocationNotification"); | |
| return; | |
| } | |
| LOG(DFATAL) << "unknown TspPkiStatus enum: " << static_cast<int>(status); | |
| sink.Append( | |
| absl::StrCat("UNKNOWN_TSP_PKI_STATUS_", static_cast<int>(status))); | |
| } | |
| absl::StatusOr<TspPkiStatus> GetTspPkiStatus(int64_t status_code); | |
| // Returns whether `status_code` would be considered successful if received in a | |
| // TimeStampResp. | |
| bool IsTspPkiStatusOk(TspPkiStatus status_code); | |
| } // namespace credentio | |
| #endif // THIRD_PARTY_CREDENTIO_TSP_STATUS_CODES_H_ |