MySQL  8.0.22
Source Code Documentation
rpl_channel_credentials.h
Go to the documentation of this file.
1 /* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
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 also distributed 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 included with MySQL.
13 
14  This program 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, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef RPL_CHANNEL_CREDENTIALS_INCLUDE
24 #define RPL_CHANNEL_CREDENTIALS_INCLUDE
25 
26 #include <map>
27 #include <string>
28 
29 typedef std::pair<bool, std::string> String_set;
30 
36 
37  Channel_cred_param(char *username_arg, char *password_arg,
38  char *plugin_auth_arg) {
39  if ((username.first = (username_arg != nullptr)))
40  username.second.assign(username_arg);
41  if ((password.first = (password_arg != nullptr)))
42  password.second.assign(password_arg);
43  if ((plugin_auth.first = (plugin_auth_arg != nullptr)))
44  plugin_auth.second.assign(plugin_auth_arg);
45  }
46  };
47 
48  private:
49  typedef std::pair<std::string, Channel_cred_param> channel_credential_pair;
50  std::map<std::string, Channel_cred_param> m_credential_set;
51 
52  /**
53  Constructor
54  */
56 
57  /**
58  Destructor
59  */
61 
62  public:
63  /**
64  Returns object
65 
66  @return instance
67  */
69 
70  public:
71  /**
72  Delete all stored credentials and delete instance.
73  */
74  void reset();
75 
76  /**
77  Number of channels stored.
78 
79  @return number of channels
80  */
81  int number_of_channels();
82 
83  /**
84  Method to get channel credentials.
85 
86  @param[in] channel_name The channel.
87  @param[out] user Username of channel.
88  @param[out] pass Password of channel.
89  @param[out] auth Authentication plugin.
90 
91  @return the operation status
92  @retval 0 OK
93  @retval 1 Credentials do not exist.
94  */
95  int get_credentials(const char *channel_name, String_set &user,
96  String_set &pass, String_set &auth);
97 
98  /**
99  Method to store credentials in map.
100 
101  @param[in] channel_name The channel name to store.
102  @param[in] username Username for channel.
103  @param[in] password Password for channel.
104  @param[in] plugin_auth Authentication plugin.
105 
106  @return the operation status
107  @retval 0 OK
108  @retval 1 Error, credentials already exists
109  */
110  int store_credentials(const char *channel_name, char *username,
111  char *password, char *plugin_auth);
112 
113  /**
114  Method to delete channel credentials.
115 
116  @param[in] channel_name The channel.
117 
118  @return the operation status
119  @retval 0 OK
120  @retval 1 Credentials do not exist.
121  */
122  int delete_credentials(const char *channel_name);
123 };
124 #endif // RPL_CHANNEL_CREDENTIALS_INCLUDE
Rpl_channel_credentials()
Constructor.
Definition: rpl_channel_credentials.h:55
int delete_credentials(const char *channel_name)
Method to delete channel credentials.
Definition: rpl_channel_credentials.cc:76
char * user
Definition: mysqladmin.cc:59
String_set username
Definition: rpl_channel_credentials.h:33
std::map< std::string, Channel_cred_param > m_credential_set
Definition: rpl_channel_credentials.h:50
Definition: rpl_channel_credentials.h:32
virtual ~Rpl_channel_credentials()
Destructor.
Definition: rpl_channel_credentials.h:60
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:43
std::pair< bool, std::string > String_set
Definition: rpl_channel_credentials.h:29
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:62
void reset()
Delete all stored credentials and delete instance.
Definition: rpl_channel_credentials.cc:27
String_set password
Definition: rpl_channel_credentials.h:34
Definition: rpl_channel_credentials.h:31
int number_of_channels()
Number of channels stored.
Definition: rpl_channel_credentials.cc:38
String_set plugin_auth
Definition: rpl_channel_credentials.h:35
static Rpl_channel_credentials & get_instance()
Returns object.
Definition: rpl_channel_credentials.cc:32
Channel_cred_param(char *username_arg, char *password_arg, char *plugin_auth_arg)
Definition: rpl_channel_credentials.h:37
std::pair< std::string, Channel_cred_param > channel_credential_pair
Definition: rpl_channel_credentials.h:49