# HG changeset patch # User Daniele Nicolodi # Date 1323104674 -3600 # Node ID f90d4f666cc76594658c7a4186adddee9bb02cce # Parent 6def6533cb1656841ec48fd0686de828914b6cf1 Cleanup diff -r 6def6533cb16 -r f90d4f666cc7 m-toolbox/classes/@LTPDADatabaseConnectionManager/LTPDADatabaseConnectionManager.m --- a/m-toolbox/classes/@LTPDADatabaseConnectionManager/LTPDADatabaseConnectionManager.m Mon Dec 05 18:04:34 2011 +0100 +++ b/m-toolbox/classes/@LTPDADatabaseConnectionManager/LTPDADatabaseConnectionManager.m Mon Dec 05 18:04:34 2011 +0100 @@ -324,37 +324,33 @@ case 3 % find credentials cred = cm.findCredentials(varargin{1}, varargin{2}, varargin{3}); - switch numel(cred) - case 0 - % no credentials found - usernames = { varargin{3} }; - if isempty(varargin{3}) - % use usernames for same hostname - tmp = cm.findCredentials(varargin{1}); - if ~isempty(tmp) - usernames = { tmp(:).username }; - end + if numel(cred) == 0 + % no credentials found + usernames = { varargin{3} }; + if isempty(varargin{3}) + % use usernames for same hostname + tmp = cm.findCredentials(varargin{1}); + if ~isempty(tmp) + usernames = { tmp(:).username }; end - % build credentials objects - tmp = {}; - for kk = 1:numel(usernames) - tmp{kk} = utils.credentials(varargin{1}, varargin{2}, usernames{kk}); - end - % convert from cell array to array - cred = [tmp{:}]; - case 1 - % credentials in cache - utils.helper.msg(msg.PROC1, 'use cached credentials'); - otherwise - % we should not have more than one credentials set - error('### more than one credentials set matching'); + end + % build credentials objects + tmp = {}; + for kk = 1:numel(usernames) + tmp{kk} = utils.credentials(varargin{1}, varargin{2}, usernames{kk}); + end + % convert from cell array to array + cred = [tmp{:}]; + else + % credentials in cache + utils.helper.msg(msg.PROC1, 'use cached credentials'); end cache = false; if (numel(cred) > 1) || ~cred.complete % ask for password [username, password, cache] = cm.inputCredentials(cred, cm.userMessage); - + % cache credentials cred = utils.credentials(varargin{1}, varargin{2}, username); cm.cacheCredentials(cred);