MySQL 8.4.3
Source Code Documentation
rpl_channel_credentials.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef RPL_CHANNEL_CREDENTIALS_INCLUDE
25#define RPL_CHANNEL_CREDENTIALS_INCLUDE
26
27#include <map>
28#include <string>
29
30typedef std::pair<bool, std::string> String_set;
31
37
38 Channel_cred_param(char *username_arg, char *password_arg,
39 char *plugin_auth_arg) {
40 if ((username.first = (username_arg != nullptr)))
41 username.second.assign(username_arg);
42 if ((password.first = (password_arg != nullptr)))
43 password.second.assign(password_arg);
44 if ((plugin_auth.first = (plugin_auth_arg != nullptr)))
45 plugin_auth.second.assign(plugin_auth_arg);
46 }
47 };
48
49 private:
50 typedef std::pair<std::string, Channel_cred_param> channel_credential_pair;
51 std::map<std::string, Channel_cred_param> m_credential_set;
52
53 /**
54 Constructor
55 */
57
58 /**
59 Destructor
60 */
61 virtual ~Rpl_channel_credentials() = default;
62
63 public:
64 /**
65 Returns object
66
67 @return instance
68 */
70
71 public:
72 /**
73 Delete all stored credentials and delete instance.
74 */
75 void reset();
76
77 /**
78 Number of channels stored.
79
80 @return number of channels
81 */
83
84 /**
85 Method to get channel credentials.
86
87 @param[in] channel_name The channel.
88 @param[out] user Username of channel.
89 @param[out] pass Password of channel.
90 @param[out] auth Authentication plugin.
91
92 @return the operation status
93 @retval 0 OK
94 @retval 1 Credentials do not exist.
95 */
96 int get_credentials(const char *channel_name, String_set &user,
97 String_set &pass, String_set &auth);
98
99 /**
100 Method to store credentials in map.
101
102 @param[in] channel_name The channel name to store.
103 @param[in] username Username for channel.
104 @param[in] password Password for channel.
105 @param[in] plugin_auth Authentication plugin.
106
107 @return the operation status
108 @retval 0 OK
109 @retval 1 Error, credentials already exists
110 */
111 int store_credentials(const char *channel_name, char *username,
112 char *password, char *plugin_auth);
113
114 /**
115 Method to delete channel credentials.
116
117 @param[in] channel_name The channel.
118
119 @return the operation status
120 @retval 0 OK
121 @retval 1 Credentials do not exist.
122 */
123 int delete_credentials(const char *channel_name);
124};
125#endif // RPL_CHANNEL_CREDENTIALS_INCLUDE
Definition: rpl_channel_credentials.h:32
int get_credentials(const char *channel_name, String_set &user, String_set &pass, String_set &auth)
Method to get channel credentials.
Definition: rpl_channel_credentials.cc:44
virtual ~Rpl_channel_credentials()=default
Destructor.
std::pair< std::string, Channel_cred_param > channel_credential_pair
Definition: rpl_channel_credentials.h:50
int store_credentials(const char *channel_name, char *username, char *password, char *plugin_auth)
Method to store credentials in map.
Definition: rpl_channel_credentials.cc:63
Rpl_channel_credentials()=default
Constructor.
std::map< std::string, Channel_cred_param > m_credential_set
Definition: rpl_channel_credentials.h:51
int number_of_channels()
Number of channels stored.
Definition: rpl_channel_credentials.cc:39
int delete_credentials(const char *channel_name)
Method to delete channel credentials.
Definition: rpl_channel_credentials.cc:77
static Rpl_channel_credentials & get_instance()
Returns object.
Definition: rpl_channel_credentials.cc:33
void reset()
Delete all stored credentials and delete instance.
Definition: rpl_channel_credentials.cc:28
static char * password
Definition: mysql_secure_installation.cc:58
char * user
Definition: mysqladmin.cc:66
constexpr value_type plugin_auth
Definition: classic_protocol_constants.h:57
std::pair< bool, std::string > String_set
Definition: rpl_channel_credentials.h:30
Definition: rpl_channel_credentials.h:33
String_set plugin_auth
Definition: rpl_channel_credentials.h:36
String_set password
Definition: rpl_channel_credentials.h:35
Channel_cred_param(char *username_arg, char *password_arg, char *plugin_auth_arg)
Definition: rpl_channel_credentials.h:38
String_set username
Definition: rpl_channel_credentials.h:34