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 
38 public:
39  using XrdHttpChecksumPtr = std::unique_ptr<XrdHttpChecksum>;
41 
43 
44  void configure(const char * csList);
45  XrdHttpChecksumRawPtr getChecksumToRun(const std::string & userDigest) const;
46  const std::vector<std::string> & getNonIANAConfiguredCksums() const;
50  const std::vector<XrdHttpChecksumRawPtr> & getConfiguredChecksums() const;
51 private:
58  void initializeXRootDConfiguredCksums(const char *csList);
63  static void initializeCksumsMaps();
64  static void addChecksumToMaps(XrdHttpChecksumPtr && checksum);
65  static std::string getElement(const std::string & input, const std::string & delimiter, const size_t position);
71  static std::vector<std::string> getUserDigests(const std::string & userDigests);
72 
73  //The map that containing all possible IANA-HTTP-compatible xrootd checksums
74  static std::map<std::string,XrdHttpChecksumPtr> XROOTD_DIGEST_NAME_TO_CKSUMS;
75  // The vector of IANA-HTTP-compatible configured checksum
76  std::vector<XrdHttpChecksumRawPtr> mConfiguredChecksums;
77  // The vector of non-HTTP configured checksum names (for testing purposes)
78  std::vector<std::string> mNonIANAConfiguredChecksums;
79 };
80 
86 public:
88 
95  void configure(const char * csList) { pImpl.configure(csList); }
104  XrdHttpChecksumRawPtr getChecksumToRun(const std::string & userDigest) const { return pImpl.getChecksumToRun(userDigest); }
105 
110  const std::vector<std::string> & getNonIANAConfiguredCksums() const { return pImpl.getNonIANAConfiguredCksums(); }
111 private:
113 };
114 
115 
116 #endif //XROOTD_XRDHTTPCHECKSUMHANDLER_HH
const std::vector< std::string > & getNonIANAConfiguredCksums() const
std::unique_ptr< XrdHttpChecksum > XrdHttpChecksumPtr
XrdHttpChecksumRawPtr getChecksumToRun(const std::string &userDigest) const
XrdHttpChecksumHandlerImpl()=default
void configure(const char *csList)
const std::vector< XrdHttpChecksumRawPtr > & getConfiguredChecksums() const
const std::vector< std::string > & getNonIANAConfiguredCksums() const
XrdHttpChecksumHandler()=default
void configure(const char *csList)
XrdHttpChecksumRawPtr getChecksumToRun(const std::string &userDigest) const