Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 1 | // Copyright 2019 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef KERBEROS_KRB5_INTERFACE_H_ |
| 6 | #define KERBEROS_KRB5_INTERFACE_H_ |
| 7 | |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 8 | #include <base/compiler_specific.h> |
Lutz Justen | e39cbd4 | 2019-05-14 14:52:24 +0200 | [diff] [blame^] | 9 | #include <base/macros.h> |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 10 | |
Lutz Justen | cb8399d | 2019-03-08 14:30:17 +0100 | [diff] [blame] | 11 | #include <string> |
| 12 | |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 13 | #include "kerberos/proto_bindings/kerberos_service.pb.h" |
| 14 | |
Lutz Justen | b79da83 | 2019-03-08 14:52:53 +0100 | [diff] [blame] | 15 | namespace base { |
| 16 | class FilePath; |
| 17 | } |
| 18 | |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 19 | namespace kerberos { |
| 20 | |
| 21 | class Krb5Interface { |
| 22 | public: |
Lutz Justen | e39cbd4 | 2019-05-14 14:52:24 +0200 | [diff] [blame^] | 23 | Krb5Interface() = default; |
| 24 | virtual ~Krb5Interface() = default; |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 25 | |
Lutz Justen | cb8399d | 2019-03-08 14:30:17 +0100 | [diff] [blame] | 26 | // Ticket-granting-ticket status, see GetTgtStatus(). |
| 27 | struct TgtStatus { |
| 28 | // For how many seconds the ticket is still valid. |
| 29 | int64_t validity_seconds = 0; |
| 30 | |
| 31 | // For how many seconds the ticket can be renewed. |
| 32 | int64_t renewal_seconds = 0; |
| 33 | }; |
| 34 | |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 35 | // Gets a Kerberos ticket-granting-ticket for the given |principal_name| |
| 36 | // (user@REALM.COM). |password| is the password for the Kerberos account. |
| 37 | // |krb5cc_path| is the file path where the Kerberos credential cache (i.e. |
| 38 | // the TGT) is written to. |krb5conf_path| is the path to a Kerberos |
| 39 | // configuration file (krb5.conf). |
Lutz Justen | e39cbd4 | 2019-05-14 14:52:24 +0200 | [diff] [blame^] | 40 | virtual ErrorType AcquireTgt(const std::string& principal_name, |
| 41 | const std::string& password, |
| 42 | const base::FilePath& krb5cc_path, |
| 43 | const base::FilePath& krb5conf_path) |
| 44 | WARN_UNUSED_RESULT = 0; |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 45 | |
Lutz Justen | cb8399d | 2019-03-08 14:30:17 +0100 | [diff] [blame] | 46 | // Renews an existing Kerberos ticket-granting-ticket for the given |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 47 | // |principal_name| (user@REALM.COM). |krb5cc_path| is the file path of the |
| 48 | // Kerberos credential cache. |krb5conf_path| is the path to a Kerberos |
| 49 | // configuration file (krb5.conf). |
Lutz Justen | e39cbd4 | 2019-05-14 14:52:24 +0200 | [diff] [blame^] | 50 | virtual ErrorType RenewTgt(const std::string& principal_name, |
| 51 | const base::FilePath& krb5cc_path, |
| 52 | const base::FilePath& krb5conf_path) |
| 53 | WARN_UNUSED_RESULT = 0; |
Lutz Justen | cb8399d | 2019-03-08 14:30:17 +0100 | [diff] [blame] | 54 | |
| 55 | // Gets some stats about the ticket-granting-ticket in the credential cache |
| 56 | // at |krb5cc_path|. |
Lutz Justen | e39cbd4 | 2019-05-14 14:52:24 +0200 | [diff] [blame^] | 57 | virtual ErrorType GetTgtStatus(const base::FilePath& krb5cc_path, |
| 58 | TgtStatus* status) WARN_UNUSED_RESULT = 0; |
| 59 | |
| 60 | private: |
| 61 | DISALLOW_COPY_AND_ASSIGN(Krb5Interface); |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | } // namespace kerberos |
| 65 | |
| 66 | #endif // KERBEROS_KRB5_INTERFACE_H_ |