XRootD
Macaroons Namespace Reference

Classes

class  Authz
 
class  Handler
 

Enumerations

enum  LogMask {
  Debug = 0x01 ,
  Info = 0x02 ,
  Warning = 0x04 ,
  Error = 0x08 ,
  All = 0xff
}
 

Functions

ssize_t determine_validity (const std::string &input)
 

Enumeration Type Documentation

◆ LogMask

Enumerator
Debug 
Info 
Warning 
Error 
All 

Definition at line 15 of file XrdMacaroonsHandler.hh.

15  {
16  Debug = 0x01,
17  Info = 0x02,
18  Warning = 0x04,
19  Error = 0x08,
20  All = 0xff
21 };
bool Debug
@ Error

Function Documentation

◆ determine_validity()

ssize_t Macaroons::determine_validity ( const std::string &  input)

Definition at line 5 of file XrdMacaroonsUtils.cc.

6 {
7  ssize_t duration = 0;
8  if (input.find("PT") != 0)
9  {
10  return -1;
11  }
12  size_t pos = 2;
13  std::string remaining = input;
14  do
15  {
16  remaining = remaining.substr(pos);
17  if (remaining.size() == 0) break;
18  long cur_duration;
19  try
20  {
21  cur_duration = stol(remaining, &pos);
22  } catch (...)
23  {
24  return -1;
25  }
26  if (pos >= remaining.size())
27  {
28  return -1;
29  }
30  char unit = remaining[pos];
31  switch (unit) {
32  case 'S':
33  break;
34  case 'M':
35  cur_duration *= 60;
36  break;
37  case 'H':
38  cur_duration *= 3600;
39  break;
40  default:
41  return -1;
42  };
43  pos ++;
44  duration += cur_duration;
45  } while (1);
46  return duration;
47 }

Referenced by Macaroons::Handler::ProcessReq().

+ Here is the caller graph for this function: