Logo ROOT   6.12/07
Reference Guide
THostAuth.h
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 #ifndef ROOT_THostAuth
13 #define ROOT_THostAuth
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // THostAuth //
19 // //
20 // Contains details about host-specific authentication methods and the //
21 // result of their application //
22 // Used by TAuthenticate //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 
26 #include "TObject.h"
27 #include "TString.h"
28 #include "TList.h"
29 #include "TRootSecContext.h"
30 #include "AuthConst.h"
31 
32 #include "TSecContext.h" // for kROOTTZERO.
33 
34 class THostAuth : public TObject {
35 
36 private:
37  TString fHost; // Host
38  Char_t fServer; // Server (kSOCKD,kROOTD,kPROOFD)
39  TString fUser; // Username
40  Int_t fNumMethods; // Number of AuthMethods
41  Int_t fMethods[kMAXSEC]; // AuthMethods
42  TString fDetails[kMAXSEC]; // AuthDetails
43  Int_t fSuccess[kMAXSEC]; // Statistics of successful attempts / per method
44  Int_t fFailure[kMAXSEC]; // Statistics of failed attempts / per method
45  Bool_t fActive; // Flag used in cleaning/reset
46 
47  TList *fSecContexts; // List of TSecContexts related to this THostAuth
48 
49  void Create(const char *host, const char *user, Int_t nmeth = 0,
50  Int_t *authmeth = 0, char **details = 0);
51 public:
52 
53  THostAuth();
54  THostAuth(const char *host, const char *user,
55  Int_t nmeth = 0, Int_t *authmeth = 0, char **details = 0);
56  THostAuth(const char *host, Int_t server, const char *user,
57  Int_t nmeth = 0, Int_t *authmeth = 0, char **details = 0);
58  THostAuth(const char *host, const char *user, Int_t authmeth,
59  const char *details);
60  THostAuth(const char *host, Int_t server, const char *user, Int_t authmeth,
61  const char *details);
62  THostAuth(const char *asstring);
63  THostAuth(THostAuth &ha);
64 
65  virtual ~THostAuth();
66 
67  void AsString(TString &out) const;
68 
69  Int_t NumMethods() const { return fNumMethods; }
70  Int_t GetMethod(Int_t idx) const { return fMethods[idx]; }
71  Bool_t HasMethod(Int_t level, Int_t *pos = 0);
72  void AddMethod(Int_t level, const char *details = 0);
73  void RemoveMethod(Int_t level);
74  void ReOrder(Int_t nmet, Int_t *fmet);
75  void Update(THostAuth *ha);
76  void SetFirst(Int_t level);
77  void AddFirst(Int_t level, const char *details = 0);
78  void SetLast(Int_t level);
79  void CountFailure(Int_t level);
80  void CountSuccess(Int_t level);
81  Int_t GetFailure(Int_t idx) const { return fFailure[idx]; }
82  Int_t GetSuccess(Int_t idx) const { return fSuccess[idx]; }
83  Bool_t IsActive() const { return fActive; }
84  void DeActivate() { fActive = kFALSE; }
85  void Activate() { fActive = kTRUE; }
86  void Reset();
87 
88  const char *GetDetails(Int_t level);
89  const char *GetDetailsByIdx(Int_t idx) const { return fDetails[idx]; }
90  void SetDetails(Int_t level, const char *details);
91 
92  const char *GetHost() const { return fHost; }
93  Int_t GetServer() const { return (Int_t)fServer; }
94  const char *GetUser() const { return fUser; }
95 
96  void SetHost(const char *host) { fHost = host; }
97  void SetServer(Int_t server) { fServer = (Char_t)server; }
98  void SetUser(const char *user) { fUser = user; }
99 
100  TList *Established() const { return fSecContexts; }
101  void SetEstablished(TList *nl) { fSecContexts = nl; }
102 
103  virtual void Print(Option_t *option = "") const;
104  void PrintEstablished() const;
105 
106  TRootSecContext *CreateSecContext(const char *user, const char *host, Int_t meth,
107  Int_t offset, const char *details,
108  const char *token, TDatime expdate = kROOTTZERO,
109  void *ctx = 0, Int_t key = -1);
110 
111  ClassDef(THostAuth,1) // Class providing host specific authentication information
112 };
113 
114 #endif
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
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
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:125
const Int_t kMAXSEC
Definition: AuthConst.h:26
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t GetServer() const
Definition: THostAuth.h:93
void CountFailure(Int_t level)
Count failures for 'method'.
Definition: THostAuth.cxx:710
Bool_t HasMethod(Int_t level, Int_t *pos=0)
Return kTRUE if method 'level' 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
void DeActivate()
Definition: THostAuth.h:84
Int_t fSuccess[kMAXSEC]
Definition: THostAuth.h:43
void CountSuccess(Int_t level)
Count successes for 'method'.
Definition: THostAuth.cxx:696
void SetServer(Int_t server)
Definition: THostAuth.h:97
#define ClassDef(name, id)
Definition: Rtypes.h:320
void SetEstablished(TList *nl)
Definition: THostAuth.h:101
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
A doubly linked list.
Definition: TList.h:44
TString fHost
Definition: THostAuth.h:37
void RemoveMethod(Int_t level)
Remove method 'meth' from the list, if there ...
Definition: THostAuth.cxx:312
Int_t GetFailure(Int_t idx) const
Definition: THostAuth.h:81
void AddMethod(Int_t level, const char *details=0)
Add method to the list.
Definition: THostAuth.cxx:279
void SetHost(const char *host)
Definition: THostAuth.h:96
const Bool_t kFALSE
Definition: RtypesCore.h:88
Int_t fNumMethods
Definition: THostAuth.h:40
void SetUser(const char *user)
Definition: THostAuth.h:98
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
const char * GetHost() const
Definition: THostAuth.h:92
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
const TDatime kROOTTZERO
Definition: TSecContext.h:30
Mother of all ROOT objects.
Definition: TObject.h:37
Bool_t IsActive() const
Definition: THostAuth.h:83
char Char_t
Definition: RtypesCore.h:29
virtual ~THostAuth()
The dtor.
Definition: THostAuth.cxx:364
void SetFirst(Int_t level)
Set 'method' to be the first used (if in the list ...).
Definition: THostAuth.cxx:585
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
void SetLast(Int_t level)
Set 'method' to be the last used (if in the list ...).
Definition: THostAuth.cxx:617
void AddFirst(Int_t level, const char *details=0)
Add new method in first position If already in the list, set as first method 'level' 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
Char_t fServer
Definition: THostAuth.h:38
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
void Activate()
Definition: THostAuth.h:85
void Reset()
Remove all methods, leaving Active status and list of associted TSceContexts unchanged.
Definition: THostAuth.cxx:346