XrdSecClient.cc

Go to the documentation of this file.
00001 /******************************************************************************/
00002 /*                                                                            */
00003 /*                       X r d S e c C l i e n t . c c                        */
00004 /*                                                                            */
00005 /* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University  */
00006 /*                            All Rights Reserved                             */
00007 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00008 /*              DE-AC03-76-SFO0515 with the Department of Energy              */
00009 /******************************************************************************/
00010 
00011 #include <unistd.h>
00012 #include <ctype.h>
00013 #include <errno.h>
00014 #include <netdb.h>
00015 #include <stdlib.h>
00016 #include <strings.h>
00017 #include <stdio.h>
00018 #include <sys/param.h>
00019 #include <sys/types.h>
00020 #include <sys/socket.h>
00021 #include <netinet/in.h>
00022 #include <arpa/inet.h>
00023 
00024 #include "XrdOuc/XrdOucErrInfo.hh"
00025 #include "XrdSys/XrdSysHeaders.hh"
00026 #include "XrdSys/XrdSysPthread.hh"
00027 #include "XrdSec/XrdSecPManager.hh"
00028 #include "XrdSec/XrdSecInterface.hh"
00029 
00030 /******************************************************************************/
00031 /*                 M i s c e l l a n e o u s   D e f i n e s                  */
00032 /******************************************************************************/
00033 
00034 #define DEBUG(x) {if (DebugON) cerr <<"sec_Client: " <<x <<endl;}
00035 
00036 /******************************************************************************/
00037 /*                         L o c a l   C l a s s e s                          */
00038 /******************************************************************************/
00039   
00040 class XrdSecProtNone : public XrdSecProtocol
00041 {
00042 public:
00043 int                Authenticate  (XrdSecCredentials  *cred,
00044                                   XrdSecParameters  **parms,
00045                                   XrdOucErrInfo      *einfo=0) 
00046                                  {return 0;}
00047 
00048 XrdSecCredentials *getCredentials(XrdSecParameters  *parm=0,       // In
00049                                   XrdOucErrInfo     *einfo=0)
00050                                  {return new XrdSecCredentials();}
00051 
00052 void               Delete() {}  // Never deleted because it's static!
00053 
00054               XrdSecProtNone() : XrdSecProtocol("") {}
00055              ~XrdSecProtNone() {}
00056 };
00057   
00058 /******************************************************************************/
00059 /*                     X r d S e c G e t P r o t o c o l                      */
00060 /******************************************************************************/
00061 
00062 // This function is only invoked by the client. It exists in the top level
00063 // shared library that interposes between all other protocol shared libraries.
00064 //
00065 extern "C"
00066 {
00067 XrdSecProtocol *XrdSecGetProtocol(const char             *hostname,
00068                                   const struct sockaddr  &netaddr,
00069                                         XrdSecParameters &parms,
00070                                         XrdOucErrInfo    *einfo)
00071 {
00072    static int DebugON = ((getenv("XrdSecDEBUG") &&
00073                           strcmp(getenv("XrdSecDEBUG"), "0")) ? 1 : 0);
00074    static XrdSecProtNone ProtNone;
00075    static XrdSecPManager PManager(DebugON);
00076    const char *noperr = "XrdSec: No authentication protocols are available.";
00077 
00078    XrdSecProtocol *protp;
00079 
00080 // Perform any required debugging
00081 //
00082    DEBUG("protocol request for host " <<hostname <<" token='"
00083          <<(parms.size > 0 ? parms.buffer : "") <<"'");
00084 
00085 // Check if the server wants no security.
00086 //
00087    if (!parms.size || !parms.buffer[0]) return (XrdSecProtocol *)&ProtNone;
00088 
00089 // Find a supported protocol.
00090 //
00091    if (!(protp = PManager.Get(hostname, netaddr, parms)))
00092       {if (einfo) einfo->setErrInfo(ENOPROTOOPT, noperr);
00093          else cerr <<noperr <<endl;
00094       }
00095 
00096 // All done
00097 //
00098    return protp;
00099 }
00100 }

Generated on Tue Jul 5 14:46:57 2011 for ROOT_528-00b_version by  doxygen 1.5.1