comparison m-toolbox/classes/@LTPDADatabaseConnectionManager/LTPDADatabaseConnectionManager.m @ 42:f90d4f666cc7 database-connection-manager

Cleanup
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 18:04:34 +0100
parents 6def6533cb16
children
comparison
equal deleted inserted replaced
41:6def6533cb16 42:f90d4f666cc7
322 end 322 end
323 323
324 case 3 324 case 3
325 % find credentials 325 % find credentials
326 cred = cm.findCredentials(varargin{1}, varargin{2}, varargin{3}); 326 cred = cm.findCredentials(varargin{1}, varargin{2}, varargin{3});
327 switch numel(cred) 327 if numel(cred) == 0
328 case 0 328 % no credentials found
329 % no credentials found 329 usernames = { varargin{3} };
330 usernames = { varargin{3} }; 330 if isempty(varargin{3})
331 if isempty(varargin{3}) 331 % use usernames for same hostname
332 % use usernames for same hostname 332 tmp = cm.findCredentials(varargin{1});
333 tmp = cm.findCredentials(varargin{1}); 333 if ~isempty(tmp)
334 if ~isempty(tmp) 334 usernames = { tmp(:).username };
335 usernames = { tmp(:).username };
336 end
337 end 335 end
338 % build credentials objects 336 end
339 tmp = {}; 337 % build credentials objects
340 for kk = 1:numel(usernames) 338 tmp = {};
341 tmp{kk} = utils.credentials(varargin{1}, varargin{2}, usernames{kk}); 339 for kk = 1:numel(usernames)
342 end 340 tmp{kk} = utils.credentials(varargin{1}, varargin{2}, usernames{kk});
343 % convert from cell array to array 341 end
344 cred = [tmp{:}]; 342 % convert from cell array to array
345 case 1 343 cred = [tmp{:}];
346 % credentials in cache 344 else
347 utils.helper.msg(msg.PROC1, 'use cached credentials'); 345 % credentials in cache
348 otherwise 346 utils.helper.msg(msg.PROC1, 'use cached credentials');
349 % we should not have more than one credentials set
350 error('### more than one credentials set matching');
351 end 347 end
352 348
353 cache = false; 349 cache = false;
354 if (numel(cred) > 1) || ~cred.complete 350 if (numel(cred) > 1) || ~cred.complete
355 % ask for password 351 % ask for password
356 [username, password, cache] = cm.inputCredentials(cred, cm.userMessage); 352 [username, password, cache] = cm.inputCredentials(cred, cm.userMessage);
357 353
358 % cache credentials 354 % cache credentials
359 cred = utils.credentials(varargin{1}, varargin{2}, username); 355 cred = utils.credentials(varargin{1}, varargin{2}, username);
360 cm.cacheCredentials(cred); 356 cm.cacheCredentials(cred);
361 357
362 % add password to credentials 358 % add password to credentials