Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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