|
||||
File indexing completed on 2025-01-30 10:27:56
0001 #ifndef __SEC_ATTR_H__ 0002 #define __SEC_ATTR_H__ 0003 /******************************************************************************/ 0004 /* */ 0005 /* X r d S e c A t t r . h h */ 0006 /* */ 0007 /* (c) 2019 by the Board of Trustees of the Leland Stanford, Jr., University */ 0008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 0009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 0010 /* */ 0011 /* This file is part of the XRootD software suite. */ 0012 /* */ 0013 /* XRootD is free software: you can redistribute it and/or modify it under */ 0014 /* the terms of the GNU Lesser General Public License as published by the */ 0015 /* Free Software Foundation, either version 3 of the License, or (at your */ 0016 /* option) any later version. */ 0017 /* */ 0018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 0019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 0020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 0021 /* License for more details. */ 0022 /* */ 0023 /* You should have received a copy of the GNU Lesser General Public License */ 0024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 0025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 0026 /* */ 0027 /* The copyright holder's institutional names and contributor's names may not */ 0028 /* be used to endorse or promote products derived from this software without */ 0029 /* specific prior written permission of the institution or contributor. */ 0030 /******************************************************************************/ 0031 0032 /*! The XrdSecAttr object is used as the base class to add arbitrary 0033 extensions to the XrdSecEntity object. A derived class definition should 0034 have a unique signature which is used by XrdSecEntity::Add() to 0035 differentiate extentions. The easiest way to do this is to use a unique 0036 memory address specific to all instances of the derived class. For instance, 0037 0038 class myAttr :: public XrdSecAttr 0039 { .... 0040 static const <type> mySig; 0041 0042 myAttr(...) : XrdSecAttr((const void *)&mySig), ... 0043 .... 0044 }; 0045 0046 You use this signature to retrieve an instance of the extension added to 0047 a specific XrdSecEntity object. Since signatures are unique the derived 0048 class is well known and you can safely use a static cast to downcast the 0049 returned pointer to the proper class (see the XrdSecEntity::Get() method). 0050 To successfully downcast using static_cast your derived class must be 0051 fully defined and in the scope of the static_cast. Otherwise, you must 0052 use the more expensive dynamic_cast. 0053 0054 Attribute objects are deleted when the associated XrdSecEntity instance 0055 is deleted. This happens when the client's server connection is closed. 0056 */ 0057 0058 class XrdSecEntity; 0059 0060 class XrdSecAttr 0061 { 0062 public: 0063 friend class XrdSecEntityAttr; 0064 0065 //------------------------------------------------------------------------------ 0066 //! Delete this object (may be over-ridden for custom action). 0067 //------------------------------------------------------------------------------ 0068 0069 virtual void Delete() {delete this;} 0070 0071 //------------------------------------------------------------------------------ 0072 //! Constructor. 0073 //! 0074 //! @param dSig - the unique signature for all instances of the class that 0075 //! uses this class as its base (i.e. the derived class). 0076 //------------------------------------------------------------------------------ 0077 0078 XrdSecAttr(const void *dSig) : Signature(dSig) {} 0079 0080 //------------------------------------------------------------------------------ 0081 //! Destructor (always externally done via Delete() method). 0082 //------------------------------------------------------------------------------ 0083 protected: 0084 0085 virtual ~XrdSecAttr() {} 0086 0087 private: 0088 0089 const void *Signature; 0090 }; 0091 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |