Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:41

0001 #ifndef __XRDOUCGMAP_H__
0002 #define __XRDOUCGMAP_H__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                    X r d O u c G M a p . h h                               */
0006 /*                                                                            */
0007 /* (c) 2006 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 #include "XrdOuc/XrdOucHash.hh"
0034 #include "XrdOuc/XrdOucString.hh"
0035 #include "XrdSys/XrdSysXSLock.hh"
0036 
0037 class XrdOucTrace;
0038 class XrdSysError;
0039 class XrdSecGMapEntry_t
0040 {
0041 public:
0042    XrdSecGMapEntry_t(const char *v, const char *u, int t) : val(v), user(u), type(t) { }
0043    XrdOucString  val;
0044    XrdOucString  user;
0045    int           type;
0046 };
0047 
0048 class XrdOucGMap
0049 {
0050 public:
0051 
0052 //------------------------------------------------------------------------------
0053 //! Map a distinguished name (dn) to a user name.
0054 //!
0055 //! @param  dn    -> Distinguished name.
0056 //! @param  user  -> Buffer where the user name is to be placed.
0057 //!                  It must end with a null byte.
0058 //! @param  ulen  -> The length of the 'user' buffer.
0059 //! @param  now   -> Current time (result of time(0)) or 0 if not available.
0060 //!
0061 //! @return Success: Zero.
0062 //!         Failure: An errno number describing the failure; typically
0063 //!                  -EFAULT       - No valid matching found.
0064 //!                  -errno        - If problems reloading the file
0065 //------------------------------------------------------------------------------
0066 
0067 virtual int  dn2user(const char *dn, char *user, int ulen, time_t now = 0);
0068 
0069 
0070 //------------------------------------------------------------------------------
0071 //! Constructor
0072 //!
0073 //! @param  eDest -> The error object that must be used to print any errors or
0074 //!                  other messages (see XrdSysError.hh).
0075 //! @param  mapfn -> Path to the grid map file to be used. This pointer
0076 //!                  may be null; the default path will be tested then.
0077 //! @param  parms -> Argument string specified on the gridmap directive. It may
0078 //!                  be null or point to a null string if no parms exist.
0079 //!                  Curently supported parms:
0080 //!                        dbg          to enable debug printouts
0081 //!                        to=timeout   to set a timeout in secs on the validity
0082 //!                                     of the information loaded from the file
0083 //!                                     Default is 600 (10'); the reload is
0084 //!                                     triggered by the first mapping request
0085 //!                                     after the timeout is expired; the file is
0086 //!                                     reloaded only if changed.
0087 //!
0088 //------------------------------------------------------------------------------
0089 #define XrdOucGMapArgs XrdSysError       *eDest, \
0090                        const char        *mapfn, \
0091                        const char        *parms
0092              XrdOucGMap(XrdOucGMapArgs);
0093 
0094 //------------------------------------------------------------------------------
0095 //! Destructor
0096 //------------------------------------------------------------------------------
0097 
0098 virtual     ~XrdOucGMap() {}
0099 
0100 //------------------------------------------------------------------------------
0101 //! Validity checker
0102 //------------------------------------------------------------------------------
0103 
0104 bool         isValid() const { return valid; }
0105 
0106 private:
0107 //------------------------------------------------------------------------------
0108 //! Internal members
0109 //------------------------------------------------------------------------------
0110 
0111 bool                          valid;
0112 XrdOucHash<XrdSecGMapEntry_t> mappings;
0113 XrdOucString                  mf_name;
0114 time_t                        mf_mtime;
0115 time_t                        notafter;
0116 long                          timeout;
0117 
0118 XrdSysError                  *elogger;
0119 XrdOucTrace                  *tracer;
0120 bool                          dbg;
0121 
0122 XrdSysXSLock                  xsl;
0123 
0124 //------------------------------------------------------------------------------
0125 //! Internal methods
0126 //------------------------------------------------------------------------------
0127 
0128 int           load(const char *mf, bool force = 0);
0129 };
0130 
0131 /******************************************************************************/
0132 /*                    X r d O u c g e t G M a p                               */
0133 /******************************************************************************/
0134   
0135 //------------------------------------------------------------------------------
0136 //! Obtain an instance of the XrdOucGMap object.
0137 //!
0138 //! This extern "C" function is called when a shared library plug-in containing
0139 //! implementation of this class is loaded. It must exist in the shared library
0140 //! and must be thread-safe.
0141 //!
0142 //! @param  eDest -> The error object that must be used to print any errors or
0143 //!                  other messages (see XrdSysError.hh).
0144 //! @param  mapfn -> Path to the grid map file to be used. This pointer
0145 //!                  may be null; the default path will be tested then.
0146 //! @param  parms -> Argument string specified on the gridmap directive. It may
0147 //!                  be null or point to a null string if no parms exist.
0148 //!
0149 //! @return Success: A pointer to an instance of the XrdOucGMap object.
0150 //!         Failure: A null pointer which causes initialization to fail.
0151 //!
0152 //! The GMap object is used frequently in the course of creating new physical
0153 //! connections.
0154 //! The algorithms used by this object *must* be efficient and speedy;
0155 //! otherwise system performance will be severely degraded.
0156 //------------------------------------------------------------------------------
0157 
0158 //------------------------------------------------------------------------------
0159 //! Declare compilation version.
0160 //!
0161 //! Additionally, you *should* declare the xrootd version you used to compile
0162 //! your plug-in. While not currently required, it is highly recommended to
0163 //! avoid execution issues should the class definition change. Declare it as:
0164 //------------------------------------------------------------------------------
0165 
0166 /*!
0167         #include "XrdVersion.hh"
0168         XrdVERSIONINFO(XrdOucgetGMap,<name>);
0169 
0170     where <name> is a 1- to 15-character unquoted name identifying your plugin.
0171 */
0172 
0173 extern "C" XrdOucGMap *XrdOucgetGMap(XrdOucGMapArgs);
0174 
0175 #endif