ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 #ifndef ROOT_TObject
26 #include "TObject.h"
27 #endif
28 #ifndef ROOT_TString
29 #include "TString.h"
30 #endif
31 #ifndef ROOT_TDatime
32 #include "TDatime.h"
33 #endif
34 
35 // Jan 1, 1995, 00:00:00 in sec from EPOCH (Jan 1, 1970)
36 const TDatime kROOTTZERO = 788914800;
37 
38 // Small class with information for final cleanup
39 class TSecContextCleanup;
40 class TPwdCtx;
41 
42 class TSecContext : public TObject {
43 
44 friend class TRootSecContext;
45 
46 private:
47  void *fContext; // Krb5, Globus: ptr to specific sec context
48  TList *fCleanup; // Points to list with info for remote cleanup
49  TDatime fExpDate; // Expiring date (one sec precision)
50  TString fHost; // Remote host name
51  TString fID; // String identifying uniquely this context
52  Int_t fMethod; // Authentication method used
53  TString fMethodName; // Authentication method name
54  Int_t fOffSet; // offset in remote host auth tab file (in bytes)
55  TString fToken; // Token identifying this authentication
56  TString fUser; // Remote login username
57 
59  void Cleanup();
60 
61 protected:
62  TSecContext(const TSecContext&);
64 
65 public:
66 
67  TSecContext(const char *url, Int_t meth, Int_t offset,
68  const char *id, const char *token,
69  TDatime expdate = kROOTTZERO, void *ctx = 0);
70  TSecContext(const char *user, const char *host, Int_t meth, Int_t offset,
71  const char *id, const char *token,
72  TDatime expdate = kROOTTZERO, void *ctx = 0);
73  virtual ~TSecContext();
74 
75  void AddForCleanup(Int_t port, Int_t proto, Int_t type);
76  virtual const char *AsString(TString &out);
77 
78  virtual void DeActivate(Option_t *opt = "CR");
79  void *GetContext() const { return fContext; }
80  TDatime GetExpDate() const { return fExpDate; }
81  const char *GetHost() const { return fHost; }
82  const char *GetID() const { return fID; }
83  Int_t GetMethod() const { return fMethod; }
84  const char *GetMethodName() const { return fMethodName; }
85  Int_t GetOffSet() const { return fOffSet; }
86  TList *GetSecContextCleanup() const { return fCleanup; }
87  const char *GetToken() const { return fToken; }
88  const char *GetUser() const { return fUser; }
89 
90  Bool_t IsA(const char *methodname);
91  Bool_t IsActive() const;
92 
93  virtual void Print(Option_t *option = "F") const;
94 
95  void SetExpDate(TDatime expdate) { fExpDate= expdate; }
96  void SetID(const char *id) { fID= id; }
98  void SetUser(const char *user) { fUser = user; }
99 
100  ClassDef(TSecContext,0) // Class providing host specific authentication information
101 };
102 
103 //
104 // TSecContextCleanup
105 //
106 // When the context is destroyed the remote authentication table
107 // should be updated; also, for globus, remote shared memory segments
108 // should be destroyed; for this we need to open a socket to a remote
109 // service; we keep track here of port and type of socket needed by
110 // the remote service used in connection with this security context.
111 // The last used is the first in the list.
112 // This info is used in TAuthenticate::CleanupSecContext to trasmit
113 // the actual cleanup request
114 //
115 class TSecContextCleanup : public TObject {
116 
117 private:
120  Int_t fServerType; // 0 = sockd, 1 = rootd, 2 = proofd
121 
122 public:
124  fPort(port), fServerProtocol(proto), fServerType(type) { };
125  virtual ~TSecContextCleanup() { };
126 
127  Int_t GetPort() const { return fPort; }
128  Int_t GetProtocol() const { return fServerProtocol; }
129  Int_t GetType() const { return fServerType; }
130 
131  ClassDef(TSecContextCleanup,0) //Update the remote authentication table
132 };
133 
134 //
135 // TPwdCtx
136 //
137 // To store associated passwd for UsrPwd and SRP methods
138 //
139 class TPwdCtx {
140 
141 private:
144 
145 public:
146  TPwdCtx(const char *pwd, Bool_t pwh): fPasswd(pwd), fPwHash(pwh) {};
147  virtual ~TPwdCtx() {};
148 
149  const char *GetPasswd() const { return fPasswd; }
150  Bool_t IsPwHash() const { return fPwHash; }
151 
152 };
153 
154 
155 
156 #endif
TDatime GetExpDate() const
Definition: TSecContext.h:80
TSecContextCleanup(Int_t port, Int_t proto, Int_t type)
Definition: TSecContext.h:123
TSecContext(const TSecContext &)
copy constructor
Bool_t IsPwHash() const
Definition: TSecContext.h:150
void AddForCleanup(Int_t port, Int_t proto, Int_t type)
Create a new TSecContextCleanup Internally is added to the list.
void * GetContext() const
Definition: TSecContext.h:79
virtual ~TPwdCtx()
Definition: TSecContext.h:147
virtual ~TSecContextCleanup()
Definition: TSecContext.h:125
const char Option_t
Definition: RtypesCore.h:62
tuple offset
Definition: tree.py:93
void SetExpDate(TDatime expdate)
Definition: TSecContext.h:95
virtual ~TSecContext()
Dtor: delete (deActivate, local/remote cleanup, list removal) all what is still active.
const char * GetUser() const
Definition: TSecContext.h:88
const char * GetHost() const
Definition: TSecContext.h:81
const char * GetMethodName() const
Definition: TSecContext.h:84
Basic string class.
Definition: TString.h:137
Bool_t IsActive() const
Check remote OffSet and expiring Date.
Int_t GetMethod() const
Definition: TSecContext.h:83
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TString fUser
Definition: TSecContext.h:56
TString fMethodName
Definition: TSecContext.h:53
const char * GetToken() const
Definition: TSecContext.h:87
TString fToken
Definition: TSecContext.h:55
const char * pwd()
Definition: rootalias.C:39
Int_t GetPort() const
Definition: TSecContext.h:127
Int_t GetType() const
Definition: TSecContext.h:129
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t GetOffSet() const
Definition: TSecContext.h:85
XFontStruct * id
Definition: TGX11.cxx:108
void SetUser(const char *user)
Definition: TSecContext.h:98
void Cleanup()
Cleanup what is still active.
char * out
Definition: TBase64.cxx:29
TPwdCtx(const char *pwd, Bool_t pwh)
Definition: TSecContext.h:146
Int_t fMethod
Definition: TSecContext.h:52
A doubly linked list.
Definition: TList.h:47
TString fID
Definition: TSecContext.h:51
virtual Bool_t CleanupSecContext(Bool_t all)
Ask remote client to cleanup security context 'ctx' If 'all', all sec context with the same host as c...
TList * fCleanup
Definition: TSecContext.h:48
TString fHost
Definition: TSecContext.h:50
TString fPasswd
Definition: TSecContext.h:142
Bool_t IsA(const char *methodname)
Checks if this security context is for method named 'methname' Case sensitive.
TSecContext & operator=(const TSecContext &)
assignement operator
TList * GetSecContextCleanup() const
Definition: TSecContext.h:86
void SetID(const char *id)
Definition: TSecContext.h:96
virtual void DeActivate(Option_t *opt="CR")
Set OffSet to -1 and expiring Date to default Remove from the list If Opt contains "C" or "c"...
const char * GetPasswd() const
Definition: TSecContext.h:149
virtual const char * AsString(TString &out)
Returns short string with relevant information about this security context.
Bool_t fPwHash
Definition: TSecContext.h:143
int type
Definition: TGX11.cxx:120
virtual void Print(Option_t *option="F") const
If opt is "F" (default) print object content.
const char * GetID() const
Definition: TSecContext.h:82
Mother of all ROOT objects.
Definition: TObject.h:58
Int_t GetProtocol() const
Definition: TSecContext.h:128
void SetOffSet(Int_t offset)
Definition: TSecContext.h:97
Int_t fOffSet
Definition: TSecContext.h:54
tuple all
Definition: na49view.py:13
void * fContext
Definition: TSecContext.h:47
TDatime fExpDate
Definition: TSecContext.h:49
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:39