22#include "RConfigure.h"
75 const char *details) :
TObject()
110 if (fHost.Contains(
":")) {
113 fHost.Remove(fHost.Index(
":"));
114 srv.Remove(0,
srv.Index(
":")+1);
115 }
else if (fHost.Contains(
"://")) {
118 fHost.Remove(0,fHost.Index(
"://")+3);
121 if (
srv ==
"0" ||
srv.BeginsWith(
"sock"))
123 else if (
srv ==
"1" ||
srv.BeginsWith(
"root"))
128 if (fHost !=
"default" && !fHost.Contains(
"*")) {
131 fHost =
addr.GetHostName();
147 if (fNumMethods > 0) {
150 for (i = 0; i <
kMAXSEC; i++) {
151 if (i < fNumMethods) {
164 if (fNumMethods > 0) {
165 for (i = 0; i < fNumMethods; i++) {
166 if (details && details[i] &&
strlen(details[i]) > 0) {
167 fDetails[i] = details[i];
171 fDetails[i] = (
const char *)
tmp;
178 fSecContexts =
new TList;
214 if (HasMethod(
meth)) {
215 SetDetails(
meth,details);
220 fMethods[fNumMethods] =
meth;
221 fSuccess[fNumMethods] = 0;
222 fFailure[fNumMethods] = 0;
223 if (details &&
strlen(details) > 0) {
224 fDetails[fNumMethods] = details;
228 fDetails[fNumMethods] = (
const char *)
tmp;
245 if (!HasMethod(
meth,&pos))
return;
249 for (; i < fNumMethods; i++) {
251 fMethods[k] = fMethods[i];
252 fSuccess[k] = fSuccess[i];
253 fFailure[k] = fFailure[i];
254 fDetails[k] = fDetails[i];
263 fMethods[fNumMethods] = -1;
264 fSuccess[fNumMethods] = -1;
265 fFailure[fNumMethods] = -1;
266 fDetails[fNumMethods].Resize(0);
279 for (; i < fNumMethods; i++) {
283 fDetails[i].Resize(0);
305 if (HasMethod(level,&i)) {
307 Info(
"GetDetails",
" %d: returning fDetails[%d]: %s",
308 level,i,fDetails[i].Data());
311 static const char *empty =
" ";
321 for (i = 0; i < fNumMethods; i++) {
322 if (fMethods[i] == level) {
337 if (HasMethod(level,&i)) {
338 if (details &&
strlen(details) > 0) {
339 fDetails[i] = details;
343 fDetails[i] = (
const char *)
tmp;
348 AddMethod(level, details);
357 char srvnam[4][8] = {
"any",
"sockd",
"rootd",
"???" };
363 "%s +------------------------------------------------------------------+",
proc);
364 Info(
"Print",
"%s + Host:%s - srv:%s - User:%s - # of available methods:%d",
367 for (i = 0; i < fNumMethods; i++){
368 Info(
"Print",
"%s + Method: %d (%s) Ok:%d Ko:%d Dets:%s",
proc,
370 fSuccess[i], fFailure[i], fDetails[i].Data());
373 "%s +------------------------------------------------------------------+",
proc);
381 Info(
"PrintEstablished",
382 "+------------------------------------------------------------------------------+");
383 Info(
"PrintEstablished",
"+ Host:%s - Number of active sec contexts: %d",
384 fHost.Data(), fSecContexts->GetSize());
387 if (fSecContexts->GetSize()>0) {
388 TIter next(fSecContexts);
397 Info(
"PrintEstablished",
398 "+------------------------------------------------------------------------------+");
417 if (HasMethod(
fmet[
j],&i)) {
431 Warning(
"ReOrder",
"Method id out of range (%d) - skipping",
fmet[
j]);
437 for(; i < fNumMethods; i++){
450 for (i = 0; i < fNumMethods; i++) {
475 for ( ; i < fNumMethods; i++) {
486 for(i = 0; i <
ha->NumMethods(); i++){
487 fMethods[i] =
ha->GetMethod(i);
488 fSuccess[i] =
ha->GetSuccess(i);
489 fFailure[i] =
ha->GetFailure(i);
490 fDetails[i] =
ha->GetDetailsByIdx(i);
494 fNumMethods =
ha->NumMethods();
500 fMethods[fNumMethods] =
tMethods[i];
501 fSuccess[fNumMethods] =
tSuccess[i];
502 fFailure[fNumMethods] =
tFailure[i];
503 fDetails[fNumMethods] =
tDetails[i];
517 if (HasMethod(
method,&i)) {
527 fMethods[
j] = fMethods[
j-1];
528 fSuccess[
j] = fSuccess[
j-1];
529 fFailure[
j] = fFailure[
j-1];
530 fDetails[
j] = fDetails[
j-1];
549 if (HasMethod(
method,&i)) {
558 for (;
j < (fNumMethods - 1);
j++) {
559 fMethods[
j] = fMethods[
j+1];
560 fSuccess[
j] = fSuccess[
j+1];
561 fFailure[
j] = fFailure[
j+1];
562 fDetails[
j] = fDetails[
j+1];
585 if (HasMethod(level,&i)) {
587 SetDetails(level, details);
595 for (i = fNumMethods; i > 0; i--) {
596 fMethods[i] = fMethods[i-1];
597 fSuccess[i] = fSuccess[i-1];
598 fFailure[i] = fFailure[i-1];
599 fDetails[i] = fDetails[i-1];
606 if (details &&
strlen(details) > 0) {
607 fDetails[0] = details;
611 fDetails[0] = (
const char *)
tmp;
628 for (i = 0; i < fNumMethods; i++) {
629 if (fMethods[i] ==
method) {
642 for (i = 0; i < fNumMethods; i++) {
643 if (fMethods[i] ==
method) {
657 const char *details,
const char *token,
663 fSecContexts->Add(ctx);
674 Out =
Form(
"h:%s u:%s n:%d",GetHost(),GetUser(),fNumMethods);
677 for (; i < fNumMethods; i++) {
678 Out +=
TString(
Form(
" '%d %s'",fMethods[i],fDetails[i].Data()));
const char Option_t
Option string (const char)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TSystem * gSystem
static char * GetDefaultDetails(Int_t method, Int_t opt, const char *user)
Determine default authentication details for method 'sec' and user 'usr'.
static const char * GetAuthMethod(Int_t idx)
Static method returning the method corresponding to idx.
void RemoveMethod(Int_t level)
Remove method 'meth' from the list, if there ...
void CountSuccess(Int_t level)
Count successes for 'method'.
TString fDetails[kMAXSEC]
THostAuth()
Default constructor.
virtual ~THostAuth()
The dtor.
void AsString(TString &out) const
Return a static string with all info in a serialized form.
void CountFailure(Int_t level)
Count failures for 'method'.
void AddMethod(Int_t level, const char *details=nullptr)
Add method to the list.
void Update(THostAuth *ha)
Update info with the one in ha Remaining methods, if any, get lower priority.
void Create(const char *host, const char *user, Int_t nmeth=0, Int_t *authmeth=nullptr, char **details=nullptr)
Create hostauth object.
void AddFirst(Int_t level, const char *details=nullptr)
Add new method in first position If already in the list, set as first method 'level' with authenticat...
const char * GetDetails(Int_t level)
Return authentication details for specified level or "" if the specified level does not exist for thi...
void SetFirst(Int_t level)
Set 'method' to be the first used (if in the list ...).
void ReOrder(Int_t nmet, Int_t *fmet)
Reorder nmet methods according fmet[nmet].
Bool_t HasMethod(Int_t level, Int_t *pos=nullptr)
Return kTRUE if method 'level' is in the list.
void Reset()
Remove all methods, leaving Active status and list of associted TSceContexts unchanged.
TRootSecContext * CreateSecContext(const char *user, const char *host, Int_t meth, Int_t offset, const char *details, const char *token, TDatime expdate=kROOTTZERO, void *ctx=nullptr, Int_t key=-1)
Create a Security context and add it to local list Return pointer to it to be stored in TAuthenticate...
void SetLast(Int_t level)
Set 'method' to be the last used (if in the list ...).
void SetDetails(Int_t level, const char *details)
Set authentication details for specified level.
void Print(Option_t *option="") const override
Print object content.
void PrintEstablished() const
Print info about established authentication vis-a-vis of this Host.
void Print(Option_t *option="F") const override
If opt is "F" (default) print object content.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
This class represents an Internet Protocol (IP) address.
Mother of all ROOT objects.
virtual const char * Getenv(const char *env)
Get environment variable.
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
This class represents a WWW compatible URL.
const char * GetProtocol() const