00001 #ifndef __SecsssEnt__ 00002 #define __SecsssEnt__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d S e c s s s E n t . h h */ 00006 /* */ 00007 /* (c) 2020 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /* */ 00012 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00033 #include <set> 00034 #include <string> 00035 #include <stdlib.h> 00036 00037 #include "XrdSys/XrdSysAtomics.hh" 00038 #include "XrdSys/XrdSysPthread.hh" 00039 00040 class XrdSecEntity; 00041 00042 class XrdSecsssEnt 00043 { 00044 public: 00045 00046 char *eData; // -> RR 00047 int iLen; // Length of V1 data 00048 int tLen; // Length of V1 plus V2 data (follows iLen) 00049 00050 //----------------------------------------------------------------------------- 00054 //----------------------------------------------------------------------------- 00055 00056 void AddContact(const std::string &hostID); 00057 00058 //----------------------------------------------------------------------------- 00060 //----------------------------------------------------------------------------- 00061 00062 void Delete(); 00063 00064 //----------------------------------------------------------------------------- 00075 //----------------------------------------------------------------------------- 00076 00077 static const int addExtra = 0x00000001; 00078 static const int addCreds = 0x00000002; 00079 static const int v2Client = 0x00000003; 00080 00081 int RR_Data(char *&dP, const char *hostIP, int dataOpts); 00082 00083 00084 void Ref() {AtomicBeg(eMtx); AtomicInc(refCnt); AtomicEnd(eMtx);} 00085 00086 void UnRef() 00087 {AtomicBeg(eMtx); 00088 int x = AtomicDec(refCnt); 00089 AtomicEnd(eMtx); 00090 if (x < 1) delete this; 00091 } 00092 00093 static void setHostName(const char *hnP); 00094 00095 XrdSecsssEnt(const XrdSecEntity *entity=0, bool defer=false) 00096 : eData(0), iLen(0), tLen(0), eP(entity), refCnt(1) 00097 {if (!defer) Serialize();} 00098 00099 //----------------------------------------------------------------------------- 00101 //----------------------------------------------------------------------------- 00102 00103 private: 00104 ~XrdSecsssEnt() {if (eData) free(eData);} 00105 00106 bool Serialize(); 00107 00108 #ifndef HAVE_ATOMICS 00109 XrdSysMutex eMtx; 00110 #endif 00111 std::set<std::string> Contacts; 00112 00113 const 00114 XrdSecEntity *eP; 00115 int refCnt; 00116 short credLen; 00117 00118 static char *myHostName; 00119 static int myHostNLen; 00120 }; 00121 #endif