| 173 | namespace EDS { |
| 174 | |
| 175 | bool validatePassword(thread_db* tdbb, const PathName& file, ClumpletWriter& dpb) |
| 176 | { |
| 177 | // Preliminary checks - should we really validate the password ourselves |
| 178 | if (!dpb.find(isc_dpb_user_name)) // check for user name presence |
| 179 | return false; |
| 180 | if (ISC_check_if_remote(file, false)) // check for remote connection |
| 181 | return false; |
| 182 | UserId* usr = tdbb->getAttachment()->att_user; |
| 183 | if (!usr) |
| 184 | return false; |
| 185 | if (!usr->usr_auth_block.hasData()) // check for embedded attachment |
| 186 | return false; |
| 187 | |
| 188 | Arg::Gds loginError(isc_login_error); |
| 189 | |
| 190 | // Build list of client/server plugins |
| 191 | RefPtr<const Config> config; |
| 192 | PathName list; |
| 193 | expandDatabaseName(file, list /* unused value */, &config); |
| 194 | PathName serverList = config->getPlugins(IPluginManager::TYPE_AUTH_SERVER); |
| 195 | PathName clientList = config->getPlugins(IPluginManager::TYPE_AUTH_CLIENT); |
| 196 | ParsedList::mergeLists(list, serverList, clientList); |
| 197 | |
| 198 | if (!list.hasData()) |
| 199 | { |
| 200 | Arg::Gds noPlugins(isc_vld_plugins); |
| 201 | iscLogStatus(NULL, noPlugins.value()); |
| 202 | |
| 203 | #ifdef DEV_BUILD |
| 204 | loginError << noPlugins; |
| 205 | #endif |
| 206 | loginError.raise(); |
| 207 | } |
| 208 | |
| 209 | // Analyze DPB |
| 210 | string login; |
| 211 | if (dpb.find(isc_dpb_user_name)) |
| 212 | { |
| 213 | dpb.getString(login); |
| 214 | fb_utils::dpbItemUpper(login); |
| 215 | } |
| 216 | string password; |
| 217 | if (dpb.find(isc_dpb_password)) |
| 218 | dpb.getString(password); |
| 219 | |
| 220 | // Try each plugin from the merged list |
| 221 | for (GetPlugins<IClient> client(IPluginManager::TYPE_AUTH_CLIENT, config, list.c_str()); |
| 222 | client.hasData(); client.next()) |
| 223 | { |
| 224 | GetPlugins<IServer> server(IPluginManager::TYPE_AUTH_SERVER, config, client.name()); |
| 225 | if (!server.hasData()) |
| 226 | continue; |
| 227 | |
| 228 | CBlock cBlock(login, password); |
| 229 | SBlock sBlock(&cBlock); |
| 230 | Auth::WriterImplementation writer; |
| 231 | writer.setPlugin(client.name()); |
| 232 |
no test coverage detected