36 #include <sys/param.h>
49 #define H(x) fprintf(stderr,x); fprintf(stderr, "\n");
50 #define I(x) fprintf(stderr, "\n"); H(x)
51 #define insx(a,b) sprintf(errbuff,a,b)
52 #define insy(a,b,c) sprintf(errbuff,a,b,c)
79 char hexbuff[
sizeof(C_Block)+8];
92 void getargs(
int argc,
char **argv);
97 int emsg(
int rc,
char *msg);
105 int main(
int argc,
char **argv)
115 unsigned char bbuff[4096];
126 {std::cerr <<
"testServer: Unable to resolve '" <<
opts.
host <<
"'; " <<eText <<std::endl;
130 else theAddr.
Set(
"localhost",0);
136 {std::cerr <<
"testServer: Unable to create server." <<std::endl; exit(1);}
141 if (!sect) std::cerr <<
"testServer: No security token for " <<
opts.
host <<std::endl;
142 else std::cerr <<
"testServer: " <<i <<
" bytes of SecToken='" <<sect <<
"'" <<std::endl;
148 else getline(bbuff,
sizeof(bbuff));
154 if (cred.
size < 0)
emsg(100,(
char *)
"Invalid credentials format.");
162 std::cerr <<
"testServer: getProtocol error " <<rc <<
"; ";
171 std::cerr <<
"testServer: Authenticate error " <<rc <<
"; ";
191 for (i = 0; i < blen; i++)
193 else if (j == EOF)
return i;
195 xerr(
insx(
"Cred longer than %d bytes.", blen));
207 extern int optind;
extern char *optarg;
char c;
223 while ((c=getopt(argc,argv,
"c:h:i:k:p:bdx")) != (char)EOF)
227 case 'c':
opts.
cfn = optarg;
break;
229 case 'h':
opts.
host = optarg;
break;
230 case 'i':
opts.
inpt = optarg;
break;
253 emsg(8, (
char *)
"-b is incompatible with inline creds.");
273 for (j = 0; j < blen; j++) {
274 if (!ibuff[i])
return j;
275 if (!
cvtx(ibuff[i++], &dig1) || !
cvtx(ibuff[i++], &dig2))
return -1;
276 obuff[j] = (dig1 << 4) | dig2;
282 if (idig >=
'0' && idig <=
'9') {*odig = idig & (
uchar)0x0f;
return 1;}
283 idig = idig | (
uchar)0x20;
284 if (idig < 'a' || idig >
'f')
return 0;
293 if (!fgets((
char *)buff, blen,
opts.
infid))
return;
294 for (i = 0; i < blen; i++)
295 if (buff[i] ==
'\n') {buff[i] =
'\000';
break;}
310 std::cerr <<
"testServer: " <<msg <<std::endl;
319 I(
"Syntax: testServer [ options ] cred ]")
320 I(
"Options: -b -c config -d -h -i input -t")
321 H(
" -p principal[.instance][@realm] -s sep")
322 I(
"Function: Display the credentials contents.")
324 if (rc > 1) exit(rc);
325 I(
"options: (defaults: -k /etc/srvtab\\n")
326 I(
"-b indicates the cred is in binary format (i.e., not hexchar).")
327 I(
"-c cfn the config file.")
328 I(
"-d turns on debugging.")
329 I(
"-h host the incoming hostname.")
330 I(
"-i input specifies the input stream (e.g., fname) if other than stdin.")
331 H(
" This -i is ignored if cred is specified on the command line.")
int getbintix(uchar *buff, int blen)
int main(int argc, char **argv)
void getline(uchar *buff, int blen)
int cvtx(uchar idig, uchar *odig)
XrdSecService * XrdSecgetService(XrdSysLogger *lp, const char *cfn)
int unhex(uchar *ibuff, uchar *obuff, int blen)
int emsg(int rc, char *msg)
void getargs(int argc, char **argv)
const char * XrdSysE2T(int errcode)
const char * Set(const char *hSpec, int pNum=PortInSpec)
const char * getErrText()
char prot[XrdSecPROTOIDSIZE]
Auth protocol used (e.g. krb5)
char * name
Entity's name.
char * host
Entity's host name dnr dependent.
virtual int Authenticate(XrdSecCredentials *cred, XrdSecParameters **parms, XrdOucErrInfo *einfo=0)=0
virtual const char * getParms(int &size, XrdNetAddrInfo *endPoint=0)=0
virtual XrdSecProtocol * getProtocol(const char *host, XrdNetAddrInfo &endPoint, const XrdSecCredentials *cred, XrdOucErrInfo &einfo)=0
Generic structure to pass security information back and forth.
char * buffer
Pointer to the buffer.
int size
Size of the buffer or length of data in the buffer.