00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 #ifndef ROOT_TSecContext
00013 #define ROOT_TSecContext
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 #ifndef ROOT_TObject
00026 #include "TObject.h"
00027 #endif
00028 #ifndef ROOT_TString
00029 #include "TString.h"
00030 #endif
00031 #ifndef ROOT_TDatime
00032 #include "TDatime.h"
00033 #endif
00034 
00035 
00036 const TDatime kROOTTZERO = 788914800;
00037 
00038 
00039 class TSecContextCleanup;
00040 class TPwdCtx;
00041 
00042 class TSecContext : public TObject {
00043 
00044 friend class TRootSecContext;
00045 
00046 private:
00047    void        *fContext;             
00048    TList       *fCleanup;             
00049    TDatime      fExpDate;             
00050    TString      fHost;                
00051    TString      fID;                  
00052    Int_t        fMethod;              
00053    TString      fMethodName;          
00054    Int_t        fOffSet;              
00055    TString      fToken;               
00056    TString      fUser;                
00057 
00058    virtual Bool_t  CleanupSecContext(Bool_t all);
00059    void         Cleanup();
00060 
00061 protected:
00062    TSecContext(const TSecContext&);
00063    TSecContext& operator=(const TSecContext&);
00064 
00065 public:
00066 
00067    TSecContext(const char *url, Int_t meth, Int_t offset,
00068                const char *id, const char *token,
00069                TDatime expdate = kROOTTZERO, void *ctx = 0);
00070    TSecContext(const char *user, const char *host, Int_t meth, Int_t offset,
00071                const char *id, const char *token,
00072                TDatime expdate = kROOTTZERO, void *ctx = 0);
00073    virtual    ~TSecContext();
00074 
00075    void        AddForCleanup(Int_t port, Int_t proto, Int_t type);
00076    virtual const char *AsString(TString &out);
00077 
00078    virtual void DeActivate(Option_t *opt = "CR");
00079    void       *GetContext() const { return fContext; }
00080    TDatime     GetExpDate() const { return fExpDate; }
00081    const char *GetHost()    const { return fHost; }
00082    const char *GetID() const { return fID; }
00083    Int_t       GetMethod()  const { return fMethod; }
00084    const char *GetMethodName() const { return fMethodName; }
00085    Int_t       GetOffSet()  const { return fOffSet; }
00086    TList      *GetSecContextCleanup() const { return fCleanup; }
00087    const char *GetToken()   const { return fToken; }
00088    const char *GetUser()    const { return fUser; }
00089 
00090    Bool_t      IsA(const char *methodname);
00091    Bool_t      IsActive()   const;
00092 
00093    virtual void Print(Option_t *option = "F") const;
00094 
00095    void        SetExpDate(TDatime expdate)  { fExpDate= expdate; }
00096    void        SetID(const char *id)        { fID= id; }
00097    void        SetOffSet(Int_t offset)      { fOffSet = offset; }
00098    void        SetUser(const char *user)    { fUser   = user; }
00099 
00100    ClassDef(TSecContext,0)  
00101 };
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 class TSecContextCleanup : public TObject {
00116 
00117 private:
00118    Int_t   fPort;
00119    Int_t   fServerProtocol;
00120    Int_t   fServerType;     
00121 
00122 public:
00123    TSecContextCleanup(Int_t port, Int_t proto, Int_t type) :
00124                fPort(port), fServerProtocol(proto), fServerType(type) { };
00125    virtual ~TSecContextCleanup() { };
00126 
00127    Int_t   GetPort() const { return fPort; }
00128    Int_t   GetProtocol() const { return fServerProtocol; }
00129    Int_t   GetType() const { return fServerType; }
00130 
00131    ClassDef(TSecContextCleanup,0) 
00132 };
00133 
00134 
00135 
00136 
00137 
00138 
00139 class TPwdCtx {
00140 
00141 private:
00142    TString fPasswd;
00143    Bool_t  fPwHash;
00144 
00145 public:
00146    TPwdCtx(const char *pwd, Bool_t pwh): fPasswd(pwd), fPwHash(pwh) {};
00147    virtual ~TPwdCtx() {};
00148 
00149    const char *GetPasswd() const { return fPasswd; }
00150    Bool_t      IsPwHash() const { return fPwHash; }
00151 
00152 };
00153 
00154 
00155 
00156 #endif