| 754 | } |
| 755 | |
| 756 | arrow::Status |
| 757 | IsValid(const arrow::flight::ServerCallContext &context, |
| 758 | const std::string &token, |
| 759 | std::string *peer_identity) override |
| 760 | { |
| 761 | auto klass = GAFLIGHT_SERVER_CUSTOM_AUTH_HANDLER_GET_CLASS(handler_); |
| 762 | auto gacontext = gaflight_server_call_context_new_raw(&context); |
| 763 | auto gtoken = g_bytes_new_static(token.data(), token.size()); |
| 764 | GError *error = nullptr; |
| 765 | auto gpeer_identity = klass->is_valid(handler_, gacontext, gtoken, &error); |
| 766 | g_bytes_unref(gtoken); |
| 767 | g_object_unref(gacontext); |
| 768 | if (gpeer_identity) { |
| 769 | gsize gpeer_identity_size; |
| 770 | auto gpeer_identity_data = g_bytes_get_data(gpeer_identity, &gpeer_identity_size); |
| 771 | *peer_identity = std::string(static_cast<const char *>(gpeer_identity_data), |
| 772 | gpeer_identity_size); |
| 773 | g_bytes_unref(gpeer_identity); |
| 774 | } |
| 775 | if (error) { |
| 776 | return garrow_error_to_status(error, |
| 777 | arrow::StatusCode::Invalid, |
| 778 | "[flight-server-custom-auth-handler]" |
| 779 | "[is-valid]"); |
| 780 | } else { |
| 781 | return arrow::Status::OK(); |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | private: |
| 786 | GAFlightServerCustomAuthHandler *handler_; |
no test coverage detected