Home > database > mysql_login_template.m

mysql_login_template

PURPOSE ^

function params=mysql_login(params)

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 function params=mysql_login(params)

 ensemble_researcher_login_template.m

 Janata Lab, Center for Mind and Brain, UC Davis

 Original Version by Petr Janata
 Edited June 8, 2010 Stefan Tomic - created template from original file. Added 'county' to list of encrypted fields

 Copy this file to a file called "mysql_login.m"
 and save it in a location that is only readable by users that run Ensemble analyses
 This file should not be readable by others.

 params is a structure containing the following fields:
 .host to the hostname where your MySQL database resides (e.g. localhost).
 .database to the name of your ensemble database

 The switch statements provide for conditional branching based on hostname and
 database. If you are supporting database connections to
 multiple hostnames and databases, different user and passwd values can be
 populated for them.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % function params=mysql_login(params)
0002 %
0003 % ensemble_researcher_login_template.m
0004 %
0005 % Janata Lab, Center for Mind and Brain, UC Davis
0006 %
0007 % Original Version by Petr Janata
0008 % Edited June 8, 2010 Stefan Tomic - created template from original file. Added 'county' to list of encrypted fields
0009 %
0010 % Copy this file to a file called "mysql_login.m"
0011 % and save it in a location that is only readable by users that run Ensemble analyses
0012 % This file should not be readable by others.
0013 %
0014 % params is a structure containing the following fields:
0015 % .host to the hostname where your MySQL database resides (e.g. localhost).
0016 % .database to the name of your ensemble database
0017 %
0018 % The switch statements provide for conditional branching based on hostname and
0019 % database. If you are supporting database connections to
0020 % multiple hostnames and databases, different user and passwd values can be
0021 % populated for them.
0022 
0023 %
0024 % Add code to check integrity of .host and .database fields and populate
0025 % with defaults if necessary.
0026 %
0027 
0028 % End of code that checks for host and databse names
0029 
0030 % Check to see if we are going to authenticate with subject or researcher
0031 % privileges. Default to more restrictive subject privileges
0032 if ~isfield(params,'login_type') || isempty(params.login_type)
0033   params.login_type = 'subject'; 
0034 end
0035 
0036 % Determine where files with authentication information live
0037 try auth_root = params.auth_root; catch params.auth_root = '/var/private/'; end
0038 switch params.host
0039   case     {'127.0.0.1','localhost'}
0040    switch db
0041      case {'ensemble_main'}
0042        auth_path = fullfile(params.auth_root,'main');
0043 
0044      case {'ensemble_dev','ensemble_test'}
0045        auth_path = fullfile(params.auth_root,'dev');
0046    
0047    end % switch db
0048 
0049 end % switch host
0050 
0051 % Try to read the authentication information
0052 [user, passwd, enc_key] = ensemble_get_credentials(auth_path,params.login_type);
0053 
0054 % Copy to output structure
0055 params.user = user;
0056 params.passwd = passwd;
0057 params.enc_key = enc_key;
0058 
0059 return

Generated on Wed 20-Mar-2019 04:00:51 by m2html © 2003