Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TSecContext.h
Go to the documentation of this file.
1 // @(#)root/net:$Id$
2 // Author: G. Ganis 31/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_TSecContext
13 #define ROOT_TSecContext
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TSecContext //
19 // //
20 // Contains details about successful authentications //
21 // Used by THostAuth //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #include "TObject.h"
26 #include "TString.h"
27 #include "TDatime.h"
28 
29 // Jan 1, 1995, 00:00:00 in sec from EPOCH (Jan 1, 1970)
30 R__EXTERN const TDatime kROOTTZERO;
31 
32 // Small class with information for final cleanup
33 class TSecContextCleanup;
34 class TPwdCtx;
35 
36 class TSecContext : public TObject {
37 
38 friend class TRootSecContext;
39 
40 private:
41  void *fContext; // ptr to specific sec context
42  TList *fCleanup; // Points to list with info for remote cleanup
43  TDatime fExpDate; // Expiring date (one sec precision)
44  TString fHost; // Remote host name
45  TString fID; // String identifying uniquely this context
46  Int_t fMethod; // Authentication method used
47  TString fMethodName; // Authentication method name
48  Int_t fOffSet; // offset in remote host auth tab file (in bytes)
49  TString fToken; // Token identifying this authentication
50  TString fUser; // Remote login username
51 
52  virtual Bool_t CleanupSecContext(Bool_t all);
53  void Cleanup();
54 
55 protected:
56  TSecContext(const TSecContext&);
57  TSecContext& operator=(const TSecContext&);
58 
59 public:
60 
61  TSecContext(const char *url, Int_t meth, Int_t offset,
62  const char *id, const char *token,
63  TDatime expdate = kROOTTZERO, void *ctx = 0);
64  TSecContext(const char *user, const char *host, Int_t meth, Int_t offset,
65  const char *id, const char *token,
66  TDatime expdate = kROOTTZERO, void *ctx = 0);
67  virtual ~TSecContext();
68 
69  void AddForCleanup(Int_t port, Int_t proto, Int_t type);
70  virtual const char *AsString(TString &out);
71 
72  virtual void DeActivate(Option_t *opt = "CR");
73  void *GetContext() const { return fContext; }
74  TDatime GetExpDate() const { return fExpDate; }
75  const char *GetHost() const { return fHost; }
76  const char *GetID() const { return fID; }
77  Int_t GetMethod() const { return fMethod; }
78  const char *GetMethodName() const { return fMethodName; }
79  Int_t GetOffSet() const { return fOffSet; }
80  TList *GetSecContextCleanup() const { return fCleanup; }
81  const char *GetToken() const { return fToken; }
82  const char *GetUser() const { return fUser; }
83 
84  Bool_t IsA(const char *methodname);
85  Bool_t IsActive() const;
86 
87  virtual void Print(Option_t *option = "F") const;
88 
89  void SetExpDate(TDatime expdate) { fExpDate= expdate; }
90  void SetID(const char *id) { fID= id; }
91  void SetOffSet(Int_t offset) { fOffSet = offset; }
92  void SetUser(const char *user) { fUser = user; }
93 
94  ClassDef(TSecContext,0) // Class providing host specific authentication information
95 };
96 
97 //
98 // TSecContextCleanup
99 //
100 // When the context is destroyed the remote authentication table
101 // should be updated; for this we need to open a socket to a remote
102 // service; we keep track here of port and type of socket needed by
103 // the remote service used in connection with this security context.
104 // The last used is the first in the list.
105 // This info is used in TAuthenticate::CleanupSecContext to trasmit
106 // the actual cleanup request
107 //
108 class TSecContextCleanup : public TObject {
109 
110 private:
111  Int_t fPort;
112  Int_t fServerProtocol;
113  Int_t fServerType; // 0 = sockd, 1 = rootd, 2 = proofd
114 
115 public:
116  TSecContextCleanup(Int_t port, Int_t proto, Int_t type) :
117  fPort(port), fServerProtocol(proto), fServerType(type) { };
118  virtual ~TSecContextCleanup() { };
119 
120  Int_t GetPort() const { return fPort; }
121  Int_t GetProtocol() const { return fServerProtocol; }
122  Int_t GetType() const { return fServerType; }
123 
124  ClassDef(TSecContextCleanup,0) //Update the remote authentication table
125 };
126 
127 //
128 // TPwdCtx
129 //
130 // To store associated passwd for UsrPwd method
131 //
132 class TPwdCtx {
133 
134 private:
135  TString fPasswd;
136  Bool_t fPwHash;
137 
138 public:
139  TPwdCtx(const char *pwd, Bool_t pwh): fPasswd(pwd), fPwHash(pwh) {};
140  virtual ~TPwdCtx() {};
141 
142  const char *GetPasswd() const { return fPasswd; }
143  Bool_t IsPwHash() const { return fPwHash; }
144 
145 };
146 
147 
148 
149 #endif