XRootD
XrdSecEntityAttr.hh
Go to the documentation of this file.
1 #ifndef __SEC_ENTITYATTR_H__
2 #define __SEC_ENTITYATTR_H__
3 /******************************************************************************/
4 /* */
5 /* X r d S e c E n t i t y A t t r . 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 //------------------------------------------------------------------------------
39 //------------------------------------------------------------------------------
40 
41 #include <sys/types.h>
42 
43 #include <string>
44 #include <vector>
45 
46 class XrdSecAttr;
47 class XrdSecEntityAttrCB;
48 class XrdSecEntityXtra;
49 
50 /******************************************************************************/
51 /* X r d S e c E n t i t y A t t r */
52 /******************************************************************************/
53 
55 {
56 public:
57 friend class XrdSecEntity;
58 
59 //------------------------------------------------------------------------------
66 //------------------------------------------------------------------------------
67 
68  bool Add(XrdSecAttr &attr);
69 
70 //------------------------------------------------------------------------------
80 //------------------------------------------------------------------------------
81 
82  bool Add(const std::string &key,
83  const std::string &val, bool replace=false);
84 
85 //------------------------------------------------------------------------------
92 //------------------------------------------------------------------------------
93 
94 XrdSecAttr *Get(const void *sigkey);
95 
96 //------------------------------------------------------------------------------
104 //------------------------------------------------------------------------------
105 
106  bool Get(const std::string &key, std::string &val);
107 
108 //------------------------------------------------------------------------------
112 //------------------------------------------------------------------------------
113 
114 std::vector<std::string> Keys();
115 
116 //------------------------------------------------------------------------------
120 //------------------------------------------------------------------------------
121 
122  void List(XrdSecEntityAttrCB &attrCB);
123 
124 //------------------------------------------------------------------------------
128 //------------------------------------------------------------------------------
129 
130  XrdSecEntityAttr(XrdSecEntityXtra *xtra) : entXtra(xtra) {}
131 
133 
134 private:
135 
136 XrdSecEntityXtra *entXtra;
137 };
138 
139 /******************************************************************************/
140 /* X r d S e c E n t i t y A t t r C B */
141 /******************************************************************************/
142 
143 // The XrdSecEntityAttrCB class defines the callback object passed to the
144 // XrdSecEntity::List() method to iteratively obtain the key-value attribute
145 // pairs associated with the entity. The XrdSecEntityAttrCB::Attr() method is
146 // called for each key-value pair. The end of the list is indicated by calling
147 // Attr() with nil key-value pointers. The Attr() method should not call
148 // the XrdSecEntity::Add() or XrdSecEntity::Get() methods; otherwise, a
149 // deadlock will occur.
150 //
152 {
153 public:
154 
155 //------------------------------------------------------------------------------
163 //------------------------------------------------------------------------------
164 
165 enum Action {Delete = -1,
166  Stop = 0,
167  Next = 1
168  };
169 
170 virtual Action Attr(const char *key, const char *val) = 0;
171 
172 //------------------------------------------------------------------------------
174 //------------------------------------------------------------------------------
175 
178 };
179 #endif
@ Stop
Stop the iteration.
@ Next
Proceed to the next key-value pair.
@ Delete
Delete the key-value and proceed to next one.
virtual Action Attr(const char *key, const char *val)=0
XrdSecEntityAttrCB()
Constructor and Destructor.
bool Add(XrdSecAttr &attr)
XrdSecAttr * Get(const void *sigkey)
std::vector< std::string > Keys()
XrdSecEntityAttr(XrdSecEntityXtra *xtra)
void List(XrdSecEntityAttrCB &attrCB)