Logo ROOT   6.10/09
Reference Guide
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 const TDatime kROOTTZERO = 788914800;
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; // Krb5, Globus: 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&);
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; also, for globus, remote shared memory segments
102 // should be destroyed; for this we need to open a socket to a remote
103 // service; we keep track here of port and type of socket needed by
104 // the remote service used in connection with this security context.
105 // The last used is the first in the list.
106 // This info is used in TAuthenticate::CleanupSecContext to trasmit
107 // the actual cleanup request
108 //
109 class TSecContextCleanup : public TObject {
110 
111 private:
114  Int_t fServerType; // 0 = sockd, 1 = rootd, 2 = proofd
115 
116 public:
118  fPort(port), fServerProtocol(proto), fServerType(type) { };
119  virtual ~TSecContextCleanup() { };
120 
121  Int_t GetPort() const { return fPort; }
122  Int_t GetProtocol() const { return fServerProtocol; }
123  Int_t GetType() const { return fServerType; }
124 
125  ClassDef(TSecContextCleanup,0) //Update the remote authentication table
126 };
127 
128 //
129 // TPwdCtx
130 //
131 // To store associated passwd for UsrPwd and SRP methods
132 //
133 class TPwdCtx {
134 
135 private:
138 
139 public:
140  TPwdCtx(const char *pwd, Bool_t pwh): fPasswd(pwd), fPwHash(pwh) {};
141  virtual ~TPwdCtx() {};
142 
143  const char *GetPasswd() const { return fPasswd; }
144  Bool_t IsPwHash() const { return fPwHash; }
145 
146 };
147 
148 
149 
150 #endif
TSecContextCleanup(Int_t port, Int_t proto, Int_t type)
Definition: TSecContext.h:117
TSecContext(const TSecContext &)
copy constructor
const char * GetToken() const
Definition: TSecContext.h:81
void AddForCleanup(Int_t port, Int_t proto, Int_t type)
Create a new TSecContextCleanup Internally is added to the list.
virtual ~TPwdCtx()
Definition: TSecContext.h:141
virtual ~TSecContextCleanup()
Definition: TSecContext.h:119
TDatime GetExpDate() const
Definition: TSecContext.h:74
const char Option_t
Definition: RtypesCore.h:62
virtual void Print(Option_t *option="F") const
If opt is "F" (default) print object content.
void SetExpDate(TDatime expdate)
Definition: TSecContext.h:89
virtual ~TSecContext()
Dtor: delete (deActivate, local/remote cleanup, list removal) all what is still active.
Basic string class.
Definition: TString.h:129
const char * GetMethodName() const
Definition: TSecContext.h:78
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TString fUser
Definition: TSecContext.h:50
Int_t GetOffSet() const
Definition: TSecContext.h:79
TString fMethodName
Definition: TSecContext.h:47
const char * GetHost() const
Definition: TSecContext.h:75
TString fToken
Definition: TSecContext.h:49
Bool_t IsActive() const
Check remote OffSet and expiring Date.
#define ClassDef(name, id)
Definition: Rtypes.h:297
TList * GetSecContextCleanup() const
Definition: TSecContext.h:80
const char * GetPasswd() const
Definition: TSecContext.h:143
void SetUser(const char *user)
Definition: TSecContext.h:92
void Cleanup()
Cleanup what is still active.
TPwdCtx(const char *pwd, Bool_t pwh)
Definition: TSecContext.h:140
const char * GetUser() const
Definition: TSecContext.h:82
Int_t fMethod
Definition: TSecContext.h:46
A doubly linked list.
Definition: TList.h:43
TString fID
Definition: TSecContext.h:45
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:42
TString fHost
Definition: TSecContext.h:44
Bool_t IsPwHash() const
Definition: TSecContext.h:144
TString fPasswd
Definition: TSecContext.h:136
Bool_t IsA(const char *methodname)
Checks if this security context is for method named 'methname' Case sensitive.
TSecContext & operator=(const TSecContext &)
assignement operator
void SetID(const char *id)
Definition: TSecContext.h:90
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"...
Int_t GetType() const
Definition: TSecContext.h:123
virtual const char * AsString(TString &out)
Returns short string with relevant information about this security context.
Bool_t fPwHash
Definition: TSecContext.h:137
const char * GetID() const
Definition: TSecContext.h:76
void * GetContext() const
Definition: TSecContext.h:73
int type
Definition: TGX11.cxx:120
const TDatime kROOTTZERO
Definition: TSecContext.h:30
Int_t GetPort() const
Definition: TSecContext.h:121
Mother of all ROOT objects.
Definition: TObject.h:37
Int_t GetProtocol() const
Definition: TSecContext.h:122
const char * proto
Definition: civetweb.c:11652
void SetOffSet(Int_t offset)
Definition: TSecContext.h:91
Int_t fOffSet
Definition: TSecContext.h:48
void * fContext
Definition: TSecContext.h:41
TDatime fExpDate
Definition: TSecContext.h:43
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
Int_t GetMethod() const
Definition: TSecContext.h:77