History

GSF.Services: Added "LOGIN" command to console application to re-query for credentials or force a re-auth for current user.

ritchiecarroll committed 12 years ago

Commit 62f95691 parent 34274733 files · +55 −36Browse files

Showing the changes to Source/Libraries/GSF.ServiceProcess (1 of 3 files). Show all

Unified · Split

Source/Libraries/GSF.ServiceProcess/ClientHelper.cs+36−25
@@ -185,7 +185,7 @@ namespace GSF.ServiceProcess · 184 unmodified lines
185185 public ClientHelper(IContainer container)
186186 : this()
187187 {
188− if (container != null)
188+ if ((object)container != null)
189189 container.Add(this);
190190 }
191191
@@ -206,7 +206,7 @@ namespace GSF.ServiceProcess · 14 unmodified lines
206206 }
207207 set
208208 {
209− if (m_remotingClient != null)
209+ if ((object)m_remotingClient != null)
210210 {
211211 // Detach events from any existing instance
212212 m_remotingClient.ConnectionEstablished -= RemotingClient_ConnectionEstablished;
@@ -218,7 +218,7 @@ namespace GSF.ServiceProcess · 5 unmodified lines
218218
219219 m_remotingClient = value;
220220
221− if (m_remotingClient != null)
221+ if ((object)m_remotingClient != null)
222222 {
223223 // Attach events to new instance
224224 m_remotingClient.ConnectionEstablished += RemotingClient_ConnectionEstablished;
@@ -245,7 +245,7 @@ namespace GSF.ServiceProcess · 20 unmodified lines
245245 }
246246 set
247247 {
248− if (value == null)
248+ if ((object)value == null)
249249 throw new ArgumentNullException("value");
250250
251251 m_username = value;
@@ -267,7 +267,7 @@ namespace GSF.ServiceProcess · 15 unmodified lines
267267 }
268268 set
269269 {
270− if (value == null)
270+ if ((object)value == null)
271271 throw new ArgumentNullException("value");
272272
273273 m_password = value;
@@ -327,14 +327,14 @@ namespace GSF.ServiceProcess · 53 unmodified lines
327327 {
328328 get
329329 {
330− if (m_remotingClient == null)
330+ if ((object)m_remotingClient == null)
331331 return false;
332332
333333 return m_remotingClient.Enabled;
334334 }
335335 set
336336 {
337− if (m_remotingClient != null)
337+ if ((object)m_remotingClient != null)
338338 m_remotingClient.Enabled = value;
339339 }
340340 }
@@ -420,8 +420,14 @@ namespace GSF.ServiceProcess · 79 unmodified lines
420420 // Save settings under the specified category.
421421 ConfigurationFile config = ConfigurationFile.Current;
422422 CategorizedSettingsElementCollection settings = config.Settings[m_settingsCategory];
423+
423424 settings["Username", true].Update(m_username);
424425 settings["Password", true].Update(m_password);
426+
427+ settings["Username"].Scope = SettingScope.User;
428+ settings["Password"].Scope = SettingScope.User;
429+ settings["Password"].Encrypted = true;
430+
425431 config.Save();
426432 }
427433 }
@@ -441,8 +447,10 @@ namespace GSF.ServiceProcess · 13 unmodified lines
441447 // Load settings from the specified category.
442448 ConfigurationFile config = ConfigurationFile.Current;
443449 CategorizedSettingsElementCollection settings = config.Settings[m_settingsCategory];
444− settings.Add("Username", m_username, "Username to be used for authentication with the service.");
445− settings.Add("Password", m_password, "Password to be used for authentication with the service.", true);
450+
451+ settings.Add("Username", m_username, "Username to be used for authentication with the service.", false, SettingScope.User);
452+ settings.Add("Password", m_password, "Password to be used for authentication with the service.", true, SettingScope.User);
453+
446454 Username = settings["Username"].ValueAs(m_username);
447455 Password = settings["Password"].ValueAs(m_password);
448456 }
@@ -453,17 +461,20 @@ namespace GSF.ServiceProcess · 4 unmodified lines
453461 /// </summary>
454462 public void Connect()
455463 {
456− if (m_remotingClient == null)
464+ if ((object)m_remotingClient == null)
457465 throw new InvalidOperationException("RemotingClient property of ClientHelper component is not set");
458466
459467 m_attemptReconnection = true;
460468 m_authenticationComplete = false;
461− m_remotingClient.Connect(); // Wait for connection.
469+
470+ // Wait for connection.
471+ m_remotingClient.Connect();
462472
463473 while (!m_authenticationComplete && m_remotingClient.Enabled)
464474 {
475+ // Wait for authentication.
465476 Thread.Sleep(100);
466− } // Wait for authentication.
477+ }
467478 }
468479
469480 /// <summary>
@@ -473,7 +484,7 @@ namespace GSF.ServiceProcess · 3 unmodified lines
473484 {
474485 m_attemptReconnection = false;
475486
476− if (m_remotingClient != null)
487+ if ((object)m_remotingClient != null)
477488 m_remotingClient.Disconnect();
478489 }
479490
@@ -485,7 +496,7 @@ namespace GSF.ServiceProcess · 5 unmodified lines
485496 {
486497 ClientRequest requestInstance = ClientRequest.Parse(request);
487498
488− if (requestInstance != null)
499+ if ((object)requestInstance != null)
489500 SendRequest(requestInstance);
490501 else
491502 UpdateStatus(UpdateType.Warning, string.Format("Request command \"{0}\" is invalid\r\n\r\n", request));
@@ -507,7 +518,7 @@ namespace GSF.ServiceProcess · 15 unmodified lines
507518 /// <param name="update">Update message received.</param>
508519 protected virtual void OnReceivedServiceUpdate(UpdateType type, string update)
509520 {
510− if (ReceivedServiceUpdate != null)
521+ if ((object)ReceivedServiceUpdate != null)
511522 ReceivedServiceUpdate(this, new EventArgs<UpdateType, string>(type, update));
512523 }
513524
@@ -517,7 +528,7 @@ namespace GSF.ServiceProcess · 3 unmodified lines
517528 /// <param name="response"><see cref="ServiceResponse"/> received.</param>
518529 protected virtual void OnReceivedServiceResponse(ServiceResponse response)
519530 {
520− if (ReceivedServiceResponse != null)
531+ if ((object)ReceivedServiceResponse != null)
521532 ReceivedServiceResponse(this, new EventArgs<ServiceResponse>(response));
522533 }
523534
@@ -527,7 +538,7 @@ namespace GSF.ServiceProcess · 3 unmodified lines
527538 /// <param name="state">New <see cref="ServiceState"/>.</param>
528539 protected virtual void OnServiceStateChanged(ObjectState<ServiceState> state)
529540 {
530− if (ServiceStateChanged != null)
541+ if ((object)ServiceStateChanged != null)
531542 ServiceStateChanged(this, new EventArgs<ObjectState<ServiceState>>(state));
532543 }
533544
@@ -537,7 +548,7 @@ namespace GSF.ServiceProcess · 3 unmodified lines
537548 /// <param name="state">New <see cref="ServiceProcessState"/>.</param>
538549 protected virtual void OnProcessStateChanged(ObjectState<ServiceProcessState> state)
539550 {
540− if (ProcessStateChanged != null)
551+ if ((object)ProcessStateChanged != null)
541552 ProcessStateChanged(this, new EventArgs<ObjectState<ServiceProcessState>>(state));
542553 }
543554
@@ -546,7 +557,7 @@ namespace GSF.ServiceProcess · 2 unmodified lines
546557 /// </summary>
547558 protected virtual void OnAuthenticationSuccess()
548559 {
549− if (AuthenticationSuccess != null)
560+ if ((object)AuthenticationSuccess != null)
550561 AuthenticationSuccess(this, EventArgs.Empty);
551562
552563 m_authenticationComplete = true;
@@ -559,7 +570,7 @@ namespace GSF.ServiceProcess · 6 unmodified lines
559570 {
560571 CancelEventArgs args = new CancelEventArgs(true);
561572
562− if (AuthenticationFailure != null)
573+ if ((object)AuthenticationFailure != null)
563574 AuthenticationFailure(this, args);
564575
565576 // Continue connection attempts if requested.
@@ -575,7 +586,7 @@ namespace GSF.ServiceProcess · 9 unmodified lines
575586 /// </summary>
576587 protected virtual void OnTelnetSessionEstablished()
577588 {
578− if (TelnetSessionEstablished != null)
589+ if ((object)TelnetSessionEstablished != null)
579590 TelnetSessionEstablished(this, EventArgs.Empty);
580591 }
581592
@@ -584,7 +595,7 @@ namespace GSF.ServiceProcess · 2 unmodified lines
584595 /// </summary>
585596 protected virtual void OnTelnetSessionTerminated()
586597 {
587− if (TelnetSessionTerminated != null)
598+ if ((object)TelnetSessionTerminated != null)
588599 TelnetSessionTerminated(this, EventArgs.Empty);
589600 }
590601
@@ -701,7 +712,7 @@ namespace GSF.ServiceProcess · 110 unmodified lines
701712 {
702713 ObjectState<ServiceState> state = response.Attachments[0] as ObjectState<ServiceState>;
703714
704− if (state != null)
715+ if ((object)state != null)
705716 {
706717 // Notify change in service state by raising an event.
707718 OnServiceStateChanged(state);
@@ -725,7 +736,7 @@ namespace GSF.ServiceProcess · 17 unmodified lines
725736 {
726737 ObjectState<ServiceProcessState> state = response.Attachments[0] as ObjectState<ServiceProcessState>;
727738
728− if (state != null)
739+ if ((object)state != null)
729740 {
730741 // Notify change in process state by raising an event.
731742 OnProcessStateChanged(state);
@@ -807,7 +818,7 @@ namespace GSF.ServiceProcess · 75 unmodified lines
807818 if (parts.Length > 1)
808819 {
809820 sourceCommand = parts[0].Trim().ToTitleCase();
810− responseSuccess = (string.Compare(parts[1].Trim(), "Success", true) == 0);
821+ responseSuccess = (string.Compare(parts[1].Trim(), "Success", StringComparison.OrdinalIgnoreCase) == 0);
811822 parseSucceeded = true;
812823 }
813824 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t