Simple Geolocalization and Course Transmission Protocol (SGCTP)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
principal.hpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Simple Geolocalization and Course Transmission Protocol (SGCTP)
5  * Copyright (C) 2014 Cedric Dufour <http://cedric.dufour.name>
6  *
7  * The Simple Geolocalization and Course Transmission Protocol (SGCTP) is
8  * free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Simple Geolocalization and Course Transmission Protocol (SGCTP) is
13  * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15  * PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License for more details.
18  */
19 
20 #ifndef SGCTP_CPRINCIPAL_HPP
21 #define SGCTP_CPRINCIPAL_HPP
22 
23 // C
24 #include <stdint.h>
25 
26 // C++
27 #include <set>
28 using namespace std;
29 
30 // SGCTP
31 #define SGCTP_MAX_PASSWORD_SIZE 256
32 #define SGCTP_MAX_PASSWORD_LENGTH 255
33 
34 
35 // SGCTP namespace
36 namespace SGCTP
37 {
38 
40 
44  class CPrincipal
45  {
46 
47  //----------------------------------------------------------------------
48  // CONSTANTS / STATIC
49  //----------------------------------------------------------------------
50 
51  public:
53  static const uint16_t MAX_PASSWORD_LENGTH = SGCTP_MAX_PASSWORD_LENGTH;
54 
55 
56  //----------------------------------------------------------------------
57  // FIELDS
58  //----------------------------------------------------------------------
59 
60  private:
62  uint64_t ui64tID;
64  char pcPassword[SGCTP_MAX_PASSWORD_SIZE];
66  set<uint8_t> ui8tPayloadType_set;
67 
68  //----------------------------------------------------------------------
69  // CONSTRUCTORS / DESTRUCTOR
70  //----------------------------------------------------------------------
71 
72  public:
74  {
75  reset();
76  };
78  {
79  reset(); // clean sensitive data
80  };
81 
82 
83  //----------------------------------------------------------------------
84  // METHODS
85  //----------------------------------------------------------------------
86 
87  //
88  // SETTERS
89  //
90 
91  public:
93  void reset();
95  void erasePassword();
96 
98  void setID( uint64_t _ui64tID )
99  {
100  ui64tID = _ui64tID;
101  };
103  void setPassword( const char *_pcPassword );
105  void addPayloadType( uint8_t _ui8tPayloadType );
106 
107  //
108  // GETTERS
109  //
110 
111  public:
113  uint64_t getID() const
114  {
115  return ui64tID;
116  };
118  const char* getPassword() const
119  {
120  return pcPassword;
121  };
123  bool hasPayloadTypes() const;
125  bool hasPayloadType( uint8_t _ui8tPayloadType ) const;
126 
127  //
128  // OTHER
129  //
130 
131  public:
133  int read( const char *_pcPrincipalsPath,
134  uint64_t _ui64tID );
135 
136  };
137 
138 }
139 
140 #endif // SGCTP_CPRINCIPAL_HPP
uint64_t getID() const
Returns the principal ID.
Definition: principal.hpp:113
const char * getPassword() const
Returns the principal password.
Definition: principal.hpp:118
#define SGCTP_MAX_PASSWORD_LENGTH
Definition: principal.hpp:32
set< uint8_t > ui8tPayloadType_set
Allowed payload types.
Definition: principal.hpp:66
SGCTP principal.
Definition: principal.hpp:44
void setID(uint64_t _ui64tID)
Sets the principal ID.
Definition: principal.hpp:98
uint64_t ui64tID
ID.
Definition: principal.hpp:62
#define SGCTP_MAX_PASSWORD_SIZE
Definition: principal.hpp:31