Logo ROOT  
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)
31
32// Small class with information for final cleanup
34class TPwdCtx;
35
36class TSecContext : public TObject {
37
38friend class TRootSecContext;
39
40private:
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
55protected:
58
59public:
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
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//
109
110private:
113 Int_t fServerType; // 0 = sockd, 1 = rootd, 2 = proofd
114
115public:
118 virtual ~TSecContextCleanup() { };
119
120 Int_t GetPort() const { return fPort; }
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//
132class TPwdCtx {
133
134private:
137
138public:
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
#define R__EXTERN
Definition: DllImport.h:27
int Int_t
Definition: RtypesCore.h:45
bool Bool_t
Definition: RtypesCore.h:63
const char Option_t
Definition: RtypesCore.h:66
#define ClassDef(name, id)
Definition: Rtypes.h:325
XFontStruct * id
Definition: TGX11.cxx:109
int type
Definition: TGX11.cxx:121
R__EXTERN const TDatime kROOTTZERO
Definition: TSecContext.h:30
const char * proto
Definition: civetweb.c:16604
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
A doubly linked list.
Definition: TList.h:44
Mother of all ROOT objects.
Definition: TObject.h:37
Bool_t fPwHash
Definition: TSecContext.h:136
Bool_t IsPwHash() const
Definition: TSecContext.h:143
virtual ~TPwdCtx()
Definition: TSecContext.h:140
TString fPasswd
Definition: TSecContext.h:135
const char * GetPasswd() const
Definition: TSecContext.h:142
TPwdCtx(const char *pwd, Bool_t pwh)
Definition: TSecContext.h:139
TSecContextCleanup(Int_t port, Int_t proto, Int_t type)
Definition: TSecContext.h:116
Int_t GetType() const
Definition: TSecContext.h:122
Int_t GetProtocol() const
Definition: TSecContext.h:121
Int_t GetPort() const
Definition: TSecContext.h:120
virtual ~TSecContextCleanup()
Definition: TSecContext.h:118
TDatime GetExpDate() const
Definition: TSecContext.h:74
Bool_t IsActive() const
Check remote OffSet and expiring Date.
const char * GetID() const
Definition: TSecContext.h:76
void SetID(const char *id)
Definition: TSecContext.h:90
TString fMethodName
Definition: TSecContext.h:47
void Cleanup()
Cleanup what is still active.
const char * GetHost() const
Definition: TSecContext.h:75
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.
void SetUser(const char *user)
Definition: TSecContext.h:92
const char * GetMethodName() const
Definition: TSecContext.h:78
TString fID
Definition: TSecContext.h:45
virtual ~TSecContext()
Dtor: delete (deActivate, local/remote cleanup, list removal) all what is still active.
virtual void Print(Option_t *option="F") const
If opt is "F" (default) print object content.
void * fContext
Definition: TSecContext.h:41
TDatime fExpDate
Definition: TSecContext.h:43
Bool_t IsA(const char *methodname)
Checks if this security context is for method named 'methname' Case sensitive.
Int_t fMethod
Definition: TSecContext.h:46
TString fUser
Definition: TSecContext.h:50
void * GetContext() const
Definition: TSecContext.h:73
void SetExpDate(TDatime expdate)
Definition: TSecContext.h:89
const char * GetUser() const
Definition: TSecContext.h:82
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",...
TSecContext & operator=(const TSecContext &)
assignement operator
TSecContext(const TSecContext &)
copy constructor
Int_t fOffSet
Definition: TSecContext.h:48
void SetOffSet(Int_t offset)
Definition: TSecContext.h:91
Int_t GetMethod() const
Definition: TSecContext.h:77
virtual const char * AsString(TString &out)
Returns short string with relevant information about this security context.
TList * GetSecContextCleanup() const
Definition: TSecContext.h:80
Int_t GetOffSet() const
Definition: TSecContext.h:79
TString fToken
Definition: TSecContext.h:49
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
Basic string class.
Definition: TString.h:136