42 #include <sys/param.h>
64 #define H(x) fprintf(stderr,x); fprintf(stderr, "\n");
65 #define I(x) fprintf(stderr, "\n"); H(x)
71 int main(
int argc,
char **argv)
73 char *
tohex(
char *inbuff,
int inlen,
char *outbuff);
75 char *protocols=0, *hostspec=0;
79 int putbin = 0, putlen = 0;
92 while ((c=getopt(argc,argv,
"bdlh:")) != (
char)EOF)
95 case 'b': putbin = 1;
break;
97 case 'h': hostspec = optarg;
break;
98 case 'l': putlen = 1;
break;
110 {std::cerr <<
"testClient: Extraneous parameter, '" <<argv[
optind] <<
"'." <<std::endl;
116 if (!protocols && !(protocols = getenv(
"XrdSecSECTOKEN")))
117 {std::cerr <<
"testClient: Security protocol string not specified." <<std::endl;
120 SecToken.
size = strlen(protocols);
121 SecToken.
buffer = protocols;
125 if (hostspec && (eText = theAddr(hostspec,0)))
126 {std::cerr <<
"testServer: Unable to resolve '" <<hostspec <<
"'; " <<eText <<std::endl;
128 }
else theAddr.
Set(
"localhost",0);
133 {putenv((
char *)
"XrdSecDEBUG=1");
134 std::cerr <<
"testClient: security token='" <<protocols <<
"'" <<std::endl;
140 if (!pp) {std::cerr <<
"Unable to get protocol." <<std::endl; exit(1);}
144 pp->addrInfo = &theAddr;
147 {std::cerr <<
"Unable to get credentials," <<std::endl;
151 std::cerr <<
"testClient: credentials size=" <<cred->
size <<std::endl;
158 {std::cerr <<
"Unable to write credentials length" <<std::endl;
161 {std::cerr <<
"Unable to write credentials" <<std::endl;
164 if (putlen) printf(
"%s",
174 char *
tohex(
char *inbuff,
int inlen,
char *outbuff) {
175 static char hv[] =
"0123456789abcdef";
177 for (i = 0; i < inlen; i++) {
178 outbuff[j++] = hv[(inbuff[i] >> 4) & 0x0f];
179 outbuff[j++] = hv[ inbuff[i] & 0x0f];
189 I(
"Syntax: testClient [ options ] [sectoken]")
190 I(
"Options: -b -d -l -h host")
191 I(
"Function: Request for credentials relative to an operation.")
193 if (rc > 1) exit(rc);
194 I(
"options: (defaults: -o 01")
195 I(
"-b output the ticket in binary format (i.e., not hexchar).")
196 I(
"-d turns on debugging.")
197 I(
"-l prefixes the ticket with its 4-byte length.")
198 I(
"-h host the requesting hostname (default is localhost).")
199 I(
"Notes: 1. Variable XrdSecSECTOKEN must contain the security token,")
200 H(
" sectoken, if it is not specified on the command line.")
size_t fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream)
int main(int argc, char **argv)
char * tohex(char *inbuff, int inlen, char *outbuff)
XrdSecProtocol * XrdSecGetProtocol(const char *hostname, XrdNetAddrInfo &endPoint, XrdSecParameters &parms, XrdOucErrInfo *einfo=0)
const char * Set(const char *hSpec, int pNum=PortInSpec)
virtual XrdSecCredentials * getCredentials(XrdSecParameters *parm=0, XrdOucErrInfo *einfo=0)=0
virtual void Delete()=0
Delete the protocol object. DO NOT use C++ delete() on this object.
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.