Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TSecContext.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/net:$Id$
0002 // Author: G. Ganis   31/03/2003
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TSecContext
0013 #define ROOT_TSecContext
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TSecContext                                                         //
0019 //                                                                      //
0020 // Contains details about successful authentications                    //
0021 // Used by THostAuth                                                    //
0022 //                                                                      //
0023 //////////////////////////////////////////////////////////////////////////
0024 
0025 #include "TObject.h"
0026 #include "TString.h"
0027 #include "TDatime.h"
0028 
0029 // Jan 1, 1995, 00:00:00 in sec from EPOCH (Jan 1, 1970)
0030 R__EXTERN const TDatime kROOTTZERO;
0031 
0032 // Small class with information for final cleanup
0033 class TSecContextCleanup;
0034 class TPwdCtx;
0035 
0036 class TSecContext : public TObject {
0037 
0038 friend class TRootSecContext;
0039 
0040 private:
0041    void        *fContext;             // ptr to specific sec context
0042    TList       *fCleanup;             // Points to list with info for remote cleanup
0043    TDatime      fExpDate;             // Expiring date (one sec precision)
0044    TString      fHost;                // Remote host name
0045    TString      fID;                  // String identifying uniquely this context
0046    Int_t        fMethod;              // Authentication method used
0047    TString      fMethodName;          // Authentication method name
0048    Int_t        fOffSet;              // offset in remote host auth tab file (in bytes)
0049    TString      fToken;               // Token identifying this authentication
0050    TString      fUser;                // Remote login username
0051 
0052    virtual Bool_t  CleanupSecContext(Bool_t all);
0053    void         Cleanup();
0054 
0055 protected:
0056    TSecContext(const TSecContext&);
0057    TSecContext& operator=(const TSecContext&);
0058 
0059 public:
0060 
0061    TSecContext(const char *url, Int_t meth, Int_t offset,
0062                const char *id, const char *token,
0063                TDatime expdate = kROOTTZERO, void *ctx = nullptr);
0064    TSecContext(const char *user, const char *host, Int_t meth, Int_t offset,
0065                const char *id, const char *token,
0066                TDatime expdate = kROOTTZERO, void *ctx = nullptr);
0067    virtual    ~TSecContext();
0068 
0069    void        AddForCleanup(Int_t port, Int_t proto, Int_t type);
0070    virtual const char *AsString(TString &out);
0071 
0072    virtual void DeActivate(Option_t *opt = "CR");
0073    void       *GetContext() const { return fContext; }
0074    TDatime     GetExpDate() const { return fExpDate; }
0075    const char *GetHost()    const { return fHost; }
0076    const char *GetID() const { return fID; }
0077    Int_t       GetMethod()  const { return fMethod; }
0078    const char *GetMethodName() const { return fMethodName; }
0079    Int_t       GetOffSet()  const { return fOffSet; }
0080    TList      *GetSecContextCleanup() const { return fCleanup; }
0081    const char *GetToken()   const { return fToken; }
0082    const char *GetUser()    const { return fUser; }
0083 
0084    Bool_t      IsA(const char *methodname);
0085    Bool_t      IsActive()   const;
0086 
0087    void Print(Option_t *option = "F") const override;
0088 
0089    void        SetExpDate(TDatime expdate)  { fExpDate= expdate; }
0090    void        SetID(const char *id)        { fID= id; }
0091    void        SetOffSet(Int_t offset)      { fOffSet = offset; }
0092    void        SetUser(const char *user)    { fUser   = user; }
0093 
0094    ClassDefOverride(TSecContext,0)  // Class providing host specific authentication information
0095 };
0096 
0097 //
0098 // TSecContextCleanup
0099 //
0100 // When the context is destroyed the remote authentication table
0101 // should be updated; for this we need to open a socket to a remote
0102 // service; we keep track here of port and type of socket needed by
0103 // the remote service used in connection with this security context.
0104 // The last used is the first in the list.
0105 // This info is used in TAuthenticate::CleanupSecContext to trasmit
0106 // the actual cleanup request
0107 //
0108 class TSecContextCleanup : public TObject {
0109 
0110 private:
0111    Int_t   fPort;
0112    Int_t   fServerProtocol;
0113    Int_t   fServerType;     // 0 = sockd, 1 = rootd, 2 = proofd
0114 
0115 public:
0116    TSecContextCleanup(Int_t port, Int_t proto, Int_t type) :
0117                fPort(port), fServerProtocol(proto), fServerType(type) { };
0118    virtual ~TSecContextCleanup() { };
0119 
0120    Int_t   GetPort() const { return fPort; }
0121    Int_t   GetProtocol() const { return fServerProtocol; }
0122    Int_t   GetType() const { return fServerType; }
0123 
0124    ClassDefOverride(TSecContextCleanup,0) //Update the remote authentication table
0125 };
0126 
0127 //
0128 // TPwdCtx
0129 //
0130 // To store associated passwd for UsrPwd method
0131 //
0132 class TPwdCtx {
0133 
0134 private:
0135    TString fPasswd;
0136    Bool_t  fPwHash;
0137 
0138 public:
0139    TPwdCtx(const char *pwd, Bool_t pwh): fPasswd(pwd), fPwHash(pwh) {};
0140    virtual ~TPwdCtx() {};
0141 
0142    const char *GetPasswd() const { return fPasswd; }
0143    Bool_t      IsPwHash() const { return fPwHash; }
0144 
0145 };
0146 
0147 
0148 #endif