00001
00002
00003
00004
00005
00006
00007
00008
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
00032
00033
00034 #define DEBUG(x) {if (DebugON) cerr <<"sec_Client: " <<x <<endl;}
00035
00036
00037
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,
00049 XrdOucErrInfo *einfo=0)
00050 {return new XrdSecCredentials();}
00051
00052 void Delete() {}
00053
00054 XrdSecProtNone() : XrdSecProtocol("") {}
00055 ~XrdSecProtNone() {}
00056 };
00057
00058
00059
00060
00061
00062
00063
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
00081
00082 DEBUG("protocol request for host " <<hostname <<" token='"
00083 <<(parms.size > 0 ? parms.buffer : "") <<"'");
00084
00085
00086
00087 if (!parms.size || !parms.buffer[0]) return (XrdSecProtocol *)&ProtNone;
00088
00089
00090
00091 if (!(protp = PManager.Get(hostname, netaddr, parms)))
00092 {if (einfo) einfo->setErrInfo(ENOPROTOOPT, noperr);
00093 else cerr <<noperr <<endl;
00094 }
00095
00096
00097
00098 return protp;
00099 }
00100 }