Coverage Report

Created: 2026-03-17 00:16

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/common/kerberos/kerberos_config.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  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,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "common/kerberos/kerberos_config.h"
19
20
#include <filesystem>
21
22
#include "common/config.h"
23
#include "util/md5.h"
24
25
namespace doris::kerberos {
26
27
KerberosConfig::KerberosConfig()
28
9
        : _refresh_interval_second(3600), _min_time_before_refresh_second(600) {}
29
30
1
std::string KerberosConfig::get_hash_code(const std::string& principal, const std::string& keytab) {
31
1
    return _get_hash_code(principal, keytab);
32
1
}
33
34
std::string KerberosConfig::_get_hash_code(const std::string& principal,
35
8
                                           const std::string& keytab) {
36
    // use md5(principal + keytab) as hash code
37
    // so that same (principal + keytab) will have same name.
38
8
    std::string combined = principal + keytab;
39
8
    Md5Digest digest;
40
8
    digest.update(combined.c_str(), combined.length());
41
8
    digest.digest();
42
8
    return digest.hex();
43
8
}
44
45
} // namespace doris::kerberos