00001 #ifndef __SUT_PFENTRY_H 00002 #define __SUT_PFENTRY_H 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d S u t P F E n t r y . h h */ 00006 /* */ 00007 /* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* Produced by Gerri Ganis for CERN */ 00009 /* */ 00010 /* This file is part of the XRootD software suite. */ 00011 /* */ 00012 /* XRootD is free software: you can redistribute it and/or modify it under */ 00013 /* the terms of the GNU Lesser General Public License as published by the */ 00014 /* Free Software Foundation, either version 3 of the License, or (at your */ 00015 /* option) any later version. */ 00016 /* */ 00017 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00018 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00019 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00020 /* License for more details. */ 00021 /* */ 00022 /* You should have received a copy of the GNU Lesser General Public License */ 00023 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00024 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00025 /* */ 00026 /* The copyright holder's institutional names and contributor's names may not */ 00027 /* be used to endorse or promote products derived from this software without */ 00028 /* specific prior written permission of the institution or contributor. */ 00029 /******************************************************************************/ 00030 00031 #include "XProtocol/XProtocol.hh" 00032 #include "XrdSys/XrdSysPthread.hh" 00033 00034 /******************************************************************************/ 00035 /* */ 00036 /* Class defining the basic entry into a PFile */ 00037 /* */ 00038 /******************************************************************************/ 00039 00040 enum kPFEntryStatus { 00041 kPFE_inactive = -2, // -2 inactive: eliminated at next trim 00042 kPFE_disabled, // -1 disabled, cannot be enabled 00043 kPFE_allowed, // 0 empty creds, can be enabled 00044 kPFE_ok, // 1 enabled and OK 00045 kPFE_onetime, // 2 enabled, can be used only once 00046 kPFE_expired, // 3 enabled, creds to be changed at next used 00047 kPFE_special, // 4 special (non-creds) entry 00048 kPFE_anonymous, // 5 enabled, OK, no creds, counter 00049 kPFE_crypt // 6 enabled, OK, crypt-like credentials 00050 }; 00051 00052 // 00053 // Buffer used internally by XrdSutPFEntry 00054 // 00055 class XrdSutPFBuf { 00056 public: 00057 char *buf; 00058 kXR_int32 len; 00059 XrdSutPFBuf(char *b = 0, kXR_int32 l = 0); 00060 XrdSutPFBuf(const XrdSutPFBuf &b); 00061 00062 virtual ~XrdSutPFBuf() { if (len > 0 && buf) delete[] buf; } 00063 00064 void SetBuf(const char *b = 0, kXR_int32 l = 0); 00065 }; 00066 00067 // 00068 // Generic File entry: it stores a 00069 // 00070 // name 00071 // status 2 bytes 00072 // cnt 2 bytes 00073 // mtime 4 bytes 00074 // buf1, buf2, buf3, buf4 00075 // 00076 // The buffers are generic buffers to store bufferized info 00077 // 00078 class XrdSutPFEntry { 00079 public: 00080 char *name; 00081 short status; 00082 short cnt; // counter 00083 kXR_int32 mtime; // time of last modification / creation 00084 XrdSutPFBuf buf1; 00085 XrdSutPFBuf buf2; 00086 XrdSutPFBuf buf3; 00087 XrdSutPFBuf buf4; 00088 XrdSysMutex pfeMutex; // Locked when reference is outstanding 00089 XrdSutPFEntry(const char *n = 0, short st = 0, short cn = 0, 00090 kXR_int32 mt = 0); 00091 XrdSutPFEntry(const XrdSutPFEntry &e); 00092 virtual ~XrdSutPFEntry() { if (name) delete[] name; } 00093 kXR_int32 Length() const { return (buf1.len + buf2.len + 2*sizeof(short) + 00094 buf3.len + buf4.len + 5*sizeof(kXR_int32)); } 00095 void Reset(); 00096 void SetName(const char *n = 0); 00097 char *AsString() const; 00098 00099 XrdSutPFEntry &operator=(const XrdSutPFEntry &pfe); 00100 }; 00101 00102 #endif