XRootD
Loading...
Searching...
No Matches
XrdSecEntityAttr Class Reference

#include <XrdSecEntityAttr.hh>

Inheritance diagram for XrdSecEntityAttr:
Collaboration diagram for XrdSecEntityAttr:

Public Member Functions

 XrdSecEntityAttr (XrdSecEntityXtra *xtra)
 ~XrdSecEntityAttr ()
bool Add (const std::string &key, const std::string &val, bool replace=false)
bool Add (XrdSecAttr &attr)
bool Get (const std::string &key, std::string &val)
XrdSecAttrGet (const void *sigkey)
std::vector< std::string > Keys ()
void List (XrdSecEntityAttrCB &attrCB)

Friends

class XrdSecEntity

Detailed Description

Definition at line 54 of file XrdSecEntityAttr.hh.

Constructor & Destructor Documentation

◆ XrdSecEntityAttr()

XrdSecEntityAttr::XrdSecEntityAttr ( XrdSecEntityXtra * xtra)
inline

Constructor and Destructor.

Parameters
xtra- Pointer to the data for the implementation.

Definition at line 130 of file XrdSecEntityAttr.hh.

130: entXtra(xtra) {}

Referenced by XrdSecEntityXtra::XrdSecEntityXtra().

Here is the caller graph for this function:

◆ ~XrdSecEntityAttr()

XrdSecEntityAttr::~XrdSecEntityAttr ( )
inline

Definition at line 132 of file XrdSecEntityAttr.hh.

132{}

Member Function Documentation

◆ Add() [1/2]

bool XrdSecEntityAttr::Add ( const std::string & key,
const std::string & val,
bool replace = false )

Add a key-value attribute to this entity. If one exists it is replaced.

Parameters
key- Reference to the key.
val- Reference to the value.
replace- When true, any existing key-value is replaced. Otherwise, the add is not performed.
Returns
True, the key-value was added or replaced.
False, the key already exists so he value was not added.

Definition at line 59 of file XrdSecEntityAttr.cc.

61{
62 XrdSysMutexHelper mHelp(entXtra->xMutex);
63 std::map<std::string, std::string>::iterator it;
64 bool found = false;
65
66// Check if this attribute already exists
67//
68 it = entXtra->attrMap.find(key);
69 if (it != entXtra->attrMap.end())
70 {if (!replace) return false;
71 found = true;
72 }
73
74// Add or replace the value
75//
76 if (found) it->second = val;
77 else entXtra->attrMap.insert(std::make_pair(key, val));
78 return true;
79}

◆ Add() [2/2]

bool XrdSecEntityAttr::Add ( XrdSecAttr & attr)

Add an attribute object to this entity.

Parameters
attr- Reference to the attribute object.
Returns
True, the object was added.
False, the object was not added because such an object exists.

Definition at line 41 of file XrdSecEntityAttr.cc.

42{
43 XrdSysMutexHelper mHelp(entXtra->xMutex);
44 std::vector<XrdSecAttr*>::iterator it;
45
46// Check if this attribute already exists
47//
48 for (it = entXtra->attrVec.begin(); it != entXtra->attrVec.end(); it++)
49 if ((*it)->Signature == attr.Signature) return false;
50
51// Add the attribute object to our list of objects
52//
53 entXtra->attrVec.push_back(&attr);
54 return true;
55}

Referenced by Macaroons::Authz::Access(), XrdAccSciTokens::Access(), XrdAccEntity::PutEntity(), and XrdOfs::rename().

Here is the caller graph for this function:

◆ Get() [1/2]

bool XrdSecEntityAttr::Get ( const std::string & key,
std::string & val )

Get an attribute key value associated with this entity.

Parameters
key- The reference to the key.
val- The reference to the string object to receive the value.
Returns
Upon success true is returned. If the key does not exist, false is returned and the val object remains unchanged.

Definition at line 102 of file XrdSecEntityAttr.cc.

103{
104 XrdSysMutexHelper mHelp(entXtra->xMutex);
105 std::map<std::string, std::string>::iterator it;
106
107// Return pointer to the attribute if it exists
108//
109 it = entXtra->attrMap.find(key);
110 if (it != entXtra->attrMap.end())
111 {val = it->second;
112 return true;
113 }
114
115// The key does not exists
116//
117 return false;
118}

◆ Get() [2/2]

XrdSecAttr * XrdSecEntityAttr::Get ( const void * sigkey)

Get an attribute object associated with this entity.

Parameters
sigkey- A unique attribute object signature key.
Returns
Upon success a pointer to the attribute object is returned. Otherwise, a nil pointer is returned.

Definition at line 85 of file XrdSecEntityAttr.cc.

86{
87 XrdSysMutexHelper mHelp(entXtra->xMutex);
88 std::vector<XrdSecAttr*>::iterator it;
89
90// Return pointer to the attribute if it exists
91//
92 for (it = entXtra->attrVec.begin(); it != entXtra->attrVec.end(); it++)
93 if ((*it)->Signature == sigkey) return *it;
94
95// Attribute not found
96//
97 return (XrdSecAttr *)0;
98}

Referenced by XrdAccAccess::Access(), XrdVomsMapfile::Apply(), XrdAccAccess::Audit(), XrdAccEntity::GetEntity(), and XrdThrottle::File::open().

Here is the caller graph for this function:

◆ Keys()

std::vector< std::string > XrdSecEntityAttr::Keys ( )

Get all the keys for associated attribytes.

Returns
A vector containing all of the keys.

Definition at line 124 of file XrdSecEntityAttr.cc.

125{
126 XrdSysMutexHelper mHelp(entXtra->xMutex);
127 std::map<std::string, std::string>::iterator itM;
128 std::vector<std::string> keyVec;
129
130 for (itM = entXtra->attrMap.begin();
131 itM != entXtra->attrMap.end(); itM++) keyVec.push_back(itM->first);
132
133 return keyVec;
134}

◆ List()

void XrdSecEntityAttr::List ( XrdSecEntityAttrCB & attrCB)

List key-value pairs via iterative callback on passed ovject.

Parameters
attrCB- Reference to the callback object to receive list entries.

Definition at line 140 of file XrdSecEntityAttr.cc.

141{
142 XrdSysMutexHelper mHelp(entXtra->xMutex);
143 std::map<std::string, std::string>::iterator itM;
144 std::vector<const char *> attrDel;
145 std::vector<const char *>::iterator itV;
147
148 for (itM = entXtra->attrMap.begin();
149 itM != entXtra->attrMap.end(); itM++)
150 {rc = attrCB.Attr(itM->first.c_str(), itM->second.c_str());
151 if (rc == XrdSecEntityAttrCB::Stop) break;
152 else if (rc == XrdSecEntityAttrCB::Delete)
153 attrDel.push_back(itM->first.c_str());
154 }
155
156 if (rc != XrdSecEntityAttrCB::Stop) attrCB.Attr(0, 0);
157
158 for (itV = attrDel.begin(); itV != attrDel.end(); itV++)
159 entXtra->attrMap.erase(std::string(*itV));
160}
@ Stop
Stop the iteration.
@ Delete
Delete the key-value and proceed to next one.
virtual Action Attr(const char *key, const char *val)=0

References XrdSecEntityAttrCB::Attr(), XrdSecEntityAttrCB::Delete, and XrdSecEntityAttrCB::Stop.

Here is the call graph for this function:

◆ XrdSecEntity

friend class XrdSecEntity
friend

Definition at line 57 of file XrdSecEntityAttr.hh.

References XrdSecEntity.

Referenced by XrdSecEntity.


The documentation for this class was generated from the following files: