GCC Code Coverage Report
Directory: cvmfs/ Exec Total Coverage
File: cvmfs/authz/authz.h Lines: 5 5 100.0 %
Date: 2019-02-03 02:48:13 Branches: 5 6 83.3 %

Line Branch Exec Source
1
/**
2
 * This file is part of the CernVM File System.
3
 *
4
 * Shared data structures for client-side authorization.
5
 */
6
7
#ifndef CVMFS_AUTHZ_AUTHZ_H_
8
#define CVMFS_AUTHZ_AUTHZ_H_
9
10
#include <inttypes.h>
11
12
#include <string>
13
14
/**
15
 * X.509 certificates are needed by the download manager to authenticate the
16
 * user.  Other credential types might be added in the future.
17
 */
18
enum AuthzTokenType {
19
  kTokenUnknown = 0,
20
  kTokenX509,
21
  kTokenBearer,
22
};
23
24
/**
25
 * The credentials as a bag of bytes that can be passed to the download
26
 * manager.  Ownership of tokens is with the AuthzSessionManager.
27
 */
28
struct AuthzToken {
29
2001
  AuthzToken() : type(kTokenUnknown), data(NULL), size(0) { }
30
  AuthzToken *DeepCopy();
31
32
  AuthzTokenType type;
33
  void *data;
34
  unsigned size;
35
};
36
37
38
enum AuthzStatus {
39
  kAuthzOk = 0,
40
  kAuthzNotFound,
41
  kAuthzInvalid,
42
  kAuthzNotMember,
43
  kAuthzNoHelper,
44
  kAuthzUnknown,
45
};
46
47
48
/**
49
 * The credentials together with the membership string it was verified for.
50
 * Entries expire.  Negative credential verification can be representated, too,
51
 * with status != kAuthzOk.
52
 */
53
1961
struct AuthzData {
54
1905
  AuthzData() : deadline(0), status(kAuthzUnknown) { }
55
  /**
56
   * The verification of the deadline is not included.
57
   */
58
28
  bool IsGranted(const std::string &expected_membership) const {
59

28
    return (status == kAuthzOk) && (membership == expected_membership);
60
  }
61
  AuthzToken token;
62
  uint64_t deadline;
63
  std::string membership;
64
  AuthzStatus status;
65
};
66
67
#endif  // CVMFS_AUTHZ_AUTHZ_H_