|
1 | | -/* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
| 1 | +/* Copyright (c) 2016, 2017 Oracle and/or its affiliates. All rights reserved. |
2 | 2 |
|
3 | 3 | This program is free software; you can redistribute it and/or modify |
4 | 4 | it under the terms of the GNU General Public License as published by |
|
21 | 21 | */ |
22 | 22 |
|
23 | 23 | #include "plugin.h" |
24 | | -#define MYSQL_KEYRING_INTERFACE_VERSION 0x0100 |
| 24 | +#define MYSQL_KEYRING_INTERFACE_VERSION 0x0101 |
25 | 25 |
|
26 | 26 | /** |
27 | 27 | The descriptor structure for the plugin, that is referred from |
@@ -105,5 +105,80 @@ struct st_mysql_keyring |
105 | 105 | */ |
106 | 106 | my_bool (*mysql_key_generate)(const char *key_id, const char *key_type, |
107 | 107 | const char *user_id, size_t key_len); |
| 108 | + |
| 109 | + /** |
| 110 | + Keys_iterator object refers to an iterator which is used to iterate |
| 111 | + on a list which refers to Key_metadata. Key_metadata hold information |
| 112 | + about individual keys keyd_id and user_id. Keys_iterator should be used |
| 113 | + in following sequence only. |
| 114 | +
|
| 115 | + void* iterator_ptr; |
| 116 | + char key_id[64]= { 0 }; |
| 117 | + char user_id[64]= { 0 }; |
| 118 | +
|
| 119 | + plugin_handle->mysql_key_iterator_init(&iterator_ptr); |
| 120 | +
|
| 121 | + if (iterator_ptr == NULL) |
| 122 | + report error; |
| 123 | +
|
| 124 | + while (!(plugin_handle->mysql_key_iterator_get_key(iterator_ptr, |
| 125 | + key_id, user_id))) |
| 126 | + { |
| 127 | + Fetch the keys. |
| 128 | + Perform operations on the fetched keys. |
| 129 | + .. |
| 130 | + } |
| 131 | + plugin_handle->mysql_key_iterator_deinit(iterator_ptr); |
| 132 | +
|
| 133 | + init() method accepts a void pointer which is the made to point to |
| 134 | + Keys_iterator instance. Keys_iterator instance internal pointer points |
| 135 | + to Key_metadata list. This list holds information about all keys stored |
| 136 | + in the backed end data store of keyring plugin. After call to init() |
| 137 | + please check iterator_ptr. |
| 138 | +
|
| 139 | + get_key() method accepts the above iterator_ptr as IN param and then |
| 140 | + fills the passes in key_id and user_id with valid values. This can be |
| 141 | + used to fetch actual key information. Every call to this method will |
| 142 | + change internal pointers to advance to next position, so that the next |
| 143 | + call will fetch the next key. |
| 144 | +
|
| 145 | + deinit() method frees all internal pointers along with iterator_ptr. |
| 146 | + */ |
| 147 | + /** |
| 148 | + Initialize an iterator. |
| 149 | +
|
| 150 | + @param[out] key_iterator Iterator used to fetch individual keys |
| 151 | + from key_container. |
| 152 | +
|
| 153 | + @return VOID |
| 154 | + */ |
| 155 | + void (*mysql_key_iterator_init)(void** key_iterator); |
| 156 | + |
| 157 | + /** |
| 158 | + Deinitialize an iterator. |
| 159 | +
|
| 160 | + @param[in] key_iterator Iterator used to fetch individual keys |
| 161 | + from key_container. |
| 162 | +
|
| 163 | + @return VOID |
| 164 | + */ |
| 165 | + void (*mysql_key_iterator_deinit)(void* key_iterator); |
| 166 | + |
| 167 | + /** |
| 168 | + Get details of key. Every call to this service will change |
| 169 | + internal pointers to advance to next position, so that the next call |
| 170 | + will fetch the next key. In case iterator moves to the end, this service |
| 171 | + will return error. |
| 172 | +
|
| 173 | + @param[in] key_iterator Iterator used to fetch individual keys |
| 174 | + from key_container. |
| 175 | + @param[out] key_id id of the key |
| 176 | + @param[out] user_id id of the owner |
| 177 | +
|
| 178 | + @return Operation status |
| 179 | + @retval 0 OK |
| 180 | + @retval 1 ERROR |
| 181 | + */ |
| 182 | + bool (*mysql_key_iterator_get_key)(void* key_iterator, char *key_id, char *user_id); |
108 | 183 | }; |
109 | 184 | #endif |
0 commit comments