#include <unistd.h>
#include <cctype>
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <sys/param.h>
#include "XrdNet/XrdNetAddr.hh"
#include "XrdSys/XrdSysHeaders.hh"
#include "XrdSec/XrdSecInterface.hh"
Go to the source code of this file.
|
#define | H(x) fprintf(stderr,x); fprintf(stderr, "\n"); |
|
#define | I(x) fprintf(stderr, "\n"); H(x) |
|
#define H |
( |
|
x | ) |
fprintf(stderr,x); fprintf(stderr, "\n"); |
#define I |
( |
|
x | ) |
fprintf(stderr, "\n"); H(x) |
◆ help()
Definition at line 187 of file XrdSectestClient.cc.
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.")
static INT to(const char *buffer)
References H, and I.
Referenced by main().
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 71 of file XrdSectestClient.cc.
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",
size_t fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream)
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.
References XrdSecBuffer::buffer, DebugON, XrdSecProtocol::Delete(), fwrite(), XrdSecProtocol::getCredentials(), help(), optind, XrdNetAddr::Set(), XrdSecBuffer::size, tohex(), and XrdSecGetProtocol().
◆ tohex()
char* tohex |
( |
char * |
inbuff, |
|
|
int |
inlen, |
|
|
char * |
outbuff |
|
) |
| |
Definition at line 174 of file XrdSectestClient.cc.
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];
Referenced by main().
◆ XrdSecGetProtocol()
Definition at line 86 of file XrdSecClient.cc.
91 static int DebugON = ((getenv(
"XrdSecDEBUG") &&
92 strcmp(getenv(
"XrdSecDEBUG"),
"0")) ? 1 : 0);
95 getenv(
"XrdSecPROXYCREDS") != 0);
96 const char *noperr =
"XrdSec: No authentication protocols are available.";
102 DEBUG(
"protocol request for host " <<hostname <<
" token='"
103 <<(parms.
size > 0 ? std::setw(parms.
size) : std::setw(1))
104 <<(parms.
size > 0 ? parms.
buffer :
"") <<
"'");
112 if (!(protp = PManager.Get(hostname, endPoint, parms, einfo)))
113 {
if (einfo) einfo->
setErrInfo(ENOPROTOOPT, noperr);
114 else std::cerr <<noperr <<std::endl;
int setErrInfo(int code, const char *emsg)
References XrdSecBuffer::buffer, DEBUG, DebugON, XrdSecPManager::Get(), XrdOucErrInfo::setErrInfo(), and XrdSecBuffer::size.
Referenced by main().