Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:10

0001 // @(#)root/auth:$Id$
0002 // Author: G. Ganis   19/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_THostAuth
0013 #define ROOT_THostAuth
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // THostAuth                                                            //
0019 //                                                                      //
0020 // Contains details about host-specific authentication methods and the  //
0021 // result of their application                                          //
0022 // Used by TAuthenticate                                                //
0023 //                                                                      //
0024 //////////////////////////////////////////////////////////////////////////
0025 
0026 #include "TObject.h"
0027 #include "TString.h"
0028 #include "TList.h"
0029 #include "TRootSecContext.h"
0030 #include "AuthConst.h"
0031 
0032 #include "TSecContext.h" // for kROOTTZERO.
0033 
0034 class THostAuth : public TObject {
0035 
0036 private:
0037    TString      fHost;             // Host
0038    Char_t       fServer;           // Server (kSOCKD,kROOTD,kPROOFD)
0039    TString      fUser;             // Username
0040    Int_t        fNumMethods;       // Number of AuthMethods
0041    Int_t        fMethods[kMAXSEC]; // AuthMethods
0042    TString      fDetails[kMAXSEC]; // AuthDetails
0043    Int_t        fSuccess[kMAXSEC]; // Statistics of successful attempts / per method
0044    Int_t        fFailure[kMAXSEC]; // Statistics of failed attempts / per method
0045    Bool_t       fActive;           // Flag used in cleaning/reset
0046 
0047    TList       *fSecContexts;  // List of TSecContexts related to this THostAuth
0048 
0049    void         Create(const char *host, const char *user, Int_t nmeth = 0,
0050                        Int_t *authmeth = nullptr, char **details = nullptr);
0051 public:
0052 
0053    THostAuth();
0054    THostAuth(const char *host, const char *user,
0055              Int_t nmeth = 0, Int_t *authmeth = nullptr, char **details = nullptr);
0056    THostAuth(const char *host, Int_t server, const char *user,
0057              Int_t nmeth = 0, Int_t *authmeth = nullptr, char **details = nullptr);
0058    THostAuth(const char *host, const char *user, Int_t authmeth,
0059              const char *details);
0060    THostAuth(const char *host, Int_t server, const char *user, Int_t authmeth,
0061              const char *details);
0062    THostAuth(const char *asstring);
0063    THostAuth(THostAuth &ha);
0064 
0065    virtual ~THostAuth();
0066 
0067    void     AsString(TString &out) const;
0068 
0069    Int_t    NumMethods() const { return fNumMethods; }
0070    Int_t    GetMethod(Int_t idx) const { return fMethods[idx]; }
0071    Bool_t   HasMethod(Int_t level, Int_t *pos = nullptr);
0072    void     AddMethod(Int_t level, const char *details = nullptr);
0073    void     RemoveMethod(Int_t level);
0074    void     ReOrder(Int_t nmet, Int_t *fmet);
0075    void     Update(THostAuth *ha);
0076    void     SetFirst(Int_t level);
0077    void     AddFirst(Int_t level, const char *details = nullptr);
0078    void     SetLast(Int_t level);
0079    void     CountFailure(Int_t level);
0080    void     CountSuccess(Int_t level);
0081    Int_t    GetFailure(Int_t idx) const { return fFailure[idx]; }
0082    Int_t    GetSuccess(Int_t idx) const { return fSuccess[idx]; }
0083    Bool_t   IsActive() const { return fActive; }
0084    void     DeActivate() { fActive = kFALSE; }
0085    void     Activate() { fActive = kTRUE; }
0086    void     Reset();
0087 
0088    const char *GetDetails(Int_t level);
0089    const char *GetDetailsByIdx(Int_t idx) const { return fDetails[idx]; }
0090    void        SetDetails(Int_t level, const char *details);
0091 
0092    const char *GetHost() const { return fHost; }
0093    Int_t    GetServer() const { return (Int_t)fServer; }
0094    const char *GetUser() const { return fUser; }
0095 
0096    void     SetHost(const char *host) { fHost = host; }
0097    void     SetServer(Int_t server) { fServer = (Char_t)server; }
0098    void     SetUser(const char *user) { fUser = user; }
0099 
0100    TList   *Established() const { return fSecContexts; }
0101    void     SetEstablished(TList *nl) { fSecContexts = nl; }
0102 
0103    void  Print(Option_t *option = "") const override;
0104    void     PrintEstablished() const;
0105 
0106    TRootSecContext *CreateSecContext(const char *user, const char *host, Int_t meth,
0107                                      Int_t offset, const char *details,
0108                                      const char *token, TDatime expdate = kROOTTZERO,
0109                                      void *ctx = nullptr, Int_t key = -1);
0110 
0111    ClassDefOverride(THostAuth,1)  // Class providing host specific authentication information
0112 };
0113 
0114 #endif