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> |
| 9 | |
Lutz Justen | cb8399d | 2019-03-08 14:30:17 +0100 | [diff] [blame^] | 10 | #include <string> |
| 11 | |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 12 | #include "kerberos/proto_bindings/kerberos_service.pb.h" |
| 13 | |
Lutz Justen | b79da83 | 2019-03-08 14:52:53 +0100 | [diff] [blame] | 14 | namespace base { |
| 15 | class FilePath; |
| 16 | } |
| 17 | |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 18 | namespace kerberos { |
| 19 | |
| 20 | class Krb5Interface { |
| 21 | public: |
| 22 | Krb5Interface(); |
| 23 | ~Krb5Interface(); |
| 24 | |
Lutz Justen | cb8399d | 2019-03-08 14:30:17 +0100 | [diff] [blame^] | 25 | // Ticket-granting-ticket status, see GetTgtStatus(). |
| 26 | struct TgtStatus { |
| 27 | // For how many seconds the ticket is still valid. |
| 28 | int64_t validity_seconds = 0; |
| 29 | |
| 30 | // For how many seconds the ticket can be renewed. |
| 31 | int64_t renewal_seconds = 0; |
| 32 | }; |
| 33 | |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 34 | // Gets a Kerberos ticket-granting-ticket for the given |principal_name| |
| 35 | // (user@REALM.COM). |password| is the password for the Kerberos account. |
| 36 | // |krb5cc_path| is the file path where the Kerberos credential cache (i.e. |
| 37 | // the TGT) is written to. |krb5conf_path| is the path to a Kerberos |
| 38 | // configuration file (krb5.conf). |
| 39 | ErrorType AcquireTgt(const std::string& principal_name, |
| 40 | const std::string& password, |
Lutz Justen | b79da83 | 2019-03-08 14:52:53 +0100 | [diff] [blame] | 41 | const base::FilePath& krb5cc_path, |
| 42 | const base::FilePath& krb5conf_path) WARN_UNUSED_RESULT; |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 43 | |
Lutz Justen | cb8399d | 2019-03-08 14:30:17 +0100 | [diff] [blame^] | 44 | // Renews an existing Kerberos ticket-granting-ticket for the given |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 45 | // |principal_name| (user@REALM.COM). |krb5cc_path| is the file path of the |
| 46 | // Kerberos credential cache. |krb5conf_path| is the path to a Kerberos |
| 47 | // configuration file (krb5.conf). |
| 48 | ErrorType RenewTgt(const std::string& principal_name, |
Lutz Justen | b79da83 | 2019-03-08 14:52:53 +0100 | [diff] [blame] | 49 | const base::FilePath& krb5cc_path, |
| 50 | const base::FilePath& krb5conf_path) WARN_UNUSED_RESULT; |
Lutz Justen | cb8399d | 2019-03-08 14:30:17 +0100 | [diff] [blame^] | 51 | |
| 52 | // Gets some stats about the ticket-granting-ticket in the credential cache |
| 53 | // at |krb5cc_path|. |
| 54 | ErrorType GetTgtStatus(const base::FilePath& krb5cc_path, TgtStatus* status); |
Lutz Justen | 09cd1c3 | 2019-02-15 14:31:49 +0100 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | } // namespace kerberos |
| 58 | |
| 59 | #endif // KERBEROS_KRB5_INTERFACE_H_ |