blob: 202dc51da8a9026d7d26655af0b98075c97a2fc1 [file] [log] [blame]
Lutz Justen09cd1c32019-02-15 14:31:49 +01001// 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 Justen09cd1c32019-02-15 14:31:49 +01008#include <base/compiler_specific.h>
Lutz Justene39cbd42019-05-14 14:52:24 +02009#include <base/macros.h>
Lutz Justen09cd1c32019-02-15 14:31:49 +010010
Lutz Justencb8399d2019-03-08 14:30:17 +010011#include <string>
12
Lutz Justen09cd1c32019-02-15 14:31:49 +010013#include "kerberos/proto_bindings/kerberos_service.pb.h"
14
Lutz Justenb79da832019-03-08 14:52:53 +010015namespace base {
16class FilePath;
17}
18
Lutz Justen09cd1c32019-02-15 14:31:49 +010019namespace kerberos {
20
21class Krb5Interface {
22 public:
Lutz Justene39cbd42019-05-14 14:52:24 +020023 Krb5Interface() = default;
24 virtual ~Krb5Interface() = default;
Lutz Justen09cd1c32019-02-15 14:31:49 +010025
Lutz Justencb8399d2019-03-08 14:30:17 +010026 // 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 Justen09cd1c32019-02-15 14:31:49 +010035 // 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 Justene39cbd42019-05-14 14:52:24 +020040 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 Justen09cd1c32019-02-15 14:31:49 +010045
Lutz Justencb8399d2019-03-08 14:30:17 +010046 // Renews an existing Kerberos ticket-granting-ticket for the given
Lutz Justen09cd1c32019-02-15 14:31:49 +010047 // |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 Justene39cbd42019-05-14 14:52:24 +020050 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 Justencb8399d2019-03-08 14:30:17 +010054
55 // Gets some stats about the ticket-granting-ticket in the credential cache
56 // at |krb5cc_path|.
Lutz Justene39cbd42019-05-14 14:52:24 +020057 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 Justen09cd1c32019-02-15 14:31:49 +010062};
63
64} // namespace kerberos
65
66#endif // KERBEROS_KRB5_INTERFACE_H_