Mercurial > hg > ltpda
changeset 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 | a59cdb8aaf31 |
files | m-toolbox/classes/@LTPDADatabaseConnectionManager/LTPDADatabaseConnectionManager.m |
diffstat | 1 files changed, 20 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- 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);