Logo ROOT   6.14/05
Reference Guide
THostAuth.cxx
Go to the documentation of this file.
1 // @(#)root/auth:$Id$
2 // Author: G. Ganis 19/03/2003
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // THostAuth //
15 // //
16 // Contains details about host-specific authentication methods and the //
17 // result of their application. //
18 // Used by TAuthenticate. //
19 // //
20 //////////////////////////////////////////////////////////////////////////
21 
22 #include "RConfigure.h"
23 #include "TSystem.h"
24 #include "THostAuth.h"
25 #include "TRootSecContext.h"
26 #include "TAuthenticate.h"
27 #include "TSocket.h"
28 #include "TUrl.h"
29 #include <stdlib.h>
30 
31 
33 
34 ////////////////////////////////////////////////////////////////////////////////
35 /// Default constructor.
36 
38 {
39  Create(0, 0);
40 }
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Create hostauth object.
44 /// 'host' may contain also the server for whicb these directives
45 /// are valid in the form 'host:server' or 'server://host'
46 /// with server either "sock[d]", "root[d]", "proof[d]" or
47 /// 0, 1, 2, respectively.
48 
49 THostAuth::THostAuth(const char *host, const char *user, Int_t nmeth,
50  Int_t *authmeth, char **details) : TObject()
51 {
52  Create(host, user, nmeth, authmeth, details);
53 }
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// Create hostauth object.
57 /// 'host' may contain also the server for whicb these directives
58 /// are valid in the form 'host:server' or 'server://host'
59 /// with server either "sock[d]", "root[d]", "proof[d]" or
60 /// 0, 1, 2, respectively.
61 
62 THostAuth::THostAuth(const char *host, Int_t server, const char *user,
63  Int_t nmeth, Int_t *authmeth, char **details) : TObject()
64 {
65  Create(host, user, nmeth, authmeth, details);
66 
67  fServer = server;
68 }
69 
70 ////////////////////////////////////////////////////////////////////////////////
71 /// Create hostauth object with one method only.
72 /// 'host' may contain also the server for whicb these directives
73 /// are valid in the form 'host:server' or 'server://host'
74 
75 THostAuth::THostAuth(const char *host, const char *user, Int_t authmeth,
76  const char *details) : TObject()
77 {
78  Create(host, user, 1, &authmeth, (char **)&details);
79 }
80 
81 ////////////////////////////////////////////////////////////////////////////////
82 /// Create hostauth object with one method only.
83 /// 'host' may contain also the server for whicb these directives
84 /// are valid in the form 'host:server' or 'server://host'
85 
86 THostAuth::THostAuth(const char *host, Int_t server, const char *user,
87  Int_t authmeth, const char *details) : TObject()
88 {
89  Create(host, user, 1, &authmeth, (char **)&details);
90  fServer = server;
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Create hostauth object.
95 /// 'host' may contain also the server for whicb these directives
96 /// are valid in the form 'host:server' or 'server://host'
97 /// with server either "sock[d]", "root[d]", "proof[d]" or
98 /// 0, 1, 2, respectively.
99 
100 void THostAuth::Create(const char *host, const char *user, Int_t nmeth,
101  Int_t *authmeth, char **details)
102 {
103  int i;
104 
105  // Host
106  fHost = host;
107 
108  fServer = -1;
109  // Extract server, if given
110  TString srv("");
111  if (fHost.Contains(":")) {
112  // .rootauthrc form: host:server
113  srv = fHost;
114  fHost.Remove(fHost.Index(":"));
115  srv.Remove(0,srv.Index(":")+1);
116  } else if (fHost.Contains("://")) {
117  // Url form: server://host
118  srv = TUrl(fHost).GetProtocol();
119  fHost.Remove(0,fHost.Index("://")+3);
120  }
121  if (srv.Length()) {
122  if (srv == "0" || srv.BeginsWith("sock"))
124  else if (srv == "1" || srv.BeginsWith("root"))
126  else if (srv == "2" || srv.BeginsWith("proof"))
128  }
129 
130  // Check and save the host FQDN ...
131  if (fHost != "default" && !fHost.Contains("*")) {
133  if (addr.IsValid())
134  fHost = addr.GetHostName();
135  }
136 
137  // User
138  fUser = user;
139  if (fUser == "")
140  fUser = gSystem->Getenv("USER");
141  if (fUser == "") {
143  if (u)
144  fUser = u->fUser;
145  delete u;
146  }
147 
148  // Methods indexes
149  fNumMethods = nmeth;
150  if (fNumMethods > 0) {
151  if (!authmeth)
152  fNumMethods = 0;
153  for (i = 0; i < kMAXSEC; i++) {
154  if (i < fNumMethods) {
155  fMethods[i] = authmeth[i];
156  fSuccess[i] = 0;
157  fFailure[i] = 0;
158  } else {
159  fMethods[i] = -1;
160  fSuccess[i] = -1;
161  fFailure[i] = -1;
162  }
163  }
164  }
165 
166  // Method details
167  if (fNumMethods > 0) {
168  for (i = 0; i < fNumMethods; i++) {
169  if (details && details[i] && strlen(details[i]) > 0) {
170  fDetails[i] = details[i];
171  } else {
172  // Use default instead
174  fDetails[i] = (const char *)tmp;
175  delete[] tmp;
176  }
177  }
178  }
179 
180  // List of TSecContext
181  fSecContexts = new TList;
182 
183  // Active when created
184  fActive = kTRUE;
185 }
186 
187 
188 ////////////////////////////////////////////////////////////////////////////////
189 /// Create hostauth object from directives given as a compact string
190 /// See THostAuth::AsString().
191 /// Used in proof context only; fServer not set; to be set by hand
192 /// with SetServer() method if really needed
193 
194 THostAuth::THostAuth(const char *asstring) : TObject()
195 {
196  fServer = -1;
197 
198  TString strtmp(asstring);
199  char *tmp = new char[strlen(asstring)+1];
200  strncpy(tmp,asstring,strlen(asstring));
201  tmp[strlen(asstring)] = 0;
202 
203  fHost = TString((const char *)strtok(tmp," "));
204  strtmp.ReplaceAll(fHost,"");
205  fHost.Remove(0,fHost.Index(":")+1);
206 
207  fUser = TString((const char *)strtok(0," "));
208  strtmp.ReplaceAll(fUser,"");
209  fUser.Remove(0,fUser.Index(":")+1);
210 
211  TString fNmet;
212  fNmet = TString((const char *)strtok(0," "));
213  strtmp.ReplaceAll(fNmet,"");
214  fNmet.Remove(0,fNmet.Index(":")+1);
215 
216  delete[] tmp;
217 
218  fNumMethods = atoi(fNmet.Data());
219  Int_t i = 0;
220  for (; i < fNumMethods; i++) {
221  TString det = strtmp;
222  det.Remove(0,det.Index("'")+1);
223  det.Resize(det.Index("'"));
224  // Remove leading spaces, if
225  char cmet[20];
226  sscanf(det.Data(),"%10s",cmet);
227  Int_t met = atoi(cmet);
228  if (met > -1 && met < kMAXSEC) {
229  det.ReplaceAll(cmet,"");
230  while (det.First(' ') == 0)
231  det.Remove(0,1);
232  while (det.Last(' ') == (det.Length() - 1))
233  det.Resize(det.Length() - 1);
234  fMethods[i] = met;
235  fSuccess[i] = 0;
236  fFailure[i] = 0;
237  fDetails[i] = det;
238  }
239  strtmp.Remove(0,strtmp.Index("'",strtmp.Index("'")+1)+1);
240  }
241  for (i = fNumMethods; i < kMAXSEC ; i++) {
242  fMethods[i] = -1;
243  fSuccess[i] = -1;
244  fFailure[i] = -1;
245  }
246 
247  // List of TSecContext
248  fSecContexts = new TList;
249 
250  // Active when created
251  fActive = kTRUE;
252 }
253 
254 
255 ////////////////////////////////////////////////////////////////////////////////
256 /// Copy ctor ...
257 
259 {
260  fHost = ha.fHost;
261  fServer = ha.fServer;
262  fUser = ha.fUser;
264  Int_t i = 0;
265  for (; i < kMAXSEC; i++) {
266  fMethods[i] = ha.fMethods[i];
267  fSuccess[i] = ha.fSuccess[i];
268  fFailure[i] = ha.fFailure[i];
269  fDetails[i] = ha.fDetails[i];
270  }
271  fSecContexts = ha.Established();
272  fActive = ha.fActive;
273 }
274 
275 ////////////////////////////////////////////////////////////////////////////////
276 /// Add method to the list. If already there, change its
277 /// details to 'details'
278 
279 void THostAuth::AddMethod(Int_t meth, const char *details)
280 {
281  // Check 'meth'
282  if (meth < 0 || meth >= kMAXSEC) return;
283 
284  // If already there, set details and return
285  if (HasMethod(meth)) {
286  SetDetails(meth,details);
287  return;
288  }
289 
290  // This is a new method
291  fMethods[fNumMethods] = meth;
292  fSuccess[fNumMethods] = 0;
293  fFailure[fNumMethods] = 0;
294  if (details && strlen(details) > 0) {
295  fDetails[fNumMethods] = details;
296  } else {
297  // Use default instead
298  char *tmp = TAuthenticate::GetDefaultDetails(meth,0,fUser);
299  fDetails[fNumMethods] = (const char *)tmp;
300  delete[] tmp;
301  }
302 
303  // Increment total number
304  fNumMethods++;
305 
306  if (gDebug > 3) Print();
307 }
308 
309 ////////////////////////////////////////////////////////////////////////////////
310 /// Remove method 'meth' from the list, if there ...
311 
313 {
314  // If we don't have it, nothing to do
315  Int_t pos = -1;
316  if (!HasMethod(meth,&pos)) return;
317 
318  // Now rescale info
319  Int_t i = 0, k = 0;
320  for (; i < fNumMethods; i++) {
321  if (i != pos) {
322  fMethods[k] = fMethods[i];
323  fSuccess[k] = fSuccess[i];
324  fFailure[k] = fFailure[i];
325  fDetails[k] = fDetails[i];
326  k++;
327  }
328  }
329 
330  // Decrement total number
331  fNumMethods--;
332 
333  // Free last position
334  fMethods[fNumMethods] = -1;
335  fSuccess[fNumMethods] = -1;
336  fFailure[fNumMethods] = -1;
338 
339  if (gDebug > 3) Print();
340 }
341 
342 ////////////////////////////////////////////////////////////////////////////////
343 /// Remove all methods, leaving Active status and
344 /// list of associted TSceContexts unchanged
345 
347 {
348  // Free all filled positions
349  Int_t i = 0;
350  for (; i < fNumMethods; i++) {
351  fMethods[i] = -1;
352  fSuccess[i] = -1;
353  fFailure[i] = -1;
354  fDetails[i].Resize(0);
355  }
356 
357  // Set total number to 0
358  fNumMethods = 0;
359 }
360 
361 ////////////////////////////////////////////////////////////////////////////////
362 /// The dtor.
363 
365 {
366  delete fSecContexts;
367 }
368 
369 ////////////////////////////////////////////////////////////////////////////////
370 /// Return authentication details for specified level
371 /// or "" if the specified level does not exist for this host.
372 
373 const char *THostAuth::GetDetails(Int_t level)
374 {
375  Int_t i = -1;
376  if (HasMethod(level,&i)) {
377  if (gDebug > 3)
378  Info("GetDetails"," %d: returning fDetails[%d]: %s",
379  level,i,fDetails[i].Data());
380  return fDetails[i];
381  }
382  static const char *empty = " ";
383  return empty;
384 }
385 
386 ////////////////////////////////////////////////////////////////////////////////
387 /// Return kTRUE if method 'level' is in the list
388 
390 {
391  int i;
392  for (i = 0; i < fNumMethods; i++) {
393  if (fMethods[i] == level) {
394  if (pos) *pos = i;
395  return kTRUE;
396  }
397  }
398  if (pos) *pos = -1;
399  return kFALSE;
400 }
401 
402 ////////////////////////////////////////////////////////////////////////////////
403 /// Set authentication details for specified level.
404 
405 void THostAuth::SetDetails(Int_t level, const char *details)
406 {
407  Int_t i = -1;
408  if (HasMethod(level,&i)) {
409  if (details && strlen(details) > 0) {
410  fDetails[i] = details;
411  } else {
412  // Use default instead
413  char *tmp = TAuthenticate::GetDefaultDetails(level,0,fUser);
414  fDetails[i] = (const char *)tmp;
415  delete[] tmp;
416  }
417  } else {
418  // Add new method ...
419  AddMethod(level, details);
420  }
421 }
422 
423 ////////////////////////////////////////////////////////////////////////////////
424 /// Print object content.
425 
426 void THostAuth::Print(Option_t *proc) const
427 {
428  char srvnam[5][8] = { "any", "sockd", "rootd", "proofd", "???" };
429 
430  Int_t isrv = (fServer >= -1 && fServer <= TSocket::kPROOFD) ?
432 
433  Info("Print",
434  "%s +------------------------------------------------------------------+",proc);
435  Info("Print","%s + Host:%s - srv:%s - User:%s - # of available methods:%d",
436  proc, fHost.Data(), srvnam[isrv], fUser.Data(), fNumMethods);
437  int i = 0;
438  for (i = 0; i < fNumMethods; i++){
439  Info("Print","%s + Method: %d (%s) Ok:%d Ko:%d Dets:%s", proc,
441  fSuccess[i], fFailure[i], fDetails[i].Data());
442  }
443  Info("Print",
444  "%s +------------------------------------------------------------------+",proc);
445 }
446 
447 ////////////////////////////////////////////////////////////////////////////////
448 /// Print info about established authentication vis-a-vis of this Host.
449 
451 {
452  Info("PrintEstablished",
453  "+------------------------------------------------------------------------------+");
454  Info("PrintEstablished","+ Host:%s - Number of active sec contexts: %d",
456 
457  // Check list
458  if (fSecContexts->GetSize()>0) {
459  TIter next(fSecContexts);
460  TSecContext *ctx = 0;
461  Int_t k = 1;
462  while ((ctx = (TSecContext *) next())) {
463  TString opt;
464  opt += k++;
465  ctx->Print(opt);
466  }
467  }
468  Info("PrintEstablished",
469  "+------------------------------------------------------------------------------+");
470 }
471 
472 ////////////////////////////////////////////////////////////////////////////////
473 /// Reorder nmet methods according fmet[nmet]
474 
475 void THostAuth::ReOrder(Int_t nmet, Int_t *fmet)
476 {
477  // Temporary arrays
478  Int_t tMethods[kMAXSEC] = {0};
479  Int_t tSuccess[kMAXSEC] = {0};
480  Int_t tFailure[kMAXSEC] = {0};
481  TString tDetails[kMAXSEC];
482  Int_t flag[kMAXSEC] = {0};
483 
484  // Copy info in the new order
485  Int_t j = 0;
486  for ( ; j < nmet; j++) {
487  Int_t i = -1;
488  if (HasMethod(fmet[j],&i)) {
489  tMethods[j] = fMethods[i];
490  tSuccess[j] = fSuccess[i];
491  tFailure[j] = fFailure[i];
492  tDetails[j] = fDetails[i];
493  flag[i]++;
494  } else if (fmet[j] >= 0 && fmet[j] < kMAXSEC) {
495  tMethods[j] = fmet[j];
496  tSuccess[j] = 0;
497  tFailure[j] = 0;
498  char *tmp = TAuthenticate::GetDefaultDetails(fmet[j],0,fUser);
499  tDetails[j] = (const char *)tmp;
500  delete[] tmp;
501  } else {
502  Warning("ReOrder","Method id out of range (%d) - skipping",fmet[j]);
503  }
504  }
505 
506  // Add existing methods not listed ... if any
507  Int_t k = nmet, i = 0;
508  for(; i < fNumMethods; i++){
509  if (flag[i] == 0) {
510  tMethods[k] = fMethods[i];
511  tSuccess[k] = fSuccess[i];
512  tFailure[k] = fFailure[i];
513  tDetails[k] = fDetails[i];
514  k++;
515  flag[i] = 1;
516  }
517  }
518 
519  // Restore from temporary
520  fNumMethods = k;
521  for (i = 0; i < fNumMethods; i++) {
522  fMethods[i] = tMethods[i];
523  fSuccess[i] = tSuccess[i];
524  fFailure[i] = tFailure[i];
525  fDetails[i] = tDetails[i];
526  }
527 
528  if (gDebug > 3) Print();
529 }
530 
531 ////////////////////////////////////////////////////////////////////////////////
532 /// Update info with the one in ha
533 /// Remaining methods, if any, get lower priority
534 
536 {
537  // Temporary arrays
538  Int_t tNumMethods = fNumMethods;
539  Int_t tMethods[kMAXSEC];
540  Int_t tSuccess[kMAXSEC];
541  Int_t tFailure[kMAXSEC];
542  TString tDetails[kMAXSEC];
543 
544  // Save existing info in temporary arrays
545  Int_t i = 0;
546  for ( ; i < fNumMethods; i++) {
547  tMethods[i] = fMethods[i];
548  tSuccess[i] = fSuccess[i];
549  tFailure[i] = fFailure[i];
550  tDetails[i] = fDetails[i];
551  }
552 
553  // Reset
554  Reset();
555 
556  // Get ha content in
557  for(i = 0; i < ha->NumMethods(); i++){
558  fMethods[i] = ha->GetMethod(i);
559  fSuccess[i] = ha->GetSuccess(i);
560  fFailure[i] = ha->GetFailure(i);
561  fDetails[i] = ha->GetDetailsByIdx(i);
562  }
563 
564  // Set new tmp size
565  fNumMethods = ha->NumMethods();
566 
567  // Add remaining methods with low priority
568  if (fNumMethods < kMAXSEC) {
569  for (i = 0; i < tNumMethods; i++) {
570  if (!HasMethod(tMethods[i]) && fNumMethods < kMAXSEC) {
571  fMethods[fNumMethods] = tMethods[i];
572  fSuccess[fNumMethods] = tSuccess[i];
573  fFailure[fNumMethods] = tFailure[i];
574  fDetails[fNumMethods] = tDetails[i];
575  fNumMethods++;
576  }
577  }
578  }
579  if (gDebug > 3) Print();
580 }
581 
582 ////////////////////////////////////////////////////////////////////////////////
583 /// Set 'method' to be the first used (if in the list ...).
584 
586 {
587  Int_t i = -1;
588  if (HasMethod(method,&i)) {
589 
590  Int_t tMe = fMethods[i];
591  Int_t tSu = fSuccess[i];
592  Int_t tFa = fFailure[i];
593  TString tDe = fDetails[i];
594 
595  // Rescale methods
596  Int_t j = i;
597  for (; j > 0; j--) {
598  fMethods[j] = fMethods[j-1];
599  fSuccess[j] = fSuccess[j-1];
600  fFailure[j] = fFailure[j-1];
601  fDetails[j] = fDetails[j-1];
602  }
603 
604  // The saved method first
605  fMethods[0] = tMe;
606  fSuccess[0] = tSu;
607  fFailure[0] = tFa;
608  fDetails[0] = tDe;
609  }
610 
611  if (gDebug > 3) Print();
612 }
613 
614 ////////////////////////////////////////////////////////////////////////////////
615 /// Set 'method' to be the last used (if in the list ...).
616 
618 {
619  Int_t i = -1;
620  if (HasMethod(method,&i)) {
621 
622  Int_t tMe = fMethods[i];
623  Int_t tSu = fSuccess[i];
624  Int_t tFa = fFailure[i];
625  TString tDe = fDetails[i];
626 
627  // Rescale methods
628  Int_t j = i;
629  for (; j < (fNumMethods - 1); j++) {
630  fMethods[j] = fMethods[j+1];
631  fSuccess[j] = fSuccess[j+1];
632  fFailure[j] = fFailure[j+1];
633  fDetails[j] = fDetails[j+1];
634  }
635 
636  // The saved method first
637  Int_t lp = fNumMethods - 1;
638  fMethods[lp] = tMe;
639  fSuccess[lp] = tSu;
640  fFailure[lp] = tFa;
641  fDetails[lp] = tDe;
642  }
643 
644  if (gDebug > 3) Print();
645 }
646 
647 ////////////////////////////////////////////////////////////////////////////////
648 /// Add new method in first position
649 /// If already in the list, set as first method 'level' with
650 /// authentication 'details'.
651 /// Faster then AddMethod(method,details)+SetFirst(method).
652 
653 void THostAuth::AddFirst(Int_t level, const char *details)
654 {
655  Int_t i = -1;
656  if (HasMethod(level,&i)) {
657  if (i > 0) {
658  SetDetails(level, details);
659  SetFirst(level);
660  }
661  if (gDebug > 3) Print();
662  return;
663  }
664 
665  // Rescale methods
666  for (i = fNumMethods; i > 0; i--) {
667  fMethods[i] = fMethods[i-1];
668  fSuccess[i] = fSuccess[i-1];
669  fFailure[i] = fFailure[i-1];
670  fDetails[i] = fDetails[i-1];
671  }
672 
673  // This method first
674  fMethods[0] = level;
675  fSuccess[0] = 0;
676  fFailure[0] = 0;
677  if (details && strlen(details) > 0) {
678  fDetails[0] = details;
679  } else {
680  // Use default instead
681  char *tmp = TAuthenticate::GetDefaultDetails(level,0,fUser);
682  fDetails[0] = (const char *)tmp;
683  delete[] tmp;
684  }
685 
686  // Increment total number
687  fNumMethods++;
688 
689  if (gDebug > 3) Print();
690 }
691 
692 
693 ////////////////////////////////////////////////////////////////////////////////
694 /// Count successes for 'method'
695 
697 {
698  int i;
699  for (i = 0; i < fNumMethods; i++) {
700  if (fMethods[i] == method) {
701  fSuccess[i]++;
702  break;
703  }
704  }
705 }
706 
707 ////////////////////////////////////////////////////////////////////////////////
708 /// Count failures for 'method'
709 
711 {
712  int i;
713  for (i = 0; i < fNumMethods; i++) {
714  if (fMethods[i] == method) {
715  fFailure[i]++;
716  break;
717  }
718  }
719 }
720 
721 ////////////////////////////////////////////////////////////////////////////////
722 /// Create a Security context and add it to local list
723 /// Return pointer to it to be stored in TAuthenticate
724 
725 TRootSecContext *THostAuth::CreateSecContext(const char *user, const char *host,
726  Int_t meth, Int_t offset,
727  const char *details, const char *token,
728  TDatime expdate, void *sctx, Int_t key)
729 {
730  TRootSecContext *ctx = new TRootSecContext(user, host, meth, offset, details,
731  token, expdate, sctx, key);
732  // Add it also to the local list if active
733  if (ctx->IsActive())
734  fSecContexts->Add(ctx);
735 
736  return ctx;
737 
738 }
739 
740 ////////////////////////////////////////////////////////////////////////////////
741 /// Return a static string with all info in a serialized form
742 
743 void THostAuth::AsString(TString &Out) const
744 {
745  Out = Form("h:%s u:%s n:%d",GetHost(),GetUser(),fNumMethods);
746 
747  Int_t i = 0;
748  for (; i < fNumMethods; i++) {
749  Out += TString(Form(" '%d %s'",fMethods[i],fDetails[i].Data()));
750  }
751 
752 }
void SetDetails(Int_t level, const char *details)
Set authentication details for specified level.
Definition: THostAuth.cxx:405
TString fDetails[kMAXSEC]
Definition: THostAuth.h:42
void AsString(TString &out) const
Return a static string with all info in a serialized form.
Definition: THostAuth.cxx:743
THostAuth()
Default constructor.
Definition: THostAuth.cxx:37
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:854
void PrintEstablished() const
Print info about established authentication vis-a-vis of this Host.
Definition: THostAuth.cxx:450
const char Option_t
Definition: RtypesCore.h:62
Bool_t fActive
Definition: THostAuth.h:45
virtual void Print(Option_t *option="F") const
If opt is "F" (default) print object content.
const char * GetHostName() const
Definition: TInetAddress.h:71
This class represents a WWW compatible URL.
Definition: TUrl.h:35
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:687
const char * GetProtocol() const
Definition: TUrl.h:67
This class represents an Internet Protocol (IP) address.
Definition: TInetAddress.h:36
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:634
const char * GetDetails(Int_t level)
Return authentication details for specified level or "" if the specified level does not exist for thi...
Definition: THostAuth.cxx:373
Int_t fMethods[kMAXSEC]
Definition: THostAuth.h:41
Basic string class.
Definition: TString.h:131
const Int_t kMAXSEC
Definition: AuthConst.h:26
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
static char * GetDefaultDetails(Int_t method, Int_t opt, const char *user)
Determine default authentication details for method &#39;sec&#39; and user &#39;usr&#39;.
void CountFailure(Int_t level)
Count failures for &#39;method&#39;.
Definition: THostAuth.cxx:710
Bool_t HasMethod(Int_t level, Int_t *pos=0)
Return kTRUE if method &#39;level&#39; is in the list.
Definition: THostAuth.cxx:389
const char * GetUser() const
Definition: THostAuth.h:94
Int_t GetSuccess(Int_t idx) const
Definition: THostAuth.h:82
Int_t fSuccess[kMAXSEC]
Definition: THostAuth.h:43
void CountSuccess(Int_t level)
Count successes for &#39;method&#39;.
Definition: THostAuth.cxx:696
Bool_t IsActive() const
Check remote OffSet and expiring Date.
void Create(const char *host, const char *user, Int_t nmeth=0, Int_t *authmeth=0, char **details=0)
Create hostauth object.
Definition: THostAuth.cxx:100
Int_t NumMethods() const
Definition: THostAuth.h:69
TList * Established() const
Definition: THostAuth.h:100
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1638
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
Definition: TSystem.cxx:1574
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition: TString.cxx:487
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
Definition: TSystem.cxx:2320
A doubly linked list.
Definition: TList.h:44
TString fHost
Definition: THostAuth.h:37
void RemoveMethod(Int_t level)
Remove method &#39;meth&#39; from the list, if there ...
Definition: THostAuth.cxx:312
Int_t GetFailure(Int_t idx) const
Definition: THostAuth.h:81
TString fUser
Definition: TSystem.h:142
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:610
char * Form(const char *fmt,...)
Ssiz_t Length() const
Definition: TString.h:405
void AddMethod(Int_t level, const char *details=0)
Add method to the list.
Definition: THostAuth.cxx:279
const Bool_t kFALSE
Definition: RtypesCore.h:88
Int_t fNumMethods
Definition: THostAuth.h:40
TString & Remove(Ssiz_t pos)
Definition: TString.h:668
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=0, Int_t key=-1)
Create a Security context and add it to local list Return pointer to it to be stored in TAuthenticate...
Definition: THostAuth.cxx:725
#define ClassImp(name)
Definition: Rtypes.h:359
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition: TString.cxx:876
const char * GetHost() const
Definition: THostAuth.h:92
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
Int_t GetMethod(Int_t idx) const
Definition: THostAuth.h:70
Int_t fFailure[kMAXSEC]
Definition: THostAuth.h:44
void ReOrder(Int_t nmet, Int_t *fmet)
Reorder nmet methods according fmet[nmet].
Definition: THostAuth.cxx:475
TList * fSecContexts
Definition: THostAuth.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
Bool_t IsValid() const
Definition: TInetAddress.h:76
virtual ~THostAuth()
The dtor.
Definition: THostAuth.cxx:364
void SetFirst(Int_t level)
Set &#39;method&#39; to be the first used (if in the list ...).
Definition: THostAuth.cxx:585
virtual void Add(TObject *obj)
Definition: TList.h:87
void Update(THostAuth *ha)
Update info with the one in ha Remaining methods, if any, get lower priority.
Definition: THostAuth.cxx:535
const char * GetDetailsByIdx(Int_t idx) const
Definition: THostAuth.h:89
R__EXTERN Int_t gDebug
Definition: Rtypes.h:86
void SetLast(Int_t level)
Set &#39;method&#39; to be the last used (if in the list ...).
Definition: THostAuth.cxx:617
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
void AddFirst(Int_t level, const char *details=0)
Add new method in first position If already in the list, set as first method &#39;level&#39; with authenticat...
Definition: THostAuth.cxx:653
virtual void Print(Option_t *option="") const
Print object content.
Definition: THostAuth.cxx:426
const Bool_t kTRUE
Definition: RtypesCore.h:87
TString fUser
Definition: THostAuth.h:39
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
Char_t fServer
Definition: THostAuth.h:38
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Definition: TString.cxx:1070
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
const char * Data() const
Definition: TString.h:364
static const char * GetAuthMethod(Int_t idx)
Static method returning the method corresponding to idx.
void Reset()
Remove all methods, leaving Active status and list of associted TSceContexts unchanged.
Definition: THostAuth.cxx:346