Logo ROOT   6.07/09
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 #ifndef ROOT_TObject
27 #include "TObject.h"
28 #endif
29 #ifndef ROOT_TString
30 #include "TString.h"
31 #endif
32 #ifndef ROOT_TList
33 #include "TList.h"
34 #endif
35 #ifndef ROOT_TRootSecContext
36 #include "TRootSecContext.h"
37 #endif
38 #ifndef ROOT_AuthConst
39 #include "AuthConst.h"
40 #endif
41 
42 
43 
44 class THostAuth : public TObject {
45 
46 private:
47  TString fHost; // Host
48  Char_t fServer; // Server (kSOCKD,kROOTD,kPROOFD)
49  TString fUser; // Username
50  Int_t fNumMethods; // Number of AuthMethods
51  Int_t fMethods[kMAXSEC]; // AuthMethods
52  TString fDetails[kMAXSEC]; // AuthDetails
53  Int_t fSuccess[kMAXSEC]; // Statistics of successful attempts / per method
54  Int_t fFailure[kMAXSEC]; // Statistics of failed attempts / per method
55  Bool_t fActive; // Flag used in cleaning/reset
56 
57  TList *fSecContexts; // List of TSecContexts related to this THostAuth
58 
59  void Create(const char *host, const char *user, Int_t nmeth = 0,
60  Int_t *authmeth = 0, char **details = 0);
61 public:
62 
63  THostAuth();
64  THostAuth(const char *host, const char *user,
65  Int_t nmeth = 0, Int_t *authmeth = 0, char **details = 0);
66  THostAuth(const char *host, Int_t server, const char *user,
67  Int_t nmeth = 0, Int_t *authmeth = 0, char **details = 0);
68  THostAuth(const char *host, const char *user, Int_t authmeth,
69  const char *details);
70  THostAuth(const char *host, Int_t server, const char *user, Int_t authmeth,
71  const char *details);
72  THostAuth(const char *asstring);
73  THostAuth(THostAuth &ha);
74 
75  virtual ~THostAuth();
76 
77  void AsString(TString &out) const;
78 
79  Int_t NumMethods() const { return fNumMethods; }
80  Int_t GetMethod(Int_t idx) const { return fMethods[idx]; }
81  Bool_t HasMethod(Int_t level, Int_t *pos = 0);
82  void AddMethod(Int_t level, const char *details = 0);
83  void RemoveMethod(Int_t level);
84  void ReOrder(Int_t nmet, Int_t *fmet);
85  void Update(THostAuth *ha);
86  void SetFirst(Int_t level);
87  void AddFirst(Int_t level, const char *details = 0);
88  void SetLast(Int_t level);
89  void CountFailure(Int_t level);
90  void CountSuccess(Int_t level);
91  Int_t GetFailure(Int_t idx) const { return fFailure[idx]; }
92  Int_t GetSuccess(Int_t idx) const { return fSuccess[idx]; }
93  Bool_t IsActive() const { return fActive; }
94  void DeActivate() { fActive = kFALSE; }
95  void Activate() { fActive = kTRUE; }
96  void Reset();
97 
98  const char *GetDetails(Int_t level);
99  const char *GetDetailsByIdx(Int_t idx) const { return fDetails[idx]; }
100  void SetDetails(Int_t level, const char *details);
101 
102  const char *GetHost() const { return fHost; }
103  Int_t GetServer() const { return (Int_t)fServer; }
104  const char *GetUser() const { return fUser; }
105 
106  void SetHost(const char *host) { fHost = host; }
107  void SetServer(Int_t server) { fServer = (Char_t)server; }
108  void SetUser(const char *user) { fUser = user; }
109 
110  TList *Established() const { return fSecContexts; }
111  void SetEstablished(TList *nl) { fSecContexts = nl; }
112 
113  virtual void Print(Option_t *option = "") const;
114  void PrintEstablished() const;
115 
116  TRootSecContext *CreateSecContext(const char *user, const char *host, Int_t meth,
117  Int_t offset, const char *details,
118  const char *token, TDatime expdate = kROOTTZERO,
119  void *ctx = 0, Int_t key = -1);
120 
121  ClassDef(THostAuth,1) // Class providing host specific authentication information
122 };
123 
124 #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:52
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:55
void AsString(TString &out) const
Return a static string with all info in a serialized form.
Definition: THostAuth.cxx:743
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:51
Basic string class.
Definition: TString.h:137
const Int_t kMAXSEC
Definition: AuthConst.h:28
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
void CountFailure(Int_t level)
Count failures for 'method'.
Definition: THostAuth.cxx:710
Bool_t IsActive() const
Definition: THostAuth.h:93
Bool_t HasMethod(Int_t level, Int_t *pos=0)
Return kTRUE if method 'level' is in the list.
Definition: THostAuth.cxx:389
void DeActivate()
Definition: THostAuth.h:94
Int_t fSuccess[kMAXSEC]
Definition: THostAuth.h:53
void CountSuccess(Int_t level)
Count successes for 'method'.
Definition: THostAuth.cxx:696
Int_t NumMethods() const
Definition: THostAuth.h:79
void SetServer(Int_t server)
Definition: THostAuth.h:107
const char * GetHost() const
Definition: THostAuth.h:102
#define ClassDef(name, id)
Definition: Rtypes.h:254
void SetEstablished(TList *nl)
Definition: THostAuth.h:111
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
A doubly linked list.
Definition: TList.h:47
TList * Established() const
Definition: THostAuth.h:110
TString fHost
Definition: THostAuth.h:47
void RemoveMethod(Int_t level)
Remove method 'meth' from the list, if there ...
Definition: THostAuth.cxx:312
Int_t GetServer() const
Definition: THostAuth.h:103
void AddMethod(Int_t level, const char *details=0)
Add method to the list.
Definition: THostAuth.cxx:279
Int_t GetSuccess(Int_t idx) const
Definition: THostAuth.h:92
void SetHost(const char *host)
Definition: THostAuth.h:106
Int_t fNumMethods
Definition: THostAuth.h:50
const char * GetDetailsByIdx(Int_t idx) const
Definition: THostAuth.h:99
void SetUser(const char *user)
Definition: THostAuth.h:108
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 * GetUser() const
Definition: THostAuth.h:104
Int_t fFailure[kMAXSEC]
Definition: THostAuth.h:54
void ReOrder(Int_t nmet, Int_t *fmet)
Reorder nmet methods according fmet[nmet].
Definition: THostAuth.cxx:475
TList * fSecContexts
Definition: THostAuth.h:57
const TDatime kROOTTZERO
Definition: TSecContext.h:36
Mother of all ROOT objects.
Definition: TObject.h:44
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
virtual void Print(Option_t *option="") const
Print object content.
Definition: THostAuth.cxx:426
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
const Bool_t kTRUE
Definition: Rtypes.h:91
Int_t GetMethod(Int_t idx) const
Definition: THostAuth.h:80
TString fUser
Definition: THostAuth.h:49
Int_t GetFailure(Int_t idx) const
Definition: THostAuth.h:91
Char_t fServer
Definition: THostAuth.h:48
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:39
void Activate()
Definition: THostAuth.h:95
void Reset()
Remove all methods, leaving Active status and list of associted TSceContexts unchanged.
Definition: THostAuth.cxx:346