File indexing completed on 2024-04-06 12:01:25
0001 #ifndef COND_XMLAUTHENTITACTIONSERVICE_H
0002 #define COND_XMLAUTHENTITACTIONSERVICE_H
0003
0004 #include "RelationalAccess/IAuthenticationService.h"
0005 #include "CoralKernel/Service.h"
0006 #include "CoralKernel/Property.h"
0007 #include <map>
0008 #include <set>
0009 #include <string>
0010 #include <boost/thread.hpp>
0011
0012 namespace coral {
0013
0014 class AuthenticationCredentials;
0015
0016 }
0017
0018 namespace cond {
0019
0020 namespace XMLAuthenticationService {
0021
0022
0023
0024
0025
0026
0027 class DataSourceEntry {
0028 public:
0029
0030 DataSourceEntry(const std::string& serviceName, const std::string& connectionName);
0031 DataSourceEntry() = delete;
0032 DataSourceEntry(const DataSourceEntry&) = delete;
0033 DataSourceEntry& operator=(const DataSourceEntry&) = delete;
0034
0035
0036 ~DataSourceEntry();
0037
0038
0039
0040
0041 void appendCredentialItem(const std::string& item, const std::string& value);
0042
0043
0044
0045
0046 void appendCredentialItemForRole(const std::string& item, const std::string& value, const std::string& role);
0047
0048
0049
0050
0051 const coral::IAuthenticationCredentials& credentials() const;
0052
0053
0054
0055
0056
0057 const coral::IAuthenticationCredentials& credentials(const std::string& role) const;
0058
0059 private:
0060
0061 std::string m_serviceName;
0062
0063
0064 std::string m_connectionName;
0065
0066
0067 coral::AuthenticationCredentials* m_default;
0068
0069
0070 std::map<std::string, coral::AuthenticationCredentials*> m_data;
0071 };
0072
0073
0074
0075
0076
0077
0078 class XMLAuthenticationService : public coral::Service, virtual public coral::IAuthenticationService {
0079 public:
0080
0081 explicit XMLAuthenticationService(const std::string& name);
0082
0083
0084 ~XMLAuthenticationService() override;
0085
0086 public:
0087
0088
0089
0090
0091 const coral::IAuthenticationCredentials& credentials(const std::string& connectionString) const override;
0092
0093
0094
0095
0096
0097
0098 const coral::IAuthenticationCredentials& credentials(const std::string& connectionString,
0099 const std::string& role) const override;
0100
0101 public:
0102
0103 void setAuthenticationPath(const std::string& inputPath);
0104
0105 private:
0106
0107 bool initialize();
0108
0109
0110 void reset();
0111
0112
0113 bool processFile(const std::string& inputFileName);
0114
0115
0116 std::set<std::string> verifyFileName();
0117
0118
0119 bool m_isInitialized;
0120
0121
0122 std::string m_inputFileName;
0123
0124
0125 std::map<std::string, DataSourceEntry*> m_data;
0126
0127
0128 mutable boost::mutex m_mutexLock;
0129
0130 coral::Property::CallbackID m_callbackID;
0131 };
0132
0133 }
0134
0135 }
0136
0137 #endif