xrootd
XrdSecProtocolsss.hh
Go to the documentation of this file.
00001 #ifndef _SECPROTOCOLSSS_
00002 #define _SECPROTOCOLSSS_
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                  X r d S e c P r o t o c o l s s s . h h                   */
00006 /*                                                                            */
00007 /* (c) 2008 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 "XrdCrypto/XrdCryptoLite.hh"
00034 #include "XrdSec/XrdSecInterface.hh"
00035 #include "XrdSecsss/XrdSecsssID.hh"
00036 #include "XrdSecsss/XrdSecsssKT.hh"
00037 #include "XrdSecsss/XrdSecsssRR.hh"
00038 
00039 class XrdOucErrInfo;
00040 
00041 class XrdSecProtocolsss : public XrdSecProtocol
00042 {
00043 public:
00044 friend class XrdSecProtocolDummy; // Avoid stupid gcc warnings about destructor
00045 
00046 
00047         int                Authenticate  (XrdSecCredentials *cred,
00048                                           XrdSecParameters **parms,
00049                                           XrdOucErrInfo     *einfo=0);
00050 
00051         void               Delete();
00052 
00053 static  int                eMsg(const char *epn, int rc, const char *txt1,
00054                                 const char *txt2=0,      const char *txt3=0, 
00055                                 const char *txt4=0);
00056 
00057 static  int                Fatal(XrdOucErrInfo *erP, const char *epn, int rc,
00058                                                      const char *etxt);
00059 
00060         XrdSecCredentials *getCredentials(XrdSecParameters  *parms=0,
00061                                           XrdOucErrInfo     *einfo=0);
00062 
00063         int   Init_Client(XrdOucErrInfo *erp, const char *Parms);
00064 
00065         int   Init_Server(XrdOucErrInfo *erp, const char *Parms);
00066 
00067 static  char *Load_Client(XrdOucErrInfo *erp, const char *Parms);
00068 
00069 static  char *Load_Server(XrdOucErrInfo *erp, const char *Parms);
00070 
00071 static  void  setOpts(int opts) {options = opts;}
00072 
00073         XrdSecProtocolsss(const char                *hname,
00074                           const struct sockaddr     *ipadd)
00075                          : XrdSecProtocol("sss"),
00076                            keyTab(0), Crypto(0), idBuff(0), Sequence(0)
00077                          {urName = strdup(hname); setIP(ipadd);}
00078 
00079 struct Crypto {const char *cName; char cType;};
00080 
00081 private:
00082        ~XrdSecProtocolsss() {} // Delete() does it all
00083 
00084 int                Decode(XrdOucErrInfo *error, XrdSecsssKT::ktEnt &decKey,
00085                           char *iBuff, XrdSecsssRR_Data *rrData, int iSize);
00086 XrdSecCredentials *Encode(XrdOucErrInfo *error, XrdSecsssKT::ktEnt &encKey,
00087                           XrdSecsssRR_Hdr *rrHdr, XrdSecsssRR_Data *rrData,
00088                           int dLen);
00089 int            getCred(XrdOucErrInfo *, XrdSecsssRR_Data &);
00090 int            getCred(XrdOucErrInfo *, XrdSecsssRR_Data &, XrdSecParameters *);
00091 char          *getLID(char *buff, int blen);
00092 static
00093 XrdCryptoLite *Load_Crypto(XrdOucErrInfo *erp, const char *eN);
00094 static
00095 XrdCryptoLite *Load_Crypto(XrdOucErrInfo *erp, const char  eT);
00096 int            myClock();
00097 char          *setID(char *id, char **idP);
00098 void           setIP(const struct sockaddr *sockP);
00099 
00100 static struct Crypto  CryptoTab[];
00101 
00102 static const char    *myName;
00103 static int            myNLen;
00104        char          *urName;
00105        char           urIP[64];
00106 static int            options;
00107 static int            isMutual;
00108 static int            deltaTime;
00109 static int            ktFixed;
00110 
00111 static XrdSecsssKT   *ktObject;  // Both:   Default Key Table object
00112        XrdSecsssKT   *keyTab;    // Both:   Active  Key Table
00113 
00114 static XrdCryptoLite *CryptObj;  // Both:   Default Cryptogrophy object
00115        XrdCryptoLite *Crypto;    // Both:   Active  Cryptogrophy object
00116 
00117 static XrdSecsssID   *idMap;     // Client: Registry
00118        char          *idBuff;    // Server: Underlying buffer for XrdSecEntity
00119 static char          *staticID;  // Client: Static identity
00120 static int            staticIDsz;// Client: Static identity length
00121        int            Sequence;  // Client: Check for sequencing
00122 };
00123 #endif