xrootd
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 <stdlib.h>
33 #include <vector>
34 
35 /******************************************************************************/
36 /* X r d A c c E n t i t y I n f o */
37 /******************************************************************************/
38 
40  {const char *name; // Filled in by caller
41  const char *host; // Filled in by caller
42  const char *vorg;
43  const char *role;
44  const char *grup;
46  name(NULL),
47  host(NULL),
48  vorg(NULL),
49  role(NULL),
50  grup(NULL) {}
52  };
53 
54 /******************************************************************************/
55 /* X r d A c c E n t i t y */
56 /******************************************************************************/
57 
58 class XrdOucTokenizer;
59 class XrdSecEntity;
60 class XrdSysError;
61 
63 {
64 public:
65 
66 static
67 XrdAccEntity *GetEntity(const XrdSecEntity *secP);
68 
69 bool Next(int &seq, XrdAccEntityInfo &info)
70  {if (int(attrVec.size()) <= seq) return false;
71  EntityAttr *aP = &attrVec[seq++];
72  info.vorg = aP->vorg;
73  info.role = aP->role;
74  info.grup = aP->grup;
75  return true;
76  }
77 
78 void PutEntity();
79 
80 static
81 void setError(XrdSysError *errP);
82 
83 private:
84 
85  XrdAccEntity(const XrdSecEntity *secP, bool &aOK);
86 
88  if (roleInfo) free(roleInfo);
89  if (grpsInfo) free(grpsInfo);
90  }
91 
92 bool OneOrZero(char *src, const char *&dest);
93 bool setAttr(XrdOucTokenizer &tkl, const char *&dest);
94 
95 struct EntityAttr
96  {const char *vorg;
97  const char *role;
98  const char *grup;
99  EntityAttr() : vorg(NULL), role(NULL), grup(NULL) {}
101  };
102 
103 
104 std::vector<EntityAttr> attrVec;
105 
106 char *vorgInfo;
107 char *roleInfo;
108 char *grpsInfo;
109 int ueid;
110 };
111 
112 /******************************************************************************/
113 /* X r d A c c E n t i t y I n i t */
114 /******************************************************************************/
115 
117 {
118 public:
119 
121  {aeR = aeP = XrdAccEntity::GetEntity(secP);}
122 
124 
125 private:
126 
128 };
129 #endif
XrdAccEntityInfo::grup
const char * grup
Definition: XrdAccEntity.hh:44
XrdAccEntity::EntityAttr::role
const char * role
Definition: XrdAccEntity.hh:97
XrdAccEntity::PutEntity
void PutEntity()
XrdAccEntityInfo::host
const char * host
Definition: XrdAccEntity.hh:41
XrdAccEntityInfo::XrdAccEntityInfo
XrdAccEntityInfo()
Definition: XrdAccEntity.hh:45
XrdAccEntityInfo::vorg
const char * vorg
Definition: XrdAccEntity.hh:42
XrdAccEntityInfo::~XrdAccEntityInfo
~XrdAccEntityInfo()
Definition: XrdAccEntity.hh:51
XrdAccEntity::EntityAttr::vorg
const char * vorg
Definition: XrdAccEntity.hh:96
XrdAccEntityInfo::name
const char * name
Definition: XrdAccEntity.hh:40
XrdAccEntity::setError
static void setError(XrdSysError *errP)
XrdAccEntity::XrdAccEntity
XrdAccEntity(const XrdSecEntity *secP, bool &aOK)
XrdAccEntity::ueid
int ueid
Definition: XrdAccEntity.hh:109
XrdAccEntity::EntityAttr::grup
const char * grup
Definition: XrdAccEntity.hh:98
XrdAccEntity::EntityAttr::EntityAttr
EntityAttr()
Definition: XrdAccEntity.hh:99
XrdAccEntity::roleInfo
char * roleInfo
Definition: XrdAccEntity.hh:107
XrdAccEntityInfo
Definition: XrdAccEntity.hh:39
XrdAccEntity::setAttr
bool setAttr(XrdOucTokenizer &tkl, const char *&dest)
XrdAccEntityInit::~XrdAccEntityInit
~XrdAccEntityInit()
Definition: XrdAccEntity.hh:123
XrdAccEntityInit::aeP
XrdAccEntity * aeP
Definition: XrdAccEntity.hh:127
XrdAccEntityInit::XrdAccEntityInit
XrdAccEntityInit(const XrdSecEntity *secP, XrdAccEntity *&aeR)
Definition: XrdAccEntity.hh:120
XrdAccEntity::vorgInfo
char * vorgInfo
Definition: XrdAccEntity.hh:106
XrdAccEntity::EntityAttr
Definition: XrdAccEntity.hh:95
XrdAccEntity::OneOrZero
bool OneOrZero(char *src, const char *&dest)
XrdAccEntity::EntityAttr::~EntityAttr
~EntityAttr()
Definition: XrdAccEntity.hh:100
XrdAccEntity
Definition: XrdAccEntity.hh:62
XrdSecEntity
Definition: XrdSecEntity.hh:51
XrdAccEntityInfo::role
const char * role
Definition: XrdAccEntity.hh:43
XrdAccEntity::grpsInfo
char * grpsInfo
Definition: XrdAccEntity.hh:108
XrdOucTokenizer
Definition: XrdOucTokenizer.hh:32
XrdAccEntity::~XrdAccEntity
~XrdAccEntity()
Definition: XrdAccEntity.hh:87
XrdAccEntityInit
Definition: XrdAccEntity.hh:116
XrdSysError
Definition: XrdSysError.hh:89
XrdAccEntity::Next
bool Next(int &seq, XrdAccEntityInfo &info)
Definition: XrdAccEntity.hh:69
XrdAccEntity::attrVec
std::vector< EntityAttr > attrVec
Definition: XrdAccEntity.hh:104
XrdAccEntity::GetEntity
static XrdAccEntity * GetEntity(const XrdSecEntity *secP)