XRootD
XrdHttpChecksumHandler.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of XrdHTTP: A pragmatic implementation of the
3 // HTTP/WebDAV protocol for the Xrootd framework
4 //
5 // Copyright (c) 2013 by European Organization for Nuclear Research (CERN)
6 // Author: Cedric Caffy <ccaffy@cern.ch>
7 // File Date: Mar 2023
8 //------------------------------------------------------------------------------
9 // XRootD is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU Lesser General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // XRootD is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public License
20 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
21 //------------------------------------------------------------------------------
22 #ifndef XROOTD_XRDHTTPCHECKSUMHANDLER_HH
23 #define XROOTD_XRDHTTPCHECKSUMHANDLER_HH
24 
25 #include "XrdHttpChecksum.hh"
26 
27 #include <string>
28 #include <map>
29 #include <vector>
30 #include <memory>
31 #include <cstdint>
32 
39 public:
40  using XrdHttpChecksumPtr = std::unique_ptr<XrdHttpChecksum>;
42 
44 
45  void configure(const char * csList);
46  XrdHttpChecksumRawPtr getChecksumToRunWantDigest(const std::string & wantDigest) const;
47  XrdHttpChecksumRawPtr getChecksumToRunWantReprDigest(const std::map<std::string,uint8_t> & wantReprDigest) const;
48  const std::vector<std::string> & getNonIANAConfiguredCksums() const;
52  const std::vector<XrdHttpChecksumRawPtr> & getConfiguredChecksums() const;
53 private:
60  void initializeXRootDConfiguredCksums(const char *csList);
65  static void initializeCksumsMaps();
66  static void addChecksumToMaps(XrdHttpChecksumPtr && checksum);
67  static std::string getElement(const std::string & input, const std::string & delimiter, const size_t position);
73  static std::vector<std::string> getUserDigests(const std::string & userDigests);
74 
75  //The map that containing all possible IANA-HTTP-compatible xrootd checksums
76  static std::map<std::string,XrdHttpChecksumPtr> XROOTD_DIGEST_NAME_TO_CKSUMS;
77  // The vector of IANA-HTTP-compatible configured checksum
78  std::vector<XrdHttpChecksumRawPtr> mConfiguredChecksums;
79  // The vector of non-HTTP configured checksum names (for testing purposes)
80  std::vector<std::string> mNonIANAConfiguredChecksums;
81 };
82 
88 public:
90 
97  void configure(const char * csList) { pImpl.configure(csList); }
106  XrdHttpChecksumRawPtr getChecksumToRunWantDigest(const std::string & wantDigest) const { return pImpl.getChecksumToRunWantDigest(wantDigest); }
107 
116  XrdHttpChecksumRawPtr getChecksumToRunWantReprDigest(const std::map<std::string,uint8_t> & wantReprDigest) const { return pImpl.getChecksumToRunWantReprDigest(wantReprDigest); }
117 
122  const std::vector<std::string> & getNonIANAConfiguredCksums() const { return pImpl.getNonIANAConfiguredCksums(); }
123 private:
125 };
126 
127 
128 #endif //XROOTD_XRDHTTPCHECKSUMHANDLER_HH
const std::vector< std::string > & getNonIANAConfiguredCksums() const
XrdHttpChecksumRawPtr getChecksumToRunWantDigest(const std::string &wantDigest) const
std::unique_ptr< XrdHttpChecksum > XrdHttpChecksumPtr
XrdHttpChecksumRawPtr getChecksumToRunWantReprDigest(const std::map< std::string, uint8_t > &wantReprDigest) const
XrdHttpChecksumHandlerImpl()=default
void configure(const char *csList)
const std::vector< XrdHttpChecksumRawPtr > & getConfiguredChecksums() const
const std::vector< std::string > & getNonIANAConfiguredCksums() const
XrdHttpChecksumRawPtr getChecksumToRunWantDigest(const std::string &wantDigest) const
XrdHttpChecksumHandler()=default
void configure(const char *csList)
XrdHttpChecksumRawPtr getChecksumToRunWantReprDigest(const std::map< std::string, uint8_t > &wantReprDigest) const