xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdAccEntity.hh
Go to the documentation of this file.
1 #ifndef __ACC_ENTITY_H__
2 #define __ACC_ENTITY_H__
3 /******************************************************************************/
4 /* */
5 /* X r d A c c E n t i t y . h h */
6 /* */
7 /* (c) 2019 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* Produced by Andrew Hanushevsky for Stanford University under contract */
9 /* DE-AC02-76-SFO0515 with the Department of Energy */
10 /* */
11 /* This file is part of the XRootD software suite. */
12 /* */
13 /* XRootD is free software: you can redistribute it and/or modify it under */
14 /* the terms of the GNU Lesser General Public License as published by the */
15 /* Free Software Foundation, either version 3 of the License, or (at your */
16 /* option) any later version. */
17 /* */
18 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21 /* License for more details. */
22 /* */
23 /* You should have received a copy of the GNU Lesser General Public License */
24 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26 /* */
27 /* The copyright holder's institutional names and contributor's names may not */
28 /* be used to endorse or promote products derived from this software without */
29 /* specific prior written permission of the institution or contributor. */
30 /******************************************************************************/
31 
32 #include <cstdlib>
33 #include <vector>
34 
35 #include "XrdSec/XrdSecAttr.hh"
36 
37 /******************************************************************************/
38 /* X r d A c c E n t i t y I n f o */
39 /******************************************************************************/
40 
42  {const char *name; // Filled in by caller
43  const char *host; // Filled in by caller
44  const char *vorg;
45  const char *role;
46  const char *grup;
48  name(NULL),
49  host(NULL),
50  vorg(NULL),
51  role(NULL),
52  grup(NULL) {}
54  };
55 
56 /******************************************************************************/
57 /* X r d A c c E n t i t y */
58 /******************************************************************************/
59 
60 class XrdOucTokenizer;
61 class XrdSecEntity;
62 class XrdSysError;
63 
64 class XrdAccEntity : public XrdSecAttr
65 {
66 public:
67 
68 static
69 XrdAccEntity *GetEntity(const XrdSecEntity *secP, bool &isNew);
70 
71 bool Next(int &seq, XrdAccEntityInfo &info)
72  {if (int(attrVec.size()) <= seq) return false;
73  EntityAttr *aP = &attrVec[seq++];
74  info.vorg = aP->vorg;
75  info.role = aP->role;
76  info.grup = aP->grup;
77  return true;
78  }
79 
80 void PutEntity(const XrdSecEntity *secP);
81 
82 static
83 void setError(XrdSysError *errP);
84 
85 private:
86 
87  XrdAccEntity(const XrdSecEntity *secP, bool &aOK);
88 
90  if (roleInfo) free(roleInfo);
91  if (grpsInfo) free(grpsInfo);
92  }
93 
94 bool OneOrZero(char *src, const char *&dest);
95 bool setAttr(XrdOucTokenizer &tkl, const char *&dest);
96 
97 struct EntityAttr
98  {const char *vorg;
99  const char *role;
100  const char *grup;
101  EntityAttr() : vorg(NULL), role(NULL), grup(NULL) {}
103  };
104 
105 
106 std::vector<EntityAttr> attrVec;
107 
108 char *vorgInfo;
109 char *roleInfo;
110 char *grpsInfo;
111 static int accSig; // Attribute Object Signture
112 };
113 
114 /******************************************************************************/
115 /* X r d A c c E n t i t y I n i t */
116 /******************************************************************************/
117 
119 {
120 public:
121 
122  XrdAccEntityInit(const XrdSecEntity *secP, XrdAccEntity *&aeR) : seP(secP)
123  {bool isNew;
124  aeR = XrdAccEntity::GetEntity(secP, isNew);
125  aeP = (isNew ? aeR : 0);
126  }
127 
129 
130 private:
131 
134 };
135 #endif
Definition: XrdSecAttr.hh:60
char * vorgInfo
Definition: XrdAccEntity.hh:108
const char * grup
Definition: XrdAccEntity.hh:100
bool OneOrZero(char *src, const char *&dest)
~XrdAccEntityInfo()
Definition: XrdAccEntity.hh:53
const char * host
Definition: XrdAccEntity.hh:43
XrdAccEntity(const XrdSecEntity *secP, bool &aOK)
const char * grup
Definition: XrdAccEntity.hh:46
const char * name
Definition: XrdAccEntity.hh:42
bool Next(int &seq, XrdAccEntityInfo &info)
Definition: XrdAccEntity.hh:71
~XrdAccEntity()
Definition: XrdAccEntity.hh:89
Definition: XrdSysError.hh:89
std::vector< EntityAttr > attrVec
Definition: XrdAccEntity.hh:106
char * grpsInfo
Definition: XrdAccEntity.hh:110
const char * role
Definition: XrdAccEntity.hh:99
const char * vorg
Definition: XrdAccEntity.hh:98
XrdAccEntityInfo()
Definition: XrdAccEntity.hh:47
static void setError(XrdSysError *errP)
const char * vorg
Definition: XrdAccEntity.hh:44
~EntityAttr()
Definition: XrdAccEntity.hh:102
bool setAttr(XrdOucTokenizer &tkl, const char *&dest)
Definition: XrdAccEntity.hh:41
XrdAccEntity * aeP
Definition: XrdAccEntity.hh:133
~XrdAccEntityInit()
Definition: XrdAccEntity.hh:128
static XrdAccEntity * GetEntity(const XrdSecEntity *secP, bool &isNew)
void PutEntity(const XrdSecEntity *secP)
Definition: XrdAccEntity.hh:118
const char * role
Definition: XrdAccEntity.hh:45
static int accSig
Definition: XrdAccEntity.hh:111
Definition: XrdOucTokenizer.hh:32
Definition: XrdAccEntity.hh:97
const XrdSecEntity * seP
Definition: XrdAccEntity.hh:132
Definition: XrdAccEntity.hh:64
Definition: XrdSecEntity.hh:63
EntityAttr()
Definition: XrdAccEntity.hh:101
XrdAccEntityInit(const XrdSecEntity *secP, XrdAccEntity *&aeR)
Definition: XrdAccEntity.hh:122
char * roleInfo
Definition: XrdAccEntity.hh:109