blob: 151037b23986a37ebb048cc2038dca3ecd11dce7 [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>
9
Lutz Justencb8399d2019-03-08 14:30:17 +010010#include <string>
11
Lutz Justen09cd1c32019-02-15 14:31:49 +010012#include "kerberos/proto_bindings/kerberos_service.pb.h"
13
Lutz Justenb79da832019-03-08 14:52:53 +010014namespace base {
15class FilePath;
16}
17
Lutz Justen09cd1c32019-02-15 14:31:49 +010018namespace kerberos {
19
20class Krb5Interface {
21 public:
22 Krb5Interface();
23 ~Krb5Interface();
24
Lutz Justencb8399d2019-03-08 14:30:17 +010025 // 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 Justen09cd1c32019-02-15 14:31:49 +010034 // 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 Justenb79da832019-03-08 14:52:53 +010041 const base::FilePath& krb5cc_path,
42 const base::FilePath& krb5conf_path) WARN_UNUSED_RESULT;
Lutz Justen09cd1c32019-02-15 14:31:49 +010043
Lutz Justencb8399d2019-03-08 14:30:17 +010044 // Renews an existing Kerberos ticket-granting-ticket for the given
Lutz Justen09cd1c32019-02-15 14:31:49 +010045 // |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 Justenb79da832019-03-08 14:52:53 +010049 const base::FilePath& krb5cc_path,
50 const base::FilePath& krb5conf_path) WARN_UNUSED_RESULT;
Lutz Justencb8399d2019-03-08 14:30:17 +010051
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 Justen09cd1c32019-02-15 14:31:49 +010055};
56
57} // namespace kerberos
58
59#endif // KERBEROS_KRB5_INTERFACE_H_