Loading...
Searching...
No Matches
XrdSectestClient.cc File Reference
`#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"`
Include dependency graph for XrdSectestClient.cc:

Go to the source code of this file.

## Macros

#define | H(x)
#define | I(x)

## Functions

void | help (int rc)
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)

## Macro Definition Documentation

## H

#define H | ( |  | x | ) |

Value:
fprintf(stderr,x); fprintf(stderr, "\n");

Definition at line 64 of file XrdSectestClient.cc.

Referenced by help().

## I

#define I | ( |  | x | ) |

Value:
fprintf(stderr, "\n"); H(x)
H
#define H(x)
Definition XrdSectestClient.cc:64

Definition at line 65 of file XrdSectestClient.cc.

Referenced by help().

## Function Documentation

## help()

void help | ( | int | rc | ) |

Definition at line 187 of file XrdSectestClient.cc.

{
/* Use H macro to avoid Sun string catenation bug. */
I("Syntax: testClient [ options ] [sectoken]")
I("Options: -b -d -l -h host")
I("Function: Request for credentials relative to an operation.")
if (rc > 1) exit(rc);
I("options: (defaults: -o 01")
I("-b output the ticket in binary format (i.e., not hexchar).")
I("-d turns on debugging.")
I("-l prefixes the ticket with its 4-byte length.")
I("-h host the requesting hostname (default is localhost).")
I("Notes: 1. Variable XrdSecSECTOKEN must contain the security token,")
H(" sectoken, if it is not specified on the command line.")
exit(rc);
}
I
#define I(x)
Definition XrdSectestClient.cc:65
if
if(Avsz)
Definition XrdSysFAttrSun.icc:98

References H, and I.

Referenced by main().

Here is the caller graph for this function:

## main()

int main | ( | int | argc,
|  | char ** | argv )

Definition at line 71 of file XrdSectestClient.cc.

{
char *tohex(char *inbuff, int inlen, char *outbuff);
char *protocols=0, *hostspec=0;
XrdNetAddr theAddr;
int putbin = 0, putlen = 0;
char kbuff[8192];
char c;
XrdSecCredentials *cred;
XrdSecParameters SecToken;
XrdSecProtocol *pp;
int DebugON = 0;
void help(int);
/*Get all of the options.
*/
while ((c=getopt(argc,argv,"bdlh:")) != (char)EOF)
{ switch(c)
{
case 'b': putbin = 1; break;
case 'd': DebugON = 1; break;
case 'h': hostspec = optarg; break;
case 'l': putlen = 1; break;
default: help(1);
}
}
// Check if the security token is the last argument
//
if (optind < argc) protocols = argv[optind++];
/*Make sure no more parameters exist.
*/
if (optind < argc)
{std::cerr <<"testClient: Extraneous parameter, '" <<argv[optind] <<"'." <<std::endl;
help(2);
}
// Determine protocol string
//
if (!protocols && !(protocols = getenv("XrdSecSECTOKEN")))
{std::cerr <<"testClient: Security protocol string not specified." <<std::endl;
help(2);
}
SecToken.size = strlen(protocols);
SecToken.buffer = protocols;
// if hostname given, get the hostname address
//
if (hostspec && (eText = theAddr(hostspec,0)))
{std::cerr <<"testServer: Unable to resolve '" <<hostspec <<"'; " <<eText <<std::endl;
exit(1);
} else theAddr.Set("localhost",0);
// Do debug processing
//
if (DebugON)
{putenv((char *)"XrdSecDEBUG=1");
std::cerr <<"testClient: security token='" <<protocols <<"'" <<std::endl;
}
// Get the protocol
//
pp = XrdSecGetProtocol(hostspec, theAddr, SecToken, 0);
if (!pp) {std::cerr << "Unable to get protocol." <<std::endl; exit(1);}
// Get credentials using this context
//
pp->addrInfo = &theAddr;
cred = pp->getCredentials();
if (!cred)
{std::cerr << "Unable to get credentials," <<std::endl;
exit(1);
}
if (DebugON)
std::cerr << "testClient: credentials size=" <<cred->size <<std::endl;
// Write out the credentials
//
if (putbin)
{if (putlen)
{if (fwrite(&cred->size, sizeof(cred->size), 1, stdout) != sizeof(cred->size))
{std::cerr << "Unable to write credentials length" <<std::endl;
exit(1);}}
if (fwrite((char *) cred->buffer, cred->size, 1, stdout) != (size_t) cred->size)
{std::cerr << "Unable to write credentials" <<std::endl;
exit(1);}
} else {
if (putlen) printf("%s",
tohex((char *)&cred->size, sizeof(cred->size), kbuff));
printf("%s\n", tohex((char *) cred->buffer, cred->size, kbuff));
}
// All done.
//
pp->Delete();
}
DebugON
int DebugON
Definition XrdCryptosslFactory.hh:43
optind
int optind
fwrite
#define fwrite(b, s, n, f)
Definition XrdPosix.hh:72
XrdSecParameters
XrdSecBuffer XrdSecParameters
Definition XrdSecInterface.hh:79
XrdSecCredentials
XrdSecBuffer XrdSecCredentials
Definition XrdSecInterface.hh:69
XrdSecGetProtocol
XrdSecProtocol * XrdSecGetProtocol(const char *hostname, XrdNetAddrInfo &endPoint, XrdSecParameters &parms, XrdOucErrInfo *einfo=0)
Definition XrdSecClient.cc:86
help
void help(int rc)
Definition XrdSectestClient.cc:187
tohex
char * tohex(char *inbuff, int inlen, char *outbuff)
Definition XrdSectestClient.cc:174
XrdNetAddr
Definition XrdNetAddr.hh:42
XrdNetAddr::Set
const char * Set(const char *hSpec, int pNum=PortInSpec)
Definition XrdNetAddr.cc:216
XrdSecProtocol
Definition XrdSecInterface.hh:131
XrdSecProtocol::getCredentials
virtual XrdSecCredentials * getCredentials(XrdSecParameters *parm=0, XrdOucErrInfo *einfo=0)=0
XrdSecProtocol::Delete
virtual void Delete()=0
Delete the protocol object. DO NOT use C++ delete() on this object.
XrdSecBuffer::buffer
char * buffer
Pointer to the buffer.
Definition XrdSecInterface.hh:53
XrdSecBuffer::size
int size
Size of the buffer or length of data in the buffer.
Definition XrdSecInterface.hh:52

References XrdSecBuffer::buffer, DebugON, XrdSecProtocol::Delete(), fwrite, XrdSecProtocol::getCredentials(), help(), optind, XrdNetAddr::Set(), XrdSecBuffer::size, tohex(), and XrdSecGetProtocol().

Here is the call graph for this function:

## tohex()

char * tohex | ( | char * | inbuff,
|  | int | inlen,
|  | char * | outbuff )

Definition at line 174 of file XrdSectestClient.cc.

{
static const char hv[] = "0123456789abcdef";
int i, j = 0;
for (i = 0; i < inlen; i++) {
outbuff[j++] = hv[(inbuff[i] >> 4) & 0x0f];
outbuff[j++] = hv[ inbuff[i] & 0x0f];
}
outbuff[j] = '\0';
return outbuff;
}

Referenced by main().

Here is the caller graph for this function:

## XrdSecGetProtocol()

XrdSecProtocol * XrdSecGetProtocol | ( | const char * | hostname,
|  | XrdNetAddrInfo & | endPoint,
|  | XrdSecParameters & | parms,
|  | XrdOucErrInfo * | einfo = 0 )

extern

Definition at line 86 of file XrdSecClient.cc.

{
static int DebugON = ((getenv("XrdSecDEBUG") &&
strcmp(getenv("XrdSecDEBUG"), "0")) ? 1 : 0);
static XrdSecProtNone ProtNone;
static XrdSecPManager PManager(DebugON, getenv("XrdSecPROXY") != 0,
getenv("XrdSecPROXYCREDS") != 0);
const char *noperr = "XrdSec: No authentication protocols are available.";
XrdSecProtocol *protp;
// Perform any required debugging
//
DEBUG("protocol request for host " <<hostname <<" token='"
<<(parms.size > 0 ? std::setw(parms.size) : std::setw(1))
<<(parms.size > 0 ? parms.buffer : "") <<"'");
// Check if the server wants no security.
//
if (!parms.size || !parms.buffer[0]) return (XrdSecProtocol *)&ProtNone;
// Find a supported protocol.
//
if (!(protp = PManager.Get(hostname, endPoint, parms, einfo)))
{if (einfo) einfo->setErrInfo(ENOPROTOOPT, noperr);
else std::cerr <<noperr <<std::endl;
}
// All done
//
return protp;
}
DEBUG
#define DEBUG(x)
Definition XrdSecClient.cc:53
XrdOucErrInfo::setErrInfo
int setErrInfo(int code, const char *emsg)
Definition XrdOucErrInfo.hh:147
XrdSecPManager
Definition XrdSecPManager.hh:48
XrdSecProtNone
Definition XrdSecClient.cc:60

References XrdSecBuffer::buffer, DEBUG, DebugON, XrdSecPManager::Get(), XrdOucErrInfo::setErrInfo(), and XrdSecBuffer::size.

Referenced by main(), and XrdVERSIONINFO().

Here is the call graph for this function:
Here is the caller graph for this function: