19 #ifndef PULSAR_AUTHENTICATION_H_
20 #define PULSAR_AUTHENTICATION_H_
26 #include <pulsar/Result.h>
29 #pragma GCC visibility push(default)
39 virtual bool hasDataForTls();
40 virtual std::string getTlsCertificates();
41 virtual std::string getTlsPrivateKey();
42 virtual bool hasDataForHttp();
43 virtual std::string getHttpAuthType();
44 virtual std::string getHttpHeaders();
45 virtual bool hasDataFromCommand();
46 virtual std::string getCommandData();
52 typedef std::shared_ptr<AuthenticationDataProvider> AuthenticationDataPtr;
53 typedef std::shared_ptr<Authentication> AuthenticationPtr;
54 typedef std::map<std::string, std::string> ParamMap;
59 virtual const std::string getAuthMethodName()
const = 0;
60 virtual Result getAuthData(AuthenticationDataPtr& authDataContent)
const {
61 authDataContent = authData_;
64 static ParamMap parseDefaultFormatAuthParams(
const std::string& authParamsString);
68 AuthenticationDataPtr authData_;
82 static AuthenticationPtr Disabled();
89 static AuthenticationPtr
create(
const std::string& pluginNameOrDynamicLibPath);
90 static AuthenticationPtr
create(
const std::string& pluginNameOrDynamicLibPath,
91 const std::string& authParamsString);
92 static AuthenticationPtr
create(
const std::string& pluginNameOrDynamicLibPath, ParamMap& params);
95 static bool isShutdownHookRegistered_;
96 static std::vector<void*> loadedLibrariesHandles_;
97 static void release_handles();
105 AuthTls(AuthenticationDataPtr&);
107 static AuthenticationPtr create(ParamMap& params);
108 static AuthenticationPtr create(
const std::string& authParamsString);
109 static AuthenticationPtr create(
const std::string& certificatePath,
const std::string& privateKeyPath);
110 const std::string getAuthMethodName()
const;
111 Result getAuthData(AuthenticationDataPtr& authDataTls)
const;
114 AuthenticationDataPtr authDataTls_;
117 typedef std::function<std::string()> TokenSupplier;
127 static AuthenticationPtr create(ParamMap& params);
129 static AuthenticationPtr create(
const std::string& authParamsString);
145 static AuthenticationPtr create(
const TokenSupplier& tokenSupplier);
147 const std::string getAuthMethodName()
const;
148 Result getAuthData(AuthenticationDataPtr& authDataToken)
const;
151 AuthenticationDataPtr authDataToken_;
161 static AuthenticationPtr create(ParamMap& params);
162 static AuthenticationPtr create(
const std::string& authParamsString);
163 const std::string getAuthMethodName()
const;
164 Result getAuthData(AuthenticationDataPtr& authDataAthenz)
const;
167 AuthenticationDataPtr authDataAthenz_;
172 #pragma GCC visibility pop