22using System . Collections . Generic ;
33using System . Xml ;
44using Bring . SPODataQuality ;
5+ using Bring . Security ;
56using System . Linq ;
67
78namespace Bring . XmlConfig
@@ -183,8 +184,15 @@ public static HashSet<string> GetIgnoredColumns()
183184 /// <exception cref="InvalidOperationException">Thrown when required configuration elements are missing or invalid.</exception>
184185 public static ( string Username , string Password ) GetSharePointCredentials ( )
185186 {
186- LoadConfig ( ) ;
187+ try
188+ {
189+ return CredentialManager . GetSharePointCredentials ( ) ;
190+ }
191+ catch
192+ {
193+ }
187194
195+ LoadConfig ( ) ;
188196 try
189197 {
190198 var spNode = _xmlDoc . SelectSingleNode ( "//Configuration/SharePoint" ) ;
@@ -196,26 +204,25 @@ public static (string Username, string Password) GetSharePointCredentials()
196204
197205 if ( usernameNode == null )
198206 throw new InvalidOperationException ( "Username element not found in SharePoint configuration." ) ;
199-
207+
200208 if ( passwordNode == null )
201209 throw new InvalidOperationException ( "Password element not found in SharePoint configuration." ) ;
202210
203211 var username = usernameNode . InnerText . Trim ( ) ;
204212 var password = passwordNode . InnerText . Trim ( ) ;
205213
206- // Basic validation
207214 if ( string . IsNullOrEmpty ( username ) )
208215 throw new InvalidOperationException ( "Username cannot be empty." ) ;
209-
216+
210217 if ( string . IsNullOrEmpty ( password ) )
211218 throw new InvalidOperationException ( "Password cannot be empty." ) ;
212219
213- Logger . Log ( 2 , "SharePoint credentials retrieved successfully." ) ;
220+ Logger . Log ( 2 , "SharePoint credentials retrieved successfully from XML config ." ) ;
214221 return ( username , password ) ;
215222 }
216223 catch ( InvalidOperationException )
217224 {
218- throw ; // Re-throw configuration-specific exceptions
225+ throw ;
219226 }
220227 catch ( Exception ex )
221228 {
@@ -224,16 +231,17 @@ public static (string Username, string Password) GetSharePointCredentials()
224231 }
225232 }
226233
227- /// <summary>
228- /// Retrieves the SQL Server connection string from the configuration file.
229- /// </summary>
230- /// <returns>The SQL Server connection string.</returns>
231- /// <exception cref="FileNotFoundException">Thrown when the configuration file is not found.</exception>
232- /// <exception cref="InvalidOperationException">Thrown when the connection string configuration is missing or invalid.</exception>
233234 public static string GetSqlConnectionString ( )
234235 {
235- LoadConfig ( ) ;
236+ try
237+ {
238+ return CredentialManager . GetSqlConnectionString ( ) ;
239+ }
240+ catch
241+ {
242+ }
236243
244+ LoadConfig ( ) ;
237245 try
238246 {
239247 var connNode = _xmlDoc . SelectSingleNode ( "//Configuration/SQL/ConnectionString" ) ;
@@ -244,12 +252,12 @@ public static string GetSqlConnectionString()
244252 if ( string . IsNullOrEmpty ( connectionString ) )
245253 throw new InvalidOperationException ( "SQL connection string cannot be empty." ) ;
246254
247- Logger . Log ( 2 , "SQL connection string retrieved successfully." ) ;
255+ Logger . Log ( 2 , "SQL connection string retrieved successfully from XML config ." ) ;
248256 return connectionString ;
249257 }
250258 catch ( InvalidOperationException )
251259 {
252- throw ; // Re-throw configuration-specific exceptions
260+ throw ;
253261 }
254262 catch ( Exception ex )
255263 {
0 commit comments