importing messaging-2008 branch to trunk.
[mono.git] / mcs / class / System.Web / System.Web.Security / SqliteRoleProvider.cs
1 //
2 // $Id: PgRoleProvider.cs 12 2007-10-17 17:22:43Z dna $
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
11 // 
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 // 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 //
23 // Copyright © 2006, 2007 Nauck IT KG           http://www.nauck-it.de
24 //
25 // Author:
26 //      Daniel Nauck            <d.nauck(at)nauck-it.de>
27 //
28 // Adapted to Sqlite by Marek Habersack <mhabersack@novell.com>
29 //
30
31 #if NET_2_0
32 using System;
33 using System.Data;
34 using System.Data.Common;
35 using System.Collections.Generic;
36 using System.Collections.Specialized;
37 using System.Diagnostics;
38 using System.Text;
39 using System.Configuration;
40 using System.Configuration.Provider;
41 using System.Web.Hosting;
42 using System.Web.Security;
43
44 using Mono.Data.Sqlite;
45
46 namespace System.Web.Security
47 {
48         internal class SqliteRoleProvider : RoleProvider
49         {
50                 const string m_RolesTableName = "Roles";
51                 const string m_UserInRolesTableName = "UsersInRoles";
52                 string m_ConnectionString = string.Empty;
53
54                 DbParameter AddParameter (DbCommand command, string parameterName)
55                 {
56                         return AddParameter (command, parameterName, null);
57                 }
58                 
59                 DbParameter AddParameter (DbCommand command, string parameterName, object parameterValue)
60                 {
61                         return AddParameter (command, parameterName, ParameterDirection.Input, parameterValue);
62                 }
63
64                 DbParameter AddParameter (DbCommand command, string parameterName, ParameterDirection direction, object parameterValue)
65                 {
66                         DbParameter dbp = command.CreateParameter ();
67                         dbp.ParameterName = parameterName;
68                         dbp.Value = parameterValue;
69                         dbp.Direction = direction;
70                         command.Parameters.Add (dbp);
71                         return dbp;
72                 }
73                 
74                 /// <summary>
75                 /// System.Configuration.Provider.ProviderBase.Initialize Method
76                 /// </summary>
77                 public override void Initialize(string name, NameValueCollection config)
78                 {
79                         // Initialize values from web.config.
80                         if (config == null)
81                                 throw new ArgumentNullException("Config", Properties.Resources.ErrArgumentNull);
82
83                         if (string.IsNullOrEmpty(name))
84                                 name = Properties.Resources.RoleProviderDefaultName;
85
86                         if (string.IsNullOrEmpty(config["description"]))
87                         {
88                                 config.Remove("description");
89                                 config.Add("description", Properties.Resources.RoleProviderDefaultDescription);
90                         }
91
92                         // Initialize the abstract base class.
93                         base.Initialize(name, config);
94
95                         m_ApplicationName = GetConfigValue(config["applicationName"], HostingEnvironment.ApplicationVirtualPath);
96
97                         // Get connection string.
98                         string connStrName = config["connectionStringName"];
99
100                         if (string.IsNullOrEmpty(connStrName))
101                         {
102                                 throw new ArgumentOutOfRangeException("ConnectionStringName", Properties.Resources.ErrArgumentNullOrEmpty);
103                         }
104                         else
105                         {
106                                 ConnectionStringSettings ConnectionStringSettings = ConfigurationManager.ConnectionStrings[connStrName];
107
108                                 if (ConnectionStringSettings == null || string.IsNullOrEmpty(ConnectionStringSettings.ConnectionString.Trim()))
109                                 {
110                                         throw new ProviderException(Properties.Resources.ErrConnectionStringNullOrEmpty);
111                                 }
112
113                                 m_ConnectionString = ConnectionStringSettings.ConnectionString;
114                         }
115                 }
116
117                 /// <summary>
118                 /// System.Web.Security.RoleProvider properties.
119                 /// </summary>
120                 #region System.Web.Security.RoleProvider properties
121                 string m_ApplicationName = string.Empty;
122
123                 public override string ApplicationName
124                 {
125                         get { return m_ApplicationName; }
126                         set { m_ApplicationName = value; }
127                 }
128                 #endregion
129
130                 /// <summary>
131                 /// System.Web.Security.RoleProvider methods.
132                 /// </summary>
133                 #region System.Web.Security.RoleProvider methods
134
135                 /// <summary>
136                 /// RoleProvider.AddUsersToRoles
137                 /// </summary>
138                 public override void AddUsersToRoles(string[] userNames, string[] roleNames)
139                 {
140                         foreach (string rolename in roleNames)
141                         {
142                                 if (!RoleExists(rolename))
143                                 {
144                                         throw new ProviderException(string.Format(Properties.Resources.ErrRoleNotExist, rolename));
145                                 }
146                         }
147
148                         foreach (string username in userNames)
149                         {
150                                 foreach (string rolename in roleNames)
151                                 {
152                                         if (IsUserInRole(username, rolename))
153                                         {
154                                                 throw new ProviderException(string.Format(Properties.Resources.ErrUserAlreadyInRole, username, rolename));
155                                         }
156                                 }
157                         }
158
159                         using (SqliteConnection dbConn = new SqliteConnection(m_ConnectionString))
160                         {
161                                 using (SqliteCommand dbCommand = dbConn.CreateCommand())
162                                 {
163                                         dbCommand.CommandText = string.Format("INSERT INTO \"{0}\" (\"Username\", \"Rolename\", \"ApplicationName\") Values (@Username, @Rolename, @ApplicationName)", m_UserInRolesTableName);
164
165                                         AddParameter (dbCommand, "@Username");
166                                         AddParameter (dbCommand, "@Rolename");
167                                         AddParameter (dbCommand, "@ApplicationName", m_ApplicationName);
168
169                                         SqliteTransaction dbTrans = null;
170
171                                         try
172                                         {
173                                                 dbConn.Open();
174                                                 dbCommand.Prepare();
175
176                                                 using (dbTrans = dbConn.BeginTransaction())
177                                                 {
178                                                         foreach (string username in userNames)
179                                                         {
180                                                                 foreach (string rolename in roleNames)
181                                                                 {
182                                                                         dbCommand.Parameters["@Username"].Value = username;
183                                                                         dbCommand.Parameters["@Rolename"].Value = rolename;
184                                                                         dbCommand.ExecuteNonQuery();
185                                                                 }
186                                                         }
187                                                         // Attempt to commit the transaction
188                                                         dbTrans.Commit();
189                                                 }
190                                         }
191                                         catch (SqliteException e)
192                                         {
193                                                 Trace.WriteLine(e.ToString());
194
195                                                 try
196                                                 {
197                                                         // Attempt to roll back the transaction
198                                                         Trace.WriteLine(Properties.Resources.LogRollbackAttempt);
199                                                         dbTrans.Rollback();
200                                                 }
201                                                 catch (SqliteException re)
202                                                 {
203                                                         // Rollback failed
204                                                         Trace.WriteLine(Properties.Resources.ErrRollbackFailed);
205                                                         Trace.WriteLine(re.ToString());
206                                                 }
207
208                                                 throw new ProviderException(Properties.Resources.ErrOperationAborted);
209                                         }
210                                         finally
211                                         {
212                                                 if (dbConn != null)
213                                                         dbConn.Close();
214                                         }
215                                 }
216                         }
217                 }
218
219                 /// <summary>
220                 /// RoleProvider.CreateRole
221                 /// </summary>
222                 public override void CreateRole(string roleName)
223                 {
224                         if (RoleExists(roleName))
225                         {
226                                 throw new ProviderException(string.Format(Properties.Resources.ErrRoleAlreadyExist, roleName));
227                         }
228
229                         using (SqliteConnection dbConn = new SqliteConnection(m_ConnectionString))
230                         {
231                                 using (SqliteCommand dbCommand = dbConn.CreateCommand())
232                                 {
233                                         dbCommand.CommandText = string.Format("INSERT INTO \"{0}\" (\"Rolename\", \"ApplicationName\") Values (@Rolename, @ApplicationName)", m_RolesTableName);
234
235                                         AddParameter (dbCommand, "@Rolename", roleName);
236                                         AddParameter (dbCommand, "@ApplicationName", m_ApplicationName);
237
238                                         try
239                                         {
240                                                 dbConn.Open();
241                                                 dbCommand.Prepare();
242
243                                                 dbCommand.ExecuteNonQuery();
244                                         }
245                                         catch (SqliteException e)
246                                         {
247                                                 Trace.WriteLine(e.ToString());
248                                                 throw new ProviderException(Properties.Resources.ErrOperationAborted);
249                                         }
250                                         finally
251                                         {
252                                                 if (dbConn != null)
253                                                         dbConn.Close();
254                                         }
255                                 }
256                         }
257                 }
258
259                 /// <summary>
260                 /// RoleProvider.DeleteRole
261                 /// </summary>
262                 public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
263                 {
264                         if (!RoleExists(roleName))
265                         {
266                                 throw new ProviderException(string.Format(Properties.Resources.ErrRoleNotExist, roleName));
267                         }
268
269                         if (throwOnPopulatedRole && GetUsersInRole(roleName).Length > 0)
270                         {
271                                 throw new ProviderException(Properties.Resources.ErrCantDeletePopulatedRole);
272                         }
273
274                         using (SqliteConnection dbConn = new SqliteConnection(m_ConnectionString))
275                         {
276                                 using (SqliteCommand dbCommand = dbConn.CreateCommand())
277                                 {
278                                         dbCommand.CommandText = string.Format("DELETE FROM \"{0}\" WHERE \"Rolename\" = @Rolename AND \"ApplicationName\" = @ApplicationName", m_RolesTableName);
279
280                                         AddParameter (dbCommand, "@Rolename", roleName);
281                                         AddParameter (dbCommand, "@ApplicationName", m_ApplicationName);
282
283                                         SqliteTransaction dbTrans = null;
284
285                                         try
286                                         {
287                                                 dbConn.Open();
288                                                 dbCommand.Prepare();
289
290                                                 using (dbTrans = dbConn.BeginTransaction())
291                                                 {
292                                                         dbCommand.ExecuteNonQuery();
293
294                                                         // Attempt to commit the transaction
295                                                         dbTrans.Commit();
296                                                 }
297                                         }
298                                         catch (SqliteException e)
299                                         {
300                                                 Trace.WriteLine(e.ToString());
301
302                                                 try
303                                                 {
304                                                         // Attempt to roll back the transaction
305                                                         Trace.WriteLine(Properties.Resources.LogRollbackAttempt);
306                                                         dbTrans.Rollback();
307                                                 }
308                                                 catch (SqliteException re)
309                                                 {
310                                                         // Rollback failed
311                                                         Trace.WriteLine(Properties.Resources.ErrRollbackFailed);
312                                                         Trace.WriteLine(re.ToString());
313                                                 }
314
315                                                 throw new ProviderException(Properties.Resources.ErrOperationAborted);
316                                         }
317                                         finally
318                                         {
319                                                 if (dbConn != null)
320                                                         dbConn.Close();
321                                         }
322                                 }
323                         }
324
325                         return true;
326                 }
327
328                 /// <summary>
329                 /// RoleProvider.FindUsersInRole
330                 /// </summary>
331                 public override string[] FindUsersInRole(string roleName, string usernameToMatch)
332                 {
333                         List<string> userList = new List<string>();
334
335                         using (SqliteConnection dbConn = new SqliteConnection(m_ConnectionString))
336                         {
337                                 using (SqliteCommand dbCommand = dbConn.CreateCommand())
338                                 {
339                                         dbCommand.CommandText = string.Format("SELECT \"Username\" FROM \"{0}\" WHERE \"Username\" LIKE @Username AND \"Rolename\" = @Rolename AND \"ApplicationName\" = @ApplicationName ORDER BY \"Username\" ASC", m_UserInRolesTableName);
340
341                                         AddParameter (dbCommand, "@Username", usernameToMatch);
342                                         AddParameter (dbCommand, "@Rolename", roleName);
343                                         AddParameter (dbCommand, "@ApplicationName", m_ApplicationName);
344
345                                         try
346                                         {
347                                                 dbConn.Open();
348                                                 dbCommand.Prepare();
349
350                                                 using (SqliteDataReader reader = dbCommand.ExecuteReader())
351                                                 {
352                                                         if (reader.HasRows)
353                                                         {
354                                                                 while (reader.Read())
355                                                                 {
356                                                                         userList.Add(reader.GetString(0));
357                                                                 }
358                                                         }
359                                                 }
360                                         }
361                                         catch (SqliteException e)
362                                         {
363                                                 Trace.WriteLine(e.ToString());
364                                                 throw new ProviderException(Properties.Resources.ErrOperationAborted);
365                                         }
366                                         finally
367                                         {
368                                                 if (dbConn != null)
369                                                         dbConn.Close();
370                                         }
371                                 }
372                         }
373
374                         return userList.ToArray();
375                 }
376
377                 /// <summary>
378                 /// RoleProvider.GetAllRoles
379                 /// </summary>
380                 public override string[] GetAllRoles()
381                 {
382                         List<string> rolesList = new List<string>();
383
384                         using (SqliteConnection dbConn = new SqliteConnection(m_ConnectionString))
385                         {
386                                 using (SqliteCommand dbCommand = dbConn.CreateCommand())
387                                 {
388                                         dbCommand.CommandText = string.Format("SELECT \"Rolename\" FROM \"{0}\" WHERE \"ApplicationName\" = @ApplicationName ORDER BY \"Rolename\" ASC", m_RolesTableName);
389
390                                         AddParameter (dbCommand, "@ApplicationName", m_ApplicationName);
391
392                                         try
393                                         {
394                                                 dbConn.Open();
395                                                 dbCommand.Prepare();
396
397                                                 using (SqliteDataReader reader = dbCommand.ExecuteReader())
398                                                 {
399                                                         while (reader.Read())
400                                                         {
401                                                                 rolesList.Add(reader.GetString(0));
402                                                         }
403                                                 }                                               
404                                         }
405                                         catch (SqliteException e)
406                                         {
407                                                 Trace.WriteLine(e.ToString());
408                                                 throw new ProviderException(Properties.Resources.ErrOperationAborted);
409                                         }
410                                         finally
411                                         {
412                                                 if (dbConn != null)
413                                                         dbConn.Close();
414                                         }
415                                 }
416                         }
417
418                         return rolesList.ToArray();
419                 }
420
421                 /// <summary>
422                 /// RoleProvider.GetRolesForUser
423                 /// </summary>
424                 public override string[] GetRolesForUser(string username)
425                 {
426                         List<string> rolesList = new List<string>();
427
428                         using (SqliteConnection dbConn = new SqliteConnection(m_ConnectionString))
429                         {
430                                 using (SqliteCommand dbCommand = dbConn.CreateCommand())
431                                 {
432                                         dbCommand.CommandText = string.Format("SELECT \"Rolename\" FROM \"{0}\" WHERE \"Username\" = @Username AND \"ApplicationName\" = @ApplicationName ORDER BY \"Rolename\" ASC", m_UserInRolesTableName);
433
434                                         AddParameter (dbCommand, "@Username", username);
435                                         AddParameter (dbCommand, "@ApplicationName", m_ApplicationName);
436
437                                         try
438                                         {
439                                                 dbConn.Open();
440                                                 dbCommand.Prepare();
441
442                                                 using (SqliteDataReader reader = dbCommand.ExecuteReader())
443                                                 {
444                                                         if (reader.HasRows)
445                                                         {
446                                                                 while (reader.Read())
447                                                                 {
448                                                                         rolesList.Add(reader.GetString(0));
449                                                                 }
450                                                         }
451                                                 }
452                                         }
453                                         catch (SqliteException e)
454                                         {
455                                                 Trace.WriteLine(e.ToString());
456                                                 throw new ProviderException(Properties.Resources.ErrOperationAborted);
457                                         }
458                                         finally
459                                         {
460                                                 if (dbConn != null)
461                                                         dbConn.Close();
462                                         }
463                                 }
464                         }
465
466                         return rolesList.ToArray();
467                 }
468
469                 /// <summary>
470                 /// RoleProvider.GetUsersInRole
471                 /// </summary>
472                 public override string[] GetUsersInRole(string roleName)
473                 {
474                         List<string> userList = new List<string>();
475
476                         using (SqliteConnection dbConn = new SqliteConnection(m_ConnectionString))
477                         {
478                                 using (SqliteCommand dbCommand = dbConn.CreateCommand())
479                                 {
480                                         dbCommand.CommandText = string.Format("SELECT \"Username\" FROM \"{0}\" WHERE \"Rolename\" = @Rolename AND \"ApplicationName\" = @ApplicationName ORDER BY \"Username\" ASC", m_UserInRolesTableName);
481
482                                         AddParameter (dbCommand, "@Rolename", roleName);
483                                         AddParameter (dbCommand, "@ApplicationName", m_ApplicationName);
484
485                                         try
486                                         {
487                                                 dbConn.Open();
488                                                 dbCommand.Prepare();
489
490                                                 using (SqliteDataReader reader = dbCommand.ExecuteReader())
491                                                 {
492                                                         if (reader.HasRows)
493                                                         {
494                                                                 while (reader.Read())
495                                                                 {
496                                                                         userList.Add(reader.GetString(0));
497                                                                 }
498                                                         }
499                                                 }
500                                         }
501                                         catch (SqliteException e)
502                                         {
503                                                 Trace.WriteLine(e.ToString());
504                                                 throw new ProviderException(Properties.Resources.ErrOperationAborted);
505                                         }
506                                         finally
507                                         {
508                                                 if (dbConn != null)
509                                                         dbConn.Close();
510                                         }
511                                 }
512                         }
513
514                         return userList.ToArray();
515                 }
516
517                 /// <summary>
518                 /// RoleProvider.IsUserInRole
519                 /// </summary>
520                 public override bool IsUserInRole(string userName, string roleName)
521                 {
522                         using (SqliteConnection dbConn = new SqliteConnection(m_ConnectionString))
523                         {
524                                 using (SqliteCommand dbCommand = dbConn.CreateCommand())
525                                 {
526                                         dbCommand.CommandText = string.Format("SELECT COUNT(*) FROM \"{0}\" WHERE \"Username\" = @Username AND \"Rolename\" = @Rolename AND \"ApplicationName\" = @ApplicationName", m_UserInRolesTableName);
527
528                                         AddParameter (dbCommand, "@Username", userName);
529                                         AddParameter (dbCommand, "@Rolename", roleName);
530                                         AddParameter (dbCommand, "@ApplicationName", m_ApplicationName);
531
532                                         try
533                                         {
534                                                 dbConn.Open();
535                                                 dbCommand.Prepare();
536
537                                                 int numRecs = 0;
538                                                 Int32.TryParse(dbCommand.ExecuteScalar().ToString(), out numRecs);
539
540                                                 if (numRecs > 0)
541                                                         return true;
542                                         }
543                                         catch (SqliteException e)
544                                         {
545                                                 Trace.WriteLine(e.ToString());
546                                                 throw new ProviderException(Properties.Resources.ErrOperationAborted);
547                                         }
548                                         finally
549                                         {
550                                                 if (dbConn != null)
551                                                         dbConn.Close();
552                                         }
553                                 }
554                         }
555
556                         return false;
557                 }
558
559                 /// <summary>
560                 /// RoleProvider.RemoveUsersFromRoles
561                 /// </summary>
562                 public override void RemoveUsersFromRoles(string[] userNames, string[] roleNames)
563                 {
564                         foreach (string rolename in roleNames)
565                         {
566                                 if (!RoleExists(rolename))
567                                 {
568                                         throw new ProviderException(string.Format(Properties.Resources.ErrRoleNotExist, rolename));
569                                 }
570                         }
571
572                         foreach (string username in userNames)
573                         {
574                                 foreach (string rolename in roleNames)
575                                 {
576                                         if (!IsUserInRole(username, rolename))
577                                         {
578                                                 throw new ProviderException(string.Format(Properties.Resources.ErrUserIsNotInRole, username, rolename));
579                                         }
580                                 }
581                         }
582
583                         using (SqliteConnection dbConn = new SqliteConnection(m_ConnectionString))
584                         {
585                                 using (SqliteCommand dbCommand = dbConn.CreateCommand())
586                                 {
587                                         dbCommand.CommandText = string.Format("DELETE FROM \"{0}\" WHERE \"Username\" = @Username AND \"Rolename\" = @Rolename AND \"ApplicationName\" = @ApplicationName", m_UserInRolesTableName);
588
589                                         AddParameter (dbCommand, "@Username");
590                                         AddParameter (dbCommand, "@Rolename");
591                                         AddParameter (dbCommand, "@ApplicationName", m_ApplicationName);
592
593                                         SqliteTransaction dbTrans = null;
594
595                                         try
596                                         {
597                                                 dbConn.Open();
598                                                 dbCommand.Prepare();
599
600                                                 using (dbTrans = dbConn.BeginTransaction())
601                                                 {
602                                                         foreach (string username in userNames)
603                                                         {
604                                                                 foreach (string rolename in roleNames)
605                                                                 {
606                                                                         dbCommand.Parameters["@Username"].Value = username;
607                                                                         dbCommand.Parameters["@Rolename"].Value = rolename;
608                                                                         dbCommand.ExecuteNonQuery();
609                                                                 }
610                                                         }
611                                                         // Attempt to commit the transaction
612                                                         dbTrans.Commit();
613                                                 }
614                                         }
615                                         catch (SqliteException e)
616                                         {
617                                                 Trace.WriteLine(e.ToString());
618
619                                                 try
620                                                 {
621                                                         // Attempt to roll back the transaction
622                                                         Trace.WriteLine(Properties.Resources.LogRollbackAttempt);
623                                                         dbTrans.Rollback();
624                                                 }
625                                                 catch (SqliteException re)
626                                                 {
627                                                         // Rollback failed
628                                                         Trace.WriteLine(Properties.Resources.ErrRollbackFailed);
629                                                         Trace.WriteLine(re.ToString());
630                                                 }
631
632                                                 throw new ProviderException(Properties.Resources.ErrOperationAborted);
633                                         }
634                                         finally
635                                         {
636                                                 if (dbConn != null)
637                                                         dbConn.Close();
638                                         }
639                                 }
640                         }
641                 }
642
643                 /// <summary>
644                 /// RoleProvider.RoleExists
645                 /// </summary>
646                 public override bool RoleExists(string roleName)
647                 {
648                         using (SqliteConnection dbConn = new SqliteConnection(m_ConnectionString))
649                         {
650                                 using (SqliteCommand dbCommand = dbConn.CreateCommand())
651                                 {
652                                         dbCommand.CommandText = string.Format("SELECT COUNT(*) FROM \"{0}\" WHERE \"Rolename\" = @Rolename AND \"ApplicationName\" = @ApplicationName", m_RolesTableName);
653
654                                         AddParameter (dbCommand, "@Rolename", roleName);
655                                         AddParameter (dbCommand, "@ApplicationName", m_ApplicationName);
656
657                                         try
658                                         {
659                                                 dbConn.Open();
660                                                 dbCommand.Prepare();
661
662                                                 int numRecs = 0;
663                                                 Int32.TryParse(dbCommand.ExecuteScalar().ToString(), out numRecs);
664
665                                                 if (numRecs > 0)
666                                                         return true;
667                                         }
668                                         catch (SqliteException e)
669                                         {
670                                                 Trace.WriteLine(e.ToString());
671                                                 throw new ProviderException(Properties.Resources.ErrOperationAborted);
672                                         }
673                                         finally
674                                         {
675                                                 if (dbConn != null)
676                                                         dbConn.Close();
677                                         }
678                                 }
679                         }
680
681                         return false;
682                 }
683                 #endregion
684
685                 #region private methods
686                 /// <summary>
687                 /// A helper function to retrieve config values from the configuration file.
688                 /// </summary>
689                 /// <param name="configValue"></param>
690                 /// <param name="defaultValue"></param>
691                 /// <returns></returns>
692                 string GetConfigValue(string configValue, string defaultValue)
693                 {
694                         if (string.IsNullOrEmpty(configValue))
695                                 return defaultValue;
696
697                         return configValue;
698                 }
699                 #endregion      
700         }
701 }
702 #endif