Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:04:12

0001 /*
0002  * This File is part of Davix, The IO library for HTTP based protocols
0003  * Copyright (C) CERN 2013
0004  * Author: Adrien Devresse <adrien.devresse@cern.ch>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019  *
0020 */
0021 
0022 #ifndef DAVIX_X509CRED_HPP
0023 #define DAVIX_X509CRED_HPP
0024 
0025 #include <status/davixstatusrequest.hpp>
0026 
0027 
0028 #ifndef __DAVIX_INSIDE__
0029 #error "Only davix.hpp for the C++ API or davix.h for the C API should be included."
0030 #endif
0031 
0032 
0033 
0034 /// @file davixx509cred.hpp
0035 /// @brief utilities for X509 credential
0036 
0037 
0038 namespace Davix {
0039 
0040 struct X509CredentialInternal;
0041 struct X509CredentialExtra;
0042 
0043 /// @class X509Credential
0044 /// @brief X509 certificate
0045 ///
0046 class DAVIX_EXPORT X509Credential
0047 {
0048 public:
0049     ///
0050     /// \brief default constructor
0051     ///
0052     X509Credential();
0053     ///
0054     /// \brief copy constructor
0055     ///
0056     X509Credential(const X509Credential & orig);
0057     ///
0058     /// \brief assignment operator
0059     ///
0060     X509Credential & operator=(const X509Credential & orig);
0061     /// \brief destructor
0062     ~X509Credential();
0063 
0064     /// load a credential from a PKCS12 file
0065     /// @param filepath_p12_cred : path to the p12 credential file
0066     /// @param password : pass to decrypt the credential, empty string if nothing
0067     /// @param err : davix error report
0068     int loadFromFileP12(const std::string & filepath_p12_cred, const std::string & password, DavixError** err);
0069 
0070     /// load a credential from a PEM file
0071     /// support RFC-3820 proxy certificate, "globus" proxy  certificate and "VOMS" proxy certificate
0072     /// support for concatenated format
0073     ///
0074     /// to use a concatenated PEM cred, just set filepath_priv_key = filepath_cred = concat cred path
0075     ///
0076     /// @param filepath_priv_key : path to the private key file
0077     /// @param filepath_cred : path to the credential file
0078     /// @param password : pass to decrypt the credential, empty string if unencrypted
0079     /// @param err : davix error report
0080     int loadFromFilePEM(const std::string & filepath_priv_key, const std::string & filepath_cred,
0081                                 const std::string & password, DavixError** err);
0082 
0083 
0084     /// check if the object contain a credential
0085     /// @return true if contains a valid certificate, false if empty
0086     bool hasCert() const;
0087 
0088 private:
0089     X509CredentialInternal * d_ptr;
0090 
0091     friend struct X509CredentialExtra;
0092 };
0093 
0094 
0095 } // namespace Davix
0096 
0097 #endif // DAVIX_X509CRED_HPP