TSecContext.h

Go to the documentation of this file.
00001 // @(#)root/net:$Id: TSecContext.h 23091 2008-04-09 15:04:27Z rdm $
00002 // Author: G. Ganis   31/03/2003
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TSecContext
00013 #define ROOT_TSecContext
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TSecContext                                                         //
00019 //                                                                      //
00020 // Contains details about successful authentications                    //
00021 // Used by THostAuth                                                    //
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 // Jan 1, 1995, 00:00:00 in sec from EPOCH (Jan 1, 1970)
00036 const TDatime kROOTTZERO = 788914800;
00037 
00038 // Small class with information for final cleanup
00039 class TSecContextCleanup;
00040 class TPwdCtx;
00041 
00042 class TSecContext : public TObject {
00043 
00044 friend class TRootSecContext;
00045 
00046 private:
00047    void        *fContext;             // Krb5, Globus: ptr to specific sec context
00048    TList       *fCleanup;             // Points to list with info for remote cleanup
00049    TDatime      fExpDate;             // Expiring date (one sec precision)
00050    TString      fHost;                // Remote host name
00051    TString      fID;                  // String identifying uniquely this context
00052    Int_t        fMethod;              // Authentication method used
00053    TString      fMethodName;          // Authentication method name
00054    Int_t        fOffSet;              // offset in remote host auth tab file (in bytes)
00055    TString      fToken;               // Token identifying this authentication
00056    TString      fUser;                // Remote login username
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)  // Class providing host specific authentication information
00101 };
00102 
00103 //
00104 // TSecContextCleanup
00105 //
00106 // When the context is destroyed the remote authentication table
00107 // should be updated; also, for globus, remote shared memory segments
00108 // should be destroyed; for this we need to open a socket to a remote
00109 // service; we keep track here of port and type of socket needed by
00110 // the remote service used in connection with this security context.
00111 // The last used is the first in the list.
00112 // This info is used in TAuthenticate::CleanupSecContext to trasmit
00113 // the actual cleanup request
00114 //
00115 class TSecContextCleanup : public TObject {
00116 
00117 private:
00118    Int_t   fPort;
00119    Int_t   fServerProtocol;
00120    Int_t   fServerType;     // 0 = sockd, 1 = rootd, 2 = proofd
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) //Update the remote authentication table
00132 };
00133 
00134 //
00135 // TPwdCtx
00136 //
00137 // To store associated passwd for UsrPwd and SRP methods
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

Generated on Tue Jul 5 14:28:10 2011 for ROOT_528-00b_version by  doxygen 1.5.1